mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
Universal GUI (#340)
Co-authored-by: Kogepan229 <[email protected]> Co-authored-by: Martin Robertz <[email protected]>
This commit is contained in:
213 files changed
+1859
-19432
No files matched your search
@@ -45,6 +45,7 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
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.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
@@ -59,7 +60,7 @@ import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEFluidStack>, IGridTickable {
|
||||
implements ICraftingProvider, IMEMonitorHandlerReceiver<IAEStack<?>>, IGridTickable {
|
||||
|
||||
private final AppEngInternalInventory inventory = new AppEngInternalInventory(this, 1);
|
||||
private final BaseActionSource source = new MachineSource(this);
|
||||
@@ -214,14 +215,13 @@ public class TileFluidAutoFiller extends AENetworkInvTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
|
||||
BaseActionSource source) {
|
||||
public void postChange(IBaseMonitor<IAEStack<?>> monitor, Iterable<IAEStack<?>> change, BaseActionSource source) {
|
||||
if (this.getProxy().isActive() && this.getStorageGrid() != null) {
|
||||
boolean hasChanged = false;
|
||||
for (IAEFluidStack tmp : change) {
|
||||
if (this.fluids.findPrecise(tmp) == null) {
|
||||
for (IAEStack<?> tmp : change) {
|
||||
if (this.fluids.findPrecise((IAEFluidStack) tmp) == null) {
|
||||
hasChanged = true;
|
||||
this.fluids.add(tmp);
|
||||
this.fluids.add((IAEFluidStack) tmp);
|
||||
}
|
||||
}
|
||||
if (hasChanged) postEvent();
|
||||
|
||||
@@ -1,258 +1,10 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.events.MENetworkCellArrayUpdate;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkStorageEvent;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.ICellContainer;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost, ICellContainer {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final FluidDiscretizingInventory fluidDropInv = new FluidDiscretizingInventory();
|
||||
private boolean prevActiveState = false;
|
||||
public class TileFluidDiscretizer extends AENetworkTile {
|
||||
|
||||
public TileFluidDiscretizer() {
|
||||
super();
|
||||
getProxy().setIdlePowerUsage(3D);
|
||||
getProxy().setFlags(GridFlags.REQUIRE_CHANNEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List<IMEInventoryHandler> getCellArray(StorageChannel channel) {
|
||||
if (channel == StorageChannel.ITEMS && getProxy().isActive()) {
|
||||
return Collections.singletonList(fluidDropInv.invHandler);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPriority(int newValue) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gridChanged() {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
fluidGrid.addListener(fluidDropInv, fluidGrid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(@SuppressWarnings("rawtypes") IMEInventory cellInventory) {
|
||||
markDirty();
|
||||
}
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnergyGrid getEnergyGrid() {
|
||||
try {
|
||||
return getProxy().getGrid().getCache(IEnergyGrid.class);
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
boolean isActive = getProxy().isActive();
|
||||
if (isActive != prevActiveState) {
|
||||
prevActiveState = isActive;
|
||||
try {
|
||||
getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
|
||||
} catch (GridAccessException e) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onPowerUpdate(MENetworkPowerStatusChange event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onChannelUpdate(MENetworkChannelsChanged event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void onStorageUpdate(MENetworkStorageEvent event) {
|
||||
updateState();
|
||||
}
|
||||
|
||||
private class FluidDiscretizingInventory
|
||||
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
|
||||
private IItemList<IAEItemStack> itemCache = null;
|
||||
|
||||
FluidDiscretizingInventory() {
|
||||
invHandler.setPriority(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack request, Actionable type, BaseActionSource src) {
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return request;
|
||||
}
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return request;
|
||||
}
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null) {
|
||||
return request;
|
||||
}
|
||||
if (type == Actionable.SIMULATE) {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.SIMULATE, src));
|
||||
} else {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.injectItems(fluidStack.copy(), Actionable.MODULATE, src));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) {
|
||||
IAEFluidStack fluidStack = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return null;
|
||||
}
|
||||
IEnergyGrid energyGrid = getEnergyGrid();
|
||||
if (energyGrid == null) {
|
||||
return null;
|
||||
}
|
||||
if (mode == Actionable.SIMULATE) {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.SIMULATE, src));
|
||||
} else {
|
||||
return ItemFluidDrop.newAeStack(fluidGrid.extractItems(fluidStack.copy(), Actionable.MODULATE, src));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out, int iteration) {
|
||||
if (itemCache == null) {
|
||||
itemCache = AEApi.instance().storage().createItemList();
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
for (IAEFluidStack fluid : fluidGrid.getStorageList()) {
|
||||
IAEItemStack stack = ItemFluidDrop.newAeStack(fluid);
|
||||
if (stack != null
|
||||
&& !FluidCraftAPI.instance().isBlacklistedInDisplay(fluid.getFluid().getClass())) {
|
||||
itemCache.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (IAEItemStack stack : itemCache) {
|
||||
out.addStorage(stack);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack getAvailableItem(@Nonnull IAEItemStack request, int iteration) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null) {
|
||||
return null;
|
||||
}
|
||||
IAEFluidStack fluidRequest = ItemFluidDrop.getAeFluidStack(request);
|
||||
if (fluidRequest == null) {
|
||||
return null;
|
||||
}
|
||||
IAEFluidStack availableFluid = fluidGrid.getAvailableItem(fluidRequest, iteration);
|
||||
if (availableFluid == null || availableFluid.getFluid() == null
|
||||
|| FluidCraftAPI.instance().isBlacklistedInDisplay(availableFluid.getFluid().getClass())) {
|
||||
return null;
|
||||
}
|
||||
return ItemFluidDrop.newAeStack(availableFluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel() {
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(Object verificationToken) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
return fluidGrid != null && fluidGrid == verificationToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change,
|
||||
BaseActionSource actionSource) {
|
||||
itemCache = null;
|
||||
try {
|
||||
List<IAEItemStack> mappedChanges = new ArrayList<>();
|
||||
for (IAEFluidStack fluidStack : change) {
|
||||
IAEItemStack itemStack = ItemFluidDrop.newAeStack(fluidStack);
|
||||
if (itemStack != null
|
||||
&& !FluidCraftAPI.instance().isBlacklistedInDisplay(fluidStack.getFluid().getClass())) {
|
||||
mappedChanges.add(itemStack);
|
||||
}
|
||||
}
|
||||
getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class)
|
||||
.postAlterationOfStoredItems(getChannel(), mappedChanges, ownActionSource);
|
||||
} catch (GridAccessException e) {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListUpdate() {
|
||||
// NO-OP
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
@@ -13,6 +14,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import com.glodblock.github.client.FluidInterfaceButtons;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
@@ -32,17 +34,23 @@ import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.ICustomButtonDataObject;
|
||||
import appeng.helpers.ICustomButtonProvider;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
public class TileFluidInterface extends TileInterface implements IDualHost, ICustomButtonProvider {
|
||||
|
||||
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
|
||||
|
||||
private ICustomButtonDataObject customButtonDataObject;
|
||||
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
|
||||
|
||||
@Override
|
||||
@@ -59,6 +67,7 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
|
||||
public TileFluidInterface() {
|
||||
super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
|
||||
this.customButtonDataObject = new FluidInterfaceButtons(true);
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
@@ -226,4 +235,39 @@ public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
this.fluidDuality.addDrops(drops);
|
||||
super.getDrops(w, x, y, z, drops);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPrimaryGuiIcon() {
|
||||
return ItemAndBlockHolder.INTERFACE.stack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCustomButtonData() {}
|
||||
|
||||
@Override
|
||||
public void readCustomButtonData() {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void initCustomButtons(int guiLeft, int guiTop, int xSize, int ySize, int xOffset, int yOffset,
|
||||
List<GuiButton> buttonList) {
|
||||
if (customButtonDataObject != null)
|
||||
customButtonDataObject.initCustomButtons(guiLeft, guiTop, xSize, ySize, xOffset, yOffset, buttonList);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean actionPerformedCustomButtons(final GuiButton btn) {
|
||||
return customButtonDataObject != null && customButtonDataObject.actionPerformedCustomButtons(btn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICustomButtonDataObject getDataObject() {
|
||||
return customButtonDataObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDataObject(ICustomButtonDataObject dataObject) {
|
||||
customButtonDataObject = dataObject;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -17,20 +15,18 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelViewable;
|
||||
import com.glodblock.github.api.registries.LevelItemInfo;
|
||||
import com.glodblock.github.api.registries.LevelState;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.ThaumicEnergisticsCrafting;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILevelViewable;
|
||||
import appeng.api.features.LevelItemInfo;
|
||||
import appeng.api.features.LevelState;
|
||||
import appeng.api.implementations.IPowerChannelState;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -49,8 +45,10 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
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.storage.data.IItemList;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -58,7 +56,9 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -76,10 +76,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public static final String NBT_LINK = "link";
|
||||
|
||||
public final RequestInfo[] requests = new RequestInfo[REQ_COUNT];
|
||||
private final LevelMaintainerInventory inventory = new LevelMaintainerInventory(requests, this);
|
||||
private final LevelMaintainerInventory inventory = new LevelMaintainerInventory(requests);
|
||||
private int firstRequest = 0;
|
||||
private final BaseActionSource source;
|
||||
private final IInventory inv = new AeItemStackHandler(inventory);
|
||||
private boolean isPowered = false;
|
||||
|
||||
public TileLevelMaintainer() {
|
||||
@@ -88,7 +87,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
source = new MachineSource(this);
|
||||
}
|
||||
|
||||
public AeStackInventory<IAEItemStack> getRequestSlots() {
|
||||
public IAEStackInventory getAEStackInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@@ -181,7 +180,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
// If there is none, find the next request we can begin calculating.
|
||||
ICraftingJob jobToSubmit = null;
|
||||
int jobToSubmitIdx = -1;
|
||||
IAEItemStack itemToBegin = null;
|
||||
IAEStack<?> itemToBegin = null;
|
||||
int itemToBeginIdx = -1;
|
||||
|
||||
for (int j = 0; j < REQ_COUNT; ++j) {
|
||||
@@ -197,29 +196,27 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
IAEItemStack craftItem = requests[i].itemStack.copy();
|
||||
IAEStack<?> aeItem = null;
|
||||
|
||||
IAEStack<?> craftItem = requests[i].stack.copy();
|
||||
craftItem.setStackSize(batchSize);
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (ThaumicEnergisticsCrafting.isAspectStack(craftItem.getItemStack())) {
|
||||
craftItem = ThaumicEnergisticsCrafting.convertAspectStack(craftItem);
|
||||
if (craftItem instanceof IAEItemStack ais) {
|
||||
if (ModAndClassUtil.ThE && ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
aeItem = ThaumicEnergisticsCrafting.convertAspectStack(ais);
|
||||
} else {
|
||||
aeItem = invItems.findPrecise(ais);
|
||||
}
|
||||
} else if (craftItem instanceof IAEFluidStack afs) {
|
||||
aeItem = invFluid.findPrecise(afs);
|
||||
}
|
||||
|
||||
IAEItemStack aeItem = invItems.findPrecise(craftItem);
|
||||
|
||||
long stackSize;
|
||||
|
||||
if (craftItem.getItem() instanceof ItemFluidDrop) {
|
||||
IAEFluidStack ifs = invFluid.findPrecise(ItemFluidDrop.getAeFluidStack(craftItem));
|
||||
stackSize = ifs == null ? 0 : ifs.getStackSize();
|
||||
} else {
|
||||
stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
}
|
||||
long stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (aeItem != null && ThaumicEnergisticsCrafting.isAspectStack(aeItem.getItemStack())) {
|
||||
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(aeItem, grid);
|
||||
if (aeItem instanceof IAEItemStack ais
|
||||
&& ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(ais, grid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,11 +240,11 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.canEmitFor(craftItem)) {
|
||||
if (craftingGrid.canEmitFor(aeItem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.isRequesting(craftItem)) {
|
||||
if (craftingGrid.isRequesting(aeItem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -338,22 +335,12 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
return isPowered;
|
||||
}
|
||||
|
||||
public IInventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public IInventory getInventoryByName(String name) {
|
||||
if (Objects.equals(name, "config")) return new AeItemStackHandler(this.inventory);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelItemInfo[] getLevelItemInfoList() {
|
||||
return Arrays.stream(this.requests).map(request -> {
|
||||
if (request == null) return null;
|
||||
return new LevelItemInfo(
|
||||
request.itemStack.getItemStack(),
|
||||
request.getAEStack(),
|
||||
request.getQuantity(),
|
||||
request.getBatchSize(),
|
||||
request.getState());
|
||||
@@ -387,11 +374,10 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
public void updateStack(int idx, @Nullable ItemStack stack) {
|
||||
public void updateStack(int idx, @Nullable IAEStack<?> stack) {
|
||||
if (stack == null) {
|
||||
requests[idx] = null;
|
||||
} else {
|
||||
stack = this.removeRecursion(stack);
|
||||
requests[idx] = new RequestInfo(stack, this);
|
||||
}
|
||||
this.saveChanges();
|
||||
@@ -481,7 +467,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
ItemStack craftStack = ItemStack.loadItemStackFromNBT(itemTag.getCompoundTag("Stack"));
|
||||
craftStack = removeRecursion(craftStack);
|
||||
if (craftStack == null) continue;
|
||||
requests[i] = new RequestInfo(craftStack, this);
|
||||
requests[i] = new RequestInfo(Platform.convertStack(AEItemStack.create(craftStack)), this);
|
||||
if (itemTag.hasKey("Enable")) {
|
||||
requests[i].enable = itemTag.getBoolean("Enable");
|
||||
}
|
||||
@@ -522,7 +508,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
for (int i = 0; i < REQ_COUNT; i++) {
|
||||
if (stacks[i] == null) continue;
|
||||
this.requests[i] = new RequestInfo(stacks[i], this);
|
||||
this.requests[i] = new RequestInfo(Platform.convertStack(AEItemStack.create(stacks[i])), this);
|
||||
this.requests[i].batchSize = batches[i];
|
||||
this.requests[i].quantity = quantyties[i];
|
||||
}
|
||||
@@ -631,7 +617,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public static class RequestInfo {
|
||||
|
||||
private final TileLevelMaintainer tile;
|
||||
private @NotNull IAEItemStack itemStack;
|
||||
private @NotNull IAEStack<?> stack;
|
||||
private long quantity;
|
||||
private long batchSize;
|
||||
private boolean enable;
|
||||
@@ -641,9 +627,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
@Nullable
|
||||
private ICraftingLink link;
|
||||
|
||||
public RequestInfo(@NotNull ItemStack stack, TileLevelMaintainer tile) {
|
||||
public RequestInfo(@NotNull IAEStack<?> stack, TileLevelMaintainer tile) {
|
||||
this.tile = tile;
|
||||
itemStack = AEItemStack.create(stack);
|
||||
this.stack = stack.copy();
|
||||
quantity = 0;
|
||||
batchSize = 0;
|
||||
enable = false;
|
||||
@@ -654,8 +640,8 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
public RequestInfo(NBTTagCompound tag, TileLevelMaintainer tile) throws IllegalArgumentException {
|
||||
this.tile = tile;
|
||||
itemStack = AEItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
if (itemStack == null) {
|
||||
stack = Platform.readStackNBT(tag.getCompoundTag(NBT_STACK), true);
|
||||
if (stack == null) {
|
||||
throw new IllegalArgumentException("ItemStack cannot be null!");
|
||||
}
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
@@ -673,7 +659,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
|
||||
public void loadFromNBT(NBTTagCompound tag) {
|
||||
itemStack = AEItemStack.loadItemStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
stack = Platform.readStackNBT(tag.getCompoundTag(NBT_STACK), true);
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
batchSize = tag.getLong(NBT_BATCH);
|
||||
enable = tag.getBoolean(NBT_ENABLE);
|
||||
@@ -690,7 +676,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
public NBTTagCompound writeToNBT(boolean includeLink) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
itemStack.writeToNBT(stackTag);
|
||||
Platform.writeStackNBT(stack, stackTag, true);
|
||||
tag.setTag(NBT_STACK, stackTag);
|
||||
tag.setLong(NBT_QUANTITY, quantity);
|
||||
tag.setLong(NBT_BATCH, batchSize);
|
||||
@@ -704,8 +690,9 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
return tag;
|
||||
}
|
||||
|
||||
public IAEItemStack getAEItemStack() {
|
||||
return this.itemStack;
|
||||
@NotNull
|
||||
public IAEStack<?> getAEStack() {
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public long getQuantity() {
|
||||
@@ -725,43 +712,34 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
|
||||
private static class LevelMaintainerInventory implements AeStackInventory<IAEItemStack> {
|
||||
private class LevelMaintainerInventory extends IAEStackInventory {
|
||||
|
||||
private final RequestInfo[] requests;
|
||||
private final TileLevelMaintainer tile;
|
||||
|
||||
private LevelMaintainerInventory(RequestInfo[] requests, TileLevelMaintainer tile) {
|
||||
this.requests = requests;
|
||||
this.tile = tile;
|
||||
public LevelMaintainerInventory(RequestInfo[] requests) {
|
||||
super(null, requests.length, StorageName.NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Iterator<IAEItemStack> iterator() {
|
||||
return Arrays.stream(requests).map(info -> info != null ? info.itemStack : null).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotCount() {
|
||||
public int getSizeInventory() {
|
||||
return requests.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable IAEItemStack getStack(int slot) {
|
||||
return requests[slot] != null ? requests[slot].itemStack : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStack(int slot, @Nullable IAEItemStack stack) {
|
||||
if (stack == null) {
|
||||
this.tile.updateStack(slot, null);
|
||||
} else {
|
||||
this.tile.updateStack(slot, stack.getItemStack());
|
||||
public IAEStack<?> getAEStackInSlot(int n) {
|
||||
if (requests[n] != null) {
|
||||
return requests[n].stack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<IAEItemStack> stream() {
|
||||
return Arrays.stream(requests).map(info -> info != null ? info.itemStack : null);
|
||||
public void putAEStackInSlot(int slot, IAEStack<?> aes) {
|
||||
updateStack(slot, aes);
|
||||
super.putAEStackInSlot(slot, aes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,13 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AELog;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.me.GridAccessException;
|
||||
@@ -52,7 +55,7 @@ import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable {
|
||||
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable, ITerminalHost {
|
||||
|
||||
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 63);
|
||||
@@ -461,4 +464,19 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
|
||||
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
|
||||
return doWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user