Table de craft buguée
-
Le String inutile sert à réobfusqué/déobfusqué les classes. Donc pas besoin dans tes propres classes.
Le problème vient du fait que le clear de la table de craft se fait lorsqu’on enlève un Item du slot de résultat, Minecraft utilise un slot custom mais toi tu as ajouté des slots normaux.
-
Ah, et comment faire, j’aurais besoin d’éclairement,car moi et les GUI’s, sa fait 2, voir 3 peut-etre

Faut que je fasse ma propre classe de slot ?
(Je fais tenter cela, car il y a bien Slot, et SlotCrafting )Edit: Non, c’est pas ça. Bon j’ai juste fait un copier coller de la classe vanilla…
Il faut peut-etre rajouter un truc mais je sais pas ce que c’estpackage net.minecraft.inventory; 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.ItemHoe; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.stats.AchievementList; public class SlotCrafting extends Slot { /** The craft matrix inventory linked to this result slot. */ private final InventoryCrafting craftMatrix; /** The player that is using the GUI where this slot resides. */ private final EntityPlayer thePlayer; /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; private static final String __OBFID = "CL_00001761"; public SlotCrafting(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition) { super(p_i45790_3_, slotIndex, xPosition, yPosition); this.thePlayer = player; this.craftMatrix = craftingInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ public boolean isItemValid(ItemStack stack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ public ItemStack decrStackSize(int amount) { if (this.getHasStack()) { this.amountCrafted += Math.min(amount, this.getStack().stackSize); } return super.decrStackSize(amount); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ protected void onCrafting(ItemStack stack, int amount) { this.amountCrafted += amount; this.onCrafting(stack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ protected void onCrafting(ItemStack stack) { if (this.amountCrafted > 0) { stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); } this.amountCrafted = 0; if (stack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { this.thePlayer.triggerAchievement(AchievementList.buildWorkBench); } if (stack.getItem() instanceof ItemPickaxe) { this.thePlayer.triggerAchievement(AchievementList.buildPickaxe); } if (stack.getItem() == Item.getItemFromBlock(Blocks.furnace)) { this.thePlayer.triggerAchievement(AchievementList.buildFurnace); } if (stack.getItem() instanceof ItemHoe) { this.thePlayer.triggerAchievement(AchievementList.buildHoe); } if (stack.getItem() == Items.bread) { this.thePlayer.triggerAchievement(AchievementList.makeBread); } if (stack.getItem() == Items.cake) { this.thePlayer.triggerAchievement(AchievementList.bakeCake); } if (stack.getItem() instanceof ItemPickaxe && ((ItemPickaxe)stack.getItem()).getToolMaterial() != Item.ToolMaterial.WOOD) { this.thePlayer.triggerAchievement(AchievementList.buildBetterPickaxe); } if (stack.getItem() instanceof ItemSword) { this.thePlayer.triggerAchievement(AchievementList.buildSword); } if (stack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { this.thePlayer.triggerAchievement(AchievementList.enchantments); } if (stack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { this.thePlayer.triggerAchievement(AchievementList.bookcase); } if (stack.getItem() == Items.golden_apple && stack.getMetadata() == 1) { this.thePlayer.triggerAchievement(AchievementList.overpowered); } } public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix); this.onCrafting(stack); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn); ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); ItemStack itemstack2 = aitemstack*; if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); } if (itemstack2 != null) { if (this.craftMatrix.getStackInSlot(i) == null) { this.craftMatrix.setInventorySlotContents(i, itemstack2); } else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } } } }EDIT² j’ai trouvé l’erreur mais je ne peut pas al corriger maintenat
-
C’était ça, maintenant, trouvez l’erreur

( Elle est plûtot simple a trouver, je l’ai vu en quelques secondes )
Le premier qui trouve aura le droit à un COOKIE -
Enleve ça: private static final String __OBFID = “CL_00001761”; c’est pour l’obfuscation, tu n’en as pas besoin

-
J’en ai pas besoin mais il ne gêne as, j’ai carrèment la flemme de l’enlever pour être franc

