Skip to content

Commit

Permalink
Fixes #5061: Use isSneaking() instead of isCrouching() (#5064)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Hartte <sebastian@hartte.de>
  • Loading branch information
yueh and shartte authored Mar 14, 2021
1 parent fd96120 commit 5fc70be
Show file tree
Hide file tree
Showing 42 changed files with 265 additions and 186 deletions.
5 changes: 3 additions & 2 deletions src/main/java/appeng/block/AEBaseTileBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import appeng.tile.AEBaseTileEntity;
import appeng.tile.networking.CableBusTileEntity;
import appeng.tile.storage.SkyChestTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;
import appeng.util.SettingsFrom;

Expand Down Expand Up @@ -179,7 +180,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos
if (player != null && !player.getHeldItem(hand).isEmpty()) {
heldItem = player.getHeldItem(hand);

if (Platform.isWrench(player, heldItem, pos) && player.isCrouching()) {
if (InteractionUtil.isWrench(player, heldItem, pos) && InteractionUtil.isInAlternateUseMode(player)) {
final BlockState blockState = world.getBlockState(pos);
final Block block = blockState.getBlock();

Expand Down Expand Up @@ -224,7 +225,7 @@ public ActionResultType onBlockActivated(BlockState state, World world, BlockPos

final String name = this.getTranslationKey();

if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
final CompoundNBT data = tileEntity.downloadSettings(SettingsFrom.MEMORY_CARD);
if (data != null) {
memoryCard.setMemoryCardContents(heldItem, name, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.CraftingCPUContainer;
import appeng.tile.crafting.CraftingTileEntity;
import appeng.util.InteractionUtil;

public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> extends AEBaseTileBlock<T> {
public static final BooleanProperty FORMED = BooleanProperty.create("formed");
Expand Down Expand Up @@ -96,7 +97,7 @@ public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos
BlockRayTraceResult hit) {
final CraftingTileEntity tg = this.getTileEntity(w, pos);

if (tg != null && !p.isCrouching() && tg.isFormed() && tg.isActive()) {
if (tg != null && !InteractionUtil.isInAlternateUseMode(p) && tg.isFormed() && tg.isActive()) {
if (!w.isRemote()) {
ContainerOpener.openContainer(CraftingCPUContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.MolecularAssemblerContainer;
import appeng.tile.crafting.MolecularAssemblerTileEntity;
import appeng.util.InteractionUtil;

public class MolecularAssemblerBlock extends AEBaseTileBlock<MolecularAssemblerTileEntity> {

Expand All @@ -60,7 +61,7 @@ protected BlockState updateBlockStateFromTileEntity(BlockState currentState, Mol
public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand,
BlockRayTraceResult hit) {
final MolecularAssemblerTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
if (tg != null && !InteractionUtil.isInAlternateUseMode(p)) {
if (!tg.isRemote()) {
ContainerOpener.openContainer(MolecularAssemblerContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/grindstone/GrinderBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.GrinderContainer;
import appeng.tile.grindstone.GrinderTileEntity;
import appeng.util.InteractionUtil;

public class GrinderBlock extends AEBaseTileBlock<GrinderTileEntity> {

Expand All @@ -45,7 +46,7 @@ public GrinderBlock(Properties props) {
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final GrinderTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
if (tg != null && !InteractionUtil.isInAlternateUseMode(p)) {
if (p instanceof ServerPlayerEntity) {
ContainerOpener.openContainer(GrinderContainer.TYPE, p,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/misc/CellWorkbenchBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import appeng.container.ContainerLocator;
import appeng.container.implementations.CellWorkbenchContainer;
import appeng.tile.misc.CellWorkbenchTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class CellWorkbenchBlock extends AEBaseTileBlock<CellWorkbenchTileEntity> {
Expand All @@ -44,7 +45,7 @@ public CellWorkbenchBlock() {
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/misc/ChargerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.tile.misc.ChargerTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
Expand All @@ -64,7 +65,7 @@ public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
return ActionResultType.PASS;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/appeng/block/misc/CondenserBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.CondenserContainer;
import appeng.tile.misc.CondenserTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class CondenserBlock extends AEBaseTileBlock<CondenserTileEntity> {
Expand All @@ -45,13 +46,13 @@ public CondenserBlock() {
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
return ActionResultType.PASS;
}

if (Platform.isServer()) {
final CondenserTileEntity tc = this.getTileEntity(w, pos);
if (tc != null && !player.isCrouching()) {
if (tc != null && !InteractionUtil.isInAlternateUseMode(player)) {
ContainerOpener.openContainer(CondenserContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResultType.SUCCESS;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/misc/InscriberBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.InscriberContainer;
import appeng.tile.misc.InscriberTileEntity;
import appeng.util.InteractionUtil;

public class InscriberBlock extends AEBaseTileBlock<InscriberTileEntity> {

Expand All @@ -51,7 +52,7 @@ public int getOpacity(BlockState state, IBlockReader worldIn, BlockPos pos) {
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (!p.isCrouching()) {
if (!InteractionUtil.isInAlternateUseMode(p)) {
final InscriberTileEntity tg = this.getTileEntity(w, pos);
if (tg != null) {
if (!tg.isRemote()) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/misc/InterfaceBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.InterfaceContainer;
import appeng.tile.misc.InterfaceTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class InterfaceBlock extends AEBaseTileBlock<InterfaceTileEntity> {
Expand All @@ -64,7 +65,7 @@ protected BlockState updateBlockStateFromTileEntity(BlockState currentState, Int
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/misc/SecurityStationBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.SecurityStationContainer;
import appeng.tile.misc.SecurityStationTileEntity;
import appeng.util.InteractionUtil;

public class SecurityStationBlock extends AEBaseTileBlock<SecurityStationTileEntity> {

Expand All @@ -63,7 +64,7 @@ protected BlockState updateBlockStateFromTileEntity(BlockState currentState, Sec
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/appeng/block/misc/VibrationChamberBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import appeng.core.AEConfig;
import appeng.tile.AEBaseTileEntity;
import appeng.tile.misc.VibrationChamberTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public final class VibrationChamberBlock extends AEBaseTileBlock<VibrationChamberTileEntity> {
Expand All @@ -70,13 +71,13 @@ protected void fillStateContainer(StateContainer.Builder<Block, BlockState> buil
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity player, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
return ActionResultType.PASS;
}

if (Platform.isServer()) {
final VibrationChamberTileEntity tc = this.getTileEntity(w, pos);
if (tc != null && !player.isCrouching()) {
if (tc != null && !InteractionUtil.isInAlternateUseMode(player)) {
ContainerOpener.openContainer(VibrationChamberContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tc, hit.getFace()));
return ActionResultType.SUCCESS;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/networking/WirelessBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import appeng.container.implementations.WirelessContainer;
import appeng.helpers.AEMaterials;
import appeng.tile.networking.WirelessTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class WirelessBlock extends AEBaseTileBlock<WirelessTileEntity> {
Expand Down Expand Up @@ -88,7 +89,7 @@ public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos
BlockRayTraceResult hit) {
final WirelessTileEntity tg = this.getTileEntity(w, pos);

if (tg != null && !player.isCrouching()) {
if (tg != null && !InteractionUtil.isInAlternateUseMode(player)) {
if (Platform.isServer()) {
ContainerOpener.openContainer(WirelessContainer.TYPE, player,
ContainerLocator.forTileEntitySide(tg, hit.getFace()));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/qnb/QuantumLinkChamberBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import appeng.core.AppEng;
import appeng.helpers.AEMaterials;
import appeng.tile.qnb.QuantumBridgeTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class QuantumLinkChamberBlock extends QuantumBaseBlock {
Expand Down Expand Up @@ -75,7 +76,7 @@ public void animateTick(final BlockState state, final World w, final BlockPos po
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/spatial/SpatialAnchorBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.SpatialAnchorContainer;
import appeng.tile.spatial.SpatialAnchorTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

/**
Expand Down Expand Up @@ -66,7 +67,7 @@ protected BlockState updateBlockStateFromTileEntity(BlockState currentState, Spa
@Override
public ActionResultType onActivated(final World worldIn, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/spatial/SpatialIOPortBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.SpatialIOPortContainer;
import appeng.tile.spatial.SpatialIOPortTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class SpatialIOPortBlock extends AEBaseTileBlock<SpatialIOPortTileEntity> {
Expand All @@ -56,7 +57,7 @@ public void neighborChanged(BlockState state, World world, BlockPos pos, Block b
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/storage/ChestBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import appeng.container.implementations.ChestContainer;
import appeng.core.localization.PlayerMessages;
import appeng.tile.storage.ChestTileEntity;
import appeng.util.InteractionUtil;

public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {

Expand Down Expand Up @@ -75,7 +76,7 @@ protected BlockState updateBlockStateFromTileEntity(BlockState currentState, Che
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
final ChestTileEntity tg = this.getTileEntity(w, pos);
if (tg != null && !p.isCrouching()) {
if (tg != null && !InteractionUtil.isInAlternateUseMode(p)) {
if (w.isRemote()) {
return ActionResultType.SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/storage/DriveBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.DriveContainer;
import appeng.tile.storage.DriveTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class DriveBlock extends AEBaseTileBlock<DriveTileEntity> {
Expand All @@ -45,7 +46,7 @@ public DriveBlock() {
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/block/storage/IOPortBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import appeng.container.ContainerOpener;
import appeng.container.implementations.IOPortContainer;
import appeng.tile.storage.IOPortTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class IOPortBlock extends AEBaseTileBlock<IOPortTileEntity> {
Expand All @@ -56,7 +57,7 @@ public void neighborChanged(BlockState state, World world, BlockPos pos, Block b
@Override
public ActionResultType onActivated(final World w, final BlockPos pos, final PlayerEntity p, final Hand hand,
final @Nullable ItemStack heldItem, final BlockRayTraceResult hit) {
if (p.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(p)) {
return ActionResultType.PASS;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/client/ClientHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.helpers.IMouseWheelItem;
import appeng.server.ServerHelper;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class ClientHelper extends ServerHelper {
Expand Down Expand Up @@ -220,7 +221,7 @@ private void wheelEvent(final InputEvent.MouseScrollEvent me) {

final Minecraft mc = Minecraft.getInstance();
final PlayerEntity player = mc.player;
if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
final boolean mainHand = player.getHeldItem(Hand.MAIN_HAND).getItem() instanceof IMouseWheelItem;
final boolean offHand = player.getHeldItem(Hand.OFF_HAND).getItem() instanceof IMouseWheelItem;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/debug/CubeGeneratorTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import appeng.core.AppEng;
import appeng.tile.AEBaseTileEntity;
import appeng.util.InteractionUtil;
import appeng.util.Platform;

public class CubeGeneratorTileEntity extends AEBaseTileEntity implements ITickableTileEntity {
Expand Down Expand Up @@ -90,7 +91,7 @@ void click(final PlayerEntity player) {
if (hand.isEmpty()) {
this.is = ItemStack.EMPTY;

if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
this.size--;
} else {
this.size++;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/debug/DebugCardItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import appeng.me.cache.TickManagerCache;
import appeng.parts.p2p.P2PTunnelPart;
import appeng.tile.networking.ControllerTileEntity;
import appeng.util.InteractionUtil;

public class DebugCardItem extends AEBaseItem {

Expand All @@ -73,7 +74,7 @@ public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
return ActionResultType.PASS;
}

if (player.isCrouching()) {
if (InteractionUtil.isInAlternateUseMode(player)) {
int grids = 0;
int totalNodes = 0;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/debug/EraserItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import appeng.core.AELog;
import appeng.items.AEBaseItem;
import appeng.util.InteractionUtil;

public class EraserItem extends AEBaseItem {

Expand All @@ -61,7 +62,7 @@ public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context)
}

final Block state = world.getBlockState(pos).getBlock();
final boolean bulk = player.isSneaking();
final boolean bulk = InteractionUtil.isInAlternateUseMode(player);
final Queue<BlockPos> next = new ArrayDeque<>();
final Set<BlockPos> closed = new HashSet<>();
final Set<Block> commonBlocks = this.getCommonBlocks();
Expand Down
Loading

0 comments on commit 5fc70be

Please sign in to comment.