Sync chip states! Working on chunk load, not after changing block. PROGRESS
parent
47f00747e8
commit
09c57a3d35
@ -1,10 +1,16 @@
|
||||
package net.brokenmoon.afloydwiremod.mixinInterfaces;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodGuiPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodPacketSyncIO;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerGuiPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodWiringGuiPacket;
|
||||
|
||||
public interface INetHandler {
|
||||
void wiremodHandleOpenGUI(WiremodGuiPacket packet);
|
||||
void wiremodHandleOpenProgrammerGUI(WiremodProgrammerGuiPacket packet);
|
||||
|
||||
void wiremodHandleProgramTile(WiremodProgrammerPacket wiremodProgrammerPacket);
|
||||
|
||||
void wiremodHandleOpenWiringGUI(WiremodWiringGuiPacket wiremodWiringGuiPacket);
|
||||
|
||||
void handleIODisc(WiremodPacketSyncIO wiremodPacketSyncIO);
|
||||
}
|
||||
|
@ -0,0 +1,273 @@
|
||||
package net.brokenmoon.afloydwiremod.packet;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
||||
import net.brokenmoon.afloydwiremod.gui.WiringButton;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.Packet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class WiremodPacketSyncIO extends Packet {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
private int size;
|
||||
public WiringButton[] io;
|
||||
public WiringButton[] oi;
|
||||
public WiremodPacketSyncIO(){
|
||||
this.isChunkDataPacket = true;
|
||||
}
|
||||
public WiremodPacketSyncIO(int xCoord, int yCoord, int zCoord, WiringButton[] inputs, WiringButton[] outputs) {
|
||||
this.isChunkDataPacket = true;
|
||||
this.x = xCoord;
|
||||
this.y = yCoord;
|
||||
this.z = zCoord;
|
||||
this.io = inputs;
|
||||
this.oi = outputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketData(DataInputStream dataInputStream) throws IOException {
|
||||
this.x = dataInputStream.readInt();
|
||||
this.y = dataInputStream.readInt();
|
||||
this.z = dataInputStream.readInt();
|
||||
if(dataInputStream.readBoolean()){
|
||||
//INPUT
|
||||
int length = dataInputStream.readInt();
|
||||
io = new WiringButton[length];
|
||||
for(int i = 0; i < length; ++i){
|
||||
io[i] = new WiringButton();
|
||||
io[i].x = dataInputStream.readInt();
|
||||
io[i].y = dataInputStream.readInt();
|
||||
io[i].buttonString = dataInputStream.readUTF();
|
||||
io[i].floatvalue = dataInputStream.readFloat();
|
||||
io[i].stringvalue = dataInputStream.readUTF();
|
||||
if(dataInputStream.readBoolean()){
|
||||
this.io[i].wire = new WireConnection();
|
||||
this.io[i].wire.x = dataInputStream.readInt();
|
||||
this.io[i].wire.y = dataInputStream.readInt();
|
||||
this.io[i].wire.z = dataInputStream.readInt();
|
||||
this.io[i].wire.thisslot = dataInputStream.readInt();
|
||||
this.io[i].wire.thatslot = dataInputStream.readInt();
|
||||
this.io[i].wire.red = dataInputStream.readFloat();
|
||||
this.io[i].wire.green = dataInputStream.readFloat();
|
||||
this.io[i].wire.blue = dataInputStream.readFloat();
|
||||
this.io[i].wire.alpha = dataInputStream.readFloat();
|
||||
this.io[i].wire.width = dataInputStream.readFloat();
|
||||
this.io[i].wire.backwired = dataInputStream.readBoolean();
|
||||
this.io[i].wire.isMade = dataInputStream.readBoolean();
|
||||
if(dataInputStream.readBoolean()){
|
||||
int ixlength = dataInputStream.readInt();
|
||||
for(int ix = 0; i < ixlength; i++){
|
||||
this.io[i].wire.xadd.add(dataInputStream.readInt());
|
||||
this.io[i].wire.yadd.add(dataInputStream.readInt());
|
||||
this.io[i].wire.zadd.add(dataInputStream.readInt());
|
||||
this.io[i].wire.sideadd.add(dataInputStream.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(dataInputStream.readBoolean()){
|
||||
int length = dataInputStream.readInt();
|
||||
oi = new WiringButton[length];
|
||||
for(int i = 0; i < length; ++i){
|
||||
oi[i] = new WiringButton();
|
||||
oi[i].x = dataInputStream.readInt();
|
||||
oi[i].y = dataInputStream.readInt();
|
||||
oi[i].buttonString = dataInputStream.readUTF();
|
||||
oi[i].floatvalue = dataInputStream.readFloat();
|
||||
oi[i].stringvalue = dataInputStream.readUTF();
|
||||
if(dataInputStream.readBoolean()){
|
||||
this.oi[i].wire = new WireConnection();
|
||||
this.oi[i].wire.x = dataInputStream.readInt();
|
||||
this.oi[i].wire.y = dataInputStream.readInt();
|
||||
this.oi[i].wire.z = dataInputStream.readInt();
|
||||
this.oi[i].wire.thisslot = dataInputStream.readInt();
|
||||
this.oi[i].wire.thatslot = dataInputStream.readInt();
|
||||
this.oi[i].wire.red = dataInputStream.readFloat();
|
||||
this.oi[i].wire.green = dataInputStream.readFloat();
|
||||
this.oi[i].wire.blue = dataInputStream.readFloat();
|
||||
this.oi[i].wire.alpha = dataInputStream.readFloat();
|
||||
this.oi[i].wire.width = dataInputStream.readFloat();
|
||||
this.oi[i].wire.backwired = dataInputStream.readBoolean();
|
||||
this.oi[i].wire.isMade = dataInputStream.readBoolean();
|
||||
if(dataInputStream.readBoolean()){
|
||||
int ixlength = dataInputStream.readInt();
|
||||
for(int ix = 0; i < ixlength; i++){
|
||||
this.oi[i].wire.xadd.add(dataInputStream.readInt());
|
||||
this.oi[i].wire.yadd.add(dataInputStream.readInt());
|
||||
this.oi[i].wire.zadd.add(dataInputStream.readInt());
|
||||
this.oi[i].wire.sideadd.add(dataInputStream.readInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
|
||||
dataOutputStream.writeInt(x);
|
||||
dataOutputStream.writeInt(y);
|
||||
dataOutputStream.writeInt(z);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
if(io != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(io.length);
|
||||
size = size + 4;
|
||||
for(int i = 0; i < this.io.length; ++i){
|
||||
dataOutputStream.writeInt(this.io[i].x);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeInt(this.io[i].y);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeUTF(this.io[i].buttonString);
|
||||
size = size + this.io[i].buttonString.length();
|
||||
dataOutputStream.writeFloat(this.io[i].floatvalue);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeUTF(this.io[i].stringvalue);
|
||||
size = size + this.io[i].stringvalue.length();
|
||||
if(io[i].wire != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(this.io[i].wire.x);
|
||||
dataOutputStream.writeInt(this.io[i].wire.y);
|
||||
dataOutputStream.writeInt(this.io[i].wire.z);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeInt(this.io[i].wire.thisslot);
|
||||
dataOutputStream.writeInt(this.io[i].wire.thatslot);
|
||||
dataOutputStream.writeFloat(this.io[i].wire.red);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeFloat(this.io[i].wire.green);
|
||||
dataOutputStream.writeFloat(this.io[i].wire.blue);
|
||||
dataOutputStream.writeFloat(this.io[i].wire.alpha);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeFloat(this.io[i].wire.width);
|
||||
dataOutputStream.writeBoolean(this.io[i].wire.backwired);
|
||||
dataOutputStream.writeBoolean(this.io[i].wire.isMade);
|
||||
size = size + 4;
|
||||
size++;
|
||||
size++;
|
||||
if(this.io[i].wire.xadd != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(this.io[i].wire.xadd.size());
|
||||
size = size + 4;
|
||||
for(int ix = 0; i < this.io[i].wire.xadd.size(); i++){
|
||||
dataOutputStream.writeInt(this.io[i].wire.xadd.get(ix));
|
||||
dataOutputStream.writeInt(this.io[i].wire.yadd.get(ix));
|
||||
dataOutputStream.writeInt(this.io[i].wire.zadd.get(ix));
|
||||
dataOutputStream.writeInt(this.io[i].wire.sideadd.get(ix));
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
}
|
||||
} else {
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
} else{
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
if(oi != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(oi.length);
|
||||
size = size + 4;
|
||||
for(int i = 0; i < this.oi.length; ++i){
|
||||
dataOutputStream.writeInt(this.oi[i].x);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeInt(this.oi[i].y);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeUTF(this.oi[i].buttonString);
|
||||
size = size + this.oi[i].buttonString.length();
|
||||
dataOutputStream.writeFloat(this.oi[i].floatvalue);
|
||||
size = size + 4;
|
||||
dataOutputStream.writeUTF(this.oi[i].stringvalue);
|
||||
size = size + this.oi[i].stringvalue.length();
|
||||
if(oi[i].wire != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(this.oi[i].wire.x);
|
||||
dataOutputStream.writeInt(this.oi[i].wire.y);
|
||||
dataOutputStream.writeInt(this.oi[i].wire.z);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeInt(this.oi[i].wire.thisslot);
|
||||
dataOutputStream.writeInt(this.oi[i].wire.thatslot);
|
||||
dataOutputStream.writeFloat(this.oi[i].wire.red);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeFloat(this.oi[i].wire.green);
|
||||
dataOutputStream.writeFloat(this.oi[i].wire.blue);
|
||||
dataOutputStream.writeFloat(this.oi[i].wire.alpha);
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
dataOutputStream.writeFloat(this.oi[i].wire.width);
|
||||
dataOutputStream.writeBoolean(this.oi[i].wire.backwired);
|
||||
dataOutputStream.writeBoolean(this.oi[i].wire.isMade);
|
||||
size = size + 4;
|
||||
size++;
|
||||
size++;
|
||||
if(this.oi[i].wire.xadd != null){
|
||||
dataOutputStream.writeBoolean(true);
|
||||
size++;
|
||||
dataOutputStream.writeInt(this.oi[i].wire.xadd.size());
|
||||
size = size + 4;
|
||||
for(int ix = 0; i < this.oi[i].wire.xadd.size(); i++){
|
||||
dataOutputStream.writeInt(this.oi[i].wire.xadd.get(ix));
|
||||
dataOutputStream.writeInt(this.oi[i].wire.yadd.get(ix));
|
||||
dataOutputStream.writeInt(this.oi[i].wire.zadd.get(ix));
|
||||
dataOutputStream.writeInt(this.oi[i].wire.sideadd.get(ix));
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
size = size + 4;
|
||||
}
|
||||
} else {
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
} else{
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dataOutputStream.writeBoolean(false);
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(NetHandler netHandler) {
|
||||
((INetHandler)netHandler).handleIODisc(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketSize() {
|
||||
return size;
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package net.brokenmoon.afloydwiremod.packet;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.Packet;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class WiremodWiringGuiPacket extends Packet {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public int x2;
|
||||
public int y2;
|
||||
public int z2;
|
||||
public WiremodWiringGuiPacket(){
|
||||
|
||||
}
|
||||
public WiremodWiringGuiPacket(int x, int y, int z, int x2, int y2, int z2){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.x2 = x2;
|
||||
this.y2 = z2;
|
||||
this.z2 = y2;
|
||||
}
|
||||
@Override
|
||||
public void readPacketData(DataInputStream dataInputStream) throws IOException {
|
||||
this.x = dataInputStream.readInt();
|
||||
this.y = dataInputStream.readInt();
|
||||
this.z = dataInputStream.readInt();
|
||||
this.x2 = dataInputStream.readInt();
|
||||
this.y2 = dataInputStream.readInt();
|
||||
this.z2 = dataInputStream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
|
||||
dataOutputStream.writeInt(this.x);
|
||||
dataOutputStream.writeInt(this.y);
|
||||
dataOutputStream.writeInt(this.z);
|
||||
dataOutputStream.writeInt(this.x2);
|
||||
dataOutputStream.writeInt(this.y2);
|
||||
dataOutputStream.writeInt(this.z2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(NetHandler netHandler) {
|
||||
((INetHandler)netHandler).wiremodHandleOpenWiringGUI(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketSize() {
|
||||
return 6 * 4;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue