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

      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
                          • robin4002R Hors-ligne
                            robin4002 Moddeurs confirmés Rédacteurs Administrateurs
                            dernière édition par

                            XDoctorX.java, fonction init, ajoute ça :
                            FMLCommonHandler.instance().bus().register(new ElevatorEvent());
                            En dessous de la ligne avec Forge.
                            BlockElevator :

                            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.Entity;
                            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 up)
                            {
                            if(up)
                            {
                            for(int i = y; i <= 255; i++)
                            {
                            if(w.getBlock(x, i, z) == XDoctorX.Elevator)
                            {
                            return i;
                            }
                            }
                            }
                            else
                            {
                            for(int i = y; i >= 0; i–)
                            {
                            if(w.getBlock(x, i, z) == XDoctorX.Elevator)
                            {
                            return i;
                            }
                            }
                            }
                            return -1;
                            }
                            }
                            

                            ElevatorEvent :

                            package com.XDoctorX.main;
                            
                            import com.XDoctorX.block.BlockElevator;
                            
                            import cpw.mods.fml.common.eventhandler.SubscribeEvent;
                            import cpw.mods.fml.common.gameevent.TickEvent;
                            import net.minecraft.entity.player.EntityPlayer;
                            import net.minecraft.util.MathHelper;
                            import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
                            
                            public class ElevatorEvent
                            {
                            @SubscribeEvent
                            public void onLivingJumpEvent(LivingJumpEvent event)
                            {
                            if(event.entity instanceof EntityPlayer)
                            {
                            if(event.entity.worldObj.getBlock(MathHelper.floor_double(event.entity.posX), MathHelper.floor_double(event.entity.posY - 1), MathHelper.floor_double(event.entity.posZ)) == XDoctorX.Elevator)
                            {
                            EntityPlayer p = (EntityPlayer)event.entity;
                            
                            int posBlocCible = BlockElevator.getTargetBlock(event.entity.worldObj, MathHelper.floor_double(event.entity.posX), MathHelper.floor_double(event.entity.posY), MathHelper.floor_double(event.entity.posZ), true);
                            if(posBlocCible != -1)
                            {
                            p.setPositionAndUpdate(event.entity.posX, posBlocCible + 1, event.entity.posZ);
                            }
                            }
                            }
                            }
                            
                            @SubscribeEvent
                            public void onPlayerTick(TickEvent.PlayerTickEvent event)
                            {
                            if(event.phase == TickEvent.Phase.START)
                            {
                            if(event.player.isSneaking())
                            {
                            if(event.player.worldObj.getBlock(MathHelper.floor_double(event.player.posX), MathHelper.floor_double(event.player.posY - 1), MathHelper.floor_double(event.player.posZ)) == XDoctorX.Elevator)
                            {
                            int posBlocCible = BlockElevator.getTargetBlock(event.player.worldObj, MathHelper.floor_double(event.player.posX), MathHelper.floor_double(event.player.posY) - 2, MathHelper.floor_double(event.player.posZ), false);
                            if(posBlocCible != -1)
                            {
                            event.player.setPositionAndUpdate(event.player.posX, posBlocCible + 1, event.player.posZ);
                            event.player.setSneaking(false);
                            }
                            }
                            }
                            }
                            }
                            }
                            
                            
                            1 réponse Dernière réponse Répondre Citer 0
                            • X Hors-ligne
                              XDoctorX
                              dernière édition par

                              merci

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

                                Balise résolu ?

                                Site web contenant mes scripts : http://SCAREXgaming.github.io

                                Pas de demandes de support par MP ni par skype SVP.
                                Je n'accepte sur skype que l…

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

                                  Bonjour,
                                  Avec les changement de la 1.8 sa a changer (getBlock = getBlockState) c’est difficile si vous vouvez m’aider c’est super 🙂

                                  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

                                    world.getBlock(x, y, z) = world.getBlockState(pos).getBlock()
                                    C’est en effet difficile …

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

                                      et pour les coordonnée (pos ne defini pas les coordonné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

                                        pos c’est un BlockPos, qui contient x, y et z.

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

                                          Moi aussi je voulais construire un elevator en 1.8, j’ai donc réfléchit tout seul comment je pouvais faire et cela m’a pris 20 min et comme je suis gentil je te passe mon code 🙂

                                            public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
                                          
                                             {
                                          
                                                if(!entity.onGround && entity.motionY > 0){// On vérifie si le joueur saute
                                                int i = pos.getX();
                                              int j = pos.getY();  // on récupère les coordonnées de l’élévateur où se trouve le joueur
                                              int k = pos.getZ();
                                          
                                                for(int n = 3; n<=15 || n == 20 ; n++) {  //Ici la limite de distance entre les élévateurs est de 15 , tu peux la changer 
                                               BlockPos parPos = new BlockPos(i, j + n, k);     // On définit le block à chaque Y
                                               Block elev = world.getBlockState(parPos).getBlock();
                                          
                                                if(elev == BlocksRegistry.elevateur){  // Ici on vérifie si  le block est un élévateur ( tu met donc ici ton élévateur)
                                                int m = n;
                                                n=20;
                                                entity.setPosition(i+ 0.5, j + m+ 1, k +0.5); // On déplace le joueur
                                                }
                                                }
                                                } 
                                                if(entity.isSneaking()){ // On vérifie ici si le joueur sneak et on effectue la même procédure mais on check en dessous de l'élévateur cette fois ci
                                                int i = pos.getX();
                                              int j = pos.getY();
                                              int k = pos.getZ();
                                          
                                                for(int b = 3; b<=15 || b == 20 ; b++) {
                                               BlockPos parPos = new BlockPos(i, j - b, k);
                                               Block elev = world.getBlockState(parPos).getBlock();
                                          
                                                if(elev == BlocksRegistry.elevateur){
                                                int g = b;
                                                b=20;
                                                entity.setPosition(i+0.5, j + -g + 1, k+0.5);
                                                }
                                                }
                                                }
                                          }
                                          
                                          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

                                            Merci pour le partage. D’ailleurs je vais passer ce post en résolu.

                                            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