Summon entity avec touche



  • Bonjour, je cherche a faire spawn une entité apres avoir appuyé sur une touche mais ca ne fonctionne pas.

    Entité:

    package com.extremium.mod.entity;
    
    import java.util.List;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.block.Block;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.projectile.EntityFireball;
    import net.minecraft.entity.projectile.EntitySmallFireball;
    import net.minecraft.entity.projectile.EntityThrowable;
    import net.minecraft.entity.projectile.EntityWitherSkull;
    import net.minecraft.init.Blocks;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.potion.Potion;
    import net.minecraft.potion.PotionEffect;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.MathHelper;
    import net.minecraft.util.MovingObjectPosition;
    import net.minecraft.util.Vec3;
    import net.minecraft.world.EnumDifficulty;
    import net.minecraft.world.Explosion;
    import net.minecraft.world.World;
    
    public class EntityStaminaBall extends EntityThrowable
    {
    
        public static final String __OBFID = "CL_00001722";
    
        public EntityStaminaBall(World p_i1773_1_)
        {
            super(p_i1773_1_);
        }
    
        public EntityStaminaBall(World p_i1774_1_, EntityLivingBase p_i1774_2_)
        {
            super(p_i1774_1_, p_i1774_2_);
        }
    
        public EntityStaminaBall(World p_i1775_1_, double p_i1775_2_, double p_i1775_4_, double p_i1775_6_)
        {
            super(p_i1775_1_, p_i1775_2_, p_i1775_4_, p_i1775_6_);
        }
    
        /**
         * Called when this EntityThrowable hits a block or entity.
         */
        public void onImpact(MovingObjectPosition p_70227_1_)
        {
                this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
                this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 4.0F, true);
                
            if (!this.worldObj.isRemote)
            {
                this.setDead();
            }
            
            
            
        }
    }
    

    Touche :

    package com.extremium.mod.proxy;
    
    
    
    
    import org.lwjgl.input.Keyboard;
    
    import com.extremium.mod.GuiStamina;
    import com.extremium.mod.entity.DynamiteEntity2;
    import com.extremium.mod.entity.EntityBossAltar;
    import com.extremium.mod.entity.EntityBossArmorer;
    import com.extremium.mod.entity.EntityBossDigger;
    import com.extremium.mod.entity.EntityBossForer;
    import com.extremium.mod.entity.EntityBossLumber;
    import com.extremium.mod.entity.EntityDrastic;
    import com.extremium.mod.entity.EntityGaster;
    import com.extremium.mod.entity.EntitySmauger;
    import com.extremium.mod.entity.EntityStaminaBall;
    import com.extremium.mod.init.ItemMod;
    import com.extremium.mod.init.ItemOverlay;
    import com.extremium.mod.models.Armorer;
    import com.extremium.mod.models.bossAltar;
    import com.extremium.mod.models.drastic;
    import com.extremium.mod.renders.RenderAltar;
    import com.extremium.mod.renders.RenderArmorer;
    import com.extremium.mod.renders.RenderDigger;
    import com.extremium.mod.renders.RenderDrastic;
    import com.extremium.mod.renders.RenderForer;
    import com.extremium.mod.renders.RenderGaster;
    import com.extremium.mod.renders.RenderLumber;
    import com.extremium.mod.renders.RenderSmauger;
    
    import cpw.mods.fml.client.registry.ClientRegistry;
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.FMLCommonHandler;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.model.ModelBiped;
    import net.minecraft.client.renderer.entity.RenderSnowball;
    import net.minecraft.client.settings.KeyBinding;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.ChatComponentTranslation;
    import net.minecraft.world.World;
    import net.minecraftforge.common.MinecraftForge;
    
    public class ClientProxy extends CommonProxy 
    {
        private static KeyBinding keyBindStamina;
        public static EntityPlayer player;
        public static World world;
        @Override
        public void registerRenders()
        {
            System.out.println("client");
            RenderingRegistry.registerEntityRenderingHandler(EntitySmauger.class, new RenderSmauger(new ModelBiped(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityStaminaBall.class, new RenderSnowball(ItemMod.stamina_fist));
            RenderingRegistry.registerEntityRenderingHandler(EntityBossAltar.class, new RenderAltar(new bossAltar(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityBossForer.class, new RenderForer(new bossAltar(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityBossLumber.class, new RenderLumber(new bossAltar(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityBossDigger.class, new RenderDigger(new bossAltar(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityBossArmorer.class, new RenderArmorer(new Armorer(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityGaster.class, new RenderGaster(new ModelBiped(), 0.5F));
            RenderingRegistry.registerEntityRenderingHandler(EntityDrastic.class, new RenderDrastic(new drastic(), 0.5F));
            
                  
        }
        
        @Override
        public void registerOverlay() 
        {
            MinecraftForge.EVENT_BUS.register(new ItemOverlay());
        }
        
        public ClientProxy()
        {
            FMLCommonHandler.instance().bus().register(this);
            keyBindStamina = new KeyBinding("extremium.keyBindStamina", Keyboard.KEY_G, "key.categories.misc");
            ClientRegistry.registerKeyBinding(keyBindStamina);
            }
            @SubscribeEvent
            public void onEvent(KeyInputEvent event)
            {
            if(keyBindStamina.isPressed())
            { 
                keyStaminaTyped(world, player);
            }
            }
         
            private void keyStaminaTyped(World world, EntityPlayer player)
            {
                if(GuiStamina.stamina == 14)
                {
    
                    world.spawnEntityInWorld(new EntityStaminaBall(world, player));
                }
                
            }
    }
    
    

  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonsoir,
    Les touches sont géré sur le client, il n'est pas possible de faire spawner directement une entité car elle doit être sur le serveur (sinon cela donne juste une entité morte, qui ne bouge pas).

    Il faut donc un paquet.


Log in to reply