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

The following examples show how to use net.minecraft.network.PacketBuffer#writeByte() . 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: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void writeInitialSyncData(PacketBuffer buf) {
    buf.writeByte(this.frontFacing.getIndex());
    buf.writeInt(this.paintingColor);
    buf.writeShort(mteTraits.size());
    for (MTETrait trait : mteTraits) {
        buf.writeVarInt(trait.getNetworkID());
        trait.writeInitialData(buf);
    }
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = getCoverAtSide(coverSide);
        if (coverBehavior != null) {
            int coverId = CoverDefinition.getNetworkIdForCover(coverBehavior.getCoverDefinition());
            buf.writeVarInt(coverId);
            coverBehavior.writeInitialSyncData(buf);
        } else {
            buf.writeVarInt(-1);
        }
    }
    buf.writeBoolean(isFragile);
}
 
Example 2
Source File: SimpleMachineMetaTileEntity.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);
    buf.writeByte(getOutputFacing().getIndex());
    buf.writeBoolean(autoOutputItems);
    buf.writeBoolean(autoOutputFluids);
}
 
Example 3
Source File: RecipeLogicSteam.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void writeInitialData(PacketBuffer buf) {
    super.writeInitialData(buf);
    buf.writeByte(getVentingSide().getIndex());
    buf.writeBoolean(needsVenting);
    buf.writeBoolean(ventingStuck);
}
 
Example 4
Source File: MessageBackpackUpdate.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
public void toBytes(ByteBuf buf) {
	PacketBuffer buffer = new PacketBuffer(buf);
	buffer.writeInt(_entityId);
	buffer.writeByte(_type.ordinal());
	switch (_type) {
		case STACK: buffer.writeItemStack(_stack); break;
		case OPEN: buffer.writeBoolean(_open); break;
		default: throw new RuntimeException("Invalid UpdateType");
	}
}
 
Example 5
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 6
Source File: PlayerInventoryUIFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void writeHolderToSyncData(PacketBuffer syncData, PlayerInventoryHolder holder) {
    syncData.writeByte(holder.hand.ordinal());
    syncData.writeItemStack(holder.getCurrentItem());
}
 
Example 7
Source File: MetaTileEntityBlockBreaker.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void writeInitialSyncData(PacketBuffer buf) {
    super.writeInitialSyncData(buf);
    buf.writeByte(getOutputFacing().getIndex());
}
 
Example 8
Source File: ServerNetwork.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
public static PacketBuffer writeDisableMod(boolean disable){
	PacketBuffer buffer = PacketPipeline.buf();
	buffer.writeByte(disable ? 1 : 2);
	return buffer;
}
 
Example 9
Source File: TypeRW.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(Byte o, PacketBuffer output) {
	output.writeByte(o);
}
 
Example 10
Source File: SyncableByte.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(PacketBuffer stream) {
	stream.writeByte(value);
}
 
Example 11
Source File: SyncableFlags.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(PacketBuffer stream) {
	stream.writeByte(value);
}
 
Example 12
Source File: SyncableUnsignedByte.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(PacketBuffer stream) {
	stream.writeByte(value);
}
 
Example 13
Source File: SyncableSides.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public void writeToStream(PacketBuffer stream) {
	stream.writeByte(write());
}