Création d'un Chest Detector
-
Non, la classe Item est une classe déjà existante qui se trouve dans le package net.minecraft.item, tu devrais avoir :
public class ItemTileEntityFinder extends Item { @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) { if(held) { List <tileentity>tiles = world.loadedTileEntityList; ArrayList <tileentity>tilesNear = new ArrayList<tileentity>(); ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair(); for(TileEntity tile : tiles) { ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair(); if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 && tileChunk.chunkXPos <= entity.chunkCoordX + 2 && tileChunk.chunkZPos >= entity.chunkCoordZ - 2 && tileChunk.chunkZPos <= entity.chunkCoordZ + 2) { tilesNear.add(tile); } } } } }Et :
public static Item tileEntityFinder; @EventHandler public void preInit(FMLPreInitialization event) { tileEntityFinder= new ItemTileEntityFinder().setUnlocalizedName("tileEntityFinder"); GameRegistry.registerItem(tileEntityFinder, "tileEntityFinder"); } ```</tileentity></tileentity></tileentity> -
C’est bon j’ai compris mais quand j’ai essayer de mettre ton code dans eclipse ça à crash.
-
Envoie-nous le rapport de crash
-
Ce que tu dois faire, c’est une nouvelle classe ItemTileEntityFinder qui est une classe fille de Item (dont il faut mettre extends Item).
Et ensuite ici :
chest_detector = new Item().setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName(“chest_detector”).setTextureName(Reference.MOD_ID + “:chest_detector”);
il faut remplacer par :
chest_detector = new ItemTileEntityFinder().setCreativeTab(CreativeTabs.tabMisc).setUnlocalizedName(“chest_detector”).setTextureName(Reference.MOD_ID + “:chest_detector”);Un peu de lecture : https://www.minecraftforgefrance.fr/showthread.php?tid=2766
-
Ok
[14:14:26] [main/INFO] [GradleStart]: Extra: [] [14:14:26] [main/INFO] [GradleStart]: Running with arguments: [–userProperties, {}, --assetsDir, C:/Users/user/.gradle/caches/minecraft/assets, --assetIndex, 1.7.10, --accessToken, {REDACTED}, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker] [14:14:26] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [14:14:26] [main/INFO] [FML]: Forge Mod Loader version 7.99.36.1558 for Minecraft 1.7.10 loading [14:14:26] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_112, running on Windows 7:amd64:6.1, installed at D:\Java [14:14:26] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [14:14:26] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin [14:14:26] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [14:14:26] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [14:14:26] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [14:14:26] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [14:14:26] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [14:14:27] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [14:14:27] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker [14:14:27] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker [14:14:27] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [14:14:27] [main/INFO]: Setting user: Player621 [14:14:28] [Client thread/INFO]: LWJGL Version: 2.9.1 [14:14:28] [Client thread/INFO] [STDOUT]: [tv.twitch.StandardCoreAPI:<init>:16]: If on Windows, make sure to provide all of the necessary dll's as specified in the twitchsdk README. Also, make sure to set the PATH environment variable to point to the directory containing the dll's. [14:14:28] [Client thread/ERROR]: Couldn't initialize twitch stream [14:14:28] [Client thread/INFO] [STDOUT]: [cpw.mods.fml.client.SplashProgress:start:188]: –-- Minecraft Crash Report ---- // Don't do that. Time: 28/10/16 14:14 Description: Loading screen debug info This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_112, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 772277328 bytes (736 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: 0, tallocated: 0 FML: GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.4.0 NVIDIA 344.65' Renderer: 'GeForce GTX 750 Ti/PCIe/SSE2' [14:14:28] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [14:14:28] [Client thread/INFO] [FML]: MinecraftForge v10.13.4.1558 Initialized [14:14:28] [Client thread/INFO] [FML]: Replaced 183 ore recipies [14:14:28] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [14:14:29] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer [14:14:29] [Client thread/INFO] [FML]: Searching D:\Forge 1.7.2\forge-1.7.10-10.13.4.1558-1.7.10-src\eclipse\mods for mods [14:14:32] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [14:14:32] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, Erderion] at CLIENT [14:14:32] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, Erderion] at SERVER [14:14:33] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Erderion [14:14:33] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [14:14:33] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations [14:14:33] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations [14:14:33] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations [14:14:33] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [14:14:33] [Client thread/INFO] [FML]: Applying holder lookups [14:14:33] [Client thread/INFO] [FML]: Holder lookups applied [14:14:33] [Client thread/INFO] [FML]: Injecting itemstacks [14:14:33] [Client thread/INFO] [FML]: Itemstack injection complete [14:14:33] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [14:14:33] [Client thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCH Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCE Erderion{0.1} [Erderion] (bin) [14:14:33] [Client thread/ERROR] [FML]: The following problems were captured during this phase [14:14:33] [Client thread/ERROR] [FML]: Caught exception from Erderion java.lang.Error: Unresolved compilation problems: itemMod cannot be resolved itemMod cannot be resolved at ErderionPackage.Erderion.preInit(Erderion.java:25) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_112] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_112] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_112] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:942) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_112] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_112] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] [14:14:33] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // You're mean. Time: 28/10/16 14:14 Description: There was a severe problem during mod loading that has caused the game to fail cpw.mods.fml.common.LoaderException: java.lang.Error: Unresolved compilation problems: itemMod cannot be resolved itemMod cannot be resolved at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:559) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) 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) Caused by: java.lang.Error: Unresolved compilation problems: itemMod cannot be resolved itemMod cannot be resolved at ErderionPackage.Erderion.preInit(Erderion.java:25) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) ... 12 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_112, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 811501360 bytes (773 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: 0, tallocated: 0 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 UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCH Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar) UCE Erderion{0.1} [Erderion] (bin) GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.4.0 NVIDIA 344.65' Renderer: 'GeForce GTX 750 Ti/PCIe/SSE2' [14:14:33] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# D:\Forge 1.7.2\forge-1.7.10-10.13.4.1558-1.7.10-src\eclipse\.\crash-reports\crash-2016-10-28_14.14.33-client.txt Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release ```</init> -
Les balises code seraient + appropriées, je pense.
-
Mettre les balises et pas TOUT les logs seraient plus approprié

