Merge pull request #1353 from MellowArpeggiation/master

Fix spotlight beams crashing in nuclear explosions
This commit is contained in:
HbmMods 2024-02-23 08:27:40 +01:00 committed by GitHub
commit 8f840f5145
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 8 deletions

View File

@ -41,7 +41,12 @@ public class BlockFallout extends Block {
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
return block != Blocks.ice && block != Blocks.packed_ice ? (block.isLeaves(world, x, y - 1, z) ? true : (block == this && (world.getBlockMetadata(x, y - 1, z) & 7) == 7 ? true : block.isOpaqueCube() && block.getMaterial().blocksMovement())) : false;
if (block == Blocks.ice || block == Blocks.packed_ice) return false;
if (block.isLeaves(world, x, y - 1, z) && !block.isAir(world, x, y - 1, z)) return true;
if (block == this && (world.getBlockMetadata(x, y - 1, z) & 7) == 7) return true;
return block.isOpaqueCube() && block.getMaterial().blocksMovement();
}
@Override

View File

@ -250,8 +250,9 @@ public class Spotlight extends Block implements ISpotlight {
}
// If we encounter an existing beam, add a new INCOMING direction to the
// metadata
SpotlightBeam.setDirection(world, x, y, z, dir, true);
// metadata, and cancel propagation if something goes wrong
if (SpotlightBeam.setDirection(world, x, y, z, dir, true) == 0)
return;
propagateBeam(world, x, y, z, dir, distance);
}

View File

@ -69,6 +69,7 @@ public class SpotlightBeam extends BlockContainer {
// Returns the final metadata, so the caller can optionally remove the block
public static int setDirection(World world, int x, int y, int z, ForgeDirection dir, boolean state) {
TileEntityData te = (TileEntityData) world.getTileEntity(x, y, z);
if (te == null) return 0; // This shouldn't happen, and if it does, cancel propagation
int transformedMetadata = applyDirection(te.metadata, dir, state);
te.metadata = transformedMetadata;
return transformedMetadata;

View File

@ -211,12 +211,12 @@ public class EntityFalloutRain extends Entity {
float hardness = b.getBlockHardness(worldObj, x, y, z);
if(dist < 65 && hardness <= Blocks.stonebrick.getExplosionResistance(null) && hardness >= 0/* && !b.hasTileEntity(worldObj.getBlockMetadata(x, y, z))*/) {
Block bl = worldObj.getBlock(x, y - 1, z);
if(bl == Blocks.air) {
if(worldObj.getBlock(x, y - 1, z) == Blocks.air) {
for(int i = 0; i <= depth; i++) {
hardness = worldObj.getBlock(x, y + i, z).getBlockHardness(worldObj, x, y + i, z);
Block block = worldObj.getBlock(x, y + i, z);
hardness = block.getBlockHardness(worldObj, x, y + i, z);
if(hardness <= Blocks.stonebrick.getExplosionResistance(null) && hardness >= 0) {
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(worldObj, x + 0.5D, y + 0.5D + i, z + 0.5D, worldObj.getBlock(x, y + i, z), worldObj.getBlockMetadata(x, y + i, z));
EntityFallingBlockNT entityfallingblock = new EntityFallingBlockNT(worldObj, x + 0.5D, y + 0.5D + i, z + 0.5D, block, worldObj.getBlockMetadata(x, y + i, z));
entityfallingblock.canDrop = false; //turn off block drops because block dropping was coded by a mule with dementia
worldObj.spawnEntityInWorld(entityfallingblock);
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import com.hbm.blocks.BlockFallingNT;
import com.hbm.blocks.ISpotlight;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -91,7 +92,7 @@ public class EntityFallingBlockNT extends Entity {
public void onUpdate() {
if(this.getBlock().getMaterial() == Material.air) {
if(this.getBlock().getMaterial() == Material.air || this.getBlock() instanceof ISpotlight) {
this.setDead();
} else {
this.prevPosX = this.posX;