code explosion

PIF50070

Architecte en herbe
21 Mars 2011
95
0
112
je voudre savoir se qu il fau taper dans le fichier modmymod
et dans blockmybloc pour fair un block explosife
avec la redston si posible
 
J'ai regarder dans le BlockTNT ,EntityTNTPrimed et RenderTNTPrimed et enfaite...
c'est très simple...
Tu Copie Colle les 3 fichier et tu remplace par tes fichier et dans mod_MyMod.java tu definie le bloc...
Rien de plus simple mais pour te simplifier je t'ecris les code ci-dessous:

Dans mod_MyMod.java tu definie ton bloc comme normalement...

BlockMyBloc:
Code:
package net.minecraft.src;
import java.util.Random;

public class BlockMyBloc extends Block
{

    public BlockMyBloc(int i, int j)
    {
        super(i, j, Material.ground);
    }

    public int getBlockTextureFromSide(int i)
    {
        if(i == 0)
        {
            return blockIndexInTexture + 2;
        }
        if(i == 1)
        {
            return blockIndexInTexture + 1;
        } else
        {
            return blockIndexInTexture;
        }
    }

    public void onBlockAdded(World world, int i, int j, int k)
    {
        super.onBlockAdded(world, i, j, k);
        if(world.isBlockIndirectlyGettingPowered(i, j, k))
        {
            onBlockDestroyedByPlayer(world, i, j, k, 1);
            world.setBlockWithNotify(i, j, k, 0);
        }
    }

    public void onNeighborBlockChange(World world, int i, int j, int k, int l)
    {
        if(l > 0 && Block.blocksList[l].canProvidePower() && world.isBlockIndirectlyGettingPowered(i, j, k))
        {
            onBlockDestroyedByPlayer(world, i, j, k, 1);
            world.setBlockWithNotify(i, j, k, 0);
        }
    }

    public int quantityDropped(Random random)
    {
        return 0;
    }

    public void onBlockDestroyedByExplosion(World world, int i, int j, int k)
    {
        EntityMyBlocPrimed entitymyblocprimed = new EntityMyBlocPrimed(world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
        entitymyblocprimed.fuse = world.rand.nextInt(entitymyblocprimed.fuse / 4) + entitymyblocprimed.fuse / 8;
        world.entityJoinedWorld(entitymyblocprimed);
    }

    public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
    {
        if(world.multiplayerWorld)
        {
            return;
        }
        if((l & 1) == 0)
        {
            dropBlockAsItem_do(world, i, j, k, new ItemStack(Block.myBloc.blockID, 1, 0));
        } else
        {
            EntityMyBlocPrimed entitymyblocprimed = new EntityMyBlocPrimed(world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
            world.entityJoinedWorld(entitymyblocprimed);
            world.playSoundAtEntity(entitymyblocprimed, "random.fuse", 1.0F, 1.0F);
        }
    }

    public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer)
    {
        if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.shiftedIndex)
        {
            world.setBlockMetadata(i, j, k, 1);
        }
        super.onBlockClicked(world, i, j, k, entityplayer);
    }

    public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
    {
        return super.blockActivated(world, i, j, k, entityplayer);
    }
}

Puis EntityMyBlocPrimed.java:
Code:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 

package net.minecraft.src;


// Referenced classes of package net.minecraft.src:
//            Entity, MathHelper, World, NBTTagCompound

public class EntityMyBlocPrimed extends Entity
{

    public EntityEyBlocPrimed(World world)
    {
        super(world);
        fuse = 0;
        preventEntitySpawning = true;
        setSize(0.98F, 0.98F);
        yOffset = height / 2.0F;
    }

    public EntityMyBlocPrimed(World world, double d, double d1, double d2)
    {
        this(world);
        setPosition(d, d1, d2);
        float f = (float)(Math.random() * 3.1415927410125732D * 2D);
        motionX = -MathHelper.sin((f * 3.141593F) / 180F) * 0.02F;
        motionY = 0.20000000298023224D;
        motionZ = -MathHelper.cos((f * 3.141593F) / 180F) * 0.02F;
        fuse = 80;
        prevPosX = d;
        prevPosY = d1;
        prevPosZ = d2;
    }

