No ammo necessary

Started by Flixnelon on Fri, 08/04/2017 - 13:01

Topic category: Help with MCreator modding

Last seen on 16:52, 6. Aug 2017
Joined Aug 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
No ammo necessary
Fri, 08/04/2017 - 13:01

Hey, I'm making a weapon that wouldn't need any ammo in my inventory (but would shoot out a texturized ball of air). However, I can't find an "air" block in the option for the ammo (specially since it only shows items and no blocks). How do I make the gun not need ammo?

 

Also, is there a way around having to create an uncraftable item to be the texture of the bullet when it's shot? I know it sounds silly, but basically it's like an air ball shooter - no need for any ammo but when it shoots, shoots out a ball.

 

Thanks!

Last seen on 19:56, 11. Aug 2019
Joined Aug 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
For the first question, air
Sat, 08/12/2017 - 18:26

For the first question, air is the first thing that pops up in the block list. But having air as ammo hasn't worked for me in survival mode.

For the second question, simply add an item that doesn't have any crafting recipie by not adding it at the end of making an item.

Last seen on 22:55, 20. Aug 2019
Joined May 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Hey I can fix this problem…
Thu, 11/02/2017 - 19:34

Hey I can fix this problem do as follows:

1- Remove the crafting recipe for the weapon your making

2- Make a new recipe as another mod element

3- Add the recipe for the gun and choose the gun as a result

4- Add the infinity enchantment to it when it is crafted

5- Make the ammo be the gun itself and your done

Last seen on 23:44, 18. Aug 2019
Joined Apr 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
To my knowledge, bow…
Thu, 11/02/2017 - 21:42

To my knowledge, bow enchantments do not work on Mcreator guns, so while you COULD technically enchant it with infinity, the gun would still consume itself as ammo and end up being a throwable item like a snowball

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
In onItemRightClick() method…
Thu, 11/02/2017 - 23:19

In onItemRightClick() method of the gun Item class , 1st remove:

 

boolean flag = par3EntityPlayer.capabilities.isCreativeMode
					|| EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, par1ItemStack) > 0;

			if (flag || par3EntityPlayer.inventory.hasItemStack(new ItemStack(SOME_ITEM))) {

This part actually does the check for item in inventory or the infinity enchantment

Then remove:
 

if (flag) {
					entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
				} else {
					par3EntityPlayer.inventory.clearMatchingItems(new ItemStack(SOME_ITEM).getItem(), -1, 1, null);
				}

This part actually does remove the item from inventory if the infinity enchantment is not used, and if the enchantment is used, it prevents the EntityArrow from being picked up.

The last step is simply balacing the brackets , so remove just one bracket before the return statement of the method.