Skip to content

Commit 6090a36

Browse files
committed
Blacklist Powah reactors (See #30)
1 parent 586333a commit 6090a36

File tree

11 files changed

+72
-16
lines changed

11 files changed

+72
-16
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// 1.21.1 2025-07-30T15:49:15.2921749 Languages: en_us for mod: constructionstick
2-
c5c9a78fed5f55fca5b05d90bfc82ac8bfb8e485 assets/constructionstick/lang/en_us.json
1+
// 1.21.1 2025-08-21T22:08:32.5174061 Languages: en_us for mod: constructionstick
2+
2af93d3a8c497b282848be9fea6e76faae0b7c25 assets/constructionstick/lang/en_us.json
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
// 1.21.1 2025-07-30T15:49:15.2905346 Tags for minecraft:block mod id constructionstick
2-
38e56b0c7a9b7ebd8fb023611ecd6a294522d593 data/constructionstick/tags/block/non_replaceable.json
1+
// 1.21.1 2025-08-21T22:03:41.9153427 Tags for minecraft:block mod id constructionstick
2+
2d1693d4919223ef0412681455fe4bb4ffe47427 data/constructionstick/tags/block/non_placable.json
3+
9316959fd98ff5cd9c5d551a2d078d0e8dcc2401 data/constructionstick/tags/block/non_replaceable.json

src/generated/resources/assets/constructionstick/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"constructionstick.option.upgrades.constructionstick:upgrade_replacement.desc": "Replaces blocks with the block in your offhand",
116116
"constructionstick.option.upgrades.constructionstick:upgrade_unbreakable": "§dUnbreakable",
117117
"constructionstick.option.upgrades.constructionstick:upgrade_unbreakable.desc": "Allows placing without using durability",
118+
"constructionstick.placement.denied": "This block cannot be placed with the Construction Stick!",
118119
"constructionstick.tooltip.blocks": "Max. %d blocks",
119120
"constructionstick.tooltip.shift": "Press [SHIFT]",
120121
"constructionstick.tooltip.storage": "%s/%s RF stored",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"values": [
3+
{
4+
"id": "powah:reactor_starter",
5+
"required": false
6+
},
7+
{
8+
"id": "powah:reactor_basic",
9+
"required": false
10+
},
11+
{
12+
"id": "powah:reactor_hardened",
13+
"required": false
14+
},
15+
{
16+
"id": "powah:reactor_blazing",
17+
"required": false
18+
},
19+
{
20+
"id": "powah:reactor_niotic",
21+
"required": false
22+
},
23+
{
24+
"id": "powah:reactor_spirited",
25+
"required": false
26+
},
27+
{
28+
"id": "powah:reactor_nitro",
29+
"required": false
30+
}
31+
]
32+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"values": [
3-
"#c:relocation_not_supported"
3+
"#c:relocation_not_supported",
4+
"#constructionstick:non_placable"
45
]
56
}

src/main/java/mrbysco/constructionstick/basics/ModTags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ public class ModTags {
1111
public static final TagKey<Item> CONSTRUCTION_STICKS = ItemTags.create(ConstructionStick.modLoc("construction_sticks"));
1212

1313
public static final TagKey<Block> NON_REPLACEABLE = BlockTags.create(ConstructionStick.modLoc("non_replaceable"));
14+
public static final TagKey<Block> NON_PLACABLE = BlockTags.create(ConstructionStick.modLoc("non_placable"));
1415
}

