mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
feat: add back navigation in LevelMaintainer from terminal
This commit is contained in:
18 files changed
+437
-69
No files matched your search
+2
-1
@@ -5,10 +5,11 @@ dependencies {
|
||||
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-262-GTNH:dev')
|
||||
api('curse.maven:cofh-core-69162:2388751')
|
||||
api('com.github.GTNewHorizons:waila:1.6.0:dev')
|
||||
api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.0:dev")
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
|
||||
compileOnly('com.github.GTNewHorizons:EnderIO:2.5.2:dev')
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
@@ -35,23 +34,23 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
|
||||
@Override
|
||||
public void initGui() {
|
||||
if (host instanceof PartFluidPatternTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
|
||||
else if (host instanceof PartFluidPatternTerminalEx)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
|
||||
else if (host instanceof PartFluidTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
|
||||
else if (host instanceof PartLevelTerminal)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
|
||||
else if (host instanceof WirelessFluidTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
|
||||
else if (host instanceof WirelessPatternTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_LEVEL_TERM, 1));
|
||||
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
|
||||
super.initGui();
|
||||
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
|
||||
}
|
||||
@@ -64,8 +63,8 @@ public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraf
|
||||
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
|
||||
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
|
||||
else if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
|
||||
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
|
||||
else if (host instanceof WirelessFluidTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
|
||||
else if (host instanceof WirelessPatternTerminalInventory)
|
||||
|
||||
@@ -6,13 +6,12 @@ import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerDualInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
@@ -148,9 +147,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
super.actionPerformed(btn);
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
if (btn == this.priority) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
|
||||
InventoryHandler.switchGui(GuiType.PRIORITY);
|
||||
} else if (btn == this.switcher) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
|
||||
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE_FLUID);
|
||||
} else if (btn == this.interfaceMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
|
||||
} else if (btn == this.BlockMode) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCGuiAmount;
|
||||
@@ -67,25 +66,25 @@ public class GuiFluidCraftAmount extends FCGuiAmount {
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof PartFluidPatternTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
} else if (target instanceof PartFluidPatternTerminalEx) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (target instanceof PartFluidTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERM.stack();
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (target instanceof PartLevelTerminal) {
|
||||
myIcon = new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1);
|
||||
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (target instanceof WirelessPatternTerminalInventory) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (target instanceof WirelessLevelTerminalInventory) {
|
||||
myIcon = new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1);
|
||||
myIcon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.implementations.GuiCraftConfirm;
|
||||
@@ -28,8 +27,8 @@ public class GuiFluidCraftConfirm extends GuiCraftConfirm implements IGuiTooltip
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (te instanceof PartLevelTerminal) {
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
|
||||
} else if (te instanceof IWirelessTerminal terminal && terminal.isUniversal(te)) {
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (te instanceof WirelessPatternTerminalInventory) {
|
||||
this.originalGui = GuiType.FLUID_TERMINAL;
|
||||
} else if (te instanceof WirelessLevelTerminalInventory) {
|
||||
@@ -39,6 +38,6 @@ public class GuiFluidCraftConfirm extends GuiCraftConfirm implements IGuiTooltip
|
||||
|
||||
@Override
|
||||
public void switchToOriginalGUI() {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
}
|
||||
@@ -17,11 +17,11 @@ import com.glodblock.github.client.gui.container.ContainerFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
@@ -117,7 +117,7 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.switcher) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE));
|
||||
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import org.lwjgl.input.Mouse;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageBus;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -93,7 +93,7 @@ public class GuiFluidStorageBus extends GuiUpgradeable {
|
||||
} else if (btn == this.clear) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
|
||||
} else if (btn == this.priority) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
|
||||
InventoryHandler.switchGui(GuiType.PRIORITY);
|
||||
} else if (btn == this.rwMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
|
||||
}
|
||||
|
||||
@@ -15,26 +15,38 @@ import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.State;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer.TLMTags;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer.Action;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.FCGuiColors;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketNEIDragClick;
|
||||
@@ -56,6 +68,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private int lastWorkingTick;
|
||||
private int refreshTick;
|
||||
private final CoFHFontRenderer render;
|
||||
protected ItemStack icon = null;
|
||||
|
||||
protected GuiType originalGui;
|
||||
protected Util.DimensionalCoordSide originalBlockPos;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
super(new ContainerLevelMaintainer(ipl, tile));
|
||||
@@ -68,6 +85,43 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
Minecraft.getMinecraft().getTextureManager(),
|
||||
true);
|
||||
this.refreshTick = 0;
|
||||
if (ipl.player.openContainer instanceof AEBaseContainer container) {
|
||||
var target = container.getTarget();
|
||||
if (target instanceof PartLevelTerminal terminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.LEVEL_TERMINAL;
|
||||
DimensionalCoord blockPos = new DimensionalCoord(terminal.getTile());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
terminal.getSide(),
|
||||
"");
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
ipl.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
ipl.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list) {
|
||||
@@ -90,6 +144,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.lastWorkingTick = this.refreshTick;
|
||||
@@ -111,6 +166,16 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
|
||||
this.buttonList);
|
||||
}
|
||||
if (this.icon != null) {
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.icon,
|
||||
this.icon.getDisplayName(),
|
||||
itemRender);
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
this.buttonList.add(originalGuiBtn);
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(Action.Refresh));
|
||||
}
|
||||
|
||||
@@ -232,14 +297,34 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
for (Component com : this.component) {
|
||||
if (com.sendToServer(btn)) {
|
||||
break;
|
||||
if (btn == originalGuiBtn) {
|
||||
switchGui();
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
for (Component com : this.component) {
|
||||
if (com.sendToServer(btn)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiType getOriginalGui() {
|
||||
return originalGui;
|
||||
}
|
||||
|
||||
public void switchGui() {
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide()));
|
||||
// InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
return currentVisibility;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCGuiAmount;
|
||||
@@ -67,16 +66,16 @@ public class GuiPatternValueAmount extends FCGuiAmount {
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof PartFluidPatternTerminal) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
|
||||
} else if (target instanceof PartFluidPatternTerminalEx) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1);
|
||||
this.myIcon = ItemAndBlockHolder.FLUID_TERMINAL_EX.stack();
|
||||
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
|
||||
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
|
||||
} else if (target instanceof IWirelessTerminal terminal && terminal.isUniversal(target)) {
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
this.originalGui = ItemWirelessUltraTerminal.readMode(terminal.getItemStack());
|
||||
} else if (target instanceof WirelessPatternTerminalInventory) {
|
||||
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
|
||||
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
super.initGui();
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketRenamer(CPacketRenamer.Action.GET_TEXT));
|
||||
if (host instanceof PartLevelTerminal) {
|
||||
icon = new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1);
|
||||
icon = ItemAndBlockHolder.LEVEL_TERMINAL.stack();
|
||||
} else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host)) {
|
||||
icon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
|
||||
icon = ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack();
|
||||
} else if (host instanceof WirelessLevelTerminalInventory) {
|
||||
icon = new ItemStack(ItemAndBlockHolder.WIRELESS_LEVEL_TERM, 1);
|
||||
icon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
} else if (host instanceof WirelessInterfaceTerminalInventory) {
|
||||
icon = new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1);
|
||||
icon = ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack();
|
||||
}
|
||||
if (this.icon != null) {
|
||||
this.buttonList.add(
|
||||
@@ -116,7 +116,7 @@ public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
public void switchGui() {
|
||||
if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
|
||||
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
|
||||
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
|
||||
else if (host instanceof WirelessInterfaceTerminalInventory)
|
||||
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
|
||||
else if (host instanceof WirelessLevelTerminalInventory)
|
||||
|
||||
@@ -7,9 +7,8 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -107,7 +106,7 @@ public abstract class FCGuiAmount extends AEBaseGui {
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
|
||||
InventoryHandler.switchGui(originalGui);
|
||||
}
|
||||
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
|
||||
final boolean isMinus = btn == this.minus1 || btn == this.minus10
|
||||
|
||||
@@ -65,7 +65,6 @@ public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
}
|
||||
dirty = this.updateList();
|
||||
if (dirty != null) {
|
||||
FluidCraft.proxy.netHandler.sendTo(dirty, (EntityPlayerMP) ip.player);
|
||||
this.isDirty = true;
|
||||
} else {
|
||||
dirty = new SPacketLevelTerminalUpdate();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import com.glodblock.github.network.wrapper.FCNetworkWrapper;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.world.World;
|
||||
@@ -25,7 +26,6 @@ import com.glodblock.github.network.SPacketMEItemInvUpdate;
|
||||
import com.glodblock.github.network.SPacketSetItemAmount;
|
||||
import com.glodblock.github.network.SPacketStringUpdate;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class ChannelLoader implements Runnable {
|
||||
@@ -33,10 +33,9 @@ public class ChannelLoader implements Runnable {
|
||||
public static final ChannelLoader INSTANCE = new ChannelLoader();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void run() {
|
||||
int id = 0;
|
||||
SimpleNetworkWrapper netHandler = FluidCraft.proxy.netHandler;
|
||||
FCNetworkWrapper netHandler = FluidCraft.proxy.netHandler;
|
||||
netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.SERVER);
|
||||
netHandler.registerMessage(
|
||||
new CPacketFluidPatternTermBtns.Handler(),
|
||||
@@ -76,7 +75,7 @@ public class ChannelLoader implements Runnable {
|
||||
new CPacketLevelTerminalCommands.Handler(),
|
||||
CPacketLevelTerminalCommands.class,
|
||||
id++,
|
||||
Side.CLIENT);
|
||||
Side.SERVER);
|
||||
}
|
||||
|
||||
public static void sendPacketToAllPlayers(Packet packet, World world) {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
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 +31,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
|
||||
public enum Action {
|
||||
EDIT,
|
||||
BACK,
|
||||
ENABLE,
|
||||
DISABLE,
|
||||
ENABLE_ALL,
|
||||
@@ -49,7 +53,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
action = Action.values()[buf.readInt()];
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
case EDIT, BACK -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
@@ -67,11 +71,11 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(action.ordinal());
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
buf.writeInt(this.x);
|
||||
buf.writeInt(this.y);
|
||||
buf.writeInt(this.z);
|
||||
buf.writeInt(this.dim);
|
||||
case EDIT, BACK -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(dim);
|
||||
buf.writeInt(side.ordinal());
|
||||
}
|
||||
case ENABLE -> {}
|
||||
@@ -98,6 +102,23 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
message.side,
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
case BACK -> {
|
||||
GuiType originalGui = null;
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiLevelMaintainer guiLevelMaintainer) {
|
||||
originalGui = guiLevelMaintainer.getOriginalGui();
|
||||
}
|
||||
if (originalGui == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(message.x, message.y, message.z, DimensionManager.getWorld(message.dim)),
|
||||
message.side,
|
||||
originalGui);
|
||||
}
|
||||
case ENABLE -> {
|
||||
if (con.getTarget() instanceof IClickableInTerminal clickableInterface) {
|
||||
Util.DimensionalCoordSide intMsg = clickableInterface.getClickedInterface();
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.glodblock.github.network.wrapper;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
public class FCIndexedCodec extends SimpleIndexedCodec {
|
||||
|
||||
static int DISCRIMINATOR_BYTE = 1;
|
||||
|
||||
@Override
|
||||
public void encodeInto(ChannelHandlerContext ctx, IMessage msg, ByteBuf target) throws Exception {
|
||||
super.encodeInto(ctx, msg, target);
|
||||
|
||||
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
|
||||
AELog.info(" -> " + msg.getClass().getName() + " : " + target.readableBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf source, IMessage msg) {
|
||||
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
|
||||
AELog.info(" <- " + msg.getClass().getName() + " : " + (source.readableBytes() + DISCRIMINATOR_BYTE));
|
||||
}
|
||||
|
||||
super.decodeInto(ctx, source, msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package com.glodblock.github.network.wrapper;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.FMLEmbeddedChannel;
|
||||
import cpw.mods.fml.common.network.FMLOutboundHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleIndexedCodec;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.channel.ChannelFutureListener;
|
||||
|
||||
/**
|
||||
* This class is a simplified netty wrapper for those not wishing to deal with the full power of netty. It provides a
|
||||
* simple message driven system, based on a discriminator byte over the custom packet channel. It assumes that you have
|
||||
* a series of unique message types with each having a unique handler. Generally, context should be derived at message
|
||||
* handling time.
|
||||
* <p>
|
||||
* Usage is simple:
|
||||
* <ul>
|
||||
* <li>construct, and store, an instance of this class. It will automatically register and configure your underlying
|
||||
* netty channel.
|
||||
*
|
||||
* <li>Then, call {@link #registerMessage(Class, Class, byte, Side)} for each message type you want to exchange
|
||||
* providing an {@link IMessageHandler} implementation class as well as an {@link IMessage} implementation class. The
|
||||
* side parameter to that method indicates which side (server or client) the <em>message processing</em> will occur on.
|
||||
* The discriminator byte should be unique for this channelName - it is used to discriminate between different types of
|
||||
* message that might occur on this channel (a simple form of message channel multiplexing, if you will).
|
||||
* <li>To get a packet suitable for presenting to the rest of minecraft, you can call {@link #getPacketFrom(IMessage)}.
|
||||
* The return result is suitable for returning from things like {@link TileEntity#getDescriptionPacket()} for example.
|
||||
* <li>Finally, use the sendXXX to send unsolicited messages to various classes of recipients.
|
||||
* </ul>
|
||||
* <p>
|
||||
* Example <code>
|
||||
* <pre>
|
||||
* // Request message
|
||||
* public Message1 implements IMessage {
|
||||
* // message structure
|
||||
* public fromBytes(ByteBuf buf) {
|
||||
* // build message from byte array
|
||||
* }
|
||||
* public toBytes(ByteBuf buf) {
|
||||
* // put message content into byte array
|
||||
* }
|
||||
* }
|
||||
* // Reply message
|
||||
* public Message2 implements IMessage {
|
||||
* // stuff as before
|
||||
* }
|
||||
* // Message1Handler expects input of type Message1 and returns type Message2
|
||||
* public Message1Handler implements IMessageHandler<Message1,Message2> {
|
||||
* public Message2 onMessage(Message1 message, MessageContext ctx) {
|
||||
* // do something and generate reply message
|
||||
* return aMessage2Object;
|
||||
* }
|
||||
* }
|
||||
* // Message2Handler expects input of type Message2 and returns no message (IMessage)
|
||||
* public Message2Handler implements IMessageHandler<Message2,IMessage> {
|
||||
* public IMessage onMessage(Message2 message, MessageContext ctx) {
|
||||
* // handle the message 2 response message at the other end
|
||||
* // no reply for this message - return null
|
||||
* return null;
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Code in a {@link FMLPreInitializationEvent} or {@link FMLInitializationEvent} handler
|
||||
* SimpleNetworkWrapper wrapper = NetworkRegistry.newSimpleChannel("MYCHANNEL");
|
||||
* // Message1 is handled by the Message1Handler class, it has discriminator id 1 and it's on the client
|
||||
* wrapper.registerMessage(Message1Handler.class, Message1.class, 1, Side.CLIENT);
|
||||
* // Message2 is handled by the Message2Handler class, it has discriminator id 2 and it's on the server
|
||||
* wrapper.registerMessage(Message2Handler.class, Message2.class, 2, Side.SERVER);
|
||||
* </pre>
|
||||
* </code>
|
||||
*
|
||||
* @author cpw
|
||||
*/
|
||||
public class FCNetworkWrapper {
|
||||
|
||||
protected final EnumMap<Side, FMLEmbeddedChannel> channels;
|
||||
protected final FCIndexedCodec packetCodec;
|
||||
|
||||
public FCNetworkWrapper(String channelName) {
|
||||
packetCodec = new FCIndexedCodec();
|
||||
channels = NetworkRegistry.INSTANCE.newChannel(channelName, packetCodec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a message and it's associated handler. The message will have the supplied discriminator byte. The
|
||||
* message handler will be registered on the supplied side (this is the side where you want the message to be
|
||||
* processed and acted upon).
|
||||
*
|
||||
* @param messageHandler the message handler type
|
||||
* @param requestMessageType the message type
|
||||
* @param discriminator a discriminator byte
|
||||
* @param side the side for the handler
|
||||
*/
|
||||
public <REQ extends IMessage, REPLY extends IMessage> void registerMessage(
|
||||
Class<? extends IMessageHandler<REQ, REPLY>> messageHandler, Class<REQ> requestMessageType,
|
||||
int discriminator, Side side) {
|
||||
registerMessage(instantiate(messageHandler), requestMessageType, discriminator, side);
|
||||
}
|
||||
|
||||
static <REQ extends IMessage, REPLY extends IMessage> IMessageHandler<? super REQ, ? extends REPLY> instantiate(
|
||||
Class<? extends IMessageHandler<? super REQ, ? extends REPLY>> handler) {
|
||||
try {
|
||||
return handler.getDeclaredConstructor().newInstance();
|
||||
} catch (Exception e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a message and it's associated handler. The message will have the supplied discriminator byte. The
|
||||
* message handler will be registered on the supplied side (this is the side where you want the message to be
|
||||
* processed and acted upon).
|
||||
*
|
||||
* @param messageHandler the message handler instance
|
||||
* @param requestMessageType the message type
|
||||
* @param discriminator a discriminator byte
|
||||
* @param side the side for the handler
|
||||
*/
|
||||
public <REQ extends IMessage, REPLY extends IMessage> void registerMessage(
|
||||
IMessageHandler<? super REQ, ? extends REPLY> messageHandler, Class<REQ> requestMessageType,
|
||||
int discriminator, Side side) {
|
||||
packetCodec.addDiscriminator(discriminator, requestMessageType);
|
||||
FMLEmbeddedChannel channel = channels.get(side);
|
||||
String type = channel.findChannelHandlerNameForType(SimpleIndexedCodec.class);
|
||||
if (side == Side.SERVER) {
|
||||
addServerHandlerAfter(channel, type, messageHandler, requestMessageType);
|
||||
} else {
|
||||
addClientHandlerAfter(channel, type, messageHandler, requestMessageType);
|
||||
}
|
||||
}
|
||||
|
||||
private <REQ extends IMessage, REPLY extends IMessage, NH extends INetHandler> void addServerHandlerAfter(
|
||||
FMLEmbeddedChannel channel, String type, IMessageHandler<? super REQ, ? extends REPLY> messageHandler,
|
||||
Class<REQ> requestType) {
|
||||
SimpleChannelHandlerWrapper<REQ, REPLY> handler = getHandlerWrapper(messageHandler, Side.SERVER, requestType);
|
||||
channel.pipeline().addAfter(type, messageHandler.getClass().getName(), handler);
|
||||
}
|
||||
|
||||
private <REQ extends IMessage, REPLY extends IMessage, NH extends INetHandler> void addClientHandlerAfter(
|
||||
FMLEmbeddedChannel channel, String type, IMessageHandler<? super REQ, ? extends REPLY> messageHandler,
|
||||
Class<REQ> requestType) {
|
||||
SimpleChannelHandlerWrapper<REQ, REPLY> handler = getHandlerWrapper(messageHandler, Side.CLIENT, requestType);
|
||||
channel.pipeline().addAfter(type, messageHandler.getClass().getName(), handler);
|
||||
}
|
||||
|
||||
private <REPLY extends IMessage, REQ extends IMessage> SimpleChannelHandlerWrapper<REQ, REPLY> getHandlerWrapper(
|
||||
IMessageHandler<? super REQ, ? extends REPLY> messageHandler, Side side, Class<REQ> requestType) {
|
||||
return new SimpleChannelHandlerWrapper<REQ, REPLY>(messageHandler, side, requestType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a minecraft packet from the supplied message. Can be used where minecraft packets are required, such as
|
||||
* {@link TileEntity#getDescriptionPacket}.
|
||||
*
|
||||
* @param message The message to translate into packet form
|
||||
* @return A minecraft {@link Packet} suitable for use in minecraft APIs
|
||||
*/
|
||||
public Packet getPacketFrom(IMessage message) {
|
||||
return channels.get(Side.SERVER).generatePacketFrom(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone. The {@link IMessageHandler} for this message type should be on the CLIENT side.
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToAll(IMessage message) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL);
|
||||
channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the specified player. The {@link IMessageHandler} for this message type should be on the
|
||||
* CLIENT side.
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param player The player to send it to
|
||||
*/
|
||||
public void sendTo(IMessage message, EntityPlayerMP player) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
||||
.set(FMLOutboundHandler.OutboundTarget.PLAYER);
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(player);
|
||||
channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone within a certain range of a point. The {@link IMessageHandler} for this message
|
||||
* type should be on the CLIENT side.
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param point The {@link TargetPoint} around which to send
|
||||
*/
|
||||
public void sendToAllAround(IMessage message, TargetPoint point) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
||||
.set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT);
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(point);
|
||||
channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone within the supplied dimension. The {@link IMessageHandler} for this message type
|
||||
* should be on the CLIENT side.
|
||||
*
|
||||
* @param message The message to send
|
||||
* @param dimensionId The dimension id to target
|
||||
*/
|
||||
public void sendToDimension(IMessage message, int dimensionId) {
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
||||
.set(FMLOutboundHandler.OutboundTarget.DIMENSION);
|
||||
channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(dimensionId);
|
||||
channels.get(Side.SERVER).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the server. The {@link IMessageHandler} for this message type should be on the SERVER side.
|
||||
*
|
||||
* @param message The message to send
|
||||
*/
|
||||
public void sendToServer(IMessage message) {
|
||||
channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET)
|
||||
.set(FMLOutboundHandler.OutboundTarget.TOSERVER);
|
||||
channels.get(Side.CLIENT).writeAndFlush(message).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import com.glodblock.github.inventory.external.AEFluidInterfaceHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.SPacketMEUpdateBuffer;
|
||||
import com.glodblock.github.network.wrapper.FCNetworkWrapper;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -23,12 +24,10 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
public final SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel(FluidCraft.MODID);
|
||||
public final FCNetworkWrapper netHandler = new FCNetworkWrapper(FluidCraft.MODID);
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {}
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.9 KiB |
Reference in new issue
Block a user