From 031cfe9bfbe600d1f502f9cbf1fb5c876908916c Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Mon, 19 Aug 2024 11:28:33 +0200 Subject: [PATCH] feat: improve wire behaviour - allow removing specific wires by using the wire item again on both endpoints - add a tooltip specifying if the wire is currently linked to an endpoint - allow to unlink the wire item - make wire show its connection point in-world --- .../c622617f6fabf890a00b9275cd5f643584a8a2c8 | 4 +- .../resources/assets/theurgy/lang/en_us.json | 5 +- .../java/com/klikli_dev/theurgy/Theurgy.java | 11 +- .../klikli_dev/theurgy/TheurgyConstants.java | 1 + .../theurgy/content/item/wire/WireItem.java | 100 +++++++++++++++++- .../book/logistics/MercurialWireEntry.java | 3 + .../theurgy/datagen/lang/ENUSProvider.java | 13 +++ .../datagen/lang/TooltipLanguageProvider.java | 9 ++ .../theurgy/logistics/LogisticsNetwork.java | 2 +- .../klikli_dev/theurgy/logistics/Wire.java | 7 +- .../theurgy/logistics/WireEndPoint.java | 3 +- .../klikli_dev/theurgy/logistics/Wires.java | 85 +++++++++++---- 12 files changed, 207 insertions(+), 36 deletions(-) diff --git a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index 7954244d2..3634faa84 100644 --- a/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.21.1 2024-08-18T11:12:57.321193 Languages: en_us -d4bf9645b2f50d984c242c57413b237136206f89 assets/theurgy/lang/en_us.json +// 1.21.1 2024-08-19T12:28:56.1332157 Languages: en_us +e2fce6be6f36a4edf044502cca8f6cc9c723ed2b assets/theurgy/lang/en_us.json diff --git a/src/generated/resources/assets/theurgy/lang/en_us.json b/src/generated/resources/assets/theurgy/lang/en_us.json index 678176193..69f9cd9a6 100644 --- a/src/generated/resources/assets/theurgy/lang/en_us.json +++ b/src/generated/resources/assets/theurgy/lang/en_us.json @@ -832,7 +832,7 @@ "book.theurgy.the_hermetica.logistics.mercurial_wand.usage.title": "Usage", "book.theurgy.the_hermetica.logistics.mercurial_wire.description": "Item-Over-Wire Transport", "book.theurgy.the_hermetica.logistics.mercurial_wire.name": "Mercurial Wire", - "book.theurgy.the_hermetica.logistics.mercurial_wire.removal.text": "To remove a wire, break one of the blocks the wire is connected to.\n", + "book.theurgy.the_hermetica.logistics.mercurial_wire.removal.text": "To remove a wire, break one of the blocks the wire is connected to.\n\\\n\\\nAlternatively, click both blocks connected by the wire with the wire item once more to remove just the one wire.\n", "book.theurgy.the_hermetica.logistics.mercurial_wire.removal.title": "Removing Wires", "book.theurgy.the_hermetica.logistics.mercurial_wire.usage.text": "Right-click one block, then right-click another block to connect them with the wire.\n\\\n\\\nOnly mercurial logistics blocks, such as inserters, extractors or connection nodes, can be connected with wires.\n", "book.theurgy.the_hermetica.logistics.mercurial_wire.usage.title": "Usage", @@ -2395,8 +2395,9 @@ "item.theurgy.attribute_filter.tooltip.usage": "§aRight-Click§r§7 the air to open the filter GUI and add items.\n§aRight-Click§r§7 a logistics inserter or extractor to apply the filter.\n§aRight-Click§r§7 a filtered block with an empty hand to remove the filter.\n", "item.theurgy.copper_wire": "Mercurial Copper Wire", "item.theurgy.copper_wire.tooltip": "A piece of copper wire capable of transferring matter in its mercurial form.", + "item.theurgy.copper_wire.tooltip.dynamic": "Linked to %1$s (Highlighted in yellow in the world).\n\n§aRight-Click§r§7 another connector block to create wire connection.\n§aShift-Right-Click§r§7 the air or a non-connector block to unlink.\n§aRight-Click§r§7 another connector block already wired to %1$s to remove the wire.\n", "item.theurgy.copper_wire.tooltip.extended": "Can be used to connect different parts of Mercurial Logistics Networks.", - "item.theurgy.copper_wire.tooltip.usage": "Right-click one connector, then right-click another connector to connect them with the wire.\n", + "item.theurgy.copper_wire.tooltip.usage": "Right-click one connector, then right-click another connector to connect them with the wire.\nRepeat the process to disconnect them.\n", "item.theurgy.crystallized_lava": "Crystallized Lava", "item.theurgy.crystallized_lava.tooltip": "Lava in solid form for easy transportation, and alchemical processing.", "item.theurgy.crystallized_water": "Crystallized Water", diff --git a/src/main/java/com/klikli_dev/theurgy/Theurgy.java b/src/main/java/com/klikli_dev/theurgy/Theurgy.java index b0f6caccb..0f7af53ca 100644 --- a/src/main/java/com/klikli_dev/theurgy/Theurgy.java +++ b/src/main/java/com/klikli_dev/theurgy/Theurgy.java @@ -30,6 +30,7 @@ import com.klikli_dev.theurgy.content.item.derivative.AlchemicalDerivativeItem; import com.klikli_dev.theurgy.content.item.sulfur.AlchemicalSulfurItem; import com.klikli_dev.theurgy.content.item.derivative.render.AlchemicalDerivativeBEWLR; +import com.klikli_dev.theurgy.content.item.wire.WireItem; import com.klikli_dev.theurgy.content.render.*; import com.klikli_dev.theurgy.content.render.itemhud.ItemHUD; import com.klikli_dev.theurgy.content.render.outliner.Outliner; @@ -54,6 +55,7 @@ import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.phys.Vec3; import net.neoforged.api.distmarker.Dist; @@ -203,9 +205,14 @@ public static void onClientTick(ClientTickEvent.Post event) { if (Minecraft.getInstance().level == null || Minecraft.getInstance().player == null) return; + Player player = Minecraft.getInstance().player; + Outliner.get().tick(); - BlockRegistry.CALORIC_FLUX_EMITTER.get().selectionBehaviour().tick(Minecraft.getInstance().player); - BlockRegistry.SULFURIC_FLUX_EMITTER.get().selectionBehaviour().tick(Minecraft.getInstance().player); + BlockRegistry.CALORIC_FLUX_EMITTER.get().selectionBehaviour().tick(player); + BlockRegistry.SULFURIC_FLUX_EMITTER.get().selectionBehaviour().tick(player); + + + WireItem.onClientTick(player); } public static void onRenderLevelStage(RenderLevelStageEvent event) { diff --git a/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java b/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java index b7a055929..e6785a1e0 100644 --- a/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java +++ b/src/main/java/com/klikli_dev/theurgy/TheurgyConstants.java @@ -58,6 +58,7 @@ public static class Tooltip { public static final String SUFFIX = ".tooltip"; public static final String EXTENDED_SUFFIX = ".tooltip.extended"; public static final String USAGE_SUFFIX = ".tooltip.usage"; + public static final String DYNMIC_SUFFIX = ".tooltip.dynamic"; private static final String PREFIX = "tooltip." + Theurgy.MODID + "."; public static final String DIVINATION_ROD_LINKED_TO = PREFIX + ".divination_rod.linked_to"; public static final String DIVINATION_ROD_NO_LINK = PREFIX + ".divination_rod.no_link"; diff --git a/src/main/java/com/klikli_dev/theurgy/content/item/wire/WireItem.java b/src/main/java/com/klikli_dev/theurgy/content/item/wire/WireItem.java index 80b5913af..646857ce2 100644 --- a/src/main/java/com/klikli_dev/theurgy/content/item/wire/WireItem.java +++ b/src/main/java/com/klikli_dev/theurgy/content/item/wire/WireItem.java @@ -4,41 +4,114 @@ package com.klikli_dev.theurgy.content.item.wire; +import com.klikli_dev.theurgy.TheurgyConstants; import com.klikli_dev.theurgy.content.behaviour.logistics.HasLeafNodeBehaviour; import com.klikli_dev.theurgy.content.behaviour.logistics.HasWireEndPoint; +import com.klikli_dev.theurgy.content.render.Color; +import com.klikli_dev.theurgy.content.render.outliner.Outliner; import com.klikli_dev.theurgy.logistics.Logistics; import com.klikli_dev.theurgy.logistics.Wire; import com.klikli_dev.theurgy.logistics.WireEndPoint; import com.klikli_dev.theurgy.logistics.Wires; +import net.minecraft.ChatFormatting; import net.minecraft.core.GlobalPos; +import net.minecraft.network.chat.Component; +import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.shapes.Shapes; +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.Objects; public class WireItem extends Item { private final int maxRange; + public WireItem(Properties pProperties, int maxRange) { super(pProperties); this.maxRange = maxRange; } + public static void onClientTick(Player player) { + var stack = player.getMainHandItem(); + if (!(stack.getItem() instanceof WireItem)) + return; + + var wirePoint = WireEndPoint.load(stack); + if (wirePoint == null || wirePoint.level() != player.level().dimension()) + return; + + Outliner.get().showAABB(wirePoint, + Shapes.block().bounds().move(wirePoint.pos()), 1).colored(Color.YELLOW).lineWidth(1 / 32f); + } + @Override - public InteractionResult useOn(UseOnContext pContext) { + public @NotNull InteractionResult useOn(UseOnContext pContext) { var stack = pContext.getItemInHand(); + //TODO: wires do not exist on client wire cache (only render cache) + // so when we check for getWire we get null -> and thus we may return the wrong interactionresult and never run the serverside logkc + if (!this.isWireEndPoint(pContext)) { + if (Objects.requireNonNull(pContext.getPlayer()).isShiftKeyDown()) { + WireEndPoint.removeFrom(stack); + return InteractionResult.SUCCESS; + } return InteractionResult.FAIL; } var wirePoint = WireEndPoint.load(stack); + if (wirePoint != null) { - return this.connectWire(pContext, wirePoint); + var existingWire = this.getWire(pContext, wirePoint); + if (existingWire != null) { + return this.disconnectWire(pContext, existingWire); + } else { + return this.connectWire(pContext, wirePoint); + } } else { return this.storeWireEndPoint(pContext); } } + @Override + public @NotNull InteractionResultHolder use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand usedHand) { + if (usedHand == InteractionHand.MAIN_HAND && player.isShiftKeyDown()) { + WireEndPoint.removeFrom(player.getMainHandItem()); + return InteractionResultHolder.sidedSuccess(player.getMainHandItem(), level.isClientSide()); + } + + return super.use(level, player, usedHand); + } + + @Override + public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext context, @NotNull List tooltipComponents, @NotNull TooltipFlag tooltipFlag) { + super.appendHoverText(stack, context, tooltipComponents, tooltipFlag); + + var wirePoint = WireEndPoint.load(stack); + if (wirePoint != null) { + tooltipComponents.add(Component.translatable( + stack.getDescriptionId() + TheurgyConstants.I18n.Tooltip.DYNMIC_SUFFIX, + Component.literal("[" + wirePoint.pos().toShortString() + "]").withStyle(ChatFormatting.GREEN) + ).withStyle(ChatFormatting.GRAY)); + } + } + + protected Wire getWire(UseOnContext pContext, WireEndPoint wireEndPoint) { + if (wireEndPoint.level() != pContext.getLevel().dimension()) + return null; //theoretically we could have a wire in place in the same spot in another dimension + + return Wires.get(pContext.getLevel()).getWire(wireEndPoint.pos(), pContext.getClickedPos()); + } + protected boolean isWireEndPoint(UseOnContext pContext) { var level = pContext.getLevel(); var pos = pContext.getClickedPos(); @@ -60,7 +133,7 @@ protected InteractionResult connectWire(UseOnContext pContext, WireEndPoint wire var stack = pContext.getItemInHand(); WireEndPoint.removeFrom(stack); - if (!pContext.getPlayer().getAbilities().instabuild) { + if (!Objects.requireNonNull(pContext.getPlayer()).getAbilities().instabuild) { stack.shrink(1); } @@ -85,6 +158,27 @@ protected InteractionResult connectWire(UseOnContext pContext, WireEndPoint wire return InteractionResult.SUCCESS; } + protected InteractionResult disconnectWire(UseOnContext pContext, Wire wire) { + var stack = pContext.getItemInHand(); + + WireEndPoint.removeFrom(stack); //removing the wire should also remove the stored wire endpoint, otherwise our next click creates a new wire from the start of this old wire. + + if (!Objects.requireNonNull(pContext.getPlayer()).getAbilities().instabuild) { + stack.grow(1); //return the wire item + } + + var level = pContext.getLevel(); + + Wires.get(level).removeWire(wire); + if (!level.isClientSide) { + var posA = GlobalPos.of(level.dimension(), wire.from()); + var posB = GlobalPos.of(level.dimension(), wire.to()); + Logistics.get().remove(posA, posB); + } + + return InteractionResult.SUCCESS; + } + protected InteractionResult storeWireEndPoint(UseOnContext pContext) { var stack = pContext.getItemInHand(); diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/book/logistics/MercurialWireEntry.java b/src/main/java/com/klikli_dev/theurgy/datagen/book/logistics/MercurialWireEntry.java index 95a9948b2..3b5b222bf 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/book/logistics/MercurialWireEntry.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/book/logistics/MercurialWireEntry.java @@ -52,6 +52,9 @@ protected void generatePages() { this.pageTitle("Removing Wires"); this.pageText(""" To remove a wire, break one of the blocks the wire is connected to. + \\ + \\ + Alternatively, click both blocks connected by the wire with the wire item once more to remove just the one wire. """ ); } diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java b/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java index 4c77f6fcb..74791d55f 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/lang/ENUSProvider.java @@ -1088,8 +1088,21 @@ private void addItems() { "Can be used to connect different parts of Mercurial Logistics Networks.", """ Right-click one connector, then right-click another connector to connect them with the wire. + Repeat the process to disconnect them. """ ); + this.addDynamicTooltip(ItemRegistry.COPPER_WIRE, + this.f(""" + Linked to %1$s (Highlighted in yellow in the world). + + {0} another connector block to create wire connection. + {1} the air or a non-connector block to unlink. + {0} another connector block already wired to %1$s to remove the wire. + """, + this.green("Right-Click"), + this.green("Shift-Right-Click") + ) + ); this.addItem(ItemRegistry.MERCURIAL_WAND, "Mercurial Wand"); var wandUsage = this.f(""" diff --git a/src/main/java/com/klikli_dev/theurgy/datagen/lang/TooltipLanguageProvider.java b/src/main/java/com/klikli_dev/theurgy/datagen/lang/TooltipLanguageProvider.java index 29c4363c9..8280c866a 100644 --- a/src/main/java/com/klikli_dev/theurgy/datagen/lang/TooltipLanguageProvider.java +++ b/src/main/java/com/klikli_dev/theurgy/datagen/lang/TooltipLanguageProvider.java @@ -40,4 +40,13 @@ default void addExtendedTooltip(Supplier key, String extendedToo default void addUsageTooltip(Supplier key, String usageTooltip) { this.addTooltip(key, null, null, usageTooltip); } + + default void addDynamicTooltip(Supplier key, String tooltip) { + this.addDynamicTooltip(key, "", tooltip); + } + + default void addDynamicTooltip(Supplier key, String keySuffix, String tooltip) { + if (tooltip != null) + this.add(key.get().getDescriptionId() + TheurgyConstants.I18n.Tooltip.DYNMIC_SUFFIX + keySuffix, tooltip); + } } diff --git a/src/main/java/com/klikli_dev/theurgy/logistics/LogisticsNetwork.java b/src/main/java/com/klikli_dev/theurgy/logistics/LogisticsNetwork.java index 85c6a0b9d..939b42a5b 100644 --- a/src/main/java/com/klikli_dev/theurgy/logistics/LogisticsNetwork.java +++ b/src/main/java/com/klikli_dev/theurgy/logistics/LogisticsNetwork.java @@ -269,7 +269,7 @@ public void rebuildCaches() { this.onUnloadExtractNode(node.asExtractor()); } if (node.mode() == LeafNodeMode.INSERT) { - //no need to call unload here as it just notifies the extractors, which we reset anyay + //no need to call unload here as it just notifies the extractors, which we reset anyway //this.onUnloadInsertNode(node.asInserter()); } } diff --git a/src/main/java/com/klikli_dev/theurgy/logistics/Wire.java b/src/main/java/com/klikli_dev/theurgy/logistics/Wire.java index d3cbbed3d..b8c998330 100644 --- a/src/main/java/com/klikli_dev/theurgy/logistics/Wire.java +++ b/src/main/java/com/klikli_dev/theurgy/logistics/Wire.java @@ -4,14 +4,12 @@ package com.klikli_dev.theurgy.logistics; -import com.klikli_dev.modonomicon.networking.ClickCommandLinkMessage; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; public record Wire(BlockPos from, BlockPos to) { public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( @@ -27,6 +25,11 @@ public record Wire(BlockPos from, BlockPos to) { Wire::new ); + public Wire(BlockPos from, BlockPos to) { + this.from = from.immutable(); + this.to = to.immutable(); + } + public static Wire load(CompoundTag tag) { return new Wire(BlockPos.of(tag.getLong("from")), BlockPos.of(tag.getLong("to"))); } diff --git a/src/main/java/com/klikli_dev/theurgy/logistics/WireEndPoint.java b/src/main/java/com/klikli_dev/theurgy/logistics/WireEndPoint.java index 47603a507..0e9696524 100644 --- a/src/main/java/com/klikli_dev/theurgy/logistics/WireEndPoint.java +++ b/src/main/java/com/klikli_dev/theurgy/logistics/WireEndPoint.java @@ -17,6 +17,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; public record WireEndPoint(BlockPos pos, ResourceKey level) { @@ -39,7 +40,7 @@ public static WireEndPoint load(CompoundTag tag) { return new WireEndPoint(BlockPos.of(tag.getLong("pos")), ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(tag.getString("level")))); } - public static WireEndPoint load(ItemStack stack) { + public static @Nullable WireEndPoint load(ItemStack stack) { return stack.get(DataComponentRegistry.WIRE_END_POINT.get()); } diff --git a/src/main/java/com/klikli_dev/theurgy/logistics/Wires.java b/src/main/java/com/klikli_dev/theurgy/logistics/Wires.java index 41b92aafe..6dcdad392 100644 --- a/src/main/java/com/klikli_dev/theurgy/logistics/Wires.java +++ b/src/main/java/com/klikli_dev/theurgy/logistics/Wires.java @@ -22,11 +22,13 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.saveddata.SavedData; import net.neoforged.neoforge.event.level.LevelEvent; +import org.jetbrains.annotations.Nullable; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.Stream; public class Wires extends SavedData { @@ -73,7 +75,7 @@ public Wires(boolean isClient) { public Wires(Set wires, boolean isClient) { this(isClient); - if(!isClient){ + if (!isClient) { this.wires.addAll(wires); //restore chunkToWires and wiresToChunk and blockPosToWire @@ -90,27 +92,6 @@ public Wires(Set wires, boolean isClient) { } - /** - * Gets all wires connected to the given block pos - */ - public Set getWires(BlockPos pos){ - return this.blockPosToWire.get(pos); - } - - /** - * Gets all wires in a chunk - */ - public Set getWires(ChunkPos chunk){ - return this.chunkToWires.get(chunk); - } - - /** - * Gets all chunks a wire is in - */ - public Set getChunks(Wire wire){ - return this.wiresToChunk.get(wire); - } - public static Wires get(Level level) { if (level instanceof ServerLevel serverLevel) { if (cachedServerLevel.get() == level) { @@ -164,6 +145,64 @@ public static Wires load(CompoundTag pCompoundTag, HolderLookup.Provider pRegist return CODEC.parse(pRegistries.createSerializationContext(NbtOps.INSTANCE), pCompoundTag.get(NBT_TAG)).result().orElseThrow(); } + /** + * Gets all wires connected to the given block pos + */ + public Set getWires(BlockPos pos) { + if (this.isClient) + return this.getClientWires(pos); + + return this.blockPosToWire.get(pos); + } + + /** + * For item interactions with wires we may need to check if a wire exists return the correct interaction result. + * The client does not keep a high-performance full cache of the wires, so we have to search the full list in the renderer. + */ + public Set getClientWires(BlockPos pos) { + return WireRenderer.get().wires.stream().filter(wire -> wire.from().equals(pos) || wire.to().equals(pos)).collect(Collectors.toSet()); + } + + public @Nullable Wire getWire(BlockPos a, BlockPos b) { + if (this.isClient) + return this.getClientWire(a, b); + + var wires = this.getWires(a); + for (Wire wire : wires) { + if (wire.from().equals(a) && wire.to().equals(b) || wire.from().equals(b) && wire.to().equals(a)) { + return wire; + } + } + + return null; + } + + /** + * For item interactions with wires we may need to check if a wire exists return the correct interaction result. + * The client does not keep a high-performance full cache of the wires, so we have to search the full list in the renderer. + */ + private @Nullable Wire getClientWire(BlockPos a, BlockPos b) { + return WireRenderer.get().wires.stream().filter(wire -> wire.from().equals(a) && wire.to().equals(b) || wire.from().equals(b) && wire.to().equals(a)).findFirst().orElse(null); + } + + /** + * Gets all wires in a chunk + */ + public Set getWires(ChunkPos chunk) { + if(this.isClient) + throw new UnsupportedOperationException("Cannot get all wires in a chunk on the client"); + return this.chunkToWires.get(chunk); + } + + /** + * Gets all chunks a wire is in + */ + public Set getChunks(Wire wire) { + if(this.isClient) + throw new UnsupportedOperationException("Cannot get all chunks a wire is in on the client"); + return this.wiresToChunk.get(wire); + } + Stream calculateChunkPosForWire(Wire wire) { return Arrays.stream(WireSlackHelper.getInterpolatedPoints(wire.from().getCenter(), wire.to().getCenter())).map(pos -> new ChunkPos( SectionPos.blockToSectionCoord(pos.x()), @@ -194,7 +233,7 @@ public void addWire(Wire wire) { this.setDirty(); } - public int removeWiresFor(BlockPos pos){ + public int removeWiresFor(BlockPos pos) { var wires = this.getWires(pos); var copy = new ArrayList<>(wires); //removeWires modifies the underlying set so we can't iterate on it copy.forEach(this::removeWire);