src/main/java/mrbysco/constructionstick/basics/StickUtil.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import mrbysco.constructionstick.containers.ContainerManager;
88
import mrbysco.constructionstick.items.stick.ItemStick;
99
import mrbysco.constructionstick.stick.StickItemUseContext;
10+
import net.minecraft.ChatFormatting;
1011
import net.minecraft.core.BlockPos;
1112
import net.minecraft.core.Direction;
1213
import net.minecraft.core.registries.BuiltInRegistries;
14+
import net.minecraft.network.chat.Component;
1315
import net.minecraft.resources.ResourceLocation;
1416
import net.minecraft.stats.Stats;
1517
import net.minecraft.world.InteractionHand;
@@ -109,6 +111,11 @@ public static boolean isTEAllowed(BlockState state) {
109111

110112
public static boolean placeBlock(Level level, Player player, BlockState block, BlockPos pos, @Nullable BlockItem item) {
111113
// Remove block if placeEvent is canceled
114+
if (block.is(ModTags.NON_PLACABLE)) {
115+
player.sendSystemMessage(Component.translatable("constructionstick.placement.denied").withStyle(ChatFormatting.RED));
116+
return false; // Block is blacklisted for placement
117+
}
118+
112119
BlockSnapshot snapshot = BlockSnapshot.create(level.dimension(), level, pos);
113120
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, block, player);
114121
NeoForge.EVENT_BUS.post(placeEvent);
@@ -240,10 +247,11 @@ public static boolean isBlockRemovable(Level level, Player player, BlockPos pos)
240247
public static boolean isBlockReplaceable(Level level, Player player, BlockPos pos) {
241248
if (!isPositionModifiable(level, player, pos)) return false;
242249

243-
if (level.getBlockState(pos).is(ModTags.NON_REPLACEABLE)) return false;
250+
BlockState state = level.getBlockState(pos);
251+
if (state.is(ModTags.NON_REPLACEABLE)) return false;
244252

245253
if (!player.isCreative()) {
246-
return !(level.getBlockState(pos).getDestroySpeed(level, pos) <= -1) && level.getBlockEntity(pos) == null;
254+
return !(state.getDestroySpeed(level, pos) <= -1) && level.getBlockEntity(pos) == null;
247255
}
248256
return true;
249257
}

src/main/java/mrbysco/constructionstick/data/client/LanguageGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package mrbysco.constructionstick.data.client;
22

33
import mrbysco.constructionstick.ConstructionStick;
4-
import mrbysco.constructionstick.items.stick.ItemStick;
54
import mrbysco.constructionstick.registry.ModItems;
65
import net.minecraft.data.PackOutput;
76
import net.neoforged.neoforge.common.data.LanguageProvider;
8-
import net.neoforged.neoforge.registries.DeferredItem;
97
import org.jetbrains.annotations.Nullable;
108

119
public class LanguageGenerator extends LanguageProvider {
@@ -106,6 +104,8 @@ protected void addTranslations() {
106104
add("constructionstick.networking.stick_option.undo", "Failed to change stick option: %s");
107105
add("constructionstick.networking.undo_blocks.failed", "Failed to undo blocks: %s");
108106

107+
add("constructionstick.placement.denied", "This block cannot be placed with the Construction Stick!");
108+
109109
add("constructionstick.alias.emi.construction", "Construction");
110110
add("constructionstick.alias.emi.wand", "Wand");
111111
add("constructionstick.alias.emi.construction_wand", "Construction Wand");

src/main/java/mrbysco/constructionstick/data/server/BlockTagsGenerator.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import mrbysco.constructionstick.basics.ModTags;
55
import net.minecraft.core.HolderLookup.Provider;
66
import net.minecraft.data.PackOutput;
7+
import net.minecraft.resources.ResourceLocation;
78
import net.neoforged.neoforge.common.Tags;
89
import net.neoforged.neoforge.common.data.BlockTagsProvider;
910
import net.neoforged.neoforge.common.data.ExistingFileHelper;
1011

12+
import java.util.List;
1113
import java.util.concurrent.CompletableFuture;
1214

1315
public class BlockTagsGenerator extends BlockTagsProvider {
@@ -17,6 +19,22 @@ public BlockTagsGenerator(PackOutput output, CompletableFuture<Provider> lookupP
1719

1820
@Override
1921
protected void addTags(Provider provider) {
20-
this.tag(ModTags.NON_REPLACEABLE).addTag(Tags.Blocks.RELOCATION_NOT_SUPPORTED);
22+
this.tag(ModTags.NON_REPLACEABLE).addTag(Tags.Blocks.RELOCATION_NOT_SUPPORTED).addTag(ModTags.NON_PLACABLE);
23+
24+
var tagAppender = this.tag(ModTags.NON_PLACABLE);
25+
List<ResourceLocation> reactors = List.of(
26+
modLoc("powah", "reactor_starter"),
27+
modLoc("powah", "reactor_basic"),
28+
modLoc("powah", "reactor_hardened"),
29+
modLoc("powah", "reactor_blazing"),
30+
modLoc("powah", "reactor_niotic"),
31+
modLoc("powah", "reactor_spirited"),
32+
modLoc("powah", "reactor_nitro")
33+
);
34+
reactors.forEach(tagAppender::addOptional);
35+
}
36+
37+
private ResourceLocation modLoc(String modID, String path) {
38+
return net.minecraft.resources.ResourceLocation.fromNamespaceAndPath(modID, path);
2139
}
2240
}

src/main/java/mrbysco/constructionstick/stick/undo/PlaceSnapshot.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ private static BlockState getPlaceBlockstate(Level level, Player player, BlockHi
9393
// Is block at pos replaceable?
9494
BlockPlaceContext ctx = new StickItemUseContext(level, player, blockHitResult, pos, item);
9595
if (!ctx.canPlace()) return null;
96-
9796
// Can block be placed?
9897
BlockState blockState = item.getBlock().getStateForPlacement(ctx);
9998
if (blockState == null || !blockState.canSurvive(level, pos)) return null;

0 commit comments

Comments
 (0)