Jump to content

Recommended Posts

Posted

Hello all! I have extended the Explosion base class and am overriding the doExplosionB(boolean b) function. For some reason, the explosion particles are not rendering. This is the code that is being executed:

 


LogHelper.info("I'm spawning a HUGE explosion particle at " + this.explosionX + ", " + this.explosionY + ", " + this.explosionZ);
EntityFX partExpl = new EntityHugeExplodeFX(this.worldObj,this.explosionX,this.explosionY,this.explosionZ,1.0D,1.0D,1.0D);
Minecraft.getMinecraft().effectRenderer.addEffect(partExpl);

//this.worldObj.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);

 

The LogHelper is printing out to chat, so I know the code is being executed, but the particles just won't render. (The last line which is commented out is what was originally there and also did not work.) Any suggestions as to what I could be doing wrong? (If more code is needed, let me know.) Thanks in advance!

Able to differentiate the difference of a sum and an integral.

Posted

So here's the snippet inside the entity class which is calling the explosion (which is basically copying the Creeper's code):

 

protected void makeExplosions()
    {
        if (!this.worldObj.isRemote)
        {
            boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");

            if (this.getPowered())
            {
                M4thThings.explosionHandler.createExplosion(this.worldObj,this,this.posX,this.posY,this.posZ,(float)(this.radius*2),flag,soundChoice);
                //this.worldObj.createExplosion(this,this.posX,this.posY,this.posZ,(float)(this.radius * 2), flag);
            }
            else
            {
                M4thThings.explosionHandler.createExplosion(this.worldObj,this,this.posX,this.posY,this.posZ,(float)this.radius,flag,soundChoice);
                //this.worldObj.createExplosion(this,this.posX,this.posY,this.posZ,(float)this.radius,flag);
            }

            this.setDead();
        }
    }

 

Then here's the ExplosionHandler class which starts creating the explosion (which is adapted from the Vanilla World class object):

 

public class ExplosionHandler {

    public static M4thCustomExplosion createExplosion(World world,Entity entity, double x, double y, double z, float size, boolean destroyBlocks,int explosionSoundChoice)
    {
        return newExplosion(world,entity,x,y,z,size,false,destroyBlocks,explosionSoundChoice);
    }

    public static M4thCustomExplosion newExplosion(World world, Entity entity, double x, double y, double z, float size, boolean par9, boolean destroyBlocks,int explosionSoundChoice)
    {
        M4thCustomExplosion explosion = new M4thCustomExplosion(world,entity,x,y,z,size);

        explosion.setExplosionSound(explosionSoundChoice);

        explosion.isFlaming = par9;
        explosion.isSmoking = destroyBlocks;
        if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(world,explosion))
        {
            return explosion;
        }
        explosion.doExplosionA();
        explosion.doExplosionB(true);
        return explosion;
    }
}

 

And then we have the M4thCustomExplosion class which extends the Vanilla Explosion class. The Only method of the superclass that is being overridden is doExplosionB (where the only code that has been altered is the first 15 or so lines):

 

@Override
    public void doExplosionB(boolean p_77279_1_) {

        this.worldObj.playSoundEffect(this.explosionX, this.explosionY, this.explosionZ, soundString, soundVolume, soundPitch);

        if (this.explosionSize >= 2.0F && this.isSmoking) {
            LogHelper.info("I'm spawning a HUGE explosion particle at " + this.explosionX + ", " + this.explosionY + ", " + this.explosionZ);
            //try something new
            EntityFX partExpl = new EntityHugeExplodeFX(this.worldObj,this.explosionX,this.explosionY,this.explosionZ,1.0D,1.0D,1.0D);
            Minecraft.getMinecraft().effectRenderer.addEffect(partExpl);

            //this.worldObj.spawnParticle("hugeexplosion", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);

        } else {
            LogHelper.info("I'm spawning a large explosion particle at " + this.explosionX + ", " + this.explosionY + ", " + this.explosionZ);
            this.worldObj.spawnParticle("largeexplode", this.explosionX, this.explosionY, this.explosionZ, 1.0D, 0.0D, 0.0D);
        }

        Iterator iterator;
        ChunkPosition chunkposition;
        int i;
        int j;
        int k;
        Block block;

        if (this.isSmoking) {
            iterator = this.affectedBlockPositions.iterator();

            while (iterator.hasNext()) {
                chunkposition = (ChunkPosition) iterator.next();
                i = chunkposition.chunkPosX;
                j = chunkposition.chunkPosY;
                k = chunkposition.chunkPosZ;
                block = this.worldObj.getBlock(i, j, k);

                if (p_77279_1_) {
                    double d0 = (double) ((float) i + this.worldObj.rand.nextFloat());
                    double d1 = (double) ((float) j + this.worldObj.rand.nextFloat());
                    double d2 = (double) ((float) k + this.worldObj.rand.nextFloat());
                    double d3 = d0 - this.explosionX;
                    double d4 = d1 - this.explosionY;
                    double d5 = d2 - this.explosionZ;
                    double d6 = (double) MathHelper.sqrt_double(d3 * d3 + d4 * d4 + d5 * d5);
                    d3 /= d6;
                    d4 /= d6;
                    d5 /= d6;
                    double d7 = 0.5D / (d6 / (double) this.explosionSize + 0.1D);
                    d7 *= (double) (this.worldObj.rand.nextFloat() * this.worldObj.rand.nextFloat() + 0.3F);
                    d3 *= d7;
                    d4 *= d7;
                    d5 *= d7;
                    this.worldObj.spawnParticle("explode", (d0 + this.explosionX * 1.0D) / 2.0D, (d1 + this.explosionY * 1.0D) / 2.0D, (d2 + this.explosionZ * 1.0D) / 2.0D, d3, d4, d5);
                    this.worldObj.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
                }

                if (block.getMaterial() != Material.air) {
                    if (block.canDropFromExplosion(this)) {
                        block.dropBlockAsItemWithChance(this.worldObj, i, j, k, this.worldObj.getBlockMetadata(i, j, k), 1.0F / this.explosionSize, 0);
                    }

                    block.onBlockExploded(this.worldObj, i, j, k, this);
                }
            }
        }

    }

Able to differentiate the difference of a sum and an integral.

Posted

I've been scanning the EntityCreeper class for hints as to how I would go about doing this, but I can't figure it out. Is there a related class I could look at to help myself out?

Able to differentiate the difference of a sum and an integral.

Posted

I'm sorry, but I can't for the life of me figure out where world.createExplosion sends a packet.

 

/**
     * Creates an explosion. Args: entity, x, y, z, strength
     */
    public Explosion createExplosion(Entity p_72876_1_, double p_72876_2_, double p_72876_4_, double p_72876_6_, float p_72876_8_, boolean p_72876_9_)
    {
        return this.newExplosion(p_72876_1_, p_72876_2_, p_72876_4_, p_72876_6_, p_72876_8_, false, p_72876_9_);
    }

    /**
     * returns a new explosion. Does initiation (at time of writing Explosion is not finished)
     */
    public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
    {
        Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_);
        explosion.isFlaming = p_72885_9_;
        explosion.isSmoking = p_72885_10_;
        if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion;
        explosion.doExplosionA();
        explosion.doExplosionB(true);
        return explosion;
    }

 

 

Is it embedded somewhere within the ForgeEventFactory?

Able to differentiate the difference of a sum and an integral.

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.