Java Code Examples for net.minecraftforge.fml.common.network.ByteBufUtils#readUTF8String()

The following examples show how to use net.minecraftforge.fml.common.network.ByteBufUtils#readUTF8String() . 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: PacketUpdateGui.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public static Object readField(ByteBuf buf, int type){

        switch(type){
            case 0:
                return buf.readInt();
            case 1:
                return buf.readFloat();
            case 2:
                return buf.readDouble();
            case 3:
                return buf.readBoolean();
            case 4:
                return ByteBufUtils.readUTF8String(buf);
            case 5:
                return buf.readByte();
            case 6:
                return ByteBufUtils.readItemStack(buf);
            case 7:
                if(!buf.readBoolean()) return null;
                return new FluidStack(FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf)), buf.readInt(), ByteBufUtils.readTag(buf));
            default:
                throw new IllegalArgumentException("Invalid sync type! " + type);
        }
    }
 
Example 2
Source File: MerchantRecipes.java    From HoloInventory with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    super.fromBytes(buf);
    name = ByteBufUtils.readUTF8String(buf);
    tag = ByteBufUtils.readTag(buf);
}
 
Example 3
Source File: ObservationFromGridImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
void restoreState(ByteBuf buf)
{
    int numGrids = buf.readInt();
    this.environs = new ArrayList<SimpleGridDef>();
    for (int i = 0; i < numGrids; i++)
    {
        SimpleGridDef sgd = new SimpleGridDef(buf.readInt(), buf.readInt(), buf.readInt(),
                                              buf.readInt(), buf.readInt(), buf.readInt(), 
                                              ByteBufUtils.readUTF8String(buf),
                                              buf.readBoolean());
        this.environs.add(sgd);
    }
}
 
Example 4
Source File: PacketUpdateMessage.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf){
    super.fromBytes(buf);
    entityId = buf.readInt();
    message = ByteBufUtils.readUTF8String(buf);
    args = new String[buf.readInt()];
    for(int i = 0; i < args.length; i++) {
        args[i] = ByteBufUtils.readUTF8String(buf);
    }
}
 
Example 5
Source File: InventoryCommandsImplementation.java    From malmo with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    this.invA = ByteBufUtils.readUTF8String(buf);
    this.slotA = buf.readInt();
    this.invB = ByteBufUtils.readUTF8String(buf);
    this.slotB = buf.readInt();
    this.combine = buf.readBoolean();
    if (buf.readBoolean())
        this.containerPos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
}
 
Example 6
Source File: MessageFluidUpdate.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	this.x = buf.readInt();
	this.y = buf.readInt();
	this.z = buf.readInt();
	this.fillAmount = buf.readInt();
	this.fluidName = ByteBufUtils.readUTF8String(buf);
}
 
Example 7
Source File: PlainInventory.java    From HoloInventory with MIT License 5 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    super.fromBytes(buf);
    name = ByteBufUtils.readUTF8String(buf);
    int size = buf.readInt();
    stacks = new ArrayList<>(size);
    for (int i = 0; i < size; i++) add(ByteBufUtils.readItemStack(buf));
}
 
Example 8
Source File: MCNetworkRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static MCNetworkRail fromByteBuf(ByteBuf b){
    MCPos pos = new MCPos(b);
    EnumRailDirection curDir = ALL_RAIL_DIRECTIONS_ARRAY[b.readByte()];
    String type = ByteBufUtils.readUTF8String(b);
    if(type.equals(NORMAL_RAIL_STRING)) {
        return new MCNetworkRail(pos, (String)null, curDir, ALL_RAIL_DIRECTIONS);
    } else {
        EnumSet<EnumRailDirection> validRailDirs = EnumSetUtils.toEnumSet(EnumRailDirection.class, ALL_RAIL_DIRECTIONS_ARRAY, b.readShort());
        return new MCNetworkRail(pos, type, curDir, validRailDirs);
    }
}
 
Example 9
Source File: MCNetworkRail.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static <T> T fromByteBuf(ByteBuf b, IRailCreator<T> factory){
    MCPos pos = new MCPos(b);
    EnumRailDirection curDir = ALL_RAIL_DIRECTIONS_ARRAY[b.readByte()];
    String type = ByteBufUtils.readUTF8String(b);
    if(type.equals(NORMAL_RAIL_STRING)) {
        return factory.create(pos, (String)null, curDir, ALL_RAIL_DIRECTIONS);
    } else {
        EnumSet<EnumRailDirection> validRailDirs = EnumSetUtils.toEnumSet(EnumRailDirection.class, ALL_RAIL_DIRECTIONS_ARRAY, b.readShort());
        return factory.create(pos, type, curDir, validRailDirs);
    }
}
 
Example 10
Source File: MCNetworkStation.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
public static MCNetworkStation fromByteBuf(ByteBuf buf){
    return new MCNetworkStation(new MCPos(buf), ByteBufUtils.readUTF8String(buf));
}
 
Example 11
Source File: MCPacket.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public String readString() {
	return ByteBufUtils.readUTF8String(buf);
}
 
Example 12
Source File: MessageSendString.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    this.type = Type.values()[buf.readByte() % Type.values().length];
    this.text = ByteBufUtils.readUTF8String(buf);
}
 
Example 13
Source File: PacketUpdateTextfield.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buffer){
    super.fromBytes(buffer);
    textFieldID = buffer.readInt();
    text = ByteBufUtils.readUTF8String(buffer);
}
 
Example 14
Source File: PacketUpdateTextfieldEntity.java    From Signals with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buffer){
    textFieldID = buffer.readInt();
    entityId = buffer.readInt();
    text = ByteBufUtils.readUTF8String(buffer);
}
 
Example 15
Source File: PacketKeyMessage.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
    sender = ByteBufUtils.readUTF8String(buf);
}
 
Example 16
Source File: NearbyCraftCommandsImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
    this.parameters = ByteBufUtils.readUTF8String(buf);
}
 
Example 17
Source File: NearbySmeltCommandsImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
    this.parameters = ByteBufUtils.readUTF8String(buf);
}
 
Example 18
Source File: SimpleCraftCommandsImplementation.java    From malmo with MIT License 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
    this.parameters = ByteBufUtils.readUTF8String(buf);
}
 
Example 19
Source File: MessageSetQuestInfo.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
	questMessageJson = ByteBufUtils.readUTF8String(buf);
	deserializeData();
}
 
Example 20
Source File: MessageProcessorUpdate.java    From Minecoprocessors with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf) {
  processorData = ByteBufUtils.readTag(buf);
  pos = BlockPos.fromLong(buf.readLong());
  name = ByteBufUtils.readUTF8String(buf);
}