Java Code Examples for net.minecraft.util.math.Vec3d#ofCenter()
The following examples show how to use
net.minecraft.util.math.Vec3d#ofCenter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BonemealAuraHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private boolean rightClickBlockSimple(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); for(Direction side : Direction.values()) { Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5)); double distanceSqHitVec = eyesPos.squaredDistanceTo(hitVec); // check if hitVec is within range (6 blocks) if(distanceSqHitVec > 36) continue; // check if side is facing towards player if(distanceSqHitVec >= distanceSqPosVec) continue; // place block IMC.getInteractionManager().rightClickBlock(pos, side, hitVec); return true; } return false; }
Example 2
Source File: FollowHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override protected boolean checkDone() { Vec3d center = Vec3d.ofCenter(current); double distanceSq = Math.pow(distance.getValue(), 2); return done = entity.squaredDistanceTo(center) <= distanceSq; }
Example 3
Source File: AutoBuildHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void buildInstantly() { Vec3d eyesPos = RotationUtils.getEyesPos(); IClientPlayerInteractionManager im = IMC.getInteractionManager(); double rangeSq = Math.pow(range.getValue(), 2); for(BlockPos pos : remainingBlocks) { if(!BlockUtils.getState(pos).getMaterial().isReplaceable()) continue; Vec3d posVec = Vec3d.ofCenter(pos); for(Direction side : Direction.values()) { BlockPos neighbor = pos.offset(side); // check if neighbor can be right-clicked if(!BlockUtils.canBeClicked(neighbor)) continue; Vec3d sideVec = Vec3d.of(side.getVector()); Vec3d hitVec = posVec.add(sideVec.multiply(0.5)); // check if hitVec is within range if(eyesPos.squaredDistanceTo(hitVec) > rangeSq) continue; // place block im.rightClickBlock(neighbor, side.getOpposite(), hitVec); break; } } remainingBlocks.clear(); }
Example 4
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public void run() { BlockPos base = start.offset(direction, length); Vec3d vec = Vec3d.ofCenter(base); WURST.getRotationFaker().faceVectorClientIgnorePitch(vec); MC.options.keyForward.setPressed(true); }
Example 5
Source File: BuildRandomHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private boolean placeBlockSimple_old(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); for(Direction side : Direction.values()) { BlockPos neighbor = pos.offset(side); // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(neighbor)) continue; Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5)); // check if hitVec is within range (6 blocks) if(eyesPos.squaredDistanceTo(hitVec) > 36) continue; // place block IMC.getInteractionManager().rightClickBlock(neighbor, side.getOpposite(), hitVec); return true; } return false; }
Example 6
Source File: AutoFarmHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private void placeBlockSimple(BlockPos pos) { Direction side = null; Direction[] sides = Direction.values(); Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); Vec3d[] hitVecs = new Vec3d[sides.length]; for(int i = 0; i < sides.length; i++) hitVecs[i] = posVec.add(Vec3d.of(sides[i].getVector()).multiply(0.5)); for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked BlockPos neighbor = pos.offset(sides[i]); if(!BlockUtils.canBeClicked(neighbor)) continue; // check line of sight BlockState neighborState = BlockUtils.getState(neighbor); VoxelShape neighborShape = neighborState.getOutlineShape(MC.world, neighbor); if(MC.world.rayTraceBlock(eyesPos, hitVecs[i], neighbor, neighborShape, neighborState) != null) continue; side = sides[i]; break; } if(side == null) for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(pos.offset(sides[i]))) continue; // check if side is facing away from player if(distanceSqPosVec > eyesPos.squaredDistanceTo(hitVecs[i])) continue; side = sides[i]; break; } if(side == null) return; Vec3d hitVec = hitVecs[side.ordinal()]; // face block WURST.getRotationFaker().faceVectorPacket(hitVec); if(RotationUtils.getAngleToLastReportedLookVec(hitVec) > 1) return; // check timer if(IMC.getItemUseCooldown() > 0) return; // place block IMC.getInteractionManager().rightClickBlock(pos.offset(side), side.getOpposite(), hitVec); // swing arm MC.player.networkHandler .sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); // reset timer IMC.setItemUseCooldown(4); }
Example 7
Source File: BonemealAuraHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private boolean rightClickBlockLegit(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); for(Direction side : Direction.values()) { Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5)); double distanceSqHitVec = eyesPos.squaredDistanceTo(hitVec); // check if hitVec is within range (4.25 blocks) if(distanceSqHitVec > 18.0625) continue; // check if side is facing towards player if(distanceSqHitVec >= distanceSqPosVec) continue; // check line of sight if(MC.world .rayTrace(new RayTraceContext(eyesPos, hitVec, RayTraceContext.ShapeType.COLLIDER, RayTraceContext.FluidHandling.NONE, MC.player)) .getType() != HitResult.Type.MISS) continue; // face block WURST.getRotationFaker().faceVectorPacket(hitVec); // place block IMC.getInteractionManager().rightClickBlock(pos, side, hitVec); MC.player.swingHand(Hand.MAIN_HAND); IMC.setItemUseCooldown(4); return true; } return false; }
Example 8
Source File: InstantBunkerHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private void placeBlockSimple(BlockPos pos) { Direction side = null; Direction[] sides = Direction.values(); Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); Vec3d[] hitVecs = new Vec3d[sides.length]; for(int i = 0; i < sides.length; i++) hitVecs[i] = posVec.add(Vec3d.of(sides[i].getVector()).multiply(0.5)); for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked BlockPos neighbor = pos.offset(sides[i]); if(!BlockUtils.canBeClicked(neighbor)) continue; // check line of sight BlockState neighborState = BlockUtils.getState(neighbor); VoxelShape neighborShape = neighborState.getOutlineShape(MC.world, neighbor); if(MC.world.rayTraceBlock(eyesPos, hitVecs[i], neighbor, neighborShape, neighborState) != null) continue; side = sides[i]; break; } if(side == null) for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(pos.offset(sides[i]))) continue; // check if side is facing away from player if(distanceSqPosVec > eyesPos.squaredDistanceTo(hitVecs[i])) continue; side = sides[i]; break; } if(side == null) return; Vec3d hitVec = hitVecs[side.ordinal()]; // face block // WURST.getRotationFaker().faceVectorPacket(hitVec); // if(RotationUtils.getAngleToLastReportedLookVec(hitVec) > 1) // return; // check timer // if(IMC.getItemUseCooldown() > 0) // return; // place block IMC.getInteractionManager().rightClickBlock(pos.offset(side), side.getOpposite(), hitVec); // swing arm MC.player.networkHandler .sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); // reset timer IMC.setItemUseCooldown(4); }
Example 9
Source File: NukerLegitHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private boolean breakBlockExtraLegit(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); for(Direction side : Direction.values()) { Vec3d hitVec = posVec.add(Vec3d.of(side.getVector()).multiply(0.5)); double distanceSqHitVec = eyesPos.squaredDistanceTo(hitVec); // check if hitVec is within range (4.25 blocks) if(distanceSqHitVec > 18.0625) continue; // check if side is facing towards player if(distanceSqHitVec >= distanceSqPosVec) continue; // check line of sight if(MC.world .rayTrace(new RayTraceContext(eyesPos, hitVec, RayTraceContext.ShapeType.COLLIDER, RayTraceContext.FluidHandling.NONE, MC.player)) .getType() != HitResult.Type.MISS) continue; // face block WURST.getRotationFaker().faceVectorClient(hitVec); if(currentBlock != null) WURST.getHax().autoToolHack.equipIfEnabled(currentBlock); // if attack key is down but nothing happens, release it for one // tick if(MC.options.keyAttack.isPressed() && !MC.interactionManager.isBreakingBlock()) { MC.options.keyAttack.setPressed(false); return true; } // damage block MC.options.keyAttack.setPressed(true); return true; } return false; }
Example 10
Source File: AutoBuildHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void onRender(float partialTicks) { if(status != Status.BUILDING) return; double scale = 1D * 7D / 8D; double offset = (1D - scale) / 2D; Vec3d eyesPos = RotationUtils.getEyesPos(); double rangeSq = Math.pow(range.getValue(), 2); // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor4f(0F, 0F, 0F, 0.5F); GL11.glPushMatrix(); RenderUtils.applyRenderOffset(); int blocksDrawn = 0; for(Iterator<BlockPos> itr = remainingBlocks.iterator(); itr.hasNext() && blocksDrawn < 1024;) { BlockPos pos = itr.next(); if(!BlockUtils.getState(pos).getMaterial().isReplaceable()) continue; GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); Vec3d posVec = Vec3d.ofCenter(pos); if(eyesPos.squaredDistanceTo(posVec) <= rangeSq) drawGreenBox(); else RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); blocksDrawn++; } GL11.glPopMatrix(); // GL resets GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glColor4f(1, 1, 1, 1); }
Example 11
Source File: PlayerFinderHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
@Override public void onRender(float partialTicks) { if(pos == null) return; // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glPushMatrix(); RenderUtils.applyRenderOffset(); // generate rainbow color float x = System.currentTimeMillis() % 2000 / 1000F; float red = 0.5F + 0.5F * MathHelper.sin(x * (float)Math.PI); float green = 0.5F + 0.5F * MathHelper.sin((x + 4F / 3F) * (float)Math.PI); float blue = 0.5F + 0.5F * MathHelper.sin((x + 8F / 3F) * (float)Math.PI); GL11.glColor4f(red, green, blue, 0.5F); // tracer line GL11.glBegin(GL11.GL_LINES); { // set start position Vec3d start = RotationUtils.getClientLookVec() .add(RenderUtils.getCameraPos()); // set end position Vec3d end = Vec3d.ofCenter(pos); // draw line GL11.glVertex3d(start.x, start.y, start.z); GL11.glVertex3d(end.x, end.y, end.z); } GL11.glEnd(); // block box { GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); RenderUtils.drawOutlinedBox(); GL11.glColor4f(red, green, blue, 0.25F); RenderUtils.drawSolidBox(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
Example 12
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private Vec3d toVec3d(BlockPos pos) { return Vec3d.ofCenter(pos); }
Example 13
Source File: TunnellerHack.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
private void placeBlockSimple(BlockPos pos) { Direction side = null; Direction[] sides = Direction.values(); Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); Vec3d[] hitVecs = new Vec3d[sides.length]; for(int i = 0; i < sides.length; i++) hitVecs[i] = posVec.add(Vec3d.of(sides[i].getVector()).multiply(0.5)); for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked BlockPos neighbor = pos.offset(sides[i]); if(!BlockUtils.canBeClicked(neighbor)) continue; // check line of sight BlockState neighborState = BlockUtils.getState(neighbor); VoxelShape neighborShape = neighborState.getOutlineShape(MC.world, neighbor); if(MC.world.rayTraceBlock(eyesPos, hitVecs[i], neighbor, neighborShape, neighborState) != null) continue; side = sides[i]; break; } if(side == null) for(int i = 0; i < sides.length; i++) { // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(pos.offset(sides[i]))) continue; // check if side is facing away from player if(distanceSqPosVec > eyesPos.squaredDistanceTo(hitVecs[i])) continue; side = sides[i]; break; } if(side == null) return; Vec3d hitVec = hitVecs[side.ordinal()]; // face block WURST.getRotationFaker().faceVectorPacket(hitVec); if(RotationUtils.getAngleToLastReportedLookVec(hitVec) > 1) return; // check timer if(IMC.getItemUseCooldown() > 0) return; // place block IMC.getInteractionManager().rightClickBlock(pos.offset(side), side.getOpposite(), hitVec); // swing arm MC.player.networkHandler .sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND)); // reset timer IMC.setItemUseCooldown(4); }
Example 14
Source File: AutoBuildHack.java From Wurst7 with GNU General Public License v3.0 | 3 votes |
private boolean tryToPlace(BlockPos pos, Vec3d eyesPos, double rangeSq) { Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); for(Direction side : Direction.values()) { BlockPos neighbor = pos.offset(side); // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(neighbor) || BlockUtils.getState(neighbor).getMaterial().isReplaceable()) continue; Vec3d dirVec = Vec3d.of(side.getVector()); Vec3d hitVec = posVec.add(dirVec.multiply(0.5)); // check if hitVec is within range if(eyesPos.squaredDistanceTo(hitVec) > rangeSq) continue; // check if side is visible (facing away from player) if(distanceSqPosVec > eyesPos.squaredDistanceTo(posVec.add(dirVec))) continue; // check line of sight if(checkLOS.isChecked() && MC.world .rayTrace(new RayTraceContext(eyesPos, hitVec, RayTraceContext.ShapeType.COLLIDER, RayTraceContext.FluidHandling.NONE, MC.player)) .getType() != HitResult.Type.MISS) continue; // face block Rotation rotation = RotationUtils.getNeededRotations(hitVec); PlayerMoveC2SPacket.LookOnly packet = new PlayerMoveC2SPacket.LookOnly(rotation.getYaw(), rotation.getPitch(), MC.player.isOnGround()); MC.player.networkHandler.sendPacket(packet); // place block IMC.getInteractionManager().rightClickBlock(neighbor, side.getOpposite(), hitVec); MC.player.swingHand(Hand.MAIN_HAND); IMC.setItemUseCooldown(4); return true; } return false; }
Example 15
Source File: BuildRandomHack.java From Wurst7 with GNU General Public License v3.0 | 3 votes |
private boolean placeBlockLegit(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = Vec3d.ofCenter(pos); double distanceSqPosVec = eyesPos.squaredDistanceTo(posVec); for(Direction side : Direction.values()) { BlockPos neighbor = pos.offset(side); // check if neighbor can be right clicked if(!BlockUtils.canBeClicked(neighbor)) continue; Vec3d dirVec = Vec3d.of(side.getVector()); Vec3d hitVec = posVec.add(dirVec.multiply(0.5)); // check if hitVec is within range (4.25 blocks) if(eyesPos.squaredDistanceTo(hitVec) > 18.0625) continue; // check if side is visible (facing away from player) if(distanceSqPosVec > eyesPos.squaredDistanceTo(posVec.add(dirVec))) continue; // check line of sight if(MC.world .rayTrace(new RayTraceContext(eyesPos, hitVec, RayTraceContext.ShapeType.COLLIDER, RayTraceContext.FluidHandling.NONE, MC.player)) .getType() != HitResult.Type.MISS) continue; // face block Rotation rotation = RotationUtils.getNeededRotations(hitVec); PlayerMoveC2SPacket.LookOnly packet = new PlayerMoveC2SPacket.LookOnly(rotation.getYaw(), rotation.getPitch(), MC.player.isOnGround()); MC.player.networkHandler.sendPacket(packet); // place block IMC.getInteractionManager().rightClickBlock(neighbor, side.getOpposite(), hitVec); MC.player.swingHand(Hand.MAIN_HAND); IMC.setItemUseCooldown(4); return true; } return false; }