net.minecraft.util.shape.VoxelShape Java Examples
The following examples show how to use
net.minecraft.util.shape.VoxelShape.
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: BlockItem_creativeNoClipMixin.java From fabric-carpet with MIT License | 6 votes |
@Redirect(method = "canPlace", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/World;canPlace(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/EntityContext;)Z" )) private boolean canSpectatingPlace(World world, BlockState state, BlockPos pos, EntityContext context, ItemPlacementContext contextOuter, BlockState stateOuter) { PlayerEntity player = contextOuter.getPlayer(); if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.abilities.flying) { // copy from canPlace VoxelShape voxelShape = state.getCollisionShape(world, pos, context); return voxelShape.isEmpty() || world.intersectsEntities(player, voxelShape.offset(pos.getX(), pos.getY(), pos.getZ())); } return world.canPlace(state, pos, context); }
Example #2
Source File: JesusHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
public boolean isOverLiquid() { boolean foundLiquid = false; boolean foundSolid = false; // check collision boxes below player ArrayList<Box> blockCollisions = MC.world .getBlockCollisions(MC.player, MC.player.getBoundingBox().offset(0, -0.5, 0)) .map(VoxelShape::getBoundingBox) .collect(Collectors.toCollection(() -> new ArrayList<>())); for(Box bb : blockCollisions) { BlockPos pos = new BlockPos(bb.getCenter()); Material material = BlockUtils.getState(pos).getMaterial(); if(material == Material.WATER || material == Material.LAVA) foundLiquid = true; else if(material != Material.AIR) foundSolid = true; } return foundLiquid && !foundSolid; }
Example #3
Source File: ParkourHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Override public void onUpdate() { if(!MC.player.isOnGround() || MC.options.keyJump.isPressed()) return; if(MC.player.isSneaking() || MC.options.keySneak.isPressed()) return; Box box = MC.player.getBoundingBox(); Box adjustedBox = box.offset(0, -0.5, 0).expand(-0.001, 0, -0.001); Stream<VoxelShape> blockCollisions = MC.world.getBlockCollisions(MC.player, adjustedBox); if(blockCollisions.findAny().isPresent()) return; MC.player.jump(); }
Example #4
Source File: AbstractBlockStateMixin.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Inject(at = {@At("HEAD")}, method = { "getOutlineShape(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"}, cancellable = true) private void onGetOutlineShape(BlockView view, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) { if(context == ShapeContext.absent()) return; HackList hax = WurstClient.INSTANCE.getHax(); if(hax == null) return; HandNoClipHack handNoClipHack = hax.handNoClipHack; if(!handNoClipHack.isEnabled() || handNoClipHack.isBlockInList(pos)) return; cir.setReturnValue(VoxelShapes.empty()); }
Example #5
Source File: CactusBlockMixin.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
@Inject(at = {@At("HEAD")}, method = { "getOutlineShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Lnet/minecraft/util/shape/VoxelShape;"}, cancellable = true) private void onGetCollisionShape(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1, ShapeContext entityContext_1, CallbackInfoReturnable<VoxelShape> cir) { EventManager events = WurstClient.INSTANCE.getEventManager(); if(events == null) return; CactusCollisionShapeEvent event = new CactusCollisionShapeEvent(); events.fire(event); VoxelShape collisionShape = event.getCollisionShape(); if(collisionShape != null) cir.setReturnValue(collisionShape); }
Example #6
Source File: MixinBlock.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true) private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) { if (ModuleManager.getModule(Xray.class).isToggled()) { callback.setReturnValue(false); callback.cancel(); } }
Example #7
Source File: Walkway.java From Galacticraft-Rewoven with MIT License | 5 votes |
private VoxelShape getShape(BlockState state) { int index = getShapeIndex(state); if (shape[index] != null) { return shape[index]; } return shape[index] = createShape(state.get(NORTH), state.get(SOUTH), state.get(EAST), state.get(WEST)); }
Example #8
Source File: BasicSolarPanelPartBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public VoxelShape getOutlineShape(BlockState blockState_1, BlockView blockView_1, BlockPos pos, ShapeContext context) { Block down = blockView_1.getBlockState(pos.down()).getBlock(); if (down == GalacticraftBlocks.BASIC_SOLAR_PANEL) { return POLE_SHAPE; } else if (blockView_1.getBlockState(pos.down().down()).getBlock() == GalacticraftBlocks.BASIC_SOLAR_PANEL) { return TOP_MID_SHAPE; } return TOP_SHAPE; }
Example #9
Source File: MixinBlock.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true) private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) { if (ModuleManager.getModule(Xray.class).isToggled()) { callback.setReturnValue(false); callback.cancel(); } }
Example #10
Source File: FluidBlockMixin.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
@Override public VoxelShape getCollisionShape(BlockState blockState_1, BlockView blockView_1, BlockPos blockPos_1, ShapeContext entityContext_1) { HackList hax = WurstClient.INSTANCE.getHax(); if(hax != null && hax.jesusHack.shouldBeSolid()) return VoxelShapes.fullCube(); return super.getCollisionShape(blockState_1, blockView_1, blockPos_1, entityContext_1); }
Example #11
Source File: Walkway.java From Galacticraft-Rewoven with MIT License | 5 votes |
private static VoxelShape createShape(boolean north, boolean south, boolean east, boolean west) { VoxelShape top1 = Block.createCuboidShape(0.0D, 13.0D, 0.0D, 2.0D, 16.0D, 16.0D); VoxelShape top2 = Block.createCuboidShape(0.0D, 13.0D, 16.0D, 16.0D, 16.0D, 14.0D); VoxelShape top3 = Block.createCuboidShape(16.0D, 13.0D, 16.0D, 14.0D, 16.0D, 0.0D); VoxelShape top4 = Block.createCuboidShape(16.0D, 13.0D, 0.0D, 0.0D, 16.0D, 2.0D); VoxelShape mTop1 = Block.createCuboidShape(6.0D, 15.0D, 2.0D, 16.0D - 6.0D, 14.0D, 16.0D - 2.0D); VoxelShape mTop2 = Block.createCuboidShape(2.0D, 15.0D, 6.0D, 16.0D - 2.0D, 14.0D, 16.0D - 6.0D); VoxelShape center = Block.createCuboidShape(6.0D, 15.0D, 6.0D, 10.0D, 6.0D, 10.0); VoxelShape base = VoxelShapes.union(top1, top2, top3, top4, mTop1, mTop2, center); if (north) { base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 7.0D, 9.0D, 7.0D, 0.0D)); } if (south) { base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 9.0D, 9.0D, 7.0D, 16.0D)); } if (east) { base = VoxelShapes.union(base, Block.createCuboidShape(9.0D, 9.0D, 7.0D, 16.0D, 7.0D, 9.0D)); } if (west) { base = VoxelShapes.union(base, Block.createCuboidShape(7.0D, 9.0D, 7.0D, 0.0D, 7.0D, 9.0D)); } return VoxelShapes.union(base); }
Example #12
Source File: AluminumWireBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) { ArrayList<VoxelShape> shapes = new ArrayList<>(); if (blockState.get(ATTACHED_NORTH)) { shapes.add(NORTH); } if (blockState.get(ATTACHED_SOUTH)) { shapes.add(SOUTH); } if (blockState.get(ATTACHED_EAST)) { shapes.add(EAST); } if (blockState.get(ATTACHED_WEST)) { shapes.add(WEST); } if (blockState.get(ATTACHED_UP)) { shapes.add(UP); } if (blockState.get(ATTACHED_DOWN)) { shapes.add(DOWN); } if (shapes.isEmpty()) { return NONE; } else { return VoxelShapes.union(NONE, shapes.toArray(new VoxelShape[0])); } }
Example #13
Source File: MixinBlock.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
@Inject(method = "isShapeFullCube", at = @At("HEAD"), cancellable = true) private static void isShapeFullCube(VoxelShape voxelShape_1, CallbackInfoReturnable<Boolean> callback) { if (ModuleManager.getModule(Xray.class).isToggled()) { callback.setReturnValue(false); callback.cancel(); } }
Example #14
Source File: FluidPipeBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) { ArrayList<VoxelShape> shapes = new ArrayList<>(); if (blockState.get(ATTACHED_NORTH)) { shapes.add(NORTH); } if (blockState.get(ATTACHED_SOUTH)) { shapes.add(SOUTH); } if (blockState.get(ATTACHED_EAST)) { shapes.add(EAST); } if (blockState.get(ATTACHED_WEST)) { shapes.add(WEST); } if (blockState.get(ATTACHED_UP)) { shapes.add(UP); } if (blockState.get(ATTACHED_DOWN)) { shapes.add(DOWN); } if (shapes.isEmpty()) { return NONE; } else { return VoxelShapes.union(NONE, shapes.toArray(new VoxelShape[0])); } }
Example #15
Source File: MoonBerryBushBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext context) { if (blockState.get(AGE) == 0) { return SMALL_SHAPE; } else { return blockState.get(AGE) < 3 ? LARGE_SHAPE : super.getOutlineShape(blockState, blockView, blockPos, context); } }
Example #16
Source File: BramblesBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { return SHAPE; }
Example #17
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 #18
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 #19
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 #20
Source File: InfusionAltarBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) { return SHAPE; }
Example #21
Source File: CactusCollisionShapeListener.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
public VoxelShape getCollisionShape() { return collisionShape; }
Example #22
Source File: CactusCollisionShapeListener.java From Wurst7 with GNU General Public License v3.0 | 4 votes |
public void setCollisionShape(VoxelShape collisionShape) { this.collisionShape = collisionShape; }
Example #23
Source File: DeaderBushBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { return SHAPE; }
Example #24
Source File: TombstoneBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getCollisionShape(BlockState state, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { return SHAPES.get(state.get(FACING)); }
Example #25
Source File: TombstoneBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView blockView, BlockPos pos, EntityContext context) { return SHAPES.get(state.get(FACING)); }
Example #26
Source File: BreadCrumbsBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView blockView, BlockPos pos, EntityContext context) { return SHAPE; }
Example #27
Source File: WitchWaterBubbleColumnBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { return VoxelShapes.empty(); }
Example #28
Source File: HallowedTreasureChestBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getCollisionShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { return SHAPE; }
Example #29
Source File: HallowedTreasureChestBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) { return SHAPE; }
Example #30
Source File: InfusionPillarBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPosition, EntityContext entityContext) { return SHAPE; }