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

61 lines
2.1 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;
2022-06-27 15:24:04 +02:00
import net.minecraft.world.level.block.Block;
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;
2024-02-03 14:56:07 +01:00
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
2020-02-02 18:00:52 +01:00
2020-02-02 19:43:40 +01:00
public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
2022-06-27 15:24:04 +02:00
private static final VoxelShape SHAPE = Block.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
2023-02-15 23:45:50 +01:00
@SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
2022-06-27 15:24:04 +02:00
return BlockAnimalContainer.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
}