Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6632344f87 | |||
| 724f3baf4c | |||
| f7562db2e9 |
@@ -54,19 +54,12 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.*;
|
||||
|
||||
import static appeng.client.render.BlockPosHighlighter.hilightBlock;
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
@@ -116,7 +109,7 @@ public class GuiInterfaceTerminal extends AEBaseGui {
|
||||
this.setScrollBar(scrollbar);
|
||||
this.xSize = 208;
|
||||
this.ySize = 255;
|
||||
this.jeiEnabled = Loader.isModLoaded("jei");
|
||||
this.jeiEnabled = Platform.isModLoaded("jei");
|
||||
this.jeiButtonPadding = jeiEnabled ? 22 : 0;
|
||||
|
||||
searchFieldInputs = createTextField(86, 12, ButtonToolTips.SearchFieldInputs.getLocal());
|
||||
|
||||
@@ -31,11 +31,7 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.client.me.SlotME;
|
||||
@@ -61,7 +57,6 @@ import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
@@ -103,7 +98,7 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private int currentMouseY = 0;
|
||||
private boolean delayedUpdate;
|
||||
|
||||
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
|
||||
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
|
||||
|
||||
public GuiMEMonitorable(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
this(inventoryPlayer, te, new ContainerMEMonitorable(inventoryPlayer, te));
|
||||
@@ -177,10 +172,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi
|
||||
NetworkHandler.instance().sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
|
||||
}
|
||||
|
||||
if (btn instanceof GuiImgButton) {
|
||||
if (btn instanceof GuiImgButton iBtn) {
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
|
||||
final GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if (iBtn.getSetting() != Settings.ACTIONS) {
|
||||
final Enum cv = iBtn.getCurrentValue();
|
||||
final Enum next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
|
||||
|
||||
@@ -46,7 +46,6 @@ import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
@@ -66,7 +65,6 @@ import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -89,7 +87,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
private IConfigManagerHost gui;
|
||||
private IConfigManager serverCM;
|
||||
private IGridNode networkNode;
|
||||
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
|
||||
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
|
||||
|
||||
|
||||
public ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
|
||||
@@ -30,13 +30,13 @@ import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.misc.TileSecurityStation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
@GuiSync(0)
|
||||
public int permissionMode = 0;
|
||||
|
||||
protected int jeiOffset = Loader.isModLoaded("jei") ? 24 : 0;
|
||||
protected int jeiOffset = Platform.isModLoaded("jei") ? 24 : 0;
|
||||
|
||||
public ContainerSecurityStation(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
@@ -75,8 +75,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
final SecurityPermissions permission = SecurityPermissions.valueOf(value);
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard bc) {
|
||||
if (bc.hasPermission(a, permission)) {
|
||||
bc.removePermission(a, permission);
|
||||
} else {
|
||||
@@ -95,8 +94,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
|
||||
this.setPermissionMode(0);
|
||||
|
||||
final ItemStack a = this.configSlot.getStack();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard) {
|
||||
final IBiometricCard bc = (IBiometricCard) a.getItem();
|
||||
if (!a.isEmpty() && a.getItem() instanceof IBiometricCard bc) {
|
||||
|
||||
for (final SecurityPermissions sp : bc.getPermissions(a)) {
|
||||
this.setPermissionMode(this.getPermissionMode() | (1 << sp.ordinal()));
|
||||
|
||||
@@ -41,9 +41,6 @@ import appeng.util.inv.WrapperCursorItemHandler;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.blamejared.recipestages.recipes.RecipeStage;
|
||||
import net.darkhax.gamestages.GameStageHelper;
|
||||
import net.darkhax.itemstages.ItemStages;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -53,9 +50,6 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -157,8 +151,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
protected IRecipe findRecipe(InventoryCrafting ic, World world, EntityPlayer player) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
if (this.container instanceof ContainerCraftingTerm containerTerminal) {
|
||||
final IRecipe recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
@@ -171,9 +164,8 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
|
||||
// Returns null in case this recipe is not yet unlocked
|
||||
private IRecipe handleRecipe(InventoryCrafting ic, IRecipe recipe, EntityPlayer player) {
|
||||
if (Loader.isModLoaded("recipestages")) {
|
||||
if (recipe instanceof RecipeStage) {
|
||||
final RecipeStage staged = (RecipeStage) recipe;
|
||||
if (Platform.isModLoaded("recipestages")) {
|
||||
if (recipe instanceof RecipeStage staged) {
|
||||
if (!staged.isGoodForCrafting(ic))
|
||||
return null;
|
||||
}
|
||||
@@ -185,8 +177,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot {
|
||||
// TODO: This is really hacky and NEEDS to be solved with a full container/gui refactoring.
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getRemainingItems(InventoryCrafting ic, World world) {
|
||||
if (this.container instanceof ContainerCraftingTerm) {
|
||||
final ContainerCraftingTerm containerTerminal = (ContainerCraftingTerm) this.container;
|
||||
if (this.container instanceof ContainerCraftingTerm containerTerminal) {
|
||||
final IRecipe recipe = containerTerminal.getCurrentRecipe();
|
||||
|
||||
if (recipe != null && recipe.matches(ic, world)) {
|
||||
|
||||
@@ -14,7 +14,6 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
|
||||
public class PacketTerminalUse extends AppEngPacket {
|
||||
@@ -45,7 +44,7 @@ public class PacketTerminalUse extends AppEngPacket {
|
||||
|
||||
}
|
||||
}
|
||||
if (Loader.isModLoaded("baubles")) {
|
||||
if (Platform.isModLoaded("baubles")) {
|
||||
tryOpenBauble(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -49,6 +50,7 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.fluids.util.AEFluidInventory;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.AENetworkFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidInventory;
|
||||
import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
@@ -90,6 +92,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
@@ -109,7 +112,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
private final UpgradeInventory upgrades;
|
||||
private boolean hasConfig = false;
|
||||
private final IStorageMonitorableAccessor accessor = this::getMonitorable;
|
||||
private final AEFluidInventory tanks = new AEFluidInventory(this, NUMBER_OF_TANKS, TANK_CAPACITY);
|
||||
private final AEFluidInventory tanks;
|
||||
private final AEFluidInventory config = new AEFluidInventory(this, NUMBER_OF_TANKS);
|
||||
private final IAEFluidStack[] requireWork;
|
||||
private int isWorking = -1;
|
||||
@@ -131,6 +134,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
this.mySource = new MachineSource(this.iHost);
|
||||
this.interfaceRequestSource = new InterfaceRequestSource(this.iHost);
|
||||
this.tanks = new AENetworkFluidInventory(this::getStorageGrid, this.mySource, this, NUMBER_OF_TANKS, TANK_CAPACITY);
|
||||
|
||||
this.fluids.setChangeSource(this.mySource);
|
||||
this.items.setChangeSource(this.mySource);
|
||||
@@ -141,6 +145,15 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IStorageGrid getStorageGrid() {
|
||||
try {
|
||||
return this.gridProxy.getStorage();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IUpgradeableHost getHost() {
|
||||
return this.iHost;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package appeng.fluids.util;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AENetworkFluidInventory extends AEFluidInventory {
|
||||
|
||||
private final Supplier<IStorageGrid> supplier;
|
||||
private final IActionSource source;
|
||||
|
||||
public AENetworkFluidInventory(Supplier<IStorageGrid> networkSupplier, IActionSource source, IAEFluidInventory handler, int slots, int capcity) {
|
||||
super(handler, slots, capcity);
|
||||
this.supplier = networkSupplier;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(final FluidStack fluid, final boolean doFill) {
|
||||
if (fluid == null || fluid.amount <= 0) {
|
||||
return 0;
|
||||
}
|
||||
IStorageGrid storage = supplier.get();
|
||||
if (storage != null) {
|
||||
int originAmt = fluid.amount;
|
||||
IMEInventory<IAEFluidStack> dest = storage.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
IAEFluidStack overflow = dest.injectItems(AEFluidStack.fromFluidStack(fluid), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.source);
|
||||
if (overflow != null && overflow.getStackSize() == originAmt) {
|
||||
return super.fill(fluid, doFill);
|
||||
} else if (overflow != null) {
|
||||
return (int) (originAmt - overflow.getStackSize());
|
||||
} else {
|
||||
return originAmt;
|
||||
}
|
||||
} else {
|
||||
return super.fill(fluid, doFill);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.events.MENetworkCraftingPatternChange;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
@@ -64,8 +65,12 @@ import appeng.parts.misc.PartInterface;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.AppEngInternalOversizedInventory;
|
||||
import appeng.tile.inventory.AppEngNetworkInventory;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.*;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.*;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -88,7 +93,6 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.RangedWrapper;
|
||||
@@ -98,7 +102,8 @@ import java.util.*;
|
||||
|
||||
import static appeng.api.config.LockCraftingMode.LOCK_UNTIL_PULSE;
|
||||
import static appeng.api.config.LockCraftingMode.LOCK_UNTIL_RESULT;
|
||||
import static appeng.helpers.ItemStackHelper.*;
|
||||
import static appeng.helpers.ItemStackHelper.stackFromNBT;
|
||||
import static appeng.helpers.ItemStackHelper.stackToNBT;
|
||||
|
||||
|
||||
public class DualityInterface implements IGridTickable, IStorageMonitorable, IInventoryDestination, IAEAppEngInventory, IConfigManagerHost, ICraftingProvider, IUpgradeableHost {
|
||||
@@ -115,7 +120,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
private final IActionSource interfaceRequestSource;
|
||||
private final ConfigManager cm = new ConfigManager(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, NUMBER_OF_CONFIG_SLOTS, 512);
|
||||
private final AppEngInternalInventory storage = new AppEngInternalOversizedInventory(this, NUMBER_OF_STORAGE_SLOTS, 512);
|
||||
private final AppEngInternalInventory storage;
|
||||
private final AppEngInternalInventory patterns = new AppEngInternalInventory(this, NUMBER_OF_PATTERN_SLOTS, 1);
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(new NullInventory<IAEFluidStack>(), AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
|
||||
@@ -153,12 +158,22 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
final MachineSource actionSource = new MachineSource(this.iHost);
|
||||
this.mySource = actionSource;
|
||||
this.storage = new AppEngNetworkInventory(this::getStorageGrid, this.mySource, this, NUMBER_OF_STORAGE_SLOTS, 512);
|
||||
this.fluids.setChangeSource(actionSource);
|
||||
this.items.setChangeSource(actionSource);
|
||||
|
||||
this.interfaceRequestSource = new InterfaceRequestSource(this.iHost);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IStorageGrid getStorageGrid() {
|
||||
try {
|
||||
return this.gridProxy.getStorage();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean invIsCustomBlocking(BlockingInventoryAdaptor inv) {
|
||||
return (inv.containsBlockingItems());
|
||||
}
|
||||
@@ -525,8 +540,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
return;
|
||||
}
|
||||
|
||||
if (is.getItem() instanceof ICraftingPatternItem) {
|
||||
final ICraftingPatternItem cpi = (ICraftingPatternItem) is.getItem();
|
||||
if (is.getItem() instanceof ICraftingPatternItem cpi) {
|
||||
final ICraftingPatternDetails details = cpi.getPatternForItem(is, this.iHost.getTileEntity().getWorld());
|
||||
|
||||
if (details != null) {
|
||||
@@ -1068,8 +1082,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
continue;
|
||||
}
|
||||
|
||||
if (te instanceof ICraftingMachine) {
|
||||
final ICraftingMachine cm = (ICraftingMachine) te;
|
||||
if (te instanceof ICraftingMachine cm) {
|
||||
if (cm.acceptsPlans()) {
|
||||
visitedFaces.remove(s);
|
||||
if (cm.pushPattern(patternDetails, table, s.getOpposite())) {
|
||||
@@ -1084,7 +1097,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
if (ad != null) {
|
||||
if (this.isBlocking()) {
|
||||
IPhantomTile phantomTE;
|
||||
if (Loader.isModLoaded("actuallyadditions") && te instanceof IPhantomTile) {
|
||||
if (Platform.isModLoaded("actuallyadditions") && te instanceof IPhantomTile) {
|
||||
phantomTE = ((IPhantomTile) te);
|
||||
if (phantomTE.hasBoundPosition()) {
|
||||
TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition());
|
||||
@@ -1224,8 +1237,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor(te, s.getOpposite());
|
||||
if (ad != null) {
|
||||
if (Loader.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile) {
|
||||
IPhantomTile phantomTE = ((IPhantomTile) te);
|
||||
if (Platform.isModLoaded("actuallyadditions") && Platform.GTLoaded && te instanceof IPhantomTile phantomTE) {
|
||||
if (phantomTE.hasBoundPosition()) {
|
||||
TileEntity phantom = w.getTileEntity(phantomTE.getBoundPosition());
|
||||
if (NonBlockingItems.INSTANCE.getMap().containsKey(w.getBlockState(phantomTE.getBoundPosition()).getBlock().getRegistryName().getNamespace())) {
|
||||
@@ -1453,7 +1465,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
|
||||
|
||||
public long getSortValue() {
|
||||
final TileEntity te = this.iHost.getTileEntity();
|
||||
return (te.getPos().getZ() << 24) ^ (te.getPos().getX() << 8) ^ te.getPos().getY();
|
||||
return ((long) te.getPos().getZ() << 24) ^ ((long) te.getPos().getX() << 8) ^ te.getPos().getY();
|
||||
}
|
||||
|
||||
public void initialize() {
|
||||
|
||||
@@ -9,7 +9,6 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@@ -24,65 +23,30 @@ public class NonBlockingItems {
|
||||
private NonBlockingItems() {
|
||||
String[] strings = AEConfig.instance().getNonBlockingItems();
|
||||
String[] modids = new String[0];
|
||||
if (strings.length > 0) {
|
||||
for (String s : strings) {
|
||||
if (s.startsWith("[") && s.endsWith("]")) {
|
||||
modids = s.substring(1, s.length() - 1).split("\\|");
|
||||
} else {
|
||||
for (String modid : modids) {
|
||||
if (!Loader.isModLoaded(modid)) {
|
||||
continue;
|
||||
}
|
||||
NON_BLOCKING_MAP.putIfAbsent(modid, new Object2ObjectOpenHashMap<>());
|
||||
for (String s : strings) {
|
||||
if (s.startsWith("[") && s.endsWith("]")) {
|
||||
modids = s.substring(1, s.length() - 1).split("\\|");
|
||||
} else {
|
||||
for (String modid : modids) {
|
||||
if (!Platform.isModLoaded(modid)) {
|
||||
continue;
|
||||
}
|
||||
NON_BLOCKING_MAP.putIfAbsent(modid, new Object2ObjectOpenHashMap<>());
|
||||
|
||||
String[] ModItemMeta = s.split(":");
|
||||
String[] ModItemMeta = s.split(":");
|
||||
|
||||
if (ModItemMeta.length < 2 || ModItemMeta.length > 3) {
|
||||
AELog.error("Invalid non blocking item entry: " + s);
|
||||
continue;
|
||||
}
|
||||
if (ModItemMeta.length < 2 || ModItemMeta.length > 3) {
|
||||
AELog.error("Invalid non blocking item entry: " + s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) {
|
||||
boolean found = false;
|
||||
for (MetaItem<?> metaItem : MetaItem.getMetaItems()) {
|
||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]);
|
||||
if (metaItem.getItem(ModItemMeta[1]) != null) {
|
||||
found = true;
|
||||
ItemStack itemStack = metaItem2.getStackForm();
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
} else {
|
||||
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
|
||||
if (!itemStack.isEmpty()) {
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
AELog.error("Item not found on nonBlocking config: " + s);
|
||||
}
|
||||
} else if (ModItemMeta[0].equals("ore")) {
|
||||
OreDictionary.getOres(ModItemMeta[1]).forEach(itemStack ->
|
||||
{
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
|
||||
if (!itemStack.isEmpty()) {
|
||||
if (ModItemMeta[0].equals("gregtech") && Platform.GTLoaded) {
|
||||
boolean found = false;
|
||||
for (MetaItem<?> metaItem : MetaItem.getMetaItems()) {
|
||||
MetaItem<?>.MetaValueItem metaItem2 = metaItem.getItem(ModItemMeta[1]);
|
||||
if (metaItem.getItem(ModItemMeta[1]) != null) {
|
||||
found = true;
|
||||
ItemStack itemStack = metaItem2.getStackForm();
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
@@ -90,9 +54,42 @@ public class NonBlockingItems {
|
||||
return intSet;
|
||||
});
|
||||
} else {
|
||||
AELog.error("Item not found on nonBlocking config: " + s);
|
||||
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
|
||||
if (!itemStack.isEmpty()) {
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
AELog.error("Item not found on nonBlocking config: " + s);
|
||||
}
|
||||
} else if (ModItemMeta[0].equals("ore")) {
|
||||
OreDictionary.getOres(ModItemMeta[1]).forEach(itemStack ->
|
||||
{
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ItemStack itemStack = GameRegistry.makeItemStack(ModItemMeta[0] + ":" + ModItemMeta[1], ModItemMeta.length == 3 ? Integer.parseInt(ModItemMeta[2]) : 0, 1, null);
|
||||
if (!itemStack.isEmpty()) {
|
||||
NON_BLOCKING_MAP.get(modid).putIfAbsent(itemStack.getItem(), new IntOpenHashSet());
|
||||
NON_BLOCKING_MAP.get(modid).computeIfPresent(itemStack.getItem(), (item, intSet) ->
|
||||
{
|
||||
intSet.add(itemStack.getItemDamage());
|
||||
return intSet;
|
||||
});
|
||||
} else {
|
||||
AELog.error("Item not found on nonBlocking config: " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package appeng.integration;
|
||||
import appeng.api.exceptions.ModNotInstalledException;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.fml.common.ModAPIManager;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ final class IntegrationNode {
|
||||
switch (stage) {
|
||||
case PRE_INIT:
|
||||
final ModAPIManager apiManager = ModAPIManager.INSTANCE;
|
||||
boolean enabled = this.modID == null || Loader.isModLoaded(this.modID) || apiManager.hasAPI(this.modID);
|
||||
boolean enabled = this.modID == null || Platform.isModLoaded(this.modID) || apiManager.hasAPI(this.modID);
|
||||
|
||||
AEConfig.instance()
|
||||
.addCustomCategoryComment("ModIntegration",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package appeng.integration.modules.bogosorter;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.Platform;
|
||||
import com.cleanroommc.bogosorter.common.sort.SortHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class InventoryBogoSortModule {
|
||||
private static final boolean loaded = Loader.isModLoaded("bogosorter");
|
||||
private static final boolean loaded = Platform.isModLoaded("bogosorter");
|
||||
|
||||
public static final Comparator<IAEItemStack> COMPARATOR = (o1, o2) -> SortHandler.getClientItemComparator().compare(o1.getDefinition(), o2.getDefinition());
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import appeng.core.AppEng;
|
||||
import appeng.services.version.*;
|
||||
import appeng.services.version.github.FormattedRelease;
|
||||
import appeng.services.version.github.ReleaseFetcher;
|
||||
import appeng.util.Platform;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.event.FMLInterModComms;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -82,7 +82,7 @@ public final class VersionChecker implements Runnable {
|
||||
final long lastCheck = Long.parseLong(rawLastCheck);
|
||||
final Date now = new Date();
|
||||
final long nowInMs = now.getTime();
|
||||
final long intervalInMs = this.config.interval() * SEC_TO_HOUR * MS_TO_SEC;
|
||||
final long intervalInMs = (long) this.config.interval() * SEC_TO_HOUR * MS_TO_SEC;
|
||||
final long lastAfterInterval = lastCheck + intervalInMs;
|
||||
|
||||
this.processInterval(nowInMs, lastAfterInterval);
|
||||
@@ -153,7 +153,7 @@ public final class VersionChecker implements Runnable {
|
||||
* @param changelog retrieved github changelog
|
||||
*/
|
||||
private void interactWithVersionCheckerMod(@Nonnull final String modFormatted, @Nonnull final String ghFormatted, @Nonnull final String changelog) {
|
||||
if (Loader.isModLoaded("VersionChecker")) {
|
||||
if (Platform.isModLoaded("VersionChecker")) {
|
||||
final NBTTagCompound versionInf = new NBTTagCompound();
|
||||
versionInf.setString("modDisplayName", AppEng.MOD_NAME);
|
||||
versionInf.setString("oldVersion", modFormatted);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package appeng.tile.inventory;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AppEngNetworkInventory extends AppEngInternalOversizedInventory {
|
||||
|
||||
private final Supplier<IStorageGrid> supplier;
|
||||
private final IActionSource source;
|
||||
|
||||
public AppEngNetworkInventory(Supplier<IStorageGrid> networkSupplier, IActionSource source, IAEAppEngInventory inventory, int size, int maxStack) {
|
||||
super(inventory, size, maxStack);
|
||||
this.supplier = networkSupplier;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
IStorageGrid storage = supplier.get();
|
||||
if (storage != null) {
|
||||
int originAmt = stack.getCount();
|
||||
IMEInventory<IAEItemStack> dest = storage.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
IAEItemStack overflow = dest.injectItems(AEItemStack.fromItemStack(stack), simulate ? Actionable.SIMULATE : Actionable.MODULATE, this.source);
|
||||
if (overflow != null && overflow.getStackSize() == originAmt) {
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
} else if (overflow != null) {
|
||||
return overflow.createItemStack();
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else {
|
||||
return super.insertItem(slot, stack, simulate);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,6 +73,8 @@ import gregtech.api.block.machines.BlockMachine;
|
||||
import gregtech.api.metatileentity.MetaTileEntity;
|
||||
import gregtech.api.util.GTUtility;
|
||||
import ic2.api.item.ICustomDamageItem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -106,7 +108,6 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.ModContainer;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -130,6 +131,7 @@ import java.util.*;
|
||||
*/
|
||||
@Optional.Interface(iface = "ic2.api.item.ICustomDamageItem", modid = "IC2")
|
||||
public class Platform {
|
||||
private static final Object2BooleanMap<String> CACHED_MODS = new Object2BooleanOpenHashMap<>();
|
||||
|
||||
public static final Block AIR_BLOCK = Blocks.AIR;
|
||||
|
||||
@@ -526,18 +528,15 @@ public class Platform {
|
||||
}
|
||||
|
||||
public static boolean isModLoaded(final String modid) {
|
||||
try {
|
||||
// if this fails for some reason, try the other method.
|
||||
return Loader.isModLoaded(modid);
|
||||
} catch (final Throwable ignored) {
|
||||
}
|
||||
return CACHED_MODS.computeIfAbsent(modid, (k) -> {
|
||||
try {
|
||||
// if this fails for some reason, try the other method.
|
||||
return Loader.isModLoaded(k);
|
||||
} catch (final Throwable ignored) {}
|
||||
|
||||
for (final ModContainer f : Loader.instance().getActiveModList()) {
|
||||
if (f.getModId().equals(modid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return Loader.instance().getActiveModList()
|
||||
.stream().anyMatch(mod -> mod.getModId().equals(k));
|
||||
});
|
||||
}
|
||||
|
||||
public static ItemStack findMatchingRecipeOutput(final InventoryCrafting ic, final World world) {
|
||||
@@ -551,8 +550,7 @@ public class Platform {
|
||||
}
|
||||
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
if (o instanceof AEItemStack) {
|
||||
final AEItemStack ais = (AEItemStack) o;
|
||||
if (o instanceof AEItemStack ais) {
|
||||
return ais.getToolTip();
|
||||
} else if (o instanceof ItemStack) {
|
||||
itemStack = (ItemStack) o;
|
||||
@@ -655,8 +653,7 @@ public class Platform {
|
||||
|
||||
}
|
||||
|
||||
if (eq.getItem() instanceof IAEWrench) {
|
||||
final IAEWrench wrench = (IAEWrench) eq.getItem();
|
||||
if (eq.getItem() instanceof IAEWrench wrench) {
|
||||
return wrench.canWrench(eq, player, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,16 @@
|
||||
|
||||
package appeng.util.item;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class AEItemStackRegistry {
|
||||
private static final WeakHashMap<AESharedItemStack, WeakReference<AESharedItemStack>> REGISTRY = new WeakHashMap<>();
|
||||
|
||||
private static final ItemStackHashStrategy HASH_STRATEGY = ItemStackHashStrategy.comparingAllButCount();
|
||||
private static final Map<Integer, AESharedItemStack> REGISTRY = new MapMaker().weakValues().makeMap();
|
||||
|
||||
private AEItemStackRegistry() {
|
||||
}
|
||||
@@ -40,23 +42,18 @@ public final class AEItemStackRegistry {
|
||||
throw new IllegalArgumentException("stack cannot be empty");
|
||||
}
|
||||
|
||||
int oldStackSize = itemStack.getCount();
|
||||
itemStack.setCount(1);
|
||||
|
||||
AESharedItemStack search = new AESharedItemStack(itemStack);
|
||||
WeakReference<AESharedItemStack> weak = REGISTRY.get(search);
|
||||
AESharedItemStack ret = null;
|
||||
|
||||
if (weak != null) {
|
||||
ret = weak.get();
|
||||
var hash = HASH_STRATEGY.hashCode(itemStack);
|
||||
var ret = REGISTRY.get(hash);
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ret == null) {
|
||||
ret = new AESharedItemStack(itemStack.copy());
|
||||
REGISTRY.put(ret, new WeakReference<>(ret));
|
||||
}
|
||||
itemStack.setCount(oldStackSize);
|
||||
|
||||
return ret;
|
||||
// computeIfAbsent is not feasible since new AESharedItemStack gets
|
||||
// instantly GC'd when leaving the lambda.
|
||||
var itemStackCopy = itemStack.copy();
|
||||
itemStackCopy.setCount(1);
|
||||
var sharedStack = new AESharedItemStack(itemStackCopy);
|
||||
REGISTRY.put(hash, sharedStack);
|
||||
return sharedStack;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user