    protected void entityInit()
    {
    }

    protected boolean canTriggerWalking()
    {
        return false;
    }

    public boolean canBeCollidedWith()
    {
        return !isDead;
    }

    public void onUpdate()
    {
        prevPosX = posX;
        prevPosY = posY;
        prevPosZ = posZ;
        motionY -= 0.039999999105930328D;
        moveEntity(motionX, motionY, motionZ);
        motionX *= 0.98000001907348633D;
        motionY *= 0.98000001907348633D;
        motionZ *= 0.98000001907348633D;
        if(onGround)
        {
            motionX *= 0.69999998807907104D;
            motionZ *= 0.69999998807907104D;
            motionY *= -0.5D;
        }
        if(fuse-- <= 0)
        {
            if(!worldObj.multiplayerWorld)
            {
                setEntityDead();
                explode();
            } else
            {
                setEntityDead();
            }
        } else
        {
            worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
        }
    }

    private void explode()
    {
        float f = 4F;
        worldObj.createExplosion(null, posX, posY, posZ, f);
    }

    protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
    {
        nbttagcompound.setByte("Fuse", (byte)fuse);
    }

    protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
    {
        fuse = nbttagcompound.getByte("Fuse");
    }

    public float getShadowSize()
    {
        return 0.0F;
    }

    public int fuse;
}

Et RenderMyBlocPrimed.java:
Code:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode 

package net.minecraft.src;

import org.lwjgl.opengl.GL11;

// Referenced classes of package net.minecraft.src:
//            Render, RenderBlocks, EntityEyBlocPrimed, Block, 
//            Entity

public class RenderMyBlocPrimed extends Render
{

    public RenderMyBlocPrimed()
    {
        blockRenderer = new RenderBlocks();
        shadowSize = 0.5F;
    }

    public void func_153_a(a entitymyblocprimed, double d, double d1, double d2, 
            float f, float f1)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)d, (float)d1, (float)d2);
        if(((float)entitymyblocprimed.fuse - f1) + 1.0F < 10F)
        {
            float f2 = 1.0F - (((float)entitymyblocprimed.fuse - f1) + 1.0F) / 10F;
            if(f2 < 0.0F)
            {
                f2 = 0.0F;
            }
            if(f2 > 1.0F)
            {
                f2 = 1.0F;
            }
            f2 *= f2;
            f2 *= f2;
            float f4 = 1.0F + f2 * 0.3F;
            GL11.glScalef(f4, f4, f4);
        }
        float f3 = (1.0F - (((float)entitymyblocprimed.fuse - f1) + 1.0F) / 100F) * 0.8F;
        loadTexture("/terrain.png");
        blockRenderer.renderBlockOnInventory(Block.tnt, 0, entitymyblocprimed.getEntityBrightness(f1));
        if((entitymyblocprimed.fuse / 5) % 2 == 0)
        {
            GL11.glDisable(3553 /*GL_TEXTURE_2D*/);
            GL11.glDisable(2896 /*GL_LIGHTING*/);
            GL11.glEnable(3042 /*GL_BLEND*/);
            GL11.glBlendFunc(770, 772);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f3);
            blockRenderer.renderBlockOnInventory(Block.tnt, 0, 1.0F);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glDisable(3042 /*GL_BLEND*/);
            GL11.glEnable(2896 /*GL_LIGHTING*/);
            GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
        }
        GL11.glPopMatrix();
    }

    public void doRender(Entity entity, double d, double d1, double d2, 
            float f, float f1)
    {
        func_153_a((EntityEyBlocPrimed)entity, d, d1, d2, f, f1);
    }

    private RenderBlocks blockRenderer;
}

Si tu veux modifier le nom tu remplace tout les entitymyblocprimed ect...
Et normalement sa devrais faire pareil que la TNT...
Sauf si tu veux que sa soit immédiat...
 
ATTENTION!
Regarde les noms et le noms que tu as definie
Tu as mit EntityEyBlocPrimed au lieu de EntityMyBlocPrimed...
Regarde bien apprend a avoir un oeil de Lynx :D