1.12.2 Entité Fusée



  • Bonjour, j'ai créé une entité (que la base) : une fusée et une dimension.
    Je voudrais que la fusée emporte le joueur jusqu'à la couche 256 puis se téléporte sur ma dimension.

    Class de ma fusée :

    public class EntityFuse extends Entity
    {
    
        public EntityFuse(World worldIn, double posX, double posY, double posZ)
        {
            super(worldIn);
            this.setPosition(posX, posY, posZ);
            this.prevPosX = posX;
            this.prevPosY = posY;
            this.prevPosZ = posZ;
            this.motionY = -0.20000000298023224D;
        }
    
        public EntityFuse(World worldIn)
        {
            super(worldIn);
        }
        
        @Override
        protected void entityInit()
        {
    
        }
    
        @Override
        protected void readEntityFromNBT(NBTTagCompound compound)
        {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        protected void writeEntityToNBT(NBTTagCompound compound)
        {
            // TODO Auto-generated method stub
    
        }
    
        @Override
        public void onEntityUpdate()
        {
            this.posY++;
        }
    
        @Override
        public boolean canBeAttackedWithItem()
        {
            return false;
        }
    
    }
    


  • Merci à plagueZ !
    Et vu que je suis gentil 😄 voici le code:

    EntityFuse:
    
    public class EntityFuse extends EntityHorse
    {
        private static boolean isLaunched = false;
        
        public EntityFuse(World worldIn)
        {
            super(worldIn);
        }
           
        public EntityFuse(World worldIn, double x, double y, double z)
        {
            super(worldIn);
            this.setPosition(x, y, z);
        }
        
        @Override
        public boolean processInteract(EntityPlayer player, EnumHand hand)
        {
            ItemStack itemstack = player.getHeldItem(hand);
            boolean flag = !itemstack.isEmpty();
    
    
                if (!this.isChild())
                {
                    if (this.isBeingRidden())
                    {
                        return super.processInteract(player, hand);
                    }
                }
    
                if (flag)
                {
                    if (itemstack.interactWithEntity(player, this, hand))
                    {
                        return true;
                    }
                }
                if(!this.isChild())
                {
                    this.mount(player);
                    this.playSound(SoundsHandler.FUSE_LAUNCH, 9.0F, 0);
                }
                else
                {
                    return super.processInteract(player, hand);
                }
                  
                return true;
        }
        
        @Override
        protected ResourceLocation getLootTable()
        {
            // TODO Auto-generated method stub
            return LootTableHandler.FUSE;
        }
        
        private void mount(EntityPlayer player)
        {       
            this.setRearing(false);
            if (!world.isRemote)
            {
                player.startRiding(this);
            }
            isLaunched = true;
        }
        
        protected void entityInit()
        {
            super.entityInit();
        }
    
        protected SoundEvent getAmbientSound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getDeathSound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getHurtSound(DamageSource damageSourceIn)
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getAngrySound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
        
        @Override
        public void writeEntityToNBT(NBTTagCompound compound)
        {
    
        }
    
    
        @Override
        public void readEntityFromNBT(NBTTagCompound compound)
        {
    
        }
    
        @Override
        public boolean isAIDisabled()
        {
            // TODO Auto-generated method stub
            return true;
        }
        
        /**
         * Called to update the entity's position/logic.
         */
        public void onUpdate()
        {
            super.onUpdate();
    
            if (this.world.isRemote && this.dataManager.isDirty())
            {
                this.dataManager.setClean();
            }  
    
            if(isLaunched)
            {
                this.addVelocity(0, 1, 0);
            }
            
            world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, 0);
             
        }
        
        @Override
        public boolean attackable()
        {
            // TODO Auto-generated method stub
            return false;
        }
        
        @Override
        public boolean canBeAttackedWithItem()
        {
            // TODO Auto-generated method stub
            return false;
        }
    }
    
    ModelFuse:
    
    public class ModelFuse extends ModelBase
    {
        private final ModelRenderer bone;
    
        public ModelFuse()
        {
            textureWidth = 64;
            textureHeight = 64;
    
            bone = new ModelRenderer(this);
            bone.setRotationPoint(0.0F, 24.0F, -8.0F);
            bone.cubeList.add(new ModelBox(bone, 0, 29, -3.0F, -29.0F, 5.0F, 6, 29, 6, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 24, 59, -2.0F, -30.0F, 6.0F, 4, 1, 4, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 24, 55, -1.0F, -32.0F, 7.0F, 2, 2, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 48, -1.0F, -25.0F, 11.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -23.0F, 1.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -21.0F, -1.0F, 2, 10, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 48, 48, -1.0F, -25.0F, 3.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -23.0F, 13.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -21.0F, 15.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 2, 2, 3.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 12, -7.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 56, 0, -9.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 2, 2, -5.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 56, 24, 7.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 12, 5.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, 3.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -7.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -5.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, 5.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 3.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 1.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 11.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 13.0F, 2, 4, 2, 0.0F, false));
        }
    
        @Override
        public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
        {
            bone.render(f5);
        }
    
        public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z)
        {
            modelRenderer.rotateAngleX = x;
            modelRenderer.rotateAngleY = y;
            modelRenderer.rotateAngleZ = z;
        }
    }
    
    RenderFuse:
    
    public class RenderFuse extends RenderLiving<EntityFuse>
    {
        protected static ModelBase modelFuse = new ModelFuse();
    
        public static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MODID + ":textures/entity/fuse.png");
    
        public RenderFuse(RenderManager renderManager)
        {
            super(renderManager, modelFuse, 0.5f);
            bindTexture(TEXTURES);
        }
    
        @Override
        protected ResourceLocation getEntityTexture(EntityFuse entity)
        {
            return TEXTURES;
        }
    
    }
    
    Events:
    
    @SubscribeEvent
        public static void playerTickEvent(PlayerTickEvent e)
        {
            if(e.player.dimension == 2)
            {
                e.player.addVelocity(0, 0.02754375, 0);
               
                if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
                {             
                    e.player.dismountRidingEntity();
                    if(e.player.world.isRemote)
                    {
                        e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
                    }
                    CustomTeleporter.teleportToDimension(e.player, 0, 0, 150, 0);
                }
            }  
            if(e.player.dimension == 0)
            {          
                if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
                {
                    e.player.dismountRidingEntity();
                    if(e.player.world.isRemote)
                    {
                        e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
                    }
                    CustomTeleporter.teleportToDimension(e.player, Reference.MOON, 0, 150, 0);
                }
            }
        }
        
        @SubscribeEvent
        public static void killFuse(LivingUpdateEvent e)
        {
            if(e.getEntityLiving().getPosition().getY()>= 298D)
            {
                //System.out.println("Pos");
                if(!e.getEntityLiving().world.isRemote)
                {
                    //System.out.println("world");
                    if(e.getEntityLiving() instanceof EntityFuse)
                    {
                        //System.out.println("fuse");
                        e.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 20, 20));                
                    }
                }
            }
         }
    

    Texture :fuse.png





  • Tu peut le faire avec un évent ou tu lui file un vélocité élevée ça va la faire voler tu récupère le sa position et si c'est plus de 256 tu tp dans la dimension vérifie aussi le joueur est dedans x)

    Et pour que ca soit simple essaye de crée une entité montable genre cheval



  • @PlagueZ merci !
    Alors par contre x) j'ai pas trouvé l'event et jsp pourquoi mais mon entité reste SYSTEMATIQUEMENT collée au joueur xD

    11579d41-3b6a-4322-bf69-095bf2d428fc-image.png



  • Code?
    Event LivingEntity?
    parce que sans code la je peut difficilement comprendre ce qui se passe xD



  • Peut être tu oublie de vérifier si l'objet sur le quel tu bosse est pas autre chose genre

    if(event.getEntity instanceof EntityFusée ){
    do whatever
    }

    pour éviter ton évent s'applique a toutes les entité du jeu



  • @PlagueZ nn c'est pas une EntityLiving

    public class EntityFuse extends Entity
    {
     
        public EntityFuse(World worldIn, double posX, double posY, double posZ)
        {
            super(worldIn);
            this.setPosition(posX, posY, posZ);
            this.prevPosX = posX;
            this.prevPosY = posY;
            this.prevPosZ = posZ;
        }
     
        public EntityFuse(World worldIn)
        {
            super(worldIn);
        }
        
        @Override
        protected void entityInit()
        {
     
        }
     
        @Override
        public boolean canBeAttackedWithItem()
        {
            return false;
        }
    
        @Override
        protected void readEntityFromNBT(NBTTagCompound compound)
        {
            // TODO Auto-generated method stub
            
        }
    
        @Override
        protected void writeEntityToNBT(NBTTagCompound compound)
        {
            // TODO Auto-generated method stub
            
        }
        
    }
    


  • et comment tu la déplace du coup sur ton joueur? ça doit être la ça déconne



  • @PlagueZ bah j'ai pas encore fait ca xD
    si tes dispo ca serait pas mieux de voc ou mp discord ?
    Si t'es ok : DrasticLp#5027



  • mais il devrait pas être coller a ton joueur systématiquement tu enregistre ton entité comment



  • Merci à plagueZ !
    Et vu que je suis gentil 😄 voici le code:

    EntityFuse:
    
    public class EntityFuse extends EntityHorse
    {
        private static boolean isLaunched = false;
        
        public EntityFuse(World worldIn)
        {
            super(worldIn);
        }
           
        public EntityFuse(World worldIn, double x, double y, double z)
        {
            super(worldIn);
            this.setPosition(x, y, z);
        }
        
        @Override
        public boolean processInteract(EntityPlayer player, EnumHand hand)
        {
            ItemStack itemstack = player.getHeldItem(hand);
            boolean flag = !itemstack.isEmpty();
    
    
                if (!this.isChild())
                {
                    if (this.isBeingRidden())
                    {
                        return super.processInteract(player, hand);
                    }
                }
    
                if (flag)
                {
                    if (itemstack.interactWithEntity(player, this, hand))
                    {
                        return true;
                    }
                }
                if(!this.isChild())
                {
                    this.mount(player);
                    this.playSound(SoundsHandler.FUSE_LAUNCH, 9.0F, 0);
                }
                else
                {
                    return super.processInteract(player, hand);
                }
                  
                return true;
        }
        
        @Override
        protected ResourceLocation getLootTable()
        {
            // TODO Auto-generated method stub
            return LootTableHandler.FUSE;
        }
        
        private void mount(EntityPlayer player)
        {       
            this.setRearing(false);
            if (!world.isRemote)
            {
                player.startRiding(this);
            }
            isLaunched = true;
        }
        
        protected void entityInit()
        {
            super.entityInit();
        }
    
        protected SoundEvent getAmbientSound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getDeathSound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getHurtSound(DamageSource damageSourceIn)
        {
            return SoundsHandler.IDLE_FUSE;
        }
    
        protected SoundEvent getAngrySound()
        {
            return SoundsHandler.IDLE_FUSE;
        }
        
        @Override
        public void writeEntityToNBT(NBTTagCompound compound)
        {
    
        }
    
    
        @Override
        public void readEntityFromNBT(NBTTagCompound compound)
        {
    
        }
    
        @Override
        public boolean isAIDisabled()
        {
            // TODO Auto-generated method stub
            return true;
        }
        
        /**
         * Called to update the entity's position/logic.
         */
        public void onUpdate()
        {
            super.onUpdate();
    
            if (this.world.isRemote && this.dataManager.isDirty())
            {
                this.dataManager.setClean();
            }  
    
            if(isLaunched)
            {
                this.addVelocity(0, 1, 0);
            }
            
            world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, 0);
             
        }
        
        @Override
        public boolean attackable()
        {
            // TODO Auto-generated method stub
            return false;
        }
        
        @Override
        public boolean canBeAttackedWithItem()
        {
            // TODO Auto-generated method stub
            return false;
        }
    }
    
    ModelFuse:
    
    public class ModelFuse extends ModelBase
    {
        private final ModelRenderer bone;
    
        public ModelFuse()
        {
            textureWidth = 64;
            textureHeight = 64;
    
            bone = new ModelRenderer(this);
            bone.setRotationPoint(0.0F, 24.0F, -8.0F);
            bone.cubeList.add(new ModelBox(bone, 0, 29, -3.0F, -29.0F, 5.0F, 6, 29, 6, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 24, 59, -2.0F, -30.0F, 6.0F, 4, 1, 4, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 24, 55, -1.0F, -32.0F, 7.0F, 2, 2, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 48, -1.0F, -25.0F, 11.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -23.0F, 1.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -21.0F, -1.0F, 2, 10, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 48, 48, -1.0F, -25.0F, 3.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -23.0F, 13.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -21.0F, 15.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 2, 2, 3.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 12, -7.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 56, 0, -9.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 2, 2, -5.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, true));
            bone.cubeList.add(new ModelBox(bone, 56, 24, 7.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 56, 12, 5.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, 3.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -7.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -5.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, 5.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 3.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 1.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 11.0F, 2, 4, 2, 0.0F, false));
            bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 13.0F, 2, 4, 2, 0.0F, false));
        }
    
        @Override
        public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
        {
            bone.render(f5);
        }
    
        public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z)
        {
            modelRenderer.rotateAngleX = x;
            modelRenderer.rotateAngleY = y;
            modelRenderer.rotateAngleZ = z;
        }
    }
    
    RenderFuse:
    
    public class RenderFuse extends RenderLiving<EntityFuse>
    {
        protected static ModelBase modelFuse = new ModelFuse();
    
        public static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MODID + ":textures/entity/fuse.png");
    
        public RenderFuse(RenderManager renderManager)
        {
            super(renderManager, modelFuse, 0.5f);
            bindTexture(TEXTURES);
        }
    
        @Override
        protected ResourceLocation getEntityTexture(EntityFuse entity)
        {
            return TEXTURES;
        }
    
    }
    
    Events:
    
    @SubscribeEvent
        public static void playerTickEvent(PlayerTickEvent e)
        {
            if(e.player.dimension == 2)
            {
                e.player.addVelocity(0, 0.02754375, 0);
               
                if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
                {             
                    e.player.dismountRidingEntity();
                    if(e.player.world.isRemote)
                    {
                        e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
                    }
                    CustomTeleporter.teleportToDimension(e.player, 0, 0, 150, 0);
                }
            }  
            if(e.player.dimension == 0)
            {          
                if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
                {
                    e.player.dismountRidingEntity();
                    if(e.player.world.isRemote)
                    {
                        e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
                    }
                    CustomTeleporter.teleportToDimension(e.player, Reference.MOON, 0, 150, 0);
                }
            }
        }
        
        @SubscribeEvent
        public static void killFuse(LivingUpdateEvent e)
        {
            if(e.getEntityLiving().getPosition().getY()>= 298D)
            {
                //System.out.println("Pos");
                if(!e.getEntityLiving().world.isRemote)
                {
                    //System.out.println("world");
                    if(e.getEntityLiving() instanceof EntityFuse)
                    {
                        //System.out.println("fuse");
                        e.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 20, 20));                
                    }
                }
            }
         }
    

    Texture :fuse.png


Log in to reply