mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-08 12:34:58 +00:00
Universal GUI (#872)
Co-authored-by: Kogepan229 <kogepan25629@gmail.com> Co-authored-by: Kogepan229 <73163994+Kogepan229@users.noreply.github.com> Co-authored-by: Martin Robertz <dream-master@gmx.net>
This commit is contained in:
225 files changed
+8182
-5684
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name 'MM repo'
|
||||
url 'https://maven.k-4u.nl/'
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package appeng.api.features;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
|
||||
public interface ILevelViewable extends IGridHost, ICustomNameObject {
|
||||
|
||||
DimensionalCoord getLocation();
|
||||
|
||||
TileEntity getTile();
|
||||
|
||||
ForgeDirection getSide();
|
||||
|
||||
/**
|
||||
* Number of rows to expect. This is used with {@link #rowSize()} to determine how to render the slots.
|
||||
*/
|
||||
default int rows() {
|
||||
return 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Number of slots per row.
|
||||
*/
|
||||
default int rowSize() {
|
||||
return 1;
|
||||
};
|
||||
|
||||
LevelItemInfo[] getLevelItemInfoList();
|
||||
|
||||
}
|
||||
@@ -47,6 +47,14 @@ public interface IWirelessTermHandler extends INetworkEncodable {
|
||||
*/
|
||||
boolean hasPower(EntityPlayer player, double amount, ItemStack is);
|
||||
|
||||
default boolean hasInfinityPower(ItemStack is) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean hasInfinityRange(ItemStack is) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the config manager for the wireless terminal.
|
||||
*
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface IWirelessTermRegistry {
|
||||
* opens the wireless terminal gui, the wireless terminal item, must be in the active slot on the tool bar.
|
||||
*/
|
||||
void openWirelessTerminalGui(ItemStack item, World w, EntityPlayer player);
|
||||
|
||||
boolean performCheck(final ItemStack item, final EntityPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package appeng.api.features;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public class LevelItemInfo {
|
||||
|
||||
public IAEStack<?> stack;
|
||||
public long quantity;
|
||||
public long batchSize;
|
||||
public LevelState state;
|
||||
|
||||
public LevelItemInfo(@Nonnull IAEStack<?> stack, long quantity, long batchSize, LevelState state) {
|
||||
this.stack = stack;
|
||||
this.quantity = quantity;
|
||||
this.batchSize = batchSize;
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package appeng.api.features;
|
||||
|
||||
public enum LevelState {
|
||||
None,
|
||||
Idle,
|
||||
Craft,
|
||||
Export,
|
||||
Error,
|
||||
NotFound,
|
||||
CantCraft
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
package appeng.api.implementations.guiobjects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -21,5 +22,12 @@ import net.minecraft.world.World;
|
||||
*/
|
||||
public interface IGuiItem {
|
||||
|
||||
IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z);
|
||||
@Deprecated
|
||||
default IGuiItemObject getGuiObject(ItemStack is, World world, int x, int y, int z) {
|
||||
return getGuiObject(is, world, null, x, y, z);
|
||||
}
|
||||
|
||||
default IGuiItemObject getGuiObject(ItemStack is, World world, EntityPlayer player, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,17 @@
|
||||
package appeng.api.implementations.guiobjects;
|
||||
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
/**
|
||||
* Obtained via {@link IGuiItem} getGuiObject
|
||||
*/
|
||||
public interface IPortableCell extends ITerminalHost, IMEMonitor<IAEItemStack>, IEnergySource, IGuiItemObject {
|
||||
public interface IPortableCell extends ITerminalHost, IEnergySource, IGuiItemObject, IInventorySlotAware {
|
||||
|
||||
@Override
|
||||
default GuiText getName() {
|
||||
return GuiText.PortableCell;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,9 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
* Any item which implements this can be treated as an IMEInventory via Util.getCell / Util.isCell It automatically
|
||||
@@ -69,15 +71,21 @@ public interface IStorageCell extends ICellWorkbenchItem {
|
||||
*/
|
||||
int getTotalTypes(ItemStack cellItem);
|
||||
|
||||
@Deprecated
|
||||
default boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition) {
|
||||
return this.isBlackListed(requestedAddition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to fine tune which items are allowed on a given cell, if you don't care, just return false; As the
|
||||
* handler for this type of cell is still the default cells, the normal AE black list is also applied.
|
||||
*
|
||||
* @param cellItem item
|
||||
* @param requestedAddition requested addition
|
||||
* @return true to preventAdditionOfItem
|
||||
*/
|
||||
boolean isBlackListed(ItemStack cellItem, IAEItemStack requestedAddition);
|
||||
default boolean isBlackListed(IAEStack<?> requestedAddition) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows you to specify if this storage cell can be stored inside other storage cells, only set this for special
|
||||
@@ -111,4 +119,8 @@ public interface IStorageCell extends ICellWorkbenchItem {
|
||||
* @return drain in ae/t this storage cell will use.
|
||||
*/
|
||||
double getIdleDrain();
|
||||
|
||||
default StorageChannel getStorageChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.api.implementations.tiles;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.helpers.ICellRestriction;
|
||||
import appeng.helpers.IOreFilterable;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.IIAEStackInventory;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
public interface ICellWorkbench extends IUpgradeableHost, IAEAppEngInventory, IConfigManagerHost, IOreFilterable,
|
||||
ICellRestriction, IIAEStackInventory {
|
||||
|
||||
ICellWorkbenchItem getCell();
|
||||
|
||||
boolean isSame(ICellWorkbench cellWorkbench);
|
||||
|
||||
IInventory getCellUpgradeInventory();
|
||||
|
||||
StorageChannel getStorageChannel();
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import appeng.api.util.CraftCancelListener;
|
||||
import appeng.api.util.CraftCompleteListener;
|
||||
import appeng.api.util.CraftUpdateListener;
|
||||
|
||||
public interface ICraftingCPU extends IBaseMonitor<IAEItemStack> {
|
||||
public interface ICraftingCPU extends IBaseMonitor {
|
||||
|
||||
/**
|
||||
* @return true if the CPU currently has a job.
|
||||
|
||||
@@ -52,6 +52,10 @@ public interface ICraftingGrid extends IGridCache {
|
||||
@Deprecated
|
||||
ImmutableMap<IAEItemStack, ImmutableList<ICraftingPatternDetails>> getCraftingPatterns();
|
||||
|
||||
@Deprecated
|
||||
Future<ICraftingJob> beginCraftingJob(World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack craftWhat,
|
||||
ICraftingCallback callback);
|
||||
|
||||
/**
|
||||
* Begin calculating a crafting job.
|
||||
*
|
||||
@@ -63,7 +67,7 @@ public interface ICraftingGrid extends IGridCache {
|
||||
* @return a future which will at an undetermined point in the future get you the {@link ICraftingJob} do not wait
|
||||
* on this, your be waiting forever.
|
||||
*/
|
||||
Future<ICraftingJob> beginCraftingJob(World world, IGrid grid, BaseActionSource actionSrc, IAEItemStack craftWhat,
|
||||
Future<ICraftingJob> beginCraftingJob(World world, IGrid grid, BaseActionSource actionSrc, IAEStack<?> craftWhat,
|
||||
ICraftingCallback callback);
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
package appeng.api.networking.crafting;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
* Passed to a ICraftingProvider as a interface to manipulate the available crafting jobs.
|
||||
@@ -25,8 +26,11 @@ public interface ICraftingProviderHelper {
|
||||
*/
|
||||
void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api);
|
||||
|
||||
@Deprecated
|
||||
void setEmitable(IAEItemStack what);
|
||||
|
||||
/**
|
||||
* Set an item can Emitable
|
||||
*/
|
||||
void setEmitable(IAEItemStack what);
|
||||
void setEmitable(IAEStack<?> what);
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface ICraftingRequester extends IActionHost {
|
||||
|
||||
@@ -37,7 +38,15 @@ public interface ICraftingRequester extends IActionHost {
|
||||
* @param mode action mode
|
||||
* @return unwanted item
|
||||
*/
|
||||
IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode);
|
||||
|
||||
default IAEStack<?> injectCraftedItems(ICraftingLink link, IAEStack<?> items, Actionable mode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
|
||||
return (IAEItemStack) injectCraftedItems(link, (IAEStack<?>) items, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the job changes from in progress, to either complete, or canceled.
|
||||
|
||||
@@ -21,10 +21,10 @@ public interface IBaseMonitor<T extends IAEStack> {
|
||||
/**
|
||||
* add a new Listener to the monitor, be sure to properly remove yourself when your done.
|
||||
*/
|
||||
void addListener(IMEMonitorHandlerReceiver<T> l, Object verificationToken);
|
||||
void addListener(IMEMonitorHandlerReceiver l, Object verificationToken);
|
||||
|
||||
/**
|
||||
* remove a Listener to the monitor.
|
||||
*/
|
||||
void removeListener(IMEMonitorHandlerReceiver<T> l);
|
||||
void removeListener(IMEMonitorHandlerReceiver l);
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable {
|
||||
*
|
||||
* @param input injected items
|
||||
*/
|
||||
void postAlterationOfStoredItems(StorageChannel chan, Iterable<? extends IAEStack> input, BaseActionSource src);
|
||||
void postAlterationOfStoredItems(StorageChannel chan, Iterable<? extends IAEStack<?>> input, BaseActionSource src);
|
||||
|
||||
/**
|
||||
* Used to add a cell provider to the storage system
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
public interface ICraftingTerminal extends ITerminalHost, IConfigManagerHost, IViewCellStorage, IAEAppEngInventory,
|
||||
ITerminalPins, ISegmentedInventory {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public interface IInterfaceTerminal extends IActionHost {
|
||||
|
||||
boolean needsUpdate();
|
||||
|
||||
default GuiText getName() {
|
||||
return GuiText.InterfaceTerminal;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import appeng.api.features.ILevelViewable;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.crafting.ICraftingProvider;
|
||||
import appeng.api.networking.crafting.ICraftingWatcherHost;
|
||||
import appeng.api.networking.energy.IEnergyWatcherHost;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.tile.inventory.IIAEStackInventory;
|
||||
|
||||
public interface ILevelEmitter
|
||||
extends IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEStack<?>>,
|
||||
ICraftingProvider, IGridTickable, IUpgradeableHost, IIAEStackInventory, ILevelViewable {
|
||||
|
||||
void setReportingValue(final long v);
|
||||
|
||||
long getReportingValue();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.helpers.UltimatePatternHelper;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.inventory.IIAEStackInventory;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
|
||||
public interface IPatternTerminal extends IIAEStackInventory, ITerminalHost, IConfigManagerHost, IViewCellStorage,
|
||||
IAEAppEngInventory, ITerminalPins, IActionHost {
|
||||
|
||||
boolean isCraftingRecipe();
|
||||
|
||||
void setCraftingRecipe(final boolean craftingMode);
|
||||
|
||||
boolean isSubstitution();
|
||||
|
||||
boolean canBeSubstitution();
|
||||
|
||||
void setSubstitution(boolean canSubstitute);
|
||||
|
||||
void setCanBeSubstitution(boolean beSubstitute);
|
||||
|
||||
IInventory getInventoryByName(final String name);
|
||||
|
||||
void exPatternTerminalCall(IAEStack<?>[] in, IAEStack<?>[] out);
|
||||
|
||||
default void loadPatternFromItem(final ItemStack stack, World world, IAEStackInventory crafting,
|
||||
IAEStackInventory output) {
|
||||
if (stack != null && stack.getItem() instanceof ICraftingPatternItem pattern) {
|
||||
final NBTTagCompound encodedValue = stack.getTagCompound();
|
||||
|
||||
if (encodedValue != null) {
|
||||
final ICraftingPatternDetails details = pattern.getPatternForItem(stack, world);
|
||||
final boolean substitute = encodedValue.getBoolean("substitute");
|
||||
final boolean beSubstitute = encodedValue.getBoolean("beSubstitute");
|
||||
final boolean isCrafting = encodedValue.getBoolean("crafting");
|
||||
final IAEStack<?>[] inItems;
|
||||
final IAEStack<?>[] outItems;
|
||||
|
||||
if (details == null) {
|
||||
if (stack.getItem() instanceof ItemEncodedPattern) {
|
||||
inItems = PatternHelper.loadIAEItemStackFromNBT(encodedValue.getTagList("in", 10), true, null);
|
||||
outItems = PatternHelper
|
||||
.loadIAEItemStackFromNBT(encodedValue.getTagList("out", 10), true, null);
|
||||
} else {
|
||||
inItems = UltimatePatternHelper
|
||||
.loadIAEStackFromNBT(encodedValue.getTagList("in", 10), true, null);
|
||||
outItems = UltimatePatternHelper
|
||||
.loadIAEStackFromNBT(encodedValue.getTagList("out", 10), true, null);
|
||||
}
|
||||
} else {
|
||||
inItems = details.getAEInputs();
|
||||
outItems = details.getAEOutputs();
|
||||
}
|
||||
|
||||
this.setCraftingRecipe(isCrafting);
|
||||
this.setSubstitution(substitute);
|
||||
this.setCanBeSubstitution(beSubstitute);
|
||||
|
||||
exPatternTerminalCall(inItems, outItems);
|
||||
|
||||
for (int x = 0; x < crafting.getSizeInventory(); x++) {
|
||||
crafting.putAEStackInSlot(x, null);
|
||||
}
|
||||
|
||||
for (int x = 0; x < output.getSizeInventory(); x++) {
|
||||
output.putAEStackInSlot(x, null);
|
||||
}
|
||||
|
||||
for (int x = 0; x < crafting.getSizeInventory() && x < inItems.length; x++) {
|
||||
if (inItems[x] != null) {
|
||||
crafting.putAEStackInSlot(x, inItems[x]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < output.getSizeInventory() && x < outItems.length; x++) {
|
||||
if (outItems[x] != null) {
|
||||
output.putAEStackInSlot(x, outItems[x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
public interface IPatternTerminalEx extends IPatternTerminal {
|
||||
|
||||
boolean isInverted();
|
||||
|
||||
void setInverted(boolean inverted);
|
||||
|
||||
int getActivePage();
|
||||
|
||||
void setActivePage(int activePage);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.IOreFilterable;
|
||||
import appeng.helpers.IPrimaryGuiIconProvider;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.inventory.IIAEStackInventory;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
|
||||
@Interface(iname = IntegrationType.BuildCraftTransport, iface = "buildcraft.api.transport.IPipeConnection")
|
||||
public interface IStorageBus
|
||||
extends IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEStack<?>>, IPipeConnection, IPriorityHost,
|
||||
IOreFilterable, IConfigManagerHost, IUpgradeableHost, IIAEStackInventory, IPrimaryGuiIconProvider {
|
||||
|
||||
boolean needSyncGUI();
|
||||
|
||||
void setNeedSyncGUI(boolean needSyncGUI);
|
||||
|
||||
MEInventoryHandler<?> getInternalHandler();
|
||||
|
||||
StorageChannel getStorageChannel();
|
||||
|
||||
default IItemList getItemList() {
|
||||
return switch (getStorageChannel()) {
|
||||
case ITEMS -> AEApi.instance().storage().createItemList();
|
||||
case FLUIDS -> AEApi.instance().storage().createFluidList();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ public interface ICellCacheRegistry {
|
||||
|
||||
int getCellStatus();
|
||||
|
||||
default StorageChannel getStorageChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
TYPE getCellType();
|
||||
|
||||
enum TYPE {
|
||||
|
||||
@@ -17,9 +17,12 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.items.contents.CellConfigLegacy;
|
||||
import appeng.items.contents.CellConfigLegacyWrapper;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public interface ICellInventory extends IMEInventory<IAEItemStack> {
|
||||
public interface ICellInventory<StackType extends IAEStack<StackType>> extends IMEInventory<StackType> {
|
||||
|
||||
/**
|
||||
* @return the item stack of this storage cell.
|
||||
@@ -38,8 +41,19 @@ public interface ICellInventory extends IMEInventory<IAEItemStack> {
|
||||
|
||||
/**
|
||||
* @return access configured list
|
||||
* @deprecated Use {@link ICellInventory#getConfigAEInventory()}
|
||||
*/
|
||||
IInventory getConfigInventory();
|
||||
@Deprecated
|
||||
default IInventory getConfigInventory() {
|
||||
return new CellConfigLegacy(this.getConfigAEInventory(), this.getChannel());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return access configured list
|
||||
*/
|
||||
default IAEStackInventory getConfigAEInventory() {
|
||||
return new CellConfigLegacyWrapper(this.getConfigInventory());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return access installed upgrades.
|
||||
@@ -99,7 +113,7 @@ public interface ICellInventory extends IMEInventory<IAEItemStack> {
|
||||
/**
|
||||
* @return how many more items can be stored with Distribution card.
|
||||
*/
|
||||
long getRemainingItemsCountDist(IAEItemStack l);
|
||||
long getRemainingItemsCountDist(StackType l);
|
||||
|
||||
/**
|
||||
* @return how many items can be added without consuming another byte.
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public interface ICellInventoryHandler extends IMEInventoryHandler<IAEItemStack> {
|
||||
public interface ICellInventoryHandler<StackType extends IAEStack<StackType>> extends IMEInventoryHandler<StackType> {
|
||||
|
||||
/**
|
||||
* @return get access to the Cell Inventory.
|
||||
*/
|
||||
ICellInventory getCellInv();
|
||||
ICellInventory<StackType> getCellInv();
|
||||
|
||||
boolean isPreformatted();
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.items.contents.CellConfigLegacy;
|
||||
import appeng.items.contents.CellConfigLegacyWrapper;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public interface ICellWorkbenchItem {
|
||||
|
||||
@@ -36,6 +39,11 @@ public interface ICellWorkbenchItem {
|
||||
*/
|
||||
IInventory getUpgradesInventory(ItemStack is);
|
||||
|
||||
@Deprecated
|
||||
default IInventory getConfigInventory(ItemStack is) {
|
||||
return new CellConfigLegacy(this.getConfigAEInventory(is), this.getStorageChannel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to extract, or mirror the contents of the work bench onto the cell.
|
||||
* <p>
|
||||
@@ -43,7 +51,9 @@ public interface ICellWorkbenchItem {
|
||||
* <p>
|
||||
* onInventoryChange will be called when saving is needed.
|
||||
*/
|
||||
IInventory getConfigInventory(ItemStack is);
|
||||
default IAEStackInventory getConfigAEInventory(ItemStack is) {
|
||||
return new CellConfigLegacyWrapper(this.getConfigInventory(is));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the current fuzzy status.
|
||||
@@ -68,4 +78,8 @@ public interface ICellWorkbenchItem {
|
||||
* @param filter new ore dictionary filter
|
||||
*/
|
||||
default void setOreFilter(ItemStack is, String filter) {}
|
||||
|
||||
default StorageChannel getStorageChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,12 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public interface ITerminalHost extends IStorageMonitorable, IConfigurableObject {
|
||||
|
||||
default GuiText getName() {
|
||||
return GuiText.Terminal;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,11 +34,11 @@ import appeng.util.IterationCounter;
|
||||
*
|
||||
* @param <StackType>
|
||||
*/
|
||||
public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<StackType> {
|
||||
public class MEMonitorHandler<StackType extends IAEStack<?>> implements IMEMonitor<StackType> {
|
||||
|
||||
private final IMEInventoryHandler<StackType> internalHandler;
|
||||
private final IItemList<StackType> cachedList;
|
||||
private final HashMap<IMEMonitorHandlerReceiver<StackType>, Object> listeners = new HashMap<>();
|
||||
private final HashMap<IMEMonitorHandlerReceiver, Object> listeners = new HashMap<>();
|
||||
|
||||
protected boolean hasChanged = true;
|
||||
|
||||
@@ -53,12 +53,12 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final IMEMonitorHandlerReceiver<StackType> l, final Object verificationToken) {
|
||||
public void addListener(final IMEMonitorHandlerReceiver l, final Object verificationToken) {
|
||||
this.listeners.put(l, verificationToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(final IMEMonitorHandlerReceiver<StackType> l) {
|
||||
public void removeListener(final IMEMonitorHandlerReceiver l) {
|
||||
this.listeners.remove(l);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
|
||||
return this.internalHandler;
|
||||
}
|
||||
|
||||
private StackType monitorDifference(final IAEStack original, final StackType leftOvers, final boolean extraction,
|
||||
private StackType monitorDifference(final IAEStack<?> original, final StackType leftOvers, final boolean extraction,
|
||||
final BaseActionSource src) {
|
||||
final StackType diff = (StackType) original.copy();
|
||||
|
||||
@@ -91,16 +91,16 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
|
||||
return leftOvers;
|
||||
}
|
||||
|
||||
protected void postChangesToListeners(final Iterable<StackType> changes, final BaseActionSource src) {
|
||||
protected void postChangesToListeners(final Iterable<IAEStack<?>> changes, final BaseActionSource src) {
|
||||
this.notifyListenersOfChange(changes, src);
|
||||
}
|
||||
|
||||
protected void notifyListenersOfChange(final Iterable<StackType> diff, final BaseActionSource src) {
|
||||
protected void notifyListenersOfChange(final Iterable<IAEStack<?>> diff, final BaseActionSource src) {
|
||||
this.hasChanged = true; // need to update the cache.
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver<StackType>, Object>> i = this.getListeners();
|
||||
final Iterator<Entry<IMEMonitorHandlerReceiver, Object>> i = this.getListeners();
|
||||
while (i.hasNext()) {
|
||||
final Entry<IMEMonitorHandlerReceiver<StackType>, Object> o = i.next();
|
||||
final IMEMonitorHandlerReceiver<StackType> receiver = o.getKey();
|
||||
final Entry<IMEMonitorHandlerReceiver, Object> o = i.next();
|
||||
final IMEMonitorHandlerReceiver receiver = o.getKey();
|
||||
if (receiver.isValid(o.getValue())) {
|
||||
receiver.postChange(this, diff, src);
|
||||
} else {
|
||||
@@ -109,7 +109,7 @@ public class MEMonitorHandler<StackType extends IAEStack> implements IMEMonitor<
|
||||
}
|
||||
}
|
||||
|
||||
protected Iterator<Entry<IMEMonitorHandlerReceiver<StackType>, Object>> getListeners() {
|
||||
protected Iterator<Entry<IMEMonitorHandlerReceiver, Object>> getListeners() {
|
||||
return this.listeners.entrySet().iterator();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
package appeng.api.storage;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -44,4 +47,23 @@ public enum StorageChannel {
|
||||
return AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
}
|
||||
|
||||
public IItemList createPrimitiveList() {
|
||||
if (this == ITEMS) {
|
||||
return AEApi.instance().storage().createPrimitiveItemList();
|
||||
} else {
|
||||
return AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
}
|
||||
|
||||
public static StorageChannel getStorageChannelByParametrizedClass(Class<?> theClass) {
|
||||
if (theClass.getGenericSuperclass() instanceof ParameterizedType parameterizedType) {
|
||||
final Type type = parameterizedType.getActualTypeArguments()[0];
|
||||
|
||||
if (type == IAEItemStack.class) return StorageChannel.ITEMS;
|
||||
else if (type == IAEFluidStack.class) return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.api.storage;
|
||||
|
||||
public enum StorageName {
|
||||
|
||||
NONE(""),
|
||||
CRAFTING_INPUT("crafting"),
|
||||
CRAFTING_OUTPUT("output"),
|
||||
CRAFTING_PATTERN("pattern");
|
||||
|
||||
private final String name;
|
||||
|
||||
StorageName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,16 @@ package appeng.api.storage.data;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public interface IAEStack<StackType extends IAEStack> {
|
||||
@@ -240,7 +246,21 @@ public interface IAEStack<StackType extends IAEStack> {
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
String getModId();
|
||||
|
||||
void setTagCompound(NBTTagCompound tag);
|
||||
|
||||
boolean hasTagCompound();
|
||||
|
||||
@Nullable
|
||||
ItemStack getItemStackForNEI();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void drawInGui(Minecraft mc, int x, int y);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
void drawOverlayInGui(Minecraft mc, int x, int y, boolean showAmount, boolean showAmountAlways,
|
||||
boolean showCraftableText, boolean showCraftableIcon);
|
||||
|
||||
int getPowerMultiplier();
|
||||
}
|
||||
@@ -11,12 +11,18 @@ import appeng.helpers.IPinsHandler;
|
||||
*/
|
||||
public interface IDisplayRepo extends IPinsHandler {
|
||||
|
||||
@Deprecated
|
||||
void postUpdate(final IAEItemStack stack);
|
||||
|
||||
void postUpdate(final IAEStack<?> stack);
|
||||
|
||||
void setViewCell(final ItemStack[] filters);
|
||||
|
||||
@Deprecated
|
||||
IAEItemStack getReferenceItem(int idx);
|
||||
|
||||
IAEStack<?> getReferenceStack(int idx);
|
||||
|
||||
ItemStack getItem(int idx);
|
||||
|
||||
void updateView();
|
||||
@@ -40,8 +46,4 @@ public interface IDisplayRepo extends IPinsHandler {
|
||||
boolean isPaused();
|
||||
|
||||
void setPaused(boolean paused);
|
||||
|
||||
default IItemList<IAEItemStack> getAvailableItems() {
|
||||
throw new UnsupportedOperationException("This method is not implemented for this IDisplayRepo.");
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,9 @@ public enum ActionKey {
|
||||
|
||||
TOGGLE_FOCUS(Keyboard.KEY_NONE),
|
||||
|
||||
SEARCH_CONNECTED_INVENTORIES(Keyboard.KEY_NONE);
|
||||
SEARCH_CONNECTED_INVENTORIES(Keyboard.KEY_NONE),
|
||||
|
||||
CONTROL_OPERATION(Keyboard.KEY_LCONTROL);
|
||||
|
||||
private final int defaultKey;
|
||||
|
||||
|
||||
@@ -435,6 +435,11 @@ public class ClientHelper extends ServerHelper {
|
||||
return this.bindings.get(key).isPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKeybind(ActionKey key) {
|
||||
return this.bindings.get(key).getKeyCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionKey(ActionKey key, int pressedKeyCode) {
|
||||
return isActiveAndMatches(this.bindings.get(key), pressedKeyCode);
|
||||
|
||||
@@ -16,11 +16,13 @@ import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -45,12 +47,15 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import appeng.api.events.GuiScrollEvent;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.slots.VirtualMESlot;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.client.render.TranslatedRenderItem;
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -62,7 +67,6 @@ import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
@@ -75,17 +79,17 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public abstract class AEBaseGui extends GuiContainer {
|
||||
public abstract class AEBaseGui extends GuiContainer implements IGuiTooltipHandler {
|
||||
|
||||
private static class AEGuiTooltip {
|
||||
|
||||
@@ -131,7 +135,6 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
}
|
||||
|
||||
private static boolean switchingGuis;
|
||||
private final List<InternalSlotME> meSlots = new LinkedList<>();
|
||||
// drag y
|
||||
protected final Set<Slot> drag_click = new HashSet<>();
|
||||
public static final AppEngRenderItem aeRenderItem = new AppEngRenderItem();
|
||||
@@ -143,12 +146,18 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
private ItemStack dbl_whichItem;
|
||||
private Slot bl_clicked;
|
||||
private boolean subGui;
|
||||
private static int controlKey;
|
||||
|
||||
private final List<VirtualMESlot> virtualSlots = new ArrayList<>();
|
||||
private final List<VirtualMESlot> draggedSlots = new ArrayList<>();
|
||||
private VirtualMESlot hoveredVirtualSlot = null;
|
||||
|
||||
public AEBaseGui(final Container container) {
|
||||
super(container);
|
||||
this.subGui = switchingGuis;
|
||||
switchingGuis = false;
|
||||
aeRenderItem.parent = this;
|
||||
controlKey = ClientHelper.proxy.getKeybind(ActionKey.CONTROL_OPERATION);
|
||||
}
|
||||
|
||||
protected static String join(final Collection<String> toolTip, final String delimiter) {
|
||||
@@ -174,12 +183,11 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
final List<Slot> slots = this.getInventorySlots();
|
||||
slots.removeIf(SlotME.class::isInstance);
|
||||
this.virtualSlots.clear();
|
||||
}
|
||||
|
||||
for (final InternalSlotME me : this.meSlots) {
|
||||
slots.add(new SlotME(me));
|
||||
}
|
||||
protected void registerVirtualSlots(VirtualMESlot slot) {
|
||||
virtualSlots.add(slot);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -315,6 +323,9 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
this.currentToolTip.shift(ox, oy);
|
||||
this.drawFG(ox, oy, x, y);
|
||||
this.currentToolTip.shift(0, 0);
|
||||
|
||||
this.hoveredVirtualSlot = null;
|
||||
this.drawVirtualSlots(this.virtualSlots, x, y);
|
||||
}
|
||||
|
||||
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
|
||||
@@ -360,6 +371,10 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
this.drag_click.clear();
|
||||
this.draggedSlots.clear();
|
||||
|
||||
final VirtualMESlot slot = getVirtualMESlotUnderMouse();
|
||||
if (slot != null && this.handleVirtualSlotClick(slot, btn)) return;
|
||||
|
||||
if (btn == 1) {
|
||||
for (final Object o : this.buttonList) {
|
||||
@@ -378,8 +393,49 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
protected boolean handleVirtualSlotClick(final VirtualMESlot slot, final int mouseButton) {
|
||||
if (slot instanceof VirtualMEPhantomSlot vSlot) {
|
||||
this.handlePhantomSlotInteraction(vSlot, mouseButton);
|
||||
|
||||
// Prevent double dragging
|
||||
if (this.mc.thePlayer.inventory.getItemStack() != null
|
||||
&& !this.draggedSlots.contains(this.hoveredVirtualSlot)) {
|
||||
this.draggedSlots.add(this.hoveredVirtualSlot);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void handleDragVirtualSlot(VirtualMESlot slot, int mouseButton) {
|
||||
if (slot instanceof VirtualMEPhantomSlot patternSlot) {
|
||||
this.handlePhantomSlotInteraction(patternSlot, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
slot.handleMouseClicked(true, true, isCtrlKeyDown(), mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
|
||||
// Hold left or right mouse button
|
||||
if (c == 0 || c == 1) {
|
||||
// Update hovered slot
|
||||
for (VirtualMESlot slot : virtualSlots) {
|
||||
if (slot.isHovered(x - this.guiLeft + 1, y - this.guiTop + 1)) {
|
||||
this.hoveredVirtualSlot = slot;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mc.thePlayer.inventory.getItemStack() != null && this.hoveredVirtualSlot != null
|
||||
&& !this.draggedSlots.contains(this.hoveredVirtualSlot)) {
|
||||
this.draggedSlots.add(this.hoveredVirtualSlot);
|
||||
this.handleDragVirtualSlot(this.hoveredVirtualSlot, c);
|
||||
}
|
||||
}
|
||||
|
||||
final Slot slot = this.getSlot(x, y);
|
||||
final ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
@@ -398,36 +454,6 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else if (slot instanceof SlotDisconnected) {
|
||||
this.drag_click.add(slot);
|
||||
if (this.drag_click.size() > 1) {
|
||||
if (itemstack != null) {
|
||||
for (final Slot dr : this.drag_click) {
|
||||
if (slot.getStack() == null) {
|
||||
InventoryAction action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
action,
|
||||
dr.getSlotIndex(),
|
||||
((SlotDisconnected) slot).getSlot().getId());
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
}
|
||||
} else if (isShiftKeyDown()) {
|
||||
for (final Slot dr : this.drag_click) {
|
||||
InventoryAction action = null;
|
||||
if (slot.getStack() != null) {
|
||||
action = InventoryAction.SHIFT_CLICK;
|
||||
}
|
||||
if (action != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
action,
|
||||
dr.getSlotIndex(),
|
||||
((SlotDisconnected) slot).getSlot().getId());
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.mouseClickMove(x, y, c, d);
|
||||
}
|
||||
@@ -437,39 +463,18 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if (mouseButton == 3) {
|
||||
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
|
||||
if (slot.getHasStack()) {
|
||||
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
|
||||
if (isCtrlKeyDown()) {
|
||||
action = InventoryAction.RENAME_PATTERN_ITEM;
|
||||
}
|
||||
|
||||
IAEItemStack stack = AEItemStack.create(slot.getStack());
|
||||
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (slot instanceof SlotFake) {
|
||||
final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE
|
||||
: InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
|
||||
if (this.drag_click.size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
if (slot instanceof SlotFake) {
|
||||
final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE
|
||||
: InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
|
||||
if (this.drag_click.size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot instanceof SlotPatternTerm) {
|
||||
@@ -503,118 +508,19 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
|
||||
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
|
||||
IAEItemStack stack = null;
|
||||
if (slot instanceof SlotME) {
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
}
|
||||
|
||||
int slotNum = this.getInventorySlots().size();
|
||||
|
||||
if (!(slot instanceof SlotME) && slot != null) {
|
||||
if (slot != null) {
|
||||
slotNum = slot.slotNumber;
|
||||
}
|
||||
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(null);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (slot instanceof SlotDisconnected) {
|
||||
if (this.drag_click.size() > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
InventoryAction action = null;
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0 -> // pickup / set-down.
|
||||
{
|
||||
ItemStack heldStack = player.inventory.getItemStack();
|
||||
if (slot.getStack() == null && heldStack != null) action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
|
||||
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
|
||||
action = InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
}
|
||||
case 1 -> action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
case 3 -> { // creative dupe:
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
} // drop item:
|
||||
default -> {}
|
||||
}
|
||||
|
||||
if (action != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
action,
|
||||
slot.getSlotIndex(),
|
||||
((SlotDisconnected) slot).getSlot().getId());
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (slot instanceof SlotME sme) {
|
||||
InventoryAction action = null;
|
||||
IAEItemStack stack = null;
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0 -> { // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
|
||||
if (sme.isPin() && player.inventory.getItemStack() != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
InventoryAction.SET_PIN,
|
||||
sme.getPinIndex(),
|
||||
0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
return;
|
||||
}
|
||||
|
||||
stack = sme.getAEStack();
|
||||
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN
|
||||
&& stack.getStackSize() == 0
|
||||
&& player.inventory.getItemStack() == null) {
|
||||
action = InventoryAction.AUTO_CRAFT;
|
||||
}
|
||||
}
|
||||
case 1 -> {
|
||||
if (sme.isPin() && ctrlDown == 1) { // clear pin
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
InventoryAction.SET_PIN,
|
||||
sme.getPinIndex(),
|
||||
-1);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
return;
|
||||
}
|
||||
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
}
|
||||
case 3 -> { // creative dupe:
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
if (stack != null && stack.isCraftable()) {
|
||||
action = InventoryAction.AUTO_CRAFT;
|
||||
} else if (player.capabilities.isCreativeMode) {
|
||||
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
|
||||
if (slotItem != null) {
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
}
|
||||
} // drop item:
|
||||
default -> {}
|
||||
}
|
||||
|
||||
if (action != null) {
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, this.getInventorySlots().size(), 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.disableShiftClick && isShiftKeyDown()) {
|
||||
this.disableShiftClick = true;
|
||||
|
||||
@@ -751,24 +657,7 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
* @return If the event was handled
|
||||
*/
|
||||
protected boolean mouseWheelEvent(final int x, final int y, final int wheel) {
|
||||
if (!isShiftKeyDown()) {
|
||||
return false;
|
||||
}
|
||||
final Slot slot = this.getSlot(x, y);
|
||||
if (slot instanceof SlotME) {
|
||||
final IAEItemStack item = ((SlotME) slot).getAEStack();
|
||||
if (item != null) {
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(item);
|
||||
final InventoryAction direction = wheel > 0 ? InventoryAction.ROLL_DOWN : InventoryAction.ROLL_UP;
|
||||
final int times = Math.abs(wheel);
|
||||
final int inventorySize = this.getInventorySlots().size();
|
||||
for (int h = 0; h < times; h++) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(direction, inventorySize, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean enableSpaceClicking() {
|
||||
@@ -814,10 +703,7 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
}
|
||||
|
||||
private void drawSlot(final Slot s) {
|
||||
if (s instanceof SlotME || s instanceof SlotFake) {
|
||||
if (s instanceof SlotME sme && sme.isPin() && !sme.getHasStack()) {
|
||||
drawTextureOnSlot(s, sme.getPinIcon(), sme.getOpacityOfIcon());
|
||||
}
|
||||
if (s instanceof SlotFake) {
|
||||
IAEItemStack stack = Platform.getAEStackInSlot(s);
|
||||
if (s instanceof SlotFake && stack != null && stack.getStackSize() == 1) {
|
||||
this.safeDrawSlot(s);
|
||||
@@ -862,8 +748,7 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
|| s instanceof AppEngCraftingSlot
|
||||
|| s instanceof SlotDisabled
|
||||
|| s instanceof SlotInaccessible
|
||||
|| s instanceof SlotRestrictedInput
|
||||
|| s instanceof SlotDisconnected;
|
||||
|| s instanceof SlotRestrictedInput;
|
||||
if (isValid && s instanceof SlotRestrictedInput) {
|
||||
try {
|
||||
isValid = ((SlotRestrictedInput) s).isValid(is, this.mc.theWorld);
|
||||
@@ -1033,10 +918,6 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
this.scrollBar = myScrollBar;
|
||||
}
|
||||
|
||||
protected List<InternalSlotME> getMeSlots() {
|
||||
return this.meSlots;
|
||||
}
|
||||
|
||||
public static final synchronized boolean isSwitchingGuis() {
|
||||
return switchingGuis;
|
||||
}
|
||||
@@ -1114,4 +995,74 @@ public abstract class AEBaseGui extends GuiContainer {
|
||||
public int getYSize() {
|
||||
return ySize;
|
||||
}
|
||||
|
||||
public static boolean isCtrlKeyDown() {
|
||||
return Keyboard.isKeyDown(controlKey);
|
||||
}
|
||||
|
||||
private void drawVirtualSlots(@Nonnull List<VirtualMESlot> slots, int mouseX, int mouseY) {
|
||||
final int x = mouseX - this.guiLeft + 1;
|
||||
final int y = mouseY - this.guiTop + 1;
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
for (VirtualMESlot slot : slots) {
|
||||
boolean isHovered = slot.drawStackAndOverlay(this.mc, x, y);
|
||||
if (isHovered) {
|
||||
this.hoveredVirtualSlot = slot;
|
||||
}
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
public @Nullable VirtualMESlot getVirtualMESlotUnderMouse() {
|
||||
return this.hoveredVirtualSlot;
|
||||
}
|
||||
|
||||
public void initCustomButtons(int xOffset, int yOffset) {
|
||||
if (inventorySlots instanceof AEBaseContainer abc && abc.getTarget() instanceof ICustomButtonProvider icbp)
|
||||
icbp.initCustomButtons(
|
||||
this.guiLeft,
|
||||
this.guiTop,
|
||||
this.xSize,
|
||||
this.ySize,
|
||||
xOffset,
|
||||
yOffset,
|
||||
this.buttonList);
|
||||
}
|
||||
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
if (inventorySlots instanceof AEBaseContainer abc && abc.getTarget() instanceof ICustomButtonProvider icbp)
|
||||
return icbp.actionPerformedCustomButtons(btn);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(final ItemStack stack, final int mouseX, final int mouseY,
|
||||
final List<String> currentToolTip) {
|
||||
VirtualMESlot hoveredSlot = this.getVirtualMESlotUnderMouse();
|
||||
if (hoveredSlot == null) return currentToolTip;
|
||||
|
||||
if (hoveredSlot.getAEStack() instanceof IAEFluidStack afs) {
|
||||
if (currentToolTip.isEmpty()) {
|
||||
currentToolTip.add(afs.getDisplayName());
|
||||
} else {
|
||||
currentToolTip.set(0, afs.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHoveredStack() {
|
||||
VirtualMESlot hoveredSlot = this.getVirtualMESlotUnderMouse();
|
||||
if (hoveredSlot == null) return null;
|
||||
|
||||
IAEStack<?> hoveredAEStack = hoveredSlot.getAEStack();
|
||||
if (hoveredAEStack == null) return null;
|
||||
|
||||
return hoveredAEStack.getItemStackForNEI();
|
||||
}
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.TerminalFontSize;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public abstract class AEBaseMEGui extends AEBaseGui implements IGuiTooltipHandler {
|
||||
|
||||
public AEBaseMEGui(final Container container) {
|
||||
super(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(final ItemStack stack, final int mouseX, final int mouseY,
|
||||
final List<String> currentToolTip) {
|
||||
if (stack != null) {
|
||||
final Slot s = this.getSlot(mouseX, mouseY);
|
||||
final boolean isSlotME = s instanceof SlotME;
|
||||
if (isSlotME || s instanceof SlotFake) {
|
||||
final int BigNumber = AEConfig.instance.getTerminalFontSize() == TerminalFontSize.SMALL ? 9999 : 999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try {
|
||||
myStack = Platform.getAEStackInSlot(s);
|
||||
} catch (final Throwable ignore) {}
|
||||
|
||||
if (myStack != null) {
|
||||
if (myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged())) {
|
||||
final String local = isSlotME ? ButtonToolTips.ItemsStored.getLocal()
|
||||
: ButtonToolTips.ItemCount.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
|
||||
.format(myStack.getStackSize());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
currentToolTip.add("\u00a77" + format);
|
||||
}
|
||||
|
||||
if (myStack.getCountRequestable() > 0) {
|
||||
final String local = ButtonToolTips.ItemsRequestable.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US)
|
||||
.format(myStack.getCountRequestable());
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
currentToolTip.add("\u00a77" + format);
|
||||
}
|
||||
} else if (stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged())) {
|
||||
final String local = ButtonToolTips.ItemsStored.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize);
|
||||
final String format = String.format(local, formattedAmount);
|
||||
|
||||
currentToolTip.add("\u00a77" + format);
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
@Override
|
||||
public void renderToolTip(final ItemStack stack, final int x, final int y) {
|
||||
final Slot s = this.getSlot(x, y);
|
||||
if ((s instanceof SlotME || s instanceof SlotFake) && stack != null) {
|
||||
final int BigNumber = AEConfig.instance.getTerminalFontSize() == TerminalFontSize.SMALL ? 9999 : 999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try {
|
||||
myStack = Platform.getAEStackInSlot(s);
|
||||
} catch (final Throwable ignore) {}
|
||||
|
||||
if (myStack != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> currentToolTip = stack
|
||||
.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
if (myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged())) {
|
||||
currentToolTip.add(
|
||||
"Items Stored: "
|
||||
+ NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize()));
|
||||
}
|
||||
|
||||
if (myStack.getCountRequestable() > 0) {
|
||||
currentToolTip.add(
|
||||
"Items Requestable: "
|
||||
+ NumberFormat.getNumberInstance(Locale.US).format(myStack.getCountRequestable()));
|
||||
}
|
||||
|
||||
this.drawTooltip(x, y, currentToolTip.toArray(new String[0]));
|
||||
} else if (stack.stackSize > BigNumber) {
|
||||
final List<String> var4 = stack
|
||||
.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
var4.add("Items Stored: " + NumberFormat.getNumberInstance(Locale.US).format(stack.stackSize));
|
||||
this.drawTooltip(x, y, var4.toArray(new String[0]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderToolTip(stack, x, y);
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
|
||||
public abstract class GuiSub extends AEBaseGui implements IGuiSub {
|
||||
|
||||
protected final IContainerSubGui container;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
public GuiSub(Container container) {
|
||||
super(container);
|
||||
this.container = (IContainerSubGui) container;
|
||||
this.container.setGuiLink(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
if (container.getPrimaryGuiIcon() != null) initPrimaryGuiButton();
|
||||
}
|
||||
|
||||
public void initPrimaryGuiButton() {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 22,
|
||||
this.guiTop,
|
||||
container.getPrimaryGuiIcon(),
|
||||
container.getPrimaryGuiIcon().getDisplayName(),
|
||||
itemRender));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
public interface IGuiSub {
|
||||
|
||||
void initPrimaryGuiButton();
|
||||
|
||||
}
|
||||
@@ -2,27 +2,20 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
public abstract class GuiAmount extends AEBaseGui {
|
||||
public abstract class GuiAmount extends GuiSub {
|
||||
|
||||
protected MEGuiTextField amountTextField;
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
|
||||
protected GuiButton nextBtn;
|
||||
|
||||
@@ -35,9 +28,6 @@ public abstract class GuiAmount extends AEBaseGui {
|
||||
protected GuiButton minus100;
|
||||
protected GuiButton minus1000;
|
||||
|
||||
protected GuiBridge originalGui;
|
||||
protected ItemStack myIcon;
|
||||
|
||||
@Reflected
|
||||
public GuiAmount(final Container container) {
|
||||
super(container);
|
||||
@@ -66,19 +56,6 @@ public abstract class GuiAmount extends AEBaseGui {
|
||||
this.buttonList.add(
|
||||
this.nextBtn = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
|
||||
|
||||
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
|
||||
|
||||
this.setOriginGUI(target);
|
||||
if (this.originalGui != null && myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 154,
|
||||
this.guiTop,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
}
|
||||
|
||||
this.amountTextField = new MEGuiTextField(61, 12);
|
||||
this.amountTextField.x = this.guiLeft + 60;
|
||||
this.amountTextField.y = this.guiTop + 55;
|
||||
@@ -86,8 +63,6 @@ public abstract class GuiAmount extends AEBaseGui {
|
||||
this.amountTextField.setFocused(true);
|
||||
}
|
||||
|
||||
protected abstract void setOriginGUI(Object target);
|
||||
|
||||
protected int getButtonQtyByIndex(int index) {
|
||||
return AEConfig.instance.craftItemsByStackAmounts(index);
|
||||
}
|
||||
@@ -118,9 +93,6 @@ public abstract class GuiAmount extends AEBaseGui {
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.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
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.container.implementations.ContainerBusIO;
|
||||
import appeng.parts.automation.PartSharedItemBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public class GuiBusIO extends GuiUpgradeable {
|
||||
|
||||
protected VirtualMEPhantomSlot[] virtualSlots;
|
||||
private final PartSharedItemBus<?> bus;
|
||||
|
||||
public GuiBusIO(final InventoryPlayer inventoryPlayer, final PartSharedItemBus<?> te) {
|
||||
super(new ContainerBusIO(inventoryPlayer, te));
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.initVirtualSlots();
|
||||
}
|
||||
|
||||
private void initVirtualSlots() {
|
||||
this.virtualSlots = new VirtualMEPhantomSlot[9];
|
||||
final IAEStackInventory inputInv = this.bus.getAEInventoryByName(StorageName.NONE);
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
VirtualMEPhantomSlot slot = new VirtualMEPhantomSlot(
|
||||
62 + 18 * x,
|
||||
22 + 18 * (y % (3)),
|
||||
inputInv,
|
||||
x + y * 3);
|
||||
this.virtualSlots[x + y * 3] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
final int capacity = this.cvb.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
if (capacity < 1) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX + 61, offsetY + 39, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 79, offsetY + 21, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 97, offsetY + 39, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 79, offsetY + 57, 79, 39, 18, 18);
|
||||
|
||||
if (capacity < 1) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
if (capacity < 2) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX + 61, offsetY + 21, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 61, offsetY + 57, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 97, offsetY + 21, 79, 39, 18, 18);
|
||||
this.drawTexturedModalRect(offsetX + 97, offsetY + 57, 79, 39, 18, 18);
|
||||
|
||||
if (capacity < 2) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
super.handleButtonVisibility();
|
||||
|
||||
final int capacity = this.cvb.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY);
|
||||
final boolean firstTier = capacity > 0;
|
||||
final boolean secondTier = capacity > 1;
|
||||
|
||||
this.virtualSlots[1].setHidden(!firstTier);
|
||||
this.virtualSlots[3].setHidden(!firstTier);
|
||||
this.virtualSlots[5].setHidden(!firstTier);
|
||||
this.virtualSlots[7].setHidden(!firstTier);
|
||||
|
||||
this.virtualSlots[0].setHidden(!secondTier);
|
||||
this.virtualSlots[2].setHidden(!secondTier);
|
||||
this.virtualSlots[6].setHidden(!secondTier);
|
||||
this.virtualSlots[8].setHidden(!secondTier);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/bus.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
StorageChannel channel = StorageChannel.getStorageChannelByParametrizedClass(this.bus.getClass());
|
||||
slot.handleMouseClicked(channel == StorageChannel.ITEMS, channel == StorageChannel.FLUIDS, false);
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,13 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.implementations.ContainerCellRestriction;
|
||||
import appeng.container.implementations.ContainerCellRestriction.CellData;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
@@ -21,7 +20,7 @@ import appeng.helpers.ICellRestriction;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
public class GuiCellRestriction extends AEBaseGui {
|
||||
public class GuiCellRestriction extends GuiSub {
|
||||
|
||||
private MEGuiTextField amountField;
|
||||
private MEGuiTextField typesField;
|
||||
@@ -29,7 +28,7 @@ public class GuiCellRestriction extends AEBaseGui {
|
||||
|
||||
public GuiCellRestriction(InventoryPlayer ip, ICellRestriction obj) {
|
||||
super(new ContainerCellRestriction(ip, obj));
|
||||
this.xSize = 256;
|
||||
this.xSize = 204;
|
||||
|
||||
this.amountField = new MEGuiTextField(85, 12);
|
||||
this.typesField = new MEGuiTextField(30, 12);
|
||||
@@ -144,7 +143,7 @@ public class GuiCellRestriction extends AEBaseGui {
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CELL_WORKBENCH));
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
} else if (!(this.amountField.textboxKeyTyped(character, key)
|
||||
|| this.typesField.textboxKeyTyped(character, key))) {
|
||||
super.keyTyped(character, key);
|
||||
|
||||
@@ -25,6 +25,9 @@ import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.implementations.tiles.ICellWorkbench;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
@@ -33,7 +36,7 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiCellWorkbench extends GuiUpgradeable {
|
||||
@@ -44,8 +47,9 @@ public class GuiCellWorkbench extends GuiUpgradeable {
|
||||
private GuiImgButton partition;
|
||||
private GuiToggleButton copyMode;
|
||||
protected GuiImgButton cellRestriction;
|
||||
private VirtualMEPhantomSlot[] configSlots;
|
||||
|
||||
public GuiCellWorkbench(final InventoryPlayer inventoryPlayer, final TileCellWorkbench te) {
|
||||
public GuiCellWorkbench(final InventoryPlayer inventoryPlayer, final ICellWorkbench te) {
|
||||
super(new ContainerCellWorkbench(inventoryPlayer, te));
|
||||
this.workbench = (ContainerCellWorkbench) this.inventorySlots;
|
||||
this.ySize = 251;
|
||||
@@ -84,6 +88,8 @@ public class GuiCellWorkbench extends GuiUpgradeable {
|
||||
this.buttonList.add(this.copyMode);
|
||||
this.buttonList.add(this.oreFilter);
|
||||
this.buttonList.add(this.cellRestriction);
|
||||
|
||||
initVirtualSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,6 +169,25 @@ public class GuiCellWorkbench extends GuiUpgradeable {
|
||||
}
|
||||
}
|
||||
|
||||
private void initVirtualSlots() {
|
||||
this.configSlots = new VirtualMEPhantomSlot[63];
|
||||
final IAEStackInventory inputInv = this.workbench.getConfig();
|
||||
final int xo = 8;
|
||||
final int yo = -133;
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
VirtualMEPhantomSlot slot = new VirtualMEPhantomSlot(
|
||||
xo + x * 18,
|
||||
yo + y * 18 + 9 * 18,
|
||||
inputInv,
|
||||
x + y * 9);
|
||||
this.configSlots[x + y * 9] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleButtonVisibility() {
|
||||
this.copyMode.setState(this.workbench.getCopyMode() == CopyMode.CLEAR_ON_REMOVE);
|
||||
@@ -224,4 +249,10 @@ public class GuiCellWorkbench extends GuiUpgradeable {
|
||||
}
|
||||
} catch (final IOException ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
StorageChannel channel = workbench.getStorageChannel();
|
||||
slot.handleMouseClicked(channel == StorageChannel.ITEMS, channel == StorageChannel.FLUIDS, false);
|
||||
}
|
||||
}
|
||||
@@ -12,38 +12,36 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CraftingMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.slots.VirtualMESlotSingle;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerCraftAmount;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class GuiCraftAmount extends GuiAmount {
|
||||
public class GuiCraftAmount extends GuiAmount implements IVirtualSlotHolder {
|
||||
|
||||
private GuiImgButton craftingMode;
|
||||
private final VirtualMESlotSingle slot;
|
||||
|
||||
@Reflected
|
||||
public GuiCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerCraftAmount(inventoryPlayer, te));
|
||||
|
||||
this.slot = new VirtualMESlotSingle(34, 53, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,49 +57,7 @@ public class GuiCraftAmount extends GuiAmount {
|
||||
CraftingMode.STANDARD));
|
||||
|
||||
((ContainerCraftAmount) this.inventorySlots).setAmountField(this.amountTextField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
for (final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = wirelessTerminalStack;
|
||||
}
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (target instanceof PartTerminal) {
|
||||
for (final ItemStack stack : parts.terminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (target instanceof PartCraftingTerminal) {
|
||||
for (final ItemStack stack : parts.craftingTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
for (final ItemStack stack : parts.patternTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (target instanceof PartPatternTerminalEx) {
|
||||
for (final ItemStack stack : parts.patternTerminalEx().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
this.registerVirtualSlots(this.slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,4 +124,9 @@ public class GuiCraftAmount extends GuiAmount {
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName _invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
this.slot.setAEStack(slotStacks.get(0));
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import static appeng.api.config.Settings.CRAFTING_SORT_BY;
|
||||
import static appeng.api.config.Settings.SORT_DIRECTION;
|
||||
import static appeng.util.Platform.stackConvert;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,8 +39,9 @@ import appeng.api.config.SortDir;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
import appeng.client.gui.widgets.GuiAeButton;
|
||||
import appeng.client.gui.widgets.GuiCraftingCPUTable;
|
||||
@@ -58,24 +60,18 @@ import appeng.core.AELog;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.crafting.v2.CraftingJobV2;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.integration.modules.NEI;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.ColorPickHelper;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.RoundHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolder, IGuiTooltipHandler {
|
||||
public class GuiCraftConfirm extends GuiSub implements ICraftingCPUTableHolder, IGuiTooltipHandler {
|
||||
|
||||
public static final int TREE_VIEW_TEXTURE_WIDTH = 238;
|
||||
public static final int TREE_VIEW_TEXTURE_HEIGHT = 238;
|
||||
@@ -151,7 +147,6 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
private CraftingSortOrder sortMode = CraftingSortOrder.NAME;
|
||||
private SortDir sortDir = SortDir.ASCENDING;
|
||||
|
||||
private GuiBridge OriginalGui;
|
||||
private GuiButton cancel;
|
||||
private GuiButton start;
|
||||
private GuiButton startWithFollow;
|
||||
@@ -167,7 +162,7 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
private MEGuiTextField searchField;
|
||||
private int tooltip = -1;
|
||||
private ItemStack hoveredStack;
|
||||
private ArrayList<Integer> goToData = new ArrayList<>();
|
||||
private final ArrayList<Integer> goToData = new ArrayList<>();
|
||||
private int searchGotoIndex = -1;
|
||||
private IAEItemStack needHighlight;
|
||||
|
||||
@@ -186,26 +181,6 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
this,
|
||||
((ContainerCraftConfirm) inventorySlots).cpuTable,
|
||||
c -> this.ccc.cpuCraftingSameItem(c) && this.ccc.cpuMatches(c));
|
||||
|
||||
if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (te instanceof PartTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (te instanceof PartCraftingTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (te instanceof PartPatternTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (te instanceof PartPatternTerminalEx) {
|
||||
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -812,32 +787,30 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
public void postUpdate(final List<IAEStack<?>> list, final byte ref) {
|
||||
for (final IAEStack<?> l : list) {
|
||||
IAEItemStack stack = stackConvert(l);
|
||||
switch (ref) {
|
||||
case 0 -> {
|
||||
this.handleInput(this.storage, stack);
|
||||
}
|
||||
}
|
||||
case 1 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
case 1 -> {
|
||||
this.handleInput(this.pending, stack);
|
||||
}
|
||||
}
|
||||
case 2 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.missing, l);
|
||||
case 2 -> {
|
||||
this.handleInput(this.missing, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
for (final IAEStack<?> l : list) {
|
||||
IAEItemStack stack = stackConvert(l);
|
||||
final long amt = this.getTotal(stack);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
this.deleteVisualStack(stack);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
final IAEItemStack is = this.findVisualStack(stack);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
@@ -880,7 +853,7 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
return ((AEItemStack) i1).getDisplayName().compareToIgnoreCase(((AEItemStack) i2).getDisplayName())
|
||||
* sortDir.sortHint;
|
||||
if (sortMode == CraftingSortOrder.MOD) {
|
||||
int v = ((AEItemStack) i1).getModID().compareToIgnoreCase(((AEItemStack) i2).getModID());
|
||||
int v = ((AEItemStack) i1).getModId().compareToIgnoreCase(((AEItemStack) i2).getModId());
|
||||
return (v == 0
|
||||
? ((AEItemStack) i1).getDisplayName().compareToIgnoreCase(((AEItemStack) i2).getDisplayName())
|
||||
: v) * sortDir.sortHint;
|
||||
@@ -995,7 +968,7 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
cpuTable.cycleCPU(backwards);
|
||||
} else if (btn == this.cancel) {
|
||||
this.addMissingItemsToBookMark();
|
||||
switchToOriginalGUI();
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
} else if (btn == this.switchDisplayMode) {
|
||||
this.displayMode = this.displayMode.next();
|
||||
recalculateScreenSize();
|
||||
@@ -1060,13 +1033,6 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
}
|
||||
}
|
||||
|
||||
public void switchToOriginalGUI() {
|
||||
// null if terminal is not a native AE2 terminal
|
||||
if (this.OriginalGui != null) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.OriginalGui));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getHoveredStack() {
|
||||
return hoveredStack;
|
||||
}
|
||||
@@ -1121,16 +1087,17 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
missing.add(iaeItemStack.getItemStack());
|
||||
}
|
||||
|
||||
final IAEItemStack outputStack = ((ContainerCraftConfirm) this.inventorySlots).getItemToCraft();
|
||||
final ItemStack outputStack = this.getItemStackForBookMark();
|
||||
|
||||
if (outputStack != null) {
|
||||
NEI.instance.addToBookmark(outputStack.getItemStack(), missing);
|
||||
} else {
|
||||
NEI.instance.addToBookmark(null, missing);
|
||||
}
|
||||
NEI.instance.addToBookmark(outputStack, missing);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack getItemStackForBookMark() {
|
||||
final IAEStack<?> outputStack = ((ContainerCraftConfirm) this.inventorySlots).getItemToCraft();
|
||||
return outputStack.getItemStackForNEI();
|
||||
}
|
||||
|
||||
public IItemList<IAEItemStack> getStorage() {
|
||||
return this.storage;
|
||||
}
|
||||
@@ -1142,4 +1109,7 @@ public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolde
|
||||
public IItemList<IAEItemStack> getMissing() {
|
||||
return this.missing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initPrimaryGuiButton() {}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ package appeng.client.gui.implementations;
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
@@ -21,12 +22,14 @@ import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
@@ -38,6 +41,7 @@ import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.NamedDimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
@@ -103,11 +107,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
|
||||
private final ContainerCraftingCPU craftingCpu;
|
||||
|
||||
protected IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
protected IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
|
||||
protected IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
|
||||
private IAEItemStack hoveredAEStack = null;
|
||||
protected IItemList<IAEStack<?>> storage = AEApi.instance().storage().createAEStackList();
|
||||
protected IItemList<IAEStack<?>> active = AEApi.instance().storage().createAEStackList();
|
||||
protected IItemList<IAEStack<?>> pending = AEApi.instance().storage().createAEStackList();
|
||||
|
||||
protected int rows = DISPLAYED_ROWS;
|
||||
|
||||
@@ -177,23 +179,23 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
}
|
||||
|
||||
protected List<IAEItemStack> visual = new ArrayList<>();
|
||||
protected List<IAEStack<?>> visual = new ArrayList<>();
|
||||
private GuiButton cancel;
|
||||
private GuiAeButton suspend;
|
||||
protected List<IAEItemStack> visualHiddenStored = new ArrayList<>();
|
||||
protected List<IAEStack<?>> visualHiddenStored = new ArrayList<>();
|
||||
protected GuiImgButton toggleHideStored;
|
||||
protected boolean hideStored;
|
||||
private int tooltip = -1;
|
||||
private final RemainingOperations remainingOperations = new RemainingOperations();
|
||||
private ItemStack hoveredStack;
|
||||
private ItemStack hoveredNbtStack;
|
||||
private IAEStack<?> hoveredStack;
|
||||
private NBTTagCompound hoveredStackNbt;
|
||||
private GuiAeButton findNext;
|
||||
private GuiAeButton findPrev;
|
||||
private GuiImgButton changeAllow;
|
||||
private MEGuiTextField searchField;
|
||||
private ArrayList<Integer> goToData = new ArrayList<>();
|
||||
private final ArrayList<Integer> goToData = new ArrayList<>();
|
||||
private int searchGotoIndex = -1;
|
||||
private IAEItemStack needHighlight;
|
||||
private IAEStack<?> needHighlight;
|
||||
|
||||
public GuiCraftingCPU(final InventoryPlayer inventoryPlayer, final Object te) {
|
||||
this(new ContainerCraftingCPU(inventoryPlayer, te));
|
||||
@@ -211,9 +213,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
this.storage = AEApi.instance().storage().createItemList();
|
||||
this.active = AEApi.instance().storage().createItemList();
|
||||
this.pending = AEApi.instance().storage().createItemList();
|
||||
this.storage = AEApi.instance().storage().createAEStackList();
|
||||
this.active = AEApi.instance().storage().createAEStackList();
|
||||
this.pending = AEApi.instance().storage().createAEStackList();
|
||||
this.visual = new ArrayList<>();
|
||||
this.visualHiddenStored = new ArrayList<>();
|
||||
}
|
||||
@@ -255,17 +257,12 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
|
||||
}
|
||||
|
||||
public IAEItemStack getHoveredAEStack() {
|
||||
return hoveredAEStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
if (isShiftKeyDown() && this.hoveredNbtStack != null) {
|
||||
NBTTagCompound data = Platform.openNbtData(this.hoveredNbtStack);
|
||||
if (isShiftKeyDown() && this.hoveredStackNbt != null) {
|
||||
// when using the highlight feature in the crafting GUI we want to show all the interfaces
|
||||
// that currently received items so the player can see if the items are processed properly
|
||||
List<NamedDimensionalCoord> ndcl = NamedDimensionalCoord.readAsListFromNBTNamed(data);
|
||||
List<NamedDimensionalCoord> ndcl = NamedDimensionalCoord.readAsListFromNBTNamed(hoveredStackNbt);
|
||||
Map<NamedDimensionalCoord, String[]> ndcm = new HashMap<>();
|
||||
for (NamedDimensionalCoord ndc : ndcl) {
|
||||
ndcm.put(
|
||||
@@ -278,14 +275,15 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
ndcm,
|
||||
((Localization) () -> "tile.appliedenergistics2.BlockInterface.name").getLocal());
|
||||
mc.thePlayer.closeScreen();
|
||||
} else if (hoveredAEStack != null && btn == 2) {
|
||||
((AEBaseContainer) inventorySlots).setTargetStack(hoveredAEStack);
|
||||
} else if (this.hoveredStack != null && btn == 2) {
|
||||
((AEBaseContainer) inventorySlots).setTargetStack(this.hoveredStack);
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
InventoryAction.AUTO_CRAFT,
|
||||
inventorySlots.inventorySlots.size(),
|
||||
hoveredAEStack.getStackSize());
|
||||
this.hoveredStack.getStackSize());
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
this.searchField.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
@@ -412,8 +410,8 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
if (this.searchField.getText().isEmpty()) return;
|
||||
String s = this.searchField.getText().toLowerCase();
|
||||
int visCount = 0;
|
||||
for (IAEItemStack aeis : hideStored ? this.visualHiddenStored : this.visual) {
|
||||
if (aeis != null && Platform.getItemDisplayName(aeis).toLowerCase().contains(s)) {
|
||||
for (IAEStack<?> stack : hideStored ? this.visualHiddenStored : this.visual) {
|
||||
if (stack != null && stack.getDisplayName().toLowerCase().contains(s)) {
|
||||
goToData.add(visCount);
|
||||
}
|
||||
visCount++;
|
||||
@@ -435,14 +433,14 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
searchGotoIndex--;
|
||||
}
|
||||
|
||||
List<IAEItemStack> visualTemp;
|
||||
List<IAEStack<?>> visualTemp;
|
||||
if (this.hideStored) {
|
||||
visualTemp = this.visualHiddenStored;
|
||||
} else {
|
||||
visualTemp = this.visual;
|
||||
}
|
||||
|
||||
IAEItemStack aeis = visualTemp.get(goToData.get(searchGotoIndex));
|
||||
IAEStack<?> aeis = visualTemp.get(goToData.get(searchGotoIndex));
|
||||
this.getScrollBar().setCurrentScroll(goToData.get(searchGotoIndex) / 3 - this.rows / 2);
|
||||
needHighlight = aeis.copy();
|
||||
}
|
||||
@@ -470,7 +468,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
.formatDuration(elapsedInMilliseconds, GuiText.ETAFormat.getLocal());
|
||||
|
||||
// If title is empty, don't show that ' - '
|
||||
if (title.length() == 0) {
|
||||
if (title.isEmpty()) {
|
||||
title = elapsedTimeText;
|
||||
} else {
|
||||
title += " - " + elapsedTimeText;
|
||||
@@ -501,21 +499,21 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
final int offY = 23;
|
||||
|
||||
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
|
||||
List<IAEItemStack> visualTemp;
|
||||
List<IAEStack<?>> visualTemp;
|
||||
if (this.hideStored) {
|
||||
visualTemp = this.visualHiddenStored;
|
||||
} else {
|
||||
visualTemp = this.visual;
|
||||
}
|
||||
for (int z = viewStart; z < Math.min(viewEnd, visualTemp.size()); z++) {
|
||||
final IAEItemStack refStack = visualTemp.get(z); // repo.getReferenceItem( z );
|
||||
final IAEStack<?> refStack = visualTemp.get(z); // repo.getReferenceItem( z );
|
||||
if (refStack != null) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
|
||||
final IAEItemStack stored = this.storage.findPrecise(refStack);
|
||||
final IAEItemStack activeStack = this.active.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEStack<?> stored = this.storage.findPrecise(refStack);
|
||||
final IAEStack<?> activeStack = this.active.findPrecise(refStack);
|
||||
final IAEStack<?> pendingStack = this.pending.findPrecise(refStack);
|
||||
|
||||
int lines = 0;
|
||||
|
||||
@@ -577,7 +575,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
GuiColors.CraftingCPUAmount.getColor());
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
hoveredAEStack = refStack;
|
||||
this.hoveredStack = refStack;
|
||||
lineList.add(
|
||||
GuiText.Crafting.getLocal() + ": "
|
||||
+ NumberFormat.getInstance().format(activeStack.getStackSize()));
|
||||
@@ -609,23 +607,28 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
|
||||
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
final IAEStack<?> is = refStack.copy();
|
||||
|
||||
if (this.tooltip == z - viewStart) {
|
||||
dspToolTip = Platform.getItemDisplayName(is);
|
||||
|
||||
if (lineList.size() > 0) {
|
||||
addItemTooltip(refStack, lineList);
|
||||
if (!lineList.isEmpty()) {
|
||||
addItemTooltip(refStack, lineList, refStack.equals(this.hoveredStack));
|
||||
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
|
||||
}
|
||||
|
||||
toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
|
||||
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
|
||||
|
||||
hoveredStack = is;
|
||||
this.hoveredStack = is;
|
||||
}
|
||||
|
||||
this.drawItem(posX, posY, is);
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
is.drawInGui(this.mc, posX, posY);
|
||||
GL11.glPopAttrib();
|
||||
|
||||
if (!this.searchField.getText().isEmpty() && goToData.contains(z)) {
|
||||
final int startX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET;
|
||||
@@ -648,28 +651,27 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip >= 0 && dspToolTip.length() > 0) {
|
||||
if (this.tooltip >= 0 && !dspToolTip.isEmpty()) {
|
||||
this.drawTooltip(toolPosX, toolPosY + 10, dspToolTip);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void addItemTooltip(IAEItemStack refStack, List<String> lineList) {
|
||||
protected void addItemTooltip(IAEStack<?> refStack, List<String> lineList, boolean stackChanged) {
|
||||
if (isShiftKeyDown()) {
|
||||
final ItemStack is = refStack.copy().getItemStack();
|
||||
final List l = is.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
final List<String> l = refStack instanceof IAEItemStack ais
|
||||
? ais.getItemStack().getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips)
|
||||
: Collections.EMPTY_LIST;
|
||||
if (!l.isEmpty()) l.remove(0);
|
||||
lineList.addAll(l);
|
||||
if (this.hoveredNbtStack == null || this.hoveredNbtStack.getItem() != is.getItem()) {
|
||||
this.hoveredNbtStack = is;
|
||||
if (this.hoveredStackNbt == null || stackChanged) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketCraftingItemInterface(refStack.copy()));
|
||||
} catch (Exception ignored) {}
|
||||
} else {
|
||||
NBTTagCompound data = Platform.openNbtData(this.hoveredNbtStack);
|
||||
List<NamedDimensionalCoord> blocks = NamedDimensionalCoord.readAsListFromNBTNamed(data);
|
||||
List<NamedDimensionalCoord> blocks = NamedDimensionalCoord.readAsListFromNBTNamed(this.hoveredStackNbt);
|
||||
|
||||
ScheduledReason sr = ScheduledReason.values()[data.getInteger("ScheduledReason")];
|
||||
ScheduledReason sr = ScheduledReason.values()[this.hoveredStackNbt.getInteger("ScheduledReason")];
|
||||
if (sr != ScheduledReason.UNDEFINED) lineList.add(sr.getLocal());
|
||||
|
||||
if (blocks.isEmpty()) return;
|
||||
@@ -686,7 +688,7 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
lineList.add(GuiText.HoldShiftClick_HIGHLIGHT_INTERFACE.getLocal());
|
||||
}
|
||||
} else {
|
||||
this.hoveredNbtStack = null;
|
||||
this.hoveredStackNbt = null;
|
||||
lineList.add(GuiText.HoldShiftForTooltip.getLocal());
|
||||
}
|
||||
}
|
||||
@@ -711,40 +713,36 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
}
|
||||
|
||||
public void postUpdate(IAEItemStack is) {
|
||||
this.hoveredNbtStack = is.getItemStack();
|
||||
public void postUpdateTooltip(NBTTagCompound nbt) {
|
||||
this.hoveredStackNbt = nbt;
|
||||
}
|
||||
|
||||
public void postUpdate(int remainingOperations) {
|
||||
this.remainingOperations.setRemainingOperations(remainingOperations);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
switch (ref) {
|
||||
case 0 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.storage, l);
|
||||
public void postUpdate(final List<IAEStack<?>> list, final byte ref) {
|
||||
for (final IAEStack<?> stack : list) {
|
||||
switch (ref) {
|
||||
case 0 -> {
|
||||
this.handleInput(this.storage, stack);
|
||||
}
|
||||
}
|
||||
case 1 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.active, l);
|
||||
case 1 -> {
|
||||
this.handleInput(this.active, stack);
|
||||
}
|
||||
}
|
||||
case 2 -> {
|
||||
for (final IAEItemStack l : list) {
|
||||
this.handleInput(this.pending, l);
|
||||
case 2 -> {
|
||||
this.handleInput(this.pending, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final IAEItemStack l : list) {
|
||||
final long amt = this.getTotal(l);
|
||||
for (final IAEStack<?> stack : list) {
|
||||
final long amt = this.getTotal(stack);
|
||||
|
||||
if (amt <= 0) {
|
||||
this.deleteVisualStack(l);
|
||||
this.deleteVisualStack(stack);
|
||||
} else {
|
||||
final IAEItemStack is = this.findVisualStack(l);
|
||||
final IAEStack<?> is = this.findVisualStack(stack);
|
||||
is.setStackSize(amt);
|
||||
}
|
||||
}
|
||||
@@ -754,8 +752,8 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
this.setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
|
||||
IAEItemStack a = s.findPrecise(l);
|
||||
private void handleInput(final IItemList<IAEStack<?>> s, final IAEStack<?> l) {
|
||||
IAEStack<?> a = s.findPrecise(l);
|
||||
|
||||
if (l.getStackSize() <= 0) {
|
||||
if (a != null) {
|
||||
@@ -773,10 +771,10 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
}
|
||||
|
||||
private long getTotal(final IAEItemStack is) {
|
||||
final IAEItemStack a = this.storage.findPrecise(is);
|
||||
final IAEItemStack b = this.active.findPrecise(is);
|
||||
final IAEItemStack c = this.pending.findPrecise(is);
|
||||
private long getTotal(final IAEStack<?> is) {
|
||||
final IAEStack<?> a = this.storage.findPrecise(is);
|
||||
final IAEStack<?> b = this.active.findPrecise(is);
|
||||
final IAEStack<?> c = this.pending.findPrecise(is);
|
||||
|
||||
long total = 0;
|
||||
|
||||
@@ -795,11 +793,11 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
return total;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(final IAEItemStack l) {
|
||||
final Iterator<IAEItemStack> i = this.visual.iterator();
|
||||
private void deleteVisualStack(final IAEStack<?> l) {
|
||||
final Iterator<IAEStack<?>> i = this.visual.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
final IAEItemStack o = i.next();
|
||||
final IAEStack<?> o = i.next();
|
||||
if (o.equals(l)) {
|
||||
i.remove();
|
||||
return;
|
||||
@@ -807,14 +805,14 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(final IAEItemStack l) {
|
||||
for (final IAEItemStack o : this.visual) {
|
||||
private IAEStack<?> findVisualStack(final IAEStack<?> l) {
|
||||
for (final IAEStack<?> o : this.visual) {
|
||||
if (o.equals(l)) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
final IAEItemStack stack = l.copy();
|
||||
final IAEStack<?> stack = l.copy();
|
||||
this.visual.add(stack);
|
||||
|
||||
return stack;
|
||||
@@ -837,15 +835,15 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiToolti
|
||||
|
||||
@Override
|
||||
public ItemStack getHoveredStack() {
|
||||
return hoveredStack;
|
||||
return hoveredStack != null ? this.hoveredStack.getItemStackForNEI() : null;
|
||||
}
|
||||
|
||||
private void hideStoredSorting() {
|
||||
this.visualHiddenStored = new ArrayList<>();
|
||||
for (final IAEItemStack refStack : this.visual) {
|
||||
for (final IAEStack<?> refStack : this.visual) {
|
||||
if (refStack != null) {
|
||||
final IAEItemStack activeStack = this.active.findPrecise(refStack);
|
||||
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
|
||||
final IAEStack<?> activeStack = this.active.findPrecise(refStack);
|
||||
final IAEStack<?> pendingStack = this.pending.findPrecise(refStack);
|
||||
if ((activeStack != null && activeStack.getStackSize() > 0)
|
||||
|| (pendingStack != null && pendingStack.getStackSize() > 0)) {
|
||||
this.visualHiddenStored.add(refStack);
|
||||
|
||||
@@ -19,19 +19,16 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.client.gui.widgets.GuiAeButton;
|
||||
import appeng.client.gui.widgets.GuiCraftingCPUTable;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
@@ -42,17 +39,11 @@ 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.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTableHolder {
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTableHolder, IGuiSub {
|
||||
|
||||
private final ContainerCraftingStatus status;
|
||||
private GuiButton selectCPU;
|
||||
@@ -60,8 +51,6 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
private final GuiCraftingCPUTable cpuTable;
|
||||
|
||||
protected GuiTabButton originalGuiBtn;
|
||||
private GuiBridge originalGui;
|
||||
protected ItemStack myIcon = null;
|
||||
private boolean tallMode;
|
||||
private GuiImgButton switchTallMode;
|
||||
private List<String> playersFollowingCurrentCraft = new ArrayList<>();
|
||||
@@ -70,49 +59,11 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
super(new ContainerCraftingStatus(inventoryPlayer, te));
|
||||
|
||||
this.status = (ContainerCraftingStatus) this.inventorySlots;
|
||||
this.status.setGuiLink(this);
|
||||
this.tallMode = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.TALL;
|
||||
recalculateScreenSize();
|
||||
|
||||
final Object target = this.status.getTarget();
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
cpuTable = new GuiCraftingCPUTable(this, this.status.getCPUTable(), c -> false);
|
||||
|
||||
if (target instanceof WirelessTerminalGuiObject) {
|
||||
for (final ItemStack wirelessTerminalStack : definitions.items().wirelessTerminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = wirelessTerminalStack;
|
||||
}
|
||||
|
||||
this.originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (target instanceof PartTerminal) {
|
||||
for (final ItemStack stack : parts.terminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (target instanceof PartCraftingTerminal) {
|
||||
for (final ItemStack stack : parts.craftingTerminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
for (final ItemStack stack : parts.patternTerminal().maybeStack(1).asSet()) {
|
||||
this.myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
if (target instanceof PartPatternTerminalEx) {
|
||||
for (final ItemStack stack : parts.patternTerminalEx().maybeStack(1).asSet()) {
|
||||
this.myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +88,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
AELog.debug(e);
|
||||
}
|
||||
} else if (btn == this.originalGuiBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.originalGui));
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
} else if (btn == this.switchTallMode) {
|
||||
tallMode = !tallMode;
|
||||
AEConfig.instance.getConfigManager()
|
||||
@@ -156,6 +107,8 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
super.initGui();
|
||||
this.setScrollBar();
|
||||
|
||||
if (status.getPrimaryGuiIcon() != null) initPrimaryGuiButton();
|
||||
|
||||
this.selectCPU = new GuiButton(
|
||||
0,
|
||||
this.guiLeft + 8,
|
||||
@@ -175,16 +128,6 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
ButtonToolTips.ToFollow.getLocal());
|
||||
this.buttonList.add(this.follow);
|
||||
|
||||
if (this.myIcon != null) {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + 213,
|
||||
this.guiTop - 4,
|
||||
this.myIcon,
|
||||
this.myIcon.getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
this.switchTallMode = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
this.guiTop + this.ySize - 18,
|
||||
@@ -324,7 +267,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref) {
|
||||
public void postUpdate(List<IAEStack<?>> list, byte ref) {
|
||||
super.postUpdate(list, ref);
|
||||
setScrollBar();
|
||||
}
|
||||
@@ -336,4 +279,15 @@ public class GuiCraftingStatus extends GuiCraftingCPU implements ICraftingCPUTab
|
||||
this.playersFollowingCurrentCraft.add(tagList.getStringTagAt(index));
|
||||
}
|
||||
}
|
||||
|
||||
public void initPrimaryGuiButton() {
|
||||
this.buttonList.add(
|
||||
this.originalGuiBtn = new GuiTabButton(
|
||||
this.guiLeft + this.xSize - 25,
|
||||
this.guiTop - 4,
|
||||
status.getPrimaryGuiIcon(),
|
||||
status.getPrimaryGuiIcon().getDisplayName(),
|
||||
itemRender));
|
||||
this.originalGuiBtn.setHideEdge(13);
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,8 @@ public class GuiInterface extends GuiUpgradeable {
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.fuzzyMode.visible = this.bc.getInstalledUpgrades(Upgrades.FUZZY) > 0;
|
||||
this.buttonList.add(fuzzyMode);
|
||||
|
||||
initCustomButtons(this.guiLeft - 18, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,6 +208,8 @@ public class GuiInterface extends GuiUpgradeable {
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
if (actionPerformedCustomButtons(btn)) return;
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
|
||||
if (btn == this.priority) {
|
||||
|
||||
@@ -50,6 +50,8 @@ import appeng.api.config.StringOrder;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.parts.IInterfaceTerminal;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.NamedDimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
@@ -78,7 +80,6 @@ import appeng.integration.IntegrationType;
|
||||
import appeng.integration.modules.NEI;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.parts.reporting.PartInterfaceTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -148,7 +149,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
private static final float STEP_Z = 10.0f;
|
||||
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
|
||||
|
||||
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final PartInterfaceTerminal te) {
|
||||
public GuiInterfaceTerminal(final InventoryPlayer inventoryPlayer, final IInterfaceTerminal te) {
|
||||
this(new ContainerInterfaceTerminal(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@@ -234,28 +235,34 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
searchFieldNames.x = guiLeft + Math.max(32, VIEW_LEFT) + 99;
|
||||
searchFieldNames.y = guiTop + 38;
|
||||
|
||||
int offset = guiTop + 8;
|
||||
terminalStyleBox.xPosition = guiLeft - 18;
|
||||
terminalStyleBox.yPosition = guiTop + 8;
|
||||
terminalStyleBox.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
searchStringSave.xPosition = guiLeft - 18;
|
||||
searchStringSave.yPosition = terminalStyleBox.yPosition + 18;
|
||||
searchStringSave.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
guiButtonSectionOrder.xPosition = guiLeft - 18;
|
||||
guiButtonSectionOrder.yPosition = searchStringSave.yPosition + 18;
|
||||
guiButtonSectionOrder.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
guiButtonBrokenRecipes.xPosition = guiLeft - 18;
|
||||
guiButtonBrokenRecipes.yPosition = guiButtonSectionOrder.yPosition + 18;
|
||||
guiButtonBrokenRecipes.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
guiButtonHideFull.xPosition = guiLeft - 18;
|
||||
guiButtonHideFull.yPosition = guiButtonBrokenRecipes.yPosition + 18;
|
||||
guiButtonHideFull.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
guiButtonAssemblersOnly.xPosition = guiLeft - 18;
|
||||
guiButtonAssemblersOnly.yPosition = guiButtonHideFull.yPosition + 18;
|
||||
guiButtonAssemblersOnly.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
guiButtonUseSubstitute.xPosition = guiLeft - 18;
|
||||
guiButtonUseSubstitute.yPosition = guiButtonAssemblersOnly.yPosition + 18;
|
||||
|
||||
offsetY = guiButtonUseSubstitute.yPosition; // last button pos for ae2fc
|
||||
guiButtonUseSubstitute.yPosition = offset;
|
||||
offset += 18;
|
||||
|
||||
setSearchString();
|
||||
|
||||
@@ -269,6 +276,8 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
buttonList.add(searchStringSave);
|
||||
buttonList.add(terminalStyleBox);
|
||||
buttonList.add(guiButtonUseSubstitute);
|
||||
|
||||
initCustomButtons(this.guiLeft - 18, offset);
|
||||
}
|
||||
|
||||
protected void repositionSlots() {
|
||||
@@ -345,6 +354,7 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (actionPerformedCustomButtons(btn)) return;
|
||||
if (btn == guiButtonAssemblersOnly) {
|
||||
onlyMolecularAssemblers = !onlyMolecularAssemblers;
|
||||
masterList.markDirty();
|
||||
@@ -943,10 +953,10 @@ public class GuiInterfaceTerminal extends AEBaseGui
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
final NBTTagCompound tag = tags.getCompoundTagAt(i);
|
||||
final ItemStack parsedItemStack = ItemStack.loadItemStackFromNBT(tag);
|
||||
final IAEStack<?> aes = Platform.readStackNBT(tag, true);
|
||||
|
||||
if (parsedItemStack != null) {
|
||||
if (itemFilter.test(parsedItemStack)) {
|
||||
if (aes != null) {
|
||||
if (itemFilter.test(aes.getItemStackForNEI())) {
|
||||
return true;
|
||||
}
|
||||
} else if (containsInvalidDisplayName && !tag.hasNoTags()) {
|
||||
|
||||
@@ -24,6 +24,9 @@ import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.parts.ILevelEmitter;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
@@ -33,7 +36,6 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
@@ -56,7 +58,9 @@ public class GuiLevelEmitter extends GuiUpgradeable {
|
||||
private GuiImgButton levelMode;
|
||||
private GuiImgButton craftingMode;
|
||||
|
||||
public GuiLevelEmitter(final InventoryPlayer inventoryPlayer, final PartLevelEmitter te) {
|
||||
private VirtualMEPhantomSlot config;
|
||||
|
||||
public GuiLevelEmitter(final InventoryPlayer inventoryPlayer, final ILevelEmitter te) {
|
||||
super(new ContainerLevelEmitter(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@@ -70,6 +74,13 @@ public class GuiLevelEmitter extends GuiUpgradeable {
|
||||
this.amountTextField.setFocused(true);
|
||||
((ContainerLevelEmitter) this.inventorySlots).setTextField(this.amountTextField);
|
||||
this.validateText();
|
||||
|
||||
this.config = new VirtualMEPhantomSlot(
|
||||
17,
|
||||
42,
|
||||
((ContainerLevelEmitter) inventorySlots).getLvlEmitter().getAEInventoryByName(StorageName.NONE),
|
||||
0);
|
||||
this.registerVirtualSlots(this.config);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,6 +261,11 @@ public class GuiLevelEmitter extends GuiUpgradeable {
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
slot.handleMouseClicked(true, true, isCtrlKeyDown());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (!this.checkHotbarKeys(key)) {
|
||||
|
||||
@@ -11,48 +11,55 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CraftingStatus;
|
||||
import appeng.api.config.PinsState;
|
||||
import appeng.api.config.SearchBoxFocusPriority;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalFontSize;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.slots.VirtualMEMonitorableSlot;
|
||||
import appeng.client.gui.slots.VirtualMEPatternSlot;
|
||||
import appeng.client.gui.slots.VirtualMEPinSlot;
|
||||
import appeng.client.gui.slots.VirtualMESlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.PinSlotME;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
@@ -67,22 +74,21 @@ 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.PacketMonitorableAction;
|
||||
import appeng.core.sync.packets.PacketPinsUpdate;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPinsHandler;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.helpers.MonitorableAction;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.modules.NEI;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.parts.reporting.AbstractPartTerminal;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiMEMonitorable extends AEBaseMEGui
|
||||
public class GuiMEMonitorable extends AEBaseGui
|
||||
implements ISortSource, IConfigManagerHost, IDropToFillTextField, IPinsHandler {
|
||||
|
||||
public static int craftingGridOffsetX;
|
||||
@@ -90,7 +96,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
|
||||
private static String memoryText = "";
|
||||
private final IDisplayRepo repo;
|
||||
private final int offsetX = 9;
|
||||
protected int offsetRepoX = 9;
|
||||
protected int offsetRepoY = 18;
|
||||
private final int MAGIC_HEIGHT_NUMBER = 114 + 1;
|
||||
private final int lowerTextureOffset = 0;
|
||||
private final IConfigManager configSrc;
|
||||
@@ -99,12 +106,12 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
private final ContainerMEMonitorable monitorableContainer;
|
||||
private GuiTabButton craftingStatusBtn;
|
||||
private GuiImgButton craftingStatusImgBtn;
|
||||
private final MEGuiTextField searchField;
|
||||
protected final MEGuiTextField searchField;
|
||||
private GuiText myName;
|
||||
private int perRow = 9;
|
||||
private int reservedSpace = 0;
|
||||
private boolean customSortOrder = true;
|
||||
private int rows = 0;
|
||||
protected int rows = 0;
|
||||
private int standardSize;
|
||||
private GuiImgButton ViewBox;
|
||||
private GuiImgButton SortByBox;
|
||||
@@ -122,6 +129,11 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
public final boolean hasPinHost;
|
||||
private boolean enableShiftPause = true;
|
||||
|
||||
protected VirtualMEPinSlot[] pinSlots = null;
|
||||
protected VirtualMEMonitorableSlot[] monitorableSlots = null;
|
||||
|
||||
private final ITerminalHost host;
|
||||
|
||||
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
this(inventoryPlayer, te, new ContainerMEMonitorable(inventoryPlayer, te));
|
||||
}
|
||||
@@ -134,6 +146,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
this.repo = new ItemRepo(scrollbar, this);
|
||||
this.host = te;
|
||||
|
||||
this.xSize = 195;
|
||||
this.ySize = 204;
|
||||
@@ -148,17 +161,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
|
||||
this.viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
if (te instanceof TileSecurity) {
|
||||
this.myName = GuiText.Security;
|
||||
} else if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.myName = GuiText.WirelessTerminal;
|
||||
} else if (te instanceof IPortableCell) {
|
||||
this.myName = GuiText.PortableCell;
|
||||
} else if (te instanceof IMEChest) {
|
||||
this.myName = GuiText.Chest;
|
||||
} else if (te instanceof AbstractPartTerminal) {
|
||||
this.myName = GuiText.Terminal;
|
||||
}
|
||||
this.myName = te.getName();
|
||||
|
||||
hasPinHost = te instanceof ITerminalPins;
|
||||
|
||||
@@ -176,8 +179,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
NEI.searchField.putFormatter(this.searchField);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
for (final IAEItemStack is : list) {
|
||||
public void postUpdate(final List<IAEStack<?>> list) {
|
||||
for (final IAEStack<?> is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
@@ -186,7 +189,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
}
|
||||
|
||||
private void setScrollBar() {
|
||||
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setTop(this.offsetRepoY).setLeft(166 + this.offsetRepoX).setHeight(this.rows * 18 - 2);
|
||||
this.getScrollBar().setRange(
|
||||
0,
|
||||
(this.repo.size() + pinsState.ordinal() * 9 + this.perRow - 1) / this.perRow - this.rows,
|
||||
@@ -195,6 +198,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
if (actionPerformedCustomButtons(btn)) return;
|
||||
|
||||
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
@@ -266,27 +270,36 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
: 9 + ((this.width - this.standardSize) / 18);
|
||||
this.rows = calculateRowsCount();
|
||||
|
||||
this.getMeSlots().clear();
|
||||
|
||||
// make sure we have space at least for one row of normal slots, because pins not adjusted by scroll bar
|
||||
adjustPinsSize();
|
||||
|
||||
super.initGui();
|
||||
|
||||
int pinsRows = pinsState.ordinal();
|
||||
this.pinSlots = new VirtualMEPinSlot[pinsRows * this.perRow];
|
||||
for (int y = 0; y < pinsRows; y++) {
|
||||
for (int x = 0; x < this.perRow; x++) {
|
||||
this.getMeSlots()
|
||||
.add(new PinSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, y * 18 + 18));
|
||||
VirtualMEPinSlot slot = new VirtualMEPinSlot(
|
||||
this.offsetRepoX + x * 18,
|
||||
y * 18 + this.offsetRepoY,
|
||||
this.repo,
|
||||
y * this.perRow + x);
|
||||
this.pinSlots[y * this.perRow + x] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < this.rows - pinsRows; y++) {
|
||||
int normalSlotRows = this.rows - pinsRows;
|
||||
this.monitorableSlots = new VirtualMEMonitorableSlot[normalSlotRows * this.perRow];
|
||||
for (int y = 0; y < normalSlotRows; y++) {
|
||||
for (int x = 0; x < this.perRow; x++) {
|
||||
this.getMeSlots().add(
|
||||
new InternalSlotME(
|
||||
this.repo,
|
||||
x + y * this.perRow,
|
||||
this.offsetX + x * 18,
|
||||
18 + y * 18 + pinsRows * 18));
|
||||
VirtualMEMonitorableSlot slot = new VirtualMEMonitorableSlot(
|
||||
this.offsetRepoX + x * 18,
|
||||
this.offsetRepoY + y * 18 + pinsRows * 18,
|
||||
this.repo,
|
||||
y * this.perRow + x);
|
||||
this.monitorableSlots[y * this.perRow + x] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +309,6 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
this.xSize = this.standardSize;
|
||||
}
|
||||
|
||||
super.initGui();
|
||||
// full size : 204
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
@@ -319,7 +331,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if (this.viewCell || this instanceof GuiWirelessTerm) {
|
||||
if (this.viewCell) {
|
||||
this.buttonList.add(
|
||||
this.ViewBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
@@ -328,15 +340,13 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
this.configSrc.getSetting(Settings.VIEW_MODE)));
|
||||
offset += 20;
|
||||
}
|
||||
if (!AEApi.instance().registries().itemDisplay().getItemFilters().isEmpty()) {
|
||||
this.buttonList.add(
|
||||
this.typeFilter = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.TYPE_FILTER,
|
||||
this.configSrc.getSetting(Settings.TYPE_FILTER)));
|
||||
offset += 20;
|
||||
}
|
||||
this.buttonList.add(
|
||||
this.typeFilter = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
offset,
|
||||
Settings.TYPE_FILTER,
|
||||
this.configSrc.getSetting(Settings.TYPE_FILTER)));
|
||||
offset += 20;
|
||||
|
||||
this.buttonList.add(
|
||||
this.SortDirBox = new GuiImgButton(
|
||||
@@ -362,7 +372,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
|
||||
offset += 20;
|
||||
|
||||
if (!(this instanceof GuiMEPortableCell) || this instanceof GuiWirelessTerm) {
|
||||
if (!(this instanceof GuiMEPortableCell)) {
|
||||
this.buttonList.add(
|
||||
this.terminalStyleBox = new GuiImgButton(
|
||||
this.guiLeft - 18,
|
||||
@@ -372,7 +382,9 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if (this.viewCell || this instanceof GuiWirelessTerm) {
|
||||
initCustomButtons(this.guiLeft - 18, offset);
|
||||
|
||||
if (this.viewCell) {
|
||||
if (AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS)
|
||||
.equals(CraftingStatus.BUTTON)) {
|
||||
this.buttonList.add(
|
||||
@@ -396,8 +408,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
if (hasPinHost) {
|
||||
this.buttonList.add(
|
||||
this.pinsStateButton = new GuiImgButton(
|
||||
this.guiLeft + 178,
|
||||
this.guiTop + 18 + (rows * 18) + 25,
|
||||
getPinButtonX(),
|
||||
getPinButtonY(),
|
||||
Settings.PINS_STATE,
|
||||
configSrc.getSetting(Settings.PINS_STATE)));
|
||||
}
|
||||
@@ -406,7 +418,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
|
||||
this.canBeAutoFocused = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.NEI_AUTOSEARCH == searchMode;
|
||||
|
||||
this.searchField.x = this.guiLeft + Math.max(80, this.offsetX);
|
||||
this.searchField.x = this.guiLeft + this.offsetRepoX + 71;
|
||||
this.searchField.y = this.guiTop + 4;
|
||||
this.searchField.setFocused(this.canBeAutoFocused);
|
||||
this.isAutoFocused = this.canBeAutoFocused;
|
||||
@@ -458,6 +470,14 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
return Math.max(3, Math.min(this.getMaxRows(), (int) Math.floor(extraSpace / 18)));
|
||||
}
|
||||
|
||||
protected int getPinButtonX() {
|
||||
return this.guiLeft + 178;
|
||||
}
|
||||
|
||||
protected int getPinButtonY() {
|
||||
return this.guiTop + 18 + (rows * 18) + 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(
|
||||
@@ -471,18 +491,147 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
this.ySize - 96 + 3,
|
||||
GuiColors.MEMonitorableInventory.getColor());
|
||||
|
||||
VirtualMEPinSlot.drawSlotsBackground(this.pinSlots, this.mc, this.zLevel);
|
||||
|
||||
this.currentMouseX = mouseX;
|
||||
this.currentMouseY = mouseY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mouseX, int mouseY, List<String> currentToolTip) {
|
||||
super.handleItemTooltip(stack, mouseX, mouseY, currentToolTip);
|
||||
VirtualMESlot hoveredSlot = this.getVirtualMESlotUnderMouse();
|
||||
|
||||
final boolean isMonitorableSlot = hoveredSlot instanceof VirtualMEMonitorableSlot;
|
||||
if (isMonitorableSlot || hoveredSlot instanceof VirtualMEPatternSlot) {
|
||||
IAEStack<?> aes = hoveredSlot.getAEStack();
|
||||
final int threshold = AEConfig.instance.getTerminalFontSize() == TerminalFontSize.SMALL ? 9999 : 999;
|
||||
if (aes != null && aes.getStackSize() > threshold) {
|
||||
final String local = isMonitorableSlot ? ButtonToolTips.ItemsStored.getLocal()
|
||||
: ButtonToolTips.ItemCount.getLocal();
|
||||
final String formattedAmount = NumberFormat.getNumberInstance(Locale.US).format(aes.getStackSize());
|
||||
currentToolTip.add(EnumChatFormatting.GRAY + String.format(local, formattedAmount));
|
||||
}
|
||||
}
|
||||
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
searchField.mouseClicked(xCoord, yCoord, btn);
|
||||
isAutoFocused = false;
|
||||
|
||||
if (handleViewCellClick(xCoord, yCoord, btn)) return;
|
||||
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
private void sendAction(MonitorableAction action, @Nullable IAEStack<?> stack, int custom) {
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
final PacketMonitorableAction p = new PacketMonitorableAction(action, custom);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleVirtualSlotClick(VirtualMESlot virtualSlot, final int mouseButton) {
|
||||
if (this.handleMonitorableSlotClick(virtualSlot, mouseButton)) return true;
|
||||
else return super.handleVirtualSlotClick(virtualSlot, mouseButton);
|
||||
}
|
||||
|
||||
private boolean handleMonitorableSlotClick(VirtualMESlot virtualSlot, final int mouseButton) {
|
||||
if (!(virtualSlot instanceof VirtualMEMonitorableSlot slot)) return false;
|
||||
IAEItemStack slotStack = slot.getAEStack() instanceof IAEItemStack ais ? ais : null;
|
||||
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
|
||||
if (slotStack != null) {
|
||||
this.sendAction(MonitorableAction.MOVE_REGION, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
final boolean isLShiftDown = isShiftKeyDown();
|
||||
final boolean isLControlDown = isCtrlKeyDown();
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0 -> { // left click
|
||||
if (slot instanceof VirtualMEPinSlot && player.inventory.getItemStack() != null) {
|
||||
this.sendAction(
|
||||
isLControlDown ? MonitorableAction.SET_CONTAINER_PIN : MonitorableAction.SET_ITEM_PIN,
|
||||
null,
|
||||
slot.getSlotIndex());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLControlDown) {
|
||||
this.sendAction(
|
||||
isLShiftDown ? MonitorableAction.FILL_CONTAINERS : MonitorableAction.FILL_SINGLE_CONTAINER,
|
||||
slot.getAEStack(),
|
||||
-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLShiftDown) {
|
||||
this.sendAction(MonitorableAction.SHIFT_CLICK, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (slot.getAEStack() != null && slot.getAEStack().getStackSize() == 0
|
||||
&& player.inventory.getItemStack() == null) {
|
||||
this.sendAction(MonitorableAction.AUTO_CRAFT, slot.getAEStack(), -1);
|
||||
return true;
|
||||
}
|
||||
this.sendAction(MonitorableAction.PICKUP_OR_SET_DOWN, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
case 1 -> { // right click
|
||||
if (slot instanceof VirtualMEPinSlot) {
|
||||
if (isLShiftDown) {
|
||||
this.sendAction(MonitorableAction.UNSET_PIN, null, slot.getSlotIndex());
|
||||
} else {
|
||||
this.sendAction(
|
||||
isLControlDown ? MonitorableAction.SET_CONTAINER_PIN : MonitorableAction.SET_ITEM_PIN,
|
||||
null,
|
||||
slot.getSlotIndex());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLControlDown) {
|
||||
this.sendAction(
|
||||
isLShiftDown ? MonitorableAction.DRAIN_CONTAINERS
|
||||
: MonitorableAction.DRAIN_SINGLE_CONTAINER,
|
||||
slot.getAEStack(),
|
||||
-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isLShiftDown) {
|
||||
this.sendAction(MonitorableAction.PICKUP_SINGLE, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.sendAction(MonitorableAction.SPLIT_OR_PLACE_SINGLE, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
case 2 -> { // middle click
|
||||
if (slot.getAEStack() != null && slot.getAEStack().isCraftable()) {
|
||||
this.sendAction(MonitorableAction.AUTO_CRAFT, slot.getAEStack(), -1);
|
||||
return true;
|
||||
} else if (player.capabilities.isCreativeMode) {
|
||||
this.sendAction(MonitorableAction.CREATIVE_DUPLICATE, slotStack, -1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default -> {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean handleViewCellClick(final int xCoord, final int yCoord, final int btn) {
|
||||
if (this.viewCell && monitorableContainer.canAccessViewCells && btn == 1) {
|
||||
Slot slot = getSlot(xCoord, yCoord);
|
||||
@@ -507,6 +656,30 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean mouseWheelEvent(int x, int y, int wheel) {
|
||||
VirtualMESlot slot = this.getVirtualMESlotUnderMouse();
|
||||
if (!isShiftKeyDown() || !(slot instanceof VirtualMEMonitorableSlot)) return false;
|
||||
|
||||
final MonitorableAction direction = wheel > 0 ? MonitorableAction.ROLL_DOWN : MonitorableAction.ROLL_UP;
|
||||
if (direction == MonitorableAction.ROLL_DOWN
|
||||
&& Minecraft.getMinecraft().thePlayer.inventory.getItemStack() == null) {
|
||||
return false;
|
||||
}
|
||||
if (direction == MonitorableAction.ROLL_UP && !(slot.getAEStack() instanceof IAEItemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(slot.getAEStack());
|
||||
final int times = Math.abs(wheel);
|
||||
for (int i = 0; i < times; i++) {
|
||||
final PacketMonitorableAction p = new PacketMonitorableAction(direction, -1);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
super.onGuiClosed();
|
||||
@@ -537,6 +710,16 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
x_width,
|
||||
99 + this.reservedSpace - this.lowerTextureOffset);
|
||||
|
||||
this.searchField.drawTextBox();
|
||||
|
||||
this.updateViewCells();
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
|
||||
protected void updateViewCells() {
|
||||
if (this.viewCell) {
|
||||
boolean update = false;
|
||||
|
||||
@@ -551,12 +734,6 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
this.repo.setViewCell(this.myCurrentViewCells);
|
||||
}
|
||||
}
|
||||
|
||||
searchField.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -564,7 +741,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows() {
|
||||
protected int getMaxRows() {
|
||||
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
|
||||
? AEConfig.instance.MEMonitorableSmallSize
|
||||
: Integer.MAX_VALUE;
|
||||
@@ -588,10 +765,9 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
|
||||
if (CommonHelper.proxy.isActionKey(ActionKey.SEARCH_CONNECTED_INVENTORIES, key)
|
||||
&& !(NEI.searchField.focused() || searchField.isFocused())) {
|
||||
final boolean mouseInGui = this
|
||||
.isPointInRegion(0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY);
|
||||
if (mouseInGui && getSlot(this.currentMouseX, this.currentMouseY) instanceof SlotME sme) {
|
||||
IAEItemStack stack = sme.getAEStack();
|
||||
VirtualMESlot slot = this.getVirtualMESlotUnderMouse();
|
||||
if (slot instanceof VirtualMEMonitorableSlot monitorableSlot) {
|
||||
IAEStack<?> stack = monitorableSlot.getAEStack();
|
||||
this.monitorableContainer.setTargetStack(stack);
|
||||
if (stack != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(
|
||||
@@ -705,11 +881,11 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
&& pointY < rectY + rectHeight + 1;
|
||||
}
|
||||
|
||||
int getReservedSpace() {
|
||||
protected int getReservedSpace() {
|
||||
return this.reservedSpace;
|
||||
}
|
||||
|
||||
void setReservedSpace(final int reservedSpace) {
|
||||
protected void setReservedSpace(final int reservedSpace) {
|
||||
this.reservedSpace = reservedSpace;
|
||||
}
|
||||
|
||||
@@ -760,7 +936,7 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
super.handleKeyboardInput();
|
||||
|
||||
// Pause the terminal when holding shift
|
||||
if (enableShiftPause) this.repo.setPaused(hasShiftDown());
|
||||
if (enableShiftPause) this.repo.setPaused(isShiftKeyDown());
|
||||
}
|
||||
|
||||
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
|
||||
@@ -789,12 +965,8 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasShiftDown() {
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAEPins(IAEItemStack[] pins) {
|
||||
public void setAEPins(IAEStack<?>[] pins) {
|
||||
repo.setAEPins(pins);
|
||||
}
|
||||
|
||||
@@ -802,20 +974,4 @@ public class GuiMEMonitorable extends AEBaseMEGui
|
||||
public void setPinsState(PinsState state) {
|
||||
configSrc.putSetting(Settings.PINS_STATE, state);
|
||||
}
|
||||
|
||||
/// returns all items visible from the terminal
|
||||
/// @return the returned list is **read-only**
|
||||
public IItemList<IAEItemStack> getAvaibleItems() {
|
||||
return repo.getAvailableItems();
|
||||
}
|
||||
|
||||
// Moving items via hotbar keys in terminals isn't working anyway.
|
||||
// Let's disable hotbar keys processing for terminal slots to allow proper input of numbers in the search field
|
||||
@Override
|
||||
protected boolean checkHotbarKeys(int keyCode) {
|
||||
if (theSlot instanceof SlotME) {
|
||||
return false;
|
||||
}
|
||||
return super.checkHotbarKeys(keyCode);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class GuiMEPortableCell extends GuiMEMonitorable {
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
protected int getMaxRows() {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,6 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -35,6 +34,7 @@ import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.NamedDimensionalCoord;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiContextMenu;
|
||||
@@ -42,7 +42,6 @@ import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.highlighter.BlockPosHighlighter;
|
||||
import appeng.container.implementations.ContainerNetworkStatus;
|
||||
import appeng.core.AEConfig;
|
||||
@@ -131,10 +130,10 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
|
||||
ItemStack is = null;
|
||||
if (tooltip > -1) {
|
||||
final IAEItemStack aeStack = repo.getReferenceItem(tooltip);
|
||||
final IAEStack<?> aeStack = repo.getReferenceStack(tooltip);
|
||||
|
||||
if (aeStack != null) {
|
||||
is = aeStack.getItemStack();
|
||||
if (aeStack instanceof IAEItemStack ais) {
|
||||
is = ais.getItemStack();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -278,10 +277,10 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list) {
|
||||
public void postUpdate(final List<IAEStack<?>> list) {
|
||||
this.repo.clear();
|
||||
|
||||
for (final IAEItemStack is : list) {
|
||||
for (final IAEStack<?> is : list) {
|
||||
this.repo.postUpdate(is);
|
||||
}
|
||||
|
||||
@@ -295,61 +294,6 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
this.getScrollBar().setRange(0, (size + 4) / 5 - this.rows, 1);
|
||||
}
|
||||
|
||||
// @Override - NEI
|
||||
public List<String> handleItemTooltip(final ItemStack stack, final int mouseX, final int mouseY,
|
||||
final List<String> currentToolTip) {
|
||||
if (stack != null) {
|
||||
final Slot s = this.getSlot(mouseX, mouseY);
|
||||
if (s instanceof SlotME) {
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
} catch (final Throwable ignore) {}
|
||||
|
||||
if (myStack != null) {
|
||||
while (currentToolTip.size() > 1) {
|
||||
currentToolTip.remove(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
protected void drawItemStackTooltip(final ItemStack stack, final int x, final int y) {
|
||||
final Slot s = this.getSlot(x, y);
|
||||
if (s instanceof SlotME && stack != null) {
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try {
|
||||
final SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
} catch (final Throwable ignore) {}
|
||||
|
||||
if (myStack != null) {
|
||||
final List<String> currentToolTip = stack
|
||||
.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
|
||||
|
||||
while (currentToolTip.size() > 1) {
|
||||
currentToolTip.remove(1);
|
||||
}
|
||||
|
||||
currentToolTip.add(
|
||||
GuiText.Installed.getLocal() + ": "
|
||||
+ NumberFormat.getNumberInstance(Locale.US).format(myStack.getStackSize()));
|
||||
currentToolTip.add(
|
||||
GuiText.EnergyDrain.getLocal() + ": "
|
||||
+ Platform.formatPowerLong(myStack.getCountRequestable(), true));
|
||||
|
||||
this.drawTooltip(x, y, currentToolTip.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy() {
|
||||
return SortOrder.NAME;
|
||||
@@ -466,8 +410,8 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource {
|
||||
int toolPosY = 0;
|
||||
|
||||
for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
|
||||
final IAEItemStack refStack = this.repo.getReferenceItem(z);
|
||||
if (refStack != null) {
|
||||
final IAEStack<?> aes = this.repo.getReferenceStack(z);
|
||||
if (aes instanceof IAEItemStack refStack) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled(0.5, 0.5, 0.5);
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.implementations.ContainerOptimizePatterns;
|
||||
@@ -32,21 +33,15 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketOptimizePatterns;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.ReadableNumberConverter;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
public class GuiOptimizePatterns extends AEBaseGui implements IGuiTooltipHandler {
|
||||
public class GuiOptimizePatterns extends GuiSub implements IGuiTooltipHandler {
|
||||
|
||||
private GuiTextField amountToCraft;
|
||||
private int amountToCraftI = 1;
|
||||
@@ -57,7 +52,6 @@ public class GuiOptimizePatterns extends AEBaseGui implements IGuiTooltipHandler
|
||||
|
||||
final GuiScrollbar scrollbar;
|
||||
|
||||
private GuiBridge OriginalGui;
|
||||
private GuiButton cancel;
|
||||
private GuiButton optimize;
|
||||
|
||||
@@ -76,26 +70,6 @@ public class GuiOptimizePatterns extends AEBaseGui implements IGuiTooltipHandler
|
||||
|
||||
scrollbar = new GuiScrollbar();
|
||||
this.setScrollBar(scrollbar);
|
||||
|
||||
if (te instanceof WirelessTerminalGuiObject) {
|
||||
this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (te instanceof PartTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (te instanceof PartCraftingTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (te instanceof PartPatternTerminal) {
|
||||
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (te instanceof PartPatternTerminalEx) {
|
||||
this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -400,9 +374,7 @@ public class GuiOptimizePatterns extends AEBaseGui implements IGuiTooltipHandler
|
||||
super.actionPerformed(btn);
|
||||
|
||||
if (btn == this.cancel) {
|
||||
if (this.OriginalGui != null) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.OriginalGui));
|
||||
}
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
} else if (btn == this.optimize && this.optimize.enabled) {
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(new PacketOptimizePatterns(multiplierMap));
|
||||
@@ -425,10 +397,12 @@ public class GuiOptimizePatterns extends AEBaseGui implements IGuiTooltipHandler
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
|
||||
public void postUpdate(final List<IAEStack<?>> list, final byte ref) {
|
||||
visual.clear();
|
||||
for (IAEItemStack stack : list) {
|
||||
visual.add(stack.copy());
|
||||
for (IAEStack<?> stack : list) {
|
||||
if (stack instanceof IAEItemStack ais) {
|
||||
visual.add(ais.copy());
|
||||
}
|
||||
}
|
||||
|
||||
this.sortItems();
|
||||
|
||||
@@ -9,26 +9,21 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerOreFilter;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IOreFilterable;
|
||||
import appeng.integration.modules.NEI;
|
||||
import appeng.parts.automation.PartSharedItemBus;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.prioitylist.OreFilteredList.OreFilterTextFormatter;
|
||||
|
||||
public class GuiOreFilter extends AEBaseGui implements IDropToFillTextField {
|
||||
public class GuiOreFilter extends GuiSub implements IDropToFillTextField {
|
||||
|
||||
private MEGuiTextField textField;
|
||||
|
||||
@@ -151,14 +146,8 @@ public class GuiOreFilter extends AEBaseGui implements IDropToFillTextField {
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
|
||||
GuiBridge OriginalGui = null;
|
||||
if (target instanceof PartStorageBus) OriginalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
else if (target instanceof PartSharedItemBus) OriginalGui = GuiBridge.GUI_BUS;
|
||||
else if (target instanceof TileCellWorkbench) OriginalGui = GuiBridge.GUI_CELL_WORKBENCH;
|
||||
|
||||
if (OriginalGui != null) NetworkHandler.instance.sendToServer(new PacketSwitchGuis(OriginalGui));
|
||||
else this.mc.thePlayer.closeScreen();
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis());
|
||||
|
||||
} else if (!this.textField.textboxKeyTyped(character, key)) {
|
||||
super.keyTyped(character, key);
|
||||
|
||||
@@ -1,47 +1,32 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.implementations.ContainerPatternItemRenamer;
|
||||
import appeng.container.implementations.ContainerPatternValueAmount;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketPatternItemRenamer;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.core.sync.packets.PacketPatternValueSet;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class GuiPatternItemRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
public class GuiPatternItemRenamer extends GuiSub implements IDropToFillTextField {
|
||||
|
||||
private final ContainerPatternValueAmount container;
|
||||
private final MEGuiTextField textField;
|
||||
private final String oldName;
|
||||
private final int valueIndex;
|
||||
private GuiBridge originalGui;
|
||||
|
||||
public GuiPatternItemRenamer(InventoryPlayer ip, ITerminalHost p) {
|
||||
super(new ContainerPatternItemRenamer(ip, p));
|
||||
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
|
||||
Slot slot = gui.theSlot;
|
||||
oldName = slot.getStack().getDisplayName();
|
||||
valueIndex = slot.slotNumber;
|
||||
} else {
|
||||
valueIndex = -1;
|
||||
oldName = "";
|
||||
}
|
||||
super(new ContainerPatternValueAmount(ip, p));
|
||||
this.container = (ContainerPatternValueAmount) this.inventorySlots;
|
||||
xSize = 256;
|
||||
|
||||
textField = new MEGuiTextField(231, 12);
|
||||
}
|
||||
|
||||
@@ -52,10 +37,12 @@ public class GuiPatternItemRenamer extends AEBaseGui implements IDropToFillTextF
|
||||
textField.x = guiLeft + 12;
|
||||
textField.y = guiTop + 35;
|
||||
textField.setFocused(true);
|
||||
textField.setText(oldName);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
textField.setText(container.getAEStack().getDisplayName());
|
||||
textField.setCursorPositionEnd();
|
||||
textField.setSelectionPos(0);
|
||||
setOriginGUI(((AEBaseContainer) inventorySlots).getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,24 +63,24 @@ public class GuiPatternItemRenamer extends AEBaseGui implements IDropToFillTextF
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
|
||||
protected void setOriginGUI(Object target) {
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
} else if (target instanceof PartPatternTerminalEx) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(final char character, final int key) {
|
||||
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketPatternItemRenamer(originalGui.ordinal(), textField.getText(), valueIndex));
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketPatternValueSet(
|
||||
getNewNameStack(),
|
||||
this.container.getInvName(),
|
||||
this.container.getSlotIndex()));
|
||||
} else if (!textField.textboxKeyTyped(character, key)) {
|
||||
super.keyTyped(character, key);
|
||||
}
|
||||
}
|
||||
|
||||
private IAEStack<?> getNewNameStack() {
|
||||
return AEItemStack.create(
|
||||
((IAEItemStack) this.container.getAEStack()).getItemStack().setStackDisplayName(textField.getText()));
|
||||
}
|
||||
|
||||
public boolean isOverTextField(final int mousex, final int mousey) {
|
||||
return textField.isMouseIn(mousex, mousey);
|
||||
}
|
||||
@@ -101,12 +88,4 @@ public class GuiPatternItemRenamer extends AEBaseGui implements IDropToFillTextF
|
||||
public void setTextFieldValue(final String displayName, final int mousex, final int mousey, final ItemStack stack) {
|
||||
textField.setText(displayName);
|
||||
}
|
||||
|
||||
public int getValueIndex() {
|
||||
return valueIndex;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return textField.getText();
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,17 @@ package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerPatternMulti;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketPatternMultiSet;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
@@ -50,26 +43,6 @@ public class GuiPatternMulti extends GuiAmount {
|
||||
this.amountTextField.setSelectionPos(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
for (final ItemStack stack : parts.patternTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
else if (target instanceof PartPatternTerminalEx) {
|
||||
for (final ItemStack stack : parts.patternTerminalEx().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj
|
||||
@@ -101,8 +74,8 @@ public class GuiPatternMulti extends GuiAmount {
|
||||
|
||||
if (btn == this.nextBtn && btn.enabled) {
|
||||
int resultI = getAmount();
|
||||
if (resultI > 1 || resultI < -1) NetworkHandler.instance
|
||||
.sendToServer(new PacketPatternMultiSet(this.originalGui.ordinal(), resultI));
|
||||
if (resultI > 1 || resultI < -1)
|
||||
NetworkHandler.instance.sendToServer(new PacketPatternMultiSet(resultI));
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
|
||||
@@ -25,16 +25,21 @@ import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.PatternBeSubstitution;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.client.gui.slots.VirtualMEPatternSlot;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
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.tile.inventory.IAEStackInventory;
|
||||
|
||||
public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
|
||||
@@ -48,28 +53,35 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
|
||||
private GuiTabButton tabCraftButton;
|
||||
private GuiTabButton tabProcessButton;
|
||||
private GuiImgButton substitutionsEnabledBtn;
|
||||
private GuiImgButton substitutionsDisabledBtn;
|
||||
private GuiImgButton beSubstitutionsEnabledBtn;
|
||||
private GuiImgButton beSubstitutionsDisabledBtn;
|
||||
protected GuiImgButton substitutionsEnabledBtn;
|
||||
protected GuiImgButton substitutionsDisabledBtn;
|
||||
protected GuiImgButton beSubstitutionsEnabledBtn;
|
||||
protected GuiImgButton beSubstitutionsDisabledBtn;
|
||||
private GuiImgButton encodeBtn;
|
||||
private GuiImgButton clearBtn;
|
||||
private GuiImgButton doubleBtn;
|
||||
protected GuiImgButton clearBtn;
|
||||
protected GuiImgButton doubleBtn;
|
||||
|
||||
protected VirtualMEPatternSlot[] craftingSlots;
|
||||
protected VirtualMEPatternSlot[] outputSlots;
|
||||
private boolean cragtingMode;
|
||||
|
||||
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te,
|
||||
final ContainerPatternTerm containerPatternTerm) {
|
||||
super(inventoryPlayer, te, containerPatternTerm);
|
||||
this.container = (ContainerPatternTerm) this.inventorySlots;
|
||||
this.cragtingMode = this.container.isCraftingMode();
|
||||
this.setReservedSpace(81);
|
||||
}
|
||||
|
||||
public GuiPatternTerm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new ContainerPatternTerm(inventoryPlayer, te));
|
||||
this.container = (ContainerPatternTerm) this.inventorySlots;
|
||||
this.setReservedSpace(81);
|
||||
this(inventoryPlayer, te, new ContainerPatternTerm(inventoryPlayer, te, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
|
||||
if (btn == 2 && doubleBtn.mousePressed(this.mc, xCoord, yCoord)) { //
|
||||
InventoryAction action = InventoryAction.SET_PATTERN_MULTI;
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, 0, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_MULTI));
|
||||
} else super.mouseClicked(xCoord, yCoord, btn);
|
||||
|
||||
}
|
||||
@@ -80,6 +92,8 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
|
||||
try {
|
||||
if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
|
||||
this.cragtingMode = this.tabProcessButton == btn;
|
||||
updateSlotVisibility();
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
"PatternTerminal.CraftMode",
|
||||
@@ -108,29 +122,30 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
.sendToServer(new PacketValueConfig("PatternTerminal.Double", String.valueOf(val)));
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
AELog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.tabCraftButton = new GuiTabButton(
|
||||
this.guiLeft + 173,
|
||||
this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.crafting_table),
|
||||
GuiText.CraftingPattern.getLocal(),
|
||||
itemRender);
|
||||
this.buttonList.add(this.tabCraftButton);
|
||||
if (this.container.getCraftingModeSupport()) {
|
||||
this.tabCraftButton = new GuiTabButton(
|
||||
this.guiLeft + 173,
|
||||
this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.crafting_table),
|
||||
GuiText.CraftingPattern.getLocal(),
|
||||
itemRender);
|
||||
this.buttonList.add(this.tabCraftButton);
|
||||
|
||||
this.tabProcessButton = new GuiTabButton(
|
||||
this.guiLeft + 173,
|
||||
this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.furnace),
|
||||
GuiText.ProcessingPattern.getLocal(),
|
||||
itemRender);
|
||||
this.buttonList.add(this.tabProcessButton);
|
||||
this.tabProcessButton = new GuiTabButton(
|
||||
this.guiLeft + 173,
|
||||
this.guiTop + this.ySize - 177,
|
||||
new ItemStack(Blocks.furnace),
|
||||
GuiText.ProcessingPattern.getLocal(),
|
||||
itemRender);
|
||||
this.buttonList.add(this.tabProcessButton);
|
||||
}
|
||||
|
||||
this.substitutionsEnabledBtn = new GuiImgButton(
|
||||
this.guiLeft + 84,
|
||||
@@ -187,13 +202,92 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
this.doubleBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.doubleBtn);
|
||||
this.updateButtonVisibility();
|
||||
|
||||
this.initVirtualSlots();
|
||||
}
|
||||
|
||||
protected int getInputSlotOffsetX() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
protected int getInputSlotOffsetY() {
|
||||
return 39;
|
||||
}
|
||||
|
||||
protected int getOutputSlotOffsetX() {
|
||||
return 110;
|
||||
}
|
||||
|
||||
protected int getOutputSlotOffsetY() {
|
||||
return 39;
|
||||
}
|
||||
|
||||
private void initVirtualSlots() {
|
||||
final int inputSlotRow = container.getPatternInputsHeigh();
|
||||
final int inputSlotPerRow = container.getPatternInputsWidth();
|
||||
final int inputPage = container.getPatternInputPages();
|
||||
this.craftingSlots = new VirtualMEPatternSlot[inputSlotPerRow * inputSlotRow * inputPage];
|
||||
final IAEStackInventory inputInv = container.getPatternTerminal()
|
||||
.getAEInventoryByName(StorageName.CRAFTING_INPUT);
|
||||
for (int y = 0; y < inputSlotRow * inputPage; y++) {
|
||||
for (int x = 0; x < inputSlotPerRow; x++) {
|
||||
VirtualMEPatternSlot slot = new VirtualMEPatternSlot(
|
||||
getInputSlotOffsetX() + 18 * x,
|
||||
this.rows * 18 + getInputSlotOffsetY() + 18 * (y % (inputSlotRow)),
|
||||
inputInv,
|
||||
x + y * inputSlotPerRow);
|
||||
this.craftingSlots[x + y * inputSlotPerRow] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
|
||||
final int outputSlotRow = container.getPatternOutputsHeigh();
|
||||
final int outputSlotPerRow = container.getPatternOutputsWidth();
|
||||
final int outputPage = container.getPatternOutputPages();
|
||||
this.outputSlots = new VirtualMEPatternSlot[outputSlotPerRow * outputSlotRow * outputPage];
|
||||
final IAEStackInventory outputInv = container.getPatternTerminal()
|
||||
.getAEInventoryByName(StorageName.CRAFTING_OUTPUT);
|
||||
for (int y = 0; y < outputSlotRow * outputPage; y++) {
|
||||
for (int x = 0; x < outputSlotPerRow; x++) {
|
||||
VirtualMEPatternSlot slot = new VirtualMEPatternSlot(
|
||||
getOutputSlotOffsetX(),
|
||||
this.rows * 18 + getOutputSlotOffsetY() + 18 * (y % outputSlotRow),
|
||||
outputInv,
|
||||
x + y * outputSlotPerRow);
|
||||
this.outputSlots[x + y * outputSlotPerRow] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
updateSlotVisibility();
|
||||
}
|
||||
|
||||
protected void updateSlotVisibility() {
|
||||
if (this.cragtingMode) {
|
||||
for (VirtualMEPhantomSlot outputSlot : outputSlots) {
|
||||
outputSlot.setHidden(true);
|
||||
}
|
||||
} else {
|
||||
for (VirtualMEPhantomSlot outputSlot : outputSlots) {
|
||||
outputSlot.setHidden(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.updateButtonVisibility();
|
||||
|
||||
if (this.cragtingMode != this.container.craftingMode) {
|
||||
this.cragtingMode = this.container.craftingMode;
|
||||
this.updateSlotVisibility();
|
||||
}
|
||||
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
drawTitle();
|
||||
}
|
||||
|
||||
protected void drawTitle() {
|
||||
this.fontRendererObj.drawString(
|
||||
GuiText.PatternTerminal.getLocal(),
|
||||
8,
|
||||
@@ -202,14 +296,16 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
}
|
||||
|
||||
private void updateButtonVisibility() {
|
||||
if (!this.container.isCraftingMode()) {
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.doubleBtn.visible = true;
|
||||
} else {
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
this.doubleBtn.visible = false;
|
||||
if (this.tabCraftButton != null) {
|
||||
if (!this.container.isCraftingMode()) {
|
||||
this.tabCraftButton.visible = false;
|
||||
this.tabProcessButton.visible = true;
|
||||
this.doubleBtn.visible = true;
|
||||
} else {
|
||||
this.tabCraftButton.visible = true;
|
||||
this.tabProcessButton.visible = false;
|
||||
this.doubleBtn.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.container.substitute) {
|
||||
@@ -240,4 +336,13 @@ public class GuiPatternTerm extends GuiMEMonitorable {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
slot.handleMouseClicked(true, !cragtingMode, isCtrlKeyDown(), mouseButton);
|
||||
}
|
||||
|
||||
public VirtualMEPatternSlot[] getCraftingSlots() {
|
||||
return craftingSlots;
|
||||
}
|
||||
}
|
||||
@@ -5,44 +5,31 @@ import java.io.IOException;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.PatternBeSubstitution;
|
||||
import appeng.api.config.PatternSlotConfig;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.implementations.ContainerPatternTermEx;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
|
||||
private static final String SUBSITUTION_DISABLE = "0";
|
||||
private static final String SUBSITUTION_ENABLE = "1";
|
||||
public class GuiPatternTermEx extends GuiPatternTerm {
|
||||
|
||||
private final ContainerPatternTermEx container;
|
||||
|
||||
private GuiImgButton substitutionsEnabledBtn;
|
||||
private GuiImgButton substitutionsDisabledBtn;
|
||||
private GuiImgButton beSubstitutionsEnabledBtn;
|
||||
private GuiImgButton beSubstitutionsDisabledBtn;
|
||||
private GuiImgButton encodeBtn;
|
||||
private GuiImgButton clearBtn;
|
||||
private GuiImgButton invertBtn;
|
||||
private GuiImgButton doubleBtn;
|
||||
private final GuiScrollbar processingScrollBar = new GuiScrollbar();
|
||||
|
||||
private boolean isInverted;
|
||||
private int activePage;
|
||||
|
||||
public GuiPatternTermEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(inventoryPlayer, te, new ContainerPatternTermEx(inventoryPlayer, te));
|
||||
this.container = (ContainerPatternTermEx) this.inventorySlots;
|
||||
@@ -50,6 +37,9 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
|
||||
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
|
||||
processingScrollBar.setTexture(AppEng.MOD_ID, "guis/pattern3.png", 242, 0);
|
||||
|
||||
this.isInverted = this.container.inverted;
|
||||
this.activePage = this.container.activePage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,35 +47,14 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
try {
|
||||
if (this.encodeBtn == btn) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
"PatternTerminalEx.Encode",
|
||||
isCtrlKeyDown() ? (isShiftKeyDown() ? "6" : "1") : (isShiftKeyDown() ? "2" : "1")));
|
||||
} else if (this.clearBtn == btn) {
|
||||
NetworkHandler.instance.sendToServer(new PacketValueConfig("PatternTerminalEx.Clear", "1"));
|
||||
} else if (this.invertBtn == btn) {
|
||||
if (this.invertBtn == btn) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig("PatternTerminalEx.Invert", container.inverted ? "0" : "1"));
|
||||
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
"PatternTerminalEx.Substitute",
|
||||
this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
|
||||
} else if (this.beSubstitutionsEnabledBtn == btn || this.beSubstitutionsDisabledBtn == btn) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
"PatternTerminalEx.BeSubstitute",
|
||||
this.beSubstitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
|
||||
} else if (doubleBtn == btn) {
|
||||
int val = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? 1 : 0;
|
||||
if (Mouse.isButtonDown(1)) val |= 0b10;
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketValueConfig("PatternTerminalEx.Double", String.valueOf(val)));
|
||||
container.getExPatternTerminal().setInverted(container.inverted);
|
||||
this.updateSlotVisibility();
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
AELog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,53 +62,6 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
this.substitutionsEnabledBtn = new GuiImgButton(
|
||||
this.guiLeft + 97,
|
||||
this.guiTop + this.ySize - 163,
|
||||
Settings.ACTIONS,
|
||||
ItemSubstitution.ENABLED);
|
||||
this.substitutionsEnabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.substitutionsEnabledBtn);
|
||||
|
||||
this.substitutionsDisabledBtn = new GuiImgButton(
|
||||
this.guiLeft + 97,
|
||||
this.guiTop + this.ySize - 163,
|
||||
Settings.ACTIONS,
|
||||
ItemSubstitution.DISABLED);
|
||||
this.substitutionsDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.substitutionsDisabledBtn);
|
||||
|
||||
this.beSubstitutionsEnabledBtn = new GuiImgButton(
|
||||
this.guiLeft + 97,
|
||||
this.guiTop + this.ySize - 143,
|
||||
Settings.ACTIONS,
|
||||
PatternBeSubstitution.ENABLED);
|
||||
this.beSubstitutionsEnabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.beSubstitutionsEnabledBtn);
|
||||
|
||||
this.beSubstitutionsDisabledBtn = new GuiImgButton(
|
||||
this.guiLeft + 97,
|
||||
this.guiTop + this.ySize - 143,
|
||||
Settings.ACTIONS,
|
||||
PatternBeSubstitution.DISABLED);
|
||||
this.beSubstitutionsDisabledBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.beSubstitutionsDisabledBtn);
|
||||
|
||||
this.clearBtn = new GuiImgButton(
|
||||
this.guiLeft + 87,
|
||||
this.guiTop + this.ySize - 163,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.CLOSE);
|
||||
this.clearBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.clearBtn);
|
||||
|
||||
this.encodeBtn = new GuiImgButton(
|
||||
this.guiLeft + 147,
|
||||
this.guiTop + this.ySize - 142,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.ENCODE);
|
||||
this.buttonList.add(this.encodeBtn);
|
||||
|
||||
invertBtn = new GuiImgButton(
|
||||
this.guiLeft + 87,
|
||||
this.guiTop + this.ySize - 153,
|
||||
@@ -148,20 +70,28 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
invertBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.invertBtn);
|
||||
|
||||
this.doubleBtn = new GuiImgButton(
|
||||
this.guiLeft + 97,
|
||||
this.guiTop + this.ySize - 153,
|
||||
Settings.ACTIONS,
|
||||
ActionItems.DOUBLE);
|
||||
this.doubleBtn.setHalfSize(true);
|
||||
this.buttonList.add(this.doubleBtn);
|
||||
|
||||
processingScrollBar.setTop(this.ySize - 164);
|
||||
this.updateSlotVisibility();
|
||||
}
|
||||
|
||||
protected int getInputSlotOffsetX() {
|
||||
return 15;
|
||||
}
|
||||
|
||||
protected int getInputSlotOffsetY() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
protected int getOutputSlotOffsetX() {
|
||||
return this.isInverted ? 58 : 112;
|
||||
}
|
||||
|
||||
protected int getOutputSlotOffsetY() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
protected void drawTitle() {
|
||||
this.fontRendererObj.drawString(
|
||||
GuiText.PatternTerminalEx.getLocal(),
|
||||
8,
|
||||
@@ -175,29 +105,8 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
return container.inverted ? "guis/pattern4.png" : "guis/pattern3.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repositionSlot(final AppEngSlot s) {
|
||||
if (s.isPlayerSide()) {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
|
||||
} else {
|
||||
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
|
||||
if (container.substitute) {
|
||||
substitutionsEnabledBtn.visible = true;
|
||||
substitutionsDisabledBtn.visible = false;
|
||||
} else {
|
||||
substitutionsEnabledBtn.visible = false;
|
||||
substitutionsDisabledBtn.visible = true;
|
||||
}
|
||||
|
||||
this.beSubstitutionsEnabledBtn.visible = this.container.beSubstitute;
|
||||
this.beSubstitutionsDisabledBtn.visible = !this.container.beSubstitute;
|
||||
|
||||
final int offset = container.inverted ? 18 * -3 : 0;
|
||||
|
||||
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
|
||||
@@ -210,6 +119,12 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
|
||||
processingScrollBar.setCurrentScroll(container.activePage);
|
||||
|
||||
if (this.isInverted != this.container.inverted || this.activePage != this.container.activePage) {
|
||||
this.isInverted = this.container.inverted;
|
||||
this.activePage = this.container.activePage;
|
||||
this.updateSlotVisibility();
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
}
|
||||
|
||||
@@ -217,12 +132,8 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
|
||||
final int currentScroll = this.processingScrollBar.getCurrentScroll();
|
||||
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
|
||||
if (btn == 2 && doubleBtn.mousePressed(this.mc, xCoord, yCoord)) { //
|
||||
InventoryAction action = InventoryAction.SET_PATTERN_MULTI;
|
||||
|
||||
final PacketInventoryAction p = new PacketInventoryAction(action, 0, 0);
|
||||
NetworkHandler.instance.sendToServer(p);
|
||||
} else super.mouseClicked(xCoord, yCoord, btn);
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
|
||||
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
|
||||
changeActivePage();
|
||||
@@ -262,14 +173,44 @@ public class GuiPatternTermEx extends GuiMEMonitorable {
|
||||
}
|
||||
|
||||
private void changeActivePage() {
|
||||
|
||||
try {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketValueConfig(
|
||||
"PatternTerminalEx.ActivePage",
|
||||
String.valueOf(this.processingScrollBar.getCurrentScroll())));
|
||||
container.activePage = this.processingScrollBar.getCurrentScroll();
|
||||
this.updateSlotVisibility();
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
AELog.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateSlotVisibility() {
|
||||
final int inputSlotRow = container.getPatternInputsHeigh();
|
||||
final int inputSlotPerRow = container.getPatternInputsWidth();
|
||||
for (int page = 0; page < container.getPatternInputPages(); page++) {
|
||||
for (int y = 0; y < inputSlotRow; y++) {
|
||||
for (int x = 0; x < inputSlotPerRow; x++) {
|
||||
VirtualMEPhantomSlot slot = this.craftingSlots[x + y * inputSlotPerRow
|
||||
+ page * (inputSlotPerRow * inputSlotRow)];
|
||||
slot.setHidden(page != this.activePage);
|
||||
slot.setX(getInputSlotOffsetX() + 18 * x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int outputSlotRow = container.getPatternOutputsHeigh();
|
||||
final int outputSlotPerRow = container.getPatternOutputsWidth();
|
||||
for (int page = 0; page < container.getPatternOutputPages(); page++) {
|
||||
for (int y = 0; y < outputSlotRow; y++) {
|
||||
for (int x = 0; x < outputSlotPerRow; x++) {
|
||||
VirtualMEPhantomSlot slot = this.outputSlots[x + y * outputSlotPerRow
|
||||
+ page * (outputSlotPerRow * outputSlotRow)];
|
||||
slot.setHidden(page != this.activePage);
|
||||
slot.setX(getOutputSlotOffsetX());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,71 +1,34 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.slots.VirtualMESlotSingle;
|
||||
import appeng.container.implementations.ContainerPatternValueAmount;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketPatternValueSet;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
|
||||
public class GuiPatternValueAmount extends GuiAmount {
|
||||
|
||||
private final int valueIndex;
|
||||
private final int originalAmount;
|
||||
private final ContainerPatternValueAmount container;
|
||||
private final VirtualMESlotSingle slot;
|
||||
|
||||
@Reflected
|
||||
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
super(new ContainerPatternValueAmount(inventoryPlayer, te));
|
||||
GuiContainer gui = (GuiContainer) Minecraft.getMinecraft().currentScreen;
|
||||
if (gui != null && gui.theSlot != null && gui.theSlot.getHasStack()) {
|
||||
Slot slot = gui.theSlot;
|
||||
originalAmount = slot.getStack().stackSize;
|
||||
valueIndex = slot.slotNumber;
|
||||
} else {
|
||||
valueIndex = -1;
|
||||
originalAmount = 0;
|
||||
}
|
||||
this.container = (ContainerPatternValueAmount) this.inventorySlots;
|
||||
|
||||
this.slot = new VirtualMESlotSingle(34, 53, 0, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.amountTextField.setText(String.valueOf(originalAmount));
|
||||
this.amountTextField.setCursorPositionEnd();
|
||||
this.amountTextField.setSelectionPos(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (target instanceof PartPatternTerminal) {
|
||||
for (final ItemStack stack : parts.patternTerminal().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (target instanceof PartPatternTerminalEx) {
|
||||
for (final ItemStack stack : parts.patternTerminalEx().maybeStack(1).asSet()) {
|
||||
myIcon = stack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
this.registerVirtualSlots(this.slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,10 +41,9 @@ public class GuiPatternValueAmount extends GuiAmount {
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.nextBtn.displayString = GuiText.Set.getLocal();
|
||||
this.nextBtn.enabled = valueIndex >= 0;
|
||||
|
||||
try {
|
||||
int resultI = getAmount();
|
||||
long resultI = getAmountLong();
|
||||
this.nextBtn.enabled = resultI > 0;
|
||||
} catch (final NumberFormatException e) {
|
||||
this.nextBtn.enabled = false;
|
||||
@@ -95,9 +57,12 @@ public class GuiPatternValueAmount extends GuiAmount {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
try {
|
||||
if (btn == this.nextBtn && btn.enabled) {
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketPatternValueSet(originalGui.ordinal(), getAmount(), valueIndex));
|
||||
if (btn == this.nextBtn && btn.enabled && slot.getAEStack() != null) {
|
||||
NetworkHandler.instance.sendToServer(
|
||||
new PacketPatternValueSet(
|
||||
this.container.getAEStack().setStackSize(getAmountLong()),
|
||||
this.container.getInvName(),
|
||||
this.container.getSlotIndex()));
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
@@ -108,4 +73,11 @@ public class GuiPatternValueAmount extends GuiAmount {
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.slot.setAEStack(this.container.getAEStack());
|
||||
this.amountTextField.setText(String.valueOf(this.container.getAEStack().getStackSize()));
|
||||
this.amountTextField.setCursorPositionEnd();
|
||||
this.amountTextField.setSelectionPos(0);
|
||||
}
|
||||
}
|
||||
@@ -13,27 +13,15 @@ package appeng.client.gui.implementations;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.calculators.ArithHelper;
|
||||
import appeng.util.calculators.Calculator;
|
||||
|
||||
@@ -60,55 +48,6 @@ public class GuiPriority extends GuiAmount {
|
||||
((ContainerPriority) this.inventorySlots).setTextField(this.amountTextField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setOriginGUI(Object target) {
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
final IBlocks blocks = definitions.blocks();
|
||||
|
||||
if (target instanceof PartStorageBus) {
|
||||
for (final ItemStack storageBusStack : parts.storageBus().maybeStack(1).asSet()) {
|
||||
myIcon = storageBusStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
if (target instanceof PartFormationPlane) {
|
||||
for (final ItemStack formationPlaneStack : parts.formationPlane().maybeStack(1).asSet()) {
|
||||
myIcon = formationPlaneStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_FORMATION_PLANE;
|
||||
}
|
||||
|
||||
if (target instanceof TileDrive) {
|
||||
for (final ItemStack driveStack : blocks.drive().maybeStack(1).asSet()) {
|
||||
myIcon = driveStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
|
||||
if (target instanceof TileChest) {
|
||||
for (final ItemStack chestStack : blocks.chest().maybeStack(1).asSet()) {
|
||||
myIcon = chestStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_CHEST;
|
||||
}
|
||||
|
||||
if (target instanceof TileInterface) {
|
||||
for (final ItemStack interfaceStack : blocks.iface().maybeStack(1).asSet()) {
|
||||
myIcon = interfaceStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if (target instanceof PartInterface) {
|
||||
for (final ItemStack interfaceStack : parts.iface().maybeStack(1).asSet()) {
|
||||
myIcon = interfaceStack;
|
||||
}
|
||||
this.originalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, GuiColors.PriorityTitle.getColor());
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.widgets.IDropToFillTextField;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.implementations.ContainerRenamer;
|
||||
@@ -18,7 +18,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
|
||||
public class GuiRenamer extends AEBaseGui implements IDropToFillTextField {
|
||||
public class GuiRenamer extends GuiSub implements IDropToFillTextField {
|
||||
|
||||
private MEGuiTextField textField;
|
||||
|
||||
|
||||
@@ -16,12 +16,17 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.parts.IStorageBus;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
@@ -33,7 +38,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable {
|
||||
|
||||
@@ -42,9 +47,12 @@ public class GuiStorageBus extends GuiUpgradeable {
|
||||
private GuiTabButton priority;
|
||||
private GuiImgButton partition;
|
||||
private GuiImgButton clear;
|
||||
private VirtualMEPhantomSlot[] configSlots;
|
||||
private final ContainerStorageBus containerStorageBus;
|
||||
|
||||
public GuiStorageBus(final InventoryPlayer inventoryPlayer, final PartStorageBus te) {
|
||||
public GuiStorageBus(final InventoryPlayer inventoryPlayer, final IStorageBus te) {
|
||||
super(new ContainerStorageBus(inventoryPlayer, te));
|
||||
this.containerStorageBus = (ContainerStorageBus) inventorySlots;
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@@ -90,6 +98,12 @@ public class GuiStorageBus extends GuiUpgradeable {
|
||||
this.buttonList.add(this.oreFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
initVirtualSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
this.fontRendererObj.drawString(
|
||||
@@ -117,6 +131,28 @@ public class GuiStorageBus extends GuiUpgradeable {
|
||||
this.partition.set(csb.getPartitionMode());
|
||||
}
|
||||
}
|
||||
|
||||
updateSlotVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY);
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i >= this.containerStorageBus.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY)) {
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
this.drawTexturedModalRect(offsetX + 7, offsetY + 64 + (18 * i), 7, 28, 162, 18);
|
||||
|
||||
if (i >= this.containerStorageBus.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY)) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,4 +184,37 @@ public class GuiStorageBus extends GuiUpgradeable {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void initVirtualSlots() {
|
||||
this.configSlots = new VirtualMEPhantomSlot[63];
|
||||
final IAEStackInventory inputInv = this.containerStorageBus.getConfig();
|
||||
final int xo = 8;
|
||||
final int yo = -133;
|
||||
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int x = 0; x < 9; x++) {
|
||||
VirtualMEPhantomSlot slot = new VirtualMEPhantomSlot(
|
||||
xo + x * 18,
|
||||
yo + y * 18 + 9 * 18,
|
||||
inputInv,
|
||||
x + y * 9);
|
||||
this.configSlots[x + y * 9] = slot;
|
||||
this.registerVirtualSlots(slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateSlotVisibility() {
|
||||
for (VirtualMEPhantomSlot slot : this.configSlots) {
|
||||
slot.setHidden(
|
||||
slot.getSlotIndex() > (18
|
||||
+ (9 * this.containerStorageBus.getUpgradeable().getInstalledUpgrades(Upgrades.CAPACITY))));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handlePhantomSlotInteraction(VirtualMEPhantomSlot slot, int mouseButton) {
|
||||
StorageChannel channel = containerStorageBus.getStorageChannel();
|
||||
slot.handleMouseClicked(channel == StorageChannel.ITEMS, channel == StorageChannel.FLUIDS, false);
|
||||
}
|
||||
}
|
||||
@@ -10,17 +10,8 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
@@ -34,23 +25,16 @@ import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.localization.GuiColors;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketNEIDragClick;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.parts.automation.PartExportBus;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
|
||||
public class GuiUpgradeable extends AEBaseGui implements INEIGuiHandler {
|
||||
public abstract class GuiUpgradeable extends AEBaseGui {
|
||||
|
||||
protected final ContainerUpgradeable cvb;
|
||||
protected final IUpgradeableHost bc;
|
||||
@@ -61,10 +45,6 @@ public class GuiUpgradeable extends AEBaseGui implements INEIGuiHandler {
|
||||
protected GuiImgButton schedulingMode;
|
||||
protected GuiImgButton oreFilter;
|
||||
|
||||
public GuiUpgradeable(final InventoryPlayer inventoryPlayer, final IUpgradeableHost te) {
|
||||
this(new ContainerUpgradeable(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
public GuiUpgradeable(final ContainerUpgradeable te) {
|
||||
super(te);
|
||||
this.cvb = te;
|
||||
@@ -204,9 +184,7 @@ public class GuiUpgradeable extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/bus.png";
|
||||
}
|
||||
protected abstract String getBackground();
|
||||
|
||||
protected String getAdvancedBackground() {
|
||||
return "guis/advanced_toolbox.png";
|
||||
@@ -246,55 +224,4 @@ public class GuiUpgradeable extends AEBaseGui implements INEIGuiHandler {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_ORE_FILTER));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) {
|
||||
return currentVisibility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
|
||||
List<Pair<SlotFake, Integer>> slots = new ArrayList<>();
|
||||
|
||||
if (this.inventorySlots.inventorySlots.size() > 0) {
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
|
||||
Object slot = this.inventorySlots.inventorySlots.get(i);
|
||||
if (slot instanceof SlotFake) {
|
||||
slots.add(Pair.of((SlotFake) slot, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Pair<SlotFake, Integer> fakeSlotPair : slots) {
|
||||
SlotFake fakeSlot = fakeSlotPair.getKey();
|
||||
if (fakeSlot.isEnabled() && getSlotArea(fakeSlot).contains(mouseX, mouseY)) {
|
||||
fakeSlot.putStack(draggedStack);
|
||||
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, fakeSlotPair.getValue()));
|
||||
if (draggedStack != null) {
|
||||
draggedStack.stackSize = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Rectangle getSlotArea(SlotFake slot) {
|
||||
return new Rectangle(guiLeft + slot.getX(), guiTop + slot.getY(), 16, 16);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
||||
public class GuiWirelessTerm extends GuiMEPortableCell {
|
||||
|
||||
public GuiWirelessTerm(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return this.defaultGetMaxRows();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
|
||||
public class VirtualMEMonitorableSlot extends VirtualMESlot {
|
||||
|
||||
protected final IDisplayRepo repo;
|
||||
|
||||
public VirtualMEMonitorableSlot(int x, int y, IDisplayRepo repo, int slotIndex) {
|
||||
super(x, y, slotIndex);
|
||||
this.repo = repo;
|
||||
this.showAmountAlways = true;
|
||||
this.showCraftableText = true;
|
||||
this.showCraftableIcon = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IAEStack<?> getAEStack() {
|
||||
return this.repo.getReferenceStack(this.slotIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawNEIOverlay() {}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
|
||||
public class VirtualMEPatternSlot extends VirtualMEPhantomSlot {
|
||||
|
||||
public VirtualMEPatternSlot(int x, int y, IAEStackInventory inventory, int slotIndex) {
|
||||
super(x, y, inventory, slotIndex);
|
||||
this.showAmount = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseClicked(boolean acceptItem, boolean acceptFluid, boolean isExtraAction, int mouseButton) {
|
||||
if (mouseButton == 2) { // middle click
|
||||
if (this.getAEStack() != null) {
|
||||
if (isExtraAction) {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_ITEM_RENAMER));
|
||||
} else {
|
||||
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_VALUE_AMOUNT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.handleMouseClicked(acceptItem, acceptFluid, isExtraAction, mouseButton);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketVirtualSlot;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.FluidUtils;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import codechicken.nei.ItemPanels;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
|
||||
public class VirtualMEPhantomSlot extends VirtualMESlot {
|
||||
|
||||
private final IAEStackInventory inventory;
|
||||
|
||||
public VirtualMEPhantomSlot(int x, int y, IAEStackInventory inventory, int slotIndex) {
|
||||
super(x, y, slotIndex);
|
||||
this.inventory = inventory;
|
||||
this.showAmount = false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IAEStack<?> getAEStack() {
|
||||
return this.inventory.getAEStackInSlot(this.getSlotIndex());
|
||||
}
|
||||
|
||||
public StorageName getStorageName() {
|
||||
return this.inventory.getStorageName();
|
||||
}
|
||||
|
||||
public void handleMouseClicked(boolean acceptItem, boolean acceptFluid, boolean isExtraAction) {
|
||||
handleMouseClicked(acceptItem, acceptFluid, isExtraAction, 0);
|
||||
}
|
||||
|
||||
// try nei dragNDrop make frind with regular interaction, unfinished
|
||||
public void handleMouseClicked(boolean acceptItem, boolean acceptFluid, boolean isExtraAction, int mouseButton) {
|
||||
IAEStack<?> currentStack = this.getAEStack();
|
||||
final ItemStack newStack = getTargetStack();
|
||||
|
||||
if (newStack != null && !this.showAmount) {
|
||||
newStack.stackSize = 1;
|
||||
}
|
||||
|
||||
// need always convert display fluid stack from nei or nothing.
|
||||
if (newStack != null && !FluidUtils.isFluidContainer(newStack)
|
||||
&& StackInfo.getFluid(Platform.copyStackWithSize(newStack, 1)) != null) {
|
||||
isExtraAction = true;
|
||||
acceptItem = false;
|
||||
}
|
||||
|
||||
switch (mouseButton) {
|
||||
case 0 -> { // left click
|
||||
if (newStack != null) {
|
||||
if (acceptFluid && (!acceptItem || isExtraAction)) {
|
||||
currentStack = AEFluidStack.create(FluidUtils.getFluidFromContainer(newStack));
|
||||
} else if (acceptItem) currentStack = AEItemStack.create(newStack);
|
||||
} else currentStack = null;
|
||||
}
|
||||
case 1 -> { // right click
|
||||
if (newStack != null) {
|
||||
newStack.stackSize = 1;
|
||||
|
||||
if (acceptFluid && (!acceptItem || isExtraAction))
|
||||
currentStack = AEFluidStack.create(FluidUtils.getFluidFromContainer(newStack));
|
||||
else if (acceptItem) currentStack = AEItemStack.create(newStack);
|
||||
|
||||
if (currentStack != null && currentStack.equals(this.getAEStack())) {
|
||||
currentStack = this.getAEStack();
|
||||
currentStack.decStackSize(-1);
|
||||
}
|
||||
} else if (currentStack != null) {
|
||||
currentStack.decStackSize(1);
|
||||
if (currentStack.getStackSize() <= 0) currentStack = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set on the client to avoid lag on slow networks
|
||||
inventory.putAEStackInSlot(this.getSlotIndex(), currentStack);
|
||||
|
||||
NetworkHandler.instance
|
||||
.sendToServer(new PacketVirtualSlot(this.getStorageName(), this.getSlotIndex(), currentStack));
|
||||
}
|
||||
|
||||
private ItemStack getTargetStack() {
|
||||
ItemStack is = Minecraft.getMinecraft().thePlayer.inventory.getItemStack();
|
||||
if (is == null && IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI)) {
|
||||
is = ItemPanels.bookmarkPanel.draggedStack;
|
||||
if (is == null) is = ItemPanels.itemPanel.draggedStack;
|
||||
}
|
||||
|
||||
return is != null ? is.copy() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class VirtualMEPinSlot extends VirtualMEMonitorableSlot {
|
||||
|
||||
private static final int PIN_ICON_INDEX = 5 * 16 + 14;
|
||||
private static final int UV_Y = (int) Math.floor((double) PIN_ICON_INDEX / 16);
|
||||
private static final int UV_X = PIN_ICON_INDEX - UV_Y * 16;
|
||||
private static final int ICON_SIZE = 16;
|
||||
private static final float PIN_ICON_OPACITY = 0.4f;
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation(AppEng.MOD_ID, "textures/guis/states.png");
|
||||
|
||||
public VirtualMEPinSlot(int x, int y, IDisplayRepo repo, int slotIndex) {
|
||||
super(x, y, repo, slotIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IAEStack<?> getAEStack() {
|
||||
return this.repo.getAEPin(this.slotIndex);
|
||||
}
|
||||
|
||||
public static void drawSlotsBackground(VirtualMEPinSlot[] slots, Minecraft mc, float z) {
|
||||
mc.getTextureManager().bindTexture(TEXTURE);
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(1.0f, 1.0f, 1.0f, PIN_ICON_OPACITY);
|
||||
for (VirtualMEPinSlot slot : slots) {
|
||||
final float x = slot.getX();
|
||||
final float y = slot.getY();
|
||||
final float uvX = UV_X * 16;
|
||||
final float uvY = UV_Y * 16;
|
||||
|
||||
final float f1 = 0.00390625F;
|
||||
final float f = 0.00390625F;
|
||||
tessellator.addVertexWithUV(x + 0, y + ICON_SIZE, z, (uvX + 0) * f, (uvY + ICON_SIZE) * f1);
|
||||
tessellator.addVertexWithUV(x + ICON_SIZE, y + ICON_SIZE, z, (uvX + ICON_SIZE) * f, (uvY + ICON_SIZE) * f1);
|
||||
tessellator.addVertexWithUV(x + ICON_SIZE, y, z, (uvX + ICON_SIZE) * f, (uvY + 0) * f1);
|
||||
tessellator.addVertexWithUV(x + 0, y, z, (uvX + 0) * f, (uvY + 0) * f1);
|
||||
}
|
||||
tessellator.setColorRGBA_F(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
tessellator.draw();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import static appeng.integration.modules.NEI.searchField;
|
||||
import static codechicken.nei.NEIClientConfig.getSearchExpression;
|
||||
import static net.minecraft.client.gui.Gui.drawRect;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.api.ItemFilter;
|
||||
|
||||
public abstract class VirtualMESlot {
|
||||
|
||||
private int xPos;
|
||||
private int yPos;
|
||||
private boolean isHidden = false;
|
||||
|
||||
protected final int slotIndex;
|
||||
|
||||
protected boolean showAmount = true;
|
||||
protected boolean showAmountAlways = false;
|
||||
protected boolean showCraftableText = false;
|
||||
protected boolean showCraftableIcon = false;
|
||||
|
||||
public VirtualMESlot(int x, int y, int slotIndex) {
|
||||
this.xPos = x;
|
||||
this.yPos = y;
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.yPos;
|
||||
}
|
||||
|
||||
public void setX(int x) {
|
||||
this.xPos = x;
|
||||
}
|
||||
|
||||
public void setY(int y) {
|
||||
this.yPos = y;
|
||||
}
|
||||
|
||||
public int getSlotIndex() {
|
||||
return this.slotIndex;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public abstract IAEStack<?> getAEStack();
|
||||
|
||||
public boolean isHovered(int mouseX, int mouseY) {
|
||||
return !this.isHidden && mouseX >= this.xPos
|
||||
&& mouseX < this.xPos + 18
|
||||
&& mouseY >= this.yPos
|
||||
&& mouseY < this.yPos + 18;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ture if hovered
|
||||
*/
|
||||
public boolean drawStackAndOverlay(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.isHidden) return false;
|
||||
|
||||
IAEStack<?> aes = this.getAEStack();
|
||||
if (aes != null) {
|
||||
aes.drawInGui(mc, this.xPos, this.yPos);
|
||||
aes.drawOverlayInGui(
|
||||
mc,
|
||||
this.xPos,
|
||||
this.yPos,
|
||||
this.showAmount,
|
||||
this.showAmountAlways,
|
||||
this.showCraftableText,
|
||||
this.showCraftableIcon);
|
||||
}
|
||||
|
||||
this.drawNEIOverlay();
|
||||
|
||||
final boolean hovered = this.isHovered(mouseX, mouseY);
|
||||
if (hovered) {
|
||||
this.drawHoveredOverlay();
|
||||
}
|
||||
return hovered;
|
||||
}
|
||||
|
||||
protected void drawHoveredOverlay() {
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColorMask(true, true, true, false);
|
||||
drawRect(this.xPos, this.yPos, this.xPos + 16, this.yPos + 16, -2130706433);
|
||||
GL11.glColorMask(true, true, true, true);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
protected void drawNEIOverlay() {
|
||||
if (searchField.isSearchingInventory()) {
|
||||
ItemFilter itemFilter = searchField.getItemFilter();
|
||||
if (itemFilter == null) return;
|
||||
|
||||
IAEStack<?> aes = this.getAEStack();
|
||||
ItemStack item = aes != null ? aes.getItemStackForNEI() : null;
|
||||
if (aes == null || item == null ? !getSearchExpression().isEmpty() : !itemFilter.matches(item)) {
|
||||
NEIClientUtils.gl2DRenderContext(() -> {
|
||||
GL11.glTranslatef(0, 0, 150);
|
||||
drawRect(this.xPos, this.yPos, this.xPos + 16, this.yPos + 16, 0x80000000);
|
||||
GL11.glTranslatef(0, 0, -150);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isHidden() {
|
||||
return this.isHidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden) {
|
||||
this.isHidden = hidden;
|
||||
}
|
||||
|
||||
public void setShowAmount(boolean showAmount) {
|
||||
this.showAmount = showAmount;
|
||||
}
|
||||
|
||||
public void setShowAmountAlways(boolean showAmountAlways) {
|
||||
this.showAmountAlways = showAmountAlways;
|
||||
}
|
||||
|
||||
public void setShowCraftableText(boolean showCraftableText) {
|
||||
this.showCraftableText = showCraftableText;
|
||||
}
|
||||
|
||||
public void setShowCraftableIcon(boolean showCraftableIcon) {
|
||||
this.showCraftableIcon = showCraftableIcon;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package appeng.client.gui.slots;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public class VirtualMESlotSingle extends VirtualMESlot {
|
||||
|
||||
private IAEStack<?> stack;
|
||||
|
||||
public VirtualMESlotSingle(int x, int y, int slotIndex, IAEStack<?> stack) {
|
||||
super(x, y, slotIndex);
|
||||
this.stack = stack;
|
||||
this.showAmount = false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IAEStack<?> getAEStack() {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void setAEStack(@Nullable final IAEStack<?> stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
|
||||
public class InternalSlotME {
|
||||
|
||||
protected final int offset;
|
||||
private final int xPos;
|
||||
private final int yPos;
|
||||
protected final IDisplayRepo repo;
|
||||
|
||||
public InternalSlotME(final IDisplayRepo def, final int offset, final int displayX, final int displayY) {
|
||||
this.repo = def;
|
||||
this.offset = offset;
|
||||
this.xPos = displayX;
|
||||
this.yPos = displayY;
|
||||
}
|
||||
|
||||
ItemStack getStack() {
|
||||
return this.repo.getItem(this.offset);
|
||||
}
|
||||
|
||||
IAEItemStack getAEStack() {
|
||||
return this.repo.getReferenceItem(this.offset);
|
||||
}
|
||||
|
||||
boolean hasPower() {
|
||||
return this.repo.hasPower();
|
||||
}
|
||||
|
||||
int getxPosition() {
|
||||
return this.xPos;
|
||||
}
|
||||
|
||||
int getyPosition() {
|
||||
return this.yPos;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,9 @@ import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TypeFilter;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.IItemDisplayRegistry;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
@@ -41,25 +43,23 @@ import appeng.integration.modules.NEI;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.ItemImmutableList;
|
||||
import appeng.util.item.OreHelper;
|
||||
import appeng.util.item.OreReference;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
|
||||
public class ItemRepo implements IDisplayRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createSortedItemList();
|
||||
private IAEItemStack[] pinsRepo = new IAEItemStack[0];
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final ArrayList<ItemStack> dsp = new ArrayList<>();
|
||||
private final IItemList<IAEStack<?>> list = AEApi.instance().storage().createAEStackList();
|
||||
private IAEStack<?>[] pinsRepo = new IAEStack<?>[0];
|
||||
private final ArrayList<IAEStack<?>> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
private int rowSize = 9;
|
||||
|
||||
private String searchString = "";
|
||||
private Map<IAEItemStack, Boolean> searchCache = new WeakHashMap<>();
|
||||
private IPartitionList<IAEItemStack> myPartitionList;
|
||||
private Map<IAEStack<?>, Boolean> searchCache = new WeakHashMap<>();
|
||||
private IPartitionList myPartitionList;
|
||||
private boolean hasPower;
|
||||
private boolean paused = false;
|
||||
|
||||
@@ -69,11 +69,11 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAEPins(IAEItemStack[] newPins) {
|
||||
IItemList<IAEItemStack> oldPins = getPinsCache();
|
||||
pinsRepo = new IAEItemStack[newPins.length];
|
||||
public void setAEPins(IAEStack<?>[] newPins) {
|
||||
IItemList<IAEStack<?>> oldPins = getPinsCache();
|
||||
pinsRepo = new IAEStack<?>[newPins.length];
|
||||
for (int i = 0; i < pinsRepo.length; i++) {
|
||||
IAEItemStack isToPin = list.findPrecise(newPins[i]);
|
||||
IAEStack<?> isToPin = list.findPrecise(newPins[i]);
|
||||
|
||||
if (isToPin == null) {
|
||||
// If the item is not found in the repo, try to find it in the previous pins.
|
||||
@@ -88,7 +88,7 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
|
||||
for (IAEItemStack ais : oldPins) {
|
||||
for (IAEStack<?> ais : oldPins) {
|
||||
if (ais.getStackSize() != -1) list.add(ais);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,10 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
|
||||
/** pin order is not keep */
|
||||
private IItemList<IAEItemStack> getPinsCache() {
|
||||
IItemList<IAEItemStack> oldPins = AEApi.instance().storage().createItemList();
|
||||
private IItemList<IAEStack<?>> getPinsCache() {
|
||||
IItemList<IAEStack<?>> oldPins = AEApi.instance().storage().createAEStackList();
|
||||
|
||||
for (IAEItemStack pin : pinsRepo) {
|
||||
for (IAEStack<?> pin : pinsRepo) {
|
||||
if (pin != null) {
|
||||
oldPins.add(pin);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getAEPin(int idx) {
|
||||
public IAEStack<?> getAEPin(int idx) {
|
||||
if (idx < 0 || idx >= pinsRepo.length) return null;
|
||||
return pinsRepo[idx];
|
||||
}
|
||||
@@ -118,6 +118,16 @@ public class ItemRepo implements IDisplayRepo {
|
||||
public IAEItemStack getReferenceItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.view.get(idx) instanceof IAEItemStack ais ? ais : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack<?> getReferenceStack(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.view.size()) {
|
||||
return null;
|
||||
}
|
||||
@@ -126,31 +136,21 @@ public class ItemRepo implements IDisplayRepo {
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int idx) {
|
||||
idx += this.src.getCurrentScroll() * this.rowSize;
|
||||
|
||||
if (idx >= this.dsp.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.dsp.get(idx);
|
||||
IAEStack<?> stack = getReferenceStack(idx);
|
||||
return stack instanceof IAEItemStack ais ? ais.getItemStack() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems() {
|
||||
IItemList<IAEItemStack> pins = AEApi.instance().storage().createItemList();
|
||||
for (IAEItemStack is : this.pinsRepo) {
|
||||
if (is != null && is.getStackSize() > 0) {
|
||||
pins.add(is);
|
||||
}
|
||||
}
|
||||
return new ItemImmutableList(list, pins);
|
||||
public void postUpdate(IAEItemStack stack) {
|
||||
this.postUpdate((IAEStack<?>) stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(final IAEItemStack is) {
|
||||
final IAEItemStack st = this.list.findPrecise(is);
|
||||
public void postUpdate(final IAEStack<?> is) {
|
||||
final IAEStack st = this.list.findPrecise(is);
|
||||
|
||||
for (IAEItemStack pin : pinsRepo) {
|
||||
if (pin != null && pin.isSameType(is)) {
|
||||
for (IAEStack pin : pinsRepo) {
|
||||
if (pin != null && pin.isSameType((Object) is)) {
|
||||
pin.reset();
|
||||
pin.add(is);
|
||||
return;
|
||||
@@ -175,11 +175,11 @@ public class ItemRepo implements IDisplayRepo {
|
||||
public void updateView() {
|
||||
if (this.paused) {
|
||||
// Update existing view with new data
|
||||
IItemList<IAEItemStack> pins = getPinsCache();
|
||||
IItemList<IAEStack<?>> pins = getPinsCache();
|
||||
for (int i = 0; i < this.view.size(); i++) {
|
||||
IAEItemStack entry = this.view.get(i);
|
||||
IAEItemStack serverEntry = this.list.findPrecise(entry);
|
||||
IAEItemStack pinsEntry = pins.findPrecise(serverEntry);
|
||||
IAEStack<?> entry = this.view.get(i);
|
||||
IAEStack<?> serverEntry = this.list.findPrecise(entry);
|
||||
IAEStack<?> pinsEntry = pins.findPrecise(serverEntry);
|
||||
if (serverEntry == null || pinsEntry != null) {
|
||||
entry.setStackSize(0);
|
||||
} else {
|
||||
@@ -188,9 +188,9 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
|
||||
// Append newly added item stacks to the end of the view
|
||||
Set<IAEItemStack> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEItemStack> entriesToAdd = new ArrayList<>();
|
||||
for (IAEItemStack serverEntry : this.list) {
|
||||
Set<IAEStack<?>> viewSet = new HashSet<>(this.view);
|
||||
ArrayList<IAEStack<?>> entriesToAdd = new ArrayList<>();
|
||||
for (IAEStack<?> serverEntry : this.list) {
|
||||
if (!viewSet.contains(serverEntry)) {
|
||||
entriesToAdd.add(serverEntry);
|
||||
}
|
||||
@@ -219,23 +219,20 @@ public class ItemRepo implements IDisplayRepo {
|
||||
this.view.sort(ItemSorters.CONFIG_BASED_SORT_BY_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
this.dsp.clear();
|
||||
this.dsp.ensureCapacity(this.list.size());
|
||||
for (final IAEItemStack is : this.view) {
|
||||
this.dsp.add(is.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
private void addEntriesToView(Iterable<IAEItemStack> entries) {
|
||||
private void addEntriesToView(Iterable<IAEStack<?>> entries) {
|
||||
final Enum viewMode = this.sortSrc.getSortDisplay();
|
||||
final Enum typeFilter = this.sortSrc.getTypeFilter();
|
||||
Predicate<IAEItemStack> itemFilter = null;
|
||||
Predicate<IAEStack<?>> itemFilter = null;
|
||||
|
||||
if (!this.searchString.trim().isEmpty()) {
|
||||
if (NEI.searchField.existsSearchField()) {
|
||||
final Predicate<ItemStack> neiFilter = NEI.searchField.getFilter(this.searchString);
|
||||
itemFilter = is -> neiFilter.test(is.getItemStack());
|
||||
itemFilter = is -> {
|
||||
ItemStack stack = is.getItemStackForNEI();
|
||||
return stack != null && neiFilter.test(stack);
|
||||
};
|
||||
} else {
|
||||
itemFilter = getFilter(this.searchString);
|
||||
}
|
||||
@@ -243,7 +240,7 @@ public class ItemRepo implements IDisplayRepo {
|
||||
|
||||
IItemDisplayRegistry registry = AEApi.instance().registries().itemDisplay();
|
||||
|
||||
out: for (IAEItemStack is : entries) {
|
||||
out: for (IAEStack<?> is : entries) {
|
||||
if (viewMode == ViewItems.CRAFTABLE && !is.isCraftable()) {
|
||||
continue;
|
||||
}
|
||||
@@ -256,15 +253,24 @@ public class ItemRepo implements IDisplayRepo {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (registry.isBlacklisted(is.getItem()) || registry.isBlacklisted(is.getItem().getClass())) {
|
||||
continue;
|
||||
if (typeFilter == TypeFilter.ITEMS) {
|
||||
if (!(is instanceof IAEItemStack)) continue;
|
||||
} else if (typeFilter == TypeFilter.FLUIDS) {
|
||||
if (!(is instanceof IAEFluidStack)) continue;
|
||||
}
|
||||
|
||||
for (final BiPredicate<TypeFilter, IAEItemStack> filter : registry.getItemFilters()) {
|
||||
if (!filter.test((TypeFilter) typeFilter, is)) continue out;
|
||||
if (is instanceof IAEItemStack ais) {
|
||||
if (registry.isBlacklisted(ais.getItemStack().getItem())
|
||||
|| registry.isBlacklisted(ais.getItemStack().getItem().getClass())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (final BiPredicate<TypeFilter, IAEItemStack> filter : registry.getItemFilters()) {
|
||||
if (!filter.test((TypeFilter) typeFilter, ais)) continue out;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemFilter == null || Boolean.TRUE.equals(this.searchCache.computeIfAbsent(is, itemFilter::test))) {
|
||||
if (itemFilter == null || this.searchCache.computeIfAbsent(is, itemFilter::test)) {
|
||||
|
||||
if (viewMode == ViewItems.CRAFTABLE) {
|
||||
is = is.copy();
|
||||
@@ -276,7 +282,7 @@ public class ItemRepo implements IDisplayRepo {
|
||||
}
|
||||
}
|
||||
|
||||
private Predicate<IAEItemStack> getFilter(String innerSearch) {
|
||||
private Predicate<IAEStack<?>> getFilter(String innerSearch) {
|
||||
|
||||
if (innerSearch.isEmpty()) {
|
||||
return stack -> true;
|
||||
@@ -293,19 +299,22 @@ public class ItemRepo implements IDisplayRepo {
|
||||
} else if ("@".equals(prefix)) {
|
||||
final Pattern pattern = getPattern(innerSearch.substring(1));
|
||||
return stack -> {
|
||||
String mod = Platform.getModId(stack);
|
||||
String mod = stack.getModId();
|
||||
return pattern.matcher(mod).find();
|
||||
};
|
||||
} else if ("$".equals(prefix)) {
|
||||
final Pattern pattern = getPattern(innerSearch.substring(1));
|
||||
return stack -> {
|
||||
OreReference ores = OreHelper.INSTANCE.isOre(stack.getItemStack());
|
||||
return ores != null && pattern.matcher(String.join("\n", ores.getEquivalents())).find();
|
||||
if (stack instanceof IAEItemStack ais) {
|
||||
OreReference ores = OreHelper.INSTANCE.isOre(ais.getItemStack());
|
||||
return ores != null && pattern.matcher(String.join("\n", ores.getEquivalents())).find();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
} else {
|
||||
final Pattern pattern = getPattern(innerSearch);
|
||||
return stack -> {
|
||||
String name = Platform.getItemDisplayName(stack);
|
||||
String name = stack.getDisplayName();
|
||||
|
||||
if (pattern.matcher(name).find()) {
|
||||
return true;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IDisplayRepo;
|
||||
|
||||
public class PinSlotME extends InternalSlotME {
|
||||
|
||||
public PinSlotME(final IDisplayRepo def, final int offset, final int displayX, final int displayY) {
|
||||
super(def, offset, displayX, displayY);
|
||||
}
|
||||
|
||||
@Override
|
||||
ItemStack getStack() {
|
||||
return this.repo.getAEPin(offset) != null ? this.repo.getAEPin(offset).getItemStack() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
IAEItemStack getAEStack() {
|
||||
return this.repo.getAEPin(offset);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class SlotDisconnected extends AppEngSlot {
|
||||
|
||||
private final ClientDCInternalInv mySlot;
|
||||
|
||||
public SlotDisconnected(final ClientDCInternalInv me, final int which, final int x, final int y) {
|
||||
super(me.getInventory(), which, x, y);
|
||||
this.mySlot = me;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getDisplayStack() {
|
||||
if (Platform.isClient()) {
|
||||
final ItemStack is = super.getStack();
|
||||
if (is != null && is.getItem() instanceof ItemEncodedPattern iep) {
|
||||
final ItemStack out = iep.getOutput(is);
|
||||
if (out != null) {
|
||||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return this.getStack() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ClientDCInternalInv getSlot() {
|
||||
return this.mySlot;
|
||||
}
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2. Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. Applied
|
||||
* Energistics 2 is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
|
||||
* Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
|
||||
* later version. Applied Energistics 2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
|
||||
* Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.me;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public class SlotME extends Slot {
|
||||
|
||||
private final InternalSlotME mySlot;
|
||||
|
||||
public SlotME(final InternalSlotME me) {
|
||||
super(null, 0, me.getxPosition(), me.getyPosition());
|
||||
this.mySlot = me;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.mySlot.getAEStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(final EntityPlayer par1EntityPlayer, final ItemStack par2ItemStack) {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(final ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.mySlot.getStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
if (this.mySlot.hasPower()) {
|
||||
return this.getStack() != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(final ItemStack par1ItemStack) {}
|
||||
|
||||
@Override
|
||||
public int getSlotStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(final int par1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotInInventory(final IInventory par1iInventory, final int par2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(final EntityPlayer par1EntityPlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPin() {
|
||||
return mySlot instanceof PinSlotME;
|
||||
}
|
||||
|
||||
public int getPinIndex() {
|
||||
return mySlot.offset;
|
||||
}
|
||||
|
||||
public int getPinIcon() {
|
||||
return 5 * 16 + 14;
|
||||
}
|
||||
|
||||
public float getOpacityOfIcon() {
|
||||
return 0.4f;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@
|
||||
|
||||
package appeng.container;
|
||||
|
||||
import static appeng.util.Platform.getItemFromPlayerInventoryBySlotIndex;
|
||||
import static appeng.util.Platform.isStacksIdentical;
|
||||
import static appeng.util.Platform.setPlayerInventorySlotByIndex;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -31,14 +35,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -51,16 +56,16 @@ import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.ItemSearchDTO;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.guisync.SyncData;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerUpgradeable;
|
||||
import appeng.container.implementations.ContainerWirelessTerm;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
@@ -72,29 +77,32 @@ import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketHighlightBlockStorage;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.core.sync.packets.PacketVirtualSlot;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.IPinsHandler;
|
||||
import appeng.helpers.IPrimaryGuiIconProvider;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.items.materials.ItemMultiMaterial;
|
||||
import appeng.me.Grid;
|
||||
import appeng.me.MachineSet;
|
||||
import appeng.me.NetworkList;
|
||||
import appeng.me.cache.NetworkMonitor;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.IterationCounter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public abstract class AEBaseContainer extends Container {
|
||||
|
||||
@@ -109,16 +117,20 @@ public abstract class AEBaseContainer extends Container {
|
||||
private boolean isContainerValid = true;
|
||||
private String customName;
|
||||
private ContainerOpenContext openContext;
|
||||
private IMEInventoryHandler<IAEItemStack> cellInv;
|
||||
private IMEInventoryHandler<IAEItemStack> cellItemInv;
|
||||
private IMEInventoryHandler<IAEFluidStack> cellFluidInv;
|
||||
private IEnergySource powerSrc;
|
||||
private boolean sentCustomName;
|
||||
private int ticksSinceCheck = 900;
|
||||
private IAEItemStack clientRequestedTargetItem = null;
|
||||
private IAEStack<?> clientRequestedTargetItem = null;
|
||||
private PrimaryGui primaryGui;
|
||||
|
||||
@Deprecated
|
||||
public AEBaseContainer(final InventoryPlayer ip, final TileEntity myTile, final IPart myPart) {
|
||||
this(ip, myTile, myPart, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AEBaseContainer(final InventoryPlayer ip, final TileEntity myTile, final IPart myPart,
|
||||
final IGuiItemObject gio) {
|
||||
this.invPlayer = ip;
|
||||
@@ -180,6 +192,11 @@ public abstract class AEBaseContainer extends Container {
|
||||
throw new IllegalArgumentException("Must have a valid anchor, instead " + anchor + " in " + ip);
|
||||
}
|
||||
|
||||
if (obj instanceof IInventorySlotAware isa) {
|
||||
final int slotIndex = isa.getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
}
|
||||
|
||||
this.mySrc = new PlayerSource(ip.player, this.getActionHost());
|
||||
|
||||
this.prepareSync();
|
||||
@@ -208,7 +225,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
try {
|
||||
final NBTTagCompound data = CompressedStreamTools.readCompressed(new ByteArrayInputStream(buffer));
|
||||
if (data != null) {
|
||||
this.setTargetStack(AEApi.instance().storage().createItemStack(ItemStack.loadItemStackFromNBT(data)));
|
||||
this.setTargetStack(Platform.readStackNBT(data));
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
@@ -217,30 +234,32 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.dataChunks.clear();
|
||||
}
|
||||
|
||||
public IAEItemStack getTargetStack() {
|
||||
public IAEStack<?> getTargetStack() {
|
||||
return this.clientRequestedTargetItem;
|
||||
}
|
||||
|
||||
public void setTargetStack(final IAEItemStack stack) {
|
||||
public void setTargetStack(final IAEStack<?> stack) {
|
||||
// client doesn't need to re-send, makes for lower overhead rapid packets.
|
||||
if (Platform.isClient()) {
|
||||
final ItemStack a = stack == null ? null : stack.getItemStack();
|
||||
final ItemStack b = this.clientRequestedTargetItem == null ? null
|
||||
: this.clientRequestedTargetItem.getItemStack();
|
||||
|
||||
if (Platform.isSameItemPrecise(a, b)) {
|
||||
return;
|
||||
if (stack == null) {
|
||||
if (this.clientRequestedTargetItem == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (stack.equals(this.clientRequestedTargetItem)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
final NBTTagCompound item = new NBTTagCompound();
|
||||
final NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(item);
|
||||
Platform.writeStackNBT(stack, nbt, true);
|
||||
}
|
||||
|
||||
try {
|
||||
CompressedStreamTools.writeCompressed(item, stream);
|
||||
CompressedStreamTools.writeCompressed(nbt, stream);
|
||||
|
||||
final int maxChunkSize = 30000;
|
||||
final List<byte[]> miniPackets = new LinkedList<>();
|
||||
@@ -395,15 +414,15 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.sendCustomName();
|
||||
|
||||
if (Platform.isServer()) {
|
||||
for (final Object crafter : this.crafters) {
|
||||
final ICrafting icrafting = (ICrafting) crafter;
|
||||
|
||||
for (final ICrafting crafter : this.crafters) {
|
||||
for (final SyncData sd : this.syncData.values()) {
|
||||
sd.tick(icrafting);
|
||||
sd.tick(crafter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
portableSourceTick();
|
||||
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@@ -413,18 +432,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean hasMETiles = false;
|
||||
for (final Object is : this.inventorySlots) {
|
||||
if (is instanceof InternalSlotME) {
|
||||
hasMETiles = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasMETiles && Platform.isClient()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
|
||||
|
||||
if (clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible) {
|
||||
@@ -443,8 +450,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
* Gather a list of valid destinations.
|
||||
*/
|
||||
if (clickSlot.isPlayerSide()) {
|
||||
tis = this.shiftStoreItem(tis);
|
||||
|
||||
// target slots in the container...
|
||||
for (final Object inventorySlot : this.inventorySlots) {
|
||||
final AppEngSlot cs = (AppEngSlot) inventorySlot;
|
||||
@@ -495,7 +500,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
if (tis != null) {
|
||||
// find partials..
|
||||
for (final Slot d : selectedSlots) {
|
||||
if (d instanceof SlotDisabled || d instanceof SlotME) {
|
||||
if (d instanceof SlotDisabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -538,7 +543,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
// any match..
|
||||
for (final Slot d : selectedSlots) {
|
||||
if (d instanceof SlotDisabled || d instanceof SlotME) {
|
||||
if (d instanceof SlotDisabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -727,195 +732,13 @@ public abstract class AEBaseContainer extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
if (action == InventoryAction.SET_PIN && this instanceof IPinsHandler iph) {
|
||||
if (id == -1) {
|
||||
iph.setPin(null, slot);
|
||||
return;
|
||||
}
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (hand == null) return;
|
||||
if (iph.getPin(slot) != null && hand.isItemEqual(iph.getPin(slot))) {
|
||||
// put item in the terminal
|
||||
doAction(player, InventoryAction.PICKUP_OR_SET_DOWN, this.inventorySlots.size(), id);
|
||||
} else {
|
||||
iph.setPin(player.inventory.getItemStack(), slot);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// get target item.
|
||||
final IAEItemStack slotItem = this.clientRequestedTargetItem;
|
||||
final IAEItemStack slotItem = this.clientRequestedTargetItem instanceof IAEItemStack ais ? ais : null;
|
||||
|
||||
switch (action) {
|
||||
case SHIFT_CLICK -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (slotItem != null) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ItemStack myItem = ais.getItemStack();
|
||||
|
||||
ais.setStackSize(myItem.getMaxStackSize());
|
||||
|
||||
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
myItem.stackSize = (int) ais.getStackSize();
|
||||
myItem = adp.simulateAdd(myItem);
|
||||
|
||||
if (myItem != null) {
|
||||
ais.setStackSize(ais.getStackSize() - myItem.stackSize);
|
||||
}
|
||||
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais != null) {
|
||||
adp.addItems(ais.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
case ROLL_DOWN -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
final int releaseQty = 1;
|
||||
final ItemStack isg = player.inventory.getItemStack();
|
||||
if (isg != null && releaseQty > 0) {
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack(isg);
|
||||
ais.setStackSize(1);
|
||||
final IAEItemStack extracted = ais.copy();
|
||||
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais == null) {
|
||||
final InventoryAdaptor ia = new AdaptorPlayerHand(player);
|
||||
|
||||
final ItemStack fail = ia.removeItems(1, extracted.getItemStack(), null);
|
||||
if (fail == null) {
|
||||
this.getCellInventory()
|
||||
.extractItems(extracted, Actionable.MODULATE, this.getActionSource());
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
case ROLL_UP, PICKUP_SINGLE -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (slotItem != null) {
|
||||
int liftQty = 1;
|
||||
final ItemStack item = player.inventory.getItemStack();
|
||||
|
||||
if (item != null) {
|
||||
if (item.stackSize >= item.getMaxStackSize()) {
|
||||
liftQty = 0;
|
||||
}
|
||||
if (!Platform.isSameItemPrecise(slotItem.getItemStack(), item)) {
|
||||
liftQty = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (liftQty > 0) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize(1);
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais != null) {
|
||||
final InventoryAdaptor ia = new AdaptorPlayerHand(player);
|
||||
|
||||
final ItemStack fail = ia.addItems(ais.getItemStack());
|
||||
if (fail != null) {
|
||||
this.getCellInventory().injectItems(ais, Actionable.MODULATE, this.getActionSource());
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case PICKUP_OR_SET_DOWN -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
if (slotItem != null) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize(ais.getItemStack().getMaxStackSize());
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case SPLIT_OR_PLACE_SINGLE -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (player.inventory.getItemStack() == null) {
|
||||
if (slotItem != null) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
final long maxSize = ais.getItemStack().getMaxStackSize();
|
||||
ais.setStackSize(maxSize);
|
||||
ais = this.getCellInventory().extractItems(ais, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
if (ais != null) {
|
||||
final long stackSize = Math.min(maxSize, ais.getStackSize());
|
||||
ais.setStackSize((stackSize + 1) >> 1);
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
}
|
||||
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
|
||||
ais.setStackSize(1);
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais == null) {
|
||||
final ItemStack is = player.inventory.getItemStack();
|
||||
is.stackSize--;
|
||||
if (is.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
case CREATIVE_DUPLICATE -> {
|
||||
if (player.capabilities.isCreativeMode && slotItem != null) {
|
||||
final ItemStack is = slotItem.getItemStack();
|
||||
@@ -924,39 +747,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case MOVE_REGION -> {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
if (slotItem != null) {
|
||||
final int playerInv = 9 * 4;
|
||||
for (int slotNum = 0; slotNum < playerInv; slotNum++) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ItemStack myItem = ais.getItemStack();
|
||||
|
||||
ais.setStackSize(myItem.getMaxStackSize());
|
||||
|
||||
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
myItem.stackSize = (int) ais.getStackSize();
|
||||
myItem = adp.simulateAdd(myItem);
|
||||
|
||||
if (myItem != null) {
|
||||
ais.setStackSize(ais.getStackSize() - myItem.stackSize);
|
||||
}
|
||||
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais != null) {
|
||||
adp.addItems(ais.getItemStack());
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case FIND_ITEMS -> {
|
||||
final Class<? extends IGridHost>[] checkedMachineClasses = new Class[] { TileDrive.class,
|
||||
TileChest.class, PartStorageBus.class, };
|
||||
@@ -964,17 +754,12 @@ public abstract class AEBaseContainer extends Container {
|
||||
|
||||
IGrid g = null;
|
||||
// Pull grid
|
||||
if (this instanceof ContainerWirelessTerm wirelessTerm
|
||||
&& wirelessTerm.getMonitor() instanceof NetworkMonitor<?>networkMonitor) {
|
||||
g = networkMonitor.getGrid();
|
||||
} else {
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host == null) return;
|
||||
final IActionHost host = this.getActionHost();
|
||||
if (host == null) return;
|
||||
|
||||
final IGridNode gn = host.getActionableNode();
|
||||
if (gn != null) {
|
||||
g = gn.getGrid();
|
||||
}
|
||||
final IGridNode gn = host.getActionableNode();
|
||||
if (gn != null) {
|
||||
g = gn.getGrid();
|
||||
}
|
||||
|
||||
if (g == null) return;
|
||||
@@ -1031,7 +816,9 @@ public abstract class AEBaseContainer extends Container {
|
||||
}
|
||||
}
|
||||
if (machine instanceof PartStorageBus innerMachine) {
|
||||
if (innerMachine.getConnectedGrid() != null) { // Check if storageBus is subnet
|
||||
if (innerMachine.getConnectedGrid() != null
|
||||
|| innerMachine.getStorageChannel() != StorageChannel.ITEMS) { // Check if storageBus is
|
||||
// subnet
|
||||
continue;
|
||||
}
|
||||
MEInventoryHandler<IAEItemStack> handler = innerMachine.getInternalHandler();
|
||||
@@ -1088,21 +875,6 @@ public abstract class AEBaseContainer extends Container {
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack shiftStoreItem(final ItemStack input) {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return input;
|
||||
}
|
||||
final IAEItemStack ais = Platform.poweredInsert(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
AEApi.instance().storage().createItemStack(input),
|
||||
this.getActionSource());
|
||||
if (ais == null) {
|
||||
return null;
|
||||
}
|
||||
return ais.getItemStack();
|
||||
}
|
||||
|
||||
private void updateSlot(final Slot clickSlot) {
|
||||
// ???
|
||||
this.detectAndSendChanges();
|
||||
@@ -1231,11 +1003,19 @@ public abstract class AEBaseContainer extends Container {
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEItemStack> getCellInventory() {
|
||||
return this.cellInv;
|
||||
return this.cellItemInv;
|
||||
}
|
||||
|
||||
public void setCellInventory(final IMEInventoryHandler<IAEItemStack> cellInv) {
|
||||
this.cellInv = cellInv;
|
||||
this.cellItemInv = cellInv;
|
||||
}
|
||||
|
||||
public IMEInventoryHandler<IAEFluidStack> getCellFluidInventory() {
|
||||
return this.cellFluidInv;
|
||||
}
|
||||
|
||||
public void setCellFluidInventory(final IMEInventoryHandler<IAEFluidStack> cellInv) {
|
||||
this.cellFluidInv = cellInv;
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
@@ -1273,4 +1053,111 @@ public abstract class AEBaseContainer extends Container {
|
||||
public void setPowerSource(final IEnergySource powerSrc) {
|
||||
this.powerSrc = powerSrc;
|
||||
}
|
||||
|
||||
// used for secondary gui for able handle tertiary, quaternary etc. gui
|
||||
public void setPrimaryGui(PrimaryGui primaryGui) {
|
||||
this.primaryGui = primaryGui;
|
||||
}
|
||||
|
||||
private void createPrimaryGui() {
|
||||
ContainerOpenContext context = getOpenContext();
|
||||
|
||||
this.primaryGui = new PrimaryGui(
|
||||
GuiBridge.getGuiByContainerClass(this.getClass()),
|
||||
getTarget() instanceof IPrimaryGuiIconProvider ip ? ip.getPrimaryGuiIcon()
|
||||
: AEApi.instance().definitions().parts().terminal().maybeStack(1).orNull(),
|
||||
context.getTile(),
|
||||
context.getSide());
|
||||
}
|
||||
|
||||
public PrimaryGui getPrimaryGui() {
|
||||
if (primaryGui == null) createPrimaryGui();
|
||||
return primaryGui;
|
||||
}
|
||||
|
||||
private int ticks = 0;
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
protected void setPowerMultiplier(final double powerMultiplier) {
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
}
|
||||
|
||||
private void portableSourceTick() {
|
||||
final Object obj = this.getTarget();
|
||||
if (obj instanceof WirelessTerminalGuiObject wtgo) {
|
||||
if (!wtgo.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
this.getPlayerInv().player.addChatMessage(PlayerMessages.OutOfRange.toChat());
|
||||
}
|
||||
|
||||
this.setValidContainer(false);
|
||||
} else {
|
||||
this.setPowerMultiplier(AEConfig.instance.wireless_getDrainRate(wtgo.getRange()));
|
||||
}
|
||||
}
|
||||
|
||||
if (obj instanceof IPortableCell ipc) {
|
||||
final int slotIndex = ipc.getInventorySlot();
|
||||
final ItemStack currentItem = getItemFromPlayerInventoryBySlotIndex(
|
||||
this.getInventoryPlayer().player,
|
||||
slotIndex);
|
||||
final ItemStack is = ipc.getItemStack();
|
||||
if (currentItem != is) {
|
||||
if (currentItem != null) {
|
||||
if (Platform.isSameItem(is, currentItem)) {
|
||||
setPlayerInventorySlotByIndex(this.getInventoryPlayer().player, slotIndex, is);
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj instanceof IEnergySource ies) {
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
ies.extractAEPower(this.getPowerMultiplier() * this.ticks, Actionable.MODULATE, PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// need for universal terminal, because getMode(ItemStack terminal) always have outdated mode
|
||||
private int switchAbleGuiItemNext = Integer.MIN_VALUE;
|
||||
|
||||
public int getSwitchAbleGuiNext() {
|
||||
return this.switchAbleGuiItemNext;
|
||||
}
|
||||
|
||||
public void setSwitchAbleGuiNext(int n) {
|
||||
this.switchAbleGuiItemNext = n;
|
||||
}
|
||||
|
||||
protected void updateVirtualSlots(StorageName invName, IAEStackInventory inventory,
|
||||
IAEStack<?>[] clientSlotsStacks) {
|
||||
var list = new Int2ObjectOpenHashMap<IAEStack<?>>();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
IAEStack<?> aes = inventory.getAEStackInSlot(i);
|
||||
IAEStack<?> aesClient = clientSlotsStacks[i];
|
||||
|
||||
if (!isStacksIdentical(aes, aesClient)) {
|
||||
list.put(i, aes);
|
||||
clientSlotsStacks[i] = aes != null ? aes.copy() : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
for (ICrafting crafter : this.crafters) {
|
||||
final EntityPlayerMP emp = (EntityPlayerMP) crafter;
|
||||
NetworkHandler.instance.sendTo(new PacketVirtualSlot(invName, list), emp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.container;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerSubGui extends AEBaseContainer implements IContainerSubGui {
|
||||
|
||||
private final Slot primaryGuiButtonIcon;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IGuiSub guiLink;
|
||||
|
||||
public ContainerSubGui(InventoryPlayer ip, Object anchor) {
|
||||
super(ip, anchor);
|
||||
this.primaryGuiButtonIcon = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 0, -9000);
|
||||
this.addSlotToContainer(this.primaryGuiButtonIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryGui(PrimaryGui primaryGui) {
|
||||
super.setPrimaryGui(primaryGui);
|
||||
this.primaryGuiButtonIcon.putStack(primaryGui.getIcon());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return this.primaryGuiButtonIcon.getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(Slot s) {
|
||||
if (Platform.isClient() && this.primaryGuiButtonIcon == s && this.primaryGuiButtonIcon.getHasStack()) {
|
||||
this.guiLink.initPrimaryGuiButton();
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setGuiLink(IGuiSub gs) {
|
||||
this.guiLink = gs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PrimaryGui {
|
||||
|
||||
final protected Object gui;
|
||||
final protected ItemStack guiIcon;
|
||||
final protected TileEntity te;
|
||||
final protected ForgeDirection side;
|
||||
protected int slotIndex = Integer.MIN_VALUE;
|
||||
|
||||
public PrimaryGui(Object gui, ItemStack guiIcon, TileEntity te, ForgeDirection side) {
|
||||
this.gui = gui;
|
||||
this.guiIcon = guiIcon;
|
||||
this.te = te;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public void open(EntityPlayer p) {
|
||||
if (gui instanceof GuiBridge gb) {
|
||||
Platform.openGUI(p, te, side, gb, slotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getIcon() {
|
||||
return guiIcon;
|
||||
}
|
||||
|
||||
public void setSlotIndex(int slotIndex) {
|
||||
this.slotIndex = slotIndex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.util.Platform.isServer;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.parts.automation.PartSharedItemBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerBusIO extends ContainerUpgradeable implements IVirtualSlotHolder {
|
||||
|
||||
public final IAEStack<?>[] virtualSlotsClient = new IAEStack<?>[9];
|
||||
private final PartSharedItemBus<?> bus;
|
||||
|
||||
public ContainerBusIO(final InventoryPlayer ip, final PartSharedItemBus<?> te) {
|
||||
super(ip, te);
|
||||
this.bus = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
this.updateVirtualSlots(StorageName.NONE, this.bus.getAEInventoryByName(StorageName.NONE), virtualSlotsClient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
final IAEStackInventory storage = this.bus.getAEInventoryByName(StorageName.NONE);
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
storage.putAEStackInSlot(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, storage, virtualSlotsClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.helpers.ICellRestriction;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerCellRestriction extends AEBaseContainer {
|
||||
public class ContainerCellRestriction extends ContainerSubGui {
|
||||
|
||||
public static class CellData {
|
||||
|
||||
@@ -78,7 +76,7 @@ public class ContainerCellRestriction extends AEBaseContainer {
|
||||
public String cellRestriction;
|
||||
|
||||
public ContainerCellRestriction(final InventoryPlayer ip, final ICellRestriction te) {
|
||||
super(ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null));
|
||||
super(ip, te);
|
||||
this.Host = te;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.util.Platform.isServer;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -23,25 +25,28 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.implementations.tiles.ICellWorkbench;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.container.slot.OptionalSlotRestrictedInput;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.ICellRestriction;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.tile.inventory.AppEngNullInventory;
|
||||
import appeng.tile.misc.TileCellWorkbench;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.util.IterationCounter;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
public class ContainerCellWorkbench extends ContainerUpgradeable implements IVirtualSlotHolder {
|
||||
|
||||
private final TileCellWorkbench workBench;
|
||||
private final ICellWorkbench workBench;
|
||||
private final AppEngNullInventory nullInventory = new AppEngNullInventory();
|
||||
|
||||
@GuiSync(2)
|
||||
@@ -50,7 +55,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
private ItemStack prevStack = null;
|
||||
private int lastUpgrades = 0;
|
||||
|
||||
public ContainerCellWorkbench(final InventoryPlayer ip, final TileCellWorkbench te) {
|
||||
private final IAEStack<?>[] configClientSlot = new IAEStack[63];
|
||||
|
||||
public ContainerCellWorkbench(final InventoryPlayer ip, final ICellWorkbench te) {
|
||||
super(ip, te);
|
||||
this.workBench = te;
|
||||
}
|
||||
@@ -88,19 +95,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
8,
|
||||
this.getInventoryPlayer()));
|
||||
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final IInventory upgradeInventory = new Upgrades();
|
||||
// null, 3 * 8 );
|
||||
|
||||
int offset = 0;
|
||||
final int x = 8;
|
||||
final int y = 29;
|
||||
for (int w = 0; w < 7; w++) {
|
||||
for (int z = 0; z < 9; z++) {
|
||||
this.addSlotToContainer(new SlotFakeTypeOnly(inv, offset, x + z * 18, y + w * 18));
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int zz = 0; zz < 3; zz++) {
|
||||
for (int z = 0; z < 8; z++) {
|
||||
@@ -117,13 +112,6 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
this.getInventoryPlayer()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new
|
||||
* OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) ); for (int w = 0; w < 2; w++) for (int z = 0;
|
||||
* z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w + 2, 2 ) ); for
|
||||
* (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new OptionalSlotFakeTypeOnly( inv,
|
||||
* this, offset++, x, y, z, w + 4, 3 ) ); }
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,9 +128,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack is = this.workBench.getInventoryByName("cell").getStackInSlot(0);
|
||||
if (Platform.isServer()) {
|
||||
if (this.workBench.getWorldObj()
|
||||
.getTileEntity(this.workBench.xCoord, this.workBench.yCoord, this.workBench.zCoord)
|
||||
!= this.workBench) {
|
||||
if (!this.workBench.isSame(this.workBench)) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
@@ -162,6 +148,11 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
|
||||
this.setCopyMode(this.getWorkBenchCopyMode());
|
||||
this.setFuzzyMode(this.getWorkBenchFuzzyMode());
|
||||
|
||||
this.updateVirtualSlots(
|
||||
StorageName.NONE,
|
||||
this.workBench.getAEInventoryByName(StorageName.NONE),
|
||||
this.configClientSlot);
|
||||
}
|
||||
|
||||
this.prevStack = is;
|
||||
@@ -197,9 +188,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final IAEStackInventory inv = this.workBench.getAEInventoryByName(StorageName.NONE);
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++) {
|
||||
inv.setInventorySlotContents(x, null);
|
||||
inv.putAEStackInSlot(x, null);
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
@@ -213,28 +204,27 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
}
|
||||
|
||||
public void partition() {
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
|
||||
final IAEStackInventory inv = this.workBench.getAEInventoryByName(StorageName.NONE);
|
||||
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0);
|
||||
|
||||
final IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory(
|
||||
this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0),
|
||||
null,
|
||||
StorageChannel.ITEMS);
|
||||
if (!(is != null && is.getItem() instanceof ICellWorkbenchItem wi)) return;
|
||||
|
||||
Iterator<IAEItemStack> i = new NullIterator<>();
|
||||
if (cellInv != null) {
|
||||
final IItemList<IAEItemStack> list = cellInv.getAvailableItems(
|
||||
AEApi.instance().storage().createSortedItemList(),
|
||||
IterationCounter.fetchNewId());
|
||||
i = list.iterator();
|
||||
}
|
||||
final IMEInventory<?> cellInv = AEApi.instance().registries().cell()
|
||||
.getCellInventory(is, null, wi.getStorageChannel());
|
||||
|
||||
if (!(cellInv instanceof CellInventory ci)) return;
|
||||
|
||||
final IItemList<?> list = ci
|
||||
.getAvailableItems(ci.getChannel().createPrimitiveList(), IterationCounter.fetchNewId());
|
||||
Iterator<?> i = list.iterator();
|
||||
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++) {
|
||||
if (i.hasNext()) {
|
||||
final ItemStack g = i.next().getItemStack();
|
||||
g.stackSize = 1;
|
||||
inv.setInventorySlotContents(x, g);
|
||||
final IAEStack<?> g = (IAEStack<?>) i.next();
|
||||
g.setStackSize(1);
|
||||
inv.putAEStackInSlot(x, g);
|
||||
} else {
|
||||
inv.setInventorySlotContents(x, null);
|
||||
inv.putAEStackInSlot(x, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +239,26 @@ public class ContainerCellWorkbench extends ContainerUpgradeable {
|
||||
this.copyMode = copyMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
final IAEStackInventory config = this.workBench.getAEInventoryByName(StorageName.NONE);
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
config.putAEStackInSlot(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.NONE, config, this.configClientSlot);
|
||||
}
|
||||
}
|
||||
|
||||
public StorageChannel getStorageChannel() {
|
||||
return this.workBench.getStorageChannel();
|
||||
}
|
||||
|
||||
public IAEStackInventory getConfig() {
|
||||
return this.workBench.getAEInventoryByName(StorageName.NONE);
|
||||
}
|
||||
|
||||
public class Upgrades implements IInventory {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ public class ContainerChest extends AEBaseContainer {
|
||||
private final TileChest chest;
|
||||
|
||||
public ContainerChest(final InventoryPlayer ip, final TileChest chest) {
|
||||
super(ip, chest, null);
|
||||
super(ip, chest);
|
||||
this.chest = chest;
|
||||
|
||||
this.addSlotToContainer(
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
|
||||
public CondenserOutput output = CondenserOutput.TRASH;
|
||||
|
||||
public ContainerCondenser(final InventoryPlayer ip, final TileCondenser condenser) {
|
||||
super(ip, condenser, null);
|
||||
super(ip, condenser);
|
||||
this.condenser = condenser;
|
||||
|
||||
this.addSlotToContainer(
|
||||
|
||||
@@ -13,8 +13,10 @@ package appeng.container.implementations;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -24,18 +26,19 @@ import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketVirtualSlot;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerCraftAmount extends AEBaseContainer {
|
||||
public class ContainerCraftAmount extends ContainerSubGui {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private MEGuiTextField amountField;
|
||||
@@ -43,14 +46,10 @@ public class ContainerCraftAmount extends AEBaseContainer {
|
||||
@GuiSync(1)
|
||||
public long initialCraftAmount = -1;
|
||||
|
||||
private final Slot craftingItem;
|
||||
private IAEItemStack itemToCreate;
|
||||
private IAEStack<?> itemToCreate;
|
||||
|
||||
public ContainerCraftAmount(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
|
||||
this.craftingItem = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
|
||||
this.addSlotToContainer(this.getCraftingItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,16 +71,24 @@ public class ContainerCraftAmount extends AEBaseContainer {
|
||||
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
|
||||
}
|
||||
|
||||
// addon
|
||||
public Slot getCraftingItem() {
|
||||
return this.craftingItem;
|
||||
return new Slot(null, 0, 0, 0) {
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack p_75215_1_) {}
|
||||
};
|
||||
}
|
||||
|
||||
public IAEItemStack getItemToCraft() {
|
||||
public IAEStack<?> getItemToCraft() {
|
||||
return this.itemToCreate;
|
||||
}
|
||||
|
||||
public void setItemToCraft(@Nonnull final IAEItemStack itemToCreate) {
|
||||
public void setItemToCraft(@Nonnull final IAEStack<?> itemToCreate) {
|
||||
this.itemToCreate = itemToCreate;
|
||||
|
||||
final PacketVirtualSlot p = new PacketVirtualSlot(StorageName.NONE, 0, itemToCreate);
|
||||
NetworkHandler.instance.sendTo(p, (EntityPlayerMP) this.getInventoryPlayer().player);
|
||||
}
|
||||
|
||||
public void setInitialCraftAmount(long initialCraftAmount) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -38,10 +37,10 @@ import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.interfaces.ICraftingCPUSelectorContainer;
|
||||
import appeng.core.AELog;
|
||||
@@ -49,20 +48,14 @@ import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftingTreeData;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.crafting.MECraftingInventory;
|
||||
import appeng.crafting.v2.CraftingJobV2;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.misc.TilePatternOptimizationMatrix;
|
||||
import appeng.util.Platform;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingCPUSelectorContainer {
|
||||
public class ContainerCraftConfirm extends ContainerSubGui implements ICraftingCPUSelectorContainer {
|
||||
|
||||
private Future<ICraftingJob> job;
|
||||
protected ICraftingJob result;
|
||||
@@ -263,15 +256,9 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingC
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
public IAEItemStack getItemToCraft() {
|
||||
try {
|
||||
ByteBuf deserialized = Unpooled.wrappedBuffer(serializedItemToCraft.getBytes(StandardCharsets.ISO_8859_1));
|
||||
return AEApi.instance().storage().readItemFromPacket(deserialized);
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
AELog.debug("Deserializing IAEItemStack Failed");
|
||||
return null;
|
||||
}
|
||||
public IAEStack<?> getItemToCraft() {
|
||||
ByteBuf deserialized = Unpooled.wrappedBuffer(serializedItemToCraft.getBytes(StandardCharsets.ISO_8859_1));
|
||||
return Platform.readStackByte(deserialized);
|
||||
}
|
||||
|
||||
public boolean cpuCraftingSameItem(final CraftingCPUStatus c) {
|
||||
@@ -330,36 +317,8 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingC
|
||||
}
|
||||
|
||||
public void switchToOriginalGUI() {
|
||||
GuiBridge originalGui = null;
|
||||
|
||||
final IActionHost ah = this.getActionHost();
|
||||
if (ah instanceof WirelessTerminalGuiObject) {
|
||||
originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (ah instanceof PartTerminal) {
|
||||
originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (ah instanceof PartCraftingTerminal) {
|
||||
originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (ah instanceof PartPatternTerminal) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (ah instanceof PartPatternTerminalEx) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
if (originalGui != null && this.getOpenContext() != null) {
|
||||
NetworkHandler.instance
|
||||
.sendTo(new PacketSwitchGuis(originalGui), (EntityPlayerMP) this.getInventoryPlayer().player);
|
||||
|
||||
final TileEntity te = this.getOpenContext().getTile();
|
||||
Platform.openGUI(this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui);
|
||||
}
|
||||
if (this.getInventoryPlayer().player.openContainer instanceof AEBaseContainer bc)
|
||||
bc.getPrimaryGui().open(this.getInventoryPlayer().player);
|
||||
}
|
||||
|
||||
private BaseActionSource getActionSrc() {
|
||||
@@ -464,14 +423,9 @@ public class ContainerCraftConfirm extends AEBaseContainer implements ICraftingC
|
||||
this.job = job;
|
||||
}
|
||||
|
||||
public void setItemToCraft(@Nonnull final IAEItemStack itemToCraft) {
|
||||
try {
|
||||
ByteBuf serialized = Unpooled.buffer();
|
||||
itemToCraft.writeToPacket(serialized);
|
||||
this.serializedItemToCraft = serialized.toString(StandardCharsets.ISO_8859_1);
|
||||
} catch (IOException e) {
|
||||
AELog.debug(e);
|
||||
AELog.debug("Deserializing IAEItemStack Failed");
|
||||
}
|
||||
public void setItemToCraft(@Nonnull final IAEStack<?> itemToCraft) {
|
||||
ByteBuf serialized = Unpooled.buffer();
|
||||
Platform.writeStackByte(itemToCraft, serialized);
|
||||
this.serializedItemToCraft = serialized.toString(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,23 @@ package appeng.container.implementations;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.container.interfaces.ICraftingCPUSelectorContainer;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU implements ICraftingCPUSelectorContainer {
|
||||
public class ContainerCraftingStatus extends ContainerCraftingCPU
|
||||
implements ICraftingCPUSelectorContainer, IContainerSubGui {
|
||||
|
||||
@GuiSync.Recurse(5)
|
||||
public ContainerCPUTable cpuTable;
|
||||
@@ -26,6 +37,10 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU implements ICr
|
||||
public ContainerCraftingStatus(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
cpuTable = new ContainerCPUTable(this, this::setCPU, true, c -> true);
|
||||
|
||||
// sub gui copy paste
|
||||
this.primaryGuiButtonIcon = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 0, -9000);
|
||||
this.addSlotToContainer(this.primaryGuiButtonIcon);
|
||||
}
|
||||
|
||||
public ContainerCPUTable getCPUTable() {
|
||||
@@ -46,4 +61,33 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU implements ICr
|
||||
public List<CraftingCPUStatus> getCPUs() {
|
||||
return cpuTable.getCPUs();
|
||||
}
|
||||
|
||||
// sub gui copy paste
|
||||
private final Slot primaryGuiButtonIcon;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IGuiSub guiLink;
|
||||
|
||||
@Override
|
||||
public void onSlotChange(Slot s) {
|
||||
if (Platform.isClient() && this.primaryGuiButtonIcon == s && this.primaryGuiButtonIcon.getHasStack()) {
|
||||
this.guiLink.initPrimaryGuiButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryGui(PrimaryGui primaryGui) {
|
||||
super.setPrimaryGui(primaryGui);
|
||||
this.primaryGuiButtonIcon.putStack(primaryGui.getIcon());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return this.primaryGuiButtonIcon.getStack();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setGuiLink(IGuiSub gs) {
|
||||
this.guiLink = gs;
|
||||
}
|
||||
}
|
||||
@@ -16,12 +16,12 @@ import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
|
||||
import appeng.api.parts.ICraftingTerminal;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
@@ -29,14 +29,14 @@ import appeng.tile.inventory.InvOperation;
|
||||
public class ContainerCraftingTerm extends ContainerMEMonitorable
|
||||
implements IAEAppEngInventory, IContainerCraftingPacket {
|
||||
|
||||
private final PartCraftingTerminal ct;
|
||||
private final ICraftingTerminal ct;
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
|
||||
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
|
||||
private final SlotCraftingTerm outputSlot;
|
||||
|
||||
public ContainerCraftingTerm(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
this.ct = (PartCraftingTerminal) monitorable;
|
||||
this.ct = (ICraftingTerminal) monitorable;
|
||||
|
||||
final IInventory crafting = this.ct.getInventoryByName("crafting");
|
||||
|
||||
@@ -65,9 +65,11 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable
|
||||
-72 + 18,
|
||||
this));
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
|
||||
this.onCraftMatrixChanged(crafting);
|
||||
|
||||
// need because InventoryBogoSorter looking for specific slot number for bind buttons
|
||||
// bindPlayerInventory in MEMonitorable break it
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ import appeng.tile.storage.TileDrive;
|
||||
public class ContainerDrive extends AEBaseContainer {
|
||||
|
||||
public ContainerDrive(final InventoryPlayer ip, final TileDrive drive) {
|
||||
super(ip, drive, null);
|
||||
super(ip, drive);
|
||||
|
||||
for (int y = 0; y < 5; y++) {
|
||||
for (int x = 0; x < 2; x++) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import appeng.tile.grindstone.TileGrinder;
|
||||
public class ContainerGrinder extends AEBaseContainer {
|
||||
|
||||
public ContainerGrinder(final InventoryPlayer ip, final TileGrinder grinder) {
|
||||
super(ip, grinder, null);
|
||||
super(ip, grinder);
|
||||
|
||||
this.addSlotToContainer(
|
||||
new SlotRestrictedInput(
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.google.common.primitives.Ints;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.parts.IInterfaceTerminal;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IInterfaceViewable;
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -44,7 +44,6 @@ import appeng.helpers.InventoryAction;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.parts.AEBasePart;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.parts.reporting.PartInterfaceTerminal;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
@@ -59,10 +58,10 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
private PacketInterfaceTerminalUpdate dirty;
|
||||
private boolean isDirty;
|
||||
private IGrid grid;
|
||||
private IActionHost anchor;
|
||||
private final IInterfaceTerminal anchor;
|
||||
private boolean wasOff;
|
||||
|
||||
public ContainerInterfaceTerminal(final InventoryPlayer ip, final IActionHost anchor) {
|
||||
public ContainerInterfaceTerminal(final InventoryPlayer ip, final IInterfaceTerminal anchor) {
|
||||
super(ip, anchor);
|
||||
assert anchor != null;
|
||||
this.anchor = anchor;
|
||||
@@ -110,7 +109,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer {
|
||||
}
|
||||
this.wasOff = false;
|
||||
|
||||
if (anchor instanceof PartInterfaceTerminal terminal && terminal.needsUpdate()) {
|
||||
if (anchor.needsUpdate()) {
|
||||
PacketInterfaceTerminalUpdate update = this.updateList();
|
||||
if (update != null) {
|
||||
update.encode();
|
||||
|
||||
@@ -10,9 +10,13 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.util.Platform.isServer;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
@@ -20,18 +24,26 @@ import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.parts.ILevelEmitter;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.client.gui.IGuiSub;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.PrimaryGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotFakeTypeOnly;
|
||||
import appeng.container.interfaces.IContainerSubGui;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
public class ContainerLevelEmitter extends ContainerUpgradeable implements IVirtualSlotHolder, IContainerSubGui {
|
||||
|
||||
private final PartLevelEmitter lvlEmitter;
|
||||
private final ILevelEmitter lvlEmitter;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private MEGuiTextField textField;
|
||||
@@ -45,9 +57,15 @@ public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
@GuiSync(4)
|
||||
public YesNo cmType;
|
||||
|
||||
public ContainerLevelEmitter(final InventoryPlayer ip, final PartLevelEmitter te) {
|
||||
private final IAEStack<?>[] configClientSlot = new IAEStack[1];
|
||||
|
||||
public ContainerLevelEmitter(final InventoryPlayer ip, final ILevelEmitter te) {
|
||||
super(ip, te);
|
||||
this.lvlEmitter = te;
|
||||
|
||||
// sub gui copy paste
|
||||
this.primaryGuiButtonIcon = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 0, -9000);
|
||||
this.addSlotToContainer(this.primaryGuiButtonIcon);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -103,9 +121,6 @@ public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
8 + 18 * 3,
|
||||
this.getInventoryPlayer())).setNotDraggable());
|
||||
}
|
||||
|
||||
final IInventory inv = this.getUpgradeable().getInventoryByName("config");
|
||||
this.addSlotToContainer(new SlotFakeTypeOnly(inv, 0, 17, 42));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,6 +146,10 @@ public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
this.setFuzzyMode((FuzzyMode) this.getUpgradeable().getConfigManager().getSetting(Settings.FUZZY_MODE));
|
||||
this.setRedStoneMode(
|
||||
(RedstoneMode) this.getUpgradeable().getConfigManager().getSetting(Settings.REDSTONE_EMITTER));
|
||||
this.updateVirtualSlots(
|
||||
StorageName.NONE,
|
||||
this.lvlEmitter.getAEInventoryByName(StorageName.NONE),
|
||||
this.configClientSlot);
|
||||
}
|
||||
|
||||
this.standardDetectAndSendChanges();
|
||||
@@ -166,4 +185,53 @@ public class ContainerLevelEmitter extends ContainerUpgradeable {
|
||||
private void setLevelMode(final LevelType lvType) {
|
||||
this.lvType = lvType;
|
||||
}
|
||||
|
||||
public ILevelEmitter getLvlEmitter() {
|
||||
return this.lvlEmitter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
this.lvlEmitter.getAEInventoryByName(StorageName.NONE)
|
||||
.putAEStackInSlot(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(
|
||||
StorageName.NONE,
|
||||
this.lvlEmitter.getAEInventoryByName(StorageName.NONE),
|
||||
this.configClientSlot);
|
||||
}
|
||||
}
|
||||
|
||||
// for level terminal
|
||||
// sub gui copypaste
|
||||
private final Slot primaryGuiButtonIcon;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IGuiSub guiLink;
|
||||
|
||||
@Override
|
||||
public void onSlotChange(Slot s) {
|
||||
if (Platform.isClient() && this.primaryGuiButtonIcon == s && this.primaryGuiButtonIcon.getHasStack()) {
|
||||
this.guiLink.initPrimaryGuiButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryGui(PrimaryGui primaryGui) {
|
||||
super.setPrimaryGui(primaryGui);
|
||||
this.primaryGuiButtonIcon.putStack(primaryGui.getIcon());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return this.primaryGuiButtonIcon.getStack();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setGuiLink(IGuiSub gs) {
|
||||
this.guiLink = gs;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,15 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.util.FluidUtils.clearFluidContainer;
|
||||
import static appeng.util.FluidUtils.fillFluidContainer;
|
||||
import static appeng.util.FluidUtils.getFilledFluidContainer;
|
||||
import static appeng.util.FluidUtils.getFluidContainerCapacity;
|
||||
import static appeng.util.FluidUtils.getFluidFromContainer;
|
||||
import static appeng.util.FluidUtils.isFilledFluidContainer;
|
||||
import static appeng.util.FluidUtils.isFluidContainer;
|
||||
import static appeng.util.IterationCounter.fetchNewId;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.ArrayList;
|
||||
@@ -23,8 +32,10 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -40,7 +51,6 @@ import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TypeFilter;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
@@ -50,43 +60,52 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.ITerminalPins;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotDisabled;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlacableItemType;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPinsHandler;
|
||||
import appeng.helpers.MonitorableAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.items.contents.PinsHandler;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer
|
||||
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>, IPinsHandler {
|
||||
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEStack<?>>, IPinsHandler {
|
||||
|
||||
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
private final IMEMonitor<IAEItemStack> monitor;
|
||||
private final IMEMonitor<IAEItemStack> monitorItems;
|
||||
private final IMEMonitor<IAEFluidStack> monitorFluids;
|
||||
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
|
||||
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
private final IConfigManager clientCM;
|
||||
private final ITerminalHost host;
|
||||
|
||||
@@ -109,10 +128,7 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
|
||||
protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable,
|
||||
final boolean bindInventory) {
|
||||
super(
|
||||
ip,
|
||||
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
|
||||
monitorable instanceof IPart ? (IPart) monitorable : null);
|
||||
super(ip, monitorable);
|
||||
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager(this);
|
||||
@@ -124,46 +140,54 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
this.clientCM.registerSetting(Settings.PINS_STATE, PinsState.DISABLED); // use for GUI
|
||||
|
||||
if (Platform.isServer()) {
|
||||
|
||||
if (monitorable instanceof ITerminalPins t) {
|
||||
pinsHandler = t.getPinsHandler(ip.player);
|
||||
this.pinsHandler = t.getPinsHandler(ip.player);
|
||||
}
|
||||
|
||||
this.serverCM = monitorable.getConfigManager();
|
||||
|
||||
this.monitor = monitorable.getItemInventory();
|
||||
if (this.monitor != null) {
|
||||
this.monitor.addListener(this, null);
|
||||
this.monitorItems = monitorable.getItemInventory();
|
||||
if (monitorItems != null) {
|
||||
this.monitorItems.addListener(this, null);
|
||||
this.setCellInventory(this.monitorItems);
|
||||
}
|
||||
|
||||
this.setCellInventory(this.monitor);
|
||||
this.monitorFluids = monitorable.getFluidInventory();
|
||||
if (monitorFluids != null) {
|
||||
this.monitorFluids.addListener(this, null);
|
||||
this.setCellFluidInventory(this.monitorFluids);
|
||||
}
|
||||
|
||||
if (monitorable instanceof IPortableCell) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IMEChest) {
|
||||
this.setPowerSource((IEnergySource) monitorable);
|
||||
} else if (monitorable instanceof IGridHost) {
|
||||
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
|
||||
if (node != null) {
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if (g != null) {
|
||||
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.monitorItems == null && this.monitorFluids == null) {
|
||||
this.setValidContainer(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (monitorable instanceof IGridHost igh) {
|
||||
this.networkNode = igh.getGridNode(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
|
||||
if (monitorable instanceof IPortableCell pc) {
|
||||
this.setPowerSource(pc);
|
||||
} else if (monitorable instanceof IMEChest imc) {
|
||||
this.setPowerSource(imc);
|
||||
} else if (this.networkNode != null) {
|
||||
final IGrid g = this.networkNode.getGrid();
|
||||
if (g != null) {
|
||||
this.setPowerSource(new ChannelPowerSrc(this.networkNode, g.getCache(IEnergyGrid.class)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.monitor = null;
|
||||
this.monitorItems = null;
|
||||
this.monitorFluids = null;
|
||||
}
|
||||
|
||||
this.canAccessViewCells = false;
|
||||
if (monitorable instanceof IViewCellStorage) {
|
||||
if (monitorable instanceof IViewCellStorage vcs) {
|
||||
for (int y = 0; y < 5; y++) {
|
||||
this.cellView[y] = new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
|
||||
((IViewCellStorage) monitorable).getViewCellStorage(),
|
||||
vcs.getViewCellStorage(),
|
||||
y,
|
||||
206,
|
||||
y * 18 + 8,
|
||||
@@ -172,16 +196,6 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
this.addSlotToContainer(this.cellView[y]);
|
||||
}
|
||||
}
|
||||
if (isAPatternTerminal()) {
|
||||
patternRefiller = new SlotRestrictedInput(
|
||||
PlacableItemType.UPGRADES,
|
||||
((IUpgradeableHost) monitorable).getInventoryByName("upgrades"),
|
||||
0,
|
||||
206,
|
||||
5 * 18 + 11,
|
||||
this.getInventoryPlayer());
|
||||
addSlotToContainer(patternRefiller);
|
||||
}
|
||||
|
||||
if (bindInventory) {
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
@@ -195,7 +209,8 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
if (Platform.isServer()) {
|
||||
if (this.monitor != this.host.getItemInventory()) {
|
||||
if (this.monitorItems != this.host.getItemInventory()
|
||||
|| this.monitorFluids != this.host.getFluidInventory()) {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
@@ -226,35 +241,24 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.items.isEmpty()) {
|
||||
try {
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
try {
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
|
||||
final PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
if (this.monitorItems != null) updateList(piu, this.monitorItems.getStorageList(), this.items);
|
||||
|
||||
for (final IAEItemStack is : this.items) {
|
||||
final IAEItemStack send = monitorCache.findPrecise(is);
|
||||
if (send == null) {
|
||||
is.setStackSize(0);
|
||||
piu.appendItem(is);
|
||||
} else {
|
||||
piu.appendItem(send);
|
||||
if (this.monitorFluids != null) updateList(piu, this.monitorFluids.getStorageList(), this.fluids);
|
||||
|
||||
if (!piu.isEmpty()) {
|
||||
this.items.resetStatus();
|
||||
this.fluids.resetStatus();
|
||||
|
||||
for (final Object c : this.crafters) {
|
||||
if (c instanceof EntityPlayer) {
|
||||
NetworkHandler.instance.sendTo(piu, (EntityPlayerMP) c);
|
||||
}
|
||||
}
|
||||
|
||||
if (!piu.isEmpty()) {
|
||||
this.items.resetStatus();
|
||||
|
||||
for (final Object c : this.crafters) {
|
||||
if (c instanceof EntityPlayer) {
|
||||
NetworkHandler.instance.sendTo(piu, (EntityPlayerMP) c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
this.updatePowerStatus();
|
||||
|
||||
@@ -273,6 +277,24 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
}
|
||||
|
||||
private void updateList(PacketMEInventoryUpdate piu, IItemList monitorCache, IItemList<?> list) {
|
||||
if (!list.isEmpty()) {
|
||||
try {
|
||||
for (final IAEStack<?> aes : list) {
|
||||
final IAEStack<?> send = monitorCache.findPrecise(aes);
|
||||
if (send == null) {
|
||||
aes.setStackSize(0);
|
||||
piu.appendItem(aes);
|
||||
} else {
|
||||
piu.appendItem(send);
|
||||
}
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updatePowerStatus() {
|
||||
try {
|
||||
if (this.networkNode != null) {
|
||||
@@ -308,43 +330,56 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
|
||||
private void queueInventory(final ICrafting c) {
|
||||
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
|
||||
if (Platform.isServer() && c instanceof EntityPlayerMP pmp) {
|
||||
try {
|
||||
PacketMEInventoryUpdate piu = new PacketMEInventoryUpdate();
|
||||
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
|
||||
|
||||
for (final IAEItemStack send : monitorCache) {
|
||||
try {
|
||||
piu.appendItem(send);
|
||||
} catch (final BufferOverflowException boe) {
|
||||
NetworkHandler.instance.sendTo(piu, (EntityPlayerMP) c);
|
||||
if (this.monitorItems != null) queueInventoryList(piu, this.monitorItems.getStorageList(), pmp);
|
||||
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
piu.appendItem(send);
|
||||
}
|
||||
}
|
||||
if (this.monitorFluids != null) queueInventoryList(piu, this.monitorFluids.getStorageList(), pmp);
|
||||
|
||||
NetworkHandler.instance.sendTo(piu, (EntityPlayerMP) c);
|
||||
NetworkHandler.instance.sendTo(piu, pmp);
|
||||
} catch (final IOException e) {
|
||||
AELog.debug(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void queueInventoryList(PacketMEInventoryUpdate piu, IItemList monitorCache, EntityPlayerMP c) {
|
||||
try {
|
||||
for (final IAEStack<?> send : (IItemList<?>) monitorCache) {
|
||||
try {
|
||||
piu.appendItem(send);
|
||||
} catch (final BufferOverflowException boe) {
|
||||
NetworkHandler.instance.sendTo(piu, c);
|
||||
|
||||
piu = new PacketMEInventoryUpdate();
|
||||
piu.appendItem(send);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCraftingFromCrafters(final ICrafting c) {
|
||||
super.removeCraftingFromCrafters(c);
|
||||
|
||||
if (this.crafters.isEmpty() && this.monitor != null) {
|
||||
this.monitor.removeListener(this);
|
||||
if (this.crafters.isEmpty() && this.monitorItems != null) {
|
||||
this.monitorItems.removeListener(this);
|
||||
}
|
||||
if (this.crafters.isEmpty() && this.monitorFluids != null) {
|
||||
this.monitorFluids.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(final EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
if (this.monitor != null) {
|
||||
this.monitor.removeListener(this);
|
||||
if (this.monitorItems != null) {
|
||||
this.monitorItems.removeListener(this);
|
||||
}
|
||||
if (this.monitorFluids != null) {
|
||||
this.monitorFluids.removeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,10 +389,14 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change,
|
||||
final BaseActionSource source) {
|
||||
for (final IAEItemStack is : change) {
|
||||
this.items.add(is);
|
||||
public void postChange(IBaseMonitor<IAEStack<?>> monitor, Iterable<IAEStack<?>> change,
|
||||
BaseActionSource actionSource) {
|
||||
for (final IAEStack<?> aes : change) {
|
||||
if (aes instanceof IAEItemStack ais) {
|
||||
this.items.add(ais);
|
||||
} else if (aes instanceof IAEFluidStack afs) {
|
||||
this.fluids.add(afs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,28 +474,11 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
|
||||
public IMEMonitor<IAEItemStack> getMonitor() {
|
||||
return monitor;
|
||||
return monitorItems;
|
||||
}
|
||||
|
||||
// to avoid duplicating this method in 2 pattern terminals
|
||||
protected void refillBlankPatterns(Slot slot) {
|
||||
if (Platform.isServer()) {
|
||||
ItemStack blanks = slot.getStack();
|
||||
int blanksToRefill = 64;
|
||||
if (blanks != null) blanksToRefill -= blanks.stackSize;
|
||||
if (blanksToRefill <= 0) return;
|
||||
final AEItemStack request = AEItemStack
|
||||
.create(AEApi.instance().definitions().materials().blankPattern().maybeStack(blanksToRefill).get());
|
||||
final IAEItemStack extracted = Platform
|
||||
.poweredExtraction(this.getPowerSource(), this.getCellInventory(), request, this.getActionSource());
|
||||
if (extracted != null) {
|
||||
if (blanks != null) blanks.stackSize += extracted.getStackSize();
|
||||
else {
|
||||
blanks = extracted.getItemStack();
|
||||
}
|
||||
slot.putStack(blanks);
|
||||
}
|
||||
}
|
||||
public IMEMonitor<IAEFluidStack> getFluidMonitor() {
|
||||
return monitorFluids;
|
||||
}
|
||||
|
||||
private int lastUpdate = 0;
|
||||
@@ -472,19 +494,20 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
final ICraftingGrid cc = itp.getGrid().getCache(ICraftingGrid.class);
|
||||
final ImmutableList<ICraftingCPU> cpuList = cc.getCpus().asList();
|
||||
|
||||
List<IAEItemStack> craftedItems = new ArrayList<>();
|
||||
List<IAEStack<?>> craftedItems = new ArrayList<>();
|
||||
|
||||
// fetch the first available crafting output
|
||||
for (int i = 0; i < cpuList.size(); i++) {
|
||||
ICraftingCPU cpu = cpuList.get(i);
|
||||
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && cpu.getFinalOutput() != null
|
||||
IAEStack<?> output = cpu.getFinalMultiOutput();
|
||||
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && output != null
|
||||
&& cpu.getCurrentJobSource() instanceof PlayerSource src
|
||||
&& src.player == pinsHandler.getPlayer()) {
|
||||
if (craftedItems.contains(cpu.getFinalOutput())) {
|
||||
if (craftedItems.contains(output)) {
|
||||
continue; // skip if already added
|
||||
}
|
||||
if (cpu.isBusy()) craftedItems.add(0, cpu.getFinalOutput().copy());
|
||||
else craftedItems.add(cpu.getFinalOutput().copy());
|
||||
if (cpu.isBusy()) craftedItems.add(0, output.copy());
|
||||
else craftedItems.add(output.copy());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,15 +518,16 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPin(ItemStack is, int idx) {
|
||||
public void setPin(IAEStack<?> is, int idx) {
|
||||
if (pinsHandler == null || !(host instanceof ITerminalPins itp)) return;
|
||||
|
||||
if (is == null) {
|
||||
final ICraftingGrid cc = itp.getGrid().getCache(ICraftingGrid.class);
|
||||
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
for (ICraftingCPU cpu : cpuSet) {
|
||||
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && cpu.getFinalOutput() != null
|
||||
&& cpu.getFinalOutput().isSameType(getPin(idx))) {
|
||||
IAEStack<?> output = cpu.getFinalMultiOutput();
|
||||
if (cpu.getCraftingAllowMode() != CraftingAllow.ONLY_NONPLAYER && output != null
|
||||
&& output.isSameType(getPin(idx))) {
|
||||
if (!cpu.isBusy()) {
|
||||
cpu.resetFinalOutput();
|
||||
} else {
|
||||
@@ -517,7 +541,7 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPin(int idx) {
|
||||
public IAEStack<?> getPin(int idx) {
|
||||
if (pinsHandler == null) return null;
|
||||
return pinsHandler.getPin(idx);
|
||||
}
|
||||
@@ -536,4 +560,466 @@ public class ContainerMEMonitorable extends AEBaseContainer
|
||||
public PinsHandler getPinsHandler() {
|
||||
return pinsHandler;
|
||||
}
|
||||
|
||||
public void doMonitorableAction(MonitorableAction action, int custom, final EntityPlayerMP player) {
|
||||
IAEItemStack slotItem = null;
|
||||
IAEFluidStack slotFluid = null;
|
||||
if (this.getTargetStack() instanceof IAEFluidStack afs) {
|
||||
slotFluid = this.getCellFluidInventory().getAvailableItem(afs, fetchNewId());
|
||||
} else if (this.getTargetStack() instanceof IAEItemStack ais) {
|
||||
slotItem = this.getCellInventory().getAvailableItem(ais, fetchNewId());
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case AUTO_CRAFT -> {} // handled in PacketMonitorableAction
|
||||
case SET_ITEM_PIN -> {
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (hand == null) return;
|
||||
|
||||
if (this.getPin(custom) != null && this.getPin(custom) instanceof IAEItemStack pinStack
|
||||
&& hand.isItemEqual(pinStack.getItemStack())) {
|
||||
// put item in the terminal
|
||||
doMonitorableAction(MonitorableAction.PICKUP_OR_SET_DOWN, this.inventorySlots.size(), player);
|
||||
} else {
|
||||
this.setPin(AEItemStack.create(hand), custom);
|
||||
}
|
||||
}
|
||||
case SET_CONTAINER_PIN -> {
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (!isFilledFluidContainer(hand)) return;
|
||||
FluidStack fluid = getFluidFromContainer(hand);
|
||||
if (fluid == null) return;
|
||||
|
||||
if (this.getPin(custom) != null && this.getPin(custom) instanceof IAEFluidStack pinStack
|
||||
&& fluid.isFluidEqual(pinStack.getFluidStack())) {
|
||||
// put item in the terminal
|
||||
doMonitorableAction(MonitorableAction.FILL_SINGLE_CONTAINER, this.inventorySlots.size(), player);
|
||||
} else {
|
||||
this.setPin(AEFluidStack.create(fluid), custom);
|
||||
}
|
||||
}
|
||||
case UNSET_PIN -> {
|
||||
this.setPin(null, custom);
|
||||
}
|
||||
case SHIFT_CLICK -> { // shift left click
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null || slotItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ItemStack myItem = ais.getItemStack();
|
||||
ais.setStackSize(myItem.getMaxStackSize());
|
||||
myItem.stackSize = (int) ais.getStackSize();
|
||||
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
myItem = adaptor.simulateAdd(myItem);
|
||||
|
||||
if (myItem != null) {
|
||||
ais.setStackSize(ais.getStackSize() - myItem.stackSize);
|
||||
}
|
||||
|
||||
ais = Platform
|
||||
.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais != null) {
|
||||
adaptor.addItems(ais.getItemStack());
|
||||
}
|
||||
}
|
||||
case PICKUP_SINGLE, ROLL_UP -> { // shift right click, roll up
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null || slotItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ItemStack hand = player.inventory.getItemStack();
|
||||
|
||||
if (hand != null) {
|
||||
if (hand.stackSize >= hand.getMaxStackSize()) return;
|
||||
if (!Platform.isSameItemPrecise(slotItem.getItemStack(), hand)) return;
|
||||
}
|
||||
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize(1);
|
||||
ais = Platform
|
||||
.poweredExtraction(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais != null) {
|
||||
final InventoryAdaptor ia = new AdaptorPlayerHand(player);
|
||||
|
||||
final ItemStack fail = ia.addItems(ais.getItemStack());
|
||||
if (fail != null) {
|
||||
this.getCellInventory().injectItems(ais, Actionable.MODULATE, this.getActionSource());
|
||||
}
|
||||
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case PICKUP_OR_SET_DOWN -> { // left click
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (hand == null) {
|
||||
if (slotItem == null) return;
|
||||
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize(ais.getItemStack().getMaxStackSize());
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack(hand);
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case SPLIT_OR_PLACE_SINGLE -> { // right click
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (hand == null) {
|
||||
if (slotItem == null) return;
|
||||
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
final long maxSize = ais.getItemStack().getMaxStackSize();
|
||||
ais.setStackSize(maxSize);
|
||||
ais = this.getCellInventory().extractItems(ais, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
if (ais != null) {
|
||||
final long stackSize = Math.min(maxSize, ais.getStackSize());
|
||||
ais.setStackSize((stackSize + 1) >> 1);
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
}
|
||||
|
||||
if (ais != null) {
|
||||
player.inventory.setItemStack(ais.getItemStack());
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().createItemStack(player.inventory.getItemStack());
|
||||
ais.setStackSize(1);
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais == null) {
|
||||
final ItemStack is = player.inventory.getItemStack();
|
||||
is.stackSize--;
|
||||
if (is.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
case ROLL_DOWN -> {
|
||||
final ItemStack hand = player.inventory.getItemStack();
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null || hand == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
IAEItemStack ais = AEItemStack.create(hand);
|
||||
ais.setStackSize(1);
|
||||
|
||||
ais = Platform
|
||||
.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource());
|
||||
if (ais == null) {
|
||||
hand.stackSize--;
|
||||
if (hand.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case MOVE_REGION -> {
|
||||
if (slotItem == null) return;
|
||||
|
||||
final long maxSize = slotItem.getItemStack().getMaxStackSize();
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
while (true) {
|
||||
IAEItemStack ais = slotItem.copy();
|
||||
ais.setStackSize(maxSize);
|
||||
ais = this.getCellInventory().extractItems(ais, Actionable.SIMULATE, this.getActionSource());
|
||||
|
||||
if (ais == null || ais.getStackSize() <= 0) break;
|
||||
|
||||
ItemStack myItem = ais.getItemStack();
|
||||
myItem = adaptor.simulateAdd(myItem);
|
||||
|
||||
if (myItem != null) {
|
||||
if (ais.getStackSize() == myItem.stackSize) break;
|
||||
ais.setStackSize(ais.getStackSize() - myItem.stackSize);
|
||||
}
|
||||
|
||||
ais = Platform.poweredExtraction(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
ais,
|
||||
this.getActionSource());
|
||||
if (ais == null || ais.getStackSize() <= 0) break;
|
||||
adaptor.addItems(ais.getItemStack());
|
||||
}
|
||||
}
|
||||
case CREATIVE_DUPLICATE -> {
|
||||
if (player.capabilities.isCreativeMode && slotItem != null) {
|
||||
final ItemStack is = slotItem.getItemStack();
|
||||
is.stackSize = is.getMaxStackSize();
|
||||
player.inventory.setItemStack(is);
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case DRAIN_SINGLE_CONTAINER -> {
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (!isFilledFluidContainer(hand)) return;
|
||||
|
||||
if (hand.stackSize == 1) {
|
||||
extractFromSingleFluidContainer(player, hand);
|
||||
} else {
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
if (hand.getItem() instanceof IFluidContainerItem container) {
|
||||
ItemStack itemToInject = hand.copy();
|
||||
itemToInject.stackSize = 1;
|
||||
FluidStack fluid = container.getFluid(itemToInject);
|
||||
IAEFluidStack aes = AEFluidStack.create(fluid);
|
||||
IAEFluidStack leftover = this.getCellFluidInventory()
|
||||
.injectItems(aes, Actionable.SIMULATE, this.getActionSource());
|
||||
int injected = leftover == null ? fluid.amount : (int) (fluid.amount - leftover.getStackSize());
|
||||
if (injected == 0) return;
|
||||
|
||||
container.drain(itemToInject, injected, true);
|
||||
if (adaptor.addItems(itemToInject) != null) return;
|
||||
|
||||
this.getCellFluidInventory().injectItems(aes, Actionable.MODULATE, this.getActionSource());
|
||||
hand.stackSize--;
|
||||
this.updateHeld(player);
|
||||
} else if (FluidContainerRegistry.isContainer(hand)) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(hand);
|
||||
IAEFluidStack toInject = AEFluidStack.create(fluid);
|
||||
IAEFluidStack leftover = this.getCellFluidInventory()
|
||||
.injectItems(toInject, Actionable.SIMULATE, this.getActionSource());
|
||||
if (leftover != null) return;
|
||||
ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(hand);
|
||||
if (adaptor.addItems(emptyContainer) != null) return;
|
||||
|
||||
this.getCellFluidInventory().injectItems(toInject, Actionable.MODULATE, this.getActionSource());
|
||||
hand.stackSize--;
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
case DRAIN_CONTAINERS -> {
|
||||
final ItemStack hand = player.inventory.getItemStack();
|
||||
if (!isFilledFluidContainer(hand)) return;
|
||||
|
||||
if (hand.stackSize == 1) {
|
||||
extractFromSingleFluidContainer(player, hand);
|
||||
} else {
|
||||
FluidStack fluid = getFluidFromContainer(hand);
|
||||
IAEFluidStack toInject = AEFluidStack.create(fluid);
|
||||
long toInjectAmount = (long) fluid.amount * hand.stackSize;
|
||||
toInject.setStackSize(toInjectAmount);
|
||||
IAEFluidStack leftover = this.getCellFluidInventory()
|
||||
.injectItems(toInject, Actionable.SIMULATE, this.getActionSource());
|
||||
long injected = leftover == null ? toInjectAmount : toInjectAmount - leftover.getStackSize();
|
||||
if (injected <= 0) return;
|
||||
|
||||
ItemStack cleared = hand.copy();
|
||||
cleared.stackSize = 1;
|
||||
cleared = clearFluidContainer(cleared);
|
||||
if (cleared == null) return;
|
||||
|
||||
if (injected == toInjectAmount && hand.stackSize <= cleared.getMaxStackSize()) {
|
||||
toInject.setStackSize(toInjectAmount);
|
||||
this.getCellFluidInventory().injectItems(toInject, Actionable.MODULATE, this.getActionSource());
|
||||
cleared.stackSize = hand.stackSize;
|
||||
player.inventory.setItemStack(cleared);
|
||||
this.updateHeld(player);
|
||||
} else {
|
||||
int stackSize = hand.stackSize;
|
||||
int fluidAmountPerItem = getFluidFromContainer(hand).amount;
|
||||
if (fluidAmountPerItem <= 0) return;
|
||||
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
for (int i = 0; i < stackSize; i++) {
|
||||
toInject.setStackSize(fluidAmountPerItem);
|
||||
leftover = this.getCellFluidInventory()
|
||||
.injectItems(toInject, Actionable.SIMULATE, this.getActionSource());
|
||||
injected = leftover == null ? fluidAmountPerItem : toInjectAmount - leftover.getStackSize();
|
||||
if (injected != fluidAmountPerItem) break;
|
||||
|
||||
if (adaptor.addItems(cleared.copy()) != null) break;
|
||||
|
||||
toInject.setStackSize(fluidAmountPerItem);
|
||||
this.getCellFluidInventory()
|
||||
.injectItems(toInject, Actionable.MODULATE, this.getActionSource());
|
||||
hand.stackSize--;
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
case FILL_SINGLE_CONTAINER -> {
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (slotFluid == null || slotFluid.getStackSize() <= 0 || !isFluidContainer(hand)) return;
|
||||
|
||||
if (hand.stackSize == 1) {
|
||||
// Set filled item to player hand
|
||||
fillSingleFluidContainer(player, hand, slotFluid);
|
||||
} else {
|
||||
// Insert filled item to player inventory
|
||||
ItemStack itemToFill = hand.copy();
|
||||
itemToFill.stackSize = 1;
|
||||
ObjectIntPair<ItemStack> filledPair = fillFluidContainer(itemToFill, slotFluid.getFluidStack());
|
||||
ItemStack filledContainer = filledPair.left();
|
||||
int filledAmount = filledPair.rightInt();
|
||||
if (filledContainer == null || filledAmount <= 0) return;
|
||||
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
if (adaptor.addItems(filledContainer) != null) return;
|
||||
|
||||
IAEFluidStack afs = slotFluid.copy();
|
||||
afs.setStackSize(filledAmount);
|
||||
this.getCellFluidInventory().extractItems(afs, Actionable.MODULATE, this.getActionSource());
|
||||
hand.stackSize--;
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
case FILL_CONTAINERS -> {
|
||||
ItemStack hand = player.inventory.getItemStack();
|
||||
if (slotFluid == null || slotFluid.getStackSize() <= 0 || !isFluidContainer(hand)) return;
|
||||
|
||||
// Set filled item to player hand
|
||||
if (hand.stackSize == 1) {
|
||||
fillSingleFluidContainer(player, hand, slotFluid);
|
||||
} else {
|
||||
int capacity = getFluidContainerCapacity(hand, slotFluid.getFluidStack());
|
||||
if (capacity == 0) return;
|
||||
|
||||
ItemStack filledContainer = getFilledFluidContainer(hand, slotFluid.getFluidStack());
|
||||
if (filledContainer.getMaxStackSize() >= hand.stackSize
|
||||
&& (long) capacity * hand.stackSize <= slotFluid.getStackSize()) {
|
||||
// Fill all item in player hand
|
||||
IAEFluidStack toExtract = slotFluid.copy();
|
||||
toExtract.setStackSize((long) capacity * hand.stackSize);
|
||||
this.getCellFluidInventory()
|
||||
.extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
filledContainer.stackSize = hand.stackSize;
|
||||
player.inventory.setItemStack(filledContainer);
|
||||
this.updateHeld(player);
|
||||
} else {
|
||||
// Set all filled item to player hand
|
||||
IAEFluidStack afs = slotFluid.copy();
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
int stackSize = hand.stackSize;
|
||||
for (int i = 0; i < stackSize; i++) {
|
||||
ItemStack itemToFill = hand.copy();
|
||||
itemToFill.stackSize = 1;
|
||||
FluidStack fluidForFill = afs.getFluidStack();
|
||||
ObjectIntPair<ItemStack> filled = fillFluidContainer(itemToFill, fluidForFill);
|
||||
filledContainer = filled.left();
|
||||
int filledAmount = filled.rightInt();
|
||||
if (filledContainer == null || filledAmount <= 0) break;
|
||||
|
||||
if (adaptor.addItems(filledContainer) != null) break;
|
||||
|
||||
long amountBeforeExtract = afs.getStackSize();
|
||||
afs.setStackSize(filledAmount);
|
||||
this.getCellFluidInventory().extractItems(afs, Actionable.MODULATE, this.getActionSource());
|
||||
afs.setStackSize(amountBeforeExtract - filledAmount);
|
||||
hand.stackSize--;
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillSingleFluidContainer(EntityPlayerMP player, ItemStack hand, IAEFluidStack slotFluid) {
|
||||
ObjectIntPair<ItemStack> filledPair = fillFluidContainer(hand, slotFluid.getFluidStack());
|
||||
ItemStack filledContainer = filledPair.left();
|
||||
int filledAmount = filledPair.rightInt();
|
||||
if (filledContainer == null || filledAmount <= 0) return;
|
||||
|
||||
IAEFluidStack afs = slotFluid.copy();
|
||||
afs.setStackSize(filledAmount);
|
||||
this.getCellFluidInventory().extractItems(afs, Actionable.MODULATE, this.getActionSource());
|
||||
player.inventory.setItemStack(filledContainer);
|
||||
this.updateHeld(player);
|
||||
}
|
||||
|
||||
private void extractFromSingleFluidContainer(EntityPlayerMP player, ItemStack hand) {
|
||||
if (hand.getItem() instanceof IFluidContainerItem container) {
|
||||
FluidStack fluid = container.getFluid(hand);
|
||||
IAEFluidStack leftover = this.getCellFluidInventory()
|
||||
.injectItems(AEFluidStack.create(fluid), Actionable.MODULATE, this.getActionSource());
|
||||
int injected = leftover == null ? fluid.amount : (int) (fluid.amount - leftover.getStackSize());
|
||||
if (injected == 0) return;
|
||||
container.drain(hand, injected, true);
|
||||
} else if (FluidContainerRegistry.isContainer(hand)) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(hand);
|
||||
IAEFluidStack toInject = AEFluidStack.create(fluid);
|
||||
IAEFluidStack leftover = this.getCellFluidInventory()
|
||||
.injectItems(toInject, Actionable.SIMULATE, this.getActionSource());
|
||||
if (leftover != null) return;
|
||||
this.getCellFluidInventory().injectItems(toInject, Actionable.MODULATE, this.getActionSource());
|
||||
player.inventory.setItemStack(FluidContainerRegistry.drainFluidContainer(hand));
|
||||
}
|
||||
this.updateHeld(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
|
||||
if (Platform.isClient()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get(idx); // require AE SLots!
|
||||
|
||||
if (clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (clickSlot != null && clickSlot.getHasStack() && clickSlot.isPlayerSide()) {
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
tis = this.shiftStoreItem(tis);
|
||||
clickSlot.putStack(tis);
|
||||
}
|
||||
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
private ItemStack shiftStoreItem(final ItemStack input) {
|
||||
if (this.getPowerSource() == null || this.getCellInventory() == null) {
|
||||
return input;
|
||||
}
|
||||
final IAEItemStack ais = Platform.poweredInsert(
|
||||
this.getPowerSource(),
|
||||
this.getCellInventory(),
|
||||
AEApi.instance().storage().createItemStack(input),
|
||||
this.getActionSource());
|
||||
if (ais == null) {
|
||||
return null;
|
||||
}
|
||||
return ais.getItemStack();
|
||||
}
|
||||
}
|
||||
@@ -11,75 +11,13 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
private final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
|
||||
public ContainerMEPortableCell(final InventoryPlayer ip, final IPortableCell monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
if (monitorable instanceof IInventorySlotAware) {
|
||||
final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
this.slot = slotIndex;
|
||||
} else {
|
||||
this.slot = -1;
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = monitorable;
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
final ItemStack currentItem = this.slot < 0 ? this.getPlayerInv().getCurrentItem()
|
||||
: this.getPlayerInv().getStackInSlot(this.slot);
|
||||
|
||||
if (this.civ != null) {
|
||||
if (currentItem != this.civ.getItemStack()) {
|
||||
if (currentItem != null) {
|
||||
if (Platform.isSameItem(this.civ.getItemStack(), currentItem)) {
|
||||
this.getPlayerInv()
|
||||
.setInventorySlotContents(this.getPlayerInv().currentItem, this.civ.getItemStack());
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.setValidContainer(false);
|
||||
}
|
||||
|
||||
// drain 1 ae t
|
||||
this.ticks++;
|
||||
if (this.ticks > 10) {
|
||||
this.civ.extractAEPower(
|
||||
this.getPowerMultiplier() * this.ticks,
|
||||
Actionable.MODULATE,
|
||||
PowerMultiplier.CONFIG);
|
||||
this.ticks = 0;
|
||||
}
|
||||
super.detectAndSendChanges();
|
||||
}
|
||||
|
||||
private double getPowerMultiplier() {
|
||||
return this.powerMultiplier;
|
||||
}
|
||||
|
||||
void setPowerMultiplier(final double powerMultiplier) {
|
||||
this.powerMultiplier = powerMultiplier;
|
||||
super(ip, monitorable);
|
||||
setPowerMultiplier(0.5);
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public class ContainerNetworkStatus extends AEBaseContainer {
|
||||
private boolean isConsume = true;
|
||||
|
||||
public ContainerNetworkStatus(final InventoryPlayer ip, final INetworkTool te) {
|
||||
super(ip, null, null);
|
||||
super(ip, te);
|
||||
final IGridHost host = te.getGridHost();
|
||||
|
||||
if (host != null) {
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ContainerNetworkTool extends AEBaseContainer {
|
||||
public boolean facadeMode;
|
||||
|
||||
public ContainerNetworkTool(final InventoryPlayer ip, final INetworkTool te) {
|
||||
super(ip, null, null);
|
||||
super(ip, te);
|
||||
this.toolInv = te;
|
||||
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -25,30 +24,22 @@ import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IInterfaceViewable;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.registries.InterfaceTerminalRegistry;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.crafting.v2.CraftingContext;
|
||||
import appeng.crafting.v2.CraftingJobV2;
|
||||
import appeng.crafting.v2.resolvers.CraftableItemResolver.CraftFromPatternTask;
|
||||
import appeng.crafting.v2.resolvers.CraftingTask;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.me.cache.CraftingGridCache;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminalEx;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.misc.TilePatternOptimizationMatrix;
|
||||
import appeng.util.PatternMultiplierHelper;
|
||||
import appeng.util.Platform;
|
||||
import codechicken.nei.ItemStackMap;
|
||||
import codechicken.nei.ItemStackSet;
|
||||
|
||||
public class ContainerOptimizePatterns extends AEBaseContainer {
|
||||
public class ContainerOptimizePatterns extends ContainerSubGui {
|
||||
|
||||
private ICraftingJob result;
|
||||
|
||||
@@ -185,36 +176,7 @@ public class ContainerOptimizePatterns extends AEBaseContainer {
|
||||
}
|
||||
|
||||
public void switchToOriginalGUI() {
|
||||
GuiBridge originalGui = null;
|
||||
|
||||
final IActionHost ah = this.getActionHost();
|
||||
if (ah instanceof WirelessTerminalGuiObject) {
|
||||
originalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if (ah instanceof PartTerminal) {
|
||||
originalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if (ah instanceof PartCraftingTerminal) {
|
||||
originalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if (ah instanceof PartPatternTerminal) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if (ah instanceof PartPatternTerminalEx) {
|
||||
originalGui = GuiBridge.GUI_PATTERN_TERMINAL_EX;
|
||||
}
|
||||
|
||||
if (originalGui != null && this.getOpenContext() != null) {
|
||||
NetworkHandler.instance
|
||||
.sendTo(new PacketSwitchGuis(originalGui), (EntityPlayerMP) this.getInventoryPlayer().player);
|
||||
|
||||
final TileEntity te = this.getOpenContext().getTile();
|
||||
Platform.openGUI(this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui);
|
||||
}
|
||||
getPrimaryGui().open(this.getInventoryPlayer().player);
|
||||
}
|
||||
|
||||
public static int getBitMultiplier(long currentCrafts, long perCraft, long maximumCrafts) {
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.helpers.IOreFilterable;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class ContainerOreFilter extends AEBaseContainer {
|
||||
public class ContainerOreFilter extends ContainerSubGui {
|
||||
|
||||
private final IOreFilterable filterHost;
|
||||
|
||||
@@ -23,7 +21,7 @@ public class ContainerOreFilter extends AEBaseContainer {
|
||||
public String filter = "";
|
||||
|
||||
public ContainerOreFilter(final InventoryPlayer ip, final IOreFilterable te) {
|
||||
super(ip, (TileEntity) (te instanceof TileEntity ? te : null), (IPart) (te instanceof IPart ? te : null));
|
||||
super(ip, te);
|
||||
this.filterHost = te;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +1,12 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
||||
public class ContainerPatternItemRenamer extends AEBaseContainer {
|
||||
|
||||
private final Slot patternValue;
|
||||
public class ContainerPatternItemRenamer extends ContainerPatternValueAmount {
|
||||
|
||||
public ContainerPatternItemRenamer(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
|
||||
}
|
||||
|
||||
public IGrid getGrid() {
|
||||
final IActionHost h = ((IActionHost) getTarget());
|
||||
return h.getActionableNode().getGrid();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return getPlayerInv().player.worldObj;
|
||||
}
|
||||
|
||||
public Slot getPatternValue() {
|
||||
return patternValue;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerSubGui;
|
||||
|
||||
public class ContainerPatternMulti extends AEBaseContainer {
|
||||
public class ContainerPatternMulti extends ContainerSubGui {
|
||||
|
||||
public ContainerPatternMulti(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
super(ip, te);
|
||||
|
||||
@@ -10,17 +10,16 @@
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
import static appeng.parts.reporting.PartPatternTerminal.*;
|
||||
import static appeng.util.Platform.isServer;
|
||||
import static appeng.util.Platform.writeStackNBT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -28,53 +27,62 @@ import net.minecraft.inventory.SlotCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.parts.IPatternTerminal;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.interfaces.IVirtualSlotHolder;
|
||||
import appeng.container.interfaces.IVirtualSlotSource;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.OptionalSlotFake;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotPatternTerm;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.items.contents.WirelessPatternTerminalGuiObject;
|
||||
import appeng.items.storage.ItemViewCell;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorPlayerHand;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
|
||||
public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost,
|
||||
IContainerCraftingPacket, IVirtualSlotHolder, IVirtualSlotSource {
|
||||
|
||||
public static final int MULTIPLE_OF_BUTTON_CLICK = 2;
|
||||
public static final int MULTIPLE_OF_BUTTON_CLICK_ON_SHIFT = 8;
|
||||
private final PartPatternTerminal patternTerminal;
|
||||
protected final IPatternTerminal patternTerminal;
|
||||
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
|
||||
private final IInventory crafting;
|
||||
private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
|
||||
private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
|
||||
private final IAEStackInventory inputs;
|
||||
private final IAEStackInventory outputs;
|
||||
public final IAEStack<?>[] craftingSlotsClient = new IAEStack<?>[getPatternInputsWidth() * getPatternInputsHeigh()
|
||||
* getPatternOutputPages()];
|
||||
private final IInventory craftingMatrix;
|
||||
public final IAEStack<?>[] outputSlotsClient = new IAEStack<?>[getPatternOutputsWidth() * getPatternOutputsHeigh()
|
||||
* getPatternOutputPages()];
|
||||
|
||||
private final SlotPatternTerm craftSlot;
|
||||
private final SlotRestrictedInput patternSlotIN;
|
||||
private final SlotRestrictedInput patternSlotOUT;
|
||||
private final boolean craftingModeSupport;
|
||||
|
||||
boolean isFirstUpdate = true;
|
||||
|
||||
@GuiSync(97)
|
||||
public boolean craftingMode = true;
|
||||
@@ -86,45 +94,49 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
public boolean beSubstitute = true;
|
||||
|
||||
public ContainerPatternTerm(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
this(ip, monitorable, true);
|
||||
}
|
||||
|
||||
public ContainerPatternTerm(final InventoryPlayer ip, final ITerminalHost monitorable,
|
||||
boolean craftingModeSupport) {
|
||||
super(ip, monitorable, false);
|
||||
this.patternTerminal = (PartPatternTerminal) monitorable;
|
||||
this.patternTerminal = (IPatternTerminal) monitorable;
|
||||
|
||||
final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern");
|
||||
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
|
||||
|
||||
this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlotToContainer(
|
||||
this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix(
|
||||
this.crafting,
|
||||
x + y * 3,
|
||||
18 + x * 18,
|
||||
-76 + y * 18));
|
||||
}
|
||||
if (monitorable instanceof WirelessPatternTerminalGuiObject wptgo) {
|
||||
wptgo.setInventorySize(
|
||||
getPatternInputsWidth() * getPatternInputsHeigh() * getPatternInputPages(),
|
||||
getPatternOutputsWidth() * getPatternOutputsHeigh() * getPatternOutputPages());
|
||||
wptgo.readInventory();
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
this.craftSlot = new SlotPatternTerm(
|
||||
ip.player,
|
||||
this.getActionSource(),
|
||||
this.getPowerSource(),
|
||||
monitorable,
|
||||
this.crafting,
|
||||
patternInv,
|
||||
this.cOut,
|
||||
110,
|
||||
-76 + 18,
|
||||
this,
|
||||
2,
|
||||
this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
this.craftingModeSupport = craftingModeSupport;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
final IInventory patternInv = this.getPatternTerminal()
|
||||
.getInventoryByName(StorageName.CRAFTING_PATTERN.getName());
|
||||
|
||||
this.inputs = this.getPatternTerminal().getAEInventoryByName(StorageName.CRAFTING_INPUT);
|
||||
this.outputs = this.getPatternTerminal().getAEInventoryByName(StorageName.CRAFTING_OUTPUT);
|
||||
|
||||
if (craftingModeSupport) {
|
||||
this.craftingMatrix = new AppEngInternalInventory(null, 9);
|
||||
this.addSlotToContainer(
|
||||
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
|
||||
this.outputSlots[y].setRenderDisabled(false);
|
||||
this.craftSlot = new SlotPatternTerm(
|
||||
ip.player,
|
||||
this.getActionSource(),
|
||||
this.getPowerSource(),
|
||||
monitorable,
|
||||
this.craftingMatrix,
|
||||
patternInv,
|
||||
this.cOut,
|
||||
110,
|
||||
-76 + 18,
|
||||
this,
|
||||
2,
|
||||
this));
|
||||
this.craftSlot.setIIcon(-1);
|
||||
} else {
|
||||
this.craftingMatrix = null;
|
||||
this.craftSlot = null;
|
||||
}
|
||||
|
||||
this.addSlotToContainer(
|
||||
@@ -146,27 +158,40 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
|
||||
this.patternSlotOUT.setStackLimit(1);
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.updateOrderOfOutputSlots();
|
||||
if (getPatternTerminal().hasRefillerUpgrade()) refillBlankPatterns(patternSlotIN);
|
||||
refillBlankPatterns(patternSlotIN);
|
||||
|
||||
// need because InventoryBogoSorter looking for specific slot number for bind buttons
|
||||
// bindPlayerInventory in MEMonitorable break it
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
|
||||
private void updateOrderOfOutputSlots() {
|
||||
if (!this.isCraftingMode()) {
|
||||
this.craftSlot.xDisplayPosition = -9000;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
|
||||
}
|
||||
} else {
|
||||
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
this.outputSlots[y].xDisplayPosition = -9000;
|
||||
if (craftingModeSupport) {
|
||||
if (!this.isCraftingMode()) {
|
||||
this.craftSlot.xDisplayPosition = -9000;
|
||||
} else {
|
||||
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copyToMatrix() {
|
||||
for (int i = 0; i < this.craftingMatrix.getSizeInventory(); i++) {
|
||||
IAEStack<?> aes = this.inputs.getAEStackInSlot(i);
|
||||
if (aes instanceof IAEItemStack ais) {
|
||||
ais.setStackSize(1);
|
||||
ItemStack is = ais.getItemStack();
|
||||
this.craftingMatrix.setInventorySlotContents(i, is);
|
||||
} else {
|
||||
this.inputs.putAEStackInSlot(i, null);
|
||||
this.craftingMatrix.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
this.getAndUpdateOutput();
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
|
||||
super.putStackInSlot(par1, par2ItemStack);
|
||||
@@ -179,15 +204,21 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory p_75130_1_) {}
|
||||
|
||||
private ItemStack getAndUpdateOutput() {
|
||||
if (!craftingModeSupport || !isCraftingMode() || !isServer()) return null;
|
||||
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
|
||||
|
||||
for (int x = 0; x < ic.getSizeInventory(); x++) {
|
||||
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
|
||||
ic.setInventorySlotContents(x, this.craftingMatrix.getStackInSlot(x));
|
||||
}
|
||||
|
||||
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
|
||||
this.cOut.setInventorySlotContents(0, is);
|
||||
super.detectAndSendChanges();
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@@ -211,15 +242,15 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
getPlayerInv().player.entityDropItem(output, 0);
|
||||
}
|
||||
this.patternSlotOUT.putStack(null);
|
||||
if (getPatternTerminal().hasRefillerUpgrade()) refillBlankPatterns(patternSlotIN);
|
||||
refillBlankPatterns(patternSlotIN);
|
||||
}
|
||||
}
|
||||
|
||||
public void encode() {
|
||||
ItemStack output = this.patternSlotOUT.getStack();
|
||||
|
||||
final ItemStack[] in = this.getInputs();
|
||||
final ItemStack[] out = this.getOutputs();
|
||||
final IAEStack<?>[] in = this.getInputs();
|
||||
final IAEStack<?>[] out = this.getOutputs();
|
||||
|
||||
// if there is no input, this would be silly.
|
||||
if (in == null || out == null) {
|
||||
@@ -227,36 +258,33 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
}
|
||||
|
||||
// first check the output slots, should either be null, or a pattern
|
||||
if (output != null && !this.isPattern(output)) {
|
||||
return;
|
||||
if (output != null) {
|
||||
if (!this.isEncodedPattern(output) && !this.isUltimatePattern(output)) {
|
||||
return;
|
||||
}
|
||||
} // if nothing is there we should snag a new pattern.
|
||||
else if (output == null) {
|
||||
output = this.patternSlotIN.getStack();
|
||||
if (!this.isPattern(output)) {
|
||||
return; // no blanks.
|
||||
else {
|
||||
ItemStack blank = this.patternSlotIN.getStack();
|
||||
if (!this.isBlankPattern(blank)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove one, and clear the input slot.
|
||||
output.stackSize--;
|
||||
if (output.stackSize == 0) {
|
||||
blank.stackSize--;
|
||||
if (blank.stackSize == 0) {
|
||||
this.patternSlotIN.putStack(null);
|
||||
}
|
||||
|
||||
refillBlankPatterns(patternSlotIN);
|
||||
|
||||
// add a new encoded pattern.
|
||||
if (isCraftingMode()) {
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern()
|
||||
.maybeStack(1).asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
output = AEApi.instance().definitions().items().encodedPattern().maybeStack(1).orNull();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
} else {
|
||||
for (final ItemStack encodedPatternStack : AEApi.instance().definitions().items()
|
||||
.encodedUltimatePattern().maybeStack(1).asSet()) {
|
||||
output = encodedPatternStack;
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
output = AEApi.instance().definitions().items().encodedUltimatePattern().maybeStack(1).orNull();
|
||||
this.patternSlotOUT.putStack(output);
|
||||
}
|
||||
if (getPatternTerminal().hasRefillerUpgrade()) refillBlankPatterns(patternSlotIN);
|
||||
}
|
||||
|
||||
// encode the slot.
|
||||
@@ -265,14 +293,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
final NBTTagList tagIn = new NBTTagList();
|
||||
final NBTTagList tagOut = new NBTTagList();
|
||||
|
||||
for (final ItemStack i : in) {
|
||||
if (isCraftingMode()) tagIn.appendTag(this.createItemTag(i));
|
||||
else tagIn.appendTag(writeStackNBT(AEItemStack.create(i), new NBTTagCompound(), true));
|
||||
for (final IAEStack<?> i : in) {
|
||||
tagIn.appendTag(writeStackNBT(i, new NBTTagCompound(), true));
|
||||
}
|
||||
|
||||
for (final ItemStack i : out) {
|
||||
if (isCraftingMode()) tagOut.appendTag(this.createItemTag(i));
|
||||
else tagOut.appendTag(writeStackNBT(AEItemStack.create(i), new NBTTagCompound(), true));
|
||||
for (final IAEStack<?> i : out) {
|
||||
tagOut.appendTag(writeStackNBT(i, new NBTTagCompound(), true));
|
||||
}
|
||||
|
||||
encodedValue.setTag("in", tagIn);
|
||||
@@ -285,13 +311,13 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
output.setTagCompound(encodedValue);
|
||||
}
|
||||
|
||||
private ItemStack[] getInputs() {
|
||||
final ItemStack[] input = new ItemStack[9];
|
||||
private IAEStack<?>[] getInputs() {
|
||||
final IAEStack<?>[] input = new IAEStack<?>[this.inputs.getSizeInventory()];
|
||||
boolean hasValue = false;
|
||||
|
||||
for (int x = 0; x < this.craftingSlots.length; x++) {
|
||||
input[x] = this.craftingSlots[x].getStack();
|
||||
if (input[x] != null) {
|
||||
for (int i = 0; i < this.inputs.getSizeInventory(); i++) {
|
||||
input[i] = this.inputs.getAEStackInSlot(i);
|
||||
if (input[i] != null) {
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
@@ -303,65 +329,52 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] getOutputs() {
|
||||
private IAEStack<?>[] getOutputs() {
|
||||
if (this.isCraftingMode()) {
|
||||
final ItemStack out = this.getAndUpdateOutput();
|
||||
final IAEStack<?> out = AEItemStack.create(this.getAndUpdateOutput());
|
||||
|
||||
if (out != null && out.stackSize > 0) {
|
||||
return new ItemStack[] { out };
|
||||
if (out != null && out.getStackSize() > 0) {
|
||||
return new IAEStack<?>[] { out };
|
||||
}
|
||||
} else {
|
||||
final List<ItemStack> list = new ArrayList<>(3);
|
||||
final List<IAEStack<?>> list = new ArrayList<>(3);
|
||||
boolean hasValue = false;
|
||||
|
||||
for (final OptionalSlotFake outputSlot : this.outputSlots) {
|
||||
final ItemStack out = outputSlot.getStack();
|
||||
for (int i = 0; i < this.outputs.getSizeInventory(); i++) {
|
||||
final IAEStack<?> out = this.outputs.getAEStackInSlot(i);
|
||||
|
||||
if (out != null && out.stackSize > 0) {
|
||||
if (out != null && out.getStackSize() > 0) {
|
||||
list.add(out);
|
||||
hasValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasValue) {
|
||||
return list.toArray(new ItemStack[0]);
|
||||
return list.toArray(new IAEStack<?>[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isPattern(final ItemStack output) {
|
||||
if (output == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
|
||||
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
|
||||
boolean isUltimatePattern = definitions.items().encodedUltimatePattern().isSameAs(output);
|
||||
isPattern |= definitions.materials().blankPattern().isSameAs(output);
|
||||
|
||||
return isPattern || isUltimatePattern;
|
||||
private boolean isBlankPattern(final ItemStack stack) {
|
||||
return stack != null && AEApi.instance().definitions().materials().blankPattern().isSameAs(stack);
|
||||
}
|
||||
|
||||
private NBTBase createItemTag(final ItemStack i) {
|
||||
final NBTTagCompound c = new NBTTagCompound();
|
||||
private boolean isEncodedPattern(final ItemStack stack) {
|
||||
return stack != null && AEApi.instance().definitions().items().encodedPattern().isSameAs(stack);
|
||||
}
|
||||
|
||||
if (i != null) {
|
||||
i.writeToNBT(c);
|
||||
c.setInteger("Count", i.stackSize);
|
||||
}
|
||||
|
||||
return c;
|
||||
private boolean isUltimatePattern(final ItemStack stack) {
|
||||
return stack != null && AEApi.instance().definitions().items().encodedUltimatePattern().isSameAs(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(final int idx) {
|
||||
if (idx == 1) {
|
||||
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
|
||||
return isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
|
||||
} else if (idx == 2) {
|
||||
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
|
||||
return isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -470,14 +483,23 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
if (Platform.isServer()) {
|
||||
if (isServer()) {
|
||||
if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) {
|
||||
this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe());
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
this.substitute = this.patternTerminal.isSubstitution();
|
||||
this.beSubstitute = this.patternTerminal.canBeSubstitution();
|
||||
|
||||
if (this.isFirstUpdate) {
|
||||
if (isCraftingMode()) {
|
||||
this.copyToMatrix();
|
||||
} else {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
}
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, this.outputs, outputSlotsClient);
|
||||
this.isFirstUpdate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,19 +515,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
|
||||
@Override
|
||||
public void onSlotChange(final Slot s) {
|
||||
if (!Platform.isServer()) return;
|
||||
if (!isServer()) return;
|
||||
if (s == this.patternSlotOUT) {
|
||||
for (final Object crafter : this.crafters) {
|
||||
final ICrafting icrafting = (ICrafting) crafter;
|
||||
|
||||
for (final Object g : this.inventorySlots) {
|
||||
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
|
||||
final Slot sri = (Slot) g;
|
||||
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
|
||||
}
|
||||
}
|
||||
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
|
||||
}
|
||||
this.isFirstUpdate = true;
|
||||
this.detectAndSendChanges();
|
||||
} else if (s == patternRefiller && patternRefiller.getStack() != null) {
|
||||
refillBlankPatterns(patternSlotIN);
|
||||
@@ -514,16 +526,41 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
for (final Slot s : this.craftingSlots) {
|
||||
s.putStack(null);
|
||||
for (int i = 0; i < this.inputs.getSizeInventory(); ++i) {
|
||||
this.inputs.putAEStackInSlot(i, null);
|
||||
}
|
||||
for (int i = 0; i < this.outputs.getSizeInventory(); ++i) {
|
||||
this.outputs.putAEStackInSlot(i, null);
|
||||
}
|
||||
if (this.craftingMatrix != null) {
|
||||
for (int i = 0; i < this.craftingMatrix.getSizeInventory(); ++i) {
|
||||
this.craftingMatrix.setInventorySlotContents(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (final Slot s : this.outputSlots) {
|
||||
s.putStack(null);
|
||||
}
|
||||
|
||||
this.detectAndSendChanges();
|
||||
this.getAndUpdateOutput();
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, this.outputs, outputSlotsClient);
|
||||
}
|
||||
|
||||
protected void refillBlankPatterns(Slot slot) {
|
||||
if (Platform.isServer()) {
|
||||
ItemStack blanks = slot.getStack();
|
||||
int blanksToRefill = 64;
|
||||
if (blanks != null) blanksToRefill -= blanks.stackSize;
|
||||
if (blanksToRefill <= 0) return;
|
||||
final AEItemStack request = AEItemStack
|
||||
.create(AEApi.instance().definitions().materials().blankPattern().maybeStack(blanksToRefill).get());
|
||||
final IAEItemStack extracted = Platform
|
||||
.poweredExtraction(this.getPowerSource(), this.getCellInventory(), request, this.getActionSource());
|
||||
if (extracted != null) {
|
||||
if (blanks != null) blanks.stackSize += (int) extracted.getStackSize();
|
||||
else {
|
||||
blanks = extracted.getItemStack();
|
||||
}
|
||||
slot.putStack(blanks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -550,11 +587,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
return this.craftingMode;
|
||||
}
|
||||
|
||||
private void setCraftingMode(final boolean craftingMode) {
|
||||
public void setCraftingMode(final boolean craftingMode) {
|
||||
this.craftingMode = craftingMode;
|
||||
this.patternTerminal.setCraftingRecipe(craftingMode);
|
||||
if (craftingMode && craftingModeSupport) copyToMatrix();
|
||||
this.updateOrderOfOutputSlots();
|
||||
}
|
||||
|
||||
public PartPatternTerminal getPatternTerminal() {
|
||||
public IPatternTerminal getPatternTerminal() {
|
||||
return this.patternTerminal;
|
||||
}
|
||||
|
||||
@@ -580,45 +620,49 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
* ((val & 2) != 0 ? -1 : 1));
|
||||
}
|
||||
|
||||
static boolean canMultiplyOrDivide(SlotFake[] slots, int mult) {
|
||||
static boolean canMultiplyOrDivide(IAEStackInventory inventory, int mult) {
|
||||
if (mult > 0) {
|
||||
for (Slot s : slots) {
|
||||
if (s.getStack() != null) {
|
||||
long val = (long) s.getStack().stackSize * mult;
|
||||
if (val > Integer.MAX_VALUE) return false;
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
IAEStack<?> aes = inventory.getAEStackInSlot(i);
|
||||
if (aes != null) {
|
||||
double val = (double) aes.getStackSize() * mult;
|
||||
if (val > Long.MAX_VALUE) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (mult < 0) {
|
||||
mult = -mult;
|
||||
for (Slot s : slots) {
|
||||
if (s.getStack() != null) { // Although % is a very inefficient algorithm, it is not a performance issue
|
||||
// here. :>
|
||||
if (s.getStack().stackSize % mult != 0) return false;
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
IAEStack<?> aes = inventory.getAEStackInSlot(i);
|
||||
if (aes != null) { // Although % is a very inefficient algorithm, it is not a performance
|
||||
// issue
|
||||
// here. :>
|
||||
if (aes.getStackSize() % mult != 0) return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void multiplyOrDivideStacksInternal(SlotFake[] slots, int mult) {
|
||||
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
|
||||
static void multiplyOrDivideStacksInternal(IAEStackInventory inventory, int mult) {
|
||||
if (mult > 0) {
|
||||
for (final Slot s : enabledSlots) {
|
||||
ItemStack st = s.getStack();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
IAEStack<?> st = inventory.getAEStackInSlot(i);
|
||||
if (st != null) {
|
||||
st.stackSize *= mult;
|
||||
s.putStack(st);
|
||||
st.setStackSize(st.getStackSize() * mult);
|
||||
inventory.putAEStackInSlot(i, st);
|
||||
}
|
||||
}
|
||||
} else if (mult < 0) {
|
||||
mult = -mult;
|
||||
for (final Slot s : enabledSlots) {
|
||||
ItemStack st = s.getStack();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
IAEStack<?> st = inventory.getAEStackInSlot(i);
|
||||
if (st != null) {
|
||||
st.stackSize /= mult;
|
||||
s.putStack(st);
|
||||
st.setStackSize(st.getStackSize() / mult);
|
||||
inventory.putAEStackInSlot(i, st);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -626,20 +670,114 @@ public class ContainerPatternTerm extends ContainerMEMonitorable
|
||||
|
||||
/**
|
||||
* Multiply or divide a number
|
||||
*
|
||||
*
|
||||
* @param multi Positive numbers are multiplied and negative numbers are divided
|
||||
*/
|
||||
public void multiplyOrDivideStacks(int multi) {
|
||||
if (!isCraftingMode()) {
|
||||
if (canMultiplyOrDivide(this.craftingSlots, multi) && canMultiplyOrDivide(this.outputSlots, multi)) {
|
||||
multiplyOrDivideStacksInternal(this.craftingSlots, multi);
|
||||
multiplyOrDivideStacksInternal(this.outputSlots, multi);
|
||||
if (canMultiplyOrDivide(this.inputs, multi) && canMultiplyOrDivide(this.outputs, multi)) {
|
||||
multiplyOrDivideStacksInternal(this.inputs, multi);
|
||||
multiplyOrDivideStacksInternal(this.outputs, multi);
|
||||
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, this.outputs, outputSlotsClient);
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAPatternTerminal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getCraftingModeSupport() {
|
||||
return craftingModeSupport;
|
||||
}
|
||||
|
||||
public int getPatternInputsWidth() {
|
||||
return patternInputsWidth;
|
||||
}
|
||||
|
||||
public int getPatternInputsHeigh() {
|
||||
return patternInputsHeigh;
|
||||
}
|
||||
|
||||
public int getPatternInputPages() {
|
||||
return patternInputsPages;
|
||||
}
|
||||
|
||||
public int getPatternOutputsWidth() {
|
||||
return patternOutputsWidth;
|
||||
}
|
||||
|
||||
public int getPatternOutputsHeigh() {
|
||||
return patternOutputsHeigh;
|
||||
}
|
||||
|
||||
public int getPatternOutputPages() {
|
||||
return patternOutputPages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVirtualSlot(StorageName invName, int slotId, IAEStack<?> aes) {
|
||||
switch (invName) {
|
||||
case CRAFTING_INPUT -> {
|
||||
if (isCraftingMode() && aes != null) {
|
||||
aes.setStackSize(1);
|
||||
}
|
||||
this.inputs.putAEStackInSlot(slotId, aes);
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
if (isCraftingMode()) {
|
||||
if (aes != null) {
|
||||
IAEItemStack ais = ((IAEItemStack) aes);
|
||||
this.craftingMatrix.setInventorySlotContents(slotId, ais.getItemStack());
|
||||
} else {
|
||||
this.craftingMatrix.setInventorySlotContents(slotId, null);
|
||||
}
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
case CRAFTING_OUTPUT -> {
|
||||
this.outputs.putAEStackInSlot(slotId, aes);
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, this.outputs, outputSlotsClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
|
||||
switch (invName) {
|
||||
case CRAFTING_INPUT -> {
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
IAEStack<?> aes = entry.getValue();
|
||||
if (isServer() && isCraftingMode() && aes != null) {
|
||||
aes.setStackSize(1);
|
||||
}
|
||||
this.inputs.putAEStackInSlot(entry.getIntKey(), aes);
|
||||
if (isServer() && isCraftingMode()) {
|
||||
this.craftingMatrix.setInventorySlotContents(
|
||||
entry.getIntKey(),
|
||||
aes != null ? ((IAEItemStack) aes).getItemStack() : null);
|
||||
}
|
||||
}
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_INPUT, this.inputs, craftingSlotsClient);
|
||||
if (isCraftingMode()) {
|
||||
this.getAndUpdateOutput();
|
||||
}
|
||||
}
|
||||
}
|
||||
case CRAFTING_OUTPUT -> {
|
||||
for (var entry : slotStacks.int2ObjectEntrySet()) {
|
||||
this.outputs.putAEStackInSlot(entry.getIntKey(), entry.getValue());
|
||||
}
|
||||
if (isServer()) {
|
||||
this.updateVirtualSlots(StorageName.CRAFTING_OUTPUT, this.outputs, outputSlotsClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 225 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user