• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu j'ai un Generateur avec la RF API qui ne genere rien

    1.8.x
    1.8.9
    2
    6
    330
    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.
    • JustAnDev
      JustAnDev dernière édition par

      bon tout est in the title
      Bloc

      package com.daichmff.modaichmod;
      
      import net.minecraft.block.BlockContainer;
      import net.minecraft.block.material.Material;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.tileentity.TileEntity;
      import net.minecraft.world.World;
      
      public class BlockBlueIngot extends BlockContainer
      {
      
          public BlockBlueIngot(Material materialIn)
          {
              super(materialIn);
              // TODO Auto-generated constructor stub
          }
      
      	   @Override
      	    public TileEntity createNewTileEntity(World worldIn, int meta) {
      	        return new TileEntityE();
      	    }
      	   
      	  
      	    
      }
      
      

      Tile

      package com.daichmff.modaichmod;
      
      import cofh.api.energy.IEnergyProvider;
      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.util.EnumFacing;
      import net.minecraft.util.IChatComponent;
      import net.minecraft.util.MathHelper;
      import net.minecraft.world.World;
      import net.minecraftforge.common.util.Constants;
      
      public class TileEntityE extends TileEntity implements IEnergyProvider,IInventory, net.minecraft.util.ITickable{
      
      	private static int iPC = 200;
      	
      	    private ItemStack[] contents = new ItemStack[1];
      	    private String customName;
      	    
      
      	
      	private int maxRF = 100000;
      	private int currentRF = 0;
      
      	
      	
      	
      	@Override
      	public void readFromNBT(NBTTagCompound compound) {
      	    super.readFromNBT(compound); // exécute ce qui se trouve dans la fonction readFromNBT de la classe mère (lecture de la position du tile entity)
              if(compound.hasKey("CustomName", Constants.NBT.TAG_STRING)) // si un tag custom name de type string existe
              {
                  this.customName = compound.getString("CustomName"); // on le lit
              }
       
              NBTTagList nbttaglist = compound.getTagList("Items", Constants.NBT.TAG_COMPOUND); // on obtient la liste de tags nommée Items
              this.contents = new ItemStack[this.getSizeInventory()]; // on réinitialise le tableau
              for(int i = 0; i < nbttaglist.tagCount(); ++i) // i varie de 0 à la taille la liste
              {
                  NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); // on lit le tag nbt
                  int j = nbttagcompound1.getByte("Slot") & 255; // on lit à quel slot se trouve l'item stack
       
                  if(j >= 0 && j < this.contents.length)
                  {
                      this.contents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); // on lit l'item stack qui se trouve dans le tag
                  }
              }
      	    super.readFromNBT(compound);
      
      	    this.currentRF = compound.getInteger("currentRF");
      
      	}
      	 
      	@Override
      	public void writeToNBT(NBTTagCompound compound) {
              super.writeToNBT(compound); // exécute se qui se trouve dans la fonction writeToNBT de la classe mère (écriture de la position du tile entity)
              if(this.hasCustomName()) // s'il y a un nom custom
              {
                  compound.setString("CustomName", this.customName); // on le met dans le tag nbt
              }
       
              NBTTagList nbttaglist = new NBTTagList(); // on créé une nouvelle liste de tags
              for(int i = 0; i < this.contents.length; ++i) // i varie de 0 à la taille de notre tableau
              {
                  if(this.contents[ i] != null) // si l'item stack à l'emplacement i du tableau n'est pas null
                  {
                      NBTTagCompound nbttagcompound1 = new NBTTagCompound(); // on créé un tag nbt
                      nbttagcompound1.setByte("Slot", (byte)i); // on enregistre son emplacement dans le tableau
                      this.contents[ i].writeToNBT(nbttagcompound1); // on écrit l'item dans le tag
                      nbttaglist.appendTag(nbttagcompound1); // on ajoute le tab à la liste
                  }
              }
              compound.setTag("Items", nbttaglist); // on enregistre la liste dans le tag nbt
      
      	    super.writeToNBT(compound);
      	    compound.setInteger("currentRF", this.currentRF);
      
      	}
      	
      	@Override
      	public int getEnergyStored(EnumFacing from) {
      		// TODO Auto-generated method stub
      		return this.currentRF;
      	}
      
      	@Override
      	public int getMaxEnergyStored(EnumFacing from) {
      		// TODO Auto-generated method stub
      		return maxRF;
      	}
      
      	@Override
      	public boolean canConnectEnergy(EnumFacing from) {
      		// TODO Auto-generated method stub
      		return true;
      	}
      
      	@Override
      	public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) {
      		// TODO Auto-generated method stub
      		currentRF -=maxExtract;
      		return maxExtract;
      	}
      
          @Override
          public int getSizeInventory()
          {
              return this.contents.length;
          }
          @Override
          public ItemStack getStackInSlot(int slotIndex)
          {
              return this.contents[slotIndex];
          }
          @Override
          public ItemStack decrStackSize(int slotIndex, int amount)
          {
              if(this.contents[slotIndex] != null) // si le contenu dans l'emplacement n'est pas null
              {
                  ItemStack itemstack;
       
                  if(this.contents[slotIndex].stackSize <= amount) // si la quantité est inférieur où égale à ce qu'on souhaite retirer
                  {
                      itemstack = this.contents[slotIndex]; // la variable itemstack prends la valeur du contenu
                      this.contents[slotIndex] = null; // on retire ce qui est dans la variable contents
                      this.markDirty(); // met à jour le tile entity
                      return itemstack; // renvoie itemstack
                  }
                  else // sinon
                  {
                      itemstack = this.contents[slotIndex].splitStack(amount); // la fonction splitStack(quantité) retire dans this.contents[slotIndex] le contenu et le met dans itemstack
       
                      if(this.contents[slotIndex].stackSize == 0) // au cas où la quantité passe à 0 (ce qui ne devrait pas arriver en temps normal)
                      {
                          this.contents[slotIndex] = null; // on met sur null, ça évite de se retrouver avec des itemstack bugué qui contiennent 0
                      }
                      this.markDirty(); // met à jour le tile entity
                      return itemstack; // renvoie itemstack
                  }
              }
              else // sinon si le contenu dans cette emplacement est null
              {
                  return null; // renvoie null, puisqu'il n'y a rien dans cette emplacement
              }
          }
      
      	@Override
      	public String getName() {
      		// TODO Auto-generated method stub
      		return this.hasCustomName() ? this.customName : "tile.cupboard";
      	}
      
      	@Override
      	public boolean hasCustomName() {
      		// TODO Auto-generated method stub
      		return false;
      	}
      	  public void setCustomName(String customName)
      	    {
      	        this.customName = customName;
      	    }
      	   @Override
      	    public boolean isUseableByPlayer(EntityPlayer player)
      	    {
      	        return true;
      	    }
      	   @Override
      	    public boolean isItemValidForSlot(int slotIndex, ItemStack stack)
      	    {
      	        return stack.getItem() == MoDaichMod.ingotblue || stack.getItem() == MoDaichMod.blueBow || stack.getItem() == MoDaichMod.bootsTuto || stack.getItem() == MoDaichMod.leggingsTuto || stack.getItem() == MoDaichMod.chestPlateTuto || stack.getItem() == MoDaichMod.helmetTuto;
      	    }
      	   @Override
      	    public int getInventoryStackLimit()
      	    {
      	        return 64;
      	    }
      
      	@Override
      	public IChatComponent getDisplayName() {
      		// TODO Auto-generated method stub
      		return null;
      	}
      
      	@Override
      	public ItemStack removeStackFromSlot(int index) {
      		// TODO Auto-generated method stub
      		return null;
      	}
      
      	
      
      
      
      
      	@Override
      	public void openInventory(EntityPlayer player) {
      		// TODO Auto-generated method stub
      		
      	}
      
      	@Override
      	public void closeInventory(EntityPlayer player) {
      	
      	}
      
      	
      	@Override
      	public int getField(int id) {
      	switch(id)
      	{
      	case 0:
      		return this.currentRF;
      	case 1:
      		return this.maxRF;
      
      
      	}
      	return 0;
      	}
      
      	@Override
      	public void setField(int id, int value) {
      	switch(id)
      	{
      	case 0:
      		this.currentRF = value;
      	case 1:
      		this.maxRF = value;
      	
      	}
      		
      	}
      
      	@Override
      	public int getFieldCount() {
      		// TODO Auto-generated method stub
      		return 2;
      	}
      	 
      
      	 
      
      	@Override
      	public void clear() {
      		// TODO Auto-generated method stub
      		
      	}
      	   @Override
      	    public void setInventorySlotContents(int slotIndex, ItemStack stack)
      	    {
      	        this.contents[slotIndex] = stack; // met l'item stack dans le tableau
      	 
      	        if(stack != null && stack.stackSize > this.getInventoryStackLimit()) // si la taille de l'item stack dépasse la limite maximum de l'inventaire
      	        {
      	            stack.stackSize = this.getInventoryStackLimit(); // on le remet sur la limite
      	        }
      	 
      	        this.markDirty(); // met à jour le tile entity
      	    }
      
      	@Override
      	public void update() {
            
      		if(worldObj.isRemote)
      		{
      			if(this.currentRF == 9999999)
      			{
      				
      			}
      			else
      			{
      				System.out.println("Your RF level is : " + currentRF);
      			}
      			
      			if(worldObj.canSeeSky(pos))
      			{
      				this.iPC =+1;
      				
      			}
      			else
      			{
      				this.iPC =-1;
      				
      			}
      			if(currentRF == 1)
      			{
      				System.out.println("[14:00:26] [Client thread/INFO]: [CHAT] <PlayerBambi> lol you have 1 rf lol you are a giant lol");
      			}
      		}
      		this.currentRF += iPC;
      		this.markDirty();
      		// TODO Auto-generated method stu   
      }
      
      }
      

      s

      1 réponse Dernière réponse Répondre Citer 0
      • JustAnDev
        JustAnDev dernière édition par JustAnDev

        @SpyMan a dit dans j'ai un Generateur avec la RF API qui ne genere rien :

        l’implémentation de cette fonction int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) est mal defini dans ta class

        alors je mets quoi dans la fonction sachant que le max et de 100 et que l’EnumFacing je pense qui soit de tout les coté

        EDIT:
        et es ce que le

        public void update()
        {
        //Reste du code
        }
        

        est bon

        s

        1 réponse Dernière réponse Répondre Citer 0
        • SpyMan
          SpyMan dernière édition par SpyMan

          yo, tes methodes de l’interface IEnergyProvder de ne sont pas definie correctement

          1 réponse Dernière réponse Répondre Citer 0
          • JustAnDev
            JustAnDev dernière édition par

            wut?
            Il y en a un mais c’est celui de la rf api il est censé pas etre mauvas sinon je te balance le code pour voir ce qui est faux

            package cofh.api.energy;
            
            import net.minecraft.util.EnumFacing;
            
            
            /**
             * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
             * <p>
             * A reference implementation is provided {@link TileEnergyHandler}.
             *
             * @author King Lemming
             *
             */
            public interface IEnergyProvider extends IEnergyHandler {
            
            	/**
            	 * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider.
            	 *
            	 * @param from
            	 *            Orientation the energy is extracted from.
            	 * @param maxExtract
            	 *            Maximum amount of energy to extract.
            	 * @param simulate
            	 *            If TRUE, the extraction will only be simulated.
            	 * @return Amount of energy that was (or would have been, if simulated) extracted.
            	 */
            	int extractEnergy(EnumFacing from, int maxExtract, boolean simulate);
            
            }
            
            

            s

            1 réponse Dernière réponse Répondre Citer 0
            • SpyMan
              SpyMan dernière édition par

              l’implémentation de cette fonction int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) est mal defini dans ta class

              1 réponse Dernière réponse Répondre Citer 0
              • JustAnDev
                JustAnDev dernière édition par JustAnDev

                @SpyMan a dit dans j'ai un Generateur avec la RF API qui ne genere rien :

                l’implémentation de cette fonction int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) est mal defini dans ta class

                alors je mets quoi dans la fonction sachant que le max et de 100 et que l’EnumFacing je pense qui soit de tout les coté

                EDIT:
                et es ce que le

                public void update()
                {
                //Reste du code
                }
                

                est bon

                s

                1 réponse Dernière réponse Répondre Citer 0
                • JustAnDev
                  JustAnDev dernière édition par

                  up💾

                  s

                  1 réponse Dernière réponse Répondre Citer 0
                  • 1 / 1
                  • Premier message
                    Dernier message
                  Design by Woryk
                  Contact / Mentions Légales

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB