Ajouter code TNT.

Argoune

Aventurier
14 Mai 2011
17
0
1
30
Bonjour, j'écrit aujourd'hui un poste car j'aimerais ajouter à mon code un moyen de le faire exploser, si ont pause de la redstone et que l'on active le tous s'il vous plait quelqu'un connais le moyen ?

mod_Mod1.java
Code:
package net.minecraft.src;

public class mod_Mod1 extends BaseMod
{
	public mod_Mod1()
	{
	ModLoader.RegisterBlock(myBloc);
    ModLoader.AddName(myBloc, "Test");
	ModLoader.AddRecipe(new ItemStack(myBloc, 3), new Object[] {"###","XXX","#X#",Character.valueOf('#'), Block.cobblestone, Character.valueOf('X'), Block.sand});

	}

	public static final Block myBloc = (new BlockMyBloc(99,224)).setHardness(1.0F)
	.setResistance(99F)
	.setBlockName("Test")
	.setLightValue(2.0F)
	.setStepSound(Block.soundMetalFootstep);
	
	



	public String Version()
	{
	return "V1";
	}
}


BlockMyBloc.java
Code:
package net.minecraft.src;

import java.util.Random;

public class BlockMyBloc extends Block
{
	public BlockMyBloc(int i, int j)
	{
		super(i, j, Material.rock);
	}

	public int idDropped(int i, Random random)
	{
		return mod_Mod1.myBloc.blockID;
	}
}


PS: J'ai regarder dans le dossier source des TnT mais je voit pas quoi prendre.

BlockTNT.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 java.util.Random;

// Referenced classes of package net.minecraft.src:
//            Block, Material, World, EntityTNTPrimed, 
//            ItemStack, EntityPlayer, Item

public class BlockTNT extends Block
{

    public BlockTNT(int i, int j)
    {
        super(i, j, Material.tnt);
    }

    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)
    {
        EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
        entitytntprimed.fuse = world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
        world.entityJoinedWorld(entitytntprimed);
    }

    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.tnt.blockID, 1, 0));
        } else
        {
            EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F);
            world.entityJoinedWorld(entitytntprimed);
            world.playSoundAtEntity(entitytntprimed, "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);
    }
}

Merci d'avance :)

Bonne journée
 
Merci la j'ai aucun soucie pour le recompiler mais quand je pause le kube le jeu plante et m'affiche ceci

Code:
Mods loaded: 2
ModLoader Beta 1.7.3
net.minecraft.src.mod_Mod1 V1

      Minecraft has crashed!      
      ----------------------      

Minecraft has stopped running because it encountered a problem.

If you wish to report this, please copy this entire text and email it to [email protected].
Please include a description of what you did when the error occured.



--- BEGIN ERROR REPORT e61e02d3 --------
Generated 12/07/11 18:36

Minecraft: Minecraft Beta 1.7.3
OS: Windows 7 (amd64) version 6.1
Java: 1.6.0_26, Sun Microsystems Inc.
VM: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Sun Microsystems Inc.
LWJGL: 2.4.2
OpenGL: ATI Radeon HD 5450 version 4.1.10524 Compatibility Profile Context, ATI Technologies Inc.

java.lang.ArrayIndexOutOfBoundsException: 30
	at net.minecraft.src.ChunkCache.getBrightness(ChunkCache.java:75)
	at net.minecraft.src.Block.getBlockBrightness(Block.java:152)
	at net.minecraft.src.RenderBlocks.renderStandardBlockWithAmbientOcclusion(RenderBlocks.java:1943)
	at net.minecraft.src.RenderBlocks.renderStandardBlock(RenderBlocks.java:1922)
	at net.minecraft.src.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:125)
	at net.minecraft.src.WorldRenderer.updateRenderer(WorldRenderer.java:148)
	at net.minecraft.src.RenderGlobal.updateRenderers(RenderGlobal.java:1073)
	at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:553)
	at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:430)
	at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRendererProxy.java:23)
	at net.minecraft.client.Minecraft.run(Minecraft.java:514)
	at java.lang.Thread.run(Thread.java:662)
--- END ERROR REPORT 92e4c7df ----------