-
C quoi les balises?
-
[java] Pour le code java
Pour le code ** Pour mettre en gras * Pour mettre en italique * Pour souligner etc ... Et après il faut fermer les balises en les réécrivant de la même façon mais avec un slash devant le nom de la balises, par exemple pour les listes c'est -
Quelle patience BrokenSwing, c’est incroyable, je trouve !
-
J’ai modifié le message.
Tu as visiblement des erreurs dans ton code, normalement eclipse te les indiques. -
J’ai finalement régler les erreurs (c’était tout bête, j’avais juste oublier de faire tout les imports) mais maintenant quand je lance minecraft le jeu fait comme si l’item n’existait pas.
-
Tu l’as ajouté dans un onglet créatif ? Au pire essai de te le give, il doit s’appeler tonModID:sonNom
-
Il n’existe même pas dans le /give.
-
Envoie ta classe principale + la classe de ton objet dans des balises java
-
package ErderionPackage.init; import java.util.ArrayList; import java.util.List; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.entity.Entity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; public class ItemTileEntityFinder extends Item { public static Item tileEntityFinder; @EventHandler public void preInit(FMLPreInitializationEvent event) { tileEntityFinder= new ItemTileEntityFinder() .setUnlocalizedName("chest_detector"); GameRegistry.registerItem(tileEntityFinder, "tileEntityFinder"); } @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) { if(held) { List <tileentity>tiles = world.loadedTileEntityList; ArrayList <tileentity>tilesNear = new ArrayList<tileentity>(); ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair(); for(TileEntity tile : tiles) { ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair(); if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 && tileChunk.chunkXPos <= entity.chunkCoordX + 2 && tileChunk.chunkZPos >= entity.chunkCoordZ - 2 && tileChunk.chunkZPos <= entity.chunkCoordZ + 2) { tilesNear.add(tile); } } } } public static void init() { // TODO Auto-generated method stub } public static void register() { // TODO Auto-generated method stub } }La classe de mon item
package ErderionPackage; import ErderionPackage.Proxy.CommonProxy; import ErderionPackage.init.BlockMod; import ErderionPackage.init.ItemTileEntityFinder; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; 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; @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class Erderion { @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { BlockMod.init(); BlockMod.register(); ItemTileEntityFinder.init(); ItemTileEntityFinder.register(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }La classe principale de mon mod</tileentity></tileentity></tileentity>
-
Aïe aïe aïe ….
public class ItemTileEntityFinder extends Item { @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) { if(held) { List <tileentity>tiles = world.loadedTileEntityList; ArrayList <tileentity>tilesNear = new ArrayList<tileentity>(); ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair(); for(TileEntity tile : tiles) { ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair(); if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 && tileChunk.chunkXPos <= entity.chunkCoordX + 2 && tileChunk.chunkZPos >= entity.chunkCoordZ - 2 && tileChunk.chunkZPos <= entity.chunkCoordZ + 2) { tilesNear.add(tile); } } } } }@Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION) public class Erderion { @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; @Instance public static Erderion instance; @EventHandler public void preInit(FMLPreInitializationEvent event) { BlockMod.init(); BlockMod.register(); // A placer dans BlockMod.init() // tileEntityFinder= new ItemTileEntityFinder() .setUnlocalizedName("chest_detector"); // A placer dans BlockMod.register() // GameRegistry.registerItem(tileEntityFinder, "tileEntityFinder"); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenders(); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } ```</tileentity></tileentity></tileentity> -
Le BlockMod marche, c’est le TileEntityFinder qui ne marche pas.
-
Ah ok, j’ai compris comment tu procédais, c’est
pas forcément la meilleur des manièresc’est pas propre du tout, mais admettons :
Tu aurais donc :public class ItemTileEntityFinder extends Item { public static Item tileEntityFinder; @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean held) { if(held) { List <tileentity>tiles = world.loadedTileEntityList; ArrayList <tileentity>tilesNear = new ArrayList<tileentity>(); ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair(); for(TileEntity tile : tiles) { ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair(); if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 && tileChunk.chunkXPos <= entity.chunkCoordX + 2 && tileChunk.chunkZPos >= entity.chunkCoordZ - 2 && tileChunk.chunkZPos <= entity.chunkCoordZ + 2) { tilesNear.add(tile); } } } } public static void init() { tileEntityFinder= new ItemTileEntityFinder() .setUnlocalizedName("chest_detector"); } public static void register() { GameRegistry.registerItem(tileEntityFinder, "tileEntityFinder"); } }Et pour ta classe principale, garde la première que tu m’as envoyée</tileentity></tileentity></tileentity>
-
Maintenant, le Chest Detector est réapparu mais il ne marche pas, c’est juste un item inutile.