Boucle dans un boolean
-
Oui j’ai bien mis 0 qui correspond à la hauteur de drop simplement me semble.
Je suis en 1.7.10, pas en 1.8.9 Xd
La seule différence est que je give un item à metadata… Je poursuis mes tests
-
Essaie de remplacer ton jeton par new ItemStack(Items.apple) comme ça si ça marche on sera sur que le problème vient du jeton

-
Eh bien… Non… Rien n’a changé, ça ne me donne qu’une pomme. Belle, rouge mais bien seule x]
Je vais voir ça comme un problème insurmontable et botter en touche, je vais faire give un autre item qui aurra la valeur de 500.C’est une contrainte que j’espèrais pouvoir contourner (ou simplement expliquer).
-
Renvoi le code
-
Voici la classe entière:
package fr.powergame.modpg2.common; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.powergame.modpg2.client.TileEntityJackPot; import fr.powergame.modpg2.proxy.ClientProxy; public class JackPot extends Block { protected JackPot(Material mat) { super(mat); } public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz) { Random rand = new Random(); //ItemStack jeton = new ItemStack(ModPg2.itemMetadata, 1, 4);Items.apple ItemStack jeton = new ItemStack(Items.apple); if (player.inventory.hasItem(ModPg2.itemJackPot)) { int randInt = rand.nextInt(1000); if (randInt >= 0) { // 1/1000 player.triggerAchievement(ModPg2.achievementJackPot); for(int j = 0 ; j < 500; ++j) { if (!player.inventory.addItemStackToInventory(jeton)) { player.entityDropItem(jeton, 0); } } if(!world.isRemote) { ChatComponentText comp = new ChatComponentText(EnumChatFormatting.DARK_AQUA + "Power JackPot > " + EnumChatFormatting.DARK_RED + "JACKPOT !!!"); (player).addChatComponentMessage(comp); } } if (randInt > 0 && randInt < 10) { // 10/1000 if(!world.isRemote) { ChatComponentText comp = new ChatComponentText(EnumChatFormatting.DARK_AQUA + "Power JackPot > " + EnumChatFormatting.GRAY + "Gagné, moyen lot."); (player).addChatComponentMessage(comp); } for(int j = 0 ; j < 25; ++j) { if (!player.inventory.addItemStackToInventory(jeton)) { player.entityDropItem(jeton, 1); } } } if (randInt >= 10 && randInt < 449) { // 100/1000 if(!world.isRemote) { ChatComponentText comp = new ChatComponentText(EnumChatFormatting.DARK_AQUA + "Power JackPot > " + EnumChatFormatting.GRAY + "Gagné, petit lot."); (player).addChatComponentMessage(comp); } if (!player.inventory.addItemStackToInventory(jeton)) { player.entityDropItem(jeton, 1); } } if (randInt >= 450) { // 500/1000 if(!world.isRemote) { ChatComponentText comp = new ChatComponentText(EnumChatFormatting.DARK_AQUA + "Power JackPot > " + EnumChatFormatting.GRAY + "Perdu"); (player).addChatComponentMessage(comp); } } player.inventory.consumeInventoryItem(ModPg2.itemJackPot); return true; } return false; } public int damageDropped(int metadata) { return metadata; } public boolean hasTileEntity(int metadata) { return true; } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityJackPot(); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { if(stack.getItemDamage() == 0) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityJackPot) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; ((TileEntityJackPot)tile).setDirection((byte)direction); } } } @Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote && world.getBlockMetadata(x, y, z) == 0) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityJackPot) { TileEntityJackPot tileDirectional = (TileEntityJackPot)tile; byte direction = tileDirectional.getDirection(); direction++; if(direction > 3) { direction = 0; } tileDirectional.setDirection(direction); return true; } } return false; } public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { return world.getBlockMetadata(x, y, z) == 0 ? new ForgeDirection[] {ForgeDirection.UP, ForgeDirection.DOWN} : ForgeDirection.VALID_DIRECTIONS; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public boolean canBeCollidedWith() { return true; } @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.tesrRenderId; } } -
Essaie de re-créer une instance d’ItemStack à chaque boucle
-
Bingo Scarex ^^
C’était bien ça, merci. (et étrange)
-
Mettre le .copy() revenait à faire exactement la même chose.
-
Aussi, c’est juste que 2 EntityItem ne peuvent pas partager une même instance d’ItemStack
-
Ouais voilà sauf que là c’était pas 2 mais 500