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
BlockMyBloc.java
PS: J'ai regarder dans le dossier source des TnT mais je voit pas quoi prendre.
BlockTNT.java
Merci d'avance
Bonne journée
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