Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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.

  • Author

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

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.

  • Author

Oh thanks, I forgot to check there ;P

(oh btw at the start I didn't think that a 1.13.x documentation would help, and plus it sooooo different for what actually happens in 1.14.x lol)

  • Author

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)

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.