mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
Merge branch 'master' into fixs
This commit is contained in:
194 files changed
+5678
-5310
No files matched your search
@@ -16,11 +16,10 @@ import appeng.me.storage.MEPassThrough;
|
||||
import appeng.parts.p2p.PartP2PLiquids;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import appeng.util.prioitylist.IPartitionList;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class Ae2Reflect {
|
||||
|
||||
@@ -54,7 +53,8 @@ public class Ae2Reflect {
|
||||
fContainerUpgradeable_upgradeable = Ae2Reflect.reflectField(ContainerUpgradeable.class, "upgradeable");
|
||||
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
|
||||
mCPU_getGrid = reflectMethod(CraftingCPUCluster.class, "getGrid");
|
||||
mCPU_postChange = reflectMethod(CraftingCPUCluster.class, "postChange", IAEItemStack.class, BaseActionSource.class);
|
||||
mCPU_postChange =
|
||||
reflectMethod(CraftingCPUCluster.class, "postChange", IAEItemStack.class, BaseActionSource.class);
|
||||
mCPU_markDirty = reflectMethod(CraftingCPUCluster.class, "markDirty");
|
||||
mP2PLiquids_getTarget = reflectMethod(PartP2PLiquids.class, "getTarget");
|
||||
} catch (Exception e) {
|
||||
@@ -62,20 +62,20 @@ public class Ae2Reflect {
|
||||
}
|
||||
}
|
||||
|
||||
public static Method reflectMethod(Class<?> owner, String name, Class<?>... paramTypes) throws NoSuchMethodException {
|
||||
public static Method reflectMethod(Class<?> owner, String name, Class<?>... paramTypes)
|
||||
throws NoSuchMethodException {
|
||||
Method m = owner.getDeclaredMethod(name, paramTypes);
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
|
||||
public static Field reflectField(Class<?> owner, String ...names) throws NoSuchFieldException {
|
||||
public static Field reflectField(Class<?> owner, String... names) throws NoSuchFieldException {
|
||||
Field f = null;
|
||||
for (String name : names) {
|
||||
try {
|
||||
f = owner.getDeclaredField(name);
|
||||
if (f != null) break;
|
||||
}
|
||||
catch (NoSuchFieldException ignore) {
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
}
|
||||
}
|
||||
if (f == null) throw new NoSuchFieldException("Can't find field from " + Arrays.toString(names));
|
||||
@@ -86,7 +86,7 @@ public class Ae2Reflect {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T readField(Object owner, Field field) {
|
||||
try {
|
||||
return (T)field.get(owner);
|
||||
return (T) field.get(owner);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to read field: " + field);
|
||||
}
|
||||
@@ -183,5 +183,4 @@ public class Ae2Reflect {
|
||||
throw new IllegalStateException("Failed to invoke method: " + mP2PLiquids_getTarget, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,13 +6,12 @@ import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Ae2ReflectClient {
|
||||
@@ -23,7 +22,6 @@ public class Ae2ReflectClient {
|
||||
private static final Field fGui_drag;
|
||||
private static final Method mGuiPatternTerm_inventorySlots;
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
fAEBaseGui_stackSizeRenderer = Ae2Reflect.reflectField(AEBaseGui.class, "aeRenderItem");
|
||||
@@ -60,5 +58,4 @@ public class Ae2ReflectClient {
|
||||
public static GuiTabButton getOriginalGuiButton(GuiCraftingStatus gui) {
|
||||
return Ae2Reflect.readField(gui, fGuiCraftingStatus_originalGuiBtn);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockPos {
|
||||
|
||||
private final int x;
|
||||
@@ -70,5 +69,4 @@ public class BlockPos {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -43,9 +44,13 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DualityFluidInterface implements IGridTickable, IStorageMonitorable, IAEFluidInventory, IUpgradeableHost, IConfigManagerHost, IFluidHandler {
|
||||
public class DualityFluidInterface
|
||||
implements IGridTickable,
|
||||
IStorageMonitorable,
|
||||
IAEFluidInventory,
|
||||
IUpgradeableHost,
|
||||
IConfigManagerHost,
|
||||
IFluidHandler {
|
||||
|
||||
public static final int NUMBER_OF_TANKS = 6;
|
||||
public static final long TANK_CAPACITY = 16000;
|
||||
@@ -55,11 +60,13 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
private final BaseActionSource mySource;
|
||||
private boolean hasConfig = false;
|
||||
private final AEFluidInventory tanks = new AEFluidInventory(this, NUMBER_OF_TANKS, (int) TANK_CAPACITY);
|
||||
private final AEFluidInventory config = new AEFluidInventory( this, NUMBER_OF_TANKS, Integer.MAX_VALUE );
|
||||
private final AEFluidInventory config = new AEFluidInventory(this, NUMBER_OF_TANKS, Integer.MAX_VALUE);
|
||||
private final IAEFluidStack[] requireWork;
|
||||
private int isWorking = -1;
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<IAEItemStack>( new NullInventory<IAEItemStack>(), StorageChannel.ITEMS );
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<IAEFluidStack>(new NullInventory<>(), StorageChannel.FLUIDS );
|
||||
private final MEMonitorPassThrough<IAEItemStack> items =
|
||||
new MEMonitorPassThrough<IAEItemStack>(new NullInventory<IAEItemStack>(), StorageChannel.ITEMS);
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids =
|
||||
new MEMonitorPassThrough<IAEFluidStack>(new NullInventory<>(), StorageChannel.FLUIDS);
|
||||
private boolean resetConfigCache = true;
|
||||
|
||||
public DualityFluidInterface(final AENetworkProxy networkProxy, final IInterfaceHost ih) {
|
||||
@@ -71,7 +78,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
this.items.setChangeSource(this.mySource);
|
||||
this.requireWork = new IAEFluidStack[6];
|
||||
|
||||
for(int i = 0; i < 6; ++i) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
this.requireWork[i] = null;
|
||||
}
|
||||
}
|
||||
@@ -79,8 +86,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
public IAEFluidStack getStandardFluid(IAEFluidStack fluid) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AEFluidStack.create(new FluidStack(fluid.getFluid(), 8000));
|
||||
}
|
||||
}
|
||||
@@ -88,8 +94,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
public IAEFluidStack getStandardFluid(FluidStack fluid) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return AEFluidStack.create(new FluidStack(fluid.getFluid(), 8000));
|
||||
}
|
||||
}
|
||||
@@ -134,7 +139,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
private IMEMonitor<IAEFluidStack> getFluidGrid() {
|
||||
try {
|
||||
return gridProxy.getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
|
||||
return gridProxy
|
||||
.getGrid()
|
||||
.<IStorageGrid>getCache(IStorageGrid.class)
|
||||
.getFluidInventory();
|
||||
} catch (GridAccessException e) {
|
||||
return null;
|
||||
}
|
||||
@@ -161,7 +169,8 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
@Override
|
||||
public TickingRequest getTickingRequest(IGridNode node) {
|
||||
return new TickingRequest(TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true);
|
||||
return new TickingRequest(
|
||||
TickRates.Interface.getMin(), TickRates.Interface.getMax(), !this.hasWorkToDo(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,14 +179,15 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
return TickRateModulation.SLEEP;
|
||||
} else {
|
||||
boolean couldDoWork = this.updateStorage();
|
||||
return this.hasWorkToDo() ? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER) : TickRateModulation.SLEEP;
|
||||
return this.hasWorkToDo()
|
||||
? (couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER)
|
||||
: TickRateModulation.SLEEP;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEItemStack> getItemInventory() {
|
||||
if( this.hasConfig )
|
||||
{
|
||||
if (this.hasConfig) {
|
||||
return null;
|
||||
}
|
||||
return this.items;
|
||||
@@ -185,8 +195,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
@Override
|
||||
public IMEMonitor<IAEFluidStack> getFluidInventory() {
|
||||
if( this.hasConfig )
|
||||
{
|
||||
if (this.hasConfig) {
|
||||
if (this.resetConfigCache) {
|
||||
this.resetConfigCache = false;
|
||||
return new InterfaceInventory(this);
|
||||
@@ -201,9 +210,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {
|
||||
|
||||
}
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue) {}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(IAEFluidTank inventory, int slot) {
|
||||
@@ -232,7 +239,6 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +258,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
private boolean updateStorage() {
|
||||
boolean didSomething = false;
|
||||
for(int x = 0; x < 6; ++x) {
|
||||
for (int x = 0; x < 6; ++x) {
|
||||
if (this.requireWork[x] != null) {
|
||||
didSomething = this.usePlan(x) || didSomething;
|
||||
}
|
||||
@@ -272,14 +278,14 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
}
|
||||
IAEFluidStack toStore;
|
||||
if (work.getStackSize() > 0L) {
|
||||
if ((long)this.tanks.fill(slot, work.getFluidStack(), false) != work.getStackSize()) {
|
||||
if ((long) this.tanks.fill(slot, work.getFluidStack(), false) != work.getStackSize()) {
|
||||
changed = true;
|
||||
} else if (Objects.requireNonNull(getFluidGrid()).getStorageList().findPrecise(work) != null) {
|
||||
toStore = dest.extractItems(work, Actionable.MODULATE, this.mySource);
|
||||
if (toStore != null) {
|
||||
changed = true;
|
||||
int filled = this.tanks.fill(slot, toStore.getFluidStack(), true);
|
||||
if ((long)filled != toStore.getStackSize()) {
|
||||
if ((long) filled != toStore.getStackSize()) {
|
||||
throw new IllegalStateException("bad attempt at managing tanks. ( fill )");
|
||||
}
|
||||
}
|
||||
@@ -288,13 +294,14 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
toStore = work.copy();
|
||||
toStore.setStackSize(-toStore.getStackSize());
|
||||
FluidStack canExtract = this.tanks.drain(slot, toStore.getFluidStack(), false);
|
||||
if (canExtract != null && (long)canExtract.amount == toStore.getStackSize()) {
|
||||
IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource);;
|
||||
if (canExtract != null && (long) canExtract.amount == toStore.getStackSize()) {
|
||||
IAEFluidStack notStored = dest.injectItems(toStore, Actionable.MODULATE, this.mySource);
|
||||
;
|
||||
toStore.setStackSize(toStore.getStackSize() - (notStored == null ? 0L : notStored.getStackSize()));
|
||||
if (toStore.getStackSize() > 0L) {
|
||||
changed = true;
|
||||
FluidStack removed = this.tanks.drain(slot, toStore.getFluidStack(), true);
|
||||
if (removed == null || toStore.getStackSize() != (long)removed.amount) {
|
||||
if (removed == null || toStore.getStackSize() != (long) removed.amount) {
|
||||
throw new IllegalStateException("bad attempt at managing tanks. ( drain )");
|
||||
}
|
||||
}
|
||||
@@ -362,7 +369,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
private void readConfig() {
|
||||
this.hasConfig = false;
|
||||
|
||||
for(int i = 0; i < this.config.getSlots(); ++i) {
|
||||
for (int i = 0; i < this.config.getSlots(); ++i) {
|
||||
if (this.config.getFluidInSlot(i) != null) {
|
||||
this.hasConfig = true;
|
||||
break;
|
||||
@@ -371,7 +378,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
|
||||
boolean had = this.hasWorkToDo();
|
||||
|
||||
for(int x = 0; x < 6; ++x) {
|
||||
for (int x = 0; x < 6; ++x) {
|
||||
this.updatePlan(x);
|
||||
}
|
||||
|
||||
@@ -393,8 +400,7 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid == null || resource == null)
|
||||
return 0;
|
||||
if (fluidGrid == null || resource == null) return 0;
|
||||
int ori = resource.amount;
|
||||
IAEFluidStack remove;
|
||||
if (doFill) {
|
||||
@@ -435,5 +441,4 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
super(tileInterface.tanks);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,9 @@ import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.helpers.PatternHelper;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -11,11 +14,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<FluidPatternDetails>{
|
||||
public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<FluidPatternDetails> {
|
||||
|
||||
private final ItemStack patternStack;
|
||||
private IAEItemStack patternStackAe;
|
||||
@@ -105,9 +104,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
if (condensed.length == 0) {
|
||||
return false;
|
||||
}
|
||||
this.outputs = Arrays.stream(outputs)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(IAEItemStack[]::new);
|
||||
this.outputs = Arrays.stream(outputs).filter(Objects::nonNull).toArray(IAEItemStack[]::new);
|
||||
this.outputsCond = condensed;
|
||||
return true;
|
||||
}
|
||||
@@ -143,7 +140,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
// ae2 null-checks the pattern stack here for some reason, but doesn't null-check in hashCode()
|
||||
// this is inconsistent, so i've just decided to assert non-null in the constructor, which is to say that
|
||||
// the pattern stack can never be null here
|
||||
return obj instanceof FluidPatternDetails && patternStackAe.equals(((FluidPatternDetails)obj).patternStackAe);
|
||||
return obj instanceof FluidPatternDetails && patternStackAe.equals(((FluidPatternDetails) obj).patternStackAe);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,7 +152,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setTag("Inputs", writeStackArray(checkInitialized(inputs)));
|
||||
tag.setTag("Outputs", writeStackArray(checkInitialized(outputs)));
|
||||
//Shits
|
||||
// Shits
|
||||
tag.setTag("in", writeStackArray(checkInitialized(inputs)));
|
||||
tag.setTag("out", writeStackArray(checkInitialized(outputs)));
|
||||
tag.setInteger("combine", this.getCombine());
|
||||
@@ -184,7 +181,7 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
// may be possible to enter a partially-correct state if setInputs succeeds but setOutputs failed
|
||||
// but outside code should treat it as completely incorrect and not attempt to make calls
|
||||
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND)))
|
||||
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND)));
|
||||
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND)));
|
||||
}
|
||||
|
||||
public static IAEItemStack[] readStackArray(NBTTagList listTag) {
|
||||
@@ -195,5 +192,4 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,9 +7,8 @@ import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IInvTweaks;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.Comparator;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
public class FluidSorters {
|
||||
private static SortDir Direction = SortDir.ASCENDING;
|
||||
@@ -20,7 +19,8 @@ public class FluidSorters {
|
||||
final Fluid f1 = ItemFluidDrop.getAeFluidStack(o1).getFluid();
|
||||
final Fluid f2 = ItemFluidDrop.getAeFluidStack(o2).getFluid();
|
||||
if (getDirection() == SortDir.ASCENDING) {
|
||||
return this.secondarySort(Util.getFluidModName(f2).compareToIgnoreCase(Util.getFluidModName(f1)), f1, f2);
|
||||
return this.secondarySort(
|
||||
Util.getFluidModName(f2).compareToIgnoreCase(Util.getFluidModName(f1)), f1, f2);
|
||||
}
|
||||
return this.secondarySort(Util.getFluidModName(f1).compareToIgnoreCase(Util.getFluidModName(f2)), f2, f1);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import appeng.core.AEConfig;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import appeng.core.localization.GuiText;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class ModAndClassUtil {
|
||||
@@ -73,7 +72,7 @@ public final class ModAndClassUtil {
|
||||
}
|
||||
try {
|
||||
Field d = ButtonToolTips.class.getDeclaredField("BeSubstitutionsDescEnabled");
|
||||
// isBeSubstitutionsButton = true;
|
||||
// isBeSubstitutionsButton = true;
|
||||
} catch (NoSuchFieldException e) {
|
||||
isBeSubstitutionsButton = false;
|
||||
}
|
||||
@@ -108,31 +107,18 @@ public final class ModAndClassUtil {
|
||||
essentiaGas = null;
|
||||
}
|
||||
|
||||
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi"))
|
||||
GT5 = true;
|
||||
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post"))
|
||||
GT6 = true;
|
||||
if (Loader.isModLoaded("extracells"))
|
||||
EC2 = true;
|
||||
if (Loader.isModLoaded("EnderIO"))
|
||||
EIO = true;
|
||||
if (Loader.isModLoaded("Forestry"))
|
||||
FTR = true;
|
||||
if (Loader.isModLoaded("OpenComputers"))
|
||||
OC = true;
|
||||
if (Loader.isModLoaded("thaumicenergistics"))
|
||||
ThE = true;
|
||||
if (Loader.isModLoaded("ae2wct"))
|
||||
WCT = true;
|
||||
if (Loader.isModLoaded("IC2"))
|
||||
IC2 = true;
|
||||
if (Loader.isModLoaded("NotEnoughItems"))
|
||||
NEI = true;
|
||||
if (Loader.isModLoaded("CoFHCore"))
|
||||
COFH = true;
|
||||
if (Loader.isModLoaded("miscutils"))
|
||||
GTPP = true;
|
||||
if (Loader.isModLoaded("Waila"))
|
||||
WAILA = true;
|
||||
if (Loader.isModLoaded("gregtech") && !Loader.isModLoaded("gregapi")) GT5 = true;
|
||||
if (Loader.isModLoaded("gregapi") && Loader.isModLoaded("gregapi_post")) GT6 = true;
|
||||
if (Loader.isModLoaded("extracells")) EC2 = true;
|
||||
if (Loader.isModLoaded("EnderIO")) EIO = true;
|
||||
if (Loader.isModLoaded("Forestry")) FTR = true;
|
||||
if (Loader.isModLoaded("OpenComputers")) OC = true;
|
||||
if (Loader.isModLoaded("thaumicenergistics")) ThE = true;
|
||||
if (Loader.isModLoaded("ae2wct")) WCT = true;
|
||||
if (Loader.isModLoaded("IC2")) IC2 = true;
|
||||
if (Loader.isModLoaded("NotEnoughItems")) NEI = true;
|
||||
if (Loader.isModLoaded("CoFHCore")) COFH = true;
|
||||
if (Loader.isModLoaded("miscutils")) GTPP = true;
|
||||
if (Loader.isModLoaded("Waila")) WAILA = true;
|
||||
}
|
||||
}
|
||||
@@ -55,5 +55,4 @@ public class NameConst {
|
||||
public static final String GUI_OC_PATTERN_EDITOR = GUI_KEY + BLOCK_OC_PATTERN_EDITOR;
|
||||
public static final String GUI_FLUID_IMPORT = GUI_KEY + ITEM_PART_FLUID_IMPORT;
|
||||
public static final String GUI_FLUID_EXPORT = GUI_KEY + ITEM_PART_FLUID_EXPORT;
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class ObjectArrayIterator<E> implements /*Resettable*/ Iterator<E> {
|
||||
/** The current iterator index */
|
||||
int index = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
/**
|
||||
* Constructs an ObjectArrayIterator that will iterate over the values in the
|
||||
* specified array.
|
||||
@@ -85,7 +85,7 @@ public class ObjectArrayIterator<E> implements /*Resettable*/ Iterator<E> {
|
||||
}
|
||||
|
||||
// Iterator interface
|
||||
//-------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if there are more elements to return from the array.
|
||||
@@ -123,7 +123,7 @@ public class ObjectArrayIterator<E> implements /*Resettable*/ Iterator<E> {
|
||||
}
|
||||
|
||||
// Properties
|
||||
//-------------------------------------------------------------------------
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the array that this iterator is iterating over.
|
||||
@@ -155,9 +155,8 @@ public class ObjectArrayIterator<E> implements /*Resettable*/ Iterator<E> {
|
||||
/**
|
||||
* Resets the iterator back to the start index.
|
||||
*/
|
||||
//@Override
|
||||
// @Override
|
||||
public void reset() {
|
||||
this.index = this.startIndex;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,16 @@ public final class RenderUtil {
|
||||
renderItemIcon(icon, 0.0D, 0.0D, size, size, z, nx, ny, nz);
|
||||
}
|
||||
|
||||
public static void renderItemIcon(IIcon icon, double xStart, double yStart, double xEnd, double yEnd, double z, float nx, float ny, float nz) {
|
||||
public static void renderItemIcon(
|
||||
IIcon icon,
|
||||
double xStart,
|
||||
double yStart,
|
||||
double xEnd,
|
||||
double yEnd,
|
||||
double z,
|
||||
float nx,
|
||||
float ny,
|
||||
float nz) {
|
||||
if (icon == null) {
|
||||
return;
|
||||
}
|
||||
@@ -28,5 +37,4 @@ public final class RenderUtil {
|
||||
}
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,12 +3,11 @@ package com.glodblock.github.util;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IMachineSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.Consumer;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SetBackedMachineSet implements IMachineSet {
|
||||
|
||||
@@ -56,5 +55,4 @@ public class SetBackedMachineSet implements IMachineSet {
|
||||
public Spliterator<IGridNode> spliterator() {
|
||||
return backingSet.spliterator();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,9 +25,12 @@ public final class Util {
|
||||
|
||||
public static EnumFacing from(ForgeDirection direction) {
|
||||
switch (direction) {
|
||||
case WEST: return EnumFacing.EAST;
|
||||
case EAST: return EnumFacing.WEST;
|
||||
case UNKNOWN: return null;
|
||||
case WEST:
|
||||
return EnumFacing.EAST;
|
||||
case EAST:
|
||||
return EnumFacing.WEST;
|
||||
case UNKNOWN:
|
||||
return null;
|
||||
default: {
|
||||
int o = direction.ordinal();
|
||||
return EnumFacing.values()[o];
|
||||
@@ -63,7 +66,8 @@ public final class Util {
|
||||
return hasPermission(player, permission, host, ForgeDirection.UNKNOWN);
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, SecurityPermissions permission, IGridHost host, ForgeDirection side) {
|
||||
public static boolean hasPermission(
|
||||
EntityPlayer player, SecurityPermissions permission, IGridHost host, ForgeDirection side) {
|
||||
return host == null || hasPermission(player, permission, host.getGridNode(side));
|
||||
}
|
||||
|
||||
@@ -75,20 +79,24 @@ public final class Util {
|
||||
return part == null || hasPermission(player, permission, part.getGridNode());
|
||||
}
|
||||
|
||||
public static boolean hasPermission(EntityPlayer player, SecurityPermissions permission, ISecurityGrid securityGrid) {
|
||||
return player == null || permission == null || securityGrid == null || securityGrid.hasPermission(player, permission);
|
||||
public static boolean hasPermission(
|
||||
EntityPlayer player, SecurityPermissions permission, ISecurityGrid securityGrid) {
|
||||
return player == null
|
||||
|| permission == null
|
||||
|| securityGrid == null
|
||||
|| securityGrid.hasPermission(player, permission);
|
||||
}
|
||||
|
||||
public static ItemStack copyStackWithSize(ItemStack itemStack, int size) {
|
||||
if (size == 0 || itemStack == null)
|
||||
return null;
|
||||
if (size == 0 || itemStack == null) return null;
|
||||
ItemStack copy = itemStack.copy();
|
||||
copy.stackSize = size;
|
||||
return copy;
|
||||
}
|
||||
|
||||
public static AEFluidStack getAEFluidFromItem(ItemStack stack) {
|
||||
if (stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack != null
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
@@ -110,7 +118,8 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static FluidStack getFluidFromItem(ItemStack stack) {
|
||||
if (stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack != null
|
||||
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
|
||||
if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
@@ -164,11 +173,10 @@ public final class Util {
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static IAEFluidStack loadFluidStackFromNBT(final NBTTagCompound i) {
|
||||
//Fuck ae2
|
||||
// Fuck ae2
|
||||
final FluidStack t = FluidRegistry.getFluidStack(i.getString("FluidName"), 1);
|
||||
final AEFluidStack fluid = AEFluidStack.create(t);
|
||||
fluid.setStackSize(i.getLong("Cnt"));
|
||||
@@ -184,8 +192,7 @@ public final class Util {
|
||||
|
||||
public static class FluidUtil {
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
|
||||
return createAEFluidStack(new FluidStack(fluid,
|
||||
FluidContainerRegistry.BUCKET_VOLUME));
|
||||
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
|
||||
}
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid, long amount) {
|
||||
@@ -197,45 +204,38 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static IAEFluidStack createAEFluidStack(int fluidId, long amount) {
|
||||
return createAEFluidStack(new FluidStack(FluidRegistry.getFluid(fluidId), 1)).setStackSize(
|
||||
amount);
|
||||
return createAEFluidStack(new FluidStack(FluidRegistry.getFluid(fluidId), 1))
|
||||
.setStackSize(amount);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
if (itemStack == null) return false;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack content = ((IFluidContainerItem) item)
|
||||
.getFluid(itemStack);
|
||||
FluidStack content = ((IFluidContainerItem) item).getFluid(itemStack);
|
||||
return content == null || content.amount <= 0;
|
||||
}
|
||||
return FluidContainerRegistry.isEmptyContainer(itemStack);
|
||||
}
|
||||
|
||||
public static boolean isFilled(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
if (itemStack == null) return false;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack content = ((IFluidContainerItem) item)
|
||||
.getFluid(itemStack);
|
||||
FluidStack content = ((IFluidContainerItem) item).getFluid(itemStack);
|
||||
return content != null && content.amount > 0;
|
||||
}
|
||||
return FluidContainerRegistry.isFilledContainer(itemStack);
|
||||
}
|
||||
|
||||
public static boolean isFluidContainer(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return false;
|
||||
if (itemStack == null) return false;
|
||||
Item item = itemStack.getItem();
|
||||
return item instanceof IFluidContainerItem
|
||||
|| FluidContainerRegistry.isContainer(itemStack);
|
||||
return item instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(itemStack);
|
||||
}
|
||||
|
||||
public static FluidStack getFluidFromContainer(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
if (itemStack == null) return null;
|
||||
|
||||
ItemStack container = itemStack.copy();
|
||||
Item item = container.getItem();
|
||||
@@ -247,8 +247,7 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static int getCapacity(ItemStack itemStack, Fluid fluid) {
|
||||
if (itemStack == null)
|
||||
return 0;
|
||||
if (itemStack == null) return 0;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
IFluidContainerItem fluidContainerItem = (IFluidContainerItem) item;
|
||||
@@ -268,12 +267,11 @@ public final class Util {
|
||||
}
|
||||
|
||||
public static ItemStack clearFluid(ItemStack itemStack) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
if (itemStack == null) return null;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
((IFluidContainerItem) item).drain(itemStack,
|
||||
((IFluidContainerItem) item).getFluid(itemStack).amount, true);
|
||||
((IFluidContainerItem) item)
|
||||
.drain(itemStack, ((IFluidContainerItem) item).getFluid(itemStack).amount, true);
|
||||
return itemStack;
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
return FluidContainerRegistry.drainFluidContainer(itemStack);
|
||||
@@ -281,55 +279,40 @@ public final class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> drainStack(
|
||||
ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null)
|
||||
return null;
|
||||
public static MutablePair<Integer, ItemStack> drainStack(ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null) return null;
|
||||
Item item = itemStack.getItem();
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack drained = ((IFluidContainerItem) item).drain(itemStack,
|
||||
fluid.amount, true);
|
||||
int amountDrained = drained != null
|
||||
&& drained.getFluid() == fluid.getFluid() ? drained.amount
|
||||
: 0;
|
||||
FluidStack drained = ((IFluidContainerItem) item).drain(itemStack, fluid.amount, true);
|
||||
int amountDrained = drained != null && drained.getFluid() == fluid.getFluid() ? drained.amount : 0;
|
||||
return new MutablePair<Integer, ItemStack>(amountDrained, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
FluidStack content = FluidContainerRegistry
|
||||
.getFluidForFilledItem(itemStack);
|
||||
int amountDrained = content != null
|
||||
&& content.getFluid() == fluid.getFluid() ? content.amount
|
||||
: 0;
|
||||
return new MutablePair<Integer, ItemStack>(amountDrained,
|
||||
FluidContainerRegistry.drainFluidContainer(itemStack));
|
||||
FluidStack content = FluidContainerRegistry.getFluidForFilledItem(itemStack);
|
||||
int amountDrained = content != null && content.getFluid() == fluid.getFluid() ? content.amount : 0;
|
||||
return new MutablePair<Integer, ItemStack>(
|
||||
amountDrained, FluidContainerRegistry.drainFluidContainer(itemStack));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> fillStack(
|
||||
ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null || itemStack.stackSize != 1)
|
||||
return null;
|
||||
public static MutablePair<Integer, ItemStack> fillStack(ItemStack itemStack, FluidStack fluid) {
|
||||
if (itemStack == null || itemStack.stackSize != 1) return null;
|
||||
Item item = itemStack.getItem();
|
||||
//If its a fluid container item instance
|
||||
// If its a fluid container item instance
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
//Call the fill method on it.
|
||||
int filled = ((IFluidContainerItem) item).fill(itemStack, fluid,
|
||||
true);
|
||||
// Call the fill method on it.
|
||||
int filled = ((IFluidContainerItem) item).fill(itemStack, fluid, true);
|
||||
|
||||
//Return the filled itemstack.
|
||||
// Return the filled itemstack.
|
||||
return new MutablePair<Integer, ItemStack>(filled, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
//Fill it through the fluidcontainer registry.
|
||||
ItemStack filledContainer = FluidContainerRegistry
|
||||
.fillFluidContainer(fluid, itemStack);
|
||||
//get the filled fluidstack.
|
||||
FluidStack filled = FluidContainerRegistry
|
||||
.getFluidForFilledItem(filledContainer);
|
||||
//Return filled container and fill amount.
|
||||
return new MutablePair<Integer, ItemStack>(
|
||||
filled != null ? filled.amount : 0, filledContainer);
|
||||
|
||||
// Fill it through the fluidcontainer registry.
|
||||
ItemStack filledContainer = FluidContainerRegistry.fillFluidContainer(fluid, itemStack);
|
||||
// get the filled fluidstack.
|
||||
FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(filledContainer);
|
||||
// Return filled container and fill amount.
|
||||
return new MutablePair<Integer, ItemStack>(filled != null ? filled.amount : 0, filledContainer);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user