Jump to content

Recommended Posts

Posted (edited)

I made a custom potion item that extends PotionItem and it works perfectly. I provided it with a multi-layer model with two layers, one for the "glass bottle" and one for the "potion liquid". However, when I loaded in, all of the custom potions used the same, default texture. So I went into ItemColors and tried to replicate the code that registers the colors of other potion variants using PotionUtils.getColor. Even though the game didn't crash, the colors of the potions didn't change.

I've checked multiple threads on this forum about similar issues, but they are either outdated and some of the methods don't work or they are only tangentially related.

TLDR: How do I change the color of my custom potions' texture to match the effect?

Here is my code for my potion item:

//Commented out imports

public class GelledPotionItem extends PotionItem
{
	public GelledPotionItem(Item.Properties builder)
	{
		super(builder);
	}
	public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity entityLiving) 
	{
		return null;
	}
	public int getUseDuration(ItemStack stack)
	{
		return 0;
	}
	public UseAction getUseAction(ItemStack stack) 
	{
		return null;
	}
	public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) 
	{
		return null;
		
	}
}

Here is my main class:

// Commented out imports

// The value here should match an entry in the META-INF/mods.toml file
@Mod("minormagicks")
public class MinorMagicks
{
	public static MinorMagicks instance;
    private static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "minormagicks";
    public MinorMagicks() 
    {
    	instance = this;
    	
    	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
    	
        modEventBus.addListener(this::setup);
        modEventBus.addListener(this::doClientStuff);
       
        ItemRegistryHandler.ITEMS.register(modEventBus);
        PotionRegistryHandler.POTIONS.register(modEventBus);
        MinecraftForge.EVENT_BUS.register(this);
        MinecraftForge.EVENT_BUS.register(new MinorMagicksForgeEventHandler());

    }

    private void setup(final FMLCommonSetupEvent event)
    {
    	MagicksItemColors.registerColors();
    	PotionRegistryHandler.replaceRecipes();
    	MagicksPotionBrewing.init();
    }
    private void doClientStuff(final FMLClientSetupEvent event) 
    {
    	
    }
}

My model json for my item:

{
  "parent": "item/generated",
  "textures": {
	"layer0": "minormagicks:items/gelled_potion_liquid",
	"layer1": "minormagicks:items/gelled_potion"
  }
}

 

Edited by OberonPuck

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.