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.

Featured Replies

Posted

I'm currently making a steam generator and I found a small problem. I have no idea how to send a variable to the TileEntity. I'm currently using a packet to relay 2 ints, one for water amount and one for temperature but I can't set the ints from my main block class. Could someone give me an example on how to do this?

The proud(ish) developer of Ancients

main.NetworkHandler.sendToServer(new WaterSteamRequestPacket(tileEntityX,tileEntityY,tileEntityZ,waterAmount,tempAmount));

 

WaterSteamRequestHandlerPacket implements IMessageHandler<BaseNodeRequestPacket, IMessage>

{

@Override

public IMessage onMessage(BaseNodeRequestPacket message, MessageContext ctx)

{

TileEntitySteamPump te = (TileEntitySteamPump)ctx.getServerHandler().playerEntity.getEntityWorld().getTileEntity(message.x, message.y, message.z);

te.setWaterLevel(message.waterLevel);

te.setTemp(message.Temp);

return new WaterSteamResponsePacket(tileEntityX,tileEntityY,tileEntityZ,waterAmount,tempAmount);

}

}

 

the return sends another packet which is registered clientside to do the same thing. I'm assuming your GUI takes the tileEntity so you should be able to use the GUI to display te.getWaterLevel().

 

This is using the ISimpleMessageWrapper tutorial.

  • Author

I haven't actually figured out guis yet so there is no gui it's just currently a BlockContainer, a TileEntity and TileEntitySpecialRenderer. I will check out how to implement onMessage with my SteamGenerator class, and I'm using packets (the onDataPacket method).

The proud(ish) developer of Ancients

  • Author

also what does the BaseNodeRequest do? I have an error on it and theres no import.

The proud(ish) developer of Ancients

BaseNodeRequest oops I just copied one of my packets, that would be your WaterTempRequestPacket you can have a look at how the baseNode packet is made here

https://github.com/Hugo-the-Dwarf/Rise-of-Tristram/tree/master/src/main/java/ee/rot/comms

 

You can look at how I register them in my main mod file.

 

EDIT:

also you can call them whatever you want, I just use Request for Client to Server messages and Response for Server to Client messages. It's just what I name them as you could name your packets "WaterTempServer, and WaterTempClient" if you wanted to.

  • Author

...I just realized that I could use setters/getters sorry for wasting your time

The proud(ish) developer of Ancients

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.