Skip to content

Commit

Permalink
Temporarily prevent FakePlayers from using wrenches
Browse files Browse the repository at this point in the history
Closes #432
  • Loading branch information
NotMyWing committed May 27, 2024
1 parent d82cdab commit cd0a5d6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/appeng/hooks/WrenchClickHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

Expand All @@ -32,22 +33,24 @@ public void playerInteract(final PlayerInteractEvent event) {

if (event instanceof PlayerInteractEvent.RightClickBlock && !event.getEntityPlayer().world.isRemote) {
EntityPlayer player = event.getEntityPlayer();
if (player instanceof FakePlayer) return;

EnumHand hand = event.getHand();
BlockPos pos = event.getPos();
World world = event.getWorld();
ItemStack held = event.getItemStack();

if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
return;
}

if (player.isSneaking() && Platform.isWrench(player, held, pos)) {
Block block = world.getBlockState(pos).getBlock();
TileEntity tile = world.getTileEntity(pos);
if (!(tile instanceof IPartHost host)) {
return;
}

if (!Platform.hasPermissions(new DimensionalCoord(world, pos), player)) {
return;
}

final LookDirection dir = Platform.getPlayerRay(player, player.getEyeHeight());
final RayTraceResult mop = block.collisionRayTrace(world.getBlockState(pos), world, pos, dir.getA(), dir.getB());
if (mop != null) {
Expand Down

0 comments on commit cd0a5d6

Please sign in to comment.