Créer un bloc type four (machine)
-
Classe principale ?
-
package mod; import mod.common.CommonProxy; import mod.common.block.BlockRegister; import mod.common.block.entity.RegisterTileEntity; import mod.common.entity.EntityRegister; import mod.common.item.ItemRegister; import mod.common.item.recipe.RecipeRegister; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = ModMinecraft.MODID, name = ModMinecraft.Name, version = ModMinecraft.Version) public class ModMinecraft { public static final String MODID = "modminecraft"; public static final String Name = "Mod Minecraft"; public static final String Version = "1.0"; @Instance("modminecraft") public static ModMinecraft instance; @SidedProxy(clientSide = "mod.client.ClientProxy", serverSide = "mod.common.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { BlockRegister.register(); ItemRegister.register(); } @EventHandler public void init(FMLInitializationEvent event) { RegisterTileEntity.register(); RecipeRegister.register(); EntityRegister.register(); proxy.registerRender(); proxy.registerTileEntityRender(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } -
Tu n’as pas enregistré ton gui handler, si ?
-
J’ai regardé le tuto et j’ai pas capter qu’il fallait l’enregistrer O.O c’est quoi la commande ? Je l’ai pas vu

Je viens de l’ajouter
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());J’édite pour dire si sa marche

Voila lorsque je fais un click droit sa crash

A detailed walkthrough of the error, its code path and all known details is as follows:
–-------------------------------------------------------------------------------------– Head –
Stacktrace:
at mod.common.block.entity.TileEntityAnalyzer.getStackInSlot(TileEntityAnalyzer.java:70)
at net.minecraft.inventory.Slot.getStack(Slot.java:88)
at net.minecraft.inventory.Container.getInventory(Container.java:67)
at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53)
at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88)
at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
at mod.common.block.BlockAnalyzer.onBlockActivated(BlockAnalyzer.java:94)
at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409)
at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74)
at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)– Ticking connection –
Details:
Connection: net.minecraft.network.NetworkManager@4c6a43d
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)– System Details –
Details:
Minecraft Version: 1.7.10
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.7.0_75, Oracle Corporation
Java VM Version: Java HotSpot
64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 749920904 bytes (715 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active
States: ‘U’ = Unloaded ‘L’ = Loaded ‘C’ = Constructed ‘H’ = Pre-initialized ‘I’ = Initialized ‘J’ = Post-initialized ‘A’ = Available ‘D’ = Disabled ‘E’ = Errored
UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)
UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar)
UCHIJAAAA modminecraft{1.0} [Mod Minecraft] (bin)
GL info:ERRORRuntimeException: No OpenGL context found in the current thread.
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP[‘Player812’/228, l=‘New World’, x=117,75, y=66,00, z=571,81]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to ‘fml,forge’
[16:20:48] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-07-07_16.20.48-server.txt
[16:20:48] [Client thread/INFO] [FML]: Waiting for the server to terminate/save.
[16:20:48] [Server thread/INFO]: Saving worlds
[16:20:48] [Server thread/INFO]: Saving chunks for level ‘New World’/Overworld
[16:20:48] [Server thread/INFO]: Saving chunks for level ‘New World’/Nether
[16:20:48] [Server thread/INFO]: Saving chunks for level ‘New World’/The End
[16:20:48] [Server thread/INFO] [FML]: Unloading dimension 0
[16:20:48] [Server thread/INFO] [FML]: Unloading dimension -1
[16:20:48] [Server thread/INFO] [FML]: Unloading dimension 1
[16:20:48] [Server thread/INFO] [FML]: Applying holder lookups
[16:20:48] [Server thread/INFO] [FML]: Holder lookups applied
[16:20:48] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded.
[16:20:48] [Client thread/INFO] [FML]: Server terminated.
AL lib: (EE) alc_cleanup: 1 device not closedLa partie du code qui correspond
@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; } } -
L’erreur est coupé non ? Il n’y a pas l’exception.
-
Oui excuse moi j’ai remarqué juste après avoir posté T_T J’ai éditer

-
Il manque toujours l’exception, il n’y a que le stack trace.
-
[16:20:46] [Server thread/INFO]: Player812 joined the game [16:20:48] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking memory connection at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:198) ~[NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.ArrayIndexOutOfBoundsException: 3 at mod.common.block.entity.TileEntityAnalyzer.getStackInSlot(TileEntityAnalyzer.java:70) ~[TileEntityAnalyzer.class:?] at net.minecraft.inventory.Slot.getStack(Slot.java:88) ~[Slot.class:?] at net.minecraft.inventory.Container.getInventory(Container.java:67) ~[Container.class:?] at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) ~[Container.class:?] at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) ~[EntityPlayer.class:?] at mod.common.block.BlockAnalyzer.onBlockActivated(BlockAnalyzer.java:94) ~[BlockAnalyzer.class:?] at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) ~[ItemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) ~[NetworkSystem.class:?] … 5 more [16:20:48] [Server thread/ERROR]: This crash report has been saved to: C:\Users\Legrandfifou\Pictures\forge\eclipse\.\crash-reports\crash-2015-07-07_16.20.48-server.txt [16:20:48] [Server thread/INFO]: Stopping server [16:20:48] [Server thread/INFO]: Saving players [16:20:48] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // Would you like a cupcake? Time: 7/07/15 16:20 Description: Ticking memory connection java.lang.ArrayIndexOutOfBoundsException: 3 at mod.common.block.entity.TileEntityAnalyzer.getStackInSlot(TileEntityAnalyzer.java:70) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at mod.common.block.BlockAnalyzer.onBlockActivated(BlockAnalyzer.java:94) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at mod.common.block.entity.TileEntityAnalyzer.getStackInSlot(TileEntityAnalyzer.java:70) at net.minecraft.inventory.Slot.getStack(Slot.java:88) at net.minecraft.inventory.Container.getInventory(Container.java:67) at net.minecraft.inventory.Container.addCraftingToCrafters(Container.java:53) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:88) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at mod.common.block.BlockAnalyzer.onBlockActivated(BlockAnalyzer.java:94) at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:409) at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:593) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:74) at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:122) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@4c6a43d Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.7.0_75, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 749920904 bytes (715 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) UCHIJAAAA modminecraft{1.0} [Mod Minecraft] (bin) GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread. Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Player Count: 1 / 8; [EntityPlayerMP['Player812'/228, l='New World', x=117,75, y=66,00, z=571,81]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' [16:20:48] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:393]: #@!@# Game crashed! Crash report saved to: #@!@# .\crash-reports\crash-2015-07-07_16.20.48-server.txt [16:20:48] [Client thread/INFO] [FML]: Waiting for the server to terminate/save. [16:20:48] [Server thread/INFO]: Saving worlds [16:20:48] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld [16:20:48] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [16:20:48] [Server thread/INFO]: Saving chunks for level 'New World'/The End [16:20:48] [Server thread/INFO] [FML]: Unloading dimension 0 [16:20:48] [Server thread/INFO] [FML]: Unloading dimension -1 [16:20:48] [Server thread/INFO] [FML]: Unloading dimension 1 [16:20:48] [Server thread/INFO] [FML]: Applying holder lookups [16:20:48] [Server thread/INFO] [FML]: Holder lookups applied [16:20:48] [Server thread/INFO] [FML]: The state engine was in incorrect state SERVER_STOPPING and forced into state SERVER_STOPPED. Errors may have been discarded. [16:20:48] [Client thread/INFO] [FML]: Server terminated. AL lib: (EE) alc_cleanup: 1 device not closed -
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
at mod.common.block.entity.TileEntityAnalyzer.getStackInSlot(TileEntityAnalyzer.java:70) ~[TileEntityAnalyzer.class:?]
Ton tableau est plus petit que le nombre de slot que tu as ajouté. -
Merci Robin ! ::D
J’ai encore un petit problème avec la texture , voyez par vous même j’ai tout fait comme dans le tuto , et mon inventaire est décalé etc

Ma texture

Probleme

-
Faut changer les valeurs dans la fonction draw.
-
@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, 46, this.xSize, this.ySize);if(this.tileAnalyzer.isBurning())
{
int i = this.tileAnalyzer.getCookProgress();
this.drawTexturedModalRect(k + 47, l + 46, 0, 2, 100, i);
}
}Les valeurs , 46 , 47 ?
-
oui, mais essaie de comprendre le code d’abord.
-
Ah ca na plus rien avoir avec
" Examinons cette fonction :
x correspond à la coordonnée x du gui (in-game) où s’affichera la texture de la barre de progression.
y correspond à la coordonnée y du gui (in-game) où s’affichera la texture de la barre de progression.
u correspond à la position x de votre barre de progression sur votre texture (dans les ressources, l’image .png).
v correspond à la position y de votre barre de progression sur votre texture (dans les ressources, l’image .png).
width correspond à la largeur du morceau de texture que vous voulez afficher.
height correspond à la hauteur du morceau de texture que vous voulez afficher." Du coup /: J’ai tout réaligner mais il ne reste plus que l’inventaire en bas qu’il faudrait remonter je vais chercher
-
çà c’est géré au niveau du container lorsque tu rajoutes les slots.
-
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));
}
}Ce serait pas ca ?
-
Si :
new Slot(inventory, i, 17 + i * 18, 229)paramètres :
- inventaire
- index dans l’inventaire
- x
- y
il suffit de modifier les 2 derniers pour avoir ce que tu veux.
-
Nice ca marche nice ! Tout est bien positionné mais devine quoi ! La recette marche pas ca ne fait rien

AnalyzerRecipes
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; } } -
Es-tu sûr que ta méthode pour savoir si le contenu correspond est bien appelée ? Si oui, as-tu bien enregistré le recipe ?
-
J’ai suivi le tutoriel donc normalement tout est fait
Appelé , elle se trouve ou alors ?
