net.minecraft.block.entity.ChestBlockEntity Java Examples

The following examples show how to use net.minecraft.block.entity.ChestBlockEntity. 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 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 #2
Source File: ChestEspHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
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;
}