Demande de TUTO Dynamite
-
Bonjour,
J’aimerai savoir si quelqu’un aurais le courage de faire un tuto pour savoir comment créer une dynamite car j’aimerai vraiment en faire une mais je ne sais vraiment pas comment faireCordialemnt, FanatikForrce
-
Salut,
Il y a eu déjà plusieurs demande d’aide sur le sujet où la solution a été donnée.
Merci de faire un peu de recherche. -
Pour faire un tnt il te faut un block et une entity je te conseille de t’inspirer du code de minecraft car c’est vraiment tres tres simple
Je te laisse t’amuser avec ce code comme bon te semble
car les tnts c’est vraiment fun !Voici un class d’un block de tnt que j’avais creer
import net.minecraft.block.Block; import net.minecraft.block.BlockTNT; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.util.IIcon; import net.minecraft.world.Explosion; import net.minecraft.world.World; public class CFour extends Block { public CFour(Material material) { super(material.tnt); setBlockName("cFour"); setBlockTextureName(MainClass.itemTextureName + "cfour_side"); setCreativeTab(MainClass.modTab); setStepSound(soundTypeGrass); setHardness(0.0F); } private IIcon side, top, bottom; public void registerBlockIcons(IIconRegister iiconRegister) { this.blockIcon = iiconRegister.registerIcon(MainClass.itemTextureName + "cfour_side"); this.side = iiconRegister.registerIcon(MainClass.itemTextureName + "cfour_side"); this.top = iiconRegister.registerIcon(MainClass.itemTextureName + "cfour_top"); this.bottom = iiconRegister.registerIcon(MainClass.itemTextureName + "cfour_bottom"); } public IIcon getIcon(int side, int metadata) { if(side == 0) { return this.bottom; } else if(side == 1) { return this.top; } return this.blockIcon; } public void onCFourActivatedByEntity(World world, int x, int y, int z, int metadata, EntityLivingBase entityLivingBase) { if (!world.isRemote) { if ((metadata & 1) == 1) { EntityCFourPrimed entityCFourPrimed = new EntityCFourPrimed(world, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), entityLivingBase); world.spawnEntityInWorld(entityCFourPrimed); world.playSoundAtEntity(entityCFourPrimed, "game.tnt.primed", 1.0F, 1.0F); } } } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel) { this.onCFourActivatedByEntity(world, x, y, z, 1, player); world.setBlockToAir(x, y, z); player.getCurrentEquippedItem().damageItem(1, player); return true; } else { return super.onBlockActivated(world, x, y, z, player, p_149727_6_, p_149727_7_, p_149727_8_, p_149727_9_); } } public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { if (!world.isRemote) { EntityCFourPrimed entityCFourPrimed = new EntityCFourPrimed(world, (double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), explosion.getExplosivePlacedBy()); entityCFourPrimed.fuse = (byte) (world.rand.nextInt(entityCFourPrimed.fuse / 4) + entityCFourPrimed.fuse / 8); world.spawnEntityInWorld(entityCFourPrimed); } } public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int metadata) { this.onCFourActivatedByEntity(world, x, y, z, metadata, (EntityLivingBase)null); }
et l’entity
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; public class EntityCFourPrimed extends Entity { public byte fuse; private EntityLivingBase tntPlacedBy; public EntityCFourPrimed(World world) { super(world); this.preventEntitySpawning = true; this.setSize(0.98F, 0.98F); this.yOffset = this.height / 2.0F; } public EntityCFourPrimed(World world, double x, double y, double z, EntityLivingBase entityLivingBase) { this(world); this.setPosition(x, y, z); float f = (float)(Math.random() * Math.PI * 2.0D); this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F); this.motionY = 0.20000000298023224D; this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F); this.fuse = 100; this.prevPosX = x; this.prevPosY = y; this.prevPosZ = z; this.tntPlacedBy = entityLivingBase; } protected void entityInit() { } protected boolean canTriggerWalking() { return false; } public boolean canBeCollidedWith() { return !this.isDead; } public void onUpdate() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.motionY -= 0.03999999910593033D; this.moveEntity(this.motionX, this.motionY, this.motionZ); this.motionX *= 0.9800000190734863D; this.motionY *= 0.9800000190734863D; this.motionZ *= 0.9800000190734863D; if (this.onGround) { this.motionX *= 0.699999988079071D; this.motionZ *= 0.699999988079071D; this.motionY *= -0.5D; } if (this.fuse– <= 0) { this.setDead(); if (!this.worldObj.isRemote) { this.explode(); } } else { this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); } } private void explode() { byte b = 10; this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, b, true); } protected void writeEntityToNBT(NBTTagCompound ntbTagCompound) { ntbTagCompound.setByte("Fuse", (byte)this.fuse); } protected void readEntityFromNBT(NBTTagCompound ntbTagCompound) { this.fuse = ntbTagCompound.getByte("Fuse"); } @SideOnly(Side.CLIENT) public float getShadowSize() { return 0.0F; } public EntityLivingBase getTntPlacedBy() { return this.tntPlacedBy; } }
-
Déjà ce n’est pas le bonne endroit et après regarde dans les sujet que j’ai créer j’en avais justement parlé