mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
level terminal
This commit is contained in:
1 parent
461d574a54
commit
b9860934ee
13 files changed
+111
-236
No files matched your search
@@ -1,17 +1,17 @@
|
||||
package com.glodblock.github.api.registries;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public class LevelItemInfo {
|
||||
|
||||
public ItemStack stack;
|
||||
public IAEStack<?> stack;
|
||||
public long quantity;
|
||||
public long batchSize;
|
||||
public LevelState state;
|
||||
|
||||
public LevelItemInfo(@NotNull ItemStack stack, long quantity, long batchSize, LevelState state) {
|
||||
public LevelItemInfo(@NotNull IAEStack<?> stack, long quantity, long batchSize, LevelState state) {
|
||||
this.stack = stack;
|
||||
this.quantity = quantity;
|
||||
this.batchSize = batchSize;
|
||||
|
||||
@@ -2,103 +2,47 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
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.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketLevelTerminalCommands;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.client.gui.implementations.GuiLevelEmitter;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.container.IContainerSubGui;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.ILevelEmitter;
|
||||
|
||||
public class GuiLevelEmitterProxy extends GuiLevelEmitter {
|
||||
public class GuiLevelEmitterProxy extends GuiLevelEmitter implements IGuiSub {
|
||||
|
||||
protected GuiType originalGui;
|
||||
protected Util.DimensionalCoordSide originalBlockPos;
|
||||
protected ItemStack originalGuiIcon;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
protected final IContainerSubGui container;
|
||||
protected GuiTabButton originalGuiBtn;;
|
||||
|
||||
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final PartLevelEmitter te) {
|
||||
public GuiLevelEmitterProxy(final InventoryPlayer inventoryPlayer, final ILevelEmitter te) {
|
||||
super(inventoryPlayer, te);
|
||||
|
||||
if (inventoryPlayer.player.openContainer instanceof AEBaseContainer container) {
|
||||
var target = container.getTarget();
|
||||
if (target instanceof PartLevelTerminal terminal) {
|
||||
originalGuiIcon = 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)) {
|
||||
originalGuiIcon = 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,
|
||||
inventoryPlayer.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
} else if (target instanceof WirelessLevelTerminalInventory terminal) {
|
||||
originalGuiIcon = ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack();
|
||||
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
|
||||
originalBlockPos = new Util.DimensionalCoordSide(
|
||||
terminal.getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0,
|
||||
inventoryPlayer.player.worldObj.provider.dimensionId,
|
||||
ForgeDirection.UNKNOWN,
|
||||
"");
|
||||
|
||||
}
|
||||
}
|
||||
this.container = (IContainerSubGui) inventorySlots;
|
||||
this.container.setGuiLink(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
if (container.getPrimaryGuiIcon() != null) initPrimaryGuiButton();
|
||||
}
|
||||
|
||||
if (this.originalGuiIcon != null) {
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 151,
|
||||
this.guiTop - 4,
|
||||
this.originalGuiIcon,
|
||||
this.originalGuiIcon.getDisplayName(),
|
||||
itemRender);
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
this.buttonList.add(originalGuiBtn);
|
||||
}
|
||||
public void initPrimaryGuiButton() {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 57,
|
||||
this.guiTop,
|
||||
container.getPrimaryGuiIcon(),
|
||||
container.getPrimaryGuiIcon().getDisplayName(),
|
||||
itemRender));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
CPacketLevelTerminalCommands message = new CPacketLevelTerminalCommands(
|
||||
CPacketLevelTerminalCommands.Action.BACK,
|
||||
originalBlockPos.x,
|
||||
originalBlockPos.y,
|
||||
originalBlockPos.z,
|
||||
originalBlockPos.getDimension(),
|
||||
originalBlockPos.getSide());
|
||||
message.setOriginalGui(originalGui.ordinal());
|
||||
FluidCraft.proxy.netHandler.sendToServer(message);
|
||||
} else {
|
||||
super.actionPerformed(btn);
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ import appeng.api.config.TerminalFontSize;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
@@ -74,7 +75,6 @@ import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextField, IGuiTooltipHandler {
|
||||
@@ -544,7 +544,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
&& relMouseY >= Math.max(viewY + rowYTop, LevelTerminalSection.TITLE_HEIGHT)
|
||||
&& relMouseY < Math.min(viewY + rowYBot, viewHeight);
|
||||
if (info != null) {
|
||||
ItemStack itemStack = info.stack;
|
||||
IAEStack<?> aes = info.stack;
|
||||
long quantity = info.quantity;
|
||||
long batch = info.batchSize;
|
||||
LevelState state = info.state;
|
||||
@@ -553,10 +553,10 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
itemStack.stackSize = 0;
|
||||
aes.setStackSize(1);
|
||||
renderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
|
||||
renderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
|
||||
renderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
|
||||
aes.drawInGui(mc, 0, 0);
|
||||
aes.drawOverlayInGui(mc, 0, 0, false, false, false, false);
|
||||
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
|
||||
int color = switch (state) {
|
||||
case Idle -> FCGuiColors.StateIdle.getColor();
|
||||
@@ -584,7 +584,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
|
||||
}
|
||||
} else {
|
||||
tooltipStack = itemStack;
|
||||
tooltipStack = Platform.stackConvert(aes).getItemStack();
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
} else if (entry.filteredRecipes[slotIdx]) {
|
||||
@@ -1105,7 +1105,9 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
continue;
|
||||
}
|
||||
|
||||
if (itemStackMatchesSearchTerm(entry.infoList[i].stack, output)) {
|
||||
if (itemStackMatchesSearchTerm(
|
||||
Platform.stackConvert(entry.infoList[i].stack).getItemStack(),
|
||||
output)) {
|
||||
shouldAdd = true;
|
||||
entry.filteredRecipes[i] = false;
|
||||
} else {
|
||||
@@ -1234,10 +1236,15 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
blockPos.getDimension(),
|
||||
blockPos.getSide()));
|
||||
} else if (isShiftKeyDown()) {
|
||||
/*
|
||||
* FluidCraft.proxy.netHandler.sendToServer( new CPacketRenamer( blockPos.x, blockPos.y, blockPos.z,
|
||||
* blockPos.getDimension(), blockPos.getSide()));
|
||||
*/
|
||||
FluidCraft.proxy.netHandler.sendToServer(
|
||||
new CPacketLevelTerminalCommands(
|
||||
Action.RENAME,
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
blockPos.getDimension(),
|
||||
blockPos.getSide()));
|
||||
|
||||
} else {
|
||||
BlockPosHighlighter.highlightBlocks(
|
||||
mc.thePlayer,
|
||||
@@ -1274,7 +1281,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
|
||||
};
|
||||
|
||||
if (action != null && this.infoList[slotIdx] != null) {
|
||||
AEItemStack aeStack = AEItemStack.create(this.infoList[slotIdx].stack);
|
||||
IAEStack<?> aeStack = this.infoList[slotIdx].stack;
|
||||
((AEBaseContainer) inventorySlots).setTargetStack(aeStack);
|
||||
// FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, slotIdx, 0,
|
||||
// aeStack));
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.glodblock.github.util.NameConst;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.implementations.GuiSub;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -155,7 +154,7 @@ public class ContainerLevelTerminal extends FCBaseContainer {
|
||||
knownTracker.infoList[i] = null;
|
||||
if (update == null) update = new SPacketLevelTerminalUpdate();
|
||||
update.addOverwriteSlotEntry(knownTracker.id, i, null);
|
||||
} else if (!ItemStack.areItemStacksEqual(prev[i].stack, curr[i].stack)
|
||||
} else if (!Platform.isStacksIdentical(prev[i].stack, curr[i].stack)
|
||||
|| prev[i].quantity == curr[i].quantity
|
||||
|| prev[i].batchSize == curr[i].batchSize
|
||||
|| prev[i].state == curr[i].state) {
|
||||
|
||||
@@ -61,7 +61,6 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.parts.p2p.PartP2PTunnelStatic;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -306,12 +305,6 @@ public class PartFluidP2PInterface extends PartP2PTunnelStatic<PartFluidP2PInter
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteMemoryCardData(PartP2PTunnel<?> newTunnel, NBTTagCompound data) throws GridAccessException {
|
||||
this.duality.getConfigManager().readFromNBT(data);
|
||||
super.pasteMemoryCardData(newTunnel, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToWorld() {
|
||||
super.addToWorld();
|
||||
|
||||
@@ -353,7 +353,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
return Arrays.stream(this.requests).map(request -> {
|
||||
if (request == null) return null;
|
||||
return new LevelItemInfo(
|
||||
request.itemStack.getItemStack(),
|
||||
AEItemStack.create(request.itemStack.getItemStack()),
|
||||
request.getQuantity(),
|
||||
request.getBatchSize(),
|
||||
request.getState());
|
||||
|
||||
@@ -8,9 +8,7 @@ import java.util.WeakHashMap;
|
||||
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.ILevelViewableAdapter;
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.coremod.registries.adapters.PartFluidLevelEmitterAdapter;
|
||||
import com.glodblock.github.coremod.registries.adapters.PartLevelEmitterAdapter;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
@@ -29,7 +27,6 @@ public class LevelTerminalRegistry implements ILevelTerminalRegistry {
|
||||
|
||||
{
|
||||
this.register(TileLevelMaintainer.class);
|
||||
this.register(PartFluidLevelEmitter.class, new PartFluidLevelEmitterAdapter());
|
||||
this.register(PartLevelEmitter.class, new PartLevelEmitterAdapter());
|
||||
}
|
||||
|
||||
|
||||
-90
@@ -1,90 +0,0 @@
|
||||
package com.glodblock.github.coremod.registries.adapters;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.ILevelViewableAdapter;
|
||||
import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.common.parts.PartFluidLevelEmitter;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
|
||||
public class PartFluidLevelEmitterAdapter implements ILevelViewable, ILevelViewableAdapter {
|
||||
|
||||
private PartFluidLevelEmitter delegate;
|
||||
|
||||
public PartFluidLevelEmitterAdapter() {}
|
||||
|
||||
public ILevelViewable adapt(IGridHost gridHost) {
|
||||
if (gridHost instanceof PartFluidLevelEmitter levelEmitter) this.delegate = levelEmitter;
|
||||
return this;
|
||||
};
|
||||
|
||||
@Override
|
||||
public DimensionalCoord getLocation() {
|
||||
return delegate.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTile() {
|
||||
return delegate.getTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getSide() {
|
||||
return delegate.getSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName(String name) {
|
||||
return delegate.getInventoryByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir) {
|
||||
return delegate.getGridNode(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType(ForgeDirection dir) {
|
||||
return delegate.getCableConnectionType(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void securityBreak() {
|
||||
delegate.securityBreak();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
return delegate.getCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return delegate.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
delegate.hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelItemInfo[] getLevelItemInfoList() {
|
||||
ItemStack stack = delegate.getInventoryByName("config").getStackInSlot(0);
|
||||
if (stack == null) return new LevelItemInfo[] { null };
|
||||
return new LevelItemInfo[] { new LevelItemInfo(
|
||||
stack,
|
||||
1, // delegate.getReportingValue()
|
||||
-1,
|
||||
delegate.isProvidingStrongPower() > 0 ? LevelState.Craft : LevelState.Idle) };
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.coremod.registries.adapters;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -12,8 +11,10 @@ import com.glodblock.github.api.registries.LevelState;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.client.StorageName;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class PartLevelEmitterAdapter implements ILevelViewable, ILevelViewableAdapter {
|
||||
@@ -79,7 +80,7 @@ public class PartLevelEmitterAdapter implements ILevelViewable, ILevelViewableAd
|
||||
|
||||
@Override
|
||||
public LevelItemInfo[] getLevelItemInfoList() {
|
||||
ItemStack stack = delegate.getInventoryByName("config").getStackInSlot(0);
|
||||
IAEStack<?> stack = delegate.getAEInventoryByName(StorageName.NONE).getAEStackInSlot(0);
|
||||
if (stack == null) return new LevelItemInfo[] { null };
|
||||
return new LevelItemInfo[] { new LevelItemInfo(
|
||||
stack,
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.glodblock.github.client.gui.GuiFluidPatternEncoder;
|
||||
import com.glodblock.github.client.gui.GuiFluidStorageBus;
|
||||
import com.glodblock.github.client.gui.GuiIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLargeIngredientBuffer;
|
||||
import com.glodblock.github.client.gui.GuiLevelEmitterProxy;
|
||||
import com.glodblock.github.client.gui.GuiLevelMaintainer;
|
||||
import com.glodblock.github.client.gui.GuiLevelTerminal;
|
||||
import com.glodblock.github.client.gui.GuiLevelWireless;
|
||||
@@ -51,7 +52,9 @@ import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.ILevelEmitter;
|
||||
|
||||
public enum GuiType {
|
||||
|
||||
@@ -68,6 +71,19 @@ public enum GuiType {
|
||||
}
|
||||
}),
|
||||
|
||||
LEVEL_EMITTER_PROXY(new PartGuiFactory<>(ILevelEmitter.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, ILevelEmitter inv) {
|
||||
return new ContainerLevelEmitter(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, ILevelEmitter inv) {
|
||||
return new GuiLevelEmitterProxy(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
LEVEL_MAINTAINER(new TileGuiFactory<>(TileLevelMaintainer.class) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
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.common.parts.PartFluidLevelEmitter;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.IContainerSubGui;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.ILevelEmitter;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -35,6 +41,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
DISABLE,
|
||||
ENABLE_ALL,
|
||||
DISABLE_ALL,
|
||||
RENAME
|
||||
}
|
||||
|
||||
public CPacketLevelTerminalCommands() {}
|
||||
@@ -57,7 +64,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
action = Action.values()[buf.readInt()];
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
case EDIT, RENAME -> {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
@@ -83,7 +90,7 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(action.ordinal());
|
||||
switch (action) {
|
||||
case EDIT -> {
|
||||
case EDIT, RENAME -> {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
@@ -110,30 +117,25 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(CPacketLevelTerminalCommands message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
switch (message.action) {
|
||||
case EDIT -> {
|
||||
|
||||
if (Objects.requireNonNull(message.action) == Action.EDIT) {
|
||||
if (player.openContainer instanceof AEBaseContainer abc) {
|
||||
final PrimaryGui pGui = abc.getPrimaryGui();
|
||||
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim)
|
||||
.getTileEntity(message.x, message.y, message.z);
|
||||
|
||||
if (tile instanceof IPartHost host) {
|
||||
IPart part = host.getPart(message.side);
|
||||
if (part instanceof PartLevelEmitter) {
|
||||
if (part instanceof ILevelEmitter) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.LEVEL_EMITTER_PROXY);
|
||||
} else if (part instanceof PartFluidLevelEmitter) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
new BlockPos(tile),
|
||||
message.side,
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
}
|
||||
} else {
|
||||
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
tile.getWorldObj(),
|
||||
@@ -141,21 +143,24 @@ public class CPacketLevelTerminalCommands implements IMessage {
|
||||
message.side,
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
}
|
||||
}
|
||||
case BACK -> {
|
||||
GuiType originalGui = GuiType.getByOrdinal(message.originalGui);
|
||||
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);
|
||||
if (player.openContainer instanceof IContainerSubGui sg) {
|
||||
sg.setPrimaryGui(pGui);
|
||||
}
|
||||
}
|
||||
} else if (Objects.requireNonNull(message.action) == Action.RENAME) {
|
||||
if (player.openContainer instanceof AEBaseContainer abc) {
|
||||
final PrimaryGui pGui = abc.getPrimaryGui();
|
||||
|
||||
TileEntity tile = DimensionManager.getWorld(message.dim)
|
||||
.getTileEntity(message.x, message.y, message.z);
|
||||
|
||||
Platform.openGUI(player, tile, message.side, GuiBridge.GUI_RENAMER);
|
||||
|
||||
if (player.openContainer instanceof IContainerSubGui sg) {
|
||||
sg.setPrimaryGui(pGui);
|
||||
}
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import static appeng.util.Platform.readStackByte;
|
||||
import static appeng.util.Platform.writeStackByte;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -14,6 +16,7 @@ import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.client.gui.GuiLevelTerminal;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
@@ -176,7 +179,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
infolist = new LevelItemInfo[infoSize];
|
||||
for (int i = 0; i < infoSize; i++) {
|
||||
if (!buf.readBoolean()) continue;
|
||||
ItemStack stack = ByteBufUtils.readItemStack(buf);
|
||||
IAEStack<?> stack = readStackByte(buf);
|
||||
long quantity = buf.readLong();
|
||||
long batchSize = buf.readLong();
|
||||
LevelState state = LevelState.values()[buf.readInt()];
|
||||
@@ -206,7 +209,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
buf.writeBoolean(info != null);
|
||||
if (info == null) continue;
|
||||
// System.out.println("Writing info: " + info.stack != null);
|
||||
ByteBufUtils.writeItemStack(buf, info.stack);
|
||||
writeStackByte(info.stack, buf);
|
||||
buf.writeLong(info.quantity);
|
||||
buf.writeLong(info.batchSize);
|
||||
buf.writeInt(info.state.ordinal());
|
||||
@@ -293,7 +296,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
this.index = buf.readInt();
|
||||
if (buf.readBoolean()) {
|
||||
this.info = new LevelItemInfo(
|
||||
ByteBufUtils.readItemStack(buf),
|
||||
readStackByte(buf),
|
||||
buf.readLong(),
|
||||
buf.readLong(),
|
||||
LevelState.values()[buf.readInt()]);
|
||||
@@ -312,7 +315,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
super.write(buf);
|
||||
buf.writeInt(index);
|
||||
buf.writeBoolean(info != null);
|
||||
ByteBufUtils.writeItemStack(buf, info.stack);
|
||||
writeStackByte(info.stack, buf);
|
||||
buf.writeLong(info.quantity);
|
||||
buf.writeLong(info.batchSize);
|
||||
buf.writeInt(info.state.ordinal());
|
||||
@@ -334,7 +337,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
this.infoList = new LevelItemInfo[infoSize];
|
||||
for (int i = 0; i < infoSize; i++) {
|
||||
if (!buf.readBoolean()) continue;
|
||||
ItemStack stack = ByteBufUtils.readItemStack(buf);
|
||||
IAEStack<?> stack = readStackByte(buf);
|
||||
long quantity = buf.readLong();
|
||||
long batchSize = buf.readLong();
|
||||
LevelState state = LevelState.values()[buf.readInt()];
|
||||
@@ -356,7 +359,7 @@ public class SPacketLevelTerminalUpdate implements IMessage {
|
||||
buf.writeBoolean(info != null);
|
||||
if (info == null) continue;
|
||||
buf.writeInt(i);
|
||||
ByteBufUtils.writeItemStack(buf, info.stack);
|
||||
writeStackByte(info.stack, buf);
|
||||
buf.writeLong(info.quantity);
|
||||
buf.writeLong(info.batchSize);
|
||||
buf.writeInt(info.state.ordinal());
|
||||
|
||||
Reference in new issue
Block a user