mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
71 lines
1.5 KiB
Java
71 lines
1.5 KiB
Java
package com.hbm.packet;
|
|
|
|
import com.hbm.tileentity.bomb.TileEntityTurretBase;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
import io.netty.buffer.ByteBuf;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
public class TETurretPacket implements IMessage {
|
|
|
|
int x;
|
|
int y;
|
|
int z;
|
|
double yaw;
|
|
double pitch;
|
|
|
|
public TETurretPacket()
|
|
{
|
|
|
|
}
|
|
|
|
public TETurretPacket(int x, int y, int z, double yaw, double pitch)
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
this.z = z;
|
|
this.yaw = yaw;
|
|
this.pitch = pitch;
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf buf) {
|
|
x = buf.readInt();
|
|
y = buf.readInt();
|
|
z = buf.readInt();
|
|
yaw = buf.readDouble();
|
|
pitch = buf.readDouble();
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf buf) {
|
|
buf.writeInt(x);
|
|
buf.writeInt(y);
|
|
buf.writeInt(z);
|
|
buf.writeDouble(yaw);
|
|
buf.writeDouble(pitch);
|
|
}
|
|
|
|
public static class Handler implements IMessageHandler<TETurretPacket, IMessage> {
|
|
|
|
@Override
|
|
public IMessage onMessage(TETurretPacket m, MessageContext ctx) {
|
|
try {
|
|
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
|
|
|
if (te != null && te instanceof TileEntityTurretBase) {
|
|
|
|
TileEntityTurretBase turret = (TileEntityTurretBase) te;
|
|
turret.rotationYaw = m.yaw;
|
|
turret.rotationPitch = m.pitch;
|
|
}
|
|
} catch(Exception ex) {
|
|
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|