Fixes wrenches not working on tile entities.

This is a temporary hack for now.
This commit is contained in:
Sebastian Hartte
2020-08-19 01:53:51 +02:00
parent 2bba843313
commit 0e7e9313ee
2 changed files with 32 additions and 15 deletions
@@ -232,7 +232,7 @@ public abstract class AEBaseTileBlock<T extends AEBaseBlockEntity> extends AEBas
Platform.spawnDrops(world, pos, itemsToDrop); Platform.spawnDrops(world, pos, itemsToDrop);
} }
return ActionResult.FAIL; return ActionResult.SUCCESS;
} }
if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) { if (heldItem.getItem() instanceof IMemoryCard && !(this instanceof CableBusBlock)) {
@@ -19,11 +19,13 @@
package appeng.items.tools.quartz; package appeng.items.tools.quartz;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import appeng.api.implementations.items.IAEWrench; import appeng.api.implementations.items.IAEWrench;
@@ -41,22 +43,37 @@ public class QuartzWrenchItem extends AEBaseItem implements IAEWrench, AEToolIte
@Override @Override
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) { public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
if (!context.getPlayer().isInSneakingPose() && Platform PlayerEntity player = context.getPlayer();
.hasPermissions(new DimensionalCoord(context.getWorld(), context.getBlockPos()), context.getPlayer())) { if (player == null) {
return ActionResult.PASS;
}
Block block = context.getWorld().getBlockState(context.getBlockPos()).getBlock(); boolean isHoldingShift = player.isInSneakingPose();
if (block instanceof AEBaseBlock) { if (!Platform.hasPermissions(new DimensionalCoord(context.getWorld(), context.getBlockPos()), player)) {
if (Platform.isClient()) { return ActionResult.FAIL;
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server. }
// Fix that in all Block#onItemUseFirst overrides.
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.PASS;
}
AEBaseBlock aeBlock = (AEBaseBlock) block; BlockState blockState = context.getWorld().getBlockState(context.getBlockPos());
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) { Block block = blockState.getBlock();
context.getPlayer().swingHand(context.getHand());
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL; if (isHoldingShift) {
} // Pass the use onto the block...
return block.onUse(blockState, context.getWorld(), context.getBlockPos(), player, context.getHand(),
new BlockHitResult(context.getHitPos(), context.getSide(), context.getBlockPos(),
context.hitsInsideBlock()));
}
if (block instanceof AEBaseBlock) {
if (Platform.isClient()) {
// TODO 1.10-R - if we return FAIL on client, action will not be sent to server.
// Fix that in all Block#onItemUseFirst overrides.
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.PASS;
}
AEBaseBlock aeBlock = (AEBaseBlock) block;
if (aeBlock.rotateAroundFaceAxis(context.getWorld(), context.getBlockPos(), context.getSide())) {
player.swingHand(context.getHand());
return !context.getWorld().isClient ? ActionResult.SUCCESS : ActionResult.FAIL;
} }
} }
return ActionResult.PASS; return ActionResult.PASS;