change fire type behaviour

This commit is contained in:
Sen 2025-05-25 15:04:14 +02:00
parent 7299ab8e5c
commit d41ad4db01
3 changed files with 33 additions and 14 deletions

View file

@ -125,7 +125,7 @@ public class BlockFire extends Block
// flag = true;
// }
if (!flag && worldIn.isRaining() && this.canDie(worldIn, pos))
if (!flag && this.canDie(worldIn, pos))
{
worldIn.setBlockToAir(pos);
}
@ -205,7 +205,7 @@ public class BlockFire extends Block
l1 /= 2;
}
if (l1 > 0 && rand.zrange(j1) <= l1 && (!worldIn.isRaining() || !this.canDie(worldIn, blockpos)))
if (l1 > 0 && rand.zrange(j1) <= l1 && !this.canDie(worldIn, blockpos))
{
int i2 = i + rand.zrange(5) / 4;
@ -225,9 +225,9 @@ public class BlockFire extends Block
}
}
protected boolean canDie(World worldIn, BlockPos pos)
protected boolean canDie(World world, BlockPos pos)
{
return worldIn.isRainingAt(pos, true) || worldIn.isRainingAt(pos.west(), true) || worldIn.isRainingAt(pos.east(), true) || worldIn.isRainingAt(pos.north(), true) || worldIn.isRainingAt(pos.south(), true);
return world.isRaining() && (world.isRainingAt(pos, true) || world.isRainingAt(pos.west(), true) || world.isRainingAt(pos.east(), true) || world.isRainingAt(pos.north(), true) || world.isRainingAt(pos.south(), true));
}
public boolean requiresUpdates()
@ -235,31 +235,31 @@ public class BlockFire extends Block
return false;
}
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
protected void catchOnFire(World world, BlockPos pos, int chance, Random rand, int age)
{
int i = FlammabilityRegistry.getFlammability(worldIn.getState(pos).getBlock());
int i = FlammabilityRegistry.getFlammability(world.getState(pos).getBlock());
if (random.zrange(chance) < i)
if (rand.zrange(chance) < i)
{
State iblockstate = worldIn.getState(pos);
State iblockstate = world.getState(pos);
if (random.zrange(age + 10) < 5 && !worldIn.isRainingAt(pos, true))
if (rand.zrange(age + 10) < 5 && !world.isRainingAt(pos, true))
{
int j = age + random.zrange(5) / 4;
int j = age + rand.zrange(5) / 4;
if (j > 15)
{
j = 15;
}
worldIn.setState(pos, this.getState().withProperty(AGE, Integer.valueOf(j)), 3);
world.setState(pos, this.getState().withProperty(AGE, Integer.valueOf(j)), 3);
}
else
{
worldIn.setBlockToAir(pos);
world.setBlockToAir(pos);
}
iblockstate.getBlock().onDestroyedByFire(worldIn, pos, iblockstate);
iblockstate.getBlock().onDestroyedByFire(world, pos, iblockstate);
// if (iblockstate.getBlock() == Blocks.tnt)
// {
// Blocks.tnt.onBlockDestroyedByPlayer(worldIn, pos, iblockstate.withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)));

View file

@ -0,0 +1,18 @@
package common.block.natural;
import common.rng.Random;
import common.util.BlockPos;
import common.world.World;
public class BlockSoulFire extends BlockTintedFire {
public BlockSoulFire() {
super(0x4010ff);
}
protected void catchOnFire(World world, BlockPos pos, int chance, Random rand, int age) {
}
protected boolean canDie(World world, BlockPos pos) {
return super.canDie(world, pos) || world.rand.chance(20);
}
}

View file

@ -77,6 +77,7 @@ import common.block.natural.BlockSandStone;
import common.block.natural.BlockSlime;
import common.block.natural.BlockSnow;
import common.block.natural.BlockSnowBlock;
import common.block.natural.BlockSoulFire;
import common.block.natural.BlockSoulSand;
import common.block.natural.BlockStone;
import common.block.natural.BlockTintedFire;
@ -428,7 +429,7 @@ public abstract class BlockRegistry {
}
registerBlock(252, "soul_fire",
(new BlockTintedFire(0x4010ff)).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer der Seelen"));
(new BlockSoulFire()).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Feuer der Seelen"));
registerBlock(253, "black_fire",
(new BlockTintedFire(0x202020)).setHardness(0.0F).setLightLevel(1.0F).setStepSound(SoundType.CLOTH).setDisplay("Dunkles Feuer"));
registerBlock(254, "web", (new BlockWeb()).setLightOpacity(1).setHardness(4.0F).setDisplay("Spinnennetz"));