George Paton 1734e45646 Explosive block rework:
* All blocks now spawn entities when destroyed by an explosion, rather than instantly exploding
* Explosive/Waste barrels now fly off as an entity, exploding when contacting a surface
* All other explosives instead spawn a zero tick entity to prevent a stack overflow while retaining existing behaviour
* onShot behaviour added to simplify blocks that should explode when shot at
2024-05-08 13:16:20 +10:00

45 lines
1.1 KiB
Java

package com.hbm.blocks.generic;
import com.hbm.blocks.BlockBase;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class BlockFlammable extends BlockBase {
public int encouragement;
public int flammability;
public BlockFlammable(Material mat, int en, int flam) {
super(mat);
this.encouragement = en;
this.flammability = flam;
}
@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return flammability;
}
@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
return encouragement;
}
public boolean shouldIgnite(World world, int x, int y, int z) {
if(flammability == 0) return false;
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) == Blocks.fire) {
return true;
}
}
return false;
}
}