Jump to content

Recommended Posts

Posted

Hey there,
 

For our mod we want to copy the minecraft blockChest code and create a proxy between it.
The idea would be that the player thinks he is interacting with a normal chest, while he is really interacting with our special chest.
 

 ModelLoader.setCustomStateMapper(ModBlocks.blockMinecoloniesChest, new StateMapperBase() {
            @Override
            protected ModelResourceLocation getModelResourceLocation(final IBlockState state)
            {
                return new ModelResourceLocation(ModItems.permTool.getRegistryName(), INVENTORY) ;
            }
        });
        itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockMinecoloniesChest), 0,
                new ModelResourceLocation(Blocks.CHEST.getRegistryName(), INVENTORY));

I used these two to register the renderer.

And I made a copy of the tileEntity and the block.

But, unfortunately, I'm not able to see the block in my inventory (the world block renders just fine)

Exception on loading:

 

Quote

[11:38:33] [Client thread/ERROR] [FML]: Exception loading model for variant minecolonies:blockChest#facing=east for blockstate "minecolonies:blockChest[facing=east]"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model minecolonies:blockChest#facing=east with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:241) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:145) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:229) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:146) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:132) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:113) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:799) [Minecraft.class:?]
    at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:340) [FMLClientHandler.class:?]
    at net.minecraft.client.Minecraft.startGame(Minecraft.java:561) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:386) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1184) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 24 more

 



Additionally:

 

public void readFromNBT(NBTTagCompound compound)
    {
        super.readFromNBT(compound);


when I call super.readFromNbt it does give me an exception:

 

Quote

[11:45:49] [Server thread/ERROR] [FML]: A TileEntity type com.minecolonies.coremod.tileentities.TileEntityMinecoloniesChest has throw an exception trying to write state. It will not persist. Report this to the mod author
java.lang.RuntimeException: class com.minecolonies.coremod.tileentities.TileEntityMinecoloniesChest is missing a mapping! This is a bug!
    at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:95) ~[TileEntity.class:?]
    at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:86) ~[TileEntity.class:?]
    at net.minecraft.tileentity.TileEntityLockable.writeToNBT(TileEntityLockable.java:23) ~[TileEntityLockable.class:?]
    at net.minecraft.tileentity.TileEntityChest.writeToNBT(TileEntityChest.java:175) ~[TileEntityChest.class:?]
    at com.minecolonies.coremod.tileentities.TileEntityMinecoloniesChest.writeToNBT(TileEntityMinecoloniesChest.java:107) ~[TileEntityMinecoloniesChest.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:409) [AnvilChunkLoader.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:182) [AnvilChunkLoader.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunkData(ChunkProviderServer.java:205) [ChunkProviderServer.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:233) [ChunkProviderServer.class:?]
    at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:1062) [WorldServer.class:?]
    at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:414) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.saveAllWorlds(IntegratedServer.java:238) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:710) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
 

 

 

Posted

You can create your own model that would seem just like a chest. I mean, a chest model isn't that complicated, it is a 14x14x14 cube with a 1x2x1 lock :)

There is a way to bind TileEntitySpecialRenderers to Item+meta pairs(ForgeHooksClient::registerTESRItemStack) but it is marked as deprecated and is commented as 'Will be removed as soon as possible', so I wouldn't use it.

Posted

I mean I could simply copy the blockState and model and texture of minecraft and use that.
But I wanted to avoid that.

I mean if the models and items are already there in minecraft why can't I use them.

Posted

You can't. There is no model or a blockstate file for a chest, because Mojang hardcoded the rendering of the chest into the game's code. See TileEntityItemStackRenderer::renderByItem. It literally checks if the block if the itemstack being rendered is a chest and renders it as a tile entity if it is

Posted

okay, I just remembered I can simply drop a normal chest. I won't need the chest item in the inventory.
I just have to replace the chest on placement.

Anyway, here:

 

 ModelLoader.setCustomStateMapper(ModBlocks.blockMinecoloniesChest, new StateMapperBase() {
            @Override
            protected ModelResourceLocation getModelResourceLocation(final IBlockState state)
            {
                return new ModelResourceLocation(ModItems.permTool.getRegistryName(), INVENTORY) ;
            }
        });


I have "inventory". I think that isn't completely right. How do I get the ModelResourceLocation for the correct block?

(It works already quite well, the only problem are the particle effects)

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.