Jump to content

[1.10.2] A few questions about porting from 1.8.9


Roboguy99

Recommended Posts

So I've been porting my mod from 1.8.9 to 1.10.2, and for the most part I've been able to do so without an issue. There are a few things I've been unable to fix, however:

 

1) `Block#setBlockBounds()` apparently no longer exists. What is the replacement for this?

2) What is the purpose of the new return value on `TileEntity#writeToNBT()`? Is it safe to just ignore it?

3) (This is probably the larger question) `IFlexibleBakedModel` has gone. I previously wrote (with a LOT of help from Diesieben) rendering code so my item displayed using a different model in the player's hand compared to everywhere else. Is this an easy fix, and how would I go about updating this? See here for code.

 

Any help is greatly appreciated. And just so you know my knowledge of the model system is pretty lacking.

I have no idea what I'm doing.

Link to comment
Share on other sites

Ok that helps loads, thanks a lot.

 

One thing:

 

`if(!(model instanceof IBakedModel)) model = new IBakedModel.Wrapper(model, DefaultVertexFormats.ITEM)`

 

The wrapper class no longer exists. What does this need to be, if this line needs to exist at all?

 

Also, upon attempting to render the item the game crashes with a NullPointerException:

 

 

net.minecraft.util.ReportedException: Rendering item
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1174) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1139) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:406) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
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_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.NullPointerException
at net.minecraft.client.renderer.RenderItem.getItemModelWithOverrides(RenderItem.java:254) ~[RenderItem.class:?]
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:356) ~[RenderItem.class:?]
at net.minecraft.client.renderer.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:345) ~[RenderItem.class:?]
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawTab(GuiContainerCreative.java:922) ~[GuiContainerCreative.class:?]
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:747) ~[GuiContainerCreative.class:?]
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:94) ~[GuiContainer.class:?]
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:59) ~[inventoryEffectRenderer.class:?]
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:634) ~[GuiContainerCreative.class:?]
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:374) ~[ForgeHooksClient.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1147) ~[EntityRenderer.class:?]
... 15 more

 

 

I haven't got time to properly debug this at the moment, so is there anything obvious? My two existing theories are a) it's to do with the line above (I commented it out to test) or b) it's the bottom 2 methods in the class returning null (what should they be returning?)

I have no idea what I'm doing.

Link to comment
Share on other sites

Sorry to bring this up again after so long, but I haven't had the time to play around since you replied.

 

I have (as far as I can tell) done what you said, and I'm still getting a NullPointerException. It is is a different place this time though:

 

 

---- Minecraft Crash Report ----
// Daisy, daisy...

Time: 06/08/16 15:20
Description: Rendering screen

java.lang.NullPointerException: Rendering screen
at net.minecraft.client.renderer.RenderItem.renderItemOverlayIntoGUI(RenderItem.java:429)
at net.minecraft.client.renderer.RenderItem.renderItemOverlays(RenderItem.java:399)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawTab(GuiContainerCreative.java:923)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawGuiContainerBackgroundLayer(GuiContainerCreative.java:747)
at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:94)
at net.minecraft.client.renderer.InventoryEffectRenderer.drawScreen(InventoryEffectRenderer.java:59)
at net.minecraft.client.gui.inventory.GuiContainerCreative.drawScreen(GuiContainerCreative.java:634)
at net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:374)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1147)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1139)
at net.minecraft.client.Minecraft.run(Minecraft.java:406)
at net.minecraft.client.main.Main.main(Main.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
at GradleStart.main(GradleStart.java:26)

 

 

As far as I can tell, nothing from my BakedModel class is null, and it's quite difficult to put breakpoints in item render code due to how often it executes.

 

I hope this is an easy fix and me being stupid, thanks for any help.

I have no idea what I'm doing.

Link to comment
Share on other sites

Show your code again and what is RenderItem line 429 for you?

 

Code is on GitHub, same link as before.

 

https://github.com/JakeStanger/Chemistry/blob/master/src/main/java/roboguy99/chemistry/item/element/render/BakedModelElement.java

 

Line 429 is

if (stack.getItem().showDurabilityBar(stack))

 

Forge version 1.10.2-12.18.1.2011 just so you know.

I have no idea what I'm doing.

Link to comment
Share on other sites

Something is causing there to be an ItemStack with a null item.

I suspect this is because you are creating ItemStacks for your Blocks but they don't have an ItemBlock registered.

 

Hmm, I'm registering items rather than blocks, and just to make sure I've disabled all blocks from my mod. I am a little unsure with the new registry system though. Is this correct?

 

this.setRegistryName(name);
GameRegistry.register(this);

 

(where

this 

is a class extending

Item

)

 

The game launches correctly, but maybe it's the problem...?

I have no idea what I'm doing.

Link to comment
Share on other sites

Eh, no you are definitely also registering Blocks. Or at least one Block: https://git.io/v63IP. This Block does not have an ItemBlock, meaning it cannot exist in any inventory or as an item entity, etc. It can only exit placed down in the world.

 

I've commented the registry line out: https://github.com/JakeStanger/Chemistry/blob/master/src/main/java/roboguy99/chemistry/block/BlockCompoundCreator.java#L30

 

I'll try actually registering an ItemBlock still and see if that makes a difference still though.

 

P.S. how do you get shortened GitHub links?

I have no idea what I'm doing.

Link to comment
Share on other sites

Well I registered the ItemBlock and it worked perfectly.

 

I then thought about why it crashed when I didn't register the block.

 

I then realised the block is used as a creative tab icon, so it crashed.

 

Whoops.  :-\

 

--

 

Thanks for the help, I'll look at those two other things you just mentioned and change them accordingly.

 

I have no idea what I'm doing.

Link to comment
Share on other sites

Well I registered the ItemBlock and it worked perfectly.

 

I then thought about why it crashed when I didn't register the block.

 

I then realised the block is used as a creative tab icon, so it crashed.

 

Whoops.  :-\

 

--

 

Thanks for the help, I'll look at those two other things you just mentioned and change them accordingly.

 

EDIT: Ah, you picked it up before I did. I just didn't read your reply in time. Thanks again.

I have no idea what I'm doing.

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.