Removed AEApi

Moved all internal access to the internal `Api` class using a new static
getter.
This commit is contained in:
yueh
2020-07-11 19:40:34 +02:00
parent d18eabe1fc
commit 0d43ca15be
168 changed files with 757 additions and 677 deletions
@@ -37,7 +37,6 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
@@ -62,6 +61,7 @@ import appeng.api.util.IConfigManager;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.InterfaceContainer;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
@@ -270,7 +270,7 @@ public class InterfacePart extends BasicStatePart implements IGridTickable, ISto
@Override
public ItemStack getItemStackRepresentation() {
return AEApi.instance().definitions().parts().iface().maybeStack(1).orElse(ItemStack.EMPTY);
return Api.instance().definitions().parts().iface().maybeStack(1).orElse(ItemStack.EMPTY);
}
@Override
@@ -28,7 +28,6 @@ import java.util.Map;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IBaseMonitor;
@@ -39,6 +38,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.me.GridAccessException;
import appeng.me.helpers.IGridProxyable;
import appeng.me.storage.ITickingMonitor;
@@ -191,7 +191,7 @@ class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAE
@Override
public IItemStorageChannel getChannel() {
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
@Override
@@ -26,7 +26,6 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import appeng.api.AEApi;
import appeng.api.config.Settings;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
@@ -41,6 +40,7 @@ import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.core.Api;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.parts.automation.UpgradeablePart;
@@ -83,7 +83,7 @@ public abstract class SharedStorageBusPart extends UpgradeablePart
* @return Storage channel
*/
public IStorageChannel getStorageChannel() {
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
protected abstract void resetCache();
@@ -37,7 +37,6 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.IncludeExclude;
@@ -76,6 +75,7 @@ import appeng.capabilities.Capabilities;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.StorageBusContainer;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.settings.TickRates;
import appeng.helpers.IInterfaceHost;
@@ -235,7 +235,7 @@ public class StorageBusPart extends UpgradeablePart
try {
if (this.getProxy().isActive()) {
this.getProxy().getStorage().postAlterationOfStoredItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class), change, this.mySrc);
Api.instance().storage().getStorageChannel(IItemStorageChannel.class), change, this.mySrc);
}
} catch (final GridAccessException e) {
// :(
@@ -306,7 +306,7 @@ public class StorageBusPart extends UpgradeablePart
this.resetCacheLogic = 0;
final IMEInventory<IAEItemStack> in = this.getInternalHandler();
IItemList<IAEItemStack> before = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
IItemList<IAEItemStack> before = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
if (in != null) {
before = in.getAvailableItems(before);
@@ -320,7 +320,7 @@ public class StorageBusPart extends UpgradeablePart
final IMEInventory<IAEItemStack> out = this.getInternalHandler();
if (in != out) {
IItemList<IAEItemStack> after = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
IItemList<IAEItemStack> after = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
if (out != null) {
after = out.getAvailableItems(after);
@@ -341,7 +341,7 @@ public class StorageBusPart extends UpgradeablePart
IStorageMonitorableAccessor accessor = accessorOpt.orElse(null);
IStorageMonitorable inventory = accessor.getInventory(this.mySrc);
if (inventory != null) {
return inventory.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
return inventory.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
}
// So this could / can be a design decision. If the tile does support our custom
@@ -427,14 +427,14 @@ public class StorageBusPart extends UpgradeablePart
this.checkInterfaceVsStorageBus(target, this.getSide().getOpposite());
this.handler = new MEInventoryHandler<IAEItemStack>(inv,
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
this.handler.setBaseAccess((AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
this.handler.setWhitelist(this.getInstalledUpgrades(Upgrades.INVERTER) > 0 ? IncludeExclude.BLACKLIST
: IncludeExclude.WHITELIST);
this.handler.setPriority(this.priority);
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage()
final IItemList<IAEItemStack> priorityList = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9;
@@ -507,7 +507,7 @@ public class StorageBusPart extends UpgradeablePart
@Override
public List<IMEInventoryHandler> getCellArray(final IStorageChannel channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
if (channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
final IMEInventoryHandler<IAEItemStack> out = this.getProxy().isActive() ? this.getInternalHandler() : null;
if (out != null) {
return Collections.singletonList(out);
@@ -559,7 +559,7 @@ public class StorageBusPart extends UpgradeablePart
@Override
public ItemStack getItemStackRepresentation() {
return AEApi.instance().definitions().parts().storageBus().maybeStack(1).orElse(ItemStack.EMPTY);
return Api.instance().definitions().parts().storageBus().maybeStack(1).orElse(ItemStack.EMPTY);
}
@Override
@@ -29,7 +29,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import appeng.api.AEApi;
import appeng.api.exceptions.FailedConnectionException;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode;
@@ -39,6 +38,7 @@ import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
@@ -168,7 +168,7 @@ public class ToggleBusPart extends BasicStatePart {
if (this.getProxy().getNode() != null && this.getOuterProxy().getNode() != null) {
if (intention) {
try {
this.connection = AEApi.instance().grid().createGridConnection(this.getProxy().getNode(),
this.connection = Api.instance().grid().createGridConnection(this.getProxy().getNode(),
this.getOuterProxy().getNode());
} catch (final FailedConnectionException e) {
// :(