Merge pull request #5656 from SFort/FixShiftConflict

Use appropriate method for sneaky players
This commit is contained in:
simibubi 2023-10-22 12:27:40 +02:00 committed by GitHub
commit 26c9af50a7
Failed to generate hash of commit
25 changed files with 27 additions and 27 deletions

View file

@ -58,7 +58,7 @@ public class PortableStorageInterfaceBlock extends WrenchableDirectionalBlock
public BlockState getStateForPlacement(BlockPlaceContext context) { public BlockState getStateForPlacement(BlockPlaceContext context) {
Direction direction = context.getNearestLookingDirection(); Direction direction = context.getNearestLookingDirection();
if (context.getPlayer() != null && context.getPlayer() if (context.getPlayer() != null && context.getPlayer()
.isSteppingCarefully()) .isShiftKeyDown())
direction = direction.getOpposite(); direction = direction.getOpposite();
return defaultBlockState().setValue(FACING, direction.getOpposite()); return defaultBlockState().setValue(FACING, direction.getOpposite());
} }

View file

@ -56,7 +56,7 @@ public class ControlsBlock extends HorizontalDirectionalBlock implements IWrench
Player player = pContext.getPlayer(); Player player = pContext.getPlayer();
state = state.setValue(FACING, horizontalDirection.getOpposite()); state = state.setValue(FACING, horizontalDirection.getOpposite());
if (player != null && player.isSteppingCarefully()) if (player != null && player.isShiftKeyDown())
state = state.setValue(FACING, horizontalDirection); state = state.setValue(FACING, horizontalDirection);
return state; return state;

View file

