tcr/java/src/common/block/BlockBlackenedSoil.java

56 lines
2 KiB
Java
Raw Normal View History

2025-05-07 18:19:24 +02:00
package common.block;
2025-04-11 15:42:59 +02:00
2025-05-07 18:19:24 +02:00
import common.init.Blocks;
import common.init.Config;
import common.item.CheatTab;
import common.item.Item;
import common.material.Material;
import common.model.Model;
import common.model.ModelProvider;
import common.rng.Random;
import common.world.BlockPos;
import common.world.State;
import common.world.WorldServer;
2025-04-11 15:42:59 +02:00
public class BlockBlackenedSoil extends Block
{
public BlockBlackenedSoil()
{
super(Material.grass);
this.setTickRandomly();
this.setTab(CheatTab.tabNature);
}
public void updateTick(WorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (worldIn.getLightFromNeighbors(pos.up()) < 2 && worldIn.getState(pos.up()).getBlock().getLightOpacity() > 6)
{
if(Config.darkSoilDecay)
worldIn.setState(pos, Blocks.blackened_dirt.getState());
}
else if (Config.darkSoilSpread && worldIn.getLightFromNeighbors(pos.up()) >= 1)
{
for (int i = 0; i < 4; i++)
{
BlockPos blockpos = pos.add(rand.zrange(3) - 1, rand.zrange(5) - 3, rand.zrange(3) - 1);
Block block = worldIn.getState(blockpos.up()).getBlock();
State iblockstate = worldIn.getState(blockpos);
if ((iblockstate.getBlock() == Blocks.dirt || iblockstate.getBlock() == Blocks.grass || iblockstate.getBlock() == Blocks.blackened_dirt) && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6)
{
worldIn.setState(blockpos, Blocks.blackened_soil.getState());
}
}
}
}
public Item getItemDropped(State state, Random rand, int fortune)
{
return Blocks.blackened_dirt.getItemDropped(Blocks.blackened_dirt.getState(), rand, fortune);
}
2025-05-04 20:27:55 +02:00
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("blackened_dirt").add().d().u("blackened_soil_top").nswe("blackened_soil_side");
2025-04-11 15:42:59 +02:00
}
}