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

55 lines
2.1 KiB
Java
Raw Normal View History

2020-04-27 18:30:44 +02:00
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.INoItemBlock;
2021-12-15 16:24:53 +01:00
import net.minecraft.core.BlockPos;
2022-06-27 15:24:04 +02:00
import net.minecraft.util.RandomSource;
2021-12-15 16:24:53 +01:00
import net.minecraft.world.item.context.BlockPlaceContext;
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;
2021-12-15 16:24:53 +01:00
import net.minecraft.world.level.block.state.BlockState;
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-04-27 18:30:44 +02:00
public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock {
2020-04-27 18:30:44 +02:00
2022-06-27 15:24:04 +02:00
private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12);
2020-04-27 18:30:44 +02:00
public BlockLight() {
2023-07-08 12:32:27 +02:00
super("light", Properties.of().noCollission().lightLevel(s -> 15));
2020-04-27 18:30:44 +02:00
}
@Override
@OnlyIn(Dist.CLIENT)
2022-06-27 15:24:04 +02:00
public void animateTick(BlockState stateIn, Level levelIn, BlockPos pos, RandomSource rand) {
2021-12-15 16:30:22 +01:00
for (var i = 0; i < 2; i++)
2020-04-27 18:30:44 +02:00
NaturesAuraAPI.instance().spawnMagicParticle(
pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F,
rand.nextGaussian() * 0.015F, 0, rand.nextGaussian() * 0.015F,
0xffcb5c, rand.nextFloat() * 2 + 1, 50, -0.015F, true, true);
}
@Override
2023-02-15 23:45:50 +01:00
@SuppressWarnings("deprecation")
2021-12-15 16:24:53 +01:00
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
2022-06-27 15:24:04 +02:00
return BlockLight.SHAPE;
2020-04-27 18:30:44 +02:00
}
@Override
2023-02-15 23:45:50 +01:00
@SuppressWarnings("deprecation")
2021-12-15 16:24:53 +01:00
public boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) {
2020-04-27 18:30:44 +02:00
return true;
}
@Override
public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().withExistingParent("light", generator.mcLoc("block/air"))
.renderType("cutout_mipped").texture("particle", "block/light"));
2020-04-27 18:30:44 +02:00
}
}