Java Code Examples for net.minecraft.world.IWorld#getBlockEntity()

The following examples show how to use net.minecraft.world.IWorld#getBlockEntity() . 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: FeatureUtils.java    From the-hallow with MIT License 5 votes vote down vote up
default void setSpawner(IWorld world, BlockPos pos, EntityType<?> entity) {
	world.setBlockState(pos, Blocks.SPAWNER.getDefaultState(), 2);
	BlockEntity be = world.getBlockEntity(pos);
	if (be instanceof MobSpawnerBlockEntity) {
		((MobSpawnerBlockEntity) be).getLogic().setEntityId(entity);
	}
}
 
Example 2
Source File: FeatureUtils.java    From the-hallow with MIT License 5 votes vote down vote up
default void setLootChest(IWorld world, BlockPos pos, Identifier lootTable, Random rand) {
	world.setBlockState(pos, Blocks.CHEST.getDefaultState(), 2);
	
	BlockEntity entity = world.getBlockEntity(pos);
	if (entity instanceof ChestBlockEntity) {
		((ChestBlockEntity) entity).setLootTable(lootTable, rand.nextLong());
	}
}
 
Example 3
Source File: WitchWaterFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public void beforeBreakingBlock(IWorld iWorld, BlockPos blockPos, BlockState blockState) {
	BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() ? iWorld.getBlockEntity(blockPos) : null;
	Block.dropStacks(blockState, iWorld.getWorld(), blockPos, blockEntity);
}
 
Example 4
Source File: BloodFluid.java    From the-hallow with MIT License 4 votes vote down vote up
@Override
public void beforeBreakingBlock(IWorld iWorld, BlockPos blockPos, BlockState blockState) {
	BlockEntity blockEntity = blockState.getBlock().hasBlockEntity() ? iWorld.getBlockEntity(blockPos) : null;
	Block.dropStacks(blockState, iWorld.getWorld(), blockPos, blockEntity);
}
 
Example 5
Source File: FluidWrapper.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void beforeBreakingBlock(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1) {
    BlockEntity blockEntity_1 = blockState_1.getBlock().hasBlockEntity() ? iWorld_1.getBlockEntity(blockPos_1) : null;
    Block.dropStacks(blockState_1, iWorld_1.getWorld(), blockPos_1, blockEntity_1);
}