Créer un bloc type four (machine)
-
comment on fait pour afficher une gui simple sans utiliser de tile et le register?
-
1er Super Tuto Presque tout fonctionne de mon coter sauf cette méthode
@Override
public int getSizeInventory() { //Tout est dans le nom, retourne la taille de l’inventaire, pour notre bloc c’est quatre
return this.contents.length;
}@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; } } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { if (this.contents[slotIndex] != null) { ItemStack itemstack = this.contents[slotIndex]; this.contents[slotIndex] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int slotIndex, ItemStack stack) { this.contents[slotIndex] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getInventoryName() { //J'ai décider qu'on ne pouvait pas mettre de nom custom return "tile.machineTuto"; } @Override public boolean hasCustomInventoryName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return slot == 3 ? false : true; } public boolean isBurning() { return this.workingTime > 0; }
car les @Override ne marche pas (Method does not override method from its superclass) pourrais tu aider stp ?
-
Bonsoir,
Tu as bien implémenté l’interface IInventory ?
-
Ce message a été supprimé ! -
Merci de ton aide ! je ne l avais pas mis mais j ai un autre problème,j aimerais que ma flèche avance de gauche a droite pourrais tu m aider stp ?
-
@robin4002 J’ai un problème lors du clic droit. J’ai un freeze puis un Crash Reports
---- Minecraft Crash Report ---- // You should try our sister game, Minceraft! Time: 19/11/19 19:39 Description: Ticking player java.lang.NullPointerException: Ticking player at fr.astfaster.crystalia.tileentity.TileEntityCrystalMachine.isUseableByPlayer(TileEntityCrystalMachine.java:142) at fr.astfaster.crystalia.container.ContainerCrystalMachine.canInteractWith(ContainerCrystalMachine.java:27) at net.minecraftforge.event.entity.player.PlayerOpenContainerEvent.<init>(PlayerOpenContainerEvent.java:27) at net.minecraftforge.common.ForgeHooks.canInteractWith(ForgeHooks.java:437) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:329) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111) 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 fr.astfaster.crystalia.tileentity.TileEntityCrystalMachine.isUseableByPlayer(TileEntityCrystalMachine.java:142) at fr.astfaster.crystalia.container.ContainerCrystalMachine.canInteractWith(ContainerCrystalMachine.java:27) at net.minecraftforge.event.entity.player.PlayerOpenContainerEvent.<init>(PlayerOpenContainerEvent.java:27) at net.minecraftforge.common.ForgeHooks.canInteractWith(ForgeHooks.java:437) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:329) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 354 Entity Name: AstFaster Entity's Exact location: -62,55, 79,38, 39,09 Entity's Block location: World: (-63,79,39), Chunk: (at 1,4,7 in -4,2; contains blocks -64,0,32 to -49,255,47), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0,00, 0,00, 0,00 Stacktrace: at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@28113a5b 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 10 (amd64) version 10.0 Java Version: 1.8.0_211, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 785802264 bytes (749 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: 13, tallocated: 95 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 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.1558-1.7.10.jar) UCHIJAAAA Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCHIJAAAA crystalia{1.0} [Crystalia] (forge-1.7.10-10.13.4.1558-1.7.10-src.main) 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['AstFaster'/354, l='New World', x=-62,55, y=79,38, z=39,09]] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge'
Peux-tu m’aider ?
-
Pourquoi me mentionner ? Ce n’est même pas moi qui ai écrit ce tutoriel.
-
Mais parce que toi tu te co svt
-
Bonjours, je vien ici pour vous demander comment faire pour réduire ou augmenter le temps que mets ma machine à donné l’item, car j’ai cherché mais je ne trouve rien.
Merci d’avance de votre aide.
-
@RotorTV Il faut jouer avec la valeur contenue dans la variable
workingTimeNeeded
dans la classe de laTileEntity
. Tu n’aura pas plus d’informations, le support de la version 1.7.10 n’étant plus d’actualité sur ce forum. -
Le probleme c est que modifier cette valeur ne fait rien ca mets toujours autant de temps a cuire un item
-
Ce message a été supprimé ! -
Bonjour , excellent tuto mais évidemment puisque je poste un commentaire : j’ai un problème étant donné que mon four n’est composé que de 2 slots d’input et 1 slot d’output j’ai du bidouiller un peu le code pour faire quelque chose et quand je met deux items dans les 2 slots d’input et bien…mon jeu crash :
Description: Ticking block entity java.lang.ArrayIndexOutOfBoundsException: 2 at raven.tacoscraft.recipes.RecipesCustomFurnace.isSameKey(RecipesCustomFurnace.java:67) at raven.tacoscraft.recipes.RecipesCustomFurnace.getSmeltingResult(RecipesCustomFurnace.java:57) at raven.tacoscraft.tileentity.TileEntityFactoriteForge.canSmelt(TileEntityFactoriteForge.java:228) at raven.tacoscraft.tileentity.TileEntityFactoriteForge.updateEntity(TileEntityFactoriteForge.java:203) at net.minecraft.world.World.updateEntities(World.java:2160) at net.minecraft.client.Minecraft.runTick(Minecraft.java:2097) 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(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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
Voici le crash-report et voici les classes des erreurs en question
La Classe des Recettes :package raven.tacoscraft.recipes; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; import net.minecraft.block.Block; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import raven.tacoscraft.Factoria; public class RecipesCustomFurnace { private static final RecipesCustomFurnace smeltingBase = new RecipesCustomFurnace(); private Map smeltingList = new HashMap(); public RecipesCustomFurnace() { this.addRecipe(Factoria.itemFactoriteIngot, Factoria.itemTinIngot, new ItemStack(Factoria.itemFactoriteTinIngot)); this.addRecipe(Factoria.itemFactoriteIngot, Items.diamond, new ItemStack(Factoria.itemFactoriteDiamondIngot)); this.addRecipe(Factoria.itemFactoriteIngot, Factoria.itemVoltitePowder, new ItemStack(Factoria.itemFactoriteVoltiteIngot)); } public void addRecipe(ItemStack stack1, ItemStack stack2, ItemStack stack3) { ItemStack[] stackList = new ItemStack[]{stack1, stack2, stack3}; this.smeltingList.put(stackList, stack3); } public void addRecipe(Item item1, Item item2, ItemStack stack) { this.addRecipe(new ItemStack(item1), new ItemStack(item2), stack); } public void addRecipe(Block block1, Item item2, ItemStack stack) { this.addRecipe(Item.getItemFromBlock(block1), item2, stack); } public ItemStack getSmeltingResult(ItemStack[] stack) { Iterator iterator = this.smeltingList.entrySet().iterator(); Entry entry; do { if (!iterator.hasNext()) { return null; } entry = (Entry)iterator.next(); } while (!this.isSameKey(stack, (ItemStack[])entry.getKey())); return (ItemStack)entry.getValue(); } private boolean isSameKey(ItemStack[] stackList, ItemStack[] stackList2) { boolean isSame = false; for(int i=0; i<=2; i++) { if(stackList[i].getItem() == stackList2[i].getItem()) { isSame = true; } else { return false; } } return isSame; } public Map getSmeltingList() { return this.smeltingList; } public static RecipesCustomFurnace smelting() { return smeltingBase; } }
La fonction CanSmelt et Updateentity de la classe TileEntity :
public void updateEntity() { if(this.isBurning() && this.canSmelt()) { ++this.workingTime; } if(this.canSmelt() && !this.isBurning()) { this.workingTime = 1; } if(this.canSmelt() && this.workingTime == this.workingTimeNeeded) { this.smeltItem(); this.workingTime = 0; } if(!this.canSmelt()) { this.workingTime= 0; } } private boolean canSmelt() { if (this.contents[0] == null || this.contents[3] == null) { return false; } else { ItemStack itemstack = RecipesCustomFurnace.smelting().getSmeltingResult(new ItemStack[]{this.contents[0], this.contents[3]}); if (this.contents[2] == null) return true; if (!this.contents[2].isItemEqual(itemstack)) return false; int result = contents[2].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.contents[2].getMaxStackSize(); } }
Ah et mon premier slot d’input est [0] et le deuxième est [3]
Merci d’avance !
-
@Raven a dit dans Créer un bloc type four (machine) :
java.lang.ArrayIndexOutOfBoundsException: 2
Renseignes toi sur cette erreur, et tu sauras la corriger
-
Ce message a été supprimé ! -
Ce message a été supprimé ! -
Ce message a été supprimé ! -
Bonjour,
Cela fonctionne-t-il en version 1.12.2 ? -
@Aiko voici le turoriel pour la 1.12.2 (par Brokenswing de plus) https://www.minecraftforgefrance.fr/topic/4114/1-12-créer-un-four
-
Bonjour j’ai un problème lorsque le block est posé en jeu, un click droit dessus ne fais absolument rien quel est le problème. Est ce que quelqu’un aurais discord pour simplifier la communication^^