Java Code Examples for net.minecraft.block.BlockState#contains()
The following examples show how to use
net.minecraft.block.BlockState#contains() .
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: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public BlockState getPlacementState(ItemPlacementContext placementContext) { final BlockState blockState = this.getDefaultState().with(FACING, placementContext.getPlayerFacing().getOpposite()); if (blockState.contains(Properties.WATERLOGGED)) { final FluidState fluidState = placementContext.getWorld().getFluidState(placementContext.getBlockPos()); return blockState.with(Properties.WATERLOGGED, fluidState.getFluid() == Fluids.WATER); } return blockState; }
Example 2
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState otherState, IWorld world, BlockPos pos, BlockPos otherPos) { if (state.contains(Properties.WATERLOGGED) && state.get(Properties.WATERLOGGED)) { world.getFluidTickScheduler().schedule(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return super.getStateForNeighborUpdate(state, direction, otherState, world, pos, otherPos); }
Example 3
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public Fluid tryDrainFluid(IWorld world, BlockPos pos, BlockState state) { if (state.contains(Properties.WATERLOGGED)) { return Waterloggable.super.tryDrainFluid(world, pos, state); } else { return Fluids.EMPTY; } }
Example 4
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 5 votes |
@Override public boolean tryFillWithFluid(IWorld world, BlockPos pos, BlockState blockState, FluidState fluidState) { if (blockState.contains(Properties.WATERLOGGED)) { return Waterloggable.super.tryFillWithFluid(world, pos, blockState, fluidState); } else { return false; } }
Example 5
Source File: HallowedTreasureChestBlockEntityRenderer.java From the-hallow with MIT License | 5 votes |
@Override public void render(HallowedTreasureChestBlockEntity treasureChest, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { matrixStack.push(); BlockState state; if(treasureChest.hasWorld()) { state = treasureChest.getCachedState(); } else { state = HallowedBlocks.HALLOWED_TREASURE_CHEST.getDefaultState(); } // initial translation to center chest -- default renders upside down. matrixStack.multiply(RIGHTSIDE_UP); matrixStack.translate(0.215, -0.57, -0.215); // rotate based on facing direction if (state.contains(HallowedTreasureChestBlock.FACING)) { switch (state.get(HallowedTreasureChestBlock.FACING)) { case NORTH: matrixStack.translate(0.57, 0, 0); matrixStack.multiply(SOUTH_ROTATION_QUAT); break; case EAST: matrixStack.translate(0.57, 0, -0.57); matrixStack.multiply(EAST_ROTATION_QUAT); break; case SOUTH: matrixStack.translate(0, 0, -0.57); matrixStack.multiply(NORTH_ROTATION_QUAT); break; case WEST: matrixStack.multiply(WEST_ROTATION_QUAT); break; default: break; } } // flip & scale to size matrixStack.multiply(NORTH_ROTATION_QUAT); matrixStack.scale(0.57f, 0.57f, 0.57f); // render chest chestModel.render(matrixStack, vertexConsumerProvider.getBuffer(RenderLayer.getEntityCutout(TEXTURE)), i, j, 1f, 1f, 1f, 1f); matrixStack.pop(); }
Example 6
Source File: ChestEspHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private Box getBoxFromChest(ChestBlockEntity chestBE) { BlockState state = chestBE.getCachedState(); if(!state.contains(ChestBlock.CHEST_TYPE)) return null; ChestType chestType = state.get(ChestBlock.CHEST_TYPE); // ignore other block in double chest if(chestType == ChestType.LEFT) return null; BlockPos pos = chestBE.getPos(); if(!BlockUtils.canBeClicked(pos)) return null; Box box = BlockUtils.getBoundingBox(pos); // larger box for double chest if(chestType != ChestType.SINGLE) { BlockPos pos2 = pos.offset(ChestBlock.getFacing(state)); if(BlockUtils.canBeClicked(pos2)) { Box box2 = BlockUtils.getBoundingBox(pos2); box = box.union(box2); } } return box; }
Example 7
Source File: MixinBlock.java From Sandbox with GNU Lesser General Public License v3.0 | 5 votes |
/** * @author B0undarybreaker */ @Deprecated @Inject(method = "getFluidState", at = @At("HEAD"), cancellable = true) private void getWaterloggedFluidState(BlockState state, CallbackInfoReturnable<FluidState> info) { if (state.contains(Properties.WATERLOGGED)) info.setReturnValue(state.get(Properties.WATERLOGGED) ? Fluids.WATER.getDefaultState() : Fluids.EMPTY.getDefaultState()); }
Example 8
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState blockState) { return blockState.contains(Properties.WATERLOGGED) && blockState.get(Properties.WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(blockState); }
Example 9
Source File: TinyPumpkinBlock.java From the-hallow with MIT License | 4 votes |
@Override public boolean canFillWithFluid(BlockView blockView, BlockPos pos, BlockState state, Fluid fluid) { return state.contains(Properties.WATERLOGGED) && Waterloggable.super.canFillWithFluid(blockView, pos, state, fluid); }