Jump to content

Grim1ight

Members
  • Posts

    28
  • Joined

  • Last visited

Posts posted by Grim1ight

  1. I don't sure that code is needed because this happens even if I use this code:

    public class EntityGargoyle extends EntityMob
    {	
        public EntityGargoyle(World p_i1694_1_)
        {
            super(p_i1694_1_);
            this.setSize(0.8F, 2F);
            this.tasks.addTask(0, new EntityAISwimming(this));
            this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
            this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
            this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
            this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
            this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
            this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
            this.tasks.addTask(8, new EntityAILookIdle(this));
            this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
            this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
        }
        
        public boolean isAIEnabled()
        {
            return true;
        }
    }
    

     

    I copied tasks from zombie class. Mob still lagging. He can't find path to target and when he falls in hole with 1 block height he just rotating on one point.

  2. Hi! I have problem with entity's AI: if isAIEnabled() returning true my mob is "lagging" - if I higher he begins shake head in different sides, if I set block before him, he jumps only after few seconds, when I changing my direction, he changes it after few seconds and moves in old direction some time. It's not critical but annoying, and happens only if I enable AI.

    Thanks.

  3. Capable? I think yes. I don't know Java much but I think enought for forge and I still studying. I started to making mods recently (few month ago). I usually trying to find tutorials or see Minecraft code to make basic code and then making my own stuff. If I will learn how to do something (Inventory slots for example), I will know how to make it further. And that's why I asking tutorial (now I want learn inventory, containers, GUIs).

     

    P.S. I want slot inside player inventory.

  4. Capable? I think yes. I don't know Java much but I think enought for forge and I still studying. I started to making mods recently (few month ago). I usually trying to find tutorials or see Minecraft code to make basic code and then making my own stuff. If I will learn how to do something (Inventory slots for example), I will know how to make it further. And that's why I asking tutorial (now I want learn inventory, containers, GUIs).

     

    P.S. I want slot inside player inventory.

  5. Hi!

     

    I need to make delay before attack, this is my code:

     

        private int attackDelay;
        private int attackTimer;
        private Entity attackedEntity = null;
        
        
        public ItemGreatsword(Item.ToolMaterial par1ToolMaterial, int par2AttackDelay)
        {
            this.field_150933_b = par1ToolMaterial;
            this.maxStackSize = 1;
            this.setMaxDamage(par1ToolMaterial.getMaxUses());
            this.setCreativeTab(CreativeTabs.tabCombat);
            this.field_150934_a = 4.0F + par1ToolMaterial.getDamageVsEntity();
        	//this.attackDelay = par2AttackDelay;
            this.attackDelay = 40;
        }
        
        @Override
        public boolean onLeftClickEntity(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, Entity par3Entity)
        {
        	if (attackedEntity == null)
        	{
        	    this.attackTimer = (this.attackDelay + 1);
        	    this.attackedEntity = par3Entity;
        	}
        	
            return true;
        }
        
        @Override
        public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
        {
            super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
        	
            EntityPlayer player = (EntityPlayer)par3Entity;
    ItemStack equippedItem = player.getCurrentEquippedItem();
    
    if (this.attackTimer > 0)
    {
        --this.attackTimer;
        System.out.println("AttackTimer: " + this.attackTimer);
    }
    
    if (this.attackTimer == 1)
    {
    	if (!par2World.isRemote)
    	{
    	    this.attackedEntity.attackEntityFrom(DamageSource.lava, 6.0F);
    	    this.attackedEntity = null;
    	    this.attackTimer = 0;
    	    System.out.println("Test");
    	}
    }
    
    if (equippedItem == par1ItemStack) 
    {
    	player.addPotionEffect(new PotionEffect(Potion.digSlowdown.getId(), 0, 3));
    }
        }
    

     

    Part of code (System.out.println("Test")) working, entity != null too, i checked it, but entity wont die.

     

    Thanks.

  6. Hi.

    I made config with entity class names list. All working fine except checking:

     

    String[] mob = Config.entityList.split(",");
        			
    String[] mobNames = new String[mob.length];
        			
    for(int i = 0; i < mob.length; i++)
    {
        mobNames[i] = mob[i];
    }
    
    for (int i = 0; i < mobNames.length; i++)
    {
        if (event.entity.class.getSimpleName() == mobNames[i])
        {
            //
        }
        else
        {
            System.out.println(event.entity.class.getSimpleName() + " --- "+ mobNames[i]);
        }
    }
    

     

    I getting it:

    "EntityZombie --- EntityZombie"

     

    Wt..?

  7. Hi! I made a mob model and want to make animations. Every leg have 2 pieces: upper and lower. Parts of code:

     

     

        convertToChild(leftleg, leftleg2);

        convertToChild(rightleg, rightleg2);

     

        this.leftleg.rotateAngleX = -1.3F * this.func_78172_a(f, 9.0F) * f1;

        this.rightleg.rotateAngleX = 1.3F * this.func_78172_a(f, 9.0F) * f1;

        this.leftleg.rotateAngleY = 0.0F;

        this.rightleg.rotateAngleY = 0.0F;

     

        protected void convertToChild(ModelRenderer parParent, ModelRenderer parChild)

        {

          parChild.rotationPointX -= parParent.rotationPointX;

          parChild.rotationPointY -= parParent.rotationPointY;

          parChild.rotationPointZ -= parParent.rotationPointZ;

          parChild.rotateAngleX -= parParent.rotateAngleX;

          parChild.rotateAngleY -= parParent.rotateAngleY;

          parChild.rotateAngleZ -= parParent.rotateAngleZ;

          parParent.addChild(parChild);

        }

     

    Problem is that upper and lower pieces moving in other directions.

  8. Why are you extending LivingEvent? And WHY are you placing the code in the constructor?

    You're event will only be called if you post it yourself, and you're probably not doing that.

     

    If you want your event to be called by forge, you need to create an EventManager class. You need to register this class at the correct bus in your preinit, in this case:

    MinecraftForge.EVENTBUS.register(new EventManager());

     

    In your EventManager you need this function:

    @SubscribeEvent
    public void update(LivingEvent.LivingUpdateEvent event)
    {
          //YOUR RENDERING CODE GOES HERE
    }
    

     

    If this short tutorial made no sense, read jabelar's tutorial:

     

    Srsly? It's part of code! I have this in main class:

    @EventHandler
    public void Load(FMLInitializationEvent Event) {
    	MinecraftForge.EVENT_BUS.register(new *EventName*());
    }
    

     

    + Smth like this:

    @SubscribeEvent
    public void onLivingAttackEvent(LivingAttackEvent event)
    {		
            if (event.ammount > 0 && event.source != DamageSource.lava && event.source != DamageSource.inFire && event.source != DamageSource.cactus 
            		&& event.source != DamageSource.wither && event.source != DamageSource.magic) {
                TheEvent bEvent = new TheEvent(event.entityLiving);
            }
    }
    

  9. What are you trying to do? Are you actually trying to handle an event? You can't handle an event the way you wrote it. Just calling the method "event" doesn't make it an event. You have to use the @Subscribe annotation to indicate that the method might be an event handler and then the parameter passed must be an event (like LivingHurtEvent). I have a tutorial on event handling here: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html

     

    It's a part of code -_-

     

    All working on clientside with mobs, with players (btw with npcs in mod CustomNPC) in serverside, but then crashing with Ticking Entity/Player error.

     

    if ()
    

  10. Hi! I have problem with LivingEvent:

    When I'm trying to spawn particles near player inside worldObj.isRemote it's isnt working, when I'm using it outside it's work but then crash with TickingPlayer/TickingEntity error. Here's code:

     

    public Event(EntityLivingBase par1Entity)
    {
        super(par1Entity);
    
        double f1 = entity.posX;
        double f2 = entity.posY + 1;
        double f3 = entity.posZ;
    
        if (entity.worldObj.isRemote) {
            if (entity instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer)entity;
                spawnParticles(player, 300); //It's not working 
            }
        }
        else
        {
            if (entity instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer)entity;
            spawnParticles(player, 300); //It's working with crash after second
            }
        }
    }
    
    
    void spawnParticles(EntityLivingBase par1entity, int par2Value) {
    spawnP(par1entity, Blocks.RedBlock, 0, 1, 2, par2Value);
    }
    
    void spawnP(EntityLivingBase par1entity, Block par2Block, int par3Meta, int par4Meta, int par5Meta, int par6Value) {
    float f1 = (float)(par1entity.posX);
    float f2 = (float)(par1entity.posY + 1F);
    float f3 = (float)(par1entity.posZ);
    
    for(int i = 0; i < par6Value; i++)
    {
    	int x = new Random().nextInt(3);
    	if (x == 0 )
    		Minecraft.getMinecraft().effectRenderer.addEffect(new EntityRedParticleFX(par1entity.worldObj, f1, f2, f3, 0.0D, 0.0D, 0.0D, par2Block, par3Meta));
    	else if (x == 1)
    		Minecraft.getMinecraft().effectRenderer.addEffect(new EntityRedParticleFX(par1entity.worldObj, f1, f2, f3, 0.0D, 0.0D, 0.0D, par2Block, par4Meta));
    	else if (x == 2)
    		Minecraft.getMinecraft().effectRenderer.addEffect(new EntityRedParticleFX(par1entity.worldObj, f1, f2, f3, 0.0D, 0.0D, 0.0D, par2Block, par5Meta));
    }
    }
    

     

  11. I would higly recommend to look at the examples from MineCraft itself. Since there is a dozen of them. Also why do you need blockBreak particles? Aint there functions to spawn in  'vanilla' particles including blockbreak particles.

     

    Btw, on the internet there are a bunch of tutorials and examples on how to create a custom particle. All of them are usable since the concept hasn't changed in the past MC versions

     

    Ok, i used code from EntityDiggingFX, now it's wirking fine! But when i used it before it's was crashing.

    P.S. Tuts that i found in google for older versions and/or crashing for me.

  12. For your first question, the particleMaxAge field is protected so you could use Java Reflection technique to modify it.

     

    For your second question, the Block class has an addDestroyEffects() method you can call. I think each call creates a single particle so you may have to call it several times to create a "burst" of particles.

    Thanks you!

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.