Jump to content

[SOLVED] [1.14.2] How to retrieve an ItemStackHandler while a TESR is rendering?


LeoCTH

Recommended Posts

I was trying to retrieve what item does the TileEntity current has (in a ItemStackHandler) in a TileEntityRenderer. It simply returns no items each time I want to access it.

My TileEntity code: https://github.com/LeoCTH/TryingOut/blob/master/src/main/java/com/leocth/tryingout/blocks/energy/ChargingStationTE.java

My TESR: https://github.com/LeoCTH/TryingOut/blob/master/src/main/java/com/leocth/tryingout/client/render/tile/RenderChargingStation.java

My Main Class: https://github.com/LeoCTH/TryingOut/blob/master/src/main/java/com/leocth/tryingout/TryingOut.java

 

P.S. It's been a long time since my last post.  I might have upset somebody on this forum while having a dispute, so my apologies ;P

Edited by LeoCTH
oops
Link to comment
Share on other sites

44 minutes ago, LeoCTH said:

I was trying to retrieve what item does the TileEntity current has (in a ItemStackHandler) in a TileEntityRenderer. It simply returns no items each time I want to access it.

You must sync the items in the ItemStackHandler to the client with a custom packet. And do this only whenever the contents change.

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

3 minutes ago, LeoCTH said:

Okay, how? I did look for methods related to packet related stuff and overrode it, but it still didn't work somehow ?

 

6 minutes ago, Animefan8888 said:

with a custom packet

Documentation here.

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

Problem solved!!! Thank you!

Just realized I don't need a custom packet tho, I can just use SUpdateTileEntityPacket and pass the NBT data on the packet when the player changes the item lol (don't criticize how I did it, just did a quick check, Botania used almost the same way xd)

Link to comment
Share on other sites

9 hours ago, LeoCTH said:

(don't criticize how I did it, just did a quick check, Botania used almost the same way xd) 

But critiques are helpful. It might be more network efficient if you make your own custom packet that only sends when the specific Item slot changes. But it's not my mod.

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

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.

×
×
  • Create New...

Important Information

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