Posted September 19, 201411 yr 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
September 19, 201411 yr 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. Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
September 19, 201411 yr 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
September 19, 201411 yr Author also what does the BaseNodeRequest do? I have an error on it and theres no import. The proud(ish) developer of Ancients
September 19, 201411 yr 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. Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
September 19, 201411 yr 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.