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;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.world.level.BlockGetter;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraft.world.level.block.Blocks;
|
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.phys.AABB;
|
|
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
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 {
|
|
|
|
|
2021-12-15 14:26:42 +01:00
|
|
|
private static final VoxelShape SHAPE = box(5, 0, 5, 11, 13, 11);
|
2020-02-02 19:43:40 +01:00
|
|
|
|
2020-02-02 18:00:52 +01:00
|
|
|
public BlockAnimalContainer() {
|
2021-12-15 14:26:42 +01:00
|
|
|
super("animal_container", BlockEntityAnimalContainer::new, Properties.copy(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-15 14:26:42 +01:00
|
|
|
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext 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-15 14:26:42 +01:00
|
|
|
public AABB getVisualizationBounds(Level level, BlockPos pos) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var tile = level.getBlockEntity(pos);
|
2021-12-04 15:40:09 +01:00
|
|
|
if (tile instanceof BlockEntityAnimalContainer) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var radius = ((BlockEntityAnimalContainer) tile).getRadius();
|
2020-02-02 18:00:52 +01:00
|
|
|
if (radius > 0)
|
2021-12-15 14:26:42 +01:00
|
|
|
return new AABB(pos).inflate(radius);
|
2020-02-02 18:00:52 +01:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|