MFF

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

    Créer un bloc type four (machine)

    Planifier Épinglé Verrouillé Déplacé Les interfaces (GUI) et les container
    1.7.10
    236 Messages 39 Publieurs 69.0k Vues 15 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.
    • FlowF Hors-ligne
      Flow
      dernière édition par

      Je ne pense pas qu’elle soit appelé , mais dans le tuto j’ai regarder et il n’y aucun endroit ou l’on appelle 😕

      Oui ce gif est drôle.

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

        @‘SCAREX’:

        Fait un clique droit sur ta fonction et fait “Open call hierarchy”, çà te montrera où ta méthode est appelée, si elle ne l’est pas, appelle là, sinon rajoute un System.out.println pour savoir ce qui ne va pas.

        Site web contenant mes scripts : http://SCAREXgaming.github.io

        Pas de demandes de support par MP ni par skype SVP.
        Je n'accepte sur skype que l…

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

          Elle est appelée car tout à l’heure je ne sais pas pourquoi ca a marcher 🙂

          Oui ce gif est drôle.

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

            Alors, si tu en es convaincu, envoi ton code (avec la balise java).

            Site web contenant mes scripts : http://SCAREXgaming.github.io

            Pas de demandes de support par MP ni par skype SVP.
            Je n'accepte sur skype que l…

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

              package mod.common.block;
              
              import java.util.HashMap;
              import java.util.Iterator;
              import java.util.Map;
              import java.util.Map.Entry;
              
              import mod.common.item.ItemRegister;
              import net.minecraft.item.Item;
              import net.minecraft.item.ItemStack;
              
              @SuppressWarnings("rawtypes")
              public class AnalyzerRecipes {
              
              private static final AnalyzerRecipes smeltingBase = new AnalyzerRecipes(); //Permet d'instancier votre classe car vous le l'instancierez nul part ailleur
              private Map smeltingList = new HashMap(); //Ceci permet de mettre vos recettes
              
              public AnalyzerRecipes()
              {
              this.addRecipe(ItemRegister.itemADNofFrog, ItemRegister.itemSevewithmosquito, new ItemStack(BlockRegister.BlockBarriere)); //Ajout d'une recette, on fait un bloc de diamant à partie de deux pommes et une flèche
              }
              
              @SuppressWarnings("unchecked")
              public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3) //Cette fonction de comprend que des ItemStack, c'est celle qui ajoute les recettes à la HashMap
              {
              ItemStack[] stackList = new ItemStack[]{stack1, stack2};
              this.smeltingList.put(stackList, stack3);
              }
              
              public void addRecipe(Item item1, Item item2, ItemStack stack) //1er cas
              {
              this.addRecipe(new ItemStack(item1), new ItemStack(item2), stack);
              }
              
              public ItemStack getSmeltingResult(ItemStack[] stack) //En argument : un tableau avec le contenu des trois slots d'input
              {
              Iterator iterator = this.smeltingList.entrySet().iterator();
              Entry entry;
              
              do
              {
              if (!iterator.hasNext()) // Si il n'y a plus de recettes dans la liste
              {
              return null; //Il n'y a pas de recette correspondante
              }
              entry = (Entry)iterator.next(); //prend la recette suivante
              }
              while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); //Check si le tableau passé en argument correspond à celui de la recette, vous avez une erreur ici, on crée la fonction tout de suite.
              
              return (ItemStack)entry.getValue(); //retourne l'itemstack : resultat de la recette
              }
              
              private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
              {
              boolean isSame = false; //Au début ce n'est pas la même
              for(int i=0; i<=1; i++) // Pour les 3 items
              {
              if(stackList*.getItem() == stackList2*.getItem()) //On vérifie si ce sont les même
              {
              isSame = true; // Si c'est le cas alors isSame vaut true
              }
              else
              {
              return false; //Si un seul n'est pas bon, on cherche pas, c'est pas la bonne recette
              }
              }
              return isSame;
              }
              
              public Map getSmeltingList()
              {
              return this.smeltingList;
              }
              
              public static AnalyzerRecipes smelting()
              {
              return smeltingBase;
              }
              }
              
              

              Tout à l’heure sa a marché ca ma donné ce que je lui demandais donc bon c’est forcément qu’elle est appelé 🙂

              Oui ce gif est drôle.

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

                Là y’a qu’une seule classe, il me faudrait la tileEntity et le container.

                Site web contenant mes scripts : http://SCAREXgaming.github.io

                Pas de demandes de support par MP ni par skype SVP.
                Je n'accepte sur skype que l…

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

                  Container

                  package mod.common.block;
                  
                  import mod.common.block.entity.TileEntityAnalyzer;
                  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 ContainerAnalyzer extends Container {
                  
                  private TileEntityAnalyzer tileAnalyzer;
                  
                  public ContainerAnalyzer(TileEntityAnalyzer tile, InventoryPlayer inventory)
                  {
                  this.tileAnalyzer= tile;
                  this.addSlotToContainer(new Slot(tile, 0, 117, 31)); //Lancez votre jeu en debug pour calibrer vos slots
                  this.addSlotToContainer(new Slot(tile, 2, 61, 31));
                  this.addSlotToContainer(new SlotResult(tile, 3, 89, 87)); //Ici c'est un slot que j'ai créer, on le fera après
                  this.bindPlayerInventory(inventory); //Les containers ont été vus dans un tutoriel de robin, merci de d'y référer
                  }
                  
                  @Override
                  public boolean canInteractWith(EntityPlayer player) {
                  return this.tileAnalyzer.isUseableByPlayer(player);
                  }
                  
                  private void bindPlayerInventory(InventoryPlayer inventory)
                  {
                  int i;
                  for (i = 0; i < 3; ++i)
                  {
                  for (int j = 0; j < 9; ++j)
                  {
                  this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 125 + i * 18));
                  }
                  }
                  
                  for (i = 0; i < 9; ++i)
                  {
                  this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 183));
                  }
                  }
                  
                  public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
                  {
                  ItemStack itemstack = null;
                  Slot slot = (Slot)this.inventorySlots.get(quantity);
                  
                  if (slot != null && slot.getHasStack())
                  {
                  ItemStack itemstack1 = slot.getStack();
                  itemstack = itemstack1.copy();
                  
                  if (quantity < this.tileAnalyzer.getSizeInventory())
                  {
                  if (!this.mergeItemStack(itemstack1, this.tileAnalyzer.getSizeInventory(), this.inventorySlots.size(), true))
                  {
                  return null;
                  }
                  }
                  else if (!this.mergeItemStack(itemstack1, 0, this.tileAnalyzer.getSizeInventory(), false))
                  {
                  return null;
                  }
                  
                  if (itemstack1.stackSize == 0)
                  {
                  slot.putStack((ItemStack)null);
                  }
                  else
                  {
                  slot.onSlotChanged();
                  }
                  }
                  
                  return itemstack;
                  }
                  
                  public void onContainerClosed(EntityPlayer player)
                  {
                  super.onContainerClosed(player);
                  this.tileAnalyzer.closeInventory();
                  }
                  }
                  
                  

                  TileEntity

                  
                  package mod.common.block.entity;
                  
                  import cpw.mods.fml.relauncher.Side;
                  import cpw.mods.fml.relauncher.SideOnly;
                  import mod.common.block.AnalyzerRecipes;
                  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 TileEntityAnalyzer extends TileEntity implements IInventory
                  {
                  private ItemStack[] contents = new ItemStack[4]; //0, 1 et 2 sont les inputs et 3 est l'output
                  
                  private int workingTime = 0; //Temps de cuisson actuel
                  private int workingTimeNeeded = 1; //Temps de cuisson nécessaire
                  
                  @Override
                  public void writeToNBT(NBTTagCompound compound)
                  {
                  super.writeToNBT(compound);
                  NBTTagList nbttaglist = new NBTTagList();
                  
                  for (int i = 0; i < this.contents.length; ++i) //pour les slots
                  {
                  if (this.contents* != null)
                  {
                  NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                  nbttagcompound1.setByte("Slot", (byte)i);
                  this.contents*.writeToNBT(nbttagcompound1);
                  nbttaglist.appendTag(nbttagcompound1);
                  }
                  }
                  
                  compound.setTag("Items", nbttaglist);
                  compound.setShort("workingTime",(short)this.workingTime); //On les enregistrent en short
                  compound.setShort("workingTimeNeeded", (short)this.workingTimeNeeded);
                  }
                  
                  @Override
                  public void readFromNBT(NBTTagCompound compound)
                  {
                  super.readFromNBT(compound);
                  
                  NBTTagList nbttaglist = compound.getTagList("Items", 10);
                  this.contents = new ItemStack[this.getSizeInventory()];
                  
                  for (int i = 0; i < nbttaglist.tagCount(); ++i) //Encore une fois pour les slots
                  {
                  NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
                  int j = nbttagcompound1.getByte("Slot") & 255;
                  
                  if (j >= 0 && j < this.contents.length)
                  {
                  this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
                  }
                  }
                  
                  this.workingTime = compound.getShort("workingTime"); //On lit nos valeurs
                  this.workingTimeNeeded = compound.getShort("workingTimeNeeded");
                  }
                  
                  @Override
                  public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l'inventaire, pour notre bloc c'est quatre
                  return this.contents.length;
                  }
                  
                  @Override
                  public ItemStack getStackInSlot(int slotIndex) { //Renvoie L'itemStack se trouvant dans le slot passé en argument
                  return this.contents[slotIndex];
                  }
                  
                  @Override //Comme dit plus haut, c'est expliqué dans le tutoriel de robin
                  public ItemStack decrStackSize(int slotIndex, int amount) {
                  if (this.contents[slotIndex] != null)
                  {
                  ItemStack itemstack;
                  
                  if (this.contents[slotIndex].stackSize <= amount)
                  {
                  itemstack = this.contents[slotIndex];
                  this.contents[slotIndex] = null;
                  this.markDirty();
                  return itemstack;
                  }
                  else
                  {
                  itemstack = this.contents[slotIndex].splitStack(amount);
                  
                  if (this.contents[slotIndex].stackSize == 0)
                  {
                  this.contents[slotIndex] = null;
                  }
                  
                  this.markDirty();
                  return itemstack;
                  }
                  }
                  else
                  {
                  return null;
                  }
                  }
                  
                  @Override
                  public ItemStack getStackInSlotOnClosing(int slotIndex) {
                  if (this.contents[slotIndex] != null)
                  {
                  ItemStack itemstack = this.contents[slotIndex];
                  this.contents[slotIndex] = null;
                  return itemstack;
                  }
                  else
                  {
                  return null;
                  }
                  }
                  
                  @Override
                  public void setInventorySlotContents(int slotIndex, ItemStack stack) {
                  this.contents[slotIndex] = stack;
                  
                  if (stack != null && stack.stackSize > this.getInventoryStackLimit())
                  {
                  stack.stackSize = this.getInventoryStackLimit();
                  }
                  
                  this.markDirty();
                  }
                  
                  @Override
                  public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom
                  return "tile.Analyzer";
                  }
                  
                  @Override
                  public boolean hasCustomInventoryName() {
                  return false;
                  }
                  
                  @Override
                  public int getInventoryStackLimit() {
                  return 64;
                  }
                  
                  @Override
                  public boolean isUseableByPlayer(EntityPlayer player) {
                  return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
                  }
                  
                  @Override
                  public void openInventory() {
                  
                  }
                  
                  @Override
                  public void closeInventory() {
                  
                  }
                  
                  @Override
                  public boolean isItemValidForSlot(int slot, ItemStack stack) {
                  return slot == 2 ? false : true;
                  }
                  
                  public boolean isBurning()
                  {
                  return this.workingTime > 0;
                  }
                  
                  private boolean canSmelt()
                  {
                  if (this.contents[0] == null || this.contents[1] == null) //Si les trois premiers slots sont vides
                  {
                  return false; //On ne peut pas lancer le processus
                  }
                  else
                  {
                  ItemStack itemstack = AnalyzerRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //Il y a une erreur ici, c'est normal, on y vient après (c'est pour les recettes)
                  if (itemstack == null) return false; //rapport avec les recettes
                  if (this.contents[2] == null) return true; //vérifications du slot d'output
                  if (!this.contents[2].isItemEqual(itemstack)) return false; //ici aussi
                  int result = contents[2].stackSize + itemstack.stackSize;
                  return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); //Et là aussi décidément
                  }
                  }
                  
                  public void updateEntity() //Méthode exécutée à chaque tick
                  {
                  if(this.isBurning() && this.canSmelt()) //Si on "cuit" et que notre recette et toujours bonne, on continue
                  {
                  ++this.workingTime; //incrémentation
                  }
                  if(this.canSmelt() && !this.isBurning()) //Si la recette est bonne mais qu'elle n'est toujours pas lancée, on la lance
                  {
                  this.workingTime = 1; //La méthode isBurning() renverra true maintenant (1>0)
                  }
                  if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) //Si on est arrivé au bout du temps de cuisson et que la recette est toujours bonne
                  {
                  this.smeltItem(); //on "cuit" les items
                  this.workingTime = 0; //et on réinitialise le temps de cuisson
                  }
                  if(!this.canSmelt()) //Si la recette la recette n'est plus bonne
                  {
                  this.workingTime= 0; //le temps de cuisson est de 0
                  }
                  }
                  
                  public void smeltItem()
                  {
                  if (this.canSmelt())
                  {
                  ItemStack itemstack = AnalyzerRecipes.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[1], this.contents[2]}); //On récupère l'output de la recette
                  if (this.contents[2] == null) //Si il y a rien dans le slot d'output
                  {
                  this.contents[2] = itemstack.copy(); //On met directement l'ItemStack
                  }
                  else if (this.contents[2].getItem() == itemstack.getItem()) //Et si l'item que l'on veut est le même que celui qu'il y a déjà
                  {
                  this.contents[2].stackSize += itemstack.stackSize; // Alors ont incrémente l'ItemStack
                  }
                  
                  –this.contents[0].stackSize; //On décrémente les slots d'input
                  –this.contents[1].stackSize;
                  
                  if (this.contents[0].stackSize <= 0) //Si les slots sont vides, on remet à null le slot
                  {
                  this.contents[0] = null;
                  }
                  if (this.contents[1].stackSize <= 0)
                  {
                  this.contents[1] = null;
                  }
                  
                  }
                  }
                  
                  @SideOnly(Side.CLIENT)
                  public int getCookProgress()
                  {
                  return this.workingTime * 41 / this.workingTimeNeeded; //41 correspond à la hauteur de la barre de progression car notre barre de progression se déroule de haut en bas
                  }
                  }
                  
                  

                  Oui ce gif est drôle.

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

                    Rajoute l’annotation @Override au-dessus de la méthode updateEntity et rajoute un system.out.println dans la classe des recipes ou dans la classe updateEntity pour savoir le contenu des variables et des items de ton inventaire.

                    Site web contenant mes scripts : http://SCAREXgaming.github.io

                    Pas de demandes de support par MP ni par skype SVP.
                    Je n'accepte sur skype que l…

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

                      J’ajoute le system.out.println comme ca et au début de tout ou avec system.out.println(“QCCH”); ?

                      Oui ce gif est drôle.

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

                        Faire un System.out.println(“quelque chose”) te permet de voir quelles parties du codes sont exécutées et à quel moment. Donc mets en là où tu penses que le code ne va peut être pas.

                        Site web contenant mes scripts : http://SCAREXgaming.github.io

                        Pas de demandes de support par MP ni par skype SVP.
                        Je n'accepte sur skype que l…

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

                          J’ai regarder et rien ne s’affiche , ca ne veut pas donner le résultats , je ne comprend pas 😞

                          Oui ce gif est drôle.

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

                            C’est le but du debug, maintenant remonte chaque fonction pour voir où çà bloque, c’est là que faire clique droit sur ta fonction puis “Open call hierarchy” est utile.

                            Site web contenant mes scripts : http://SCAREXgaming.github.io

                            Pas de demandes de support par MP ni par skype SVP.
                            Je n'accepte sur skype que l…

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

                              Jvais tout revérifier encore une fois avec le tuto pour voir si j’ai bien tout mis , ca sera plus simple je pense que de chercher dans toutes les classes.

                              Oui ce gif est drôle.

                              1 réponse Dernière réponse Répondre Citer 0
                              • DiabolicaTrixD Hors-ligne
                                DiabolicaTrix Correcteurs Moddeurs confirmés
                                dernière édition par

                                Euhm, mon gui ne s’ouvre pas…?

                                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

                                  @‘DiabolicaTrix’:

                                  Euhm, mon gui ne s’ouvre pas…?

                                  Sans ton code ça va être difficile de trouver où est l’erreur.

                                  @xav, il faut pas répondre aux messages avec fond rouge/violet, ce sont des messages supprimés par le membre qui l’a posté (tu les voit car en tant que modo tu peux les restaurer).

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • DiabolicaTrixD Hors-ligne
                                    DiabolicaTrix Correcteurs Moddeurs confirmés
                                    dernière édition par

                                    Ah ouais, désolé xP.

                                    GuiHandler:

                                    ​package diabolicatrix.base.gui;
                                    
                                    import cpw.mods.fml.common.network.IGuiHandler;
                                    import diabolicatrix.base.container.ContainerTestChest;
                                    import diabolicatrix.base.tileentity.TileEntityBlockChest;
                                    import net.minecraft.entity.player.EntityPlayer;
                                    import net.minecraft.tileentity.TileEntity;
                                    import net.minecraft.world.World;
                                    
                                    public class GuiHandler implements IGuiHandler {
                                    
                                    @Override
                                    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
                                    TileEntity tile = world.getTileEntity(x, y, z);
                                    if(tile instanceof TileEntityBlockChest)
                                    {
                                    return new ContainerTestChest((TileEntityBlockChest)tile, player.inventory);
                                    }
                                    return null;
                                    }
                                    
                                    @Override
                                    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
                                    TileEntity tile = world.getTileEntity(x, y, z);
                                    if(tile instanceof TileEntityBlockChest)
                                    {
                                    return new GuiTestChest((TileEntityBlockChest)tile, player.inventory);
                                    }
                                    return null;
                                    }
                                    
                                    }
                                    
                                    

                                    Gui:

                                    ​package diabolicatrix.base.gui;
                                    
                                    import org.lwjgl.opengl.GL11;
                                    
                                    import diabolicatrix.base.container.ContainerAlloyFurnace;
                                    import diabolicatrix.base.tileentity.TileEntityAlloyFurnace;
                                    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;
                                    
                                    public class GuiAlloyFurnace extends GuiContainer {
                                    
                                    private static final ResourceLocation texture = new ResourceLocation("t4:textures/gui/container/guialloyfurnace.png");
                                       private TileEntityAlloyFurnace tileAlloyFurnace;
                                       private IInventory playerInv;
                                    
                                    public GuiAlloyFurnace(TileEntityAlloyFurnace tile, InventoryPlayer inventory) 
                                    {
                                    super(new ContainerAlloyFurnace(tile, inventory));
                                           this.tileAlloyFurnace = tile;
                                           this.playerInv = inventory;
                                           this.allowUserInput = false;
                                           this.ySize = 256;
                                           this.xSize = 256;
                                    }
                                    
                                    @Override
                                    protected void drawGuiContainerBackgroundLayer(float partialRenderTick, int x, int y) 
                                    {
                                    
                                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                                           this.mc.getTextureManager().bindTexture(texture);
                                           int k = (this.width - this.xSize) / 2;
                                           int l = (this.height - this.ySize) / 2;
                                           this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
                                           this.drawTexturedModalRect(0, 0, 176, 14, 100 + 1, 16);
                                    
                                    }
                                    
                                    protected void drawGuiContainerForegroundLayer(int x, int y)
                                       {
                                           this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName()), 10, this.ySize - 98, 4210752);
                                       }
                                    
                                    }
                                    
                                    

                                    Container:

                                    ​package diabolicatrix.base.container;
                                    
                                    import diabolicatrix.base.SlotResult;
                                    import diabolicatrix.base.tileentity.TileEntityAlloyFurnace;
                                    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 ContainerAlloyFurnace extends Container {
                                    
                                    private TileEntityAlloyFurnace tileAlloyFurnace;
                                    
                                    public ContainerAlloyFurnace(TileEntityAlloyFurnace tile, InventoryPlayer inventory)
                                    {
                                    
                                            this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 0, 49, 75));
                                            this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 1, 89, 75));
                                            this.addSlotToContainer(new Slot(this.tileAlloyFurnace, 2, 129, 75));
                                            this.addSlotToContainer(new SlotResult(this.tileAlloyFurnace, 3, 89, 135));
                                            this.bindPlayerInventory(inventory);
                                    }
                                    
                                    @Override
                                    public boolean canInteractWith(EntityPlayer player) {
                                    return this.tileAlloyFurnace.isUseableByPlayer(player);
                                    }
                                    
                                    private void bindPlayerInventory(InventoryPlayer inventory)
                                    {
                                    int i;
                                    for (i = 0; i < 3; ++i)
                                            {
                                                for (int j = 0; j < 9; ++j)
                                                {
                                                    this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 17 + j * 18, 171 + i * 18));
                                                }
                                            }
                                    
                                            for (i = 0; i < 9; ++i)
                                            {
                                                this.addSlotToContainer(new Slot(inventory, i, 17 + i * 18, 229));
                                            }
                                    }
                                    
                                    public ItemStack transferStackInSlot(EntityPlayer player, int quantity)
                                        {
                                            ItemStack itemstack = null;
                                            Slot slot = (Slot)this.inventorySlots.get(quantity);
                                    
                                            if (slot != null && slot.getHasStack())
                                            {
                                                ItemStack itemstack1 = slot.getStack();
                                                itemstack = itemstack1.copy();
                                    
                                                if (quantity < this.tileAlloyFurnace.getSizeInventory())
                                                {
                                                    if (!this.mergeItemStack(itemstack1, this.tileAlloyFurnace.getSizeInventory(), this.inventorySlots.size(), true))
                                                    {
                                                        return null;
                                                    }
                                                }
                                                else if (!this.mergeItemStack(itemstack1, 0, this.tileAlloyFurnace.getSizeInventory(), false))
                                                {
                                                    return null;
                                                }
                                    
                                                if (itemstack1.stackSize == 0)
                                                {
                                                    slot.putStack((ItemStack)null);
                                                }
                                                else
                                                {
                                                    slot.onSlotChanged();
                                                }
                                            }
                                    
                                            return itemstack;
                                        }
                                    
                                    public void onContainerClosed(EntityPlayer player)
                                        {
                                            super.onContainerClosed(player);
                                            this.tileAlloyFurnace.closeInventory();
                                        }
                                    }
                                    
                                    

                                    Block:

                                    ​package diabolicatrix.base.block;
                                    
                                    import java.util.List;
                                    import java.util.Random;
                                    
                                    import cpw.mods.fml.relauncher.Side;
                                    import cpw.mods.fml.relauncher.SideOnly;
                                    import diabolicatrix.base.tileentity.TileEntityAlloyFurnace;
                                    import net.minecraft.block.Block;
                                    import net.minecraft.block.material.Material;
                                    import net.minecraft.client.renderer.texture.IIconRegister;
                                    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.inventory.IInventory;
                                    import net.minecraft.item.Item;
                                    import net.minecraft.item.ItemStack;
                                    import net.minecraft.nbt.NBTTagCompound;
                                    import net.minecraft.network.Packet;
                                    import net.minecraft.tileentity.TileEntity;
                                    import net.minecraft.util.ChatComponentText;
                                    import net.minecraft.util.IIcon;
                                    import net.minecraft.util.MathHelper;
                                    import net.minecraft.world.IBlockAccess;
                                    import net.minecraft.world.World;
                                    
                                    public class BlockAlloyFurnace extends Block {
                                    
                                    private IIcon top, bottom, behind, front, right, left, fronto;
                                    public static String[] subBlock = new String[] { "block1", "block2"};
                                    public IIcon[] iconArray = new IIcon[subBlock.length];
                                    
                                    public BlockAlloyFurnace(Material material) {
                                    super(material);
                                    }
                                    
                                    @SideOnly(Side.CLIENT)
                                    public void registerBlockIcons(IIconRegister iiconregister) {
                                    this.blockIcon = iiconregister.registerIcon("t4:furnace_top");
                                    this.top = iiconregister.registerIcon("t4:furnace_top");
                                    this.bottom = iiconregister.registerIcon("t4:furnace_top");
                                    this.behind = iiconregister.registerIcon("t4:furnace_side");
                                    this.front = iiconregister.registerIcon("t4:furnace_front");
                                    this.fronto = iiconregister.registerIcon("t4:furnace_fronto");
                                    this.left = iiconregister.registerIcon("t4:furnace_side");
                                    this.right = iiconregister.registerIcon("t4:furnace_side");
                                    
                                    }
                                    
                                    public int damageDropped(int metadata) {
                                    return metadata;
                                    }
                                    
                                        public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack)
                                        {
                                        TileEntity tile = world.getTileEntity(x, y, z);
                                    
                                            if(tile instanceof TileEntityAlloyFurnace){
                                            int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3;
                                            ((TileEntityAlloyFurnace)tile).setDirection((byte)direction);
                                            }
                                        }
                                    
                                        @SideOnly(Side.CLIENT)
                                        public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
                                        {
                                        int metadata = world.getBlockMetadata(x, y, z);
                                        if (metadata == 1){
                                    
                                    if (side == 0 || side == 1) {
                                    return this.bottom;
                                    }
                                    TileEntity tile = world.getTileEntity(x, y, z);
                                    if(tile instanceof TileEntityAlloyFurnace){
                                    byte direction = ((TileEntityAlloyFurnace)tile).getDirection();
                                    return side == 3 && direction == 0 ? this.fronto : (side == 4 && direction == 1 ? this.fronto : (side == 2 && direction == 2 ? this.fronto : (side == 5 && direction == 3 ? this.fronto : this.top)));
                                    }
                                        }
                                        else if (metadata == 0){
                                    
                                    if (side == 0 || side == 1) {
                                    return this.bottom;
                                    }
                                    TileEntity tile = world.getTileEntity(x, y, z);
                                    if(tile instanceof TileEntityAlloyFurnace){
                                    byte direction = ((TileEntityAlloyFurnace)tile).getDirection();
                                    return side == 3 && direction == 0 ? this.front : (side == 4 && direction == 1 ? this.front : (side == 2 && direction == 2 ? this.front : (side == 5 && direction == 3 ? this.front : this.top)));
                                    }
                                        }
                                            return this.getIcon(side, world.getBlockMetadata(x, y, z));
                                        }
                                    
                                    @SideOnly(Side.CLIENT)
                                    public IIcon getIcon(int side, int metadata) {
                                    if (metadata == 1) {
                                    if (side == 0) {
                                    return this.bottom;
                                    } else if (side == 1) {
                                    return this.top;
                                    } else if (side == 2) {
                                    return this.behind;
                                    } else if (side == 3) {
                                    return this.fronto;
                                    } else if (side == 4) {
                                    return this.left;
                                    } else if (side == 5) {
                                    return this.right;
                                    }
                                    }
                                    else {
                                    if (side == 0) {
                                    return this.bottom;
                                    } else if (side == 1) {
                                    return this.top;
                                    } else if (side == 2) {
                                    return this.behind;
                                    } else if (side == 3) {
                                    return this.front;
                                    } else if (side == 4) {
                                    return this.left;
                                    } else if (side == 5) {
                                    return this.right;
                                    }
                                    }
                                    return this.blockIcon;
                                    
                                    }
                                    
                                    @Override
                                    public boolean hasTileEntity(int metadata) {
                                    return true;
                                    }
                                    
                                    @Override
                                    public TileEntity createTileEntity(World world, int metadata) {
                                    return new TileEntityAlloyFurnace();
                                    }
                                    
                                    public void breakBlock(World world, int x, int y, int z, Block block, int metadata)
                                        {
                                            TileEntity tileentity = world.getTileEntity(x, y, z);
                                    
                                           if (tileentity instanceof IInventory)
                                           {
                                            IInventory inv = (IInventory)tileentity;
                                               for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1)
                                               {
                                                   ItemStack itemstack = inv.getStackInSlot(i1);
                                    
                                                   if (itemstack != 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; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
                                                       {
                                                           int j1 = world.rand.nextInt(21) + 10;
                                    
                                                           if (j1 > itemstack.stackSize)
                                                           {
                                                               j1 = itemstack.stackSize;
                                                           }
                                    
                                                           itemstack.stackSize -= j1;
                                                           entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.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 (itemstack.hasTagCompound())
                                                           {
                                                               entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                                                           }
                                                       }
                                                   }
                                               }
                                    
                                               world.func_147453_f(x, y, z, block);
                                           }
                                    
                                            super.breakBlock(world, x, y, z, block, metadata);
                                        }
                                    
                                    }
                                    
                                    

                                    SlotResult:

                                    ​package diabolicatrix.base;
                                    
                                    import net.minecraft.entity.player.EntityPlayer;
                                    import net.minecraft.inventory.IInventory;
                                    import net.minecraft.inventory.Slot;
                                    import net.minecraft.item.ItemStack;
                                    
                                    public class SlotResult extends Slot {
                                    
                                    public SlotResult(IInventory inventory, int id, int x, int y) 
                                    {
                                    super(inventory, id, x, y);
                                    }
                                    
                                    @Override
                                    public boolean isItemValid(ItemStack stack)
                                        {
                                            return false;
                                        }
                                    
                                    public ItemStack decrStackSize(int amount)
                                        {
                                            return super.decrStackSize(amount);
                                        }
                                    
                                    public void onPickupFromSlot(EntityPlayer player, ItemStack stack)
                                        {
                                            super.onCrafting(stack);
                                            super.onPickupFromSlot(player, stack);
                                        }
                                    
                                    }
                                    
                                    

                                    Recipes:

                                    ​package diabolicatrix.base.recipes;
                                    
                                    import java.util.HashMap;
                                    import java.util.Iterator;
                                    import java.util.Map;
                                    import java.util.Map.Entry;
                                    
                                    import diabolicatrix.base.Base;
                                    import net.minecraft.block.Block;
                                    import net.minecraft.entity.player.EntityPlayer;
                                    import net.minecraft.init.Blocks;
                                    import net.minecraft.init.Items;
                                    import net.minecraft.item.Item;
                                    import net.minecraft.item.ItemStack;
                                    import net.minecraft.world.World;
                                    
                                    public class BlockAlloyFurnaceRecipes {
                                    
                                    private static final BlockAlloyFurnaceRecipes smeltingBase = new BlockAlloyFurnaceRecipes();
                                    private Map smeltingList = new HashMap();
                                    
                                    public BlockAlloyFurnaceRecipes()
                                    {
                                    this.addRecipe(Items.apple, Items.apple, Items.arrow, new ItemStack(Blocks.diamond_block));
                                    }
                                    
                                    public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4)
                                    {
                                    ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
                                    this.smeltingList.put(stackList, stack4);
                                    }
                                    
                                            public void addRecipe(Item item1, Item item2, Item item3, ItemStack stack)
                                    {
                                    this.addRecipe(new ItemStack(item1), new ItemStack(item2), new ItemStack(item3), stack);
                                    }
                                    
                                    public void addRecipe(Block block1, Item item2, Item item3, ItemStack stack)
                                    {
                                    this.addRecipe(Item.getItemFromBlock(block1), item2, item3, stack);
                                    }
                                    
                                    public void addRecipe(Block block1, Block block2, Item item3, ItemStack stack)
                                    {
                                    this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), item3, stack);
                                    }
                                    
                                    public void addRecipe(Block block1, Block block2, Block block3, ItemStack stack)
                                    {
                                    this.addRecipe(Item.getItemFromBlock(block1), Item.getItemFromBlock(block2), Item.getItemFromBlock(block3), stack);
                                    }
                                    
                                    public ItemStack getSmeltingResult(ItemStack[] stack) 
                                    {
                                        Iterator iterator = this.smeltingList.entrySet().iterator();
                                        Entry entry;
                                    
                                        do
                                        {
                                            if (!iterator.hasNext())
                                            {
                                                return null; 
                                            }
                                               entry = (Entry)iterator.next();
                                           }
                                           while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); 
                                    
                                           return (ItemStack)entry.getValue();
                                     }
                                    
                                    private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2)
                                    {
                                    boolean isSame = false; 
                                    for(int i=0; i<=2; i++) 
                                    {
                                    if(stackList*.getItem() == stackList2*.getItem())
                                    {
                                    isSame = true; 
                                    }
                                    else
                                    {
                                    return false;
                                    }
                                    }
                                    return isSame;
                                    }
                                    
                                    public Map getSmeltingList()
                                    {
                                           return this.smeltingList;
                                        }
                                    
                                    public static BlockAlloyFurnaceRecipes smelting()
                                    {
                                    return smeltingBase;
                                    }
                                    
                                    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz)
                                    {
                                        if (world.isRemote)
                                        {
                                            return true;
                                        }
                                        else
                                        {
                                        player.openGui(Base.instance, 1, world, x, y, z);
                                            return true;
                                        }
                                    }
                                    }
                                    
                                    

                                    Et c’est tout je crois.

                                    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

                                      public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz)
                                      {
                                      if (world.isRemote)
                                      {
                                      return true;
                                      }
                                      else
                                      {
                                      player.openGui(Base.instance, 1, world, x, y, z);
                                      return true;
                                      }
                                      }
                                      

                                      Cette fonction n’a rien à faire dans Recipes.java, elle doit être dans le bloc.

                                      1 réponse Dernière réponse Répondre Citer 0
                                      • DiabolicaTrixD Hors-ligne
                                        DiabolicaTrix Correcteurs Moddeurs confirmés
                                        dernière édition par

                                        Hahaha comment je me suis fail… je croyais que j’étais dans bloc xP Merci!

                                        J’ai compris pourquoi, Eclipse coupe le nom donc ça affiche: BlockAlloyF…


                                        Le gui ne s’affiche pas mais la main du perso va vers le bloc contrairement à avant

                                        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

                                          Ton gui handle est bien enregistré ?

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • DiabolicaTrixD Hors-ligne
                                            DiabolicaTrix Correcteurs Moddeurs confirmés
                                            dernière édition par

                                            Oui, car mon Gui de Coffre fonctionne

                                            NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
                                            
                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 8
                                            • 9
                                            • 10
                                            • 11
                                            • 12
                                            • 11 / 12
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB