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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) {
Direction direction = context.getNearestLookingDirection();
if (context.getPlayer() != null && context.getPlayer()
.isSteppingCarefully())
.isShiftKeyDown())
direction = 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();
state = state.setValue(FACING, horizontalDirection.getOpposite());
if (player != null && player.isSteppingCarefully())
if (player != null && player.isShiftKeyDown())
state = state.setValue(FACING, horizontalDirection);
return state;

View file

@ -121,7 +121,7 @@ public class SuperGlueSelectionHandler {
return;
}
boolean cancel = player.isSteppingCarefully();
boolean cancel = player.isShiftKeyDown();
if (cancel && firstPos == null)
return;
@ -201,7 +201,7 @@ public class SuperGlueSelectionHandler {
return true;
}
if (player.isSteppingCarefully()) {
if (player.isShiftKeyDown()) {
if (firstPos != null) {
discard();
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,
Player player) {
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 material.getCloneItemStack(target, level, pos, player);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@ public class ExperienceNuggetItem extends Item {
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 maxOrbs = amountUsed == 1 ? 1 : 5;
int valuePer = Math.max(1, 1 + total / maxOrbs);

View file

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

View file

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

View file

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

View file

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

View file

@ -83,7 +83,7 @@ public class TrainRelocator {
return;
if (!player.position()
.closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) {
.closerThan(relocatingOrigin, 24) || player.isShiftKeyDown()) {
relocatingTrain = null;
player.displayClientMessage(Lang.translateDirect("train.relocate.abort")
.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,
BlockHitResult pHit) {
if (pPlayer == null || pPlayer.isSteppingCarefully())
if (pPlayer == null || pPlayer.isShiftKeyDown())
return InteractionResult.PASS;
ItemStack itemInHand = pPlayer.getItemInHand(pHand);
if (AllItems.WRENCH.isIn(itemInHand))

View file

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

View file

@ -60,7 +60,7 @@ public class CurvedTrackSelectionPacket extends BlockEntityConfigurationPacket<T
.getItem(slot);
if (!(stack.getItem() instanceof TrackTargetingBlockItem))
return;
if (player.isSteppingCarefully() && stack.hasTag()) {
if (player.isShiftKeyDown() && stack.hasTag()) {
player.displayClientMessage(Lang.translateDirect("track_target.clear"), true);
stack.setTag(null);
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);
} else if (player.isSteppingCarefully()) {
} else if (player.isShiftKeyDown()) {
if (!level.isClientSide) {
player.displayClientMessage(Lang.translateDirect("track.selection_cleared"), true);
stack.setTag(null);

View file

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