codechicken.lib.data.MCDataInput Java Examples

The following examples show how to use codechicken.lib.data.MCDataInput. 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: ConfigTagImpl.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void read(MCDataInput in) {
    if (isCategory()) {
        int numChildren = in.readVarInt();
        for (int i = 0; i < numChildren; i++) {
            String name = in.readString();
            ConfigTagImpl found = children.get(name);
            if (found == null) {
                throw new IllegalArgumentException("read called with data that does not align to this tag, Missing: " + name);
            }
            found.read(in);
        }
    } else {
        value = type.read(in, listType);
    }
}
 
Example #2
Source File: PartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void readDesc(MCDataInput packet) {

    if (hidden == null)
        hidden = new boolean[6];

    super.readDesc(packet);

    for (int i = 0; i < 6; i++)
        hidden[i] = packet.readBoolean();

    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        Collection<IFrameSideModifier> c = getSideModifiers(d);
        c.clear();
        int amt = packet.readInt();
        for (int i = 0; i < amt; i++)
            c.add((IFrameSideModifier) FrameModifierRegistry.instance().findModifier(packet.readString()));
    }
}
 
Example #3
Source File: ConfigSyncManager.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void applyTo(MCDataInput in, ConfigTag parent) {
    SyncState master = SyncState.create(parent);
    Map<String, ConfigTag> lookup = master.syncTags.stream()//
            .collect(Collectors.toMap(ConfigTag::getQualifiedName, Function.identity()));
    int numTags = in.readVarInt();
    for (int i = 0; i < numTags; i++) {
        String ident = in.readString();
        ConfigTag found = lookup.get(ident);
        if (found == null) {
            throw new RuntimeException("Unable to apply server sync, tag does not exist! " + ident);
        }
        found.read(in);
    }
    try {
        parent.runSync(SyncType.CONNECT);
    } catch (SyncException e) {
        throw new RuntimeException("Unable to apply server sync, SyncException thrown!", e);
    }

}
 
Example #4
Source File: PartPressureTube.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void readDesc(MCDataInput packet){
    for(int i = 0; i < 6; i++) {
        tube.sidesConnected[i] = packet.readBoolean();
    }
    tube.readFromNBT(packet.readNBTTagCompound());
}
 
Example #5
Source File: TileEnderTank.java    From EnderStorage with MIT License 5 votes vote down vote up
@Override
public void readFromPacket(MCDataInput packet) {
    super.readFromPacket(packet);
    liquid_state.setFrequency(frequency);
    rotation = packet.readUByte() & 3;
    liquid_state.s_liquid = packet.readFluidStack();
    pressure_state.a_pressure = packet.readBoolean();
    if (!described) {
        liquid_state.c_liquid = liquid_state.s_liquid;
        pressure_state.b_rotate = pressure_state.a_rotate = pressure_state.approachRotate();
    }
    described = true;
}
 
Example #6
Source File: ICCLContainerType.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public T create(int windowId, PlayerInventory inventory, MCDataInput packet) {
    if (factory instanceof ICCLContainerFactory) {
        return ((ICCLContainerFactory<T>) factory).create(windowId, inventory, packet);
    }
    return null;
}
 
Example #7
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    List list = new LinkedList();
    int num = in.readVarInt();
    for (int i = 0; i < num; i++) {
        list.add(listType.read(in, null));
    }
    return list;
}
 
Example #8
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return in.readSignedVarLong();
}
 
Example #9
Source File: TubeModule.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
@Optional.Method(modid = ModIds.FMP)
public void readDesc(MCDataInput data){
    dir = ForgeDirection.getOrientation(data.readInt());
}
 
Example #10
Source File: WirelessPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
@Override
public void read(MCDataInput packet) {
    super.read(packet);
    onPartChanged(this);
}
 
Example #11
Source File: WirelessPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
@Override
public void readDesc(MCDataInput packet) {
    state = packet.readByte();
}
 
Example #12
Source File: TransceiverPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
@Override
public void readDesc(MCDataInput packet) {
    super.readDesc(packet);
    currentfreq = packet.readUShort();
}
 
Example #13
Source File: TransmitterPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
@Override
public void read(MCDataInput packet) {
    super.read(packet);
    changeSpinState(active());
}
 
Example #14
Source File: ReceiverPart.java    From WirelessRedstone with MIT License 4 votes vote down vote up
@Override
public void read(MCDataInput packet)
{
    super.read(packet);
    changeSpinState(disabled());
}
 
Example #15
Source File: PartChiselTorch.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void readDesc(MCDataInput packet) {
	super.readDesc(packet);
	this.idx = packet.readInt();
}
 
Example #16
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return in.readDouble();
}
 
Example #17
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return INT.read(in, listType);
}
 
Example #18
Source File: GTMultipartFactory.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public TMultiPart createPartClient(ResourceLocation identifier, MCDataInput packet) {
    return createPart(identifier);
}
 
Example #19
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return in.readSignedVarInt();
}
 
Example #20
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return in.readString();
}
 
Example #21
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public Object read(MCDataInput in, TagType listType) {
    return in.readBoolean();
}
 
Example #22
Source File: EnderItemStorage.java    From EnderStorage with MIT License 4 votes vote down vote up
public void handleContainerPacket(MCDataInput packet) {
    size = packet.readByte();
    empty();
}
 
Example #23
Source File: ContainerEnderItemStorage.java    From EnderStorage with MIT License 4 votes vote down vote up
public ContainerEnderItemStorage(int windowId, PlayerInventory playerInv, MCDataInput packet) {
    this(windowId, playerInv, EnderStorageManager.instance(true).getStorage(Frequency.readFromPacket(packet), EnderItemStorage.TYPE));
    chestInv.handleContainerPacket(packet);
}
 
Example #24
Source File: Frequency.java    From EnderStorage with MIT License 4 votes vote down vote up
public static Frequency readFromPacket(MCDataInput packet) {
    return new Frequency(packet.readCompoundNBT());
}
 
Example #25
Source File: TileFrequencyOwner.java    From EnderStorage with MIT License 4 votes vote down vote up
public void readFromPacket(MCDataInput packet) {
    frequency.set(Frequency.readFromPacket(packet));
    onFrequencySet();
}
 
Example #26
Source File: TileEnderChest.java    From EnderStorage with MIT License 4 votes vote down vote up
@Override
public void readFromPacket(MCDataInput packet) {
    super.readFromPacket(packet);
    rotation = packet.readUByte() & 3;
}
 
Example #27
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 votes vote down vote up
public abstract Object read(MCDataInput in, TagType listType); 
Example #28
Source File: ConfigTag.java    From CodeChickenLib with GNU Lesser General Public License v2.1 votes vote down vote up
void read(MCDataInput in); 
Example #29
Source File: ICCLContainerType.java    From CodeChickenLib with GNU Lesser General Public License v2.1 votes vote down vote up
T create(int windowId, PlayerInventory inventory, MCDataInput packet); 
Example #30
Source File: ICCLContainerFactory.java    From CodeChickenLib with GNU Lesser General Public License v2.1 votes vote down vote up
T create(int windowId, PlayerInventory inventory, MCDataInput packet);