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

59 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;
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.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 {
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-19 15:32:45 +01:00
super("animal_container", BlockEntityAnimalContainer.class, Properties.copy(Blocks.STONE));
2020-02-02 19:43:40 +01:00
}
@Override
protected boolean hasWaterlogging() {
return true;
}
2020-02-02 19:43:40 +01:00
@Override
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)
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)
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
}