DarkGuardsman
-
Posts
1479 -
Joined
-
Last visited
Posts posted by DarkGuardsman
-
-
For synchronising entities over to the client, data watchers are used, which should make your job easier. Look how the vanilla classes synchronise stuff like tamed state, etc.
cool, thank you i will try that out
-
Doing an if statement that compares the player's keyboard input might be what you need.
-
thank you for the responce
My code is based off a tuturial i read up on how to move from Modloadermp to Forge network. So some of my code is about a complete match at the moment. When i do code clean up when the mod works i'll go threw and rename/recode everything cleaner. Later on i'll build on the send data to have more than 2 int so thats why i keep the loop. Makes things easier when i start to send data that will be used in GUIs used to interface with the guard. Also i think the data has to be stored as a byte array inorder to be sent without overriding the first number.
The properties are set as ints to make it possible to send and store as an array. Int (i) is the team id and Int(j) is the weapon type. Both are set when SendType is called during updating of the entity. Texture is done client side by picking first the team color then the profession texture to go with the weapon.
-
In my mod i have a single EntityGuard.class that does everything related to that Entity. Part of the class is picking the weapon, team and texture of the Entity to be displayed to the player. The problem is that on smp every guard show up the same. Too fix this i'm trying to use Forge network packet system but nothing seem to be changing. Could someone help me with the code needed to send that data required for the guard entities to update correctly.
here the what i'm using to send the packet
public void SendType(int i, int j, Entity entity) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream data = new DataOutputStream(bytes); try { int[] coords = {i, j}; for(int a = 0; a < 2; a++) { data.writeInt(coords[a]); } } catch(IOException e) { e.printStackTrace(); } Packet250CustomPayload packet = new Packet250CustomPayload(); packet.channel = "mod_Guardsman"; packet.data = bytes.toByteArray(); packet.length = packet.data.length; ModLoader.getMinecraftServerInstance().configManager.sendPacketToAllPlayers(packet); }
and here is what is reciving it
public void onPacketData(NetworkManager network, String channel, byte[] bytes) { DataInputStream dataStream = new DataInputStream(new ByteArrayInputStream(bytes)); try { for(int i = 0; i < 3; i++) { coords[i] = dataStream.readInt(); } } catch(IOException e) { e.printStackTrace(); } }
[Help]client side updating of Entity
in General Discussion
Posted
ok i took a look at both client & server code for the Wolf. I found i'm using datawatchers already in the same way wolf.class does. So is there a special way to use datawatcher to get them to link from server to client.
here is client side EntityGuard class
And here is the server side