mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
Correct split client-server code
This commit is contained in:
1 parent
db8aee2c25
commit
6e96cba6fe
7 files changed
+84
-37
No files matched your search
@@ -1,13 +1,10 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiLevelMaintainer;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
@@ -28,6 +25,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
private int z;
|
||||
private int dim;
|
||||
private ForgeDirection side;
|
||||
private int originalGui = -1;
|
||||
|
||||
public enum Action {
|
||||
EDIT,
|
||||
@@ -49,17 +47,30 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public CPacketLevelTerminalCommands setOriginalGui(int originalGui) {
|
||||
this.originalGui = originalGui;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
action = Action.values()[buf.readInt()];
|
||||
switch (action) {
|
||||
case EDIT, BACK -> {
|
||||
case EDIT -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
dim = buf.readInt();
|
||||
side = ForgeDirection.getOrientation(buf.readInt());
|
||||
}
|
||||
case BACK -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
dim = buf.readInt();
|
||||
side = ForgeDirection.getOrientation(buf.readInt());
|
||||
originalGui = buf.readInt();
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
@@ -71,13 +82,21 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(action.ordinal());
|
||||
switch (action) {
|
||||
case EDIT, BACK -> {
|
||||
case EDIT -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
}
|
||||
case BACK -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
buf.writeInt(originalGui);
|
||||
}
|
||||
case ENABLE -> {}
|
||||
case DISABLE -> {}
|
||||
case ENABLE_ALL -> {}
|
||||
@@ -103,11 +122,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
case BACK -> {
|
||||
GuiType originalGui = null;
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiLevelMaintainer guiLevelMaintainer) {
|
||||
originalGui = guiLevelMaintainer.getOriginalGui();
|
||||
}
|
||||
GuiType originalGui = GuiType.getByOrdinal(message.originalGui);
|
||||
if (originalGui == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiRenamer;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IClickableInTerminal;
|
||||
@@ -179,10 +176,7 @@ public class CPacketRenamer implements IMessage {
|
||||
.getTileEntity(intMsg.x, intMsg.y, intMsg.z);
|
||||
this.setName(tile, intMsg.getSide(), message.text);
|
||||
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiRenamer guiRenamer) {
|
||||
guiRenamer.switchGui();
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketSwitchBack(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import com.glodblock.github.client.gui.GuiRenamer;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class SPacketSwitchBack implements IMessage {
|
||||
|
||||
public SPacketSwitchBack() {}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {}
|
||||
|
||||
public static class Handler implements IMessageHandler<SPacketSwitchBack, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(SPacketSwitchBack message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiRenamer) {
|
||||
((GuiRenamer) gs).switchGui();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user