Search in sources :

Example 1 with RailcraftOutputStream

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;
}
Also used : ByteBufOutputStream(io.netty.buffer.ByteBufOutputStream) RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with RailcraftOutputStream

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) {
    }
}
Also used : RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) PacketEffect(mods.railcraft.common.util.network.PacketEffect) IOException(java.io.IOException)

Example 3 with RailcraftOutputStream

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);
}
Also used : RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) PacketEffect(mods.railcraft.common.util.network.PacketEffect) IOException(java.io.IOException)

Example 4 with RailcraftOutputStream

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) {
    }
}
Also used : RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) PacketEffect(mods.railcraft.common.util.network.PacketEffect) IOException(java.io.IOException)

Example 5 with RailcraftOutputStream

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;
}
Also used : ByteBufOutputStream(io.netty.buffer.ByteBufOutputStream) RailcraftOutputStream(mods.railcraft.common.util.network.RailcraftOutputStream) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

RailcraftOutputStream (mods.railcraft.common.util.network.RailcraftOutputStream)8 IOException (java.io.IOException)7 PacketEffect (mods.railcraft.common.util.network.PacketEffect)4 ByteBuf (io.netty.buffer.ByteBuf)2 ByteBufOutputStream (io.netty.buffer.ByteBufOutputStream)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 FluidLogic (mods.railcraft.common.blocks.logic.FluidLogic)1 ILogicContainer (mods.railcraft.common.blocks.logic.ILogicContainer)1 StructureLogic (mods.railcraft.common.blocks.logic.StructureLogic)1 WaterGeneratorLogic (mods.railcraft.common.blocks.logic.WaterGeneratorLogic)1 GeneratorStatus (mods.railcraft.common.blocks.logic.WaterGeneratorLogic.GeneratorStatus)1 StandardTank (mods.railcraft.common.fluids.tanks.StandardTank)1 SlotOutput (mods.railcraft.common.gui.slots.SlotOutput)1 SlotRailcraft (mods.railcraft.common.gui.slots.SlotRailcraft)1 ToolTip (mods.railcraft.common.gui.tooltips.ToolTip)1 ToolTipLine (mods.railcraft.common.gui.tooltips.ToolTipLine)1 FluidGaugeWidget (mods.railcraft.common.gui.widgets.FluidGaugeWidget)1 LocalizationPlugin (mods.railcraft.common.plugins.forge.LocalizationPlugin)1 Streams (mods.railcraft.common.util.collections.Streams)1 IInventoryImplementor (mods.railcraft.common.util.inventory.IInventoryImplementor)1