MFF

    Minecraft Forge France
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes
    • Forge Events
      • Automatique
      • Foncé
      • Clair
    • S'inscrire
    • Se connecter

    Elevator

    Planifier Épinglé Verrouillé Déplacé Résolu 1.7.x
    1.7.10
    36 Messages 5 Publieurs 7.9k Vues 1 Watching
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • X Hors-ligne
      XDoctorX
      dernière édition par

      comment je fait si jai mit la boucle dans une class externe ?

      1 réponse Dernière réponse Répondre Citer 0
      • AlgorythmisA Hors-ligne
        Algorythmis
        dernière édition par

        @‘XDoctorX’:

        comment je fait si jai mit la boucle dans une class externe ?

        Tu apprends le Java…

        public static int[] getTargetBlock(World w, int x, int y, int z, boolean mode) {
           int i;
           int[] v = {x, y, z};
           if (mode) // Si "mode" est true, on veut monter
               for (i = y; i <= 255; i++)
                   if (w.getBlock(x, i, z) == ModElevator.block_elevator)
                       v[1] = i;
           else // Si "mode" est false, on veut descendre
               for (i = y; i >= 0; i–)
                   if (w.getBlock(x, i, z) == ModElevator.block_elevator)
                       v[1] = i;
           return v;
        }
        
        int[] positionBlocCible = ClasseExterne.getTargetBlock(monde, posX, posY, posZ, mode);
        

        Mes mods :

        • Cookie Ore (1.7.10)

        Mod en cours : **E…

        1 réponse Dernière réponse Répondre Citer 0
        • X Hors-ligne
          XDoctorX
          dernière édition par

          j’ai un crash :

          –-- Minecraft Crash Report ----
          // This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]
          
          Time: 28/07/15 14:04
          Description: Ticking entity
          
          java.lang.NullPointerException: Ticking entity
          at com.XDoctorX.main.ElevatorEvent.onLivingJumpEvent(ElevatorEvent.java:27)
          at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_ElevatorEvent_onLivingJumpEvent_LivingJumpEvent.invoke(.dynamic)
          at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
          at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
          at net.minecraftforge.common.ForgeHooks.onLivingJump(ForgeHooks.java:351)
          at net.minecraft.entity.EntityLivingBase.jump(EntityLivingBase.java:1572)
          at net.minecraft.entity.player.EntityPlayer.jump(EntityPlayer.java:1829)
          at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2004)
          at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:612)
          at net.minecraft.client.entity.EntityPlayerSP.onLivingUpdate(EntityPlayerSP.java:299)
          at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816)
          at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327)
          at net.minecraft.client.entity.EntityClientPlayerMP.onUpdate(EntityClientPlayerMP.java:96)
          at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298)
          at net.minecraft.world.World.updateEntity(World.java:2258)
          at net.minecraft.world.World.updateEntities(World.java:2108)
          at net.minecraft.client.Minecraft.runTick(Minecraft.java:2086)
          at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028)
          at net.minecraft.client.Minecraft.run(Minecraft.java:951)
          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:483)
          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 com.XDoctorX.main.ElevatorEvent.onLivingJumpEvent(ElevatorEvent.java:27)
          at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_ElevatorEvent_onLivingJumpEvent_LivingJumpEvent.invoke(.dynamic)
          at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
          at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
          at net.minecraftforge.common.ForgeHooks.onLivingJump(ForgeHooks.java:351)
          at net.minecraft.entity.EntityLivingBase.jump(EntityLivingBase.java:1572)
          at net.minecraft.entity.player.EntityPlayer.jump(EntityPlayer.java:1829)
          at net.minecraft.entity.EntityLivingBase.onLivingUpdate(EntityLivingBase.java:2004)
          at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:612)
          at net.minecraft.client.entity.EntityPlayerSP.onLivingUpdate(EntityPlayerSP.java:299)
          at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816)
          at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327)
          at net.minecraft.client.entity.EntityClientPlayerMP.onUpdate(EntityClientPlayerMP.java:96)
          at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298)
          at net.minecraft.world.World.updateEntity(World.java:2258)
          
          -- Entity being ticked --
          Details:
          Entity Type: null (net.minecraft.client.entity.EntityClientPlayerMP)
          Entity ID: 163
          Entity Name: Player312
          Entity's Exact location: -427,57, 6,62, 401,52
          Entity's Block location: World: (-428,6,401), Chunk: (at 4,0,1 in -27,25; contains blocks -432,0,400 to -417,255,415), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
          Entity's Momentum: 0,00, 0,42, 0,00
          Stacktrace:
          at net.minecraft.world.World.updateEntities(World.java:2108)
          
          -- Affected level --
          Details:
          Level name: MpServer
          All players: 1 total; [EntityClientPlayerMP['Player312'/163, l='MpServer', x=-427,57, y=6,62, z=401,52]]
          Chunk stats: MultiplayerChunkCache: 289, 289
          Level seed: 0
          Level generator: ID 01 - flat, ver 0\. Features enabled: false
          Level generator options:
          Level spawn location: World: (-418,4,400), Chunk: (at 14,0,0 in -27,25; contains blocks -432,0,400 to -417,255,415), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
          Level time: 7035 game time, 7035 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: 89 total; [EntitySheep['Sheep'/134, l='MpServer', x=-366,09, y=4,00, z=323,84], EntitySheep['Sheep'/135, l='MpServer', x=-364,97, y=4,00, z=343,97], EntitySheep['Sheep'/136, l='MpServer', x=-365,06, y=4,00, z=339,03], EntitySheep['Sheep'/137, l='MpServer', x=-361,31, y=4,00, z=353,31], EntitySheep['Sheep'/138, l='MpServer', x=-348,84, y=4,00, z=326,88], EntityPig['Pig'/21, l='MpServer', x=-489,03, y=4,00, z=351,94], EntitySheep['Sheep'/23, l='MpServer', x=-507,50, y=4,00, z=407,41], EntitySheep['Sheep'/24, l='MpServer', x=-504,88, y=4,00, z=403,84], EntityChicken['Chicken'/25, l='MpServer', x=-506,47, y=4,00, z=425,47], EntityChicken['Chicken'/28, l='MpServer', x=-496,47, y=4,00, z=439,47], EntityPig['Pig'/29, l='MpServer', x=-499,25, y=4,00, z=437,88], EntitySheep['Sheep'/30, l='MpServer', x=-499,25, y=4,00, z=450,34], EntityPig['Pig'/31, l='MpServer', x=-491,09, y=4,00, z=365,97], EntityHorse['Horse'/32, l='MpServer', x=-483,47, y=4,00, z=377,25], EntityCow['Cow'/33, l='MpServer', x=-480,59, y=4,00, z=381,75], EntityPig['Pig'/34, l='MpServer', x=-486,38, y=4,00, z=376,19], EntityHorse['Horse'/35, l='MpServer', x=-491,09, y=4,00, z=384,41], EntityPig['Pig'/36, l='MpServer', x=-484,59, y=4,00, z=388,84], EntityHorse['Horse'/37, l='MpServer', x=-481,44, y=4,00, z=388,25], EntitySheep['Sheep'/38, l='MpServer', x=-486,84, y=4,00, z=396,19], EntityCow['Cow'/39, l='MpServer', x=-484,75, y=4,00, z=384,31], EntitySheep['Sheep'/40, l='MpServer', x=-492,66, y=4,00, z=418,72], EntityChicken['Chicken'/41, l='MpServer', x=-487,56, y=4,00, z=421,56], EntityPig['Pig'/42, l='MpServer', x=-493,13, y=4,00, z=424,16], EntityCow['Cow'/43, l='MpServer', x=-490,72, y=4,00, z=456,72], EntityChicken['Chicken'/44, l='MpServer', x=-481,41, y=4,00, z=452,63], EntityChicken['Chicken'/45, l='MpServer', x=-490,47, y=4,00, z=471,53], EntityChicken['Chicken'/46, l='MpServer', x=-475,56, y=4,00, z=479,47], EntityChicken['Chicken'/48, l='MpServer', x=-485,97, y=4,00, z=481,47], EntityCow['Cow'/49, l='MpServer', x=-473,16, y=4,00, z=372,03], EntityCow['Cow'/50, l='MpServer', x=-473,56, y=4,00, z=384,69], EntityCow['Cow'/51, l='MpServer', x=-470,43, y=4,00, z=372,55], EntityHorse['Horse'/52, l='MpServer', x=-476,06, y=4,00, z=372,75], EntityHorse['Horse'/53, l='MpServer', x=-472,06, y=4,00, z=380,19], EntityHorse['Horse'/54, l='MpServer', x=-466,37, y=4,00, z=381,13], EntityHorse['Horse'/55, l='MpServer', x=-473,03, y=4,00, z=369,34], EntityCow['Cow'/56, l='MpServer', x=-466,88, y=4,00, z=370,91], EntityHorse['Horse'/57, l='MpServer', x=-470,88, y=4,00, z=375,25], EntityPig['Pig'/58, l='MpServer', x=-477,78, y=4,00, z=408,63], EntityPig['Pig'/59, l='MpServer', x=-464,97, y=4,00, z=402,88], EntityChicken['Chicken'/60, l='MpServer', x=-468,59, y=4,00, z=413,41], EntitySheep['Sheep'/61, l='MpServer', x=-468,59, y=4,00, z=414,53], EntitySheep['Sheep'/62, l='MpServer', x=-474,91, y=4,00, z=417,06], EntityChicken['Chicken'/63, l='MpServer', x=-473,56, y=4,00, z=438,63], EntityChicken['Chicken'/64, l='MpServer', x=-464,47, y=4,00, z=457,09], EntityCow['Cow'/65, l='MpServer', x=-471,06, y=4,00, z=455,97], EntityPig['Pig'/66, l='MpServer', x=-467,91, y=4,00, z=457,13], EntityPig['Pig'/67, l='MpServer', x=-468,97, y=4,00, z=453,88], EntityClientPlayerMP['Player312'/163, l='MpServer', x=-427,57, y=6,62, z=401,52], EntityChicken['Chicken'/68, l='MpServer', x=-470,47, y=4,00, z=473,56], EntityChicken['Chicken'/69, l='MpServer', x=-485,44, y=4,00, z=483,47], EntityCow['Cow'/71, l='MpServer', x=-462,06, y=4,00, z=392,03], EntityChicken['Chicken'/72, l='MpServer', x=-452,22, y=4,00, z=394,19], EntityChicken['Chicken'/73, l='MpServer', x=-453,81, y=4,00, z=431,97], EntityChicken['Chicken'/74, l='MpServer', x=-458,53, y=4,00, z=418,47], EntityChicken['Chicken'/75, l='MpServer', x=-455,53, y=4,00, z=427,59], EntityPig['Pig'/76, l='MpServer', x=-460,34, y=4,00, z=446,22], EntityPig['Pig'/77, l='MpServer', x=-448,91, y=4,00, z=457,69], EntityCow['Cow'/78, l='MpServer', x=-463,09, y=4,00, z=476,88], EntityPig['Pig'/79, l='MpServer', x=-453,31, y=4,00, z=478,88], EntitySheep['Sheep'/83, l='MpServer', x=-445,69, y=4,00, z=423,16], EntitySheep['Sheep'/84, l='MpServer', x=-449,25, y=4,00, z=445,78], EntityChicken['Chicken'/85, l='MpServer', x=-434,63, y=4,00, z=444,59], EntityPig['Pig'/86, l='MpServer', x=-445,03, y=4,00, z=446,97], EntityPig['Pig'/87, l='MpServer', x=-440,25, y=4,00, z=449,56], EntitySheep['Sheep'/93, l='MpServer', x=-426,78, y=4,00, z=326,94], EntitySheep['Sheep'/94, l='MpServer', x=-436,76, y=4,00, z=323,69], EntityPig['Pig'/95, l='MpServer', x=-418,19, y=4,00, z=445,09], EntityPig['Pig'/96, l='MpServer', x=-422,06, y=4,00, z=435,91], EntityPig['Pig'/97, l='MpServer', x=-431,03, y=4,00, z=439,16], EntityPig['Pig'/98, l='MpServer', x=-418,19, y=4,00, z=450,56], EntityPig['Pig'/99, l='MpServer', x=-423,06, y=4,00, z=468,03], EntityPig['Pig'/101, l='MpServer', x=-407,97, y=4,00, z=433,13], EntityPig['Pig'/102, l='MpServer', x=-409,38, y=4,00, z=462,44], EntityPig['Pig'/103, l='MpServer', x=-415,84, y=4,00, z=453,84], EntityPig['Pig'/104, l='MpServer', x=-400,34, y=4,00, z=454,69], EntityPig['Pig'/105, l='MpServer', x=-402,78, y=4,00, z=473,75], EntityPig['Pig'/106, l='MpServer', x=-386,53, y=4,00, z=347,88], EntityPig['Pig'/107, l='MpServer', x=-396,84, y=4,00, z=366,22], EntitySheep['Sheep'/108, l='MpServer', x=-391,13, y=4,00, z=369,94], EntityPig['Pig'/109, l='MpServer', x=-399,16, y=4,00, z=454,25], EntitySheep['Sheep'/119, l='MpServer', x=-380,72, y=4,00, z=327,19], EntitySheep['Sheep'/120, l='MpServer', x=-373,34, y=4,00, z=332,78], EntitySheep['Sheep'/121, l='MpServer', x=-381,91, y=4,00, z=353,25], EntityPig['Pig'/122, l='MpServer', x=-370,59, y=4,00, z=365,81], EntityPig['Pig'/123, l='MpServer', x=-378,63, y=4,00, z=362,81], EntityPig['Pig'/124, l='MpServer', x=-380,22, y=4,00, z=366,19], EntityPig['Pig'/125, l='MpServer', x=-380,81, y=4,00, z=369,59], EntityPig['Pig'/126, l='MpServer', x=-382,44, y=4,00, z=370,09]]
          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:2555)
          at net.minecraft.client.Minecraft.run(Minecraft.java:973)
          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:483)
          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: Windows 7 (x86) version 6.1
          Java Version: 1.8.0_05, Oracle Corporation
          Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
          Memory: 885016616 bytes (844 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 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.85.1291 Minecraft Forge 10.13.2.1291 4 mods loaded, 4 mods active
          mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available
          FML{7.10.85.1291} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available
          Forge{10.13.2.1291} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1291.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available
          xdoctorx{1.0.0} [XDoctorX] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available->Available->Available
          Launched Version: 1.7.10
          LWJGL: 2.9.1
          OpenGL: GeForce GT 610/PCIe/SSE2 GL version 4.3.0, NVIDIA Corporation
          GL Caps: Using GL 1.3 multitexturing.
          Using framebuffer objects because OpenGL 3.0 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)
          

          La class principal :

          package com.XDoctorX.main;
          
          import ibxm.Player;
          
          import com.XDoctorX.block.*;
          import com.XDoctorX.block.tileentity.TileEntityMacerator;
          
          import cpw.mods.fml.common.network.NetworkRegistry;
          import net.minecraft.block.Block;
          import net.minecraft.block.material.Material;
          import net.minecraft.client.Minecraft;
          import net.minecraft.client.gui.GuiMainMenu;
          import net.minecraft.creativetab.CreativeTabs;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.item.Item;
          import net.minecraft.world.World;
          import net.minecraftforge.common.DimensionManager;
          import net.minecraftforge.common.MinecraftForge;
          import net.minecraftforge.common.util.ForgeDirection;
          import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
          import cpw.mods.fml.client.FMLClientHandler;
          import cpw.mods.fml.common.Mod;
          import cpw.mods.fml.common.Mod.EventHandler;
          import cpw.mods.fml.common.Mod.Instance;
          import cpw.mods.fml.common.SidedProxy;
          import cpw.mods.fml.common.event.FMLInitializationEvent;
          import cpw.mods.fml.common.event.FMLPostInitializationEvent;
          import cpw.mods.fml.common.event.FMLPreInitializationEvent;
          import cpw.mods.fml.common.eventhandler.SubscribeEvent;
          import cpw.mods.fml.common.gameevent.TickEvent;
          import cpw.mods.fml.common.registry.GameRegistry;
          import cpw.mods.fml.common.registry.LanguageRegistry;
          import cpw.mods.fml.relauncher.Side;
          import cpw.mods.fml.relauncher.SideOnly;
          
          @Mod(modid = "xdoctorx", name = "XDoctorX", version = "1.0.0")
          
          public class XDoctorX
          {
          @Instance("xdoctorx")
          public static XDoctorX instance;
          @SidedProxy(clientSide = "com.XDoctorX.main.ClientProxy", serverSide = "com.XDoctorX.main.CommonProxy")
          public static CommonProxy proxy;
          public static final String MODID = "xdoctorx";
          public GuiHandler guiHandler = new GuiHandler();
          public static Block Macerator;
          public static Block Elevator;
          
          @EventHandler
          public void preInit(FMLPreInitializationEvent event)
          {
          
          Macerator = new BlockMacerator(false).setHardness(3.5F).setBlockName("furnace").setCreativeTab(CreativeTabs.tabRedstone);
          Elevator = new BlockElevator().setBlockTextureName(MODID + ":elevator").setHardness(3.5F).setBlockName("Elevator").setCreativeTab(CreativeTabs.tabRedstone);
          
          GameRegistry.registerBlock(Macerator, "Macerator");
          GameRegistry.registerBlock(Elevator, "Elevator");
          
          //GameRegistry.registerTileEntity(TileEntityMacerator.class, "XDoctorX:MaceratorTileEntity");
          NetworkRegistry.INSTANCE.registerGuiHandler(instance, guiHandler);
          
          }
          @EventHandler
          public void init(FMLInitializationEvent event)
          {
          proxy.registerRender();
          MinecraftForge.EVENT_BUS.register(new ElevatorEvent());
          }
          
          @EventHandler
          public void postInit(FMLPostInitializationEvent event)
          {
          
          }
          
          @SubscribeEvent
             @SideOnly(Side.CLIENT)
             public void onTick(TickEvent.ClientTickEvent event)
             {
                 Minecraft mc = FMLClientHandler.instance().getClient();
                 if(mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiMainMenu.class))
                 {
                     mc.displayGuiScreen(new GuiCustomMainMenu());
                 }
          
             }
          
          }
          
          

          La class du block :

          package com.XDoctorX.block;
          
          import org.lwjgl.input.Keyboard;
          
          import com.XDoctorX.main.XDoctorX;
          
          import cpw.mods.fml.common.eventhandler.SubscribeEvent;
          import net.minecraft.block.Block;
          import net.minecraft.block.material.Material;
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.world.World;
          import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
          
          public class BlockElevator extends Block{
          public EntityPlayer player;
          public World world;
          
          public BlockElevator() {
          super(Material.circuits);
          }
          
          public static int[] getTargetBlock(World w, int x, int y, int z, boolean mode) {
            int i;
            int[] v = {x, y, z};
            if (mode) // Si "mode" est true, on veut monter
                for (i = y; i <= 255; i++)
                    if (w.getBlock(x, i, z) == XDoctorX.Elevator)
                        v[1] = i;
            else // Si "mode" est false, on veut descendre
                for (i = y; i >= 0; i–)
                    if (w.getBlock(x, i, z) == XDoctorX.Elevator)
                        v[1] = i;
            return v;
          }
          }
          
          

          La class du ElevatorEvent :

          package com.XDoctorX.main;
          
          import java.io.DataInput;
          import java.io.IOException;
          
          import net.minecraft.entity.player.EntityPlayer;
          import net.minecraft.world.World;
          import net.minecraftforge.common.util.ForgeDirection;
          import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
          
          import com.XDoctorX.block.BlockElevator;
          
          import cpw.mods.fml.common.eventhandler.SubscribeEvent;
          
          public class ElevatorEvent{
          
          public EntityPlayer player;
          public World world;
           public PlayerMovementEvent.Type type;
          
          @SubscribeEvent
          public void onLivingJumpEvent(LivingJumpEvent event)
          {
           if (event.entity instanceof EntityPlayer)
           {
           int[] positionBlocCible = BlockElevator.getTargetBlock(world, (int)player.posX, (int)player.posY, (int)player.posZ, true);
           }
          }
          
          }
          
          
          1 réponse Dernière réponse Répondre Citer 0
          • AlgorythmisA Hors-ligne
            Algorythmis
            dernière édition par

            @‘XDoctorX’:

            package com.XDoctorX.main;
            
            import java.io.DataInput;
            import java.io.IOException;
            import net.minecraft.entity.player.EntityPlayer;
            import net.minecraft.world.World;
            import net.minecraftforge.common.util.ForgeDirection;
            import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
            import com.XDoctorX.block.BlockElevator;
            import cpw.mods.fml.common.eventhandler.SubscribeEvent;
            
            public class ElevatorEvent {
               public EntityPlayer player;
               public World world;
               public PlayerMovementEvent.Type type;
            
               @SubscribeEvent
               public void onLivingJumpEvent(LivingJumpEvent event) {
                   if (event.entity instanceof EntityPlayer) {
                       int[] positionBlocCible = BlockElevator.getTargetBlock(world, (int)player.posX, (int)player.posY, (int)player.posZ, true);
                   }
               }
            }
            

            Rassure-moi, tu le fais exprès?
            Ce que je t’ai donné, c’est le code pour récupérer la position du prochain ascenseur au-dessus du joueur.
            Or, là :

            • Tu ne vérifies même pas si le joueur est sur un bloc ascenseur
            • Tu passes une variable membre non-initialisée en argument alors que la bonne variable est là, juste sous ton nez
            • Tu n’utilises même pas la valeur récupérée (bon, en même temps y’a pas grand chose à récupérer vu que ça crash. Mais pourquoi ça crash? Tout simplement parce que tu passes une variable non-initialisée en argument. T’étonne pas d’avoir des NullPointerException si la valeur est null).

            Tout ça ne me donne pas du tout envie de t’aider.
            Comme on te l’a sûrement déjà dit : Essaie de comprendre le code avant de l’utiliser.
            Apprends le Java, je sais pas, moi. Quand t’étais petit, fallait qu’on t’explique comment on empile des cubes en plastique ou bien?
            Désolé si j’emploie un ton agressif mais copier-coller un bout de code au hasard ça va bien 3 minutes, mais après faut pas être surpris si on a des crashs à tout bout de champ.
            T’as déjà trouvé comment récupérer la position du joueur. Ok, c’est assez facile, mais ça veut bien dire que tu peux réfléchir par toi-même et trouver une solution à partir de ce qu’on te propose. Sans créer des variables au hasard sans se demander à quoi peuvent servir celles qui existent déjà.

            Du coup je sais vraiment pas si je te fais la correction de ton code…
            Bon, allez, histoire d’essayer de t’apprendre quelque chose :

            package com.XDoctorX.main;
            
            import java.io.DataInput;
            import java.io.IOException;
            import net.minecraft.entity.player.EntityPlayer;
            import net.minecraft.world.World;
            import net.minecraftforge.common.util.ForgeDirection;
            import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
            import com.XDoctorX.block.BlockElevator;
            import cpw.mods.fml.common.eventhandler.SubscribeEvent;
            
            public class ElevatorEvent {
               @SubscribeEvent
               public void onLivingJumpEvent(LivingJumpEvent event) {
                   if (event.entity instanceof EntityPlayer && event.entity.worldObj.getBlock(event.entity.posX, event.entity.posY - 1, event.entity.posZ) == ClassePrincipale.*block_elevator*) {
                       EntityPlayer p = (EntityPlayer)(event.entity);
                       int[] posBlocCible = BlockElevator.getTargetBlock(world, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                       p.setPosition(posBlocCible[0], posBlocCible[1]+1, posBlocCible[2]);
                   }
               }
            }
            

            Mes mods :

            • Cookie Ore (1.7.10)

            Mod en cours : **E…

            1 réponse Dernière réponse Répondre Citer 0
            • X Hors-ligne
              XDoctorX
              dernière édition par

              sa marche pas c’est le meme crash report

              1 réponse Dernière réponse Répondre Citer 0
              • robin4002R Hors-ligne
                robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                dernière édition par

                Toujours un NPE à la ligne 27 de ta classe ElevatorEvent ?

                1 réponse Dernière réponse Répondre Citer 0
                • AlgorythmisA Hors-ligne
                  Algorythmis
                  dernière édition par

                  Désolé, pourtant en théorie ce code marche très bien, on a remplacé les variables qui causaient l’erreur.

                  Mes mods :

                  • Cookie Ore (1.7.10)

                  Mod en cours : **E…

                  1 réponse Dernière réponse Répondre Citer 0
                  • X Hors-ligne
                    XDoctorX
                    dernière édition par

                    non je croit

                    
                    package com.XDoctorX.main;
                    
                    import java.io.DataInput;
                    import java.io.IOException;
                    import net.minecraft.entity.player.EntityPlayer;
                    import net.minecraft.world.World;
                    import net.minecraftforge.common.util.ForgeDirection;
                    import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
                    import com.XDoctorX.block.BlockElevator;
                    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                    
                    public class ElevatorEvent {
                    
                    public World world;
                    
                    @SubscribeEvent
                    public void onLivingJumpEvent(LivingJumpEvent event) {
                    if (event.entity instanceof EntityPlayer && event.entity.worldObj.getBlock((int)event.entity.posX,(int) event.entity.posY - 1,(int) event.entity.posZ) == XDoctorX.Elevator) {
                    EntityPlayer p = (EntityPlayer)(event.entity);
                    int[] posBlocCible = BlockElevator.getTargetBlock(world, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                    p.setPosition(posBlocCible[0], posBlocCible[1]+1, posBlocCible[2]);
                    }
                    }
                    }
                    
                    
                    1 réponse Dernière réponse Répondre Citer 0
                    • robin4002R Hors-ligne
                      robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                      dernière édition par

                      public World world; n’a rien à faire là.
                      int[] posBlocCible = BlockElevator.getTargetBlock(world, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                      -> event.entity.worldObj à la place de world ici.

                      1 réponse Dernière réponse Répondre Citer 0
                      • X Hors-ligne
                        XDoctorX
                        dernière édition par

                        sa marche pas et il y a a pas de crash report

                        1 réponse Dernière réponse Répondre Citer 0
                        • AlgorythmisA Hors-ligne
                          Algorythmis
                          dernière édition par

                          @‘robin4002’:

                          public World world; n’a rien à faire là.
                                          int[] posBlocCible = BlockElevator.getTargetBlock(world, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                          -> event.entity.worldObj à la place de world ici.

                          Oups, merci Robin ^^’ Erreur d’inattention

                          Mes mods :

                          • Cookie Ore (1.7.10)

                          Mod en cours : **E…

                          1 réponse Dernière réponse Répondre Citer 0
                          • X Hors-ligne
                            XDoctorX
                            dernière édition par

                            je lais fait mais sa marche pas et il y a plus de crash report

                            1 réponse Dernière réponse Répondre Citer 0
                            • robin4002R Hors-ligne
                              robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                              dernière édition par

                              marche pas = il se passe rien ? Tu as bien placé les blocs ? Renvoies également le code actuel.

                              1 réponse Dernière réponse Répondre Citer 0
                              • X Hors-ligne
                                XDoctorX
                                dernière édition par

                                Rien se passe.

                                code du Event :

                                
                                package com.XDoctorX.main;
                                
                                import java.io.DataInput;
                                import java.io.IOException;
                                import net.minecraft.entity.player.EntityPlayer;
                                import net.minecraft.world.World;
                                import net.minecraftforge.common.util.ForgeDirection;
                                import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
                                import com.XDoctorX.block.BlockElevator;
                                import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                                
                                public class ElevatorEvent {
                                
                                @SubscribeEvent
                                public void onLivingJumpEvent(LivingJumpEvent event) {
                                if (event.entity instanceof EntityPlayer && event.entity.worldObj.getBlock((int)event.entity.posX,(int) event.entity.posY - 1,(int) event.entity.posZ) == XDoctorX.Elevator) {
                                EntityPlayer p = (EntityPlayer)(event.entity);
                                int[] posBlocCible = BlockElevator.getTargetBlock(event.entity.worldObj, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                                p.setPosition(posBlocCible[0], posBlocCible[1]+1, posBlocCible[2]);
                                }
                                }
                                }
                                
                                
                                1 réponse Dernière réponse Répondre Citer 0
                                • AlgorythmisA Hors-ligne
                                  Algorythmis
                                  dernière édition par

                                  Tu essaies bien en te plaçant sur un bloc ascenseur?

                                  Mes mods :

                                  • Cookie Ore (1.7.10)

                                  Mod en cours : **E…

                                  1 réponse Dernière réponse Répondre Citer 0
                                  • robin4002R Hors-ligne
                                    robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                    dernière édition par

                                    Essayes avec p.setPositionAndUpdate(posBlocCible[0], posBlocCible[1]+1, posBlocCible[2]);

                                    1 réponse Dernière réponse Répondre Citer 0
                                    • X Hors-ligne
                                      XDoctorX
                                      dernière édition par

                                      je suis sur le bloc, rien se passe j"ai mit

                                      p.addChatComponentMessage(new ChatComponentTranslation(“test”));

                                      sa marche une seul fois apres sa marche plus et le code est maintenant

                                      
                                         package com.XDoctorX.main;
                                      
                                         import java.io.DataInput;
                                      import java.io.IOException;
                                      
                                      import net.minecraft.entity.player.EntityPlayer;
                                      import net.minecraft.util.ChatComponentTranslation;
                                      import net.minecraft.world.World;
                                      import net.minecraftforge.common.util.ForgeDirection;
                                      import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
                                      
                                      import com.XDoctorX.block.BlockElevator;
                                      
                                      import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                                      
                                         public class ElevatorEvent {
                                      
                                             @SubscribeEvent
                                             public void onLivingJumpEvent(LivingJumpEvent event) {
                                                 if (event.entity instanceof EntityPlayer && event.entity.worldObj.getBlock((int)event.entity.posX,(int) event.entity.posY - 1,(int) event.entity.posZ) == XDoctorX.Elevator) {
                                                     EntityPlayer p = (EntityPlayer)(event.entity);
                                                     p.addChatComponentMessage(new ChatComponentTranslation("test"));
                                                     int[] posBlocCible = BlockElevator.getTargetBlock(event.entity.worldObj, (int)p.posX, (int)p.posY, (int)p.posZ, true);
                                                     p.setPositionAndUpdate(posBlocCible[0], posBlocCible[1]+1, posBlocCible[2]);                
                                                 }
                                             }
                                         }
                                      
                                      
                                      1 réponse Dernière réponse Répondre Citer 0
                                      • X Hors-ligne
                                        XDoctorX
                                        dernière édition par

                                        up up up up up up up up

                                        1 réponse Dernière réponse Répondre Citer 0
                                        • robin4002R Hors-ligne
                                          robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                                          dernière édition par

                                          24h avant de up, merci de lire le règlement du forum …
                                          Envoies-moi un zip de ton dossier src je vais tester de mon côté.

                                          1 réponse Dernière réponse Répondre Citer 0
                                          • X Hors-ligne
                                            XDoctorX
                                            dernière édition par

                                            http://www.mediafire.com/download/0xeu8bbw2hvn1v2/Src+Elevator+by+XDoctorX.zip

                                            1 réponse Dernière réponse Répondre Citer 0
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • Premier message
                                              Dernier message
                                            Design by Woryk
                                            ContactMentions Légales

                                            MINECRAFT FORGE FRANCE © 2024

                                            Powered by NodeBB