Jump to content

Recommended Posts

Posted

Hello,

I am working on a mod in which a gas will explode should it come in contact with a flame source, we have the gas exploding but on explosion the blocks disappear but you can not walk through the area without glitching. when you try to break or place a block around you you notice that the blocks destroyed by the explosion never were destroyed but just invisible. this is fixed by disconnecting and reconnecting but we do not want this glitch at all, we are looking for some help fixing it! here is our basicgas file with the explosion code:

 

 

package com.BlackMage.BluTech.Gases;

import java.util.Random;

import com.BlackMage.BluTech.TileEntity.TileGas;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;

public abstract class BasicGas extends BlockContainer{

public static int Pressure;
public boolean canExplode;
public boolean canBurn;
public boolean isDestructive;
public Fluid blocksFluid;
public static int Weight;//oxygen has the weight of 5, heavier sinks lighter floats


public BasicGas()
{
	super(Material.circuits);
	setLightOpacity(lightOpacity);

}

@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
	if(block.equals(Blocks.fire) || (block.equals(Blocks.lava) || (block.equals(Blocks.torch) && world.difficultySetting == EnumDifficulty.NORMAL || world.difficultySetting == EnumDifficulty.HARD)))
	{
		if(block.equals(Blocks.fire) || (block.equals(Blocks.lava) || (block.equals(Blocks.torch))))
		{
			world.setBlockToAir(x, y, z);
			FlameContact(world, x, y, z);
		}

	}
}

public void explode(World world, int x, int y, int z)
{
	// Make sure that the gas is able to explode
	if(canExplode)
	{
		// Delete the current block and cause the explosion!
		world.createExplosion(null, x, y, z, 5F, true);
	}
}

public void FlameContact(World world, int x, int y, int z)
{
	if(canExplode)
	{
		this.explode(world, x, y, z);
	}
	else if(canBurn)
	{
		int tempY = y - 1;
		while(world.getBlock(x, tempY, z) == this || world.getBlock(x, tempY, z) == Blocks.air || world.getBlock(x, tempY, z).isReplaceable(world, x, tempY, z))
		{
			tempY--;
		}

		tempY++;

		world.setBlock(x, y, z, Blocks.air);
		world.removeTileEntity(x, y, z);
		world.setBlock(x, tempY, z, Blocks.fire);
	}
}

public boolean setBlockTransparent()
{
	return true;
}

@Override
public boolean isReplaceable(IBlockAccess world, int i, int j, int k)
{
	return true;
}

@Override
public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion)
{	
	if( explosion.explosionX != x && explosion.explosionY != y && explosion.explosionZ != z)
	{
		FlameContact(world, x, y, z);	
	}
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
    {
        return null;
    }

/**
     * Returns the quantity of items to drop on block destruction.
     */
@Override
    public int quantityDropped(Random par1Random)
    {
        return 0;
    }

    /**
     * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha
     */
@Override
    public int getRenderBlockPass()
    {
        return 1;
    }

    /**
     * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two
     * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
     */
@Override
    public boolean isOpaqueCube()
    {
        return false;
    }

    public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
    	 if (par5Entity instanceof EntityLivingBase) {
    	  ((EntityLivingBase) par5Entity).addPotionEffect(new PotionEffect(Potion.confusion.getId(), 100, 2));
    	 }
  }

    /**
     * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
     */
//	@Override
//    public boolean renderAsNormalBlock()
//    {
//        return false;
//    }


}

 

 

Any ideas to why this is not properly removing the blocks destroyed by the explosion?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.