Skip to content

Commit

Permalink
Merge pull request #5656 from SFort/FixShiftConflict
Browse files Browse the repository at this point in the history
Use appropriate method for sneaky players
  • Loading branch information
simibubi authored Oct 22, 2023
2 parents 99dff66 + a5ce9ab commit 26c9af5
Show file tree
Hide file tree
Showing 25 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEn
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public BlockState getStateForPlacement(BlockPlaceContext pContext) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void tick() {
return;
}

boolean cancel = player.isSteppingCarefully();
boolean cancel = player.isShiftKeyDown();
if (cancel && firstPos == null)
return;

Expand Down Expand Up @@ -201,7 +201,7 @@ public boolean onMouseInput(boolean attack) {
return true;
}

if (player.isSteppingCarefully()) {
if (player.isShiftKeyDown()) {
if (firstPos != null) {
discard();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public float getExplosionResistance(BlockState state, BlockGetter level, BlockPo
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Pla
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void tick() {
Player player = mc.player;
ItemStack heldItem = player.getMainHandItem();

if (player.isSteppingCarefully())
if (player.isShiftKeyDown())
return;

if (!AllBlocks.METAL_GIRDER.has(world.getBlockState(pos)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BlockState getStateForPlacement(BlockPlaceContext pContext) {
.relative(pContext.getClickedFace()
.getOpposite()));
if (placedOn.getBlock() == this && (pContext.getPlayer() == null || !pContext.getPlayer()
.isSteppingCarefully()))
.isShiftKeyDown()))
stateForPlacement = stateForPlacement.setValue(AXIS, placedOn.getValue(AXIS));
return stateForPlacement;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public boolean canSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos)
@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public InteractionResult useOn(UseOnContext context) {
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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private static void interact(PlayerInteractEvent event, boolean paste) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void onBlockActivated(PlayerInteractEvent.RightClickBlock event) {
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())) {
Expand Down Expand Up @@ -94,7 +94,7 @@ public boolean clicked(Level level, BlockPos pos, BlockState blockState, Player
}

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected void createBlockStateDefinition(Builder<Block, BlockState> pBuilder) {
@Override
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
if (pContext.getPlayer() == null || !pContext.getPlayer()
.isSteppingCarefully()) {
.isShiftKeyDown()) {
BlockState placedOn = pContext.getLevel()
.getBlockState(pContext.getClickedPos()
.relative(pContext.getClickedFace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void tryMultiPlace(BlockPlaceContext ctx) {
Player player = ctx.getPlayer();
if (player == null)
return;
if (player.isSteppingCarefully())
if (player.isShiftKeyDown())
return;
Direction face = ctx.getClickedFace();
ItemStack stack = ctx.getItemInHand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, Inte
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Pla
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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public InteractionResult useOn(UseOnContext pContext) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ else if (blockEntity instanceof FunnelBlockEntity)
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static void onClicked(ClickInputEvent event) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void updateEntityAfterFallOn(BlockGetter worldIn, Entity entityIn) {
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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static boolean onClickInput(ClickInputEvent event) {
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected void applySettings(ServerPlayer player, TrackBlockEntity be) {
.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public InteractionResult useOn(UseOnContext pContext) {
}
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public InteractionResult useOn(UseOnContext pContext) {
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);
Expand Down

0 comments on commit 26c9af5

Please sign in to comment.