MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Créer un gui et un container sur un bloc (type coffre)

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.6.x
    136 Messages 24 Publieurs 55.9k Vues 5 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • Superloup10S Hors-ligne
      Superloup10 Modérateurs
      dernière édition par

      Personnellement, je fais comme ceci: GuiHandler.java

      Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

      Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

      1 réponse Dernière réponse Répondre Citer 0
      • T Hors-ligne
        totos51
        dernière édition par

        le soucis c’est que ya pas de TileEntity pour une enclume 😕

        1 réponse Dernière réponse Répondre Citer 0
        • robin4002R Hors-ligne
          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
          dernière édition par

          Il n’utilise pas le tile entity mais l’id.

          1 réponse Dernière réponse Répondre Citer 0
          • T Hors-ligne
            totos51
            dernière édition par

            oui mais il switch sur le tileentity non?

            1 réponse Dernière réponse Répondre Citer 0
            • Superloup10S Hors-ligne
              Superloup10 Modérateurs
              dernière édition par

              Si tu regardes bien, ContainerPedia et GuiPedia ne prennent pas en compte le tileEntity.

              Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

              Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

              1 réponse Dernière réponse Répondre Citer 1
              • T Hors-ligne
                totos51
                dernière édition par

                autant pour moi, merci, je vais regarder avec ça 😄

                1 réponse Dernière réponse Répondre Citer 0
                • M Hors-ligne
                  MrAzErTy31
                  dernière édition par

                  Bonsoir, je voudrais savoir si l’on pouvait ouvrir un GUI avec un clic droit sur un item et avoir des boutons sur le menu menu. Merci 🙂

                  Mes mods :

                  >! GGButtonMod : http://minecraftforgefrance.fr/showthread.php?tid=1280
                  CraftYourMenu : http://minecraftforgefrance.fr/showth…

                  1 réponse Dernière réponse Répondre Citer 0
                  • robin4002R Hors-ligne
                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                    dernière édition par

                    Le menu menu ? Je connais que le menu menu menu moi 😛
                    Oui c’est possible, je l’ai fait sur le sabre de nanotech mod. Après si plus ou moins compliqué selon ce que tu veux faire. Un simple gui avec des boutons, il faut juste des paquets pour envoyer les informations aux serveurs après, et tu sauvegarde tout dans le nbt tag de l’item stack. Par contre un gui et un container avec des slots sur un item (en gros un sac), j’ai pas encore tenté, ça m’a l’air plus complet.
                    Il faudrait un tutoriel à part pour traiter ça, je vais voir pour en faire un lorsque je vais reprendre les tutoriels (j’ai d’autres priorités pour l’instant).

                    1 réponse Dernière réponse Répondre Citer 0
                    • M Hors-ligne
                      MrAzErTy31
                      dernière édition par

                      Merci de ta reponse robin 🙂 Donc aloes en faite je résume :
                      Quand on fait un clique droit sur un item, un gui s’ouvre au joueur qui a cliqué avec l’item, dans ce gui, il y aura différents boutons simples, lors d’un clique sur l’un d’eux, un son sera joué à la position du joueur, et le gui ser fermera. Merci d’avance 🙂

                      Mes mods :

                      >! GGButtonMod : http://minecraftforgefrance.fr/showthread.php?tid=1280
                      CraftYourMenu : http://minecraftforgefrance.fr/showth…

                      1 réponse Dernière réponse Répondre Citer 0
                      • robin4002R Hors-ligne
                        robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                        dernière édition par

                        Suffit juste d’ouvrir le gui lorsque le joueur fait un clic droit :

                        
                        @Override
                        public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
                        {
                        player.openGui(ClassePrincipale.instance, id, world, (int)player.posX, (int)player.posY, (int)player.posZ);
                        return stack;
                        }
                        

                        Ensuite dans le gui handler, il faut faire une condition avec l’id.
                        Côté serveur, tu n’as rien à faire. Côté client, ouvre le gui.
                        Ensuite pour les boutons, si tu veux que seul le joueur entende le son, il faut le jouer directement comme les sons du clic des boutons. Sinon faut envoyer un paquet au serveur, et le serveur va renvoyer à tout les clients via la fonction playSound du serveur.

                        1 réponse Dernière réponse Répondre Citer 0
                        • pulganP Hors-ligne
                          pulgan
                          dernière édition par

                          Petit probleme :
                          TileEntityTutorial2
                          TileEntityTutorial

                          A quoi corresponde ces deux tileentity?

                          1 réponse Dernière réponse Répondre Citer 0
                          • robin4002R Hors-ligne
                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                            dernière édition par

                            Heu tu parle de quoi ? Il n’y a pas un seul TileEntityTutorial ni de TileEntityTutorial2 dans ce tutoriel.

                            1 réponse Dernière réponse Répondre Citer 0
                            • pulganP Hors-ligne
                              pulgan
                              dernière édition par

                              Bon j’ai un probleme 😛 j’ai suivis a la lettre le tuto mais en jeu quand je clique droit rien ne se passe alors que j’ai aucune erreur dans mes fichiers

                              Classe Gui :

                              
                              package craftz;
                              
                              import net.minecraft.client.gui.inventory.GuiContainer;
                              import net.minecraft.client.resources.I18n;
                              import net.minecraft.entity.player.InventoryPlayer;
                              import net.minecraft.inventory.IInventory;
                              import net.minecraft.util.ResourceLocation;
                              
                              import org.lwjgl.opengl.GL11;
                              
                              public class GuiBigChest extends GuiContainer
                              {
                              public static ResourceLocation texture = new ResourceLocation("craftz", "textures/gui/container/bigChest.png");
                              private TileEntityBigChest bigChest;
                              private IInventory playerInventory;
                              public GuiBigChest(InventoryPlayer inventory, TileEntityBigChest tileEntity)
                              {
                              super(new ContainerBigChest(inventory, tileEntity));
                              this.bigChest = tileEntity;
                              this.playerInventory = inventory;
                              this.ySize = 230;
                              }
                              
                              protected void drawGuiContainerForegroundLayer(int par1, int par2)
                              {
                              this.fontRenderer.drawString(this.playerInventory.isInvNameLocalized() ? this.playerInventory.getInvName() : I18n.getString(this.playerInventory.getInvName()), 8, 129, 0);
                              this.fontRenderer.drawString(this.bigChest.isInvNameLocalized() ? this.bigChest.getInvName() : I18n.getString(this.bigChest.getInvName()), 8, 7, 0);
                              }
                              
                              @Override
                              protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
                              {
                              GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                              this.mc.getTextureManager().bindTexture(texture);
                              int x = (this.width - this.xSize) / 2;
                              int y = (this.height - this.ySize) / 2;
                              this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
                              }
                              }
                              
                              

                              block coffre:

                              
                              package craftz;
                              
                              import java.util.List;
                              
                              import net.minecraft.block.BlockContainer;
                              import net.minecraft.block.material.Material;
                              import net.minecraft.client.renderer.texture.IconRegister;
                              import net.minecraft.creativetab.CreativeTabs;
                              import net.minecraft.entity.EntityLivingBase;
                              import net.minecraft.entity.item.EntityItem;
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.item.ItemStack;
                              import net.minecraft.nbt.NBTTagCompound;
                              import net.minecraft.tileentity.TileEntity;
                              import net.minecraft.tileentity.TileEntityChest;
                              import net.minecraft.util.Icon;
                              import net.minecraft.util.MathHelper;
                              import net.minecraft.world.IBlockAccess;
                              import net.minecraft.world.World;
                              import cpw.mods.fml.common.network.FMLNetworkHandler;
                              import cpw.mods.fml.relauncher.Side;
                              import cpw.mods.fml.relauncher.SideOnly;
                              
                              public class BlockCoffre extends BlockContainer
                              {
                              
                              protected BlockCoffre(int par1, Material par2Material) {
                              super(par1, par2Material);
                              }
                              public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                              {
                              if(world.getBlockMetadata(x, y, z) == 3)
                              {
                              FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                              return true;
                              }
                              return false;
                              }
                              public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                              {
                              TileEntity te = world.getBlockTileEntity(x, y, z);
                              if(te != null && stack.getItemDamage() == 3 && te instanceof TileEntityBigChest && stack.hasDisplayName())
                              {
                              ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                              }
                              }
                              public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                              {
                              if(metadata == 3)
                              {
                              dropContainerItem(world, x, y, z);
                              }
                              super.breakBlock(world, x, y, z, side, metadata);
                              }
                              @Override
                              public TileEntity createNewTileEntity(World world) {
                              // TODO Auto-generated method stub
                              return null;
                              }
                              protected void dropContainerItem(World world, int x, int y, int z)
                              {
                              TileEntityBigChest bigchest = (TileEntityBigChest)world.getBlockTileEntity(x, y, z);
                              
                              if (bigchest != null)
                              {
                              for (int slotId = 0; slotId < bigchest.getSizeInventory(); slotId++)
                              {
                              ItemStack stack = bigchest.getStackInSlot(slotId);
                              
                              if (stack != null)
                              {
                              float f = world.rand.nextFloat() * 0.8F + 0.1F;
                              float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                              EntityItem entityitem;
                              
                              for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                              {
                              int k1 = world.rand.nextInt(21) + 10;
                              
                              if (k1 > stack.stackSize)
                              {
                              k1 = stack.stackSize;
                              }
                              
                              stack.stackSize -= k1;
                              entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(stack.itemID, k1, stack.getItemDamage()));
                              float f3 = 0.05F;
                              entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                              entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                              entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                              
                              if (stack.hasTagCompound())
                              {
                              entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
                              }
                              }
                              }
                              }
                              }
                              }
                              }
                              
                              

                              COntainer:

                              
                              package craftz;
                              
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.entity.player.InventoryPlayer;
                              import net.minecraft.inventory.Container;
                              import net.minecraft.inventory.Slot;
                              import net.minecraft.item.ItemStack;
                              
                              public class ContainerBigChest extends Container
                              {
                              private TileEntityBigChest tileEntity;
                              
                              public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest)
                              {
                              this.tileEntity = teChest;
                              
                              for(int i = 0; i < 6; i++)
                              {
                              for(int j = 0; j < 9; j++)
                              {
                              this.addSlotToContainer(new Slot(teChest, j + i * 9, 8 + j * 18, 18 + i * 18));
                              }
                              }
                              this.bindPlayerInventory(playerInventory);
                              }
                              
                              private void bindPlayerInventory(InventoryPlayer playerInventory)
                              {
                              int i;
                              for(i = 0; i < 3; i++)
                              {
                              for(int j = 0; j < 9; j++)
                              {
                              this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18 + 37));
                              }
                              }
                              
                              for(i = 0; i < 9; i++)
                              {
                              this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 161 + 37));
                              }
                              }
                              
                              @Override
                              public boolean canInteractWith(EntityPlayer player)
                              {
                              return tileEntity.isUseableByPlayer(player);
                              }
                              
                              public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
                              {
                              ItemStack itemstack = null;
                              Slot slot = (Slot)this.inventorySlots.get(slotId);
                              
                              if(slot != null && slot.getHasStack())
                              {
                              ItemStack itemstack1 = slot.getStack();
                              itemstack = itemstack1.copy();
                              
                              if(slotId < 9)
                              {
                              if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
                              {
                              return null;
                              }
                              }
                              else if(!this.mergeItemStack(itemstack1, 0, 9, false))
                              {
                              return null;
                              }
                              
                              if(itemstack1.stackSize == 0)
                              {
                              slot.putStack((ItemStack)null);
                              }
                              else
                              {
                              slot.onSlotChanged();
                              }
                              }
                              return itemstack;
                              }
                              }
                              
                              

                              GUi handler

                              
                              package craftz;
                              
                              import cpw.mods.fml.common.network.IGuiHandler;
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.tileentity.TileEntity;
                              import net.minecraft.world.World;
                              
                              public class GuiHandlerTutorial implements IGuiHandler
                              
                              {
                              
                              @Override
                              public Object getServerGuiElement(int ID, EntityPlayer player, World world,
                              int x, int y, int z) {
                              TileEntity te = world.getBlockTileEntity(x, y, z);
                              if(te instanceof TileEntityBigChest)
                              {
                              return new ContainerBigChest(player.inventory, (TileEntityBigChest)te);
                              }
                              return null;
                              }
                              
                              @Override
                              public Object getClientGuiElement(int ID, EntityPlayer player, World world,
                              int x, int y, int z) {
                              
                              TileEntity te = world.getBlockTileEntity(x, y, z);
                              if(te instanceof TileEntityBigChest)
                              {
                              return new GuiBigChest(player.inventory, (TileEntityBigChest)te);
                              }
                              return null;
                              }
                              }
                              
                              

                              et Tile ENtity

                              
                              package craftz;
                              
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.inventory.IInventory;
                              import net.minecraft.item.ItemStack;
                              import net.minecraft.nbt.NBTTagCompound;
                              import net.minecraft.nbt.NBTTagList;
                              import net.minecraft.tileentity.TileEntity;
                              
                              import net.minecraft.entity.player.EntityPlayer;
                              import net.minecraft.inventory.IInventory;
                              import net.minecraft.item.ItemStack;
                              import net.minecraft.nbt.NBTTagCompound;
                              import net.minecraft.nbt.NBTTagList;
                              import net.minecraft.tileentity.TileEntity;
                              
                              public class TileEntityBigChest extends TileEntity implements IInventory
                              {
                              private ItemStack[] inventory = new ItemStack[72];
                              private String customName;
                              
                              public void readFromNBT(NBTTagCompound nbttag)
                              {
                              super.readFromNBT(nbttag);
                              NBTTagList nbttaglist = nbttag.getTagList("Items");
                              this.inventory = new ItemStack[this.getSizeInventory()];
                              
                              if (nbttag.hasKey("CustomName"))
                              {
                              this.customName = nbttag.getString("CustomName");
                              }
                              
                              for (int i = 0; i < nbttaglist.tagCount(); i++)
                              {
                              NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                              int j = nbttagcompound1.getByte("Slot");
                              
                              if (j >= 0 && j < this.inventory.length)
                              {
                              this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                              }
                              }
                              }
                              
                              public void writeToNBT(NBTTagCompound nbttag)
                              {
                              super.writeToNBT(nbttag);
                              NBTTagList nbttaglist = new NBTTagList();
                              
                              for (int i = 0; i < this.inventory.length; i++)
                              {
                              if (this.inventory* != null)
                              {
                              NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                              nbttagcompound1.setByte("Slot", (byte)i);
                              this.inventory*.writeToNBT(nbttagcompound1);
                              nbttaglist.appendTag(nbttagcompound1);
                              }
                              }
                              
                              nbttag.setTag("Items", nbttaglist);
                              
                              if (this.isInvNameLocalized())
                              {
                              nbttag.setString("CustomName", this.customName);
                              }
                              }
                              @Override
                              public int getSizeInventory()
                              {
                              return inventory.length;
                              }
                              @Override
                              public ItemStack getStackInSlot(int slotId)
                              {
                              return inventory[slotId];
                              }
                              @Override
                              public ItemStack decrStackSize(int slotId, int quantity)
                              {
                              if (this.inventory[slotId] != null)
                              {
                              ItemStack itemstack;
                              
                              if (this.inventory[slotId].stackSize <= quantity)
                              {
                              itemstack = this.inventory[slotId];
                              this.inventory[slotId] = null;
                              this.onInventoryChanged();
                              return itemstack;
                              }
                              else
                              {
                              itemstack = this.inventory[slotId].splitStack(quantity);
                              
                              if (this.inventory[slotId].stackSize == 0)
                              {
                              this.inventory[slotId] = null;
                              }
                              
                              this.onInventoryChanged();
                              return itemstack;
                              }
                              }
                              else
                              {
                              return null;
                              }
                              }
                              
                              @Override
                              public ItemStack getStackInSlotOnClosing(int slotId)
                              {
                              if (this.inventory[slotId] != null)
                              {
                              ItemStack itemstack = this.inventory[slotId];
                              this.inventory[slotId] = null;
                              return itemstack;
                              }
                              else
                              {
                              return null;
                              }
                              }
                              
                              @Override
                              public void setInventorySlotContents(int slotId, ItemStack stack)
                              {
                              this.inventory[slotId] = stack;
                              
                              if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                              {
                              stack.stackSize = this.getInventoryStackLimit();
                              }
                              
                              this.onInventoryChanged();
                              }
                              @Override
                              public String getInvName()
                              {
                              return this.isInvNameLocalized() ? this.customName : "container.bigchest";
                              }
                              
                              @Override
                              public boolean isInvNameLocalized()
                              {
                              return this.customName != null && this.customName.length() > 0;
                              }
                              
                              public void setCustomGuiName(String name)
                              {
                              this.customName = name;
                              }
                              @Override
                              public int getInventoryStackLimit()
                              {
                              return 64;
                              }
                              @Override
                              public boolean isUseableByPlayer(EntityPlayer player)
                              {
                              return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
                              }
                              @Override
                              public void openChest()
                              {
                              
                              }
                              
                              @Override
                              public void closeChest()
                              {
                              
                              }
                              @Override
                              public boolean isItemValidForSlot(int slotId, ItemStack stack)
                              {
                              return true;
                              }
                              
                              }
                              
                              

                              Merci superloup

                              1 réponse Dernière réponse Répondre Citer 0
                              • Superloup10S Hors-ligne
                                Superloup10 Modérateurs
                                dernière édition par

                                Il y a des balises exprès pour le code java [java][/java] sans les *.

                                Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

                                Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

                                1 réponse Dernière réponse Répondre Citer 0
                                • robin4002R Hors-ligne
                                  robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                  dernière édition par

                                  Je vois deux problèmes dans le bloc.
                                  1. Ta fonction createTileEntity retourne null, cela devrait être :

                                  @Override
                                  public TileEntity createNewTileEntity(World world) {
                                  return new TileEntityBigChest();
                                  }
                                  

                                  Autre problème, j’ai dit que dans le cas du tutoriel je créé le container sur le metadata 3, dans ton cas tu n’as pas de métadata donc :

                                  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                  {
                                  if(world.getBlockMetadata(x, y, z) == 3)
                                  {
                                  FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                  return true;
                                  }
                                  return false;
                                  }
                                  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                  {
                                  TileEntity te = world.getBlockTileEntity(x, y, z);
                                  if(te != null && stack.getItemDamage() == 3 && te instanceof TileEntityBigChest && stack.hasDisplayName())
                                  {
                                  ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                  }
                                  }
                                  public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                  {
                                  if(metadata == 3)
                                  {
                                  dropContainerItem(world, x, y, z);
                                  }
                                  super.breakBlock(world, x, y, z, side, metadata);
                                  }
                                  

                                  Devrait être :

                                  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                  {
                                  FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                  return true;
                                  }
                                  public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                  {
                                  TileEntity te = world.getBlockTileEntity(x, y, z);
                                  if(te instanceof TileEntityBigChest && stack.hasDisplayName())
                                  {
                                  ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                  }
                                  }
                                  public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                  {
                                  dropContainerItem(world, x, y, z);
                                  super.breakBlock(world, x, y, z, side, metadata);
                                  }
                                  
                                  1 réponse Dernière réponse Répondre Citer 0
                                  • pulganP Hors-ligne
                                    pulgan
                                    dernière édition par

                                    Bon meme apres correction rien ne se passe faut t’il que je te donne ma nouvelle classe + la classe principal?

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • robin4002R Hors-ligne
                                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                      dernière édition par

                                      Heu ouai envoie toutes tes classes.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • pulganP Hors-ligne
                                        pulgan
                                        dernière édition par

                                        @‘robin4002’:

                                        Heu ouai envoie toutes tes classes.

                                        Donc de retour cette fois avec toutes les classe:
                                        les corrections donné par robin ont était effectuer sur la classe block

                                        merci de votre aide

                                        Classe principal:

                                        
                                        package craftz;
                                        
                                        import net.minecraft.block.Block;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.client.gui.Gui;
                                        import net.minecraft.creativetab.CreativeTabs;
                                        import net.minecraft.entity.Entity;
                                        import net.minecraft.entity.EnumCreatureType;
                                        import net.minecraft.item.EnumToolMaterial;
                                        import net.minecraft.item.Item;
                                        import net.minecraft.item.ItemFood;
                                        import net.minecraft.item.ItemSeeds;
                                        import net.minecraft.world.biome.BiomeGenBase;
                                        import net.minecraftforge.common.DimensionManager;
                                        import net.minecraftforge.common.EnumHelper;
                                        import cpw.mods.fml.common.Mod;
                                        import cpw.mods.fml.common.Mod.Init;
                                        import cpw.mods.fml.common.Mod.Instance;
                                        import cpw.mods.fml.common.Mod.PostInit;
                                        import cpw.mods.fml.common.Mod.PreInit;
                                        import cpw.mods.fml.common.SidedProxy;
                                        import cpw.mods.fml.common.event.FMLInitializationEvent;
                                        import cpw.mods.fml.common.event.FMLPostInitializationEvent;
                                        import cpw.mods.fml.common.event.FMLPreInitializationEvent;
                                        import cpw.mods.fml.common.network.NetworkMod;
                                        import cpw.mods.fml.common.network.NetworkRegistry;
                                        import cpw.mods.fml.common.registry.EntityRegistry;
                                        import cpw.mods.fml.common.registry.GameRegistry;
                                        import cpw.mods.fml.common.registry.LanguageRegistry;
                                        import cpw.mods.fml.common.registry.TickRegistry;
                                        import cpw.mods.fml.relauncher.Side;
                                        
                                        @Mod(modid = "craftz", name = "craftz", version = "0.1")
                                        @NetworkMod(clientSideRequired = true, serverSideRequired = false)
                                        
                                        public class ModCatnos
                                        {
                                        @SidedProxy(clientSide = "craftz.ClientProxy", serverSide = "craftz.CommonProxy")
                                        public static CommonProxy proxy;
                                        public static Block BlockOrgeCulture, matrixportalblock, porte, porte2, mychest, wallwood, sculture, yolo;
                                        public static Item itemcake, poire, sniper, couteau, ItemOrge, ItemOrgeGraines, cleporte, itemporte2;
                                        public static CreativeTabs TestCreativeTabs = new TestCreativeTabs("TestCreativeTabs");
                                        public static boolean zoom;
                                        public static Gui guitest;
                                        public static BiomeGenBase Biomedetest;
                                        public static final int dimensionId = 8;
                                        
                                        @Instance("ModCatnos")
                                        public static ModCatnos instance;
                                        
                                        static EnumToolMaterial cut = EnumHelper.addToolMaterial("cut", 3, 1561, 8.0F, 3, 10);
                                        
                                        @PreInit
                                        public void preload(FMLPreInitializationEvent event)
                                        {
                                        //Configuration
                                        
                                        //Blocks
                                        matrixportalblock = new BlockPortalmatrixblock(4001).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("matrixlock");
                                        porte = new BlockPorte(4002, Material.rock).setCreativeTab(ModCatnos.TestCreativeTabs).setBlockUnbreakable().setUnlocalizedName("porte");
                                        porte2 = new PorteBlock(4003, Material.rock).setCreativeTab(ModCatnos.TestCreativeTabs).setBlockUnbreakable().setUnlocalizedName("porte2");
                                        wallwood = new WallWoodBlock(4004, Block.planks).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("wallwood");
                                        // sculture = new BlockSculpture(4005).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("sculture");
                                        yolo = new BlockCoffre(4006, Material.wood).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("coffre");
                                        //Items
                                        sniper = new ItemSniper1(3001).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("sniper");
                                        couteau = new ItemCouteau(3002, cut).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("cut");
                                        poire = new ItemPoire(3003, 3, false).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("poire");
                                        cleporte = new ItemClePorte(3004).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("cleporte");
                                        itemporte2 = new Itemporte2(3005, Material.wood).setCreativeTab(ModCatnos.TestCreativeTabs).setUnlocalizedName("itemporte2");
                                        
                                        //CreativeTabs
                                        
                                        //Achievements
                                        
                                        //Biome
                                        Biomedetest = new biomeDeTest(40).setBiomeName("Biome De test").setDisableRain().setTemperatureRainfall(1.2F, 0.9F).setEnableSnow().setMinMaxHeight(0.3F, 0.5F);
                                        
                                        }
                                        
                                        @Init
                                        public void load(FMLInitializationEvent event)
                                        {
                                        //Registry Block
                                        GameRegistry.registerBlock(matrixportalblock, "matrixportalblock");
                                        GameRegistry.registerBlock(wallwood, "mur en bois");
                                        GameRegistry.registerBlock(porte, "porte");
                                        GameRegistry.registerBlock(porte2,"porte2");
                                        // GameRegistry.registerBlock(sculture, "sculture");
                                        GameRegistry.registerBlock(yolo, "yolo");
                                        
                                        //Registry Item
                                        GameRegistry.registerItem(sniper, "sniper");
                                        GameRegistry.registerItem(poire, "poire");
                                        GameRegistry.registerItem(couteau, "couteau");
                                        GameRegistry.registerItem(cleporte, "cleporte");
                                        
                                        //registry Biome
                                        GameRegistry.addBiome(Biomedetest);
                                        
                                        //registry TileEntity
                                        GameRegistry.registerTileEntity(TileEntityBigChest.class, "TileEntityBigChest");
                                        
                                        NetworkRegistry.instance().registerGuiHandler(this.instance, new GuiHandlerTutorial());
                                        
                                        TickRegistry.registerTickHandler(new TickClientHandler(), Side.CLIENT);
                                        
                                        DimensionManager.registerProviderType(ModCatnos.dimensionId, WorldProviderMatrix.class, false);
                                        DimensionManager.registerDimension(ModCatnos.dimensionId, ModCatnos.dimensionId);
                                        //Mobs
                                        
                                        //Render
                                        proxy.registerRender();
                                        proxy.registerTileEntityRender();
                                        //NetWork
                                        }
                                        
                                        @PostInit
                                        public void modloaded(FMLPostInitializationEvent event)
                                        {
                                        //Language
                                        LanguageRegistry.addName(sniper, "sniper");
                                        LanguageRegistry.addName(couteau, "couteau");
                                        LanguageRegistry.addName(poire, "poire");
                                        LanguageRegistry.addName(matrixportalblock, "matrixportalblock");
                                        LanguageRegistry.addName(cleporte, "cle de securite");
                                        LanguageRegistry.addName(porte, "porte de securite");
                                        LanguageRegistry.addName(yolo, "coffre geant");
                                        
                                        LanguageRegistry.instance().addStringLocalization("entity.AnyZob.name", "AnyZob");
                                        //Recipe
                                        
                                        }
                                        
                                        }
                                        
                                        

                                        Classe block

                                        
                                        package craftz;
                                        
                                        import java.util.List;
                                        
                                        import net.minecraft.block.BlockContainer;
                                        import net.minecraft.block.material.Material;
                                        import net.minecraft.client.renderer.texture.IconRegister;
                                        import net.minecraft.creativetab.CreativeTabs;
                                        import net.minecraft.entity.EntityLivingBase;
                                        import net.minecraft.entity.item.EntityItem;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.tileentity.TileEntityChest;
                                        import net.minecraft.util.Icon;
                                        import net.minecraft.util.MathHelper;
                                        import net.minecraft.world.IBlockAccess;
                                        import net.minecraft.world.World;
                                        import cpw.mods.fml.common.network.FMLNetworkHandler;
                                        import cpw.mods.fml.relauncher.Side;
                                        import cpw.mods.fml.relauncher.SideOnly;
                                        
                                        public class BlockCoffre extends BlockContainer
                                        {
                                        
                                        protected BlockCoffre(int par1, Material par2Material) {
                                        super(par1, par2Material);
                                        }
                                        public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
                                        {
                                        FMLNetworkHandler.openGui(player, ModCatnos.instance, 0, world, x, y, z);
                                        return true;
                                        }
                                        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                        {
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te instanceof TileEntityBigChest && stack.hasDisplayName())
                                        {
                                        ((TileEntityBigChest)te).setCustomGuiName(stack.getDisplayName());
                                        }
                                        }
                                        public void breakBlock(World world, int x, int y, int z, int side, int metadata)
                                        {
                                        dropContainerItem(world, x, y, z);
                                        super.breakBlock(world, x, y, z, side, metadata);
                                        }
                                        @Override
                                        public TileEntity createNewTileEntity(World world) {
                                        return new TileEntityBigChest();
                                        }
                                        protected void dropContainerItem(World world, int x, int y, int z)
                                        {
                                        TileEntityBigChest bigchest = (TileEntityBigChest)world.getBlockTileEntity(x, y, z);
                                        
                                        if (bigchest != null)
                                        {
                                        for (int slotId = 0; slotId < bigchest.getSizeInventory(); slotId++)
                                        {
                                        ItemStack stack = bigchest.getStackInSlot(slotId);
                                        
                                        if (stack != null)
                                        {
                                        float f = world.rand.nextFloat() * 0.8F + 0.1F;
                                        float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
                                        EntityItem entityitem;
                                        
                                        for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                        {
                                        int k1 = world.rand.nextInt(21) + 10;
                                        
                                        if (k1 > stack.stackSize)
                                        {
                                        k1 = stack.stackSize;
                                        }
                                        
                                        stack.stackSize -= k1;
                                        entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(stack.itemID, k1, stack.getItemDamage()));
                                        float f3 = 0.05F;
                                        entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3);
                                        entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F);
                                        entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3);
                                        
                                        if (stack.hasTagCompound())
                                        {
                                        entityitem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy());
                                        }
                                        }
                                        }
                                        }
                                        }
                                        }
                                        public boolean onBlockEventReceived(World world, int x, int y, int z, int eventId, int eventValue)
                                        {
                                        super.onBlockEventReceived(world, x, y, z, eventId, eventValue);
                                        TileEntity tileentity = world.getBlockTileEntity(x, y, z);
                                        return tileentity != null ? tileentity.receiveClientEvent(eventId, eventValue) : false;
                                        }
                                        }
                                        
                                        

                                        Classe Container

                                        
                                        package craftz;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.entity.player.InventoryPlayer;
                                        import net.minecraft.inventory.Container;
                                        import net.minecraft.inventory.Slot;
                                        import net.minecraft.item.ItemStack;
                                        
                                        public class ContainerBigChest extends Container
                                        {
                                        private TileEntityBigChest tileEntity;
                                        
                                        public ContainerBigChest(InventoryPlayer playerInventory, TileEntityBigChest teChest)
                                        {
                                        this.tileEntity = teChest;
                                        teChest.openChest();
                                        
                                        for(int i = 0; i < 6; i++)
                                        {
                                        for(int j = 0; j < 9; j++)
                                        {
                                        this.addSlotToContainer(new Slot(teChest, j + i * 9, 8 + j * 18, 18 + i * 18));
                                        }
                                        }
                                        this.bindPlayerInventory(playerInventory);
                                        }
                                        
                                        private void bindPlayerInventory(InventoryPlayer playerInventory)
                                        {
                                        int i;
                                        for(i = 0; i < 3; i++)
                                        {
                                        for(int j = 0; j < 9; j++)
                                        {
                                        this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18 + 37));
                                        }
                                        }
                                        
                                        for(i = 0; i < 9; i++)
                                        {
                                        this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 161 + 37));
                                        }
                                        }
                                        
                                        @Override
                                        public boolean canInteractWith(EntityPlayer player)
                                        {
                                        return tileEntity.isUseableByPlayer(player);
                                        }
                                        
                                        public ItemStack transferStackInSlot(EntityPlayer player, int slotId)
                                        {
                                        ItemStack itemstack = null;
                                        Slot slot = (Slot)this.inventorySlots.get(slotId);
                                        
                                        if(slot != null && slot.getHasStack())
                                        {
                                        ItemStack itemstack1 = slot.getStack();
                                        itemstack = itemstack1.copy();
                                        
                                        if(slotId < 9)
                                        {
                                        if(!this.mergeItemStack(itemstack1, 9, this.inventorySlots.size(), true))
                                        {
                                        return null;
                                        }
                                        }
                                        else if(!this.mergeItemStack(itemstack1, 0, 9, false))
                                        {
                                        return null;
                                        }
                                        
                                        if(itemstack1.stackSize == 0)
                                        {
                                        slot.putStack((ItemStack)null);
                                        }
                                        else
                                        {
                                        slot.onSlotChanged();
                                        }
                                        }
                                        return itemstack;
                                        }
                                        public void onContainerClosed(EntityPlayer player)
                                        {
                                        super.onContainerClosed(player);
                                        tileEntity.closeChest();
                                        }
                                        
                                        }
                                        
                                        

                                        Classe Guihandler

                                        
                                        package craftz;
                                        
                                        import cpw.mods.fml.common.network.IGuiHandler;
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.tileentity.TileEntity;
                                        import net.minecraft.world.World;
                                        
                                        public class GuiHandlerTutorial implements IGuiHandler
                                        
                                        {
                                        
                                        @Override
                                        public Object getServerGuiElement(int ID, EntityPlayer player, World world,
                                        int x, int y, int z) {
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te instanceof TileEntityBigChest)
                                        {
                                        return new ContainerBigChest(player.inventory, (TileEntityBigChest)te);
                                        }
                                        return null;
                                        }
                                        
                                        @Override
                                        public Object getClientGuiElement(int ID, EntityPlayer player, World world,
                                        int x, int y, int z) {
                                        
                                        TileEntity te = world.getBlockTileEntity(x, y, z);
                                        if(te instanceof TileEntityBigChest)
                                        {
                                        return new GuiBigChest(player.inventory, (TileEntityBigChest)te);
                                        }
                                        return null;
                                        }
                                        }
                                        
                                        

                                        Classe TileEntity

                                        
                                        package craftz;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.nbt.NBTTagList;
                                        import net.minecraft.tileentity.TileEntity;
                                        
                                        import net.minecraft.entity.player.EntityPlayer;
                                        import net.minecraft.inventory.IInventory;
                                        import net.minecraft.item.ItemStack;
                                        import net.minecraft.nbt.NBTTagCompound;
                                        import net.minecraft.nbt.NBTTagList;
                                        import net.minecraft.tileentity.TileEntity;
                                        
                                        public class TileEntityBigChest extends TileEntity implements IInventory
                                        {
                                        private ItemStack[] inventory = new ItemStack[72];
                                        private String customName;
                                        
                                        public void readFromNBT(NBTTagCompound nbttag)
                                        {
                                        super.readFromNBT(nbttag);
                                        NBTTagList nbttaglist = nbttag.getTagList("Items");
                                        this.inventory = new ItemStack[this.getSizeInventory()];
                                        
                                        if (nbttag.hasKey("CustomName"))
                                        {
                                        this.customName = nbttag.getString("CustomName");
                                        }
                                        
                                        for (int i = 0; i < nbttaglist.tagCount(); i++)
                                        {
                                        NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
                                        int j = nbttagcompound1.getByte("Slot");
                                        
                                        if (j >= 0 && j < this.inventory.length)
                                        {
                                        this.inventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                                        }
                                        }
                                        }
                                        
                                        public void writeToNBT(NBTTagCompound nbttag)
                                        {
                                        super.writeToNBT(nbttag);
                                        NBTTagList nbttaglist = new NBTTagList();
                                        
                                        for (int i = 0; i < this.inventory.length; i++)
                                        {
                                        if (this.inventory* != null)
                                        {
                                        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                                        nbttagcompound1.setByte("Slot", (byte)i);
                                        this.inventory*.writeToNBT(nbttagcompound1);
                                        nbttaglist.appendTag(nbttagcompound1);
                                        }
                                        }
                                        
                                        nbttag.setTag("Items", nbttaglist);
                                        
                                        if (this.isInvNameLocalized())
                                        {
                                        nbttag.setString("CustomName", this.customName);
                                        }
                                        }
                                        @Override
                                        public int getSizeInventory()
                                        {
                                        return inventory.length;
                                        }
                                        @Override
                                        public ItemStack getStackInSlot(int slotId)
                                        {
                                        return inventory[slotId];
                                        }
                                        @Override
                                        public ItemStack decrStackSize(int slotId, int quantity)
                                        {
                                        if (this.inventory[slotId] != null)
                                        {
                                        ItemStack itemstack;
                                        
                                        if (this.inventory[slotId].stackSize <= quantity)
                                        {
                                        itemstack = this.inventory[slotId];
                                        this.inventory[slotId] = null;
                                        this.onInventoryChanged();
                                        return itemstack;
                                        }
                                        else
                                        {
                                        itemstack = this.inventory[slotId].splitStack(quantity);
                                        
                                        if (this.inventory[slotId].stackSize == 0)
                                        {
                                        this.inventory[slotId] = null;
                                        }
                                        
                                        this.onInventoryChanged();
                                        return itemstack;
                                        }
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        @Override
                                        public ItemStack getStackInSlotOnClosing(int slotId)
                                        {
                                        if (this.inventory[slotId] != null)
                                        {
                                        ItemStack itemstack = this.inventory[slotId];
                                        this.inventory[slotId] = null;
                                        return itemstack;
                                        }
                                        else
                                        {
                                        return null;
                                        }
                                        }
                                        
                                        @Override
                                        public void setInventorySlotContents(int slotId, ItemStack stack)
                                        {
                                        this.inventory[slotId] = stack;
                                        
                                        if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                                        {
                                        stack.stackSize = this.getInventoryStackLimit();
                                        }
                                        
                                        this.onInventoryChanged();
                                        }
                                        @Override
                                        public String getInvName()
                                        {
                                        return this.isInvNameLocalized() ? this.customName : "container.bigchest";
                                        }
                                        
                                        @Override
                                        public boolean isInvNameLocalized()
                                        {
                                        return this.customName != null && this.customName.length() > 0;
                                        }
                                        
                                        public void setCustomGuiName(String name)
                                        {
                                        this.customName = name;
                                        }
                                        @Override
                                        public int getInventoryStackLimit()
                                        {
                                        return 64;
                                        }
                                        @Override
                                        public boolean isUseableByPlayer(EntityPlayer player)
                                        {
                                        return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
                                        }
                                        @Override
                                        public void openChest()
                                        {
                                        
                                        }
                                        
                                        @Override
                                        public void closeChest()
                                        {
                                        
                                        }
                                        @Override
                                        public boolean isItemValidForSlot(int slotId, ItemStack stack)
                                        {
                                        return true;
                                        }
                                        
                                        }
                                        
                                        
                                        1 réponse Dernière réponse Répondre Citer 0
                                        • robin4002R Hors-ligne
                                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                          dernière édition par

                                          Je ne vois pourtant plus aucune erreur, tu as essayé en plaçant un nouveau bloc ou tu essayé sur des blocs déjà existant ?
                                          Test sur une nouvelle map, ça serait mieux.

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • pulganP Hors-ligne
                                            pulgan
                                            dernière édition par

                                            @‘robin4002’:

                                            Je ne vois pourtant plus aucune erreur, tu as essayé en plaçant un nouveau bloc ou tu essayé sur des blocs déjà existant ?
                                            Test sur une nouvelle map, ça serait mieux.

                                            Pour info peut être un rapport, j’ai fait le tutoriel et au moment ou j’ai fait dans une classe le .instance, il n’exister pas j’ai du le créer mais je n’ai rien changer dessus peut être un rapport avec sa

                                            PS: j’ai pas encore tester sur un nouveau monde

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 7 / 7
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB