From 936ac37a298427c29eb57f273f95c7b18b6a43c5 Mon Sep 17 00:00:00 2001 From: ForgeStove Date: Sat, 8 Mar 2025 03:18:01 +0800 Subject: [PATCH 1/3] Fixed FactoryPanelBlock.java Fixed players not being able to place factory_gauge in the same location when holding down the Shift key --- .../content/logistics/factoryBoard/FactoryPanelBlock.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBlock.java b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBlock.java index 23b4280894..1a487cd6f8 100644 --- a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBlock.java +++ b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBlock.java @@ -292,8 +292,6 @@ public int getDirectSignal(BlockState pBlockState, BlockGetter pBlockAccess, Blo @Override public boolean canBeReplaced(BlockState pState, BlockPlaceContext pUseContext) { - if (pUseContext.isSecondaryUseActive()) - return false; if (!AllBlocks.FACTORY_GAUGE.isIn(pUseContext.getItemInHand())) return false; Vec3 location = pUseContext.getClickLocation(); From 6a9a6f0e42b3c13766b63375bfc7c3f4cec2a803 Mon Sep 17 00:00:00 2001 From: ForgeStove Date: Sat, 8 Mar 2025 12:34:28 +0800 Subject: [PATCH 2/3] Allow player to clear the link when Shift + Right-click --- .../LogisticallyLinkedBlockItem.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java index 108cea68a2..1fe4881aad 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java @@ -3,6 +3,11 @@ import java.util.List; import java.util.UUID; +import net.minecraft.client.Minecraft; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.phys.HitResult.Type; + import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,6 +72,18 @@ public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext to .addTo(tooltipComponents); } + public InteractionResultHolder use(Level level, Player player, InteractionHand usedHand) { + ItemStack itemstack = player.getItemInHand(usedHand); + Minecraft mc = Minecraft.getInstance(); + if (!itemstack.getComponents().has(DataComponents.BLOCK_ENTITY_DATA)) + return InteractionResultHolder.fail(itemstack); + if (player.isShiftKeyDown() && (mc.hitResult == null || mc.hitResult.getType() == Type.MISS)) { + itemstack.remove(DataComponents.BLOCK_ENTITY_DATA); + return InteractionResultHolder.success(itemstack); + } + return InteractionResultHolder.pass(itemstack); + } + @Override public @NotNull InteractionResult useOn(UseOnContext pContext) { ItemStack stack = pContext.getItemInHand(); From d4e7f0582154db4b7cfc927952458c247bb8a2cf Mon Sep 17 00:00:00 2001 From: ForgeStove Date: Sun, 9 Mar 2025 03:50:29 +0800 Subject: [PATCH 3/3] fix server issue --- .../LogisticallyLinkedBlockItem.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java index 1fe4881aad..444cb2b965 100644 --- a/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java +++ b/src/main/java/com/simibubi/create/content/logistics/packagerLink/LogisticallyLinkedBlockItem.java @@ -1,13 +1,7 @@ package com.simibubi.create.content.logistics.packagerLink; - import java.util.List; import java.util.UUID; -import net.minecraft.client.Minecraft; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.phys.HitResult.Type; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,16 +14,21 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; 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.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext.Fluid; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult.Type; public class LogisticallyLinkedBlockItem extends BlockItem { @@ -74,14 +73,13 @@ public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext to public InteractionResultHolder use(Level level, Player player, InteractionHand usedHand) { ItemStack itemstack = player.getItemInHand(usedHand); - Minecraft mc = Minecraft.getInstance(); + if (level.isClientSide) return InteractionResultHolder.pass(itemstack); + BlockHitResult hitResult = getPlayerPOVHitResult(level, player, Fluid.NONE); if (!itemstack.getComponents().has(DataComponents.BLOCK_ENTITY_DATA)) return InteractionResultHolder.fail(itemstack); - if (player.isShiftKeyDown() && (mc.hitResult == null || mc.hitResult.getType() == Type.MISS)) { + if (player.isShiftKeyDown() && hitResult.getType() == Type.MISS) itemstack.remove(DataComponents.BLOCK_ENTITY_DATA); - return InteractionResultHolder.success(itemstack); - } - return InteractionResultHolder.pass(itemstack); + return InteractionResultHolder.success(itemstack); } @Override