'Item is Smelted' trigger not working

Started by Mindthemoods on Mon, 05/23/2022 - 23:06

Topic category: Troubleshooting, bugs, and solutions

Last seen on 18:45, 10. Aug 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
'Item is Smelted' trigger not working
Mon, 05/23/2022 - 23:06

I spent a while trying to make a system that would put an empty bucket in a furnace slot when a milk bucket is smelted- eventually it occurred to me to test if the 'item is smelted' trigger was working- I made some basic procedures to create messages when an item was smelted, none of which worked. As far as I can tell, the trigger is non-functional in the latest version. 

Last seen on 18:45, 10. Aug 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
This is the original code I…
Mon, 05/23/2022 - 23:38

This is the original code I came up with. When the milk bucket is smelted, it should produce a wheel of cheese, and leave an empty bucket in the input slot. I've tried countless variations of this, none of which have worked- leading me to think that the trigger itself is the issue. (This is generated from the block code.)

package net.mcreator.cookingwithmindthemoods.procedures;

/* imports omitted */

@Mod.EventBusSubscriber
public class SaveBucketProcedure {
	@SubscribeEvent
	public static void onItemSmelted(PlayerEvent.ItemSmeltedEvent event) {
		execute(event, event.getPlayer().level, event.getPlayer().getX(), event.getPlayer().getY(), event.getPlayer().getZ(), event.getSmelting());
	}

	public static void execute(LevelAccessor world, double x, double y, double z, ItemStack itemstack) {
		execute(null, world, x, y, z, itemstack);
	}

	private static void execute(@Nullable Event event, LevelAccessor world, double x, double y, double z, ItemStack itemstack) {
		if (itemstack.getItem() == CookingWithMindthemoodsModItems.CHEESE_WHEEL_ITEM.get()) {
			{
				BlockEntity _ent = world.getBlockEntity(new BlockPos(x, y, z));
				if (_ent != null) {
					final int _slotid = 0;
					final ItemStack _setstack = new ItemStack(Items.BUCKET);
					_setstack.setCount(1);
					_ent.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null).ifPresent(capability -> {
						if (capability instanceof IItemHandlerModifiable)
							((IItemHandlerModifiable) capability).setStackInSlot(_slotid, _setstack);
					});
				}
			}
		}
	}
}

 

Last seen on 18:45, 10. Aug 2022
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
...The solution I eventually…
Tue, 05/24/2022 - 00:28

...The solution I eventually came to was to just have smelting milk give a 'bucket of cheese,' which can then be used to place a cheese wheel and return an empty bucket. (I actually think it looks better!) ...However, I'm pretty sure the trigger is still broken. Worth looking into.