forked from NightKosh/Gravestone-mod-Graves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraveStonePacketHandler.java
47 lines (44 loc) · 1.9 KB
/
GraveStonePacketHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package GraveStone;
import GraveStone.tileentity.TileEntityGSGrave;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*
*/
public class GraveStonePacketHandler implements IPacketHandler {
@Override
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
if (packet.channel.equals("GSDeathText")) {
//System.out.println("!!!!!!!!!!!!!!!!");
World world = ((EntityPlayer) player).worldObj;
if (world != null) {
//System.out.println("world != null ");
DataInputStream InputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
try {
//System.out.println(((EntityPlayer) player).posX + " " + ((EntityPlayer) player).posZ + " ");
TileEntity tileEntity = world.getBlockTileEntity(InputStream.readInt(), InputStream.readInt(), InputStream.readInt());
if (tileEntity != null) {
String str = InputStream.readUTF();
((TileEntityGSGrave) tileEntity).setDeathText(str);
//System.out.println("te != null ");
//System.out.println(str);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}