Hi, and heave a nice day!
I want to make a mod with many abilities. One part of it is to handle tasks or checkpoints to trigger "ages". So I want to block some crafting recipes until a pleyer reach the needed "level". Remove a recipe server-wide is easy but I don't know how to remove recipes only for players corectly.
I tried a very primitiv work-around but it has several problems:
@SubscribeEvent
public void onCraft(ItemCraftedEvent event) {
if (event.crafting.getItem().getRegistryName().toString().contains("minecraft:wooden_sword")) {
event.player.inventory.clearMatchingItems(Item.getByNameOrId("minecraft:wooden_sword"), -1, 1, null);
}
}
@SubscribeEvent
public void pickUp(EntityItemPickupEvent event) {
if (event.getEntity() instanceof EntityPlayer) {
if (event.getItem().getEntityItem().getItem().getRegistryName().toString().contains("minecraft:wooden_sword")) {
event.setCanceled(true);
}
}
}
The first part is removing the output from the players inventory. But the player is loosing the ingridients.
The second part destroying the items on pickup, because the player can pres "Q" in the workbench to drop the item.
Is it posible to prevent the player from taking the result out of the workbench? The ingridients should stay in the bench. I tried to cancel the event, but then the client crashes. Also is there a event for "event.getEntityPlayer().inventory.inventoryChanged"? I want to drop the item when a player gets a forbidden item.
Thank you very much for your help.