@ -121,7 +121,7 @@ public class SuperGlueSelectionHandler {
return; return;
} }
boolean cancel = player.isSteppingCarefully(); boolean cancel = player.isShiftKeyDown();
if (cancel && firstPos == null) if (cancel && firstPos == null)
return; return;
@ -201,7 +201,7 @@ public class SuperGlueSelectionHandler {
return true; return true;
} }
if (player.isSteppingCarefully()) { if (player.isShiftKeyDown()) {
if (firstPos != null) { if (firstPos != null) {
discard(); discard();
return true; return true;

View file

@ -316,7 +316,7 @@ public abstract class CopycatBlock extends Block implements IBE<CopycatBlockEnti
public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos,
Player player) { Player player) {
BlockState material = getMaterial(level, pos); BlockState material = getMaterial(level, pos);
if (AllBlocks.COPYCAT_BASE.has(material) || player != null && player.isSteppingCarefully()) if (AllBlocks.COPYCAT_BASE.has(material) || player != null && player.isShiftKeyDown())
return new ItemStack(this); return new ItemStack(this);
return material.getCloneItemStack(target, level, pos, player); return material.getCloneItemStack(target, level, pos, player);
} }

View file

@ -121,7 +121,7 @@ public class GirderBlock extends Block implements SimpleWaterloggedBlock, IWrenc
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }
if (AllItems.WRENCH.isIn(itemInHand) && !pPlayer.isSteppingCarefully()) { if (AllItems.WRENCH.isIn(itemInHand) && !pPlayer.isShiftKeyDown()) {
if (GirderWrenchBehavior.handleClick(pLevel, pPos, pState, pHit)) if (GirderWrenchBehavior.handleClick(pLevel, pPos, pState, pHit))
return InteractionResult.sidedSuccess(pLevel.isClientSide); return InteractionResult.sidedSuccess(pLevel.isClientSide);
return InteractionResult.FAIL; return InteractionResult.FAIL;

View file

@ -44,7 +44,7 @@ public class GirderWrenchBehavior {
Player player = mc.player; Player player = mc.player;
ItemStack heldItem = player.getMainHandItem(); ItemStack heldItem = player.getMainHandItem();
if (player.isSteppingCarefully()) if (player.isShiftKeyDown())
return; return;
if (!AllBlocks.METAL_GIRDER.has(world.getBlockState(pos))) if (!AllBlocks.METAL_GIRDER.has(world.getBlockState(pos)))

View file

@ -18,7 +18,7 @@ public class LayeredBlock extends RotatedPillarBlock {
.relative(pContext.getClickedFace() .relative(pContext.getClickedFace()
.getOpposite())); .getOpposite()));
if (placedOn.getBlock() == this && (pContext.getPlayer() == null || !pContext.getPlayer() if (placedOn.getBlock() == this && (pContext.getPlayer() == null || !pContext.getPlayer()
.isSteppingCarefully())) .isShiftKeyDown()))
stateForPlacement = stateForPlacement.setValue(AXIS, placedOn.getValue(AXIS)); stateForPlacement = stateForPlacement.setValue(AXIS, placedOn.getValue(AXIS));
return stateForPlacement; return stateForPlacement;
} }

View file

@ -87,7 +87,7 @@ public class ClipboardBlock extends FaceAttachedHorizontalDirectionalBlock
@Override @Override
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand,
BlockHitResult pHit) { BlockHitResult pHit) {
if (pPlayer.isSteppingCarefully()) { if (pPlayer.isShiftKeyDown()) {
breakAndCollect(pState, pLevel, pPos, pPlayer); breakAndCollect(pState, pLevel, pPos, pPlayer);
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }

View file

@ -34,7 +34,7 @@ public class ClipboardBlockItem extends BlockItem {
Player player = context.getPlayer(); Player player = context.getPlayer();
if (player == null) if (player == null)
return InteractionResult.PASS; return InteractionResult.PASS;
if (player.isSteppingCarefully()) if (player.isShiftKeyDown())
return super.useOn(context); return super.useOn(context);
return use(context.getLevel(), player, context.getHand()).getResult(); return use(context.getLevel(), player, context.getHand()).getResult();
} }

View file

@ -141,7 +141,7 @@ public class ClipboardValueSettingsHandler {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player != null && player.isSpectator()) if (player != null && player.isSpectator())
return; return;
if (player.isSteppingCarefully()) if (player.isShiftKeyDown())
return; return;
if (!(world.getBlockEntity(pos) instanceof SmartBlockEntity smartBE)) if (!(world.getBlockEntity(pos) instanceof SmartBlockEntity smartBE))
return; return;

View file

@ -132,7 +132,7 @@ public class PumpBlock extends DirectionalKineticBlock
return toPlace; return toPlace;
if (bestConnectedDirection.getAxis() == targetDirection.getAxis()) if (bestConnectedDirection.getAxis() == targetDirection.getAxis())
return toPlace; return toPlace;
if (player.isSteppingCarefully() && bestConnectedDirection.getAxis() != targetDirection.getAxis()) if (player.isShiftKeyDown() && bestConnectedDirection.getAxis() != targetDirection.getAxis())
return toPlace; return toPlace;
return toPlace.setValue(FACING, bestConnectedDirection); return toPlace.setValue(FACING, bestConnectedDirection);

View file

@ -66,7 +66,7 @@ public class ValveHandleBlock extends HandCrankBlock {
return; return;
if (!player.mayBuild()) if (!player.mayBuild())
return; return;
if (AllItems.WRENCH.isIn(player.getItemInHand(event.getHand())) && player.isSteppingCarefully()) if (AllItems.WRENCH.isIn(player.getItemInHand(event.getHand())) && player.isShiftKeyDown())
return; return;
if (vhb.clicked(level, pos, blockState, player, event.getHand())) { if (vhb.clicked(level, pos, blockState, player, event.getHand())) {
@ -94,7 +94,7 @@ public class ValveHandleBlock extends HandCrankBlock {
} }
onBlockEntityUse(level, pos, onBlockEntityUse(level, pos,
hcbe -> (hcbe instanceof ValveHandleBlockEntity vhbe) && vhbe.activate(player.isSteppingCarefully()) hcbe -> (hcbe instanceof ValveHandleBlockEntity vhbe) && vhbe.activate(player.isShiftKeyDown())
? InteractionResult.SUCCESS ? InteractionResult.SUCCESS
: InteractionResult.PASS); : InteractionResult.PASS);
return true; return true;

View file

@ -53,7 +53,7 @@ public class ItemVaultBlock extends Block implements IWrenchable, IBE<ItemVaultB
@Override @Override
public BlockState getStateForPlacement(BlockPlaceContext pContext) { public BlockState getStateForPlacement(BlockPlaceContext pContext) {
if (pContext.getPlayer() == null || !pContext.getPlayer() if (pContext.getPlayer() == null || !pContext.getPlayer()
.isSteppingCarefully()) { .isShiftKeyDown()) {
BlockState placedOn = pContext.getLevel() BlockState placedOn = pContext.getLevel()
.getBlockState(pContext.getClickedPos() .getBlockState(pContext.getClickedPos()
.relative(pContext.getClickedFace() .relative(pContext.getClickedFace()

View file

@ -54,7 +54,7 @@ public class ItemVaultItem extends BlockItem {
Player player = ctx.getPlayer(); Player player = ctx.getPlayer();
if (player == null) if (player == null)
return; return;
if (player.isSteppingCarefully()) if (player.isShiftKeyDown())
return; return;
Direction face = ctx.getClickedFace(); Direction face = ctx.getClickedFace();
ItemStack stack = ctx.getItemInHand(); ItemStack stack = ctx.getItemInHand();

View file

@ -35,7 +35,7 @@ public class ExperienceNuggetItem extends Item {
return InteractionResultHolder.consume(itemInHand); return InteractionResultHolder.consume(itemInHand);
} }
int amountUsed = pPlayer.isSteppingCarefully() ? 1 : itemInHand.getCount(); int amountUsed = pPlayer.isShiftKeyDown() ? 1 : itemInHand.getCount();
int total = Mth.ceil(3f * amountUsed); int total = Mth.ceil(3f * amountUsed);
int maxOrbs = amountUsed == 1 ? 1 : 5; int maxOrbs = amountUsed == 1 ? 1 : 5;
int valuePer = Math.max(1, 1 + total / maxOrbs); int valuePer = Math.max(1, 1 + total / maxOrbs);

View file

@ -139,7 +139,7 @@ public class DisplayLinkBlock extends WrenchableDirectionalBlock implements IBE<
BlockHitResult pHit) { BlockHitResult pHit) {
if (pPlayer == null) if (pPlayer == null)
return InteractionResult.PASS; return InteractionResult.PASS;
if (pPlayer.isSteppingCarefully()) if (pPlayer.isShiftKeyDown())
return InteractionResult.PASS; return InteractionResult.PASS;
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, DistExecutor.unsafeRunWhenOn(Dist.CLIENT,
() -> () -> withBlockEntityDo(pLevel, pPos, be -> this.displayScreen(be, pPlayer))); () -> () -> withBlockEntityDo(pLevel, pPos, be -> this.displayScreen(be, pPlayer)));

View file

@ -57,7 +57,7 @@ public class DisplayLinkBlockItem extends BlockItem {
if (player == null) if (player == null)
return InteractionResult.FAIL; return InteractionResult.FAIL;
if (player.isSteppingCarefully() && stack.hasTag()) { if (player.isShiftKeyDown() && stack.hasTag()) {
if (level.isClientSide) if (level.isClientSide)
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
player.displayClientMessage(Lang.translateDirect("display_link.clear"), true); player.displayClientMessage(Lang.translateDirect("display_link.clear"), true);

View file

@ -85,7 +85,7 @@ public class SmartObserverBlock extends DirectedDirectionalBlock implements IBE<
if (preferredFacing == null) { if (preferredFacing == null) {
Direction facing = context.getNearestLookingDirection(); Direction facing = context.getNearestLookingDirection();
preferredFacing = context.getPlayer() != null && context.getPlayer() preferredFacing = context.getPlayer() != null && context.getPlayer()
.isSteppingCarefully() ? facing : facing.getOpposite(); .isShiftKeyDown() ? facing : facing.getOpposite();
} }
if (preferredFacing.getAxis() == Axis.Y) { if (preferredFacing.getAxis() == Axis.Y) {

View file

@ -123,7 +123,7 @@ public class ThresholdSwitchBlock extends DirectedDirectionalBlock implements IB
if (preferredFacing == null) { if (preferredFacing == null) {
Direction facing = context.getNearestLookingDirection(); Direction facing = context.getNearestLookingDirection();
preferredFacing = context.getPlayer() != null && context.getPlayer() preferredFacing = context.getPlayer() != null && context.getPlayer()
.isSteppingCarefully() ? facing : facing.getOpposite(); .isShiftKeyDown() ? facing : facing.getOpposite();
} }
if (preferredFacing.getAxis() == Axis.Y) { if (preferredFacing.getAxis() == Axis.Y) {

View file

@ -83,7 +83,7 @@ public class TrainRelocator {
return; return;
if (!player.position() if (!player.position()
.closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) { .closerThan(relocatingOrigin, 24) || player.isShiftKeyDown()) {
relocatingTrain = null; relocatingTrain = null;
player.displayClientMessage(Lang.translateDirect("train.relocate.abort") player.displayClientMessage(Lang.translateDirect("train.relocate.abort")
.withStyle(ChatFormatting.RED), true); .withStyle(ChatFormatting.RED), true);

View file

@ -113,7 +113,7 @@ public class StationBlock extends Block implements IBE<StationBlockEntity>, IWre
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand,
BlockHitResult pHit) { BlockHitResult pHit) {
if (pPlayer == null || pPlayer.isSteppingCarefully()) if (pPlayer == null || pPlayer.isShiftKeyDown())
return InteractionResult.PASS; return InteractionResult.PASS;
ItemStack itemInHand = pPlayer.getItemInHand(pHand); ItemStack itemInHand = pPlayer.getItemInHand(pHand);
if (AllItems.WRENCH.isIn(itemInHand)) if (AllItems.WRENCH.isIn(itemInHand))

View file

@ -126,7 +126,7 @@ public class CurvedTrackInteraction {
player.swing(InteractionHand.MAIN_HAND); player.swing(InteractionHand.MAIN_HAND);
return true; return true;
} }
if (AllItems.WRENCH.isIn(heldItem) && player.isSteppingCarefully()) { if (AllItems.WRENCH.isIn(heldItem) && player.isShiftKeyDown()) {
AllPackets.getChannel().sendToServer(new CurvedTrackDestroyPacket(result.blockEntity() AllPackets.getChannel().sendToServer(new CurvedTrackDestroyPacket(result.blockEntity()
.getBlockPos(), .getBlockPos(),
result.loc() result.loc()

View file

@ -60,7 +60,7 @@ public class CurvedTrackSelectionPacket extends BlockEntityConfigurationPacket<T
.getItem(slot); .getItem(slot);
if (!(stack.getItem() instanceof TrackTargetingBlockItem)) if (!(stack.getItem() instanceof TrackTargetingBlockItem))
return; return;
if (player.isSteppingCarefully() && stack.hasTag()) { if (player.isShiftKeyDown() && stack.hasTag()) {
player.displayClientMessage(Lang.translateDirect("track_target.clear"), true); player.displayClientMessage(Lang.translateDirect("track_target.clear"), true);
stack.setTag(null); stack.setTag(null);
AllSoundEvents.CONTROLLER_CLICK.play(player.level, null, pos, 1, .5f); AllSoundEvents.CONTROLLER_CLICK.play(player.level, null, pos, 1, .5f);

View file

@ -80,7 +80,7 @@ public class TrackBlockItem extends BlockItem {
} }
return super.useOn(pContext); return super.useOn(pContext);
} else if (player.isSteppingCarefully()) { } else if (player.isShiftKeyDown()) {
if (!level.isClientSide) { if (!level.isClientSide) {
player.displayClientMessage(Lang.translateDirect("track.selection_cleared"), true); player.displayClientMessage(Lang.translateDirect("track.selection_cleared"), true);
stack.setTag(null); stack.setTag(null);

View file

@ -65,7 +65,7 @@ public class TrackTargetingBlockItem extends BlockItem {
if (player == null) if (player == null)
return InteractionResult.FAIL; return InteractionResult.FAIL;
if (player.isSteppingCarefully() && stack.hasTag()) { if (player.isShiftKeyDown() && stack.hasTag()) {
if (level.isClientSide) if (level.isClientSide)
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
player.displayClientMessage(Lang.translateDirect("track_target.clear"), true); player.displayClientMessage(Lang.translateDirect("track_target.clear"), true);