Fixed opening block containers

There was an issue with the incorrect block being used due to some silly logic error by myself.
This commit is contained in:
Daniel E 2019-11-19 21:38:59 -07:00
parent 30718da330
commit a0f2abe3d1
1 changed files with 15 additions and 23 deletions

View File

@ -7,10 +7,7 @@ import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer; import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.module.Module; import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.impl.module.player.FreeCamModule; import me.rigamortis.seppuku.impl.module.player.FreeCamModule;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockLiquid;
import net.minecraft.block.BlockObsidian;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
@ -85,7 +82,7 @@ public final class ObsidianReplaceModule extends Module {
final PlacementRequest placementRequest = placementRequests.poll(); final PlacementRequest placementRequest = placementRequests.poll();
assert placementRequest != null; assert placementRequest != null;
final BlockPos position = placementRequest.getBlockPosition(); final BlockPos position = placementRequest.getStructurePosition();
final double playerToBlockDistance = final double playerToBlockDistance =
calculateVecDistance(player.getPositionEyes(1.0f), calculateVecDistance(player.getPositionEyes(1.0f),
position.getX(), position.getY(), position.getZ()); position.getX(), position.getY(), position.getZ());
@ -142,7 +139,7 @@ public final class ObsidianReplaceModule extends Module {
final EnumFacing blockPlacementFace = calculateFaceForPlacement(relativePosition, position); final EnumFacing blockPlacementFace = calculateFaceForPlacement(relativePosition, position);
if (blockPlacementFace != null && placementRequests.offer(new PlacementRequest( if (blockPlacementFace != null && placementRequests.offer(new PlacementRequest(
relativePosition, position, blockPlacementFace))) relativePosition, blockPlacementFace)))
return; return;
} }
} }
@ -196,16 +193,18 @@ public final class ObsidianReplaceModule extends Module {
private void handlePlaceRequest(final Minecraft minecraft, final PlacementRequest placementRequest) { private void handlePlaceRequest(final Minecraft minecraft, final PlacementRequest placementRequest) {
final EntityPlayerSP player = minecraft.player; final EntityPlayerSP player = minecraft.player;
final IBlockState blockState = player.world.getBlockState(placementRequest.getStructureBlock()); final BlockPos structurePosition = placementRequest.getStructurePosition();
final boolean blockActivated = blockState.getBlock().onBlockActivated(player.world, final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition);
placementRequest.getBlockPosition(), blockState, player, EnumHand.MAIN_HAND, final Block structureBlock = structureBlockState.getBlock();
placementRequest.getPlaceDirection(), 0.0f, 0.0f, 0.0f); final boolean blockActivated = structureBlock.onBlockActivated(minecraft.world,
structurePosition, structureBlockState, player, EnumHand.MAIN_HAND,
EnumFacing.UP, 0.0f, 0.0f, 0.0f);
if (blockActivated) if (blockActivated)
player.connection.sendPacket(new CPacketEntityAction(player, player.connection.sendPacket(new CPacketEntityAction(player,
CPacketEntityAction.Action.START_SNEAKING)); CPacketEntityAction.Action.START_SNEAKING));
if (minecraft.playerController.processRightClickBlock(player, minecraft.world, if (minecraft.playerController.processRightClickBlock(player, minecraft.world,
placementRequest.getBlockPosition(), placementRequest.getPlaceDirection(), structurePosition, placementRequest.getPlaceDirection(),
Vec3d.ZERO, EnumHand.MAIN_HAND) != EnumActionResult.FAIL) Vec3d.ZERO, EnumHand.MAIN_HAND) != EnumActionResult.FAIL)
player.swingArm(EnumHand.MAIN_HAND); player.swingArm(EnumHand.MAIN_HAND);
@ -269,24 +268,17 @@ public final class ObsidianReplaceModule extends Module {
} }
private static final class PlacementRequest { private static final class PlacementRequest {
private final BlockPos blockPosition; private final BlockPos structurePosition;
private final BlockPos structureBlock;
private final EnumFacing placeDirection; private final EnumFacing placeDirection;
PlacementRequest(final BlockPos blockPosition, PlacementRequest(final BlockPos structurePosition,
final BlockPos structureBlock,
final EnumFacing placeDirection) { final EnumFacing placeDirection) {
this.blockPosition = blockPosition; this.structurePosition = structurePosition;
this.structureBlock = structureBlock;
this.placeDirection = placeDirection; this.placeDirection = placeDirection;
} }
BlockPos getBlockPosition() { BlockPos getStructurePosition() {
return blockPosition; return structurePosition;
}
BlockPos getStructureBlock() {
return structureBlock;
} }
EnumFacing getPlaceDirection() { EnumFacing getPlaceDirection() {