Jump to content

Recommended Posts

Posted (edited)

Food item isn't rendering for me and I can't figure out why.

unknown.png

 

FoodBase

package com.zock629.firstmod.items;

import com.zock629.firstmod.Main;
import com.zock629.firstmod.init.ModItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemFood;

public class FoodBase extends ItemFood 
{
	
	public FoodBase(String name, int amount, float saturation, boolean isWolfFood) 
	{
		super(amount, saturation, isWolfFood);
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(CreativeTabs.FOOD);
		
		ModItems.ITEMS.add(this);
	}
	
	public void registerModels() 
	{
		Main.proxy.registerItemRenderer(this, 0, "inventory");
	}

}

 

DrinkBase

package com.zock629.firstmod.items;

import com.zock629.firstmod.Main;
import com.zock629.firstmod.init.ModItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class DrinkBase extends FoodBase
{
	
	public DrinkBase(String name, int amount, float saturation, boolean isWolfFood) {
		super(name, amount, saturation, isWolfFood);
		// TODO Auto-generated constructor stub
	}
	
	public void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
		player.inventory.addItemStackToInventory(new ItemStack(Item.getItemById(374)));
	}
	
	@Override
	public EnumAction getItemUseAction(ItemStack stack) {
	return EnumAction.DRINK;
	}	

}

 

ModItems

package com.zock629.firstmod.init;

import java.util.ArrayList;
import java.util.List;
import com.zock629.firstmod.items.DrinkBase;
import com.zock629.firstmod.items.FoodBase;
import com.zock629.firstmod.items.ItemBase;
import net.minecraft.item.Item;

public class ModItems 
{
	
	public static final List<Item> ITEMS = new ArrayList<Item>();
	
	public static final Item Ginger	= new ItemBase("ginger");
	public static final Item Ginger_Beer = new DrinkBase("ginger_beer", 1, 0.5F, false);

}

 

Json File

{
   "parent": "item/generated",
   "textures": {
       "layer0": "fm:items/ginger_beer"
   }
}

 

EDIT:

 

ClientProxy

package com.zock629.firstmod.proxy;

import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;

public class ClientProxy extends CommonProxy 
{
	public void registerItemRenderer(Item item, int meta, String id) 
	{
		ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), id));
	}
}

 

CommonProxy

package com.zock629.firstmod.proxy;

import net.minecraft.item.Item;

public class CommonProxy 
{
	public void registerItemRenderer(Item item, int meta, String id) {}
}

 

IHasModel

package com.zock629.firstmod.util;

public interface IHasModel 
{
	public void registerModels();
}

 

Edited by Zock629
Posted
47 minutes ago, diesieben07 said:
  • Do not create your items in a static initializer.
  • You need to show more of your code, you do not show where you register your models or items.

I updated to add more of the code I have let me know if I need to show more

Posted
36 minutes ago, Zock629 said:

I worked it out I forgot to put "implements IHasModel" into FoodBase

And this is why I think the IHasModel interface is stupid.

EVERYTHING NEEDS A MODEL.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.