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

45 lines
1.6 KiB
Java
Raw Normal View History

2020-02-02 22:21:55 +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.BlockEntitySnowCreator;
2020-02-02 23:27:40 +01:00
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
2021-12-15 16:24:53 +01:00
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.AABB;
2024-02-03 14:56:07 +01:00
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
2020-02-02 22:21:55 +01:00
2020-02-02 23:27:40 +01:00
public class BlockSnowCreator extends BlockContainerImpl implements IVisualizable, ICustomBlockState {
2021-12-15 16:24:53 +01:00
2020-02-02 22:21:55 +01:00
public BlockSnowCreator() {
2021-12-19 15:32:45 +01:00
super("snow_creator", BlockEntitySnowCreator.class, Properties.copy(Blocks.STONE_BRICKS));
2020-02-02 22:21:55 +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 BlockEntitySnowCreator) {
2021-12-15 16:30:22 +01:00
var radius = ((BlockEntitySnowCreator) tile).getRange();
2020-02-02 22:21:55 +01:00
if (radius > 0)
2021-12-15 16:24:53 +01:00
return new AABB(pos).inflate(radius);
2020-02-02 22:21:55 +01:00
}
return null;
}
@Override
2021-12-04 15:40:09 +01:00
public int getVisualizationColor(Level level, BlockPos pos) {
2020-02-02 22:21:55 +01:00
return 0xdbe9ff;
}
2020-02-02 23:27:40 +01:00
@Override
public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
generator.modLoc("block/" + this.getBaseName()),
generator.modLoc("block/" + this.getBaseName() + "_top"),
generator.modLoc("block/" + this.getBaseName() + "_top")));
}
2020-02-02 22:21:55 +01:00
}