-
Haha, d’accord

-
Ah, je viens de me rendre compte que c’est pas ma classe … Fuck, désolé ^^’
Voici ma classepackage eryah.usefulthings.container; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import eryah.usefulthings.recipes.WeaponTableRecipes; public class SlotWeaponResult extends Slot { /** The craft matrix inventory linked to this result slot. */ private final InventoryCrafting craftMatrix; /** The player that is using the GUI where this slot resides. */ private final EntityPlayer thePlayer; /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; public SlotWeaponResult(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition) { super(p_i45790_3_, slotIndex, xPosition, yPosition); this.thePlayer = player; this.craftMatrix = craftingInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ public boolean isItemValid(ItemStack stack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ public ItemStack decrStackSize(int amount) { if (this.getHasStack()) { this.amountCrafted += Math.min(amount, this.getStack().stackSize); } return super.decrStackSize(amount); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ protected void onCrafting(ItemStack stack, int amount) { this.amountCrafted += amount; this.onCrafting(stack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ protected void onCrafting(ItemStack stack) { if (this.amountCrafted > 0) { stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); } this.amountCrafted = 0; } public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix); this.onCrafting(stack); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn); ItemStack[] aitemstack = WeaponTableRecipes.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); ItemStack itemstack2 = aitemstack*; if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); } if (itemstack2 != null) { if (this.craftMatrix.getStackInSlot(i) == null) { this.craftMatrix.setInventorySlotContents(i, itemstack2); } else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } } } } -
protected void onCrafting(ItemStack stack, int amount) { this.amountCrafted += amount; this.onCrafting(stack); }Tu augmentes le nombre d’items dans la case résultat sans vider la matrice de craft?
**EDIT : **Je suis con, amountCrafted c’est même pas le nombre d’items en résultat… si?
EDIT 2 :…Eryah il est con aussi, il nous donne la classe corrigée, comment il veut qu’on trouve l’erreur facepalm -
Ca pourrait être ça, mais non
-
J’ai mis la classe corrigée –’
package eryah.usefulthings.container; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import eryah.usefulthings.recipes.WeaponTableRecipes; public class SlotWeaponResult extends Slot { /** The craft matrix inventory linked to this result slot. */ private final InventoryCrafting craftMatrix; /** The player that is using the GUI where this slot resides. */ private final EntityPlayer thePlayer; /** The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; public SlotWeaponResult(EntityPlayer player, InventoryCrafting craftingInventory, IInventory p_i45790_3_, int slotIndex, int xPosition, int yPosition) { super(p_i45790_3_, slotIndex, xPosition, yPosition); this.thePlayer = player; this.craftMatrix = craftingInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ public boolean isItemValid(ItemStack stack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ public ItemStack decrStackSize(int amount) { if (this.getHasStack()) { this.amountCrafted += Math.min(amount, this.getStack().stackSize); } return super.decrStackSize(amount); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ protected void onCrafting(ItemStack stack, int amount) { this.amountCrafted += amount; this.onCrafting(stack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ protected void onCrafting(ItemStack stack) { if (this.amountCrafted > 0) { stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); } this.amountCrafted = 0; } public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) { net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix); this.onCrafting(stack); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn); ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj); net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null); for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); ItemStack itemstack2 = aitemstack*; if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); } if (itemstack2 != null) { if (this.craftMatrix.getStackInSlot(i) == null) { this.craftMatrix.setInventorySlotContents(i, itemstack2); } else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack2)) { this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } } } } -
Code erroné :
ItemStack[] aitemstack = CraftingManager.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);Code corrigé :
ItemStack[] aitemstack = WeaponTableRecipes.getInstance().func_180303_b(this.craftMatrix, playerIn.worldObj);:::
Trouvé avec ceci x)
::: -
Je l’ai dit avant

-
Mais pas sur ce topic

-
Arghhh je venais de voir le même truc x( mais Sasukz, tu fus plus rapide…
-
Vous avez gagnés un cookie

GG a vous deux -
C’était easy avec Winmerge

