Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed FactoryPanelBlock.java. Feature LogisticallyLinkedBlockItem.java #7814

Open
wants to merge 3 commits into
base: mc1.21.1/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -67,6 +72,18 @@ public void appendHoverText(@NotNull ItemStack stack, @NotNull TooltipContext to
.addTo(tooltipComponents);
}

public InteractionResultHolder<ItemStack> 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();
Expand Down