use of mods.railcraft.common.util.network.RailcraftOutputStream in project Railcraft by Railcraft.
the class RailcraftTileEntity method getUpdateTag.
@Override
public final NBTTagCompound getUpdateTag() {
NBTTagCompound nbt = super.getUpdateTag();
ByteBuf byteBuf = Unpooled.buffer();
try (ByteBufOutputStream out = new ByteBufOutputStream(byteBuf);
RailcraftOutputStream data = new RailcraftOutputStream(out)) {
writePacketData(data);
} catch (IOException e) {
Game.logThrowable("Error constructing tile packet: {0}", e, getClass());
if (Game.DEVELOPMENT_ENVIRONMENT)
throw new RuntimeException(e);
}
nbt.setByteArray("sync", byteBuf.array());
return nbt;
}
use of mods.railcraft.common.util.network.RailcraftOutputStream in project Railcraft by Railcraft.
the class CommonEffectProxy method fireSparkEffect.
@Override
public void fireSparkEffect(World world, Vec3d start, Vec3d end) {
if (Game.isClient(world))
return;
try {
PacketEffect pkt = new PacketEffect(Effect.FIRESPARK);
RailcraftOutputStream data = pkt.getOutputStream();
data.writeVec3d(start);
data.writeVec3d(end);
pkt.sendPacket(world, start);
} catch (IOException ignored) {
}
}
use of mods.railcraft.common.util.network.RailcraftOutputStream in project Railcraft by Railcraft.
the class CommonEffectProxy method teleportEffect.
@Override
public void teleportEffect(Entity entity, Vec3d destination) {
if (Game.isClient(entity.worldObj))
return;
try {
PacketEffect pkt = new PacketEffect(Effect.TELEPORT);
RailcraftOutputStream data = pkt.getOutputStream();
data.writeVec3d(entity.getPositionVector());
data.writeVec3d(destination);
pkt.sendPacket(entity.worldObj, entity.getPositionVector());
} catch (IOException ignored) {
}
SoundHelper.playSoundAtEntity(entity, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.25F, 1.0F);
}
use of mods.railcraft.common.util.network.RailcraftOutputStream in project Railcraft by Railcraft.
the class CommonEffectProxy method zapEffectDeath.
@Override
public void zapEffectDeath(World world, Object source) {
if (Game.isClient(world))
return;
try {
PacketEffect pkt = new PacketEffect(Effect.ZAP_DEATH);
RailcraftOutputStream data = pkt.getOutputStream();
EffectManager.IEffectSource es = EffectManager.getEffectSource(source);
data.writeVec3d(es.getPosF());
pkt.sendPacket(world, es.getPosF());
} catch (IOException ignored) {
}
}
use of mods.railcraft.common.util.network.RailcraftOutputStream in project Railcraft by Railcraft.
the class TileRailcraft method getUpdateTag.
@Override
public final NBTTagCompound getUpdateTag() {
NBTTagCompound nbt = super.getUpdateTag();
ByteBuf byteBuf = Unpooled.buffer();
try (ByteBufOutputStream out = new ByteBufOutputStream(byteBuf);
RailcraftOutputStream data = new RailcraftOutputStream(out)) {
writePacketData(data);
byte[] syncData = new byte[byteBuf.readableBytes()];
byteBuf.readBytes(syncData);
nbt.setByteArray("sync", syncData);
} catch (IOException e) {
Game.log().throwable("Error constructing tile packet: {0}", e, getClass());
if (Game.DEVELOPMENT_VERSION)
throw new RuntimeException(e);
} finally {
byteBuf.release();
}
return nbt;
}
Aggregations