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
@@ -53,7 +53,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.RangedWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
@@ -91,6 +90,7 @@ import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.settings.TickRates;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
@@ -131,10 +131,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final AppEngInternalInventory storage = new AppEngInternalInventory(this, NUMBER_OF_STORAGE_SLOTS);
private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS);
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(
new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
new NullInventory<IAEItemStack>(), Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(
new NullInventory<IAEFluidStack>(),
AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
new NullInventory<IAEFluidStack>(), Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
private final UpgradeInventory upgrades;
private boolean hasConfig = false;
private int priority;
@@ -360,7 +359,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
final ItemStack stored = this.storage.getStackInSlot(slot);
if (req == null && !stored.isEmpty()) {
final IAEItemStack work = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
final IAEItemStack work = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(stored);
this.requireWork[slot] = work.setStackSize(-work.getStackSize());
return;
@@ -379,7 +378,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
} else
// Stored != null; dispose!
{
final IAEItemStack work = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
final IAEItemStack work = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(stored);
this.requireWork[slot] = work.setStackSize(-work.getStackSize());
return;
@@ -433,7 +432,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Override
public boolean canInsert(final ItemStack stack) {
final IAEItemStack out = this.destination.injectItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack),
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack),
Actionable.SIMULATE, null);
if (out == null) {
return true;
@@ -456,9 +455,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
public void gridChanged() {
try {
this.items.setInternal(this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)));
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)));
this.fluids.setInternal(this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
.getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
} catch (final GridAccessException gae) {
this.items.setInternal(new NullInventory<IAEItemStack>());
this.fluids.setInternal(new NullInventory<IAEFluidStack>());
@@ -563,7 +562,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
boolean changed = false;
try {
this.destination = this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IEnergySource src = this.gridProxy.getEnergy();
if (this.craftingTracker.isBusy(x)) {
@@ -663,13 +662,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Override
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
if (channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
if (this.hasConfig()) {
return (IMEMonitor<T>) new InterfaceInventory(this);
}
return (IMEMonitor<T>) this.items;
} else if (channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) {
} else if (channel == Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)) {
if (this.hasConfig()) {
return null;
}
@@ -737,7 +736,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
@Override
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
if (channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
return (IMEMonitor<T>) new InterfaceInventory(di);
}
return null;
@@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableSet;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
@@ -34,6 +33,7 @@ import appeng.api.networking.crafting.ICraftingLink;
import appeng.api.networking.crafting.ICraftingRequester;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.util.InventoryAdaptor;
public class MultiCraftingTracker {
@@ -54,7 +54,7 @@ public class MultiCraftingTracker {
final CompoundNBT link = extra.getCompound("links-" + x);
if (link != null && !link.isEmpty()) {
this.setLink(x, AEApi.instance().storage().loadCraftingLink(link, this.owner));
this.setLink(x, Api.instance().storage().loadCraftingLink(link, this.owner));
}
}
}
@@ -34,11 +34,11 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.ContainerNull;
import appeng.core.Api;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
@@ -92,7 +92,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
this.markItemAs(x, gs, TestStatus.ACCEPT);
}
in.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
in.add(Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
this.testFrame.setInventorySlotContents(x, gs);
}
@@ -101,7 +101,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
if (this.standardRecipe != null) {
this.correctOutput = this.standardRecipe.getCraftingResult(this.crafting);
out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
out.add(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(this.correctOutput));
} else {
throw new IllegalStateException("No pattern here!");
@@ -119,7 +119,7 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable<Patter
}
if (!gs.isEmpty()) {
out.add(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
out.add(Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(gs));
}
}
}
@@ -21,7 +21,6 @@ package appeng.helpers;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
@@ -45,6 +44,7 @@ import appeng.api.storage.data.IItemList;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.core.Api;
import appeng.tile.networking.WirelessTileEntity;
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware {
@@ -73,7 +73,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
try {
final long encKey = Long.parseLong(this.encryptionKey);
obj = AEApi.instance().registries().locatable().getLocatableBy(encKey);
obj = Api.instance().registries().locatable().getLocatableBy(encKey);
} catch (final NumberFormatException err) {
// :P
}
@@ -86,7 +86,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
this.sg = this.targetGrid.getCache(IStorageGrid.class);
if (this.sg != null) {
this.itemStorage = this.sg
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
}
}
}
@@ -198,7 +198,7 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
if (this.itemStorage != null) {
return this.itemStorage.getChannel();
}
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
@Override