Can't Figure Out Right Click Interaction

Started by Eclips3 on

Topic category: Advanced modding

Last seen on 14:36, 13. Jun 2020
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can't Figure Out Right Click Interaction

I'm fairly new to coding, mostly getting through with tutorials.

In my mod, I wanted to make an enchantment, and that's what I did. My problem is making the enchantment functional. It's an Auto Smelt enchant and runs off of a procedure. The procedure isn't the problem. I need to call the procedure with the proper dependencies (which in my case are "itemstack", the tool with the enchantment, "world", the world, and "x", "y" and "z", the coordinates of the block that is to be auto smelted). You auto smelt the block by right-clicking, giving you the ability to choose whether or not you can auto smelt it. Can anybody help me with this?

Here is the code for the function of the enchant.

    @SubscribeEvent
	public ActionResultType onItemUse(LivingUpdateEvent event) {
		LivingEntity living = event.getEntityLiving();
		int level = EnchantmentHelper.getMaxEnchantmentLevel(ModEnchantments.auto_smelt, living);
		if(level>0) {
			World world = living.getEntityWorld();
			BlockPos pos = living.getPosition();
			int x = pos.getX();
			int y = pos.getY();
			int z = pos.getZ();
			ItemStack itemstack = living.getHeldItemMainhand();
			{
				java.util.HashMap<String, Object> $_dependencies = new java.util.HashMap<>();
				$_dependencies.put("entity", living);
				$_dependencies.put("x", x);
				$_dependencies.put("y", y);
				$_dependencies.put("z", z);
				$_dependencies.put("itemstack", itemstack);
				$_dependencies.put("world", world);
				AutoSmeltProcedure.executeProcedure($_dependencies);
			}	
		}
	}

At the current moment, it's only a LivingUpdateEvent, as I don't really know what to put there to recognize a right-click.

Last seen on 14:36, 13. Jun 2020
Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I took a break from it and…
Thu, 05/14/2020 - 01:49

I took a break from it and figured it out.