Java Code Examples for net.minecraft.block.BlockState#canPlaceAt()
The following examples show how to use
net.minecraft.block.BlockState#canPlaceAt() .
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: RestlessCactusBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState state2, IWorld world, BlockPos pos, BlockPos pos2) { if (!state.canPlaceAt(world, pos)) { world.getBlockTickScheduler().schedule(pos, this, 1); } return super.getStateForNeighborUpdate(state, direction, state2, world, pos, pos2); }
Example 2
Source File: WitchWaterBubbleColumnBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction dir, BlockState state2, IWorld world, BlockPos pos, BlockPos pos2) { if (!state.canPlaceAt(world, pos)) { return HallowedBlocks.WITCH_WATER_BLOCK.getDefaultState(); } else { if (dir == Direction.DOWN) { world.setBlockState(pos, HallowedBlocks.WITCH_WATER_BUBBLE_COLUMN.getDefaultState().with(DRAG, calculateDrag(world, pos2)), 2); } else if (dir == Direction.UP && state2.getBlock() != HallowedBlocks.WITCH_WATER_BUBBLE_COLUMN && isStillWater(world, pos2)) { world.getBlockTickScheduler().schedule(pos, this, this.getTickRate(world)); } world.getFluidTickScheduler().schedule(pos, HallowedFluids.WITCH_WATER, HallowedFluids.WITCH_WATER.getTickRate(world)); return super.getStateForNeighborUpdate(state, dir, state2, world, pos, pos2); } }
Example 3
Source File: DeceasedGrassBlock.java From the-hallow with MIT License | 5 votes |
@Override public void grow(ServerWorld world, Random random, BlockPos blockPos, BlockState blockState) { BlockPos upPos = blockPos.up(); BlockState grassBlock = HallowedBlocks.DECEASED_GRASS_BLOCK.getDefaultState(); label48: for (int i = 0; i < 128; ++i) { BlockPos randomPos = upPos; for (int j = 0; j < i / 16; ++j) { randomPos = randomPos.add(random.nextInt(3) - 1, (random.nextInt(3) - 1) * random.nextInt(3) / 2, random.nextInt(3) - 1); if (world.getBlockState(randomPos.down()).getBlock() != this || world.getBlockState(randomPos).isFullCube(world, randomPos)) { continue label48; } } BlockState randomBlockState = world.getBlockState(randomPos); if (randomBlockState.getBlock() == grassBlock.getBlock() && random.nextInt(10) == 0) { ((Fertilizable) grassBlock.getBlock()).grow(world, random, randomPos, randomBlockState); } if (randomBlockState.isAir()) { BlockState stateToPlace; if (random.nextInt(8) == 0) { List<ConfiguredFeature<?, ?>> list = world.getBiomeAccess().getBiome(randomPos).getFlowerFeatures(); if (list.isEmpty()) { continue; } stateToPlace = ((FlowerFeature) ((DecoratedFeatureConfig) (list.get(0)).config).feature.feature).getFlowerToPlace(random, randomPos, list.get(0).config); } else { stateToPlace = grassBlock; } if (stateToPlace.canPlaceAt(world, randomPos)) { world.setBlockState(randomPos, stateToPlace, 3); } } } }
Example 4
Source File: PumpkinPieBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState state2, IWorld iWorld, BlockPos pos, BlockPos pos2) { return direction == Direction.DOWN && !state.canPlaceAt(iWorld, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, state2, iWorld, pos, pos2); }
Example 5
Source File: BreadCrumbsBlock.java From the-hallow with MIT License | 4 votes |
@SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState state2, IWorld world, BlockPos pos, BlockPos pos2) { return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, state2, world, pos, pos2); }
Example 6
Source File: RedstoneWireTurbo.java From fabric-carpet with MIT License | 4 votes |
private void identifyNode(final World worldIn, final UpdateNode upd1) { final BlockPos pos = upd1.self; final BlockState oldState = worldIn.getBlockState(pos); upd1.currentState = oldState; // Some neighbors of redstone wire are other kinds of blocks. // These need to receive block updates to inform them that // redstone wire values have changed. final Block block = oldState.getBlock(); if (block != wire) { // Mark this block as not redstone wire and therefore // requiring updates upd1.type = UpdateNode.Type.OTHER; // Non-redstone blocks may propagate updates, but those updates // are not handled by this accelerator. Therefore, we do not // expand this position's neighbors. return; } // One job of RedstoneWireBlock.neighborChanged is to convert // redstone wires to items if the block beneath was removed. // With this accelerator, RedstoneWireBlock.neighborChanged // is only typically called for a single wire block, while // others are processed internally by the breadth first search // algorithm. To preserve this game behavior, this check must // be replicated here. if (!oldState.canPlaceAt(worldIn, pos)) { // Pop off the redstone dust Block.dropStacks(oldState, worldIn, pos); worldIn.removeBlock(pos, false); // Mark this position as not being redstone wire upd1.type = UpdateNode.Type.OTHER; // Note: Sending updates to air blocks leads to an empty method. // Testing shows this to be faster than explicitly avoiding updates to // air blocks. return; } // If the above conditions fail, then this is a redstone wire block. upd1.type = UpdateNode.Type.REDSTONE; }