mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
add hotkey and baubles support
This commit is contained in:
1 parent
09c1c49529
commit
aef677868b
22 files changed
+249
-48
No files matched your search
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
|
||||
@@ -9,4 +12,13 @@ public class GuiFluidPatternExWireless extends GuiFluidPatternTerminalEx {
|
||||
public GuiFluidPatternExWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
if (s instanceof SlotDisabled || s.isPlayerSide()) {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
|
||||
} else {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import appeng.core.localization.GuiText;
|
||||
|
||||
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternWireless;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
@@ -29,6 +31,10 @@ public class GuiFluidPatternTerminal extends FCGuiEncodeTerminal {
|
||||
super(inventoryPlayer, te, new ContainerFluidPatternTerminal(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
public GuiFluidPatternTerminal(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te, new ContainerFluidPatternWireless(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
|
||||
@@ -11,7 +11,9 @@ import appeng.client.gui.widgets.GuiImgButton;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternExWireless;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -24,6 +26,12 @@ public class GuiFluidPatternTerminalEx extends FCGuiEncodeTerminal {
|
||||
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
|
||||
}
|
||||
|
||||
public GuiFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te, new ContainerFluidPatternExWireless(inventoryPlayer, te));
|
||||
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
|
||||
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void initGui() {
|
||||
|
||||
@@ -2,6 +2,9 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
|
||||
public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
|
||||
@@ -9,4 +12,13 @@ public class GuiFluidPatternWireless extends GuiFluidPatternTerminal {
|
||||
public GuiFluidPatternWireless(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
if (s instanceof SlotDisabled || s.isPlayerSide()) {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
|
||||
} else {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@ import net.minecraft.inventory.Container;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
@@ -27,9 +29,13 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
|
||||
public FCBaseMEGui(final InventoryPlayer inventoryPlayer, Container container) {
|
||||
super(container);
|
||||
if (inventoryPlayer.getCurrentItem() != null
|
||||
&& inventoryPlayer.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal)
|
||||
this.drawSwitchGuiBtn = true;
|
||||
if (container instanceof FCBaseContainer) {
|
||||
Object target = ((FCBaseContainer) container).getTarget();
|
||||
if (target instanceof IWirelessTerminal
|
||||
&& ((IWirelessTerminal) target).getItemStack().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
this.drawSwitchGuiBtn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,14 +141,4 @@ public abstract class FCBaseMEGui extends AEBaseMEGui {
|
||||
}
|
||||
super.actionPerformed(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,8 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
@@ -50,6 +48,8 @@ import codechicken.nei.util.TextHistory;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerMonitor;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
@@ -119,7 +119,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
InventoryHandler.switchGui(GuiType.CRAFTING_STATUS);
|
||||
}
|
||||
if (btn instanceof GuiImgButton) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
@@ -314,7 +314,7 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends FCBaseMEGui
|
||||
|
||||
for (final Object s : this.inventorySlots.inventorySlots) {
|
||||
if (s instanceof AppEngSlot) {
|
||||
if (((Slot) s).xDisplayPosition < 195) {
|
||||
if (((Slot) s).xDisplayPosition < 195 || s instanceof SlotDisabled) {
|
||||
this.repositionSlot((AppEngSlot) s);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
|
||||
InventoryHandler.openGui(
|
||||
this.getInventoryPlayer().player,
|
||||
getWorld(),
|
||||
new BlockPos(this.getPlayerInv().currentItem, 0, 0),
|
||||
new BlockPos(((IWirelessTerminal) ah).getInventorySlot(), 0, 0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
originalGui);
|
||||
} else if (this.getOpenContext() != null) {
|
||||
|
||||
@@ -29,7 +29,9 @@ public abstract class FCBaseContainer extends AEBaseContainer {
|
||||
if (isWirelessTerminal()) {
|
||||
if (this.host != null) {
|
||||
final int slotIndex = this.host.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
if (Util.GuiHelper.decodeInvType(slotIndex).getLeft() == Util.GuiHelper.InvType.PLAYER_INV) {
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
}
|
||||
return slotIndex;
|
||||
} else {
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -13,11 +14,15 @@ import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.util.Platform;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
@@ -36,7 +41,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessUltraTerminal> {
|
||||
implements IBauble, IRegister<ItemWirelessUltraTerminal> {
|
||||
|
||||
public final static String MODE = "mode_main";
|
||||
private final static List<GuiType> guis = new ArrayList<>();
|
||||
@@ -162,9 +167,10 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
}
|
||||
|
||||
public static void switchTerminal(EntityPlayer player, GuiType guiType) {
|
||||
if (player.inventory.getCurrentItem().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
((ItemWirelessUltraTerminal) player.inventory.getCurrentItem().getItem())
|
||||
.setMode(guiType, player.inventory.getCurrentItem());
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
|
||||
if (term == null) return;
|
||||
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).setMode(guiType, term.getRight());
|
||||
}
|
||||
if (Platform.isClient()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType, true));
|
||||
@@ -173,7 +179,7 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
player.inventory.currentItem,
|
||||
term.getLeft(),
|
||||
Util.GuiHelper.encodeType(
|
||||
guis.indexOf(GuiType.valueOf(guiType.toString())),
|
||||
Util.GuiHelper.GuiType.ITEM),
|
||||
@@ -191,4 +197,34 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
public GuiType guiGuiType(ItemStack stack) {
|
||||
return readMode(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.RING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEquipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEquip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUnequip(ItemStack itemStack, EntityLivingBase entityLivingBase) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
|
||||
import com.glodblock.github.inventory.item.IItemInventory;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public abstract class ItemGuiFactory<T> implements IGuiFactory {
|
||||
|
||||
@@ -29,7 +30,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
ItemStack item = Util.getWirelessTerminal(player, x);
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
@@ -56,7 +57,7 @@ public abstract class ItemGuiFactory<T> implements IGuiFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
ItemStack item = Util.getWirelessTerminal(player, x);
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -30,9 +30,8 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
@Override
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
|
||||
if (result.getLeft() == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
ItemStack item = Util.getWirelessTerminal(player, x);
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
@@ -63,7 +62,7 @@ public abstract class PartOrItemGuiFactory<T> extends PartGuiFactory<T> {
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
ImmutablePair<Util.GuiHelper.GuiType, Integer> result = Util.GuiHelper.decodeType(y);
|
||||
if (result.left == Util.GuiHelper.GuiType.ITEM) {
|
||||
ItemStack item = player.getHeldItem();
|
||||
ItemStack item = Util.getWirelessTerminal(player, x);
|
||||
if (item == null || !(item.getItem() instanceof IItemInventory)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ public class WirelessFluidTerminalInventory extends MEMonitorHandler<IAEFluidSta
|
||||
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
|
||||
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
|
||||
out.putSetting(Settings.VIEW_MODE, ViewItems.ALL);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class KeybindLoader implements Runnable {
|
||||
|
||||
public static KeyBinding openTerminal;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
openTerminal = new KeyBinding("key.OpenTerminal", Keyboard.CHAR_NONE, "itemGroup.ae2fc");
|
||||
ClientRegistry.registerKeyBinding(openTerminal);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyInput(InputEvent.KeyInputEvent event) {
|
||||
if (Minecraft.getMinecraft().currentScreen != null) return;
|
||||
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
|
||||
if (p.openContainer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (openTerminal.isPressed()) {
|
||||
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(p);
|
||||
if (term != null && term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
ItemWirelessUltraTerminal.switchTerminal(
|
||||
p,
|
||||
((ItemWirelessUltraTerminal) term.getRight().getItem()).guiGuiType(term.getRight()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import appeng.core.AELog;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
@@ -97,11 +98,11 @@ public class CPacketCraftRequest implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
GuiType.FLUID_CRAFTING_CONFIRM);
|
||||
} else {
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
GuiType.FLUID_CRAFTING_CONFIRM_ITEM);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -94,6 +95,7 @@ public class CPacketInventoryAction implements IMessage {
|
||||
final EntityPlayerMP sender = ctx.getServerHandler().playerEntity;
|
||||
if (sender.openContainer instanceof AEBaseContainer) {
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
Object target = baseContainer.getTarget();
|
||||
if (message.action == InventoryAction.AUTO_CRAFT) {
|
||||
final ContainerOpenContext context = baseContainer.getOpenContext();
|
||||
if (context != null) {
|
||||
@@ -105,12 +107,12 @@ public class CPacketInventoryAction implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
|
||||
GuiType.FLUID_CRAFTING_AMOUNT);
|
||||
} else {
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
sender.worldObj,
|
||||
new BlockPos(
|
||||
sender.inventory.currentItem,
|
||||
((IWirelessTerminal) target).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
@@ -136,12 +138,12 @@ public class CPacketInventoryAction implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(baseContainer.getOpenContext().getSide()),
|
||||
GuiType.PATTERN_VALUE_SET);
|
||||
} else {
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
sender,
|
||||
sender.worldObj,
|
||||
new BlockPos(
|
||||
sender.inventory.currentItem,
|
||||
((IWirelessTerminal) target).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
ForgeDirection.UNKNOWN,
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.PartOrItemGuiFactory;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -85,11 +86,11 @@ public class CPacketPatternValueSet implements IMessage {
|
||||
0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.originGui);
|
||||
} else {
|
||||
} else if (target instanceof IWirelessTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(player.inventory.currentItem, 0, 0),
|
||||
new BlockPos(((IWirelessTerminal) target).getInventorySlot(), 0, 0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.originGui);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
@@ -84,12 +85,12 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.guiType);
|
||||
} else {
|
||||
} else if (((AEBaseContainer) cont).getTarget() instanceof IWirelessTerminal) {
|
||||
InventoryHandler.openGui(
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(
|
||||
player.inventory.currentItem,
|
||||
((IWirelessTerminal) ((AEBaseContainer) cont).getTarget()).getInventorySlot(),
|
||||
Util.GuiHelper.encodeType(0, Util.GuiHelper.GuiType.ITEM),
|
||||
0),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.proxy;
|
||||
|
||||
import com.glodblock.github.loader.KeybindLoader;
|
||||
import com.glodblock.github.loader.ListenerLoader;
|
||||
import com.glodblock.github.loader.RenderLoader;
|
||||
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
|
||||
@@ -21,6 +22,7 @@ public class ClientProxy extends CommonProxy {
|
||||
super.init(event);
|
||||
(new ListenerLoader()).run();
|
||||
(new RenderLoader()).run();
|
||||
(new KeybindLoader()).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,10 +39,12 @@ import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import baubles.api.BaublesApi;
|
||||
|
||||
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.item.IFluidPortableCell;
|
||||
|
||||
@@ -54,18 +56,28 @@ public final class Util {
|
||||
|
||||
public static int drainItemPower(AEBaseContainer c, InventoryPlayer ip, int slot, int ticks, double pm,
|
||||
IFluidPortableCell wt) {
|
||||
final ItemStack currentItem = slot < 0 ? ip.getCurrentItem() : ip.getStackInSlot(slot);
|
||||
if (wt != null) {
|
||||
if (currentItem != wt.getItemStack()) {
|
||||
if (currentItem != null) {
|
||||
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
|
||||
ip.setInventorySlotContents(ip.currentItem, wt.getItemStack());
|
||||
if (slot != -1) {
|
||||
final ItemStack currentItem = getWirelessTerminal(ip.player, slot);
|
||||
if (wt != null) {
|
||||
if (currentItem != wt.getItemStack()) {
|
||||
if (currentItem != null) {
|
||||
if (Platform.isSameItem(wt.getItemStack(), currentItem)) {
|
||||
if (GuiHelper.decodeInvType(slot).getLeft() == GuiHelper.InvType.PLAYER_INV) {
|
||||
ip.setInventorySlotContents(slot, wt.getItemStack());
|
||||
} else {
|
||||
BaublesApi.getBaubles(ip.player).setInventorySlotContents(
|
||||
GuiHelper.decodeInvType(slot).getRight(),
|
||||
wt.getItemStack());
|
||||
}
|
||||
} else {
|
||||
c.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
c.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
c.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
c.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
c.setValidContainer(false);
|
||||
@@ -132,6 +144,40 @@ public final class Util {
|
||||
return new NullInventory<>();
|
||||
}
|
||||
|
||||
public static ItemStack getWirelessTerminal(EntityPlayer player, int x) {
|
||||
ImmutablePair<GuiHelper.InvType, Integer> result = GuiHelper.decodeInvType(x);
|
||||
if (result.getLeft() == GuiHelper.InvType.PLAYER_INV) {
|
||||
return player.inventory.getStackInSlot(result.getRight());
|
||||
} else {
|
||||
return BaublesApi.getBaubles(player).getStackInSlot(result.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutablePair<Integer, ItemStack> getUltraWirelessTerm(EntityPlayer player) {
|
||||
int invSize = player.inventory.getSizeInventory();
|
||||
|
||||
if (invSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack is = player.inventory.getStackInSlot(i);
|
||||
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
return new ImmutablePair<>(i, is);
|
||||
}
|
||||
}
|
||||
IInventory handler = BaublesApi.getBaubles(player);
|
||||
if (handler != null) {
|
||||
invSize = handler.getSizeInventory();
|
||||
for (int i = 0; i < invSize; ++i) {
|
||||
ItemStack is = handler.getStackInSlot(i);
|
||||
if (is != null && is.getItem() instanceof ItemWirelessUltraTerminal) {
|
||||
return new ImmutablePair<>(GuiHelper.encodeType(i, GuiHelper.InvType.PLAYER_BAUBLES), is);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
|
||||
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
|
||||
@@ -323,6 +369,11 @@ public final class Util {
|
||||
ITEM
|
||||
}
|
||||
|
||||
public enum InvType {
|
||||
PLAYER_INV,
|
||||
PLAYER_BAUBLES
|
||||
}
|
||||
|
||||
private static final int value = 1 << 30;
|
||||
|
||||
public static int encodeType(int y, GuiType type) {
|
||||
@@ -332,6 +383,13 @@ public final class Util {
|
||||
return value | (type.ordinal() << 29) | y;
|
||||
}
|
||||
|
||||
public static int encodeType(int x, InvType type) {
|
||||
if (Math.abs(x) > (1 << 28)) {
|
||||
throw new IllegalArgumentException("out of range");
|
||||
}
|
||||
return value | (type.ordinal() << 29) | x;
|
||||
}
|
||||
|
||||
public static ImmutablePair<GuiType, Integer> decodeType(int y) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
return new ImmutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
|
||||
@@ -339,6 +397,14 @@ public final class Util {
|
||||
return new ImmutablePair<>(GuiType.TILE, y);
|
||||
}
|
||||
}
|
||||
|
||||
public static ImmutablePair<InvType, Integer> decodeInvType(int x) {
|
||||
if (Math.abs(x) > (1 << 28)) {
|
||||
return new ImmutablePair<>(InvType.values()[x >> 29 & 1], x - (3 << 29 & x));
|
||||
} else {
|
||||
return new ImmutablePair<>(InvType.PLAYER_INV, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
|
||||
Reference in new issue
Block a user