Résolu Item container (backpack)
-
[font=Ubuntu, sans-serifSalut J’ai créé un item backpack qui est “censé” ouvrir un GUI mais il ne fonctionne pas. je m’explique : l’item du backpack est présent mais quand je fait clique droit dessus sa me met shutting down internat server et sa crash. je modde en 1.7.10 et j’ai recopié le tuto a la lettre et puis je comprend assez le code. j’ai aucune erreur dans le code donc je ne sait pas d’ou sa vient ]
[font=Ubuntu, sans-serifj’ai regardé le crash report et l’erreur vient de là : at com.ludrak.mods.bags.backPack.onItemRightClick(backPack.java:34)][font=Ubuntu, sans-serifet cette ligne c’est : player.openGui(MinecraftAddMod.instance, 0, world, (int) player.posX, (int) player.posY, (int) player.posZ); dans la fonction onItemRightClick() de mon item ^^]
[font=Ubuntu, sans-serifj’espère que vous comprendrez et que j’ai donné assez de détails ][font=Ubuntu, sans-serif ]
[font=Ubuntu, sans-serifmerci d’avance ] -
Salut,
Avoir le rapport de crash complet ça serait sympa. Et ton code complet aussi. -
ok crash :
–-- Minecraft Crash Report ---- // I bet Cylons wouldn't have this problem. Time: 13/01/16 20:48 Description: Unexpected error java.lang.NullPointerException: Unexpected error at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at com.ludrak.mods.bags.backPack.onItemRightClick(backPack.java:34) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) at net.minecraft.client.Minecraft.run(Minecraft.java:962) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265) at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) at com.ludrak.mods.bags.backPack.onItemRightClick(backPack.java:34) at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:164) at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:430) at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1557) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player401'/283, l='MpServer', x=-61,56, y=84,46, z=-31,06]] Chunk stats: MultiplayerChunkCache: 624, 624 Level seed: 0 Level generator: ID 00 - default, ver 1\. Features enabled: false Level generator options: Level spawn location: World: (-120,64,252), Chunk: (at 8,4,12 in -8,15; contains blocks -128,0,240 to -113,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 112286 game time, 78441 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: 75 total; [EntityXPOrb['Experience Orb'/384, l='MpServer', x=-19,84, y=58,25, z=64,66], EntityXPOrb['Experience Orb'/387, l='MpServer', x=9,69, y=60,25, z=57,25], EntityXPOrb['Experience Orb'/388, l='MpServer', x=9,41, y=60,25, z=54,28], EntityXPOrb['Experience Orb'/389, l='MpServer', x=5,00, y=60,25, z=52,25], EntityXPOrb['Experience Orb'/390, l='MpServer', x=10,63, y=60,25, z=54,44], EntityXPOrb['Experience Orb'/391, l='MpServer', x=-13,50, y=58,25, z=64,97], EntityXPOrb['Experience Orb'/392, l='MpServer', x=-13,16, y=58,25, z=66,81], EntityClientPlayerMP['Player401'/283, l='MpServer', x=-61,56, y=84,46, z=-31,06], EntityEnderman['Enderman'/285, l='MpServer', x=-61,63, y=37,00, z=-20,18], EntityEnderman['Enderman'/286, l='MpServer', x=-50,00, y=49,00, z=-34,91], EntityEnderman['Enderman'/287, l='MpServer', x=-46,88, y=51,00, z=-44,72], EntityEnderman['Enderman'/288, l='MpServer', x=-52,72, y=49,00, z=-38,72], EntityEnderman['Enderman'/289, l='MpServer', x=-63,66, y=45,00, z=-14,94], EntityEnderman['Enderman'/290, l='MpServer', x=-65,44, y=45,00, z=-7,78], EntityEnderman['Enderman'/291, l='MpServer', x=-75,75, y=46,00, z=-42,69], EntityEnderman['Enderman'/292, l='MpServer', x=-64,65, y=40,00, z=-37,65], EntityEnderman['Enderman'/293, l='MpServer', x=-67,95, y=40,00, z=-32,94], EntityEnderCrystal['entity.EnderCrystal.name'/294, l='MpServer', x=-77,50, y=53,00, z=-44,50], EntityEnderman['Enderman'/304, l='MpServer', x=-43,35, y=52,00, z=-43,42], EntityEnderman['Enderman'/305, l='MpServer', x=-47,88, y=49,00, z=-31,47], EntityEnderman['Enderman'/306, l='MpServer', x=-46,34, y=51,00, z=-39,84], EntityEnderman['Enderman'/307, l='MpServer', x=-47,97, y=50,00, z=-36,91], EntitySteeve['Ender Steve'/308, l='MpServer', x=-65,50, y=47,00, z=-46,00], EntityEnderman['Enderman'/311, l='MpServer', x=-80,94, y=45,00, z=-38,38], EntityEnderman['Enderman'/312, l='MpServer', x=-35,97, y=52,00, z=-52,06], EntityEnderman['Enderman'/313, l='MpServer', x=-35,31, y=52,00, z=-51,28], EntitySteeve['Ender Steve'/314, l='MpServer', x=-25,03, y=58,00, z=-8,31], EntityEnderman['Enderman'/315, l='MpServer', x=-31,13, y=60,00, z=14,31], EntityEnderman['Enderman'/316, l='MpServer', x=-35,47, y=59,00, z=9,50], EntityEnderman['Enderman'/317, l='MpServer', x=-45,44, y=58,00, z=11,56], EntityEnderman['Enderman'/319, l='MpServer', x=-24,41, y=60,00, z=5,94], EntityEnderman['Enderman'/320, l='MpServer', x=-9,00, y=59,00, z=-28,44], EntityEnderman['Enderman'/321, l='MpServer', x=-51,59, y=58,00, z=22,63], EntityEnderman['Enderman'/322, l='MpServer', x=-50,75, y=59,00, z=26,56], EntityEnderman['Enderman'/323, l='MpServer', x=-54,97, y=57,00, z=18,66], EntityEnderman['Enderman'/324, l='MpServer', x=-45,60, y=59,00, z=22,31], EntityEnderman['Enderman'/325, l='MpServer', x=-10,47, y=58,00, z=-42,98], EntityEnderman['Enderman'/326, l='MpServer', x=-8,22, y=60,00, z=-6,06], EntityEnderman['Enderman'/327, l='MpServer', x=-12,25, y=60,00, z=-4,78], EntityEnderman['Enderman'/328, l='MpServer', x=-44,66, y=59,00, z=22,21], EntityEnderman['Enderman'/329, l='MpServer', x=-36,94, y=59,00, z=18,66], EntityEnderCrystal['entity.EnderCrystal.name'/330, l='MpServer', x=-94,50, y=90,00, z=-77,50], EntityEnderman['Enderman'/331, l='MpServer', x=-5,95, y=58,00, z=-50,68], EntityEnderman['Enderman'/332, l='MpServer', x=-8,41, y=61,00, z=1,59], EntityXPOrb['Experience Orb'/333, l='MpServer', x=-19,59, y=61,25, z=28,53], EntityEnderman['Enderman'/334, l='MpServer', x=-62,46, y=58,00, z=43,04], EntityEnderman['Enderman'/335, l='MpServer', x=14,63, y=59,00, z=-35,02], EntityEnderman['Enderman'/336, l='MpServer', x=5,72, y=59,00, z=-37,78], EntityEnderman['Enderman'/337, l='MpServer', x=10,78, y=59,00, z=-44,34], EntityEnderman['Enderman'/338, l='MpServer', x=10,21, y=60,00, z=-0,55], EntityEnderman['Enderman'/339, l='MpServer', x=13,59, y=60,00, z=-2,63], EntityEnderman['Enderman'/340, l='MpServer', x=12,50, y=60,00, z=-0,72], EntityEnderman['Enderman'/341, l='MpServer', x=13,38, y=60,00, z=-1,75], EntityEnderman['Enderman'/342, l='MpServer', x=7,59, y=60,00, z=-6,84], EntityEnderman['Enderman'/343, l='MpServer', x=8,03, y=60,00, z=-2,47], EntityEnderman['Enderman'/344, l='MpServer', x=-43,83, y=59,00, z=37,14], EntityEnderman['Enderman'/345, l='MpServer', x=-40,00, y=60,00, z=39,44], EntityEnderman['Enderman'/346, l='MpServer', x=-46,69, y=59,00, z=36,75], EntityEnderman['Enderman'/347, l='MpServer', x=-46,59, y=59,00, z=31,72], EntityEnderman['Enderman'/348, l='MpServer', x=5,78, y=58,00, z=-48,34], EntityEnderman['Enderman'/349, l='MpServer', x=1,53, y=58,00, z=-48,81], EntityEnderman['Enderman'/350, l='MpServer', x=8,16, y=58,53, z=-46,31], EntityEnderman['Enderman'/351, l='MpServer', x=13,73, y=60,00, z=-0,56], EntityEnderman['Enderman'/352, l='MpServer', x=8,02, y=60,00, z=2,82], EntityEnderman['Enderman'/353, l='MpServer', x=11,53, y=61,13, z=19,50], EntityXPOrb['Experience Orb'/362, l='MpServer', x=-17,09, y=59,25, z=53,97], EntityXPOrb['Experience Orb'/363, l='MpServer', x=-20,78, y=59,25, z=50,94], EntityEnderman['Enderman'/364, l='MpServer', x=12,89, y=61,00, z=46,23], EntityEnderman['Enderman'/365, l='MpServer', x=4,53, y=62,00, z=43,84], EntityEnderman['Enderman'/366, l='MpServer', x=18,84, y=62,00, z=35,41], EntityEnderman['Enderman'/368, l='MpServer', x=17,56, y=62,00, z=31,47], EntityEnderman['Enderman'/369, l='MpServer', x=21,03, y=62,00, z=23,34], EntityXPOrb['Experience Orb'/370, l='MpServer', x=-0,16, y=59,25, z=58,44], EntityXPOrb['Experience Orb'/382, l='MpServer', x=-21,03, y=58,25, z=69,22], EntityXPOrb['Experience Orb'/383, l='MpServer', x=-20,72, y=58,25, z=69,22]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) at net.minecraft.client.Minecraft.run(Minecraft.java:991) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) – System Details -- Details: Minecraft Version: 1.7.10 Operating System: Mac OS X (x86_64) version 10.9.5 Java Version: 1.8.0_65, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 789087656 bytes (752 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 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.1566 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.1566-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1566} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1566-1.7.10.jar) UCHIJAAAA minecraftadd{1.1.2} [Minecraft Add's] (bin) GL info: ' Vendor: 'Intel Inc.' Version: '2.1 INTEL-8.28.37' Renderer: 'Intel Iris Pro OpenGL Engine' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: Intel Iris Pro OpenGL Engine GL version 2.1 INTEL-8.28.37, Intel Inc. GL Caps: Using GL 1.3 multitexturing. Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported. Anisotropic filtering is supported and maximum anisotropy is 16. Shaders are available because OpenGL 2.1 is supported. Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
Item BackPack :
package com.ludrak.mods.bags; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import com.ludrak.mods.MinecraftAddMod; import com.ludrak.mods.lib.References; import cpw.mods.fml.common.registry.GameRegistry; public class backPack extends Item { public backPack() { this.setUnlocalizedName("backPack"); this.setTextureName(References.MODID + ":backPack"); this.setCreativeTab(CreativeTabs.tabTools); this.maxStackSize = 1; this.register(); } public final void register() { GameRegistry.registerItem(this, "backPack"); } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { player.openGui(MinecraftAddMod.instance, 0, world, (int) player.posX, (int) player.posY, (int) player.posZ); return stack; } }
GUIHandler :
package com.ludrak.mods.bags; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GUIHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof backPack)) return null; return new ContainerBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54)); } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case 0: // The last parameter must be a multiple of 9 (e.g: 9, 18, 27, 54) // Condition to check if the player has the right item in hand if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof backPack)) return null; return new GuiBackPack(player.inventory, new InventoryBackPack(player.getHeldItem(), 54)); } return null; } }
InventoryBackPack :
package com.ludrak.mods.bags; import com.ludrak.mods.lib.References; 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.minecraftforge.common.util.Constants; public class InventoryBackPack implements IInventory { public ItemStack[] content; public int size; public InventoryBackPack(ItemStack container, int size) { this.size = size; this.content = new ItemStack; if (!container.hasTagCompound()) container.setTagCompound(new NBTTagCompound()); this.readFromNBT(container.getTagCompound()); } /** * This methods reads the content of the NBTTagCompound inside the container * * @param comp * the container NBTTagCompound */ public void readFromNBT(NBTTagCompound comp) { NBTTagList nbtlist = comp.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < nbtlist.tagCount(); i++) { NBTTagCompound comp1 = nbtlist.getCompoundTagAt(i); int slot = comp1.getInteger("Slot"); this.content[slot] = ItemStack.loadItemStackFromNBT(comp1); } } /** * This methods saves the content inside the container * * @param comp * the NBTTagCompound to write in */ public void writeToNBT(NBTTagCompound comp) { NBTTagList nbtlist = new NBTTagList(); for (int i = 0; i < this.size; i++) { if (this.content* != null) { NBTTagCompound comp1 = new NBTTagCompound(); comp1.setInteger("Slot", i); this.content*.writeToNBT(comp1); nbtlist.appendTag(comp1); } } comp.setTag("Inventory", nbtlist); } @Override public int getSizeInventory() { return this.size; } @Override public ItemStack getStackInSlot(int index) { return this.content[index]; } @Override public ItemStack decrStackSize(int index, int amount) { ItemStack stack = getStackInSlot(index); if (stack != null) { if (stack.stackSize > amount) { stack = stack.splitStack(amount); if (stack.stackSize == 0) this.content[index] = null; } else { this.content[index] = null; } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int index) { ItemStack stack = getStackInSlot(index); if (stack != null) this.content[index] = null; return stack; } @Override public void setInventorySlotContents(int index, ItemStack stack) { this.content[index] = stack; } @Override public String getInventoryName() { return References.MODID + ".container.backpack"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public void markDirty() {} @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public void openInventory() {} @Override public void closeInventory() {} /** * Prevents backpack-ception */ @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return !(stack.getItem() instanceof backPack); } }
ContainerBackPack :
package com.ludrak.mods.bags; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ContainerBackPack extends Container { public InventoryBackPack invBackpack; public int rows; public ContainerBackPack(InventoryPlayer playerInv, InventoryBackPack inv) { this.invBackpack = inv; this.rows = inv.getSizeInventory() / 9; int i = (this.rows - 4) * 18; int j; int k; // Adding slots to the backpack for (j = 0; j < this.rows; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new SlotBackPack(inv, k + j * 9, 8 + k * 18, 18 + j * 18)); } } // Adding player's slots for (j = 0; j < 3; ++j) { for (k = 0; k < 9; ++k) { this.addSlotToContainer(new Slot(playerInv, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); } } for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j, 8 + j * 18, 161 + i)); } } @Override public boolean canInteractWith(EntityPlayer player) { return true; } public void writeToNBT(ItemStack stack) { if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); invBackpack.writeToNBT(stack.getTagCompound()); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); // Prevents backpack-ception (backpack inside backpack) with // shift-click if (itemstack.getItem() instanceof backPack) return null; if (index < this.invBackpack.getSizeInventory()) { if (!this.mergeItemStack(itemstack1, this.invBackpack.getSizeInventory(), this.inventorySlots.size(), true)) return null; } else if (!this.mergeItemStack(itemstack1, 0, this.invBackpack.getSizeInventory(), false)) { return null; } if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); } return itemstack; } /** * @param buttonPressed * left click, right click, wheel click, etc. * @param flag * category (e.g.: hotbar keys) */ @Override public ItemStack slotClick(int slotIndex, int buttonPressed, int flag, EntityPlayer player) { // Prevents from removing current backpack if (flag == 2 && buttonPressed == player.inventory.currentItem) return null; if (slotIndex - this.invBackpack.getSizeInventory() - 27 == player.inventory.currentItem) return null; return super.slotClick(slotIndex, buttonPressed, flag, player); } /** * Used to save content */ @Override public void onContainerClosed(EntityPlayer player) { this.writeToNBT(player.getHeldItem()); super.onContainerClosed(player); } }
GUIBackPack :
package com.ludrak.mods.bags; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class GuiBackPack extends GuiContainer { public static final ResourceLocation texture = new ResourceLocation("textures/gui/container/generic_54.png"); protected InventoryBackPack inv; protected InventoryPlayer playerInv; public int rows; public GuiBackPack(InventoryPlayer playerInv, InventoryBackPack inv) { super(new ContainerBackPack(playerInv, inv)); this.playerInv = playerInv; this.inv = inv; this.allowUserInput = false; // Calculate the number of rows this.rows = inv.getSizeInventory() / 9; // Height of the GUI using the number of rows this.ySize = 114 + this.rows * 18; } @Override protected void drawGuiContainerForegroundLayer(int x, int y) { this.fontRendererObj.drawString(I18n.format(this.inv.getInventoryName(), new Object[0]), 8, 6, 4210752); this.fontRendererObj.drawString(this.playerInv.hasCustomInventoryName() ? this.playerInv.getInventoryName() : I18n.format(this.playerInv.getInventoryName(), new Object[0]), 8, this.ySize - 96 + 2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float prt, int x, int y) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(texture); // Centering GUI int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; // Drawing the first part of the GUI (slots of the backpack) this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.rows * 18 + 17); // And after the slots from the player's inventory this.drawTexturedModalRect(k, l + this.rows * 18 + 17, 0, 126, this.xSize, 96); } }
SlotBackPack :
package com.ludrak.mods.bags; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotBackPack extends Slot { public SlotBackPack(IInventory inv, int index, int x, int y) { super(inv, index, x, y); } @Override public boolean isItemValid(ItemStack stack) { return !(stack.getItem() instanceof backPack); } }
-
Merci pour les balises … Les avoir mit dès la création du message aurait évité que le code s’écrase sur la gauche.
Le problème se trouve dans la classe principale.
-
ok désolé pour les balises je savait juste pas comment les mettre. tu veut ma class principale ? (avec les balises ;))
-
Oui
-
Class Principale :
[size=x-smallpackage] com.ludrak.mods; [size=x-smallimport] java.awt.Color; [size=x-smallimport] java.util.Hashtable; [size=x-smallimport] net.minecraft.block.Block; [size=x-smallimport] net.minecraft.block.material.Material; [size=x-smallimport] net.minecraft.client.model.ModelBiped; [size=x-smallimport] net.minecraft.creativetab.CreativeTabs; [size=x-smallimport] net.minecraft.enchantment.Enchantment; [size=x-smallimport] net.minecraft.init.Blocks; [size=x-smallimport] net.minecraft.init.Items; [size=x-smallimport] net.minecraft.item.Item; [size=x-smallimport] net.minecraft.item.Item.ToolMaterial; [size=x-smallimport] net.minecraft.item.ItemArmor.ArmorMaterial; [size=x-smallimport] net.minecraft.item.ItemStack; [size=x-smallimport] net.minecraftforge.common.DimensionManager; [size=x-smallimport] net.minecraftforge.common.config.Configuration; [size=x-smallimport] net.minecraftforge.common.util.EnumHelper; [size=x-smallimport] com.ibm.icu.text.~~ChineseDateFormat~~.~~Field~~; [size=x-smallimport] com.ludrak.mods.Bows.DiamBow; [size=x-smallimport] com.ludrak.mods.Bows.EmBow; [size=x-smallimport] com.ludrak.mods.Bows.LavaBow; [size=x-smallimport] com.ludrak.mods.Bows.RubyBow; [size=x-smallimport] com.ludrak.mods.Bows.SaphBow; [size=x-smallimport] com.ludrak.mods.Dimensions.EndChunkProvider; [size=x-smallimport] com.ludrak.mods.Eggs.DragonEgg; [size=x-smallimport] com.ludrak.mods.Guns.EntityAKBullet; [size=x-smallimport] com.ludrak.mods.Guns.EntityBullet; [size=x-smallimport] com.ludrak.mods.Guns.EntitySniperBullet; [size=x-smallimport] com.ludrak.mods.Guns.GunBallItem; [size=x-smallimport] com.ludrak.mods.Guns.ItemAK47; [size=x-smallimport] com.ludrak.mods.Guns.ItemAKBall; [size=x-smallimport] com.ludrak.mods.Guns.ItemGun; [size=x-smallimport] com.ludrak.mods.Guns.ItemSnipe; [size=x-smallimport] com.ludrak.mods.Guns.RenderBullet; [size=x-smallimport] com.ludrak.mods.Guns.RenderSniperBullet; [size=x-smallimport] com.ludrak.mods.Guns.SniperBallItem; [size=x-smallimport] com.ludrak.mods.World.WorldGen; [size=x-smallimport] com.ludrak.mods.armors.ArmorEmerald; [size=x-smallimport] com.ludrak.mods.armors.ArmorRuby; [size=x-smallimport] com.ludrak.mods.armors.ArmorSapphire; [size=x-smallimport] com.ludrak.mods.armors.LavaArmor; [size=x-smallimport] com.ludrak.mods.blocks.BlockProperties; [size=x-smallimport] com.ludrak.mods.blocks.LavaOre; [size=x-smallimport] com.ludrak.mods.blocks.RubyOre; [size=x-smallimport] com.ludrak.mods.blocks.SapphireOre; [size=x-smallimport] com.ludrak.mods.lib.CommonProxy; [size=x-smallimport] com.ludrak.mods.lib.References; [size=x-smallimport] com.ludrak.mods.records.record; [size=x-smallimport] com.ludrak.mods.tools.AxeItem; [size=x-smallimport] com.ludrak.mods.tools.HoeItem; [size=x-smallimport] com.ludrak.mods.tools.PickItem; [size=x-smallimport] com.ludrak.mods.tools.ShovelItem; [size=x-smallimport] com.ludrak.mods.tools.SwordItem; [size=x-smallimport] com.ludrak.mods.tools.SwordLava; [size=x-smallimport] cpw.mods.fml.client.registry.RenderingRegistry; [size=x-smallimport] cpw.mods.fml.common.Mod; [size=x-smallimport] cpw.mods.fml.common.Mod.EventHandler; [size=x-smallimport] cpw.mods.fml.common.Mod.Instance; [size=x-smallimport] cpw.mods.fml.common.SidedProxy; [size=x-smallimport] cpw.mods.fml.common.event.FMLInitializationEvent; [size=x-smallimport] cpw.mods.fml.common.event.FMLPostInitializationEvent; [size=x-smallimport] cpw.mods.fml.common.event.FMLPreInitializationEvent; [size=x-smallimport] cpw.mods.fml.common.registry.EntityRegistry; [size=x-smallimport] cpw.mods.fml.common.registry.GameRegistry; [size=x-smallimport] cpw.mods.fml.common.registry.LanguageRegistry; [size=x-small@Mod](modid = References.MODID, version = References.VERSION) [size=x-smallpublic] class MinecraftAddMod<setUnlocalizedName> [size=x-small{] [size=x-small@SidedProxy](clientSide = References.ClientProxy, serverSide = References.ServerProxy) [size=x-smallpublic static CommonProxy] proxy; [size=x-smallpublic] int gun_bullet_projectileID; [size=x-small@Instance](References.MODID) [size=x-smallpublic] static MinecraftAddMod instance; [size=x-small@EventHandler] [size=x-smallpublic] void preInit(FMLPreInitializationEvent event) [size=x-small{] [size=x-smallConfiguration] config = new Configuration(event.getSuggestedConfigurationFile()); [size=x-smalltry ] [size=x-small{] [size=x-smallconfig].load(); [size=x-smallgun_bullet_projectileID] = config.get("Entity", "Bullet Projectile ID", 427).getInt(); [size=x-smallconfig].save(); [size=x-small}] [size=x-smallfinally ] [size=x-small{] [size=x-smallif](config.hasChanged()) [size=x-small{] [size=x-smallconfig].save(); [size=x-small}] [size=x-small}] [size=x-smallInits.]Init(); [size=x-smallInits].register(); [size=x-small}] [size=x-small@EventHandler] [size=x-smallpublic] void Inits(FMLInitializationEvent event) [size=x-small{] [size=x-smallproxy].registerRenderInformation(); [size=x-small}] [size=x-small@EventHandler] [size=x-smallpublic] void load(FMLPostInitializationEvent event) [size=x-small{] [size=x-small}] [size=x-small}]
Inits :
package com.ludrak.mods; import java.awt.Color; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.util.EnumHelper; import akka.io.Tcp.Register; import com.ludrak.mods.Bows.DiamBow; import com.ludrak.mods.Bows.EmBow; import com.ludrak.mods.Bows.LavaBow; import com.ludrak.mods.Bows.RubyBow; import com.ludrak.mods.Bows.SaphBow; import com.ludrak.mods.Eggs.DragonEgg; import com.ludrak.mods.Entitys.EntitySteeve; import com.ludrak.mods.Guns.EntityAKBullet; import com.ludrak.mods.Guns.EntityBullet; import com.ludrak.mods.Guns.EntitySniperBullet; import com.ludrak.mods.Guns.GunBallItem; import com.ludrak.mods.Guns.ItemAK47; import com.ludrak.mods.Guns.ItemAKBall; import com.ludrak.mods.Guns.ItemGun; import com.ludrak.mods.Guns.ItemSnipe; import com.ludrak.mods.Guns.RenderBullet; import com.ludrak.mods.Guns.RenderSniperBullet; import com.ludrak.mods.Guns.SniperBallItem; import com.ludrak.mods.World.WorldGen; import com.ludrak.mods.armors.ArmorEmerald; import com.ludrak.mods.armors.ArmorRuby; import com.ludrak.mods.armors.ArmorSapphire; import com.ludrak.mods.armors.LavaArmor; import com.ludrak.mods.bags.backPack; import com.ludrak.mods.blocks.LavaOre; import com.ludrak.mods.blocks.RubyOre; import com.ludrak.mods.blocks.SapphireOre; import com.ludrak.mods.lib.References; import com.ludrak.mods.tools.AxeItem; import com.ludrak.mods.tools.HoeItem; import com.ludrak.mods.tools.PickItem; import com.ludrak.mods.tools.ShovelItem; import com.ludrak.mods.tools.SwordItem; import com.ludrak.mods.tools.SwordLava; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; public class Inits { public static ToolMaterial EmeraldMaterial = EnumHelper.addToolMaterial("EmeraldMaterial", 1200, 799, 12.5F, 3, 19); public static ArmorMaterial EmeraldArmor = EnumHelper.addArmorMaterial("EmeraldArmor", 37, new int[]{5, 9, 8, 5}, 19); public static ToolMaterial SapphireMaterial = EnumHelper.addToolMaterial("SapphireMaterial", 1400, 999, 13.5F, 3.5F, 20); public static ArmorMaterial SapphireArmor = EnumHelper.addArmorMaterial("SapphireArmor", 39, new int[]{5, 9, 8, 5}, 20); public static ToolMaterial RubyMaterial = EnumHelper.addToolMaterial("RubyMaterial", 1500, 1100, 14F, 4F, 21); public static ArmorMaterial RubyArmor = EnumHelper.addArmorMaterial("RubyArmor", 40, new int[]{5, 9, 8, 5}, 21); public static ToolMaterial LavaMaterial = EnumHelper.addToolMaterial("LavaMaterial", 1800, 1700, 16F, 5.5F, 21); public static ArmorMaterial LavaArmor = EnumHelper.addArmorMaterial("RubyArmor", 45, new int[]{5, 9, 8, 5}, 21); /** Emerald Items **/ public static Item EmeraldSword, EmeraldPick, EmeraldAxe, EmeraldShovel, EmeraldHoe, EmeraldHelmet, EmeraldChest, EmeraldLeggings, EmeraldBoots; /** Sapphire Items **/ public static Item Sapphire, SapphireSword, SapphirePick, SapphireAxe, SapphireShovel, SapphireHoe, SapphireHelmet, SapphireChest, SapphireLeggings, SapphireBoots; /** Ruby Items **/public static Item Ruby, RubySword, RubyPick, RubyAxe, RubyShovel, RubyHoe, RubyBoots, RubyLeggings, RubyChest, RubyHelmet; /** Lava Block **/public static Block LavaOre; /**and items **/public static Item LavaCrystal, LavaSword, LavaPick, LavaAxe, LavaShovel, LavaHoe, LavaHelmet, LavaChest, LavaLeg, LavaBoots, LavaRod; /** Bows Items **/public static Item DiamondBow, EmeraldBow, SaphBow, RubyBow, LavaBow; /** Gun **/public static Item Gun, GunBall, Sniper, SniperBall, AK47, AKBall, backPack; /** Sapphire Blocks **/ public static Block SapphireOre; /** Ruby Blocks **/public static Block RubyOre; /** Items **/public static Item CarbonString; /** Eggs **/public static Item DragonEgg; /** Items for gun and sniper assemblation **/public static Item lentille, crosse, mecanism, cannon, lunette; public static void Init() { EmeraldSword = new SwordItem(EmeraldMaterial).setUnlocalizedName("EmeraldSword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(References.MODID + ":EmeraldSword"); EmeraldPick = new PickItem(EmeraldMaterial).setUnlocalizedName("EmeraldPick").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":EmeraldPick"); EmeraldAxe = new AxeItem(EmeraldMaterial).setUnlocalizedName("EmeraldAxe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":EmeraldAxe"); EmeraldShovel = new ShovelItem(EmeraldMaterial).setUnlocalizedName("EmeraldShovel").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":EmeraldShovel"); EmeraldHoe = new HoeItem(EmeraldMaterial).setUnlocalizedName("EmeraldHoe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":EmeraldHoe"); EmeraldHelmet = new ArmorEmerald(EmeraldArmor, 0).setUnlocalizedName("EmeraldHelmet").setTextureName(References.MODID + ":EmeraldHelmet"); EmeraldChest = new ArmorEmerald(EmeraldArmor, 1).setUnlocalizedName("EmeraldChest").setTextureName(References.MODID + ":EmeraldChest"); EmeraldLeggings = new ArmorEmerald(EmeraldArmor, 2).setUnlocalizedName("EmeraldLeggings").setTextureName(References.MODID + ":EmeraldLeggings"); EmeraldBoots = new ArmorEmerald(EmeraldArmor, 3).setUnlocalizedName("EmeraldBoots").setTextureName(References.MODID + ":EmeraldBoots"); /** Sapphire Objects **/ SapphireOre = new SapphireOre(Material.rock).setBlockName("SapphireOre").setBlockTextureName(References.MODID + ":SapphireOre").setCreativeTab(CreativeTabs.tabBlock); Sapphire = new Item().setUnlocalizedName("Sapphire").setCreativeTab(CreativeTabs.tabMaterials).setTextureName(References.MODID + ":Sapphire"); SapphireSword = new SwordItem(SapphireMaterial).setUnlocalizedName("SapphireSword").setTextureName(References.MODID + ":SapphireSword").setCreativeTab(CreativeTabs.tabCombat); SapphirePick = new PickItem(SapphireMaterial).setUnlocalizedName("SapphirePick").setTextureName(References.MODID + ":SapphirePick").setCreativeTab(CreativeTabs.tabTools); SapphireAxe = new AxeItem(SapphireMaterial).setUnlocalizedName("SapphireAxe").setTextureName(References.MODID + ":SapphireAxe").setCreativeTab(CreativeTabs.tabTools); SapphireShovel = new ShovelItem(SapphireMaterial).setUnlocalizedName("SapphireShovel").setTextureName(References.MODID + ":SapphireShovel").setCreativeTab(CreativeTabs.tabTools); SapphireHoe = new HoeItem(SapphireMaterial).setUnlocalizedName("SapphireHoe").setTextureName(References.MODID + ":SapphireHoe").setCreativeTab(CreativeTabs.tabTools); SapphireHelmet = new ArmorSapphire(SapphireArmor, 0).setUnlocalizedName("SapphireHelmet").setTextureName(References.MODID + ":SapphireHelmet"); SapphireChest = new ArmorSapphire(SapphireArmor, 1).setUnlocalizedName("SapphireChest").setTextureName(References.MODID + ":SapphireChest"); SapphireLeggings = new ArmorSapphire(SapphireArmor, 2).setUnlocalizedName("SapphireLeggings").setTextureName(References.MODID + ":SapphireLeggings"); SapphireBoots = new ArmorSapphire(SapphireArmor, 3).setUnlocalizedName("SapphireBoots").setTextureName(References.MODID + ":SapphireBoots"); /** Ruby Objects **/ Ruby = new Item().setUnlocalizedName("Ruby").setCreativeTab(CreativeTabs.tabMaterials).setTextureName(References.MODID + ":Ruby"); RubyOre = new RubyOre(Material.rock).setBlockName("RubyOre").setCreativeTab(CreativeTabs.tabBlock).setBlockTextureName(References.MODID + ":RubyOre"); RubySword = new SwordItem(RubyMaterial).setUnlocalizedName("RubySword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(References.MODID + ":RubySword"); RubyPick = new PickItem(RubyMaterial).setUnlocalizedName("RubyPick").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":RubyPick"); RubyAxe = new AxeItem(RubyMaterial).setUnlocalizedName("RubyAxe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":RubyAxe"); RubyShovel = new ShovelItem(RubyMaterial).setUnlocalizedName("RubyShovel").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":RubyShovel"); RubyHoe = new HoeItem(RubyMaterial).setUnlocalizedName("RubyHoe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":RubyHoe"); RubyHelmet = new ArmorRuby(RubyArmor, 0).setUnlocalizedName("RubyHelmet").setTextureName(References.MODID + ":RubyHelmet"); RubyChest = new ArmorRuby(RubyArmor, 1).setUnlocalizedName("RubyChest").setTextureName(References.MODID + ":RubyChest"); RubyLeggings = new ArmorRuby(RubyArmor, 2).setUnlocalizedName("RubyLeggings").setTextureName(References.MODID + ":RubyLeggings"); RubyBoots = new ArmorRuby(RubyArmor, 3).setUnlocalizedName("RubyBoots").setTextureName(References.MODID + ":RubyBoots"); /** Bows Objects **/ DiamondBow = new DiamBow().setUnlocalizedName("DiamondBow").setTextureName(References.MODID + ":DiamStand"); EmeraldBow = new EmBow().setUnlocalizedName("EmeraldBow").setTextureName(References.MODID + ":EmStand"); SaphBow = new SaphBow().setUnlocalizedName("SaphBow").setTextureName(References.MODID + ":SaphStand"); RubyBow = new RubyBow().setUnlocalizedName("RubyBow").setTextureName(References.MODID + ":RubyStand"); LavaBow = new LavaBow().setUnlocalizedName("LavaBow").setTextureName(References.MODID + ":lava_bow_standby"); CarbonString = new Item().setUnlocalizedName("Cbs").setTextureName(References.MODID + ":CarbonString").setCreativeTab(CreativeTabs.tabMaterials); /** Eggs **/ DragonEgg = new DragonEgg(); /** Guns **/ Gun = new ItemGun(); Sniper = new ItemSnipe(); GunBall = new GunBallItem(); SniperBall = new SniperBallItem(); AK47 = new ItemAK47(); AKBall = new ItemAKBall(); lentille = new Item().setUnlocalizedName("lentille").setTextureName("minecraftadd:lentille").setCreativeTab(CreativeTabs.tabMaterials); mecanism = new Item().setUnlocalizedName("mecanism").setTextureName("minecraftadd:mecanism").setCreativeTab(CreativeTabs.tabMaterials); crosse = new Item().setUnlocalizedName("crosse").setTextureName("minecraftadd:crosse").setCreativeTab(CreativeTabs.tabMaterials); cannon = new Item().setUnlocalizedName("cannon").setTextureName("minecraftadd:cannon").setCreativeTab(CreativeTabs.tabMaterials); lunette = new Item().setUnlocalizedName("lunette").setTextureName("minecraftadd:lunette").setCreativeTab(CreativeTabs.tabMaterials); LavaOre = new LavaOre(Material.rock); LavaCrystal = new Item().setUnlocalizedName("LavaCrystal").setTextureName("minecraftadd:lava_crystal").setCreativeTab(CreativeTabs.tabMaterials); LavaSword = new SwordLava(LavaMaterial); LavaPick = new PickItem(LavaMaterial).setUnlocalizedName("LavaPick").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":lava_crystal_pick"); LavaAxe = new AxeItem(LavaMaterial).setUnlocalizedName("LavaAxe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":lava_crystal_axe"); LavaShovel = new AxeItem(LavaMaterial).setUnlocalizedName("LavaShovel").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":lava_crystal_shovel"); LavaHoe = new HoeItem(LavaMaterial).setUnlocalizedName("LavaHoe").setCreativeTab(CreativeTabs.tabTools).setTextureName(References.MODID + ":lava_crystal_hoe"); LavaHelmet = new LavaArmor(LavaArmor, 0).setUnlocalizedName("LavaHelmet").setTextureName(References.MODID + ":lavahelmet"); LavaChest = new LavaArmor(LavaArmor, 1).setUnlocalizedName("LavaChest").setTextureName(References.MODID + ":lavachest"); LavaLeg = new LavaArmor(LavaArmor, 2).setUnlocalizedName("LavaLeg").setTextureName(References.MODID + ":lavaleg"); LavaBoots = new LavaArmor(LavaArmor, 3).setUnlocalizedName("LavaBoots").setTextureName(References.MODID + ":lavaboots"); LavaRod = new Item().setUnlocalizedName("LavaRod").setTextureName(References.MODID + ":lava_rod").setCreativeTab(CreativeTabs.tabMaterials); backPack = new backPack(); } public static void register() { /** Emerald Register **/ GameRegistry.registerItem(EmeraldSword, "EmeraldSword"); LanguageRegistry.addName(EmeraldSword, "Emerald Sword"); GameRegistry.registerItem(EmeraldPick, "EmeraldPick"); LanguageRegistry.addName(EmeraldPick, "Emerald Pickaxe"); GameRegistry.registerItem(EmeraldAxe, "EmeraldAxe"); LanguageRegistry.addName(EmeraldAxe, "Emerald Axe"); GameRegistry.registerItem(EmeraldShovel, "EmeraldShovel"); LanguageRegistry.addName(EmeraldShovel, "Emerald Shovel"); GameRegistry.registerItem(EmeraldHoe, "EmeraldHoe"); LanguageRegistry.addName(EmeraldHoe, "Emerald Hoe"); GameRegistry.registerItem(EmeraldHelmet, "EmeraldHelmet"); LanguageRegistry.addName(EmeraldHelmet, "Emerald Helmet"); GameRegistry.registerItem(EmeraldChest, "EmeraldChest"); LanguageRegistry.addName(EmeraldChest, "Emerald Chestplate"); GameRegistry.registerItem(EmeraldLeggings, "EmeraldLeggings"); LanguageRegistry.addName(EmeraldLeggings, "Emerald Leggings"); GameRegistry.registerItem(EmeraldBoots, "EmeraldBoots"); LanguageRegistry.addName(EmeraldBoots, "Emerald Boots"); /** Sapphire Register **/ GameRegistry.registerItem(Sapphire, "Sapphire"); LanguageRegistry.addName(Sapphire, "Sapphire"); GameRegistry.registerBlock(SapphireOre, "SapphireOre"); LanguageRegistry.addName(SapphireOre, "Sapphire Ore"); GameRegistry.registerItem(SapphireSword, "SapphireSword"); LanguageRegistry.addName(SapphireSword, "Sapphire Sword"); GameRegistry.registerItem(SapphirePick, "SapphirePick"); LanguageRegistry.addName(SapphirePick, "Sapphire Pickaxe"); GameRegistry.registerItem(SapphireAxe, "SapphireAxe"); LanguageRegistry.addName(SapphireAxe, "Sapphire Axe"); GameRegistry.registerItem(SapphireShovel, "SapphireShovel"); LanguageRegistry.addName(SapphireShovel, "Sapphire Shovel"); GameRegistry.registerItem(SapphireHoe, "SapphireHoe"); LanguageRegistry.addName(SapphireHoe, "Sapphire Hoe"); GameRegistry.registerItem(SapphireHelmet, "SapphireHelmet"); LanguageRegistry.addName(SapphireHelmet, "Sapphire Helmet"); GameRegistry.registerItem(SapphireChest, "SapphireChest"); LanguageRegistry.addName(SapphireChest, "Sapphire Chestplate"); GameRegistry.registerItem(SapphireLeggings, "SapphireLeggings"); LanguageRegistry.addName(SapphireLeggings, "Sapphire Leggings"); GameRegistry.registerItem(SapphireBoots, "SapphireBoots"); LanguageRegistry.addName(SapphireBoots, "Sapphire Boots"); /** Ruby Register **/ GameRegistry.registerItem(Ruby, "Ruby"); LanguageRegistry.addName(Ruby, "Ruby"); GameRegistry.registerBlock(RubyOre, "RubyOre"); LanguageRegistry.addName(RubyOre, "Ruby Ore"); GameRegistry.registerItem(RubySword, "RubySword"); LanguageRegistry.addName(RubySword, "Ruby Sword"); GameRegistry.registerItem(RubyPick, "RubyPick"); LanguageRegistry.addName(RubyPick, "Ruby Pickaxe"); GameRegistry.registerItem(RubyAxe, "RubyAxe"); LanguageRegistry.addName(RubyAxe, "Ruby Axe"); GameRegistry.registerItem(RubyShovel, "RubyShovel"); LanguageRegistry.addName(RubyShovel, "Ruby Shovel"); GameRegistry.registerItem(RubyHoe, "RubyHoe"); LanguageRegistry.addName(RubyHoe, "Ruby Hoe"); GameRegistry.registerItem(RubyHelmet, "RubyHelmet"); LanguageRegistry.addName(RubyHelmet, "Ruby Helmet"); GameRegistry.registerItem(RubyChest, "RubyChest"); LanguageRegistry.addName(RubyChest, "Ruby Chestplate"); GameRegistry.registerItem(RubyLeggings, "RubyLeggings"); LanguageRegistry.addName(RubyLeggings, "Ruby Leggings"); GameRegistry.registerItem(RubyBoots, "RubyBoots"); LanguageRegistry.addName(RubyBoots, "Ruby Boots"); GameRegistry.registerItem(DiamondBow, " DiamondBow"); LanguageRegistry.addName(DiamondBow, "Diamond Bow"); GameRegistry.registerItem(EmeraldBow, " EmeraldBow"); LanguageRegistry.addName(EmeraldBow, "Emerald Bow"); GameRegistry.registerItem(SaphBow, " SaphBow"); LanguageRegistry.addName(SaphBow, "Sapphire Bow"); GameRegistry.registerItem(RubyBow, " RubyBow"); LanguageRegistry.addName(RubyBow, "Ruby Bow"); GameRegistry.registerItem(LavaBow, " LavaBow"); LanguageRegistry.addName(LavaBow, "Lava Bow"); GameRegistry.registerItem(CarbonString, " Cbs"); LanguageRegistry.addName(CarbonString, "Carbon String"); GameRegistry.registerItem(DragonEgg, "DragonEgg"); LanguageRegistry.addName(DragonEgg, "Dragon Egg"); /** Guns **/ EntityRegistry.registerModEntity(EntityBullet.class, "bullet", 576465, References.MODID, 40, 1, true); EntityRegistry.registerModEntity(EntitySniperBullet.class, "bullet2", 576465, References.MODID, 40, 1, true); EntityRegistry.registerModEntity(EntityAKBullet.class, "bullet3", 576465, References.MODID, 40, 1, true); GameRegistry.registerItem(Gun, "Gun");LanguageRegistry.addName(Gun, "Gun"); GameRegistry.registerItem(Sniper, "Sniper");LanguageRegistry.addName(Sniper, "Sniper"); GameRegistry.registerItem(AK47, "AK47");LanguageRegistry.addName(AK47, "AK 47"); GameRegistry.registerItem(GunBall, "GunBall");LanguageRegistry.addName(GunBall, "Gun Bullet"); GameRegistry.registerItem(SniperBall, "SniperBall");LanguageRegistry.addName(SniperBall, "Sniper Bullet"); GameRegistry.registerItem(AKBall, "AKBall");LanguageRegistry.addName(AKBall, "AK 47 Bullet"); GameRegistry.registerItem(lentille, "lentille");LanguageRegistry.addName(lentille, "Lentille"); GameRegistry.registerItem(mecanism, "mecanism");LanguageRegistry.addName(mecanism, "Mecanism"); GameRegistry.registerItem(cannon, "cannon");LanguageRegistry.addName(cannon, "Cannon"); GameRegistry.registerItem(lunette, "lunette");LanguageRegistry.addName(lunette, "Sniper Sight"); GameRegistry.registerItem(crosse, "crosse");LanguageRegistry.addName(crosse, "Cross"); GameRegistry.registerBlock(LavaOre, "LavaOre");LanguageRegistry.addName(LavaOre, "Lava Ore"); GameRegistry.registerItem(LavaCrystal, "LavaCrystal");LanguageRegistry.addName(LavaCrystal, "Lava Crystal"); GameRegistry.registerItem(LavaSword, "LavaSword");LanguageRegistry.addName(LavaSword, "Lava Sword"); GameRegistry.registerItem(LavaPick, "LavaPick");LanguageRegistry.addName(LavaPick, "Lava Pickaxe"); GameRegistry.registerItem(LavaAxe, "LavaAxe");LanguageRegistry.addName(LavaAxe, "Lava Axe"); GameRegistry.registerItem(LavaShovel, "LavaShovel");LanguageRegistry.addName(LavaShovel, "Lava Shovel"); GameRegistry.registerItem(LavaHoe, "LavaHoe");LanguageRegistry.addName(LavaHoe, "Lava Hoe"); GameRegistry.registerItem(LavaHelmet, "LavaHelmet");LanguageRegistry.addName(LavaHelmet, "Lava Helmet"); GameRegistry.registerItem(LavaChest, "LavaChest");LanguageRegistry.addName(LavaChest, "Lava Chestplate"); GameRegistry.registerItem(LavaLeg, "LavaLeg");LanguageRegistry.addName(LavaLeg, "Lava Leggings"); GameRegistry.registerItem(LavaBoots, "LavaBoots");LanguageRegistry.addName(LavaBoots, "Lava Boots"); GameRegistry.registerItem(LavaRod, "LavaRod");LanguageRegistry.addName(LavaRod, "Lava Rod"); GameRegistry.registerItem(backPack, "backPack");LanguageRegistry.addName(backPack, "Backpack"); EntityRegistry.registerGlobalEntityID(EntitySteeve.class, "EntitySteeve", EntityRegistry.findGlobalUniqueEntityId(), new Color(10, 100, 200).getRGB(), new Color(0, 50, 200).getRGB()); EntityRegistry.registerModEntity(EntitySteeve.class, "EntitySteeve", 420, MinecraftAddMod.instance, 40, 1, true); EntityRegistry.addSpawn(EntitySteeve.class, 1, 1, 1, EnumCreatureType.monster, BiomeGenBase.sky); WorldGen worldgeneration = new WorldGen(); GameRegistry.registerWorldGenerator(worldgeneration, 0); /** CRAFTS **/ GameRegistry.addRecipe(new ItemStack(CarbonString, 1), " y ", " y ", " y ",'y', Items.coal); GameRegistry.addRecipe(new ItemStack(CarbonString, 1), "y ", "y ", "y ",'y', Items.coal); GameRegistry.addRecipe(new ItemStack(CarbonString, 1), " y", " y", " y",'y', Items.coal); GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), " xy", "x y", " xy",'y', CarbonString, 'x', Items.diamond); GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), "xy ", "x y", "xy",'x', CarbonString, 'y', Items.diamond); GameRegistry.addRecipe(new ItemStack(LavaBow, 1), " xy", "x y", " xy",'y', CarbonString, 'x', LavaRod); GameRegistry.addRecipe(new ItemStack(LavaBow, 1), "xy ", "x y", "xy",'x', CarbonString, 'y', LavaRod); GameRegistry.addRecipe(new ItemStack(EmeraldBow, 1), " xy", "x y", " xy",'y', CarbonString, 'x', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldBow, 1), "xy ", "x y", "xy",'x', CarbonString, 'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(Gun, 1), "yyy", " dy", " yy",'y', Items.iron_ingot, 'x', Items.gold_ingot, 'd', Items.diamond); GameRegistry.addRecipe(new ItemStack(GunBall, 2), " x ", "xyx", "xyx",'y', Items.gunpowder, 'x', Items.gold_ingot); GameRegistry.addRecipe(new ItemStack(SniperBall, 1), " x ", "xyx", "xyx",'y', Items.gunpowder, 'x', Items.iron_ingot); GameRegistry.addRecipe(new ItemStack(AKBall, 16), " x ", "xyx", "cyc",'y', Items.gunpowder, 'x', Items.gold_ingot, 'c', Items.iron_ingot); GameRegistry.addRecipe(new ItemStack(lentille, 1), " x ", "x x", " x ", 'x', Blocks.glass); GameRegistry.addRecipe(new ItemStack(crosse, 1), "xxx", " xx", " x", 'x', Blocks.obsidian); GameRegistry.addRecipe(new ItemStack(cannon, 1), "xxx", " ", "xxx",'x', Blocks.obsidian); GameRegistry.addRecipe(new ItemStack(lunette, 1), "xxx", "y y", "xxx",'y', lentille, 'x', Blocks.obsidian); GameRegistry.addRecipe(new ItemStack(mecanism, 1), "xxx", " yx", " xx", 'x', Blocks.obsidian, 'y', Blocks.redstone_block); GameRegistry.addRecipe(new ItemStack(Sniper, 1), " x ", "ymc", " oo", 'x', lunette, 'y', cannon, 'm', mecanism, 'c', crosse, 'o', Blocks.obsidian); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), " ", "x ", "x ", 'x', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), " ", " x ", " x ", 'x', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), " ", " x", " x", 'x', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), "x ", "x ", " ", 'x', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), " x ", " x ", " ", 'x', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaRod, 1), " x", " x", " ", 'x', LavaCrystal); /** EMERALDS **/ /** Sword Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldSword, 1), " y ", " y ", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldSword, 1), "y ", "y ", "x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldSword, 1), " y", " y", " x", 'x',Items.stick ,'y', Items.emerald); /** Pickaxe Craft**/ GameRegistry.addRecipe(new ItemStack(EmeraldPick, 1), "yyy", " x ", " x ", 'x',Items.stick ,'y', Items.emerald); /** Axe Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldAxe, 1), "yy ", "yx ", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldAxe, 1), " yy", " yx", " x", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldAxe, 1), " yy", " xy", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldAxe, 1), "yy ", "xy ", "x ", 'x',Items.stick ,'y', Items.emerald); /** Shovel Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldShovel, 1), "y ", "x ", "x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldShovel, 1), " y ", " x ", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldShovel, 1), " y", " x", " x", 'x',Items.stick ,'y', Items.emerald); /** Hoe Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldHoe, 1), "yy ", " x ", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldHoe, 1), " yy", " x", " x", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldHoe, 1), " yy", " y", " x ", 'x',Items.stick ,'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldHoe, 1), "yy ", "x ", "x ", 'x',Items.stick ,'y', Items.emerald); /** Helmet Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldHelmet, 1), "yyy", "y y", " ", 'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldHelmet, 1), " ", "yyy", "y y", 'y', Items.emerald); /** Chestplate Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldChest, 1), "y y", "yyy", "yyy", 'y', Items.emerald); /** Leggings Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldLeggings, 1), "yyy", "y y", "y y", 'y', Items.emerald); /** Boots Craft **/ GameRegistry.addRecipe(new ItemStack(EmeraldBoots, 1), "y y", "y y", " ", 'y', Items.emerald); GameRegistry.addRecipe(new ItemStack(EmeraldBoots, 1), " ", "y y", "y y", 'y', Items.emerald); /** SAPPHIRE **/ /** Sword Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), " y ", " y ", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), "y ", "y ", "x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireSword, 1), " y", " y", " x", 'x',Items.stick ,'y', Sapphire); /** Pickaxe Craft**/ GameRegistry.addRecipe(new ItemStack(SapphirePick, 1), "yyy", " x ", " x ", 'x',Items.stick ,'y', Sapphire); /** Axe Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), "yy ", "yx ", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), " yy", " yx", " x", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), " yy", " xy", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireAxe, 1), "yy ", "xy ", "x ", 'x',Items.stick ,'y', Sapphire); /** Shovel Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), "y ", "x ", "x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), " y ", " x ", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireShovel, 1), " y", " x", " x", 'x',Items.stick ,'y', Sapphire); /** Hoe Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), "yy ", " x ", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), " yy", " x", " x", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), " yy", " y", " x ", 'x',Items.stick ,'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireHoe, 1), "yy ", "x ", "x ", 'x',Items.stick ,'y', Sapphire); /** Helmet Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireHelmet, 1), "yyy", "y y", " ", 'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireHelmet, 1), " ", "yyy", "y y", 'y', Sapphire); /** Chestplate Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireChest, 1), "y y", "yyy", "yyy", 'y', Sapphire); /** Leggings Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireLeggings, 1), "yyy", "y y", "y y", 'y', Sapphire); /** Boots Craft **/ GameRegistry.addRecipe(new ItemStack(SapphireBoots, 1), "y y", "y y", " ", 'y', Sapphire); GameRegistry.addRecipe(new ItemStack(SapphireBoots, 1), " ", "y y", "y y", 'y', Sapphire); /** Lava Craft **/ /** Sword Craft **/ GameRegistry.addRecipe(new ItemStack(LavaSword, 1), " y ", " y ", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaSword, 1), "y ", "y ", "x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaSword, 1), " y", " y", " x", 'x',Items.blaze_rod ,'y', LavaCrystal); /** Pickaxe Craft**/ GameRegistry.addRecipe(new ItemStack(LavaPick, 1), "yyy", " x ", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); /** Axe Craft **/ GameRegistry.addRecipe(new ItemStack(LavaAxe, 1), "yy ", "yx ", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaAxe, 1), " yy", " yx", " x", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaAxe, 1), " yy", " xy", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaAxe, 1), "yy ", "xy ", "x ", 'x',Items.blaze_rod ,'y', LavaCrystal); /** Shovel Craft **/ GameRegistry.addRecipe(new ItemStack(LavaShovel, 1), "y ", "x ", "x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaShovel, 1), " y ", " x ", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaShovel, 1), " y", " x", " x", 'x',Items.blaze_rod ,'y', LavaCrystal); /** Hoe Craft **/ GameRegistry.addRecipe(new ItemStack(LavaHoe, 1), "yy ", " x ", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaHoe, 1), " yy", " x", " x", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaHoe, 1), " yy", " y", " x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(LavaHoe, 1), "yy ", "x ", "x ", 'x',Items.blaze_rod ,'y', LavaCrystal); GameRegistry.addRecipe(new ItemStack(Blocks.mob_spawner, 1, 1), "xxx", "xxx", "xxx", 'x',Items.blaze_rod ,'y', LavaCrystal); } }
-
4 essais pour avoir le bon résultat !
Les balises c’est pas encore ça x)
Tu n’as jamais utilisé de forum auparavant ?Le problème vient du fait que ton gui handler n’est pas enregistré.
-
ok merci
PS: pour les balises je n’ai jamais passé de code sur le forum alors je ne savait pas comment les utiliser et je suis nouveau (et un peu débile) x)