Alexmaster75 Posted June 27, 2022 Posted June 27, 2022 (edited) Hi i would like some help to cast my custom item into a method Vanilla Minecraft uses to return an empty bottle to the player after the use, the class i'm using as pattern it's "HoneyBottleItem" (forge_snapshot > net > minecraft > item > HoneyBottleItem). The issue i'm occurring it's not recognizing the custom item of the mod, substituted with the glass bottle of Minecraft, here's my version: package net.alexmaster75.tea.item.custom; import net.alexmaster75.tea.item.TeaItems; import net.minecraft.advancements.CriteriaTriggers; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.stats.Stats; import net.minecraft.world.World; public class TeaCupConsume extends Item { public TeaCupConsume(Properties properties) { super(properties); } public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) { super.onItemUseFinish(stack, worldIn, entityLiving); if (entityLiving instanceof ServerPlayerEntity) { ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)entityLiving; CriteriaTriggers.CONSUME_ITEM.trigger(serverplayerentity, stack); serverplayerentity.addStat(Stats.ITEM_USED.get(this)); } if (stack.isEmpty()) { return new ItemStack(TeaItems.EMPTY_CUP); // <- Error: Required type: IItemProvider // Provided: RegistryObject <net.minecraft.item.Item> } else { if (entityLiving instanceof PlayerEntity && !((PlayerEntity)entityLiving).abilities.isCreativeMode) { ItemStack itemstack = new ItemStack(TeaItems.EMPTY_CUP); // <- Same error PlayerEntity playerentity = (PlayerEntity)entityLiving; if (!playerentity.inventory.addItemStackToInventory(itemstack)) { playerentity.dropItem(itemstack, false); } } return stack; } } } ^ My Version It may seem a stupid error but i'm not getting the solution Thanks Edited June 27, 2022 by Alexmaster75 Removed Vanilla code Quote
Alpvax Posted June 27, 2022 Posted June 27, 2022 You need to actually get the Item instance form the registry (by calling #get). Also, DON'T SHARE VANILLA CODE! You do not have the rights to share it, and we can all look it up for ourselves. 1 Quote
Alexmaster75 Posted June 27, 2022 Author Posted June 27, 2022 Also thanks you so much, now it works! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.