Java Code Examples for net.minecraft.network.PacketBuffer#writeBlockPos()

The following examples show how to use net.minecraft.network.PacketBuffer#writeBlockPos() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PhysicsObject.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
public void writeSpawnData(ByteBuf buffer) {
    PacketBuffer modifiedBuffer = new PacketBuffer(buffer);

    modifiedBuffer.writeInt(getOwnedChunks().getCenterX());
    modifiedBuffer.writeInt(getOwnedChunks().getCenterZ());
    modifiedBuffer.writeInt(getOwnedChunks().getRadius());

    modifiedBuffer.writeDouble(getWrapperEntity().posX);
    modifiedBuffer.writeDouble(getWrapperEntity().posY);
    modifiedBuffer.writeDouble(getWrapperEntity().posZ);

    modifiedBuffer.writeDouble(getWrapperEntity().getPitch());
    modifiedBuffer.writeDouble(getWrapperEntity().getYaw());
    modifiedBuffer.writeDouble(getWrapperEntity().getRoll());

    getCenterCoord().writeToByteBuf(modifiedBuffer);

    // Make a local copy to avoid potential data races
    BlockPos physicsInfuserPosLocal = getPhysicsInfuserPos();
    modifiedBuffer.writeBoolean(physicsInfuserPosLocal != null);
    if (physicsInfuserPosLocal != null) {
        modifiedBuffer.writeBlockPos(physicsInfuserPosLocal);
    }
}
 
Example 2
Source File: MetaTileEntityMultiblockPart.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void writeInitialSyncData(PacketBuffer buf) {
    super.writeInitialSyncData(buf);
    MultiblockControllerBase controller = getController();
    buf.writeBoolean(controller != null);
    if (controller != null) {
        buf.writeBlockPos(controller.getPos());
    }
}
 
Example 3
Source File: MetaTileEntityTank.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void writeInitialSyncData(PacketBuffer buf) {
    super.writeInitialSyncData(buf);
    if (isTankController()) {
        buf.writeBoolean(true);
        ByteBufUtils.writeRelativeBlockList(buf, getPos(), connectedTanks);
        buf.writeBlockPos(new BlockPos(multiblockSize));
        FluidStack fluidStack = multiblockFluidTank.getFluid();
        ByteBufUtils.writeFluidStack(buf, fluidStack);
    } else {
        buf.writeBoolean(false);
        buf.writeBlockPos(controllerPos);
    }
}
 
Example 4
Source File: EntityMountable.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void writeSpawnData(ByteBuf buffer) {
    PacketBuffer packetBuffer = new PacketBuffer(buffer);
    Vec3d mountPosLocal = mountPos;
    packetBuffer.writeDouble(mountPosLocal.x);
    packetBuffer.writeDouble(mountPosLocal.y);
    packetBuffer.writeDouble(mountPosLocal.z);
    packetBuffer.writeInt(mountPosSpace.ordinal());
    packetBuffer.writeBoolean(referencePos != null);
    if (referencePos != null) {
        packetBuffer.writeBlockPos(referencePos);
    }
}
 
Example 5
Source File: PacketExtractUpgrade.java    From MiningGadgets with MIT License 4 votes vote down vote up
public static void encode(PacketExtractUpgrade msg, PacketBuffer buffer) {
    buffer.writeInt(msg.nameLength);
    buffer.writeBlockPos(msg.pos);
    buffer.writeString(msg.upgrade);
}
 
Example 6
Source File: CoverBehaviorUIFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void writeHolderToSyncData(PacketBuffer syncData, CoverBehavior holder) {
    syncData.writeBlockPos(holder.coverHolder.getPos());
    syncData.writeByte(holder.attachedSide.ordinal());
}
 
Example 7
Source File: MetaTileEntityUIFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void writeHolderToSyncData(PacketBuffer syncData, MetaTileEntityHolder holder) {
    syncData.writeBlockPos(holder.getPos());
}
 
Example 8
Source File: VSGuiButtonMessage.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public void toBytes(ByteBuf buf) {
    PacketBuffer packetBuffer = new PacketBuffer(buf);
    packetBuffer.writeBlockPos(tileEntityPos);
    packetBuffer.writeVarInt(buttonId);
}
 
Example 9
Source File: TileEntityRpcTarget.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(PacketBuffer output) {
	output.writeInt(te.getWorld().provider.getDimension());
	output.writeBlockPos(te.getPos());
}
 
Example 10
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(BlockPos o, PacketBuffer output) {
	output.writeBlockPos(o);
}
 
Example 11
Source File: BlockEventPacket.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
protected void writeToStream(PacketBuffer output) {
	output.writeInt(dimension);
	output.writeBlockPos(blockPos);
}
 
Example 12
Source File: SyncMapTile.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
protected void writeOwnerData(PacketBuffer output) {
	output.writeBlockPos(owner.getPos());
}