Updated some unneeded variables
Cleaned up some of the function code inside of ObsidianReplace.
This commit is contained in:
parent
0688680866
commit
04522e1fe1
|
@ -70,19 +70,16 @@ public final class ObsidianReplaceModule extends Module {
|
||||||
|
|
||||||
final Minecraft minecraft = Minecraft.getMinecraft();
|
final Minecraft minecraft = Minecraft.getMinecraft();
|
||||||
final EntityPlayerSP player = minecraft.player;
|
final EntityPlayerSP player = minecraft.player;
|
||||||
final int obisidanSlot = findObsidianInHotbar(player);
|
final HandSwapContext handSwapContext = new HandSwapContext(
|
||||||
if (obisidanSlot == -1)
|
player.inventory.currentItem, findObsidianInHotbar(player));
|
||||||
|
if (handSwapContext.getNewSlot() == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final int currentSlot = player.inventory.currentItem;
|
|
||||||
final HandSwapContext handSwapContext = new HandSwapContext(currentSlot, obisidanSlot);
|
|
||||||
handleHandSwap(handSwapContext, false, minecraft);
|
handleHandSwap(handSwapContext, false, minecraft);
|
||||||
|
|
||||||
final PlacementRequest placementRequest = placementRequests.poll();
|
final PlacementRequest placementRequest = placementRequests.poll();
|
||||||
final BlockPos position = placementRequest.getStructurePosition();
|
final double playerToBlockDistance = calculateVecDistance(
|
||||||
final double playerToBlockDistance =
|
player.getPositionEyes(1.0f), placementRequest.getStructurePosition());
|
||||||
calculateVecDistance(player.getPositionEyes(1.0f),
|
|
||||||
position.getX(), position.getY(), position.getZ());
|
|
||||||
if (playerToBlockDistance <= getReachDistance(minecraft))
|
if (playerToBlockDistance <= getReachDistance(minecraft))
|
||||||
handlePlaceRequest(minecraft, placementRequest);
|
handlePlaceRequest(minecraft, placementRequest);
|
||||||
|
|
||||||
|
@ -101,12 +98,11 @@ public final class ObsidianReplaceModule extends Module {
|
||||||
if (event.getPacket() instanceof SPacketBlockChange) {
|
if (event.getPacket() instanceof SPacketBlockChange) {
|
||||||
final SPacketBlockChange blockChange = (SPacketBlockChange) event.getPacket();
|
final SPacketBlockChange blockChange = (SPacketBlockChange) event.getPacket();
|
||||||
if (blockChange.getBlockState().getBlock() instanceof BlockAir) {
|
if (blockChange.getBlockState().getBlock() instanceof BlockAir) {
|
||||||
final BlockPos position = blockChange.getBlockPosition();
|
final BlockPos blockPosition = blockChange.getBlockPosition();
|
||||||
final double playerToBlockDistance =
|
final double playerToBlockDistance = calculateVecDistance(
|
||||||
calculateVecDistance(minecraft.player.getPositionEyes(1.0f),
|
minecraft.player.getPositionEyes(1.0f), blockPosition);
|
||||||
position.getX(), position.getY(), position.getZ());
|
|
||||||
if (playerToBlockDistance <= getReachDistance(minecraft))
|
if (playerToBlockDistance <= getReachDistance(minecraft))
|
||||||
buildPlacementRequest(minecraft, position);
|
buildPlacementRequest(minecraft, blockPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,8 +188,7 @@ public final class ObsidianReplaceModule extends Module {
|
||||||
final EntityPlayerSP player = minecraft.player;
|
final EntityPlayerSP player = minecraft.player;
|
||||||
final BlockPos structurePosition = placementRequest.getStructurePosition();
|
final BlockPos structurePosition = placementRequest.getStructurePosition();
|
||||||
final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition);
|
final IBlockState structureBlockState = minecraft.world.getBlockState(structurePosition);
|
||||||
final Block structureBlock = structureBlockState.getBlock();
|
final boolean blockActivated = structureBlockState.getBlock().onBlockActivated(minecraft.world,
|
||||||
final boolean blockActivated = structureBlock.onBlockActivated(minecraft.world,
|
|
||||||
structurePosition, structureBlockState, player, EnumHand.MAIN_HAND,
|
structurePosition, structureBlockState, player, EnumHand.MAIN_HAND,
|
||||||
EnumFacing.UP, 0.0f, 0.0f, 0.0f);
|
EnumFacing.UP, 0.0f, 0.0f, 0.0f);
|
||||||
if (blockActivated)
|
if (blockActivated)
|
||||||
|
@ -231,11 +226,10 @@ public final class ObsidianReplaceModule extends Module {
|
||||||
return minecraft.playerController.getBlockReachDistance();
|
return minecraft.playerController.getBlockReachDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateVecDistance(final Vec3d vec, final int blockX,
|
private double calculateVecDistance(final Vec3d vec, final BlockPos blockPosition) {
|
||||||
final int blockY, final int blockZ) {
|
final double diffX = blockPosition.getX() - vec.x;
|
||||||
final double diffX = blockX - vec.x;
|
final double diffY = blockPosition.getY() - vec.y;
|
||||||
final double diffY = blockY - vec.y;
|
final double diffZ = blockPosition.getZ() - vec.z;
|
||||||
final double diffZ = blockZ - vec.z;
|
|
||||||
return MathHelper.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
return MathHelper.sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue