package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalContainer; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.tileentity.BlockEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.level.IBlockReader; import net.minecraft.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11); public BlockAnimalContainer() { super("animal_container", BlockEntityAnimalContainer::new, Properties.from(Blocks.STONE)); } @Override protected boolean hasWaterlogging() { return true; } @Override public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) { return SHAPE; } @Override @OnlyIn(Dist.CLIENT) public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) { BlockEntity tile = level.getBlockEntity(pos); if (tile instanceof BlockEntityAnimalContainer) { int radius = ((BlockEntityAnimalContainer) tile).getRadius(); if (radius > 0) return new AxisAlignedBB(pos).grow(radius); } return null; } @Override @OnlyIn(Dist.CLIENT) public int getVisualizationColor(Level level, BlockPos pos) { return 0x42ddf5; } @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); } }