2020-02-02 18:00:52 +01:00
|
|
|
package de.ellpeck.naturesaura.blocks;
|
|
|
|
|
|
|
|
import de.ellpeck.naturesaura.api.render.IVisualizable;
|
2021-12-04 15:40:09 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalContainer;
|
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;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.tileentity.BlockEntity;
|
2020-02-02 18:00:52 +01:00
|
|
|
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;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.level.IBlockReader;
|
|
|
|
import net.minecraft.level.Level;
|
2020-02-02 18:00:52 +01:00
|
|
|
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() {
|
2021-12-04 15:40:09 +01:00
|
|
|
super("animal_container", BlockEntityAnimalContainer::new, Properties.from(Blocks.STONE));
|
2020-02-02 19:43:40 +01:00
|
|
|
}
|
|
|
|
|
2020-02-05 14:30:17 +01:00
|
|
|
@Override
|
|
|
|
protected boolean hasWaterlogging() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-02 19:43:40 +01:00
|
|
|
@Override
|
2021-12-04 15:40:09 +01:00
|
|
|
public VoxelShape getShape(BlockState state, IBlockReader levelIn, BlockPos pos, ISelectionContext context) {
|
2020-02-02 19:43:40 +01:00
|
|
|
return SHAPE;
|
2020-02-02 18:00:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-12-04 15:40:09 +01:00
|
|
|
public AxisAlignedBB getVisualizationBounds(Level level, BlockPos pos) {
|
|
|
|
BlockEntity tile = level.getBlockEntity(pos);
|
|
|
|
if (tile instanceof BlockEntityAnimalContainer) {
|
|
|
|
int radius = ((BlockEntityAnimalContainer) tile).getRadius();
|
2020-02-02 18:00:52 +01:00
|
|
|
if (radius > 0)
|
|
|
|
return new AxisAlignedBB(pos).grow(radius);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-12-04 15:40:09 +01:00
|
|
|
public int getVisualizationColor(Level level, BlockPos pos) {
|
2020-02-02 18:00:52 +01:00
|
|
|
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
|
|
|
}
|