Jump to content

[Solved]ghost Model?


darkfire123

Recommended Posts

As i was working on making a custom chest, every time I run my game i get this error for a dark_stonechest, but to my knowledge nowhere in my code do i mention it or my JSON mention it????

Exception loading model for variant dfm:dark_stonechest#inventory for item "dfm:dark_stonechest", normal location exception: 

 

// link to the full error

https://pastebin.com/aJw4rsZU 

 

I am also im noob when it comes to minecraft... but I have been taking classes in java! so im more of Advance noob lol

 

Spoiler

RegistryHandler ( and yes i'm using IHasModel, yes i know its redundant but right now I really don't feel like getting rid of it)

 


package com.df.dfmod.Utils.Handlers;

import com.df.dfmod.DFM_Main;
import com.df.dfmod.Init.DFMBlocks;
import com.df.dfmod.Init.DFMItems;
import com.df.dfmod.Init.Blocks.Animation.RenderDarkstoneChest;
import com.df.dfmod.Init.TileEntity.TileEntityDarkStoneChest;
import com.df.dfmod.Utils.Reference;
import com.df.dfmod.Utils.Utils;
import com.df.dfmod.Utils.Interface.IhasModel;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.item.Item;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;

@EventBusSubscriber
public class RegistryHandler {
	
	
	@SubscribeEvent
	public static void onItemRegister(RegistryEvent.Register<Item> event)
	{
		event.getRegistry().registerAll(DFMItems.ITEMS.toArray(new Item[0]));
	}
	
	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event)
	{	
		event.getRegistry().registerAll(DFMBlocks.BLOCKS.toArray(new Block[0]));
		TileEntityHandler.registerTileEntites();
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDarkStoneChest.class, new RenderDarkstoneChest() );
	}
	
	@SubscribeEvent
	public static void onModelRegister(ModelRegistryEvent event)
	{
		DFM_Main.proxy.RegisterItemRenderer(Item.getItemFromBlock(DFMBlocks.DARKSTONE_CHEST), 0, "Inventory");
		//System.out.println();
		
		for(Item item : DFMItems.ITEMS) {
			if(item instanceof IhasModel) {
				((IhasModel)item).registerModels();
			
				Utils.getlogger().info("items" + item.toString());
			}
		}
		
		for(Block block : DFMBlocks.BLOCKS) {
			if(block instanceof IhasModel) {
				((IhasModel)block).registerModels();
				
				Utils.getlogger().info("Blocks" + block.toString());
			}
		}
		
	}


	public static void initRegisteries() {
		Utils.getlogger().info("RegistryHandler: initRegisteries");
		NetworkRegistry.INSTANCE.registerGuiHandler(DFM_Main.instance, new GuiHandler());
		

	}
}

 

 

Spoiler

TileEntityDarkStoneChest

 


package com.df.dfmod.Init.TileEntity;

import com.df.dfmod.Init.Container.ContainerDarkStoneChest;
import com.df.dfmod.Utils.Reference;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ItemStackHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityLockableLoot;
import net.minecraft.util.ITickable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;

public class TileEntityDarkStoneChest extends TileEntityLockableLoot implements ITickable{

	private static NonNullList<ItemStack> chestContents =	NonNullList.<ItemStack>withSize(72, ItemStack.EMPTY);
    private NonNullList<ItemStack> items;
	public int numPlayersUsing, ticksSinceSync;
	public float lidAngle, prevLidAngle;
	
	
    public boolean hasBeenCleared;
    public boolean destroyedByCreativePlayer;

    public TileEntityDarkStoneChest() {
		System.out.println("TileEntityDarkStoneChest: " + getName());

	}
    
    
	@Override
	public int getSizeInventory() {
		return 72;
	}

	@Override
	public boolean isEmpty() {
		for (ItemStack stack: this.chestContents) {
			if(!stack.isEmpty()) {
				return false;
			}
		}
		return true;
	}

	@Override
	public int getInventoryStackLimit() {
		return 72;
	}

	@Override
	public String getName() {
		return this.hasCustomName() ? this.customName : "container.darkstone_chest";
	}
	
	@Override
	public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
		return new ContainerDarkStoneChest(playerInventory, this, playerIn);
	}

	@Override
	public String getGuiID() {
		return Reference.MODID + ":darkstone_chest";
	}

	
	@Override
	public void update() {
		if (!this.world.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + pos.getX() + pos.getY() + pos.getZ()) % 200 == 0)
        {
            this.numPlayersUsing = 0;
            float f = 5.0F;
 
            for (EntityPlayer entityplayer : this.world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB((double)((float)pos.getX() - 5.0F), (double)((float)pos.getY() - 5.0F), (double)((float)pos.getZ() - 5.0F), (double)((float)(pos.getX() + 1) + 5.0F), (double)((float)(pos.getY() + 1) + 5.0F), (double)((float)(pos.getZ() + 1) + 5.0F))))
            {
                if (entityplayer.openContainer instanceof ContainerDarkStoneChest)
                {      
                	if(((ContainerDarkStoneChest)entityplayer.openContainer).getChestInventory() == this) {
                		
                		++this.numPlayersUsing;
                	}
                }
            }
        }
       
        this.prevLidAngle = this.lidAngle;
        float f1 = 0.1F;
 
        if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F)
        {
            double d1 = (double)pos.getX() + 0.5D;
            double d2 = (double)pos.getZ() + 0.5D;
            this.world.playSound((EntityPlayer)null, d1, (double)pos.getY() + 0.5D, d2, SoundEvents.BLOCK_IRON_TRAPDOOR_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
        }
 
        if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F)
        {
            float f2 = this.lidAngle;
 
            if (this.numPlayersUsing > 0)
            {
                this.lidAngle += 0.1F;
            }
            else
            {
                this.lidAngle -= 0.1F;
            }
 
            if (this.lidAngle > 1.0F)
            {
                this.lidAngle = 1.0F;
            }
 
            float f3 = 0.5F;
 
            if (this.lidAngle < 0.5F && f2 >= 0.5F)
            {
                double d3 = (double)pos.getX() + 0.5D;
                double d0 = (double)pos.getZ() + 0.5D;
                this.world.playSound((EntityPlayer)null, d3, (double)pos.getY() + 0.5D, d0, SoundEvents.BLOCK_IRON_TRAPDOOR_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
            }
 
            if (this.lidAngle < 0.0F)
            {
                this.lidAngle = 0.0F;
            }
        }       		
	}
	
	
	@Override
	protected NonNullList<ItemStack> getItems() {
		return this.chestContents;
	}
	
	@Override
	public void readFromNBT(NBTTagCompound compound) {
		super.readFromNBT(compound);
		this.chestContents = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
		
		if(!this.checkLootAndRead(compound)) {
			ItemStackHelper.loadAllItems(compound, chestContents);
		}
		if(compound.hasKey(customName, 8)) {
			this.customName = compound.getString("CustomName");
		}
	}
	
	@Override
	public NBTTagCompound writeToNBT(NBTTagCompound compound) {
		super.writeToNBT(compound);
		if(!this.checkLootAndWrite(compound)) {
			ItemStackHelper.saveAllItems(compound, chestContents);
		}
		if (compound.hasKey(customName, 8)) {
			compound.setString("CustomName", this.customName);
		}
		return compound;
	}
	
	public NBTTagCompound saveToNbt(NBTTagCompound compound)
    {
        if (!this.checkLootAndWrite(compound))
        {
            ItemStackHelper.saveAllItems(compound, this.items, false);
        }

        if (this.hasCustomName())
        {
            compound.setString("CustomName", this.customName);
        }

        if (!compound.hasKey("Lock") && this.isLocked())
        {
            this.getLockCode().toNBT(compound);
        }

        return compound;
    }
	
	
	@Override
	public void openInventory(EntityPlayer player) {
		++this.numPlayersUsing;
		this.world.addBlockEvent(pos, this.getBlockType(), 1, this.numPlayersUsing);
		this.world.notifyNeighborsOfStateChange(pos, this.getBlockType(), false);
	}

	@Override
	public void closeInventory(EntityPlayer player) {
		--this.numPlayersUsing;
		this.world.addBlockEvent(pos, this.getBlockType(), 1, this.numPlayersUsing);
		this.world.notifyNeighborsOfStateChange(pos, this.getBlockType(), false);
	}


}

 

 

Spoiler

DarkStoneChest

 


package com.df.dfmod.Init.Blocks.CustomBlocks;

import com.df.dfmod.DFM_Main;
import com.df.dfmod.Init.DFMBlocks;
import com.df.dfmod.Init.DFMItems;
import com.df.dfmod.Init.TileEntity.TileEntityDarkStoneChest;
import com.df.dfmod.Utils.Reference;
import com.df.dfmod.Utils.Utils;
import com.df.dfmod.Utils.Interface.IhasModel;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityShulkerBox;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class DarkStoneChest extends BlockContainer implements IhasModel{

	public DarkStoneChest(String name, Material materialIn) {
		super(materialIn);
		
		setUnlocalizedName(name);
		setRegistryName(name);
		setCreativeTab(Reference.DFMTABS);
		setHarvestLevel("axe", 0);
		
		DFMBlocks.BLOCKS.add(this);
		DFMItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
		
		System.out.println("DarkStoneChest: " +name);

	}

	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileEntityDarkStoneChest();
	}

	@Override
	public void registerModels() {
		DFM_Main.proxy.RegisterItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
		
	}
	
	@Override
	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
		if(!worldIn.isRemote) {
			playerIn.sendMessage(new TextComponentString("opend"));
			playerIn.openGui(Reference.MODID, Reference.GUI_DARKSTONECHEST, worldIn, pos.getX(), pos.getY(), pos.getZ());
		}
		//playerIn.sendMessage(new TextComponentString("Right Clicked"));
		return true;
	}
	
	@Override
	public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
		TileEntity tileentity = worldIn.getTileEntity(pos);

	}
	
	
	@Override
	public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
		if(stack.hasDisplayName()) {
			TileEntity tileentity = worldIn.getTileEntity(pos);
			
			if(tileentity instanceof TileEntityDarkStoneChest) {
				((TileEntityDarkStoneChest)tileentity).setCustomName(stack.getDisplayName());
			}
				
		}
		super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
	}
	
	
	
	
	
	@Override
	public EnumBlockRenderType getRenderType(IBlockState state) {
		return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
	}
	
	@Override
	public boolean isFullBlock(IBlockState state) {
		return false;
	}
	
	@Override
	public boolean isFullCube(IBlockState state) {
		return false;
	}
	
	@Override
	public boolean isOpaqueCube(IBlockState state) {
		return false;
	}
	

}

 

 

Spoiler

RenderDarkstoneChest

 


package com.df.dfmod.Init.Blocks.Animation;

import java.util.Calendar;

import com.df.dfmod.Init.TileEntity.TileEntityDarkStoneChest;
import com.df.dfmod.Init.TileEntity.TileEntityDarkStone_Furnace;
import com.df.dfmod.Utils.Reference;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class RenderDarkstoneChest extends TileEntitySpecialRenderer<TileEntityDarkStoneChest>{
	private static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MODID + ":textures/blocks/darkstone_chest.png");     
	private final ModelDarkStoneChest  MODEL = new ModelDarkStoneChest();
	

	
	
	@Override
	public void render(TileEntityDarkStoneChest te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
		GlStateManager.enableDepth();
        GlStateManager.depthFunc(515);
        GlStateManager.depthMask(true);
       
        ModelDarkStoneChest model = MODEL;
       
        if (destroyStage >= 0)
        {
            this.bindTexture(DESTROY_STAGES[destroyStage]);
            GlStateManager.matrixMode(5890);
            GlStateManager.pushMatrix();
            GlStateManager.scale(4.0F, 4.0F, 1.0F);
            GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
            GlStateManager.matrixMode(5888);
        }
        else this.bindTexture(TEXTURE);
       
        GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
       
        float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
        f = 1.0F - f;
        f = 1.0F - f * f * f;
        model.lid.rotateAngleX = -(f * ((float)Math.PI / 2F));
        model.renderAll();
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
 
        if (destroyStage >= 0)
        {
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        }   
	}
	

}

 

 

Spoiler

ModelDarkStoneChest

 


package com.df.dfmod.Init.Blocks.Animation;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

/**
 * ModelChest - Either Mojang or a mod author
 * Created using Tabula 6.0.0
 */

@SideOnly(Side.CLIENT)
public class ModelDarkStoneChest extends ModelBase {
	public ModelRenderer handle = (new ModelRenderer(this, 0, 0)).setTextureSize(64, 64);
	//public ModelRenderer handle;
    public ModelRenderer lid;
    public ModelRenderer storage;

    public ModelDarkStoneChest() {
        this.textureWidth = 64;
        this.textureHeight = 64;
        
        this.lid = new ModelRenderer(this, 0, 0);
        this.lid.setRotationPoint(1.0F, 7.0F, 15.0F);
        this.lid.addBox(0.0F, -5.0F, -14.0F, 14, 5, 14, 0.0F);
        
        this.storage = new ModelRenderer(this, 0, 19);
        this.storage.setRotationPoint(1.0F, 6.0F, 1.0F);
        this.storage.addBox(0.0F, 0.0F, 0.0F, 14, 10, 14, 0.0F);
        
        this.handle = new ModelRenderer(this, 0, 0);
        this.handle.setRotationPoint(8.0F, 7.0F, 15.0F);
        this.handle.addBox(-1.0F, -2.0F, -15.0F, 2, 4, 1, 0.0F);
    }

    @Override
    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { 
        this.lid.render(f5);
        this.storage.render(f5);
        this.handle.render(f5);
    }

  public void renderAll() {
	  this.handle.rotateAngleX = this.lid.rotateAngleX;
	  this.lid.render(0.0625f);
	  this.handle.render(0.0625f);
	  this.storage.render(0.0625f);
  }
}

 

 

let me know if you need any other classes or  other information

 

Also some other Thought i wanted to know was if i still need a block state for the custom Chest or if it dosn't need one like the vanilla chest

 

Edited by darkfire123
Solved
Link to comment
Share on other sites

5 hours ago, darkfire123 said:

DFM_Main.proxy.RegisterItemRenderer(Item.getItemFromBlock(this), 0, "inventory");

Hmmm, I wonder. By the way just for clarification you're getting this error for two reasons. You dont have an item model at the correct location and B you didn't specify the "inventory" variant in your blockstate json.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Well i f-ed lol looking though my code i relized that the model of dark_stonechest was missing for my item...

DarkStone chest..plate....

 

as for the IHasModel Register i found out that its not needed because i was creating a model using TESR ...

thanks for the help! @Animefan8888

 

next on my list why my item texture for my chest is in-viable ?

Link to comment
Share on other sites

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.