MFF

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

    Crash ouverture Gui

    Planifier Épinglé Verrouillé Déplacé Non résolu Support pour les moddeurs
    1.12.2
    29 Messages 2 Publieurs 1.3k Vues 2 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.
    • M Hors-ligne
      matlion
      dernière édition par

      Alors j’ai modifié une grande partie de mon code pour faire ce que je voulais, malheuresement le jeu crashe encore quand j’ouvre ma machine. Ci-dessous les codes du container, du tileentity et du gui:

      public class ContainerGloriumMachine extends Container
      {
      	private TileEntityMachineGlorium tile;
      	private int	timePassed = 0;
      	private int	burnTimeLeft = 0;
      
      	public ContainerGloriumMachine(TileEntityMachineGlorium tile, InventoryPlayer playerInventory) {
      	    this.tile = tile;
      	 
              this.addSlotToContainer(new Slot(tile, 0, 26, 11));
              this.addSlotToContainer(new Slot(tile, 1, 26, 11));
              this.addSlotToContainer(new Slot(tile, 2, 76, 105));
              this.addSlotToContainer(new SlotResult(tile, 3, 164, 82)); //Ici c'est un slot que j'ai créer, on le fera après
      	 
      	}
      	
      	@Override
      	public boolean canInteractWith(EntityPlayer player) {
      	    return tile.isUsableByPlayer(player);
      	}
      	
      	@Override
      	public void addListener(IContainerListener listener) {
      	    super.addListener(listener);
      	    listener.sendAllWindowProperties(this, this.tile);
      	}
      	 
      	@Override
      	public void detectAndSendChanges() {
      	    super.detectAndSendChanges();
      	 
      	    for(int i = 0; i < this.listeners.size(); ++i) {
      	        IContainerListener icontainerlistener = (IContainerListener) this.listeners.get(i);
      	 
      	        if (this.burnTimeLeft != this.tile.getField(0)) {
      	            icontainerlistener.sendWindowProperty(this, 0,
      	                    this.tile.getField(0));
      	        }
      	 
      	        if (this.timePassed != this.tile.getField(1)) {
      	            icontainerlistener.sendWindowProperty(this, 1,
      	                    this.tile.getField(1));
      	        }
      	    }
      	 
      	    this.burnTimeLeft = this.tile.getField(0);
      	    this.timePassed = this.tile.getField(1);
      	}
      	 
      	@Override
      	@SideOnly(Side.CLIENT)
      	public void updateProgressBar(int id, int data) {
      	    this.tile.setField(id, data);
      	}
      	
      	@Override
      	public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
      	    return ItemStack.EMPTY;
      	}
      }
      

      tileEntity

      public class TileEntityMachineGlorium extends TileEntityLockable implements ITickable
      
      {
      	private NonNullList<ItemStack> stacks = NonNullList.withSize(4, ItemStack.EMPTY);
      	private String customName;
      	private int	timePassed = 0;
      	private int	burningTimeLeft	= 0;
      	
      	@Override
      	public void readFromNBT(NBTTagCompound compound) {
      	    super.readFromNBT(compound);
      	    this.stacks = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
      	    ItemStackHelper.loadAllItems(compound, this.stacks);
      	 
      	    if (compound.hasKey("CustomName", 8)) {
      	        this.customName = compound.getString("CustomName");
      	    }
      	    this.burningTimeLeft = compound.getInteger("burningTimeLeft");
      	    this.timePassed = compound.getInteger("timePassed");
      	}
      	 
      	@Override
      	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
      	    super.writeToNBT(compound);
      	    ItemStackHelper.saveAllItems(compound, this.stacks);
      	 
      	    if (this.hasCustomName()) {
      	        compound.setString("CustomName", this.customName);
      	    }
      	 
      	    compound.setInteger("burningTimeLeft", this.burningTimeLeft);
      	    compound.setInteger("timePassed", this.timePassed);
      	 
      	    return compound;
      	}
      	
      	@Override
      	public boolean hasCustomName() {
      	    return this.customName != null && !this.customName.isEmpty();
      	}
      	 
      	@Override
      	public String getName() {
      	    return hasCustomName() ? this.customName : "tile.custom_furnace";
      	}
      	 
      	public void setCustomName(String name) {
      	    this.customName = name;
      	}
      	
      	@Override
      	public int getField(int id) {
      	    switch (id) {
      	        case 0:
      	            return this.burningTimeLeft;
      	        case 1:
      	            return this.timePassed;
      	    }
      	    return 0;
      	}
      	 
      	@Override
      	public void setField(int id, int value) {
      	    switch (id) {
      	        case 0:
      	            this.burningTimeLeft = value;
      	            break;
      	        case 1:
      	            this.timePassed = value;
      	    }
      	}
      	 
      	@Override
      	public int getFieldCount() {
      	    return 2;
      	}
      	
      	@Override
      	public int getSizeInventory() {
      	    return this.stacks.size();
      	}
      	 
      	@Override
      	public ItemStack getStackInSlot(int index) {
      	    return this.stacks.get(index);
      	}
      	 
      	@Override
      	public ItemStack decrStackSize(int index, int count) {
      	    return ItemStackHelper.getAndSplit(this.stacks, index, count);
      	}
      	 
      	@Override
      	public ItemStack removeStackFromSlot(int index) {
      	    return ItemStackHelper.getAndRemove(stacks, index);
      	}
      	 
      	@Override
      	public void setInventorySlotContents(int index, ItemStack stack) {
      	    this.stacks.set(index, stack);
      	 
      	    if (stack.getCount() > this.getInventoryStackLimit()) {
      	        stack.setCount(this.getInventoryStackLimit());
      	    }
      	}
      	 
      	@Override
      	public int getInventoryStackLimit() {
      	    return 64;
      	}
      	 
      	@Override
      	public boolean isEmpty() {
      	    for(ItemStack stack : this.stacks) {
      	        if (!stack.isEmpty()) {
      	            return false;
      	        }
      	    }
      	    return true;
      	}
      	 
      	@Override
      	public void clear() {
      	    for(int i = 0; i < this.stacks.size(); i++) {
      	        this.stacks.set(i, ItemStack.EMPTY);
      	    }
      	}
      	
      	@Override
      	public void openInventory(EntityPlayer player) {}
      	 
      	@Override
      	public void closeInventory(EntityPlayer player) {}
      
      	
      	@Override
      	public boolean isItemValidForSlot(int index, ItemStack stack) {
      	    if (index == 2)
      	        return stack.getItem() == ItemsMod.lingot_glorium;
      		return true;
      	}
      	
      	/** Vérifie la distance entre le joueur et le bloc et que le bloc soit toujours présent */
      	public boolean isUsableByPlayer(EntityPlayer player) {
      	    return this.world.getTileEntity(this.pos) != this ? false : player
      	            .getDistanceSq((double) this.pos.getX() + 0.5D,
      	                    (double) this.pos.getY() + 0.5D,
      	                    (double) this.pos.getZ() + 0.5D) <= 64.0D;
      	}
      	
      	public boolean hasFuelEmpty() {
      	    return this.getStackInSlot(2).isEmpty();
      	}
      	
      	public ItemStack getRecipeResult() {
      	    return RecipesGloriumMachine.getRecipeResult(new ItemStack[] {
      	            this.getStackInSlot(0), this.getStackInSlot(1) });
      	}
      	
      	public boolean canSmelt() {
      	    // On récupère le résultat de la recette
      	    ItemStack result = this.getRecipeResult();
      	 
      	    // Le résultat est null si il n'y a pas de recette associée, donc on retourne faux
      	    if (result != null) {
      	 
      	        // On récupère le contenu du slot de résultat
      	        ItemStack slot4 = this.getStackInSlot(3);
      	 
      	        // Si il est vide on renvoie vrai
      	        if (slot4.isEmpty())
      	            return true;
      	 
      	        // Sinon on vérifie que ce soit le même objet, les même métadata et que la taille finale ne sera pas trop grande
      	        if (slot4.getItem() == result.getItem() && slot4.getItemDamage() == result.getItemDamage()) {
      	            int newStackSize = slot4.getCount() + result.getCount();
      	            if (newStackSize <= this.getInventoryStackLimit() && newStackSize <= slot4.getMaxStackSize()) {
      	                return true;
      	            }
      	        }
      	    }
      	    return false;
      	}
      	
      	public void smelt() {
      	    // Cette fonction n'est appelée que si result != null, c'est pourquoi on ne fait pas de null check
      	    ItemStack result = this.getRecipeResult();
      	    // On enlève un item de chaque ingrédient
      	    this.decrStackSize(0, 1);
      	    this.decrStackSize(1, 1);
      	    // On récupère le slot de résultat
      	    ItemStack stack4 = this.getStackInSlot(3);
      	    // Si il est vide
      	    if (stack4.isEmpty()) {
      	        // On y insère une copie du résultat
      	        this.setInventorySlotContents(3, result.copy());
      	    } else {
      	        // Sinon on augmente le nombre d'objets de l'ItemStack
      	        stack4.setCount(stack4.getCount() + result.getCount());
      	    }
      	}
      	
      	/** Temps de cuisson de la recette */
      	public int getFullRecipeTime() {
      	    return 200;
      	}
      	 
      	/** Temps que dure 1 unité de carburant (ici : 1 planche + 1 blé) */
      	public int getFullBurnTime() {
      	    return 600;
      	}
      	 
      	/** Renvoie vrai si le feu est allumé */
      	public boolean isBurning() {
      	    return burningTimeLeft > 0;
      	}
      	
      	@Override
      	public void update() {
      	    if (!this.world.isRemote) {
      	 
      	        /* Si le carburant brûle, on réduit réduit le temps restant */
      	        if (this.isBurning()) {
      	            this.burningTimeLeft--;
      	        }
      	 
      	        /*
      	            * Si la on peut faire cuire la recette et que le four ne cuit pas
      	            * alors qu'il peut, alors on le met en route
      	            */
      	        if (!this.isBurning() && this.canSmelt() && !this.hasFuelEmpty()) {
      	            this.burningTimeLeft = this.getFullBurnTime();
      	            this.decrStackSize(2, 1);
      	        }
      	 
      	        /* Si on peut faire cuire la recette et que le feu cuit */
      	        if (this.isBurning() && this.canSmelt()) {
      	            this.timePassed++;
      	            if (timePassed >= this.getFullRecipeTime()) {
      	                timePassed = 0;
      	                this.smelt();
      	            }
      	        } else {
      	            timePassed = 0;
      	        }
      	        this.markDirty();
      	    }
      	}
      
      	@Override
      	public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
      		// TODO Auto-generated method stub
      		return null;
      	}
      
      	@Override
      	public String getGuiID() {
      		// TODO Auto-generated method stub
      		return null;
      	}
      	
      }
      

      et le gui

      public class GuiGloriumMachine extends GuiContainer
      {
      	private static final ResourceLocation background = new ResourceLocation("glore","textures/gui/container/custom_furnace.png");
      	private TileEntityMachineGlorium tile;
      	private InventoryPlayer playerInv;
      	
      	public GuiGloriumMachine(TileEntityMachineGlorium tile, InventoryPlayer playerInv) {
              super(new ContainerGloriumMachine(tile, playerInv));
              this.tile = tile;
      	}
      	
      	@Override
      	protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
      		GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
              this.mc.getTextureManager().bindTexture(background);
              this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
              
              if(this.tile.isBurning())
              {
                  int i = this.getBurnLeftScaled(13); //Nous créerons cette fonction après
                  this.drawTexturedModalRect(this.guiLeft + 8, this.guiTop + 54 + 12 - i, 176, 12 - i, 14, i + 1);
              }
              
              int l = this.getCookProgressScaled(24);
              this.drawTexturedModalRect(this.guiLeft + 44, this.guiTop + 36, 176, 14, l + 1, l);
      	}
      	
      	@Override
          protected void drawGuiContainerForegroundLayer(int x, int y)
          {
          	String tileName = this.tile.getDisplayName().getUnformattedText();
          	this.fontRenderer.drawString(tileName, (this.xSize / 2 - this.fontRenderer.getStringWidth(tileName) / 2) + 3, 8, 4210752);
          	this.fontRenderer.drawString(this.playerInv.getDisplayName().getUnformattedText(), 122, this.ySize - 96 + 2, 4210752);
          }
      	
      	private int getBurnLeftScaled(int pixels) 
      	{
      		int i = this.tile.getField(1);
      		if(i == 0) i = 200;
      		return this.tile.getField(0) * pixels / i;
      	}
      	
      	private int getCookProgressScaled(int pixels) 
      	{
      		int i = this.tile.getField(2);
      		int j = this.tile.getField(3);
      		return j != 0 && i != 0 ? i * pixels / j : 0;
      	}
      }
      

      Ainsi que le rapport de crash :

      
      java.lang.NullPointerException: Rendering screen
      	at fr.gloria.glore.guis.GuiGloriumMachine.drawGuiContainerForegroundLayer(GuiGloriumMachine.java:45)
      	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:135)
      	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:349)
      	at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1168)
      	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1192)
      	at net.minecraft.client.Minecraft.run(Minecraft.java:436)
      	at net.minecraft.client.main.Main.main(Main.java:118)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
      	at GradleStart.main(GradleStart.java:25)
      
      
      A detailed walkthrough of the error, its code path and all known details is as follows:
      ---------------------------------------------------------------------------------------
      
      -- Head --
      Thread: Client thread
      Stacktrace:
      	at fr.gloria.glore.guis.GuiGloriumMachine.drawGuiContainerForegroundLayer(GuiGloriumMachine.java:45)
      	at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:135)
      	at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:349)
      
      -- Screen render details --
      Details:
      	Screen name: fr.gloria.glore.guis.GuiGloriumMachine
      	Mouse location: Scaled: (213, 119). Absolute: (427, 240)
      	Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2
      
      -- Affected level --
      Details:
      	Level name: MpServer
      	All players: 1 total; [EntityPlayerSP['Player917'/391, l='MpServer', x=180.42, y=15.00, z=544.10]]
      	Chunk stats: MultiplayerChunkCache: 566, 566
      	Level seed: 0
      	Level generator: ID 00 - default, ver 1. Features enabled: false
      	Level generator options: 
      	Level spawn location: World: (188,64,256), Chunk: (at 12,4,0 in 11,16; contains blocks 176,0,256 to 191,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
      	Level time: 11351 game time, 11351 day time
      	Level dimension: 0
      	Level storage version: 0x00000 - Unknown?
      	Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
      	Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
      	Forced entities: 99 total; [EntityItem['item.tile.stonebrick'/515, l='MpServer', x=185.88, y=12.00, z=510.41], EntityItem['item.tile.stone.diorite'/516, l='MpServer', x=182.49, y=10.00, z=509.13], EntityItem['item.tile.stone.granite'/517, l='MpServer', x=182.88, y=10.00, z=509.16], EntityItem['item.tile.stone.granite'/518, l='MpServer', x=181.13, y=10.00, z=509.27], EntityItem['item.tile.stone.diorite'/519, l='MpServer', x=181.13, y=10.00, z=510.34], EntityItem['item.tile.stone.diorite'/520, l='MpServer', x=182.93, y=11.00, z=511.88], EntitySkeleton['Squelette'/521, l='MpServer', x=183.53, y=17.00, z=506.01], EntityZombie['Zombie'/522, l='MpServer', x=183.70, y=17.00, z=508.28], EntityParrot['Perroquet'/523, l='MpServer', x=189.24, y=65.00, z=510.44], EntityBat['Chauve-souris'/524, l='MpServer', x=121.58, y=13.10, z=575.75], EntitySheep['Mouton'/525, l='MpServer', x=116.29, y=64.00, z=562.19], EntitySheep['Mouton'/529, l='MpServer', x=124.29, y=71.00, z=487.80], EntityZombie['Zombie'/541, l='MpServer', x=151.74, y=18.00, z=489.50], EntityBat['Chauve-souris'/542, l='MpServer', x=135.66, y=26.67, z=506.26], EntitySpider['Araignée'/807, l='MpServer', x=138.50, y=44.00, z=520.50], EntityCreeper['Creeper'/554, l='MpServer', x=101.50, y=18.00, z=542.50], EntitySheep['Mouton'/556, l='MpServer', x=111.87, y=67.00, z=536.47], EntitySheep['Mouton'/557, l='MpServer', x=106.50, y=67.00, z=543.50], EntitySheep['Mouton'/558, l='MpServer', x=109.38, y=68.00, z=535.48], EntitySheep['Mouton'/559, l='MpServer', x=115.46, y=69.00, z=500.02], EntitySheep['Mouton'/560, l='MpServer', x=115.53, y=69.00, z=501.10], EntitySheep['Mouton'/561, l='MpServer', x=115.42, y=69.00, z=509.88], EntityCreeper['Creeper'/562, l='MpServer', x=132.21, y=57.00, z=481.49], EntityZombie['Zombie'/565, l='MpServer', x=110.78, y=40.00, z=518.48], EntityBat['Chauve-souris'/566, l='MpServer', x=109.56, y=47.10, z=522.97], EntityZombie['Zombie'/567, l='MpServer', x=102.50, y=39.00, z=524.50], EntityPlayerSP['Player917'/391, l='MpServer', x=180.42, y=15.00, z=544.10], EntityItem['item.tile.stonebrick'/392, l='MpServer', x=178.84, y=12.00, z=554.88], EntityItem['item.tile.stonebrick'/393, l='MpServer', x=177.94, y=12.00, z=554.88], EntityItem['item.tile.stone.diorite'/394, l='MpServer', x=179.13, y=10.00, z=547.81], EntityItem['item.tile.stone.diorite'/395, l='MpServer', x=180.88, y=11.00, z=547.66], EntityItem['item.tile.stone.diorite'/396, l='MpServer', x=182.07, y=11.00, z=547.88], EntityItem['item.tile.stonebrick'/397, l='MpServer', x=179.13, y=10.00, z=547.81], EntityBat['Chauve-souris'/398, l='MpServer', x=190.24, y=16.10, z=551.03], EntityItem['item.tile.stonebrick'/399, l='MpServer', x=181.13, y=11.00, z=543.55], EntityCreeper['Creeper'/400, l='MpServer', x=186.81, y=27.00, z=533.50], EntityCreeper['Creeper'/401, l='MpServer', x=191.58, y=26.00, z=533.52], EntityRabbit['Lapin'/669, l='MpServer', x=245.51, y=63.00, z=613.93], EntitySkeleton['Squelette'/671, l='MpServer', x=224.49, y=19.00, z=618.27], EntityBat['Chauve-souris'/692, l='MpServer', x=258.51, y=60.11, z=535.32], EntityBat['Chauve-souris'/693, l='MpServer', x=252.87, y=61.50, z=553.60], EntityBat['Chauve-souris'/694, l='MpServer', x=250.75, y=63.28, z=545.82], EntitySkeleton['Squelette'/695, l='MpServer', x=207.52, y=24.00, z=585.80], EntitySkeleton['Squelette'/440, l='MpServer', x=128.50, y=18.00, z=605.50], EntitySkeleton['Squelette'/696, l='MpServer', x=198.46, y=24.00, z=584.22], EntityZombie['Zombie'/697, l='MpServer', x=202.50, y=24.00, z=581.50], EntitySkeleton['Squelette'/698, l='MpServer', x=203.50, y=22.00, z=582.50], EntityZombie['Zombie'/701, l='MpServer', x=216.50, y=24.00, z=597.50], EntityRabbit['Lapin'/702, l='MpServer', x=196.08, y=64.00, z=608.34], EntityRabbit['Lapin'/703, l='MpServer', x=205.09, y=64.00, z=614.04], EntityItem['item.tile.flower1.dandelion'/704, l='MpServer', x=238.88, y=61.00, z=507.16], EntityItem['item.tile.flower1.dandelion'/705, l='MpServer', x=235.13, y=62.00, z=505.13], EntityBat['Chauve-souris'/706, l='MpServer', x=241.53, y=48.68, z=479.17], EntityCreeper['Creeper'/707, l='MpServer', x=197.58, y=26.00, z=531.30], EntityCreeper['Creeper'/708, l='MpServer', x=198.30, y=26.30, z=530.30], EntitySquid['Poulpe'/709, l='MpServer', x=168.85, y=59.40, z=572.51], EntityChicken['Poule'/710, l='MpServer', x=159.50, y=63.00, z=583.50], EntityChicken['Poule'/711, l='MpServer', x=148.81, y=63.00, z=578.50], EntityZombie['Zombie'/712, l='MpServer', x=245.19, y=49.00, z=477.48], EntityBat['Chauve-souris'/713, l='MpServer', x=243.43, y=50.16, z=471.65], EntitySkeleton['Squelette'/714, l='MpServer', x=202.84, y=14.00, z=518.51], EntityCreeper['Creeper'/715, l='MpServer', x=193.19, y=15.00, z=519.50], EntityBat['Chauve-souris'/716, l='MpServer', x=203.88, y=15.00, z=520.71], EntityCreeper['Creeper'/717, l='MpServer', x=205.17, y=24.00, z=516.50], EntityZombie['Zombie'/718, l='MpServer', x=160.30, y=17.03, z=551.70], EntityPig['Cochon'/719, l='MpServer', x=145.50, y=63.00, z=563.50], EntityChicken['Poule'/720, l='MpServer', x=149.29, y=63.00, z=571.86], EntityZombie['Zombie'/723, l='MpServer', x=245.29, y=17.00, z=520.49], EntityParrot['Perroquet'/724, l='MpServer', x=225.50, y=65.00, z=543.50], EntitySquid['Poulpe'/725, l='MpServer', x=179.33, y=61.34, z=579.51], EntitySquid['Poulpe'/726, l='MpServer', x=180.20, y=61.82, z=580.38], EntityZombie['Zombie'/727, l='MpServer', x=238.50, y=15.00, z=521.50], EntityCreeper['Creeper'/728, l='MpServer', x=235.58, y=15.00, z=514.78], EntityChicken['Poule'/729, l='MpServer', x=161.31, y=63.00, z=583.13], EntityCreeper['Creeper'/731, l='MpServer', x=215.50, y=20.00, z=494.50], EntityZombie['Zombie'/732, l='MpServer', x=229.51, y=18.00, z=470.20], EntityCreeper['Creeper'/733, l='MpServer', x=203.26, y=20.00, z=503.61], EntitySkeleton['Squelette'/734, l='MpServer', x=209.52, y=29.00, z=469.27], EntitySkeleton['Squelette'/735, l='MpServer', x=212.50, y=18.00, z=472.50], EntityCreeper['Creeper'/736, l='MpServer', x=211.50, y=18.00, z=474.46], EntitySquid['Poulpe'/481, l='MpServer', x=165.45, y=59.50, z=501.47], EntitySpider['Araignée'/737, l='MpServer', x=210.50, y=18.00, z=471.50], EntitySquid['Poulpe'/482, l='MpServer', x=157.10, y=56.38, z=513.32], EntityCreeper['Creeper'/489, l='MpServer', x=157.50, y=15.00, z=496.50], EntityZombie['Zombie'/490, l='MpServer', x=155.50, y=15.00, z=496.50], EntityBat['Chauve-souris'/491, l='MpServer', x=158.22, y=15.01, z=500.03], EntitySquid['Poulpe'/492, l='MpServer', x=154.40, y=56.19, z=498.42], EntitySquid['Poulpe'/493, l='MpServer', x=156.72, y=56.11, z=508.95], EntityBat['Chauve-souris'/494, l='MpServer', x=115.25, y=24.10, z=534.51], EntityBat['Chauve-souris'/495, l='MpServer', x=119.99, y=45.48, z=532.86], EntityZombie['Zombie'/502, l='MpServer', x=187.58, y=16.00, z=522.77], EntityBat['Chauve-souris'/503, l='MpServer', x=188.13, y=16.26, z=522.56], EntitySheep['Mouton'/504, l='MpServer', x=146.33, y=64.00, z=559.78], EntitySheep['Mouton'/505, l='MpServer', x=136.47, y=63.00, z=563.27], EntitySheep['Mouton'/506, l='MpServer', x=137.50, y=63.00, z=567.50], EntityPig['Cochon'/507, l='MpServer', x=141.84, y=63.00, z=564.55], EntityPig['Cochon'/508, l='MpServer', x=143.11, y=63.00, z=563.77], EntityPig['Cochon'/509, l='MpServer', x=138.51, y=63.00, z=568.83], EntitySheep['Mouton'/510, l='MpServer', x=134.50, y=63.00, z=563.28]]
      	Retry entities: 0 total; []
      	Server brand: fml,forge
      	Server type: Integrated singleplayer server
      Stacktrace:
      	at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:456)
      	at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2862)
      	at net.minecraft.client.Minecraft.run(Minecraft.java:457)
      	at net.minecraft.client.main.Main.main(Main.java:118)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
      	at GradleStart.main(GradleStart.java:25)
      
      

      Merci de votre aide

      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 robin4002

        Alors comme tu as enlevé les importations les numéros de ligne ne correspondent pas. À quel ligne correspond ceci ?

        at fr.gloria.glore.guis.GuiGloriumMachine.drawGuiContainerForegroundLayer(GuiGloriumMachine.java:45)

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

          Il correspond à la ligne :

          this.fontRenderer.drawString(this.playerInv.getDisplayName().getUnformattedText(), 122, this.ySize - 96 + 2, 4210752);
          
          
          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

            C’est ta variable playerInv qui n’est jamais initialisé.

            Dans le constructeur, ajoutes this.playerInv = playerInv;

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

              Merci de ton aide. Ca marche, mais j’ai désormais un problème avec les recettes. Aucune erreur dans la console ni dans les logs pourtant le code semble bon.

              public class RecipesGloriumMachine 
              {
              	private static final RecipesGloriumMachine smeltingBase = new RecipesGloriumMachine();
              	private Map smeltingList = new HashMap();
              	
              	private static final HashMap <ItemStack[], ItemStack>recipes = new HashMap<ItemStack[], ItemStack>();
              	static {
              	    addRecipe(Items.APPLE, Items.ARROW, Items.BAKED_POTATO, new ItemStack(ItemsMod.lingot_glorium));
              	}
              	
              	private static void addRecipe(Item ingredient1, Item ingredient2, Item ingredient3, ItemStack resultat1) {
              	    addRecipe(new ItemStack(ingredient1), new ItemStack(ingredient2), new ItemStack(ingredient3), resultat1);
              	}
              	 
                  public static void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3, ItemStack stack4)
                  {
                      ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3};
                      recipes.put(stackList, stack4);
                  }
              	private static boolean areKeysEqual(ItemStack[] key1, ItemStack[] key2) {
              	    if(key1.length != key2.length) return false;
              	 
              	    for(int i = 0; i < key1.length; i++) {
              	        ItemStack s1 = key1[i];
              	        ItemStack s2 = key2[i];
              	        if(s1.isEmpty() && !s2.isEmpty()) return false;
              	        if(!s1.isEmpty() && s2.isEmpty()) return false;
              	        if(s1.getItem() != s2.getItem()) return false;
              	        if(s1.getItemDamage() != s2.getItemDamage()) return false;
              	    }
              	    return true;
              	}
              	
              	public static ItemStack getRecipeResult(ItemStack[] ingredients) {
              	    Iterator<Entry<ItemStack[], ItemStack>> it = recipes.entrySet().iterator();
              	    while(it.hasNext()) {
              	        Entry <ItemStack[], ItemStack>entry = it.next();
              	        if(areKeysEqual(entry.getKey(), ingredients)) {
              	            return entry.getValue();
              	        }
              	    }
              	    return null;
              	}
              	
              }
              
              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

                Lances ton jeu en debug, mets un point d’arrêt dans la fonction canSmelt de ton four et regardes la valeur des variables.

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

                  Ces valeurs là ?
                  Capture.PNG

                  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

                    regardes surtout le résultat de this.getStackInSlot(0), this.getStackInSlot(1) et de ItemStack result = this.getRecipeResult();

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

                      Il faut que je rajoute ?

                      this.getStackInSlot(0), this.getStackInSlot(1), this.getStackInSlot(2) });
                      
                      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

                        Non, que tu regardes via le débugueur leur valeur quand tu es sur le point d’arrêt, pour comprendre ce qu’il se passe.

                        Dans l’onglet expression de débugueur tu peux y mettre des fonctions à interpréter, afin de récupérer la valeur.

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

                          J’ai regardé, et j’en déduis que:
                          le slot 0 enregistre un ItemFood
                          le slot 1 un ItemArrow
                          le slot 2 un ItemFood
                          et le slot 3 il est null

                          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

                            Ok je crois avoir trouvé où est le problème.

                            C’est dans la classe de ton tile entity :

                            	public ItemStack getRecipeResult() {
                            	    return RecipesGloriumMachine.getRecipeResult(new ItemStack[] {
                            	            this.getStackInSlot(0), this.getStackInSlot(1) });
                            	}
                            

                            ici tu appels ta fonction getRecipeResult avec deux items stack, or tes recettes prennent 3 items. Je pense que cela devrait être plutôt comme ceci :

                            return RecipesGloriumMachine.getRecipeResult(new ItemStack[] {
                            	            this.getStackInSlot(0), this.getStackInSlot(1), this.getStackInSlot(2) });
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • M Hors-ligne
                              matlion
                              dernière édition par

                              Le Gui semble marcher mais pour une raison inconnu, le slot 3 récupére l’item comme combustible ce qui fait que la recette ne marche pas. Une idéé ?

                              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

                                Comment ça comme combustible ? à quoi ressemble ton gui ?

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

                                  Il ressemble à ça:
                                  custom_furnace.png
                                  et il prends le slot de gauche c’est à dire celui de la patate comme combustible et allume le feu. Or j’aimerais que la pomme la flèche et la patate donne mon objet.

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

                                    J’ai modifié les lignes suivantes :

                                    public boolean isItemValidForSlot(int index, ItemStack stack) {
                                    	return true;
                                    }
                                    

                                    et

                                    public void update() {
                                    	    if (!this.world.isRemote) {
                                    	 
                                    	        /* Si le carburant brûle, on réduit réduit le temps restant */
                                    	        if (this.isBurning()) {
                                    	            this.burningTimeLeft--;
                                    	        }
                                    	 
                                    	        /*
                                    	            * Si la on peut faire cuire la recette et que le four ne cuit pas
                                    	            * alors qu'il peut, alors on le met en route
                                    	            */
                                    	        if (!this.isBurning() && this.canSmelt()) {
                                    	            this.burningTimeLeft = this.getFullBurnTime();
                                    	            this.decrStackSize(2, 1);
                                    	        }
                                    	 
                                    	        /* Si on peut faire cuire la recette et que le feu cuit */
                                    	        if (this.isBurning() && this.canSmelt()) {
                                    	            this.timePassed++;
                                    	            if (timePassed >= this.getFullRecipeTime()) {
                                    	                timePassed = 0;
                                    	                this.smelt();
                                    	            }
                                    	        } else {
                                    	            timePassed = 0;
                                    	        }
                                    	        this.markDirty();
                                    	    }
                                    	}
                                    

                                    Mais toujours le même soucis

                                    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

                                      C’est plutôt dans la fonction smelt qu’il faut changer le slot utilisé pour le carburant.

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

                                        J’ai modifié la fonction smelt comme suit :

                                        	public void smelt() {
                                        
                                        		if(this.canSmelt()) 
                                        		{
                                        			ItemStack input1 = (ItemStack)this.stacks.get(0);
                                        			ItemStack input2 = (ItemStack)this.stacks.get(1);
                                        			ItemStack result = RecipesGloriumMachine.getInstance().getRecipeResult(input1);
                                        			ItemStack output = (ItemStack)this.stacks.get(3);
                                        			
                                        			if(output.isEmpty()) this.stacks.set(3, result.copy());
                                        			else if(output.getItem() == result.getItem()) output.grow(result.getCount());
                                        			
                                        			input1.shrink(1);
                                        			input2.shrink(1);
                                        		}
                                        	}
                                        

                                        mais j’ai une erreur à:

                                        ItemStack result = RecipesGloriumMachine.getInstance().getRecipeResult(input1);
                                        

                                        Qui me dit "the method getRecipeResult(ItemStack[]) in the type RecipesGloriumMachine is not applicable for the arguments (ItemStack).

                                        La classe méthode en question :

                                        public static ItemStack getRecipeResult(ItemStack[] ingredients) {
                                        	    Iterator<Entry<ItemStack[], ItemStack>> it = recipes.entrySet().iterator();
                                        	    while(it.hasNext()) {
                                        	        Entry <ItemStack[], ItemStack>entry = it.next();
                                        	        if(areKeysEqual(entry.getKey(), ingredients)) {
                                        	            return entry.getValue();
                                        	        }
                                        	    }
                                        	    return null;
                                        	}
                                        
                                        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

                                          Bha oui, ta fonction prend un array d’itemstack, pas un itemstack seul.

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

                                            Ok j’ai modifié le code, ce qui donne:

                                            	public void smelt() {
                                            
                                            		if(this.canSmelt()) 
                                            		{
                                            			ItemStack input1 = (ItemStack)this.stacks.get(0);
                                            			ItemStack input2 = (ItemStack)this.stacks.get(1);
                                            			ItemStack result = RecipesGloriumMachine.getInstance().getRecipeResult(new ItemStack[] {this.stacks[0], this.stacks[1], this.stacks[2]);
                                            			ItemStack output = (ItemStack)this.stacks.get(3);
                                            			
                                            			if(output.isEmpty()) this.stacks.set(3, result.copy());
                                            			else if(output.getItem() == result.getItem()) output.grow(result.getCount());
                                            			
                                            			input1.shrink(1);
                                            			input2.shrink(1);
                                            		}
                                            	}
                                            

                                            mais j’ai une erreur ici:

                                            {this.stacks[0], this.stacks[1], this.stacks[2]}
                                            

                                            qui me dit:
                                            The type of the expression must be an array type but it resolved to NonNullList<ItemStack>
                                            Je ne vois pas pourquoi ça fait une erreur, alors que c’est sensé être un array. Merci de ton aide

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

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB