NaturesAura/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java

55 lines
2 KiB
Java
Raw Normal View History

2020-02-02 18:00:52 +01:00
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.render.IVisualizable;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalContainer;
2020-02-02 19:43:40 +01:00
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
2020-02-02 18:00:52 +01:00
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
2020-02-02 19:43:40 +01:00
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
2020-02-02 18:00:52 +01:00
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
2020-02-02 19:43:40 +01:00
public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11);
2020-02-02 18:00:52 +01:00
public BlockAnimalContainer() {
2020-02-02 19:43:40 +01:00
super("animal_container", TileEntityAnimalContainer::new, ModBlocks.prop(Blocks.STONE));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
2020-02-02 18:00:52 +01:00
}
@Override
@OnlyIn(Dist.CLIENT)
public AxisAlignedBB getVisualizationBounds(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityAnimalContainer) {
int radius = ((TileEntityAnimalContainer) tile).getRadius();
if (radius > 0)
return new AxisAlignedBB(pos).grow(radius);
}
return null;
}
@Override
@OnlyIn(Dist.CLIENT)
public int getVisualizationColor(World world, BlockPos pos) {
return 0x42ddf5;
}
2020-02-02 19:43:40 +01:00
@Override
public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName())));
}
2020-02-02 18:00:52 +01:00
}