Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Posts posted by PegBeard

  1. Getting the thrower's held item and reading the NBT from there was what I thought I should do, but I was unsure where to put the code.

    If I put it in onImpact it would create a slight bug, and I couldn't see an 'onSpawn' type event for EntityThrowable.

    I have the code for handling the NBT and what to do for the result, just wondering where the most efficient place for it would be.

    Would I perhaps need to get the item to write to the entityNBT in the method that spawns the entity?

  2. I was wondering if it was possible to get a projectile to read NBT data from the player's currently equipped item, preferably when it is spawned.

    I have had a look at a few vanilla projectiles but I couldn't see anything helpful (though it is late and I may have missed something in my fatigue), EntityPotion has a method for writing/reading entity NBT data though I am not sure how to use it to my advantage, and Google didn't turn up anything either.

  3. This is the way I am attempting to check only the hotbar for the ammo, but it seems to checking for anything in the hotbar and then for the ammo in the rest of my inventory and firing from there.


    	public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
            ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
            if (event.isCanceled())
                return event.result;
            for (int i = 0; i < 9; i++)
            	if (par3EntityPlayer.inventory.getStackInSlot(i) != null)
            		if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.wheat_seeds)  || par3EntityPlayer.inventory.hasItem(Items.pumpkin_seeds) || par3EntityPlayer.inventory.hasItem(Items.melon_seeds)  || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.ironNugget) || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.pyriteDust))
            			par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
      	  	return par1ItemStack;


    I am guessing this bit is my main issue - if (par3EntityPlayer.inventory.getStackInSlot(i) != null) - as I'm not specifying a specific item to search for and stop on, but it wouldn't except a specific Item and I'm not sure how getStackInSlot works, if I am honest.

    I only have a basic understanding of Java, so I probably look like a bit of a numpty, but making an MC mod is an attempt to get better at it.

  4. I have made a projectile weapon which is able to shoot a variety of projectiles based on the ammunition in the players inventory. Currently, it fires all applicable types of ammo, but I would like it to only detect ammo that is on the players hotbar.

    I have been playing around with getStackInSlot and designating the hotbar slots, but that isn't really doing what I want it to - unless I have missed something.

    I am not overly familiar with all the functions of MC/Forge, as I've only been at this for a week or so and I was wondering if there was a way to detect a specific item in the players hotbar, that isn't the held item - specifically I want this to happen on right click with the weapon, to determine if applicable ammo is present and the weapon can be fired.

  5. Nevermind, I worked it out about 2 minutes after making this post.



    ---------I am new to modding and, as such, I'm not familiar with all methods/events.

    I have added a couple of hammers to my mod and would like to make them attack slower, for balancing reasons.

    I have already gotten a Mining Fatigue potion effect to slow the animation, but I want to add a actual debuff to attack speed when the hammer is being held, similar to how TC's cleaver works.


    I have googled my way into a dead end and I am out of ideas, so any suggestions, examples, or a push in the right direction would be much appreciated.--------------

  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.