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(); 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..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,5 +1,4 @@ package com.simibubi.create.content.logistics.packagerLink; - import java.util.List; import java.util.UUID; @@ -15,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 { @@ -67,6 +71,17 @@ 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); + 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() && hitResult.getType() == Type.MISS) + itemstack.remove(DataComponents.BLOCK_ENTITY_DATA); + return InteractionResultHolder.success(itemstack); + } + @Override public @NotNull InteractionResult useOn(UseOnContext pContext) { ItemStack stack = pContext.getItemInHand();