Programmer GUI: working in MP
parent
8e5e02fd6f
commit
47f00747e8
@ -0,0 +1,13 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.minecraft.src.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(value = Packet.class, remap = false)
|
||||
public interface AccessorPacket {
|
||||
@Invoker("addIdClassMapping")
|
||||
static void callAddIdClassMapping(int i, boolean clientPacket, boolean serverPacket, Class class1) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodGuiPacket;
|
||||
import net.minecraft.src.*;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = EntityPlayerMP.class, remap = false)
|
||||
public class MixinEntityPlayerMP implements IEntityPlayer {
|
||||
@Shadow public NetServerHandler playerNetServerHandler;
|
||||
|
||||
@Override
|
||||
public void displayGuiProgrammer(AbstractWireTileEntity chip) {
|
||||
this.playerNetServerHandler.sendPacket(new WiremodGuiPacket(1, chip.xCoord, chip.yCoord, chip.zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayGuiSettings(AbstractWireTileEntity chip) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayGuiWireSettings(ToolWiring toolWiring) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodGuiPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = NetClientHandler.class, remap = false)
|
||||
public class MixinNetClientHandler implements INetHandler {
|
||||
@Shadow
|
||||
Minecraft mc;
|
||||
@Override
|
||||
public void wiremodHandleOpenGUI(WiremodGuiPacket packet) {
|
||||
switch (packet.guiType){
|
||||
case 1:
|
||||
((IEntityPlayer)this.mc.thePlayer).displayGuiProgrammer((ChipTileEntity)this.mc.theWorld.getBlockTileEntity(packet.x, packet.y, packet.z));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wiremodHandleProgramTile(WiremodProgrammerPacket wiremodProgrammerPacket) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodGuiPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
|
||||
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.src.EntityPlayerMP;
|
||||
import net.minecraft.src.NetServerHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(value = NetServerHandler.class, remap = false)
|
||||
public class MixinNetServerHandler implements INetHandler {
|
||||
@Shadow
|
||||
private MinecraftServer mcServer;
|
||||
@Shadow
|
||||
private EntityPlayerMP playerEntity;
|
||||
|
||||
@Override
|
||||
public void wiremodHandleOpenGUI(WiremodGuiPacket packet) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wiremodHandleProgramTile(WiremodProgrammerPacket packet) {
|
||||
((ChipTileEntity)this.mcServer.getWorldManager(this.playerEntity.dimension).getBlockTileEntity(packet.x, packet.y, packet.z)).setMode(packet.mode);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.brokenmoon.afloydwiremod.mixinInterfaces;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodGuiPacket;
|
||||
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
|
||||
|
||||
public interface INetHandler {
|
||||
void wiremodHandleOpenGUI(WiremodGuiPacket packet);
|
||||
|
||||
void wiremodHandleProgramTile(WiremodProgrammerPacket wiremodProgrammerPacket);
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
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 WiremodGuiPacket extends Packet {
|
||||
public int guiType;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public WiremodGuiPacket(){
|
||||
|
||||
}
|
||||
|
||||
public WiremodGuiPacket(int type, int x, int y, int z){
|
||||
this.guiType = type;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketData(DataInputStream dataInputStream) throws IOException {
|
||||
this.guiType = dataInputStream.readInt();
|
||||
this.x = dataInputStream.readInt();
|
||||
this.y = dataInputStream.readInt();
|
||||
this.z = dataInputStream.readInt();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
|
||||
dataOutputStream.writeInt(this.guiType);
|
||||
dataOutputStream.writeInt(this.x);
|
||||
dataOutputStream.writeInt(this.y);
|
||||
dataOutputStream.writeInt(this.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(NetHandler netHandler) {
|
||||
((INetHandler)netHandler).wiremodHandleOpenGUI(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketSize() {
|
||||
return 4 * 4;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
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 WiremodProgrammerPacket extends Packet {
|
||||
public WiremodProgrammerPacket(){
|
||||
|
||||
}
|
||||
public String mode;
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public WiremodProgrammerPacket(String mode, int x, int y, int z){
|
||||
this.mode = mode;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
@Override
|
||||
public void readPacketData(DataInputStream dataInputStream) throws IOException {
|
||||
this.mode = dataInputStream.readUTF();
|
||||
this.x = dataInputStream.readInt();
|
||||
this.y = dataInputStream.readInt();
|
||||
this.z = dataInputStream.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePacketData(DataOutputStream dataOutputStream) throws IOException {
|
||||
dataOutputStream.writeUTF(mode);
|
||||
dataOutputStream.writeInt(this.x);
|
||||
dataOutputStream.writeInt(this.y);
|
||||
dataOutputStream.writeInt(this.z);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPacket(NetHandler netHandler) {
|
||||
System.out.println("AE");
|
||||
((INetHandler)netHandler).wiremodHandleProgramTile(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPacketSize() {
|
||||
return (4 * 3) + this.mode.length();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue