add blackened stuff

This commit is contained in:
Sen 2025-04-11 15:42:59 +02:00
parent 262a4adfe0
commit 6d912ae7ac
6 changed files with 138 additions and 0 deletions

View file

@ -0,0 +1,46 @@
package game.block;
import game.init.Blocks;
import game.init.Config;
import game.item.CheatTab;
import game.material.Material;
import game.rng.Random;
import game.world.BlockPos;
import game.world.State;
import game.world.WorldServer;
public class BlockBlackenedDirt extends Block
{
public BlockBlackenedDirt()
{
super(Material.ground);
this.setTickRandomly();
this.setTab(CheatTab.tabNature);
}
public void updateTick(WorldServer worldIn, BlockPos pos, State state, Random rand)
{
if (Config.darkDirtSpread)
{
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)
{
worldIn.setState(blockpos, Blocks.blackened_dirt.getState());
}
else if (iblockstate.getBlock() == Blocks.grass && worldIn.getLightFromNeighbors(blockpos.up()) >= 2 && block.getLightOpacity() <= 6)
{
worldIn.setState(blockpos, Blocks.blackened_soil.getState());
}
else if (iblockstate.getBlock() == Blocks.stone && rand.chance(25))
{
worldIn.setState(blockpos, Blocks.blackened_stone.getState());
}
}
}
}
}

View file

@ -0,0 +1,54 @@
package game.block;
import game.init.Blocks;
import game.init.Config;
import game.item.CheatTab;
import game.item.Item;
import game.material.Material;
import game.renderer.blockmodel.ModelBlock;
import game.rng.Random;
import game.world.BlockPos;
import game.world.State;
import game.world.WorldServer;
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);
}
public ModelBlock getModel(String name, State state) {
return new ModelBlock("blackened_dirt").add().d().u("blackened_soil_top").nswe("blackened_soil_side");
}
}

View file

@ -0,0 +1,20 @@
package game.block;
import game.init.Blocks;
import game.init.ItemRegistry;
import game.item.CheatTab;
import game.item.Item;
import game.material.Material;
import game.rng.Random;
import game.world.State;
public class BlockBlackenedStone extends Block {
public BlockBlackenedStone() {
super(Material.rock);
this.setTab(CheatTab.tabNature);
}
public Item getItemDropped(State state, Random rand, int fortune) {
return ItemRegistry.getItemFromBlock(Blocks.blackened_cobble);
}
}

View file

@ -195,6 +195,9 @@ public abstract class BlockRegistry {
(new BlockSoulSand()).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Seelensand").setShovelHarvestable());
registerBlock(23, "glowstone", (new BlockGlowstone(Material.glass)).setHardness(0.3F).setStepSound(SoundType.GLASS).setLightLevel(1.0F)
.setDisplay("Glowstone"));
registerBlock(24, "blackened_stone", (new BlockBlackenedStone()).setHardness(1.5F).setResistance(10.0F).setStepSound(SoundType.STONE).setDisplay("Schwarzstein"));
registerBlock(25, "blackened_cobble", (new Block(Material.rock)).setHardness(2.0F).setResistance(10.0F).setStepSound(SoundType.STONE)
.setDisplay("Schwarzbruchstein").setTab(CheatTab.tabNature));
registerFluid(32, 33, "water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, TextureWaterFX.class, TextureWaterFlowFX.class);
@ -254,6 +257,10 @@ public abstract class BlockRegistry {
registerBlock(133, "moon_cheese", (new BlockTreasure(Material.gourd)).setHardness(1.5F).setResistance(5.0F)
.setStepSound(SoundType.CLOTH).setDisplay("Mondkäse").setTab(CheatTab.tabNature));
registerBlock(134, "slime_block", (new BlockSlime()).setDisplay("Schleimblock").setStepSound(SoundType.SLIME));
registerBlock(135, "blackened_dirt",
(new BlockBlackenedDirt()).setHardness(0.5F).setStepSound(SoundType.GRAVEL).setDisplay("Schwarzerde").setShovelHarvestable());
registerBlock(136, "blackened_soil",
(new BlockBlackenedSoil()).setHardness(0.6F).setStepSound(SoundType.GRASS).setDisplay("Schwarzgrund").setShovelHarvestable());

View file

@ -3,6 +3,7 @@ package game.init;
import game.block.Block;
import game.block.BlockBeacon;
import game.block.BlockBed;
import game.block.BlockBlackenedSoil;
import game.block.BlockBush;
import game.block.BlockCactus;
import game.block.BlockCauldron;
@ -41,9 +42,13 @@ import game.block.BlockTripWireHook;
public abstract class Blocks {
public static final Block air = get("air");
public static final Block stone = get("stone");
public static final Block blackened_stone = get("blackened_stone");
public static final BlockGrass grass = (BlockGrass)get("grass");
public static final BlockBlackenedSoil blackened_soil = (BlockBlackenedSoil)get("blackened_soil");
public static final Block dirt = get("dirt");
public static final Block blackened_dirt = get("blackened_dirt");
public static final Block cobblestone = get("cobblestone");
public static final Block blackened_cobble = get("blackened_cobble");
public static final Block oak_planks = get("oak_planks");
public static final Block spruce_planks = get("spruce_planks");
public static final Block birch_planks = get("birch_planks");

View file

@ -285,8 +285,14 @@ public abstract class Config {
public static boolean hookCheckDamage = true;
@Var(name = "grassSpread")
public static boolean grassSpread = true;
@Var(name = "blackenedSoilSpread")
public static boolean darkSoilSpread = true;
@Var(name = "blackenedDirtSpread")
public static boolean darkDirtSpread = true;
@Var(name = "grassDecay")
public static boolean grassDecay = true;
@Var(name = "blackenedSoilDecay")
public static boolean darkSoilDecay = true;
@Var(name = "grassDrying")
public static boolean grassDry = true;
@Var(name = "tallgrassDrying")