mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge remote-tracking branch 'origin/stack-type-api' into dev
This commit is contained in:
36 files changed
+193
-1242
No files matched your search
+1
-1
@@ -108,7 +108,7 @@ mixinsPackage =
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass = coremod.FluidCraftCore
|
||||
coreModClass =
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
|
||||
import com.glodblock.github.crossmod.waila.WailaInit;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.loader.CalculatorV2PluginLoader;
|
||||
import com.glodblock.github.loader.ChannelLoader;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.loader.RecipeLoader;
|
||||
@@ -74,10 +73,6 @@ public class FluidCraft {
|
||||
RecipeLoader.runTerminalRecipe();
|
||||
RecipeLoader.addDisassembleRecipe();
|
||||
|
||||
if (ModAndClassUtil.isV2) {
|
||||
CalculatorV2PluginLoader.installCalculatorV2Plugins();
|
||||
}
|
||||
|
||||
proxy.postInit(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Set;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import com.glodblock.github.api.registries.ILevelTerminalRegistry;
|
||||
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
|
||||
import com.glodblock.github.util.LevelTerminalRegistry;
|
||||
|
||||
public final class FluidCraftAPI implements IFluidCraftAPI {
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.features.LevelState;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.client.gui.GuiSub;
|
||||
import appeng.client.gui.slots.VirtualMEPhantomSlot;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
@@ -61,7 +62,8 @@ public class GuiLevelMaintainer extends GuiSub {
|
||||
27,
|
||||
20 + i * 19,
|
||||
this.cont.getTile().getAEStackInventory(),
|
||||
i);
|
||||
i,
|
||||
GuiLevelMaintainer::acceptType);
|
||||
slot.setShowAmount(true);
|
||||
slot.setShowAmountAlways(true);
|
||||
this.registerVirtualSlots(slot);
|
||||
@@ -193,6 +195,10 @@ public class GuiLevelMaintainer extends GuiSub {
|
||||
component[index].setState(state);
|
||||
}
|
||||
|
||||
private static boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType<?> type, int mouseButton) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private class Component {
|
||||
|
||||
public boolean isEnable = false;
|
||||
|
||||
@@ -16,12 +16,12 @@ import org.jetbrains.annotations.Nullable;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.base.FCBaseContainer;
|
||||
import com.glodblock.github.common.parts.PartLevelTerminal;
|
||||
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.SPacketLevelTerminalUpdate;
|
||||
import com.glodblock.github.util.FluidPrimaryGui;
|
||||
import com.glodblock.github.util.LevelTerminalRegistry;
|
||||
|
||||
import appeng.api.features.ILevelViewable;
|
||||
import appeng.api.features.LevelItemInfo;
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.glodblock.github.common.storage.CellType;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.items.AEBaseCell;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -24,8 +28,8 @@ public abstract class FCBaseItemCell extends AEBaseCell {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public @NotNull IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
|
||||
public FCBaseItemCell(Optional subName) {
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseInfiniteCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.me.storage.FluidCellInventoryHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class ItemCreativeFluidStorageCell extends AEBaseInfiniteCell
|
||||
@@ -42,7 +49,12 @@ public class ItemCreativeFluidStorageCell extends AEBaseInfiniteCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public @NotNull IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack stack) {
|
||||
return new FluidCellInventoryHandler(new CreativeCellInventory<>(stack));
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ package com.glodblock.github.common.item;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.parts.PartFluidConversionMonitor;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -37,6 +39,11 @@ public class ItemFluidConversionMonitor extends FCBaseItem implements IPartItem
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack p_77650_1_) {
|
||||
return FCPartsTexture.PartTerminalBroad.getIcon();
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.glodblock.github.common.item;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.common.parts.PartFluidStorageMonitor;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
@@ -37,6 +39,11 @@ public class ItemFluidStorageMonitor extends FCBaseItem implements IPartItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack p_77650_1_) {
|
||||
return FCPartsTexture.PartTerminalBroad.getIcon();
|
||||
}
|
||||
|
||||
public void registerIcons(IIconRegister _iconRegister) {}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.items.storage.ItemVoidStorageCell;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -25,7 +27,7 @@ public class ItemFluidVoidStorageCell extends ItemVoidStorageCell implements IRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,26 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
import static com.glodblock.github.util.Util.FluidUtil.water_bucket;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseInfiniteCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.me.storage.FluidCellInventoryHandler;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
@@ -62,7 +68,12 @@ public class ItemInfinityWaterStorageCell extends AEBaseInfiniteCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public @NotNull IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMEInventoryHandler getCellInventory(ItemStack stack) {
|
||||
return new FluidCellInventoryHandler(new CreativeCellInventory<>(stack));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -9,6 +11,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.api.FluidCraftAPI;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
@@ -17,9 +21,9 @@ import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.items.AEBasePortableCell;
|
||||
import appeng.items.contents.CellUpgrades;
|
||||
import appeng.items.contents.PortableCellViewer;
|
||||
@@ -79,12 +83,12 @@ public class ItemPortableFluidCell extends AEBasePortableCell implements IRegist
|
||||
@Override
|
||||
public IGuiItemObject getGuiObject(final ItemStack is, final World w, final EntityPlayer p, final int x,
|
||||
final int y, final int z) {
|
||||
return new PortableCellViewer<IAEFluidStack>(is, x, StorageChannel.FLUIDS);
|
||||
return new PortableCellViewer<IAEFluidStack>(is, x, FLUID_STACK_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public @NotNull IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,157 +1,28 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import appeng.parts.reporting.PartConversionMonitor;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.PlayerSource;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartFluidConversionMonitor extends PartFluidStorageMonitor {
|
||||
public class PartFluidConversionMonitor extends PartConversionMonitor {
|
||||
|
||||
public PartFluidConversionMonitor(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPartShiftActivate(final EntityPlayer player, final Vec3 pos) {
|
||||
if (Platform.isClient()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Platform.hasPermissions(this.getLocation(), player)) {
|
||||
return false;
|
||||
}
|
||||
FluidStack fluidStack;
|
||||
ItemStack item = player.getCurrentEquippedItem();
|
||||
if (item != null && item.getItem() instanceof ItemFluidPacket) {
|
||||
fluidStack = ItemFluidPacket.getFluidStack(item);
|
||||
} else {
|
||||
fluidStack = Util.FluidUtil.getFluidFromContainer(item);
|
||||
}
|
||||
if (this.getDisplayed() == null || fluidStack == null
|
||||
|| fluidStack.getFluid() != ((IAEFluidStack) this.getDisplayed()).getFluid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return false;
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
// Migrate old tag
|
||||
if (data.hasKey("configuredItem")) {
|
||||
final NBTTagCompound myItem = data.getCompoundTag("configuredItem");
|
||||
if (!myItem.hasNoTags() && !myItem.hasKey("StackType")) {
|
||||
myItem.setString("StackType", FLUID_STACK_TYPE.getId());
|
||||
}
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEFluidStack> cell = this.getProxy().getStorage().getFluidInventory();
|
||||
final IAEFluidStack input = (IAEFluidStack) this.getDisplayed().copy().setStackSize(fluidStack.amount);
|
||||
final IAEFluidStack failedToInsert = Platform
|
||||
.poweredInsert(energy, cell, input, new PlayerSource(player, this));
|
||||
if (failedToInsert != null && failedToInsert.getStackSize() == input.getStackSize()) {
|
||||
return false;
|
||||
} else if (failedToInsert == null || failedToInsert.getStackSize() != input.getStackSize()) {
|
||||
if (item.getItem() instanceof ItemFluidPacket) {
|
||||
if (failedToInsert != null) {
|
||||
player.getCurrentEquippedItem()
|
||||
.setTagCompound(ItemFluidPacket.newStack(failedToInsert).getTagCompound());
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ItemStack tmp = item.copy();
|
||||
tmp.stackSize = 1;
|
||||
ItemStack tank = null;
|
||||
if (failedToInsert == null) {
|
||||
tank = Util.FluidUtil.clearFluid(tmp);
|
||||
} else {
|
||||
if (tmp.getItem() instanceof IFluidContainerItem) {
|
||||
tank = Util.FluidUtil.setFluidContainerAmount(tmp, (int) failedToInsert.getStackSize());
|
||||
} else if (FluidContainerRegistry.isContainer(tmp)) {
|
||||
IAEFluidStack insertedFluid = input.copy();
|
||||
insertedFluid.decStackSize(failedToInsert.getStackSize());
|
||||
this.getProxy().getStorage().getFluidInventory()
|
||||
.extractItems(insertedFluid, Actionable.MODULATE, new PlayerSource(player, this));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (tank != null && !player.inventory.addItemStackToInventory(tank)) {
|
||||
player.entityDropItem(tank, 0);
|
||||
}
|
||||
}
|
||||
item.stackSize--;
|
||||
if (item.stackSize <= 0) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (final GridAccessException ignored) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void extractItem(final EntityPlayer player) {
|
||||
final IAEFluidStack input = (IAEFluidStack) this.getDisplayed();
|
||||
ItemStack eq = player.getCurrentEquippedItem();
|
||||
if (input != null && Util.FluidUtil.isFluidContainer(eq) && Util.FluidUtil.isEmpty(eq)) {
|
||||
try {
|
||||
if (!this.getProxy().isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final IEnergySource energy = this.getProxy().getEnergy();
|
||||
final IMEMonitor<IAEFluidStack> cell = this.getProxy().getStorage().getFluidInventory();
|
||||
ItemStack tank = eq.copy();
|
||||
tank.stackSize = 1;
|
||||
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(tank, input.getFluidStack());
|
||||
input.setStackSize(fillStack.left);
|
||||
|
||||
final IAEFluidStack retrieved = Platform
|
||||
.poweredExtraction(energy, cell, input, new PlayerSource(player, this));
|
||||
if (retrieved != null) {
|
||||
if (!player.inventory.addItemStackToInventory(fillStack.right)) {
|
||||
player.entityDropItem(fillStack.right.copy(), 0);
|
||||
}
|
||||
eq.stackSize--;
|
||||
if (eq.stackSize <= 0) {
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||
}
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor(player, ForgeDirection.UNKNOWN);
|
||||
ItemStack newItems = adaptor.addItems(
|
||||
Util.FluidUtil.setFluidContainerAmount(fillStack.right, (int) retrieved.getStackSize()));
|
||||
if (newItems != null) {
|
||||
final TileEntity te = this.getTile();
|
||||
final List<ItemStack> list = Collections.singletonList(newItems);
|
||||
Platform.spawnDrops(
|
||||
player.worldObj,
|
||||
te.xCoord + this.getSide().offsetX,
|
||||
te.yCoord + this.getSide().offsetY,
|
||||
te.zCoord + this.getSide().offsetZ,
|
||||
list);
|
||||
}
|
||||
|
||||
if (player.openContainer != null) {
|
||||
player.openContainer.detectAndSendChanges();
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException ignored) {}
|
||||
}
|
||||
|
||||
super.readFromNBT(data);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -15,6 +17,7 @@ import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartBaseExportBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
@@ -72,11 +75,11 @@ public class PartFluidExportBus extends PartBaseExportBus<IAEFluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doFuzzy(IAEFluidStack aes, FuzzyMode fzMode, InventoryAdaptor destination, IEnergyGrid energy,
|
||||
protected void doFuzzy(IAEFluidStack aes, FuzzyMode fzMode, IEnergyGrid energy,
|
||||
IMEMonitor<IAEFluidStack> gridInv) {}
|
||||
|
||||
@Override
|
||||
protected void doOreDict(InventoryAdaptor destination, IEnergyGrid energy, IMEMonitor<IAEFluidStack> gridInv) {}
|
||||
protected void doOreDict(IEnergyGrid energy, IMEMonitor<IAEFluidStack> gridInv) {}
|
||||
|
||||
// legacy
|
||||
@Override
|
||||
@@ -91,4 +94,9 @@ public class PartFluidExportBus extends PartBaseExportBus<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStackType<IAEFluidStack> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -23,6 +23,7 @@ import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.PartBaseImportBus;
|
||||
import appeng.tile.inventory.IAEStackInventory;
|
||||
@@ -42,18 +43,14 @@ public class PartFluidImportBus extends PartBaseImportBus<IAEFluidStack> {
|
||||
|
||||
@Override
|
||||
protected Object getTarget() {
|
||||
TileEntity self = this.getHost().getTile();
|
||||
return this.getTileEntity(self, (new BlockPos(self)).getOffSet(this.getSide()));
|
||||
}
|
||||
final TileEntity self = this.getHost().getTile();
|
||||
final TileEntity target = this.getTileEntity(
|
||||
self,
|
||||
self.xCoord + this.getSide().offsetX,
|
||||
self.yCoord + this.getSide().offsetY,
|
||||
self.zCoord + this.getSide().offsetZ);
|
||||
|
||||
private TileEntity getTileEntity(final TileEntity self, final BlockPos pos) {
|
||||
final World w = self.getWorldObj();
|
||||
|
||||
if (w.getChunkProvider().chunkExists(pos.getX() >> 4, pos.getZ() >> 4)) {
|
||||
return w.getTileEntity(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return null;
|
||||
return target instanceof IFluidHandler handler ? handler : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +88,11 @@ public class PartFluidImportBus extends PartBaseImportBus<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getAdaptorFlags() {
|
||||
return InventoryAdaptor.ALLOW_FLUIDS | InventoryAdaptor.FOR_EXTRACTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean importStuff(final Object myTarget, final IAEFluidStack whatToImport,
|
||||
final IMEMonitor<IAEFluidStack> inv, final IEnergySource energy, final FuzzyMode fzMode) {
|
||||
@@ -173,7 +175,7 @@ public class PartFluidImportBus extends PartBaseImportBus<IAEFluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getAdaptorFlags() {
|
||||
return InventoryAdaptor.ALLOW_FLUIDS | InventoryAdaptor.FOR_EXTRACTS;
|
||||
public IAEStackType<IAEFluidStack> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStackType;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
|
||||
public class PartFluidStorageBus extends PartStorageBus {
|
||||
@@ -12,7 +14,7 @@ public class PartFluidStorageBus extends PartStorageBus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getStorageChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
public IAEStackType<?> getStackType() {
|
||||
return FLUID_STACK_TYPE;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,28 @@
|
||||
package com.glodblock.github.common.parts;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import com.glodblock.github.common.parts.base.FCPartMonitor;
|
||||
import appeng.parts.reporting.PartStorageMonitor;
|
||||
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.helpers.Reflected;
|
||||
public class PartFluidStorageMonitor extends PartStorageMonitor {
|
||||
|
||||
public class PartFluidStorageMonitor extends FCPartMonitor {
|
||||
|
||||
private static final CableBusTextures FRONT_BRIGHT_ICON = CableBusTextures.PartStorageMonitor_Bright;
|
||||
private static final CableBusTextures FRONT_DARK_ICON = CableBusTextures.PartStorageMonitor_Dark;
|
||||
private static final CableBusTextures FRONT_COLORED_ICON = CableBusTextures.PartStorageMonitor_Colored;
|
||||
private static final CableBusTextures FRONT_COLORED_ICON_LOCKED = CableBusTextures.PartStorageMonitor_Colored_Locked;
|
||||
|
||||
@Reflected
|
||||
public PartFluidStorageMonitor(final ItemStack is) {
|
||||
public PartFluidStorageMonitor(ItemStack is) {
|
||||
super(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontBright() {
|
||||
return FRONT_BRIGHT_ICON;
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
// Migrate old tag
|
||||
if (data.hasKey("configuredItem")) {
|
||||
final NBTTagCompound myItem = data.getCompoundTag("configuredItem");
|
||||
if (!myItem.hasNoTags() && !myItem.hasKey("StackType")) {
|
||||
myItem.setString("StackType", FLUID_STACK_TYPE.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontColored() {
|
||||
return this.isLocked() ? FRONT_COLORED_ICON_LOCKED : FRONT_COLORED_ICON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CableBusTextures getFrontDark() {
|
||||
return FRONT_DARK_ICON;
|
||||
super.readFromNBT(data);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.ThaumicEnergisticsCrafting;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
@@ -45,11 +44,10 @@ import appeng.api.networking.security.MachineSource;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.StorageName;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
@@ -99,30 +97,35 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public IAEStack<?> injectCraftedItems(ICraftingLink link, IAEStack<?> stack, Actionable mode) {
|
||||
int idx = this.getRequestIndexByLink(link);
|
||||
|
||||
try {
|
||||
if (getProxy().isActive()) {
|
||||
final IEnergyGrid energy = getProxy().getEnergy();
|
||||
final double power = Math
|
||||
.ceil(ItemFluidDrop.isFluidStack(items) ? items.getStackSize() / 1000D : items.getStackSize());
|
||||
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
|
||||
if (ItemFluidDrop.isFluidStack(items)) {
|
||||
IAEFluidStack notInjectedItems = getProxy().getStorage().getFluidInventory()
|
||||
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, source);
|
||||
if (notInjectedItems != null) {
|
||||
items.setStackSize(notInjectedItems.getStackSize());
|
||||
if (idx != -1) {
|
||||
this.updateState(idx, LevelState.Export);
|
||||
}
|
||||
final double power = Math.ceil((double) stack.getStackSize() / stack.getAmountPerUnit());
|
||||
|
||||
return items;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
if (energy.extractAEPower(power, mode, PowerMultiplier.CONFIG) > power - 0.01) {
|
||||
IMEMonitor monitor = getProxy().getStorage().getMEMonitor(stack.getStackType());
|
||||
if (monitor == null) return stack;
|
||||
|
||||
IAEStack<?> notInjected;
|
||||
if (stack instanceof IAEItemStack ais && ItemFluidDrop.isFluidStack(ais)) {
|
||||
notInjected = getProxy().getStorage().getFluidInventory()
|
||||
.injectItems(ItemFluidDrop.getAeFluidStack(ais), mode, source);
|
||||
} else {
|
||||
return getProxy().getStorage().getItemInventory().injectItems(items, mode, source);
|
||||
notInjected = monitor.injectItems(stack, mode, source);
|
||||
}
|
||||
|
||||
if (notInjected != null) {
|
||||
if (idx != -1) {
|
||||
this.updateState(idx, LevelState.Export);
|
||||
}
|
||||
|
||||
return notInjected;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +133,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
AELog.debug(e);
|
||||
}
|
||||
|
||||
return items;
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,8 +165,6 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
try {
|
||||
final ICraftingGrid craftingGrid = getProxy().getCrafting();
|
||||
final IGrid grid = getProxy().getGrid();
|
||||
final IItemList<IAEItemStack> invItems = getProxy().getStorage().getItemInventory().getStorageList();
|
||||
final IItemList<IAEFluidStack> invFluid = getProxy().getStorage().getFluidInventory().getStorageList();
|
||||
|
||||
// Check there are available crafting CPUs before doing any work.
|
||||
// This hopefully stops level maintainers busy-looping calculating
|
||||
@@ -196,32 +197,17 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
IAEStack<?> aeItem = null;
|
||||
|
||||
IAEStack<?> craftItem = requests[i].stack.copy();
|
||||
craftItem.setStackSize(batchSize);
|
||||
IMEMonitor monitor = getProxy().getStorage().getMEMonitor(craftItem.getStackType());
|
||||
if (monitor == null) continue;
|
||||
|
||||
if (craftItem instanceof IAEItemStack ais) {
|
||||
if (ModAndClassUtil.ThE && ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
aeItem = ThaumicEnergisticsCrafting.convertAspectStack(ais);
|
||||
} else {
|
||||
aeItem = invItems.findPrecise(ais);
|
||||
}
|
||||
} else if (craftItem instanceof IAEFluidStack afs) {
|
||||
aeItem = invFluid.findPrecise(afs);
|
||||
}
|
||||
IAEStack<?> stackInStorage = monitor.getStorageList().findPrecise(craftItem);
|
||||
|
||||
long stackSize = aeItem == null ? 0 : aeItem.getStackSize();
|
||||
|
||||
if (ModAndClassUtil.ThE) {
|
||||
if (aeItem instanceof IAEItemStack ais
|
||||
&& ThaumicEnergisticsCrafting.isAspectStack(ais.getItemStack())) {
|
||||
stackSize = ThaumicEnergisticsCrafting.getEssentiaAmount(ais, grid);
|
||||
}
|
||||
}
|
||||
long stackSize = stackInStorage == null ? 0 : stackInStorage.getStackSize();
|
||||
|
||||
boolean isDone = this.isDone(i);
|
||||
boolean isCraftable = aeItem != null && aeItem.isCraftable();
|
||||
boolean isCraftable = stackInStorage != null && stackInStorage.isCraftable();
|
||||
boolean shouldCraft = isCraftable && stackSize < quantity;
|
||||
|
||||
if (isDone) {
|
||||
@@ -240,11 +226,11 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.canEmitFor(aeItem)) {
|
||||
if (craftingGrid.canEmitFor(stackInStorage)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (craftingGrid.isRequesting(aeItem)) {
|
||||
if (craftingGrid.isRequesting(stackInStorage)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -289,7 +275,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
// No jobs to submit, start calculating some item.
|
||||
|
||||
requests[itemToBeginIdx].job = craftingGrid
|
||||
.beginCraftingJob(getWorldObj(), grid, source, itemToBegin, null);
|
||||
.beginCraftingJob(this.worldObj, grid, source, itemToBegin, null);
|
||||
this.updateState(itemToBeginIdx, LevelState.Craft);
|
||||
|
||||
// Try the next item next time.
|
||||
@@ -644,6 +630,10 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
if (stack == null) {
|
||||
throw new IllegalArgumentException("ItemStack cannot be null!");
|
||||
}
|
||||
|
||||
// Migrate old aspect stack
|
||||
stack = ThaumicEnergisticsCrafting.convertItemAspectStack(stack);
|
||||
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
batchSize = tag.getLong(NBT_BATCH);
|
||||
enable = tag.getBoolean(NBT_ENABLE);
|
||||
@@ -660,6 +650,10 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
public void loadFromNBT(NBTTagCompound tag) {
|
||||
stack = Platform.readStackNBT(tag.getCompoundTag(NBT_STACK), true);
|
||||
|
||||
// Migrate old aspect stack
|
||||
stack = ThaumicEnergisticsCrafting.convertItemAspectStack(stack);
|
||||
|
||||
quantity = tag.getLong(NBT_QUANTITY);
|
||||
batchSize = tag.getLong(NBT_BATCH);
|
||||
enable = tag.getBoolean(NBT_ENABLE);
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.glodblock.github.coremod;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
||||
import com.glodblock.github.coremod.transform.ExternalStorageRegistryTransformer;
|
||||
import com.glodblock.github.coremod.transform.GuiCraftingTransformer;
|
||||
import com.glodblock.github.coremod.transform.NEITransformer;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ASMUtil;
|
||||
|
||||
public class FCClassTransformer implements IClassTransformer {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger("ASM AE2FC");
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
ClassMapper tform;
|
||||
switch (transformedName) {
|
||||
case "appeng.client.gui.implementations.GuiCraftingCPU", "appeng.client.gui.implementations.GuiCraftConfirm", "net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm", "appeng.client.gui.widgets.GuiCraftingTree" -> tform = GuiCraftingTransformer.INSTANCE;
|
||||
case "appeng.integration.modules.NEI" -> tform = NEITransformer.INSTANCE;
|
||||
case "appeng.core.features.registries.ExternalStorageRegistry" -> tform = ExternalStorageRegistryTransformer.INSTANCE;
|
||||
default -> {
|
||||
return basicClass;
|
||||
}
|
||||
}
|
||||
logger.debug("Transforming class: " + transformedName);
|
||||
final byte[] bytes = tform.transformClass(basicClass);
|
||||
if (FluidCraftCore.DUMP_CLASSES()) {
|
||||
ASMUtil.saveAsRawClassFile(basicClass, transformedName + "_PRE", this);
|
||||
ASMUtil.saveAsRawClassFile(bytes, transformedName + "_POST", this);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public abstract static class ClassMapper {
|
||||
|
||||
public final byte[] transformClass(byte[] code) {
|
||||
ClassReader reader = new ClassReader(code);
|
||||
ClassWriter writer = new ClassWriter(reader, getWriteFlags());
|
||||
reader.accept(getClassMapper(writer), ClassReader.EXPAND_FRAMES);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
protected int getWriteFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected abstract ClassVisitor getClassMapper(ClassVisitor downstream);
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.glodblock.github.coremod;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
@IFMLLoadingPlugin.Name("FluidCraftCore")
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.TransformerExclusions("com.glodblock.github.coremod")
|
||||
public class FluidCraftCore implements IFMLLoadingPlugin {
|
||||
|
||||
private static final boolean DUMP_CLASSES = Boolean.parseBoolean(System.getProperty("ae2fc.dumpClass", "false"));
|
||||
private static boolean OBF_ENV;
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[] { FCClassTransformer.class.getName() };
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
OBF_ENV = (boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean DUMP_CLASSES() {
|
||||
return DUMP_CLASSES || !OBF_ENV;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.glodblock.github.coremod.hooker;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.IGuiTooltipHandler;
|
||||
|
||||
public class CoreModHooks {
|
||||
|
||||
public static ItemStack displayFluid(IAEItemStack aeStack) {
|
||||
if (aeStack.getItemStack() != null && aeStack.getItemStack().getItem() instanceof ItemFluidDrop) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(aeStack.getItemStack());
|
||||
return ItemFluidPacket.newDisplayStack(fluid);
|
||||
} else return aeStack.getItemStack();
|
||||
}
|
||||
|
||||
public static ItemStack getStackUnderMouse(GuiContainer gui, int mousex, int mousey) {
|
||||
if (gui instanceof IGuiTooltipHandler guiTooltipHandler) {
|
||||
return guiTooltipHandler.getHoveredStack();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.glodblock.github.coremod.hooker;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class CoreModHooksClient {
|
||||
|
||||
}
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Label;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class ExternalStorageRegistryTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final ExternalStorageRegistryTransformer INSTANCE = new ExternalStorageRegistryTransformer();
|
||||
|
||||
private ExternalStorageRegistryTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformExternalStorageRegistry(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getWriteFlags() {
|
||||
return ClassWriter.COMPUTE_FRAMES;
|
||||
}
|
||||
|
||||
private static class TransformExternalStorageRegistry extends ClassVisitor {
|
||||
|
||||
public TransformExternalStorageRegistry(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if ("getHandler".equals(name)) {
|
||||
return new TransformGetHandler(api, super.visitMethod(access, name, desc, signature, exceptions));
|
||||
} else {
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformGetHandler extends MethodVisitor {
|
||||
|
||||
private int cnt_return = 0;
|
||||
private int cnt_if = 0;
|
||||
private Label L6 = null;
|
||||
private final Label L9 = new Label();
|
||||
|
||||
TransformGetHandler(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJumpInsn(int opcode, Label label) {
|
||||
if (opcode == Opcodes.IFEQ) {
|
||||
cnt_if++;
|
||||
}
|
||||
if (cnt_if == 3) {
|
||||
L6 = label;
|
||||
cnt_if++;
|
||||
super.visitJumpInsn(opcode, L9);
|
||||
return;
|
||||
}
|
||||
super.visitJumpInsn(opcode, label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInsn(int opcode) {
|
||||
if (opcode == Opcodes.ARETURN) {
|
||||
cnt_return++;
|
||||
}
|
||||
super.visitInsn(opcode);
|
||||
if (cnt_return == 2) {
|
||||
super.visitLabel(L9);
|
||||
super.visitFieldInsn(
|
||||
Opcodes.GETSTATIC,
|
||||
"com/glodblock/github/inventory/external/AEFluidTankHandler",
|
||||
"INSTANCE",
|
||||
"Lcom/glodblock/github/inventory/external/AEFluidTankHandler;");
|
||||
super.visitVarInsn(Opcodes.ALOAD, 1);
|
||||
super.visitVarInsn(Opcodes.ALOAD, 2);
|
||||
super.visitVarInsn(Opcodes.ALOAD, 3);
|
||||
super.visitVarInsn(Opcodes.ALOAD, 4);
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKEVIRTUAL,
|
||||
"com/glodblock/github/inventory/external/AEFluidTankHandler",
|
||||
"canHandle",
|
||||
"(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraftforge/common/util/ForgeDirection;Lappeng/api/storage/StorageChannel;Lappeng/api/networking/security/BaseActionSource;)Z",
|
||||
false);
|
||||
super.visitJumpInsn(Opcodes.IFEQ, L6);
|
||||
super.visitFieldInsn(
|
||||
Opcodes.GETSTATIC,
|
||||
"com/glodblock/github/inventory/external/AEFluidTankHandler",
|
||||
"INSTANCE",
|
||||
"Lcom/glodblock/github/inventory/external/AEFluidTankHandler;");
|
||||
super.visitInsn(Opcodes.ARETURN);
|
||||
cnt_return++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class GuiCraftingTransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final GuiCraftingTransformer INSTANCE = new GuiCraftingTransformer();
|
||||
|
||||
private GuiCraftingTransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformGuiCrafting(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformGuiCrafting extends ClassVisitor {
|
||||
|
||||
TransformGuiCrafting(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if ("drawFG".equals(name) || "drawListFG".equals(name) || "drawStack".equals(name)) {
|
||||
return new TransformFluidIcon(api, super.visitMethod(access, name, desc, signature, exceptions));
|
||||
}
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformFluidIcon extends MethodVisitor {
|
||||
|
||||
TransformFluidIcon(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
|
||||
if (opcode == Opcodes.INVOKEINTERFACE && owner.equals("appeng/api/storage/data/IAEItemStack")
|
||||
&& name.equals("getItemStack")) {
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"displayFluid",
|
||||
"(Lappeng/api/storage/data/IAEItemStack;)Lnet/minecraft/item/ItemStack;",
|
||||
false);
|
||||
} else {
|
||||
super.visitMethodInsn(opcode, owner, name, desc, itf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package com.glodblock.github.coremod.transform;
|
||||
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import com.glodblock.github.coremod.FCClassTransformer;
|
||||
|
||||
public class NEITransformer extends FCClassTransformer.ClassMapper {
|
||||
|
||||
public static final NEITransformer INSTANCE = new NEITransformer();
|
||||
|
||||
private NEITransformer() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
|
||||
return new TransformNEI(Opcodes.ASM5, downstream);
|
||||
}
|
||||
|
||||
private static class TransformNEI extends ClassVisitor {
|
||||
|
||||
TransformNEI(int api, ClassVisitor cv) {
|
||||
super(api, cv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
return switch (name) {
|
||||
case "getStackUnderMouse" -> new TransformStackUnderMouse(
|
||||
api,
|
||||
super.visitMethod(access, name, desc, signature, exceptions));
|
||||
default -> super.visitMethod(access, name, desc, signature, exceptions);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static class TransformStackUnderMouse extends MethodVisitor {
|
||||
|
||||
TransformStackUnderMouse(int api, MethodVisitor mv) {
|
||||
super(api, mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInsn(int opcode) {
|
||||
if (opcode == Opcodes.ACONST_NULL) {
|
||||
super.visitVarInsn(Opcodes.ALOAD, 1);
|
||||
super.visitVarInsn(Opcodes.ILOAD, 2);
|
||||
super.visitVarInsn(Opcodes.ILOAD, 3);
|
||||
super.visitMethodInsn(
|
||||
Opcodes.INVOKESTATIC,
|
||||
"com/glodblock/github/coremod/hooker/CoreModHooks",
|
||||
"getStackUnderMouse",
|
||||
"(Lnet/minecraft/client/gui/inventory/GuiContainer;II)Lnet/minecraft/item/ItemStack;",
|
||||
false);
|
||||
return;
|
||||
}
|
||||
super.visitInsn(opcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.glodblock.github.crossmod.thaumcraft;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.client.lib.UtilsFX;
|
||||
|
||||
public class AspectRender {
|
||||
|
||||
public static final ResourceLocation UNKNOWN_TEXTURE = new ResourceLocation(
|
||||
"thaumcraft",
|
||||
"textures/aspects/_unknown.png");
|
||||
|
||||
public static void drawAspect(EntityPlayer player, int posX, int posY, float zLevel, Aspect aspect, long amount) {
|
||||
if (aspect == null || amount <= 0) {
|
||||
return;
|
||||
}
|
||||
if (AspectUtil.isPlayerDiscoveredAspect(player, aspect)) {
|
||||
UtilsFX.drawTag(posX, posY, aspect, 0, 0, zLevel);
|
||||
} else {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(UNKNOWN_TEXTURE);
|
||||
RenderUtil.setGLColorFromInt(aspect.getColor());
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
UtilsFX.drawTexturedQuadFull(posX, posY, zLevel);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
package com.glodblock.github.crossmod.thaumcraft;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.ThEApi;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.common.fluids.GaseousEssentia;
|
||||
import thaumicenergistics.common.integration.tc.EssentiaItemContainerHelper;
|
||||
import thaumicenergistics.common.storage.AspectStack;
|
||||
|
||||
public class AspectUtil {
|
||||
|
||||
public static final EssentiaItemContainerHelper HELPER = EssentiaItemContainerHelper.INSTANCE;
|
||||
public static int R = 128;
|
||||
|
||||
@Optional.Method(modid = "thaumicenergistics")
|
||||
public static void init() {
|
||||
R = ThEApi.instance().config().conversionMultiplier();
|
||||
}
|
||||
|
||||
public static boolean isPlayerDiscoveredAspect(final EntityPlayer player, final Aspect aspect) {
|
||||
if (player != null && aspect != null) {
|
||||
return Thaumcraft.proxy.getPlayerKnowledge().hasDiscoveredAspect(player.getCommandSenderName(), aspect);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEssentiaGas(Fluid fluid) {
|
||||
return fluid instanceof GaseousEssentia;
|
||||
}
|
||||
|
||||
public static boolean isEssentiaGas(FluidStack fluid) {
|
||||
return fluid != null && fluid.getFluid() instanceof GaseousEssentia;
|
||||
}
|
||||
|
||||
public static boolean isEssentiaGas(IAEFluidStack fluid) {
|
||||
return fluid != null && fluid.getFluid() instanceof GaseousEssentia;
|
||||
}
|
||||
|
||||
public static Aspect getAspectFromGas(FluidStack fluid) {
|
||||
if (!isEssentiaGas(fluid)) {
|
||||
return null;
|
||||
}
|
||||
GaseousEssentia gas = (GaseousEssentia) fluid.getFluid();
|
||||
return gas.getAspect();
|
||||
}
|
||||
|
||||
public static Aspect getAspectFromJar(ItemStack stack) {
|
||||
if (isEssentiaContainer(stack)) {
|
||||
return HELPER.getAspectInContainer(stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Aspect getAspectFromGas(IAEFluidStack fluid) {
|
||||
if (isEssentiaGas(fluid)) {
|
||||
return null;
|
||||
}
|
||||
GaseousEssentia gas = (GaseousEssentia) fluid.getFluid();
|
||||
return gas.getAspect();
|
||||
}
|
||||
|
||||
public static FluidStack getGasFromAspect(IAspectStack aspectStack) {
|
||||
if (aspectStack == null || aspectStack.isEmpty()) return null;
|
||||
return new FluidStack(
|
||||
GaseousEssentia.getGasFromAspect(aspectStack.getAspect()),
|
||||
(int) aspectStack.getStackSize() * R);
|
||||
}
|
||||
|
||||
public static boolean isEssentiaContainer(ItemStack stack) {
|
||||
return HELPER.getItemType(stack) != EssentiaItemContainerHelper.AspectItemType.Invalid
|
||||
&& HELPER.getItemType(stack) != EssentiaItemContainerHelper.AspectItemType.ItemAspect;
|
||||
}
|
||||
|
||||
public static AEFluidStack getAEGasFromContainer(ItemStack stack) {
|
||||
if (isEssentiaContainer(stack) && !isEmptyEssentiaContainer(stack)) {
|
||||
IAspectStack aspectStack = HELPER.getAspectStackFromContainer(stack);
|
||||
aspectStack.setStackSize(stack.stackSize * aspectStack.getStackSize());
|
||||
FluidStack gas = getGasFromAspect(aspectStack);
|
||||
return AEFluidStack.create(gas);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isEmptyEssentiaContainer(ItemStack stack) {
|
||||
return HELPER.isContainerEmpty(stack) && isEssentiaContainer(stack);
|
||||
}
|
||||
|
||||
public static ItemStack setAspectAmount(ItemStack itemStack, int amount, Aspect aspect) {
|
||||
if (isEssentiaContainer(itemStack)) {
|
||||
IEssentiaContainerItem container = (IEssentiaContainerItem) itemStack.getItem();
|
||||
assert container != null;
|
||||
container.getAspects(itemStack).aspects.put(aspect, amount);
|
||||
return itemStack;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> fillEssentiaFromGas(ItemStack itemStack, FluidStack fluid) {
|
||||
if (isEssentiaContainer(itemStack) && isEssentiaGas(fluid)) {
|
||||
if (itemStack.stackSize != 1) {
|
||||
return null;
|
||||
}
|
||||
Aspect aspect = getAspectFromGas(fluid);
|
||||
int amount = fluid.amount / R;
|
||||
EssentiaItemContainerHelper.AspectItemType iType = HELPER.getItemType(itemStack);
|
||||
if (iType == EssentiaItemContainerHelper.AspectItemType.JarLabel) {
|
||||
ItemStack label = itemStack.copy();
|
||||
HELPER.setLabelAspect(label, aspect);
|
||||
}
|
||||
int cap = HELPER.getContainerCapacity(itemStack);
|
||||
int tryFill = Math.min(cap, amount);
|
||||
ImmutablePair<Integer, ItemStack> result = HELPER
|
||||
.injectIntoContainer(itemStack, new AspectStack(aspect, tryFill));
|
||||
return result != null ? new MutablePair<>(result.left * R, result.right) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static MutablePair<Integer, ItemStack> drainEssentiaFromGas(ItemStack itemStack, FluidStack fluid) {
|
||||
if (isEssentiaContainer(itemStack) && isEssentiaGas(fluid)) {
|
||||
Aspect aspect = getAspectFromGas(fluid);
|
||||
int amount = fluid.amount / R;
|
||||
IAspectStack contents = HELPER.getAspectStackFromContainer(itemStack);
|
||||
int drained;
|
||||
ItemStack stack = null;
|
||||
if (contents == null || !Objects.equals(contents.getAspect(), aspect)) {
|
||||
drained = 0;
|
||||
} else {
|
||||
ImmutablePair<Integer, ItemStack> result = HELPER
|
||||
.extractFromContainer(itemStack, new AspectStack(aspect, amount));
|
||||
drained = result == null ? 0 : result.left;
|
||||
stack = result == null ? null : result.right;
|
||||
}
|
||||
return stack == null ? null : new MutablePair<>(drained * R, stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+13
-54
@@ -1,7 +1,5 @@
|
||||
package com.glodblock.github.crossmod.thaumcraft;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
@@ -11,14 +9,13 @@ import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumicenergistics.api.grid.IEssentiaGrid;
|
||||
import thaumicenergistics.common.items.ItemCraftingAspect;
|
||||
import thaumicenergistics.common.storage.AEEssentiaStack;
|
||||
|
||||
public class ThaumicEnergisticsCrafting {
|
||||
|
||||
@@ -39,6 +36,17 @@ public class ThaumicEnergisticsCrafting {
|
||||
return stack.getItem() == neiAddonAspect || stack.getItem() == thaumicEnergisticsAspect;
|
||||
}
|
||||
|
||||
public static IAEStack<?> convertItemAspectStack(IAEStack<?> stack) {
|
||||
if (stack instanceof IAEItemStack ais && isAspectStack(ais.getItemStack())) {
|
||||
Aspect aspect = getAspect(ais.getItemStack());
|
||||
if (aspect == null) return stack;
|
||||
|
||||
return new AEEssentiaStack(aspect, stack.getStackSize());
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "thaumicenergistics")
|
||||
private static @Nullable Aspect getAspect(ItemStack stack) {
|
||||
if (stack == null) return null;
|
||||
@@ -59,53 +67,4 @@ public class ThaumicEnergisticsCrafting {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Method(modid = "thaumicenergistics")
|
||||
private static ItemStack getAspectStack(Aspect aspect, int stackSize) {
|
||||
return ItemCraftingAspect.createStackForAspect(aspect, stackSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an aspect stack into a thaumic energistics stack.
|
||||
*/
|
||||
public static IAEItemStack convertAspectStack(IAEItemStack stack) {
|
||||
if (ModAndClassUtil.ThE) {
|
||||
return convertAspectStackImpl(stack);
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "thaumicenergistics")
|
||||
private static IAEItemStack convertAspectStackImpl(IAEItemStack stack) {
|
||||
if (stack == null) return null;
|
||||
|
||||
Aspect aspect = getAspect(stack.getItemStack());
|
||||
|
||||
if (aspect == null) return stack;
|
||||
|
||||
return Objects.requireNonNull(AEItemStack.create(getAspectStack(aspect, 1))).setStackSize(stack.getStackSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of essentia stored in a grid for a given aspect preview.
|
||||
*/
|
||||
public static long getEssentiaAmount(IAEItemStack stack, IGrid grid) {
|
||||
if (ModAndClassUtil.ThE) {
|
||||
return getEssentiaAmountImpl(stack, grid);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "thaumicenergistics")
|
||||
private static long getEssentiaAmountImpl(IAEItemStack stack, IGrid grid) {
|
||||
Aspect aspect = getAspect(stack.getItemStack());
|
||||
|
||||
if (aspect == null) return 0;
|
||||
|
||||
IEssentiaGrid essentiaGrid = grid.getCache(IEssentiaGrid.class);
|
||||
|
||||
return essentiaGrid.getEssentiaAmount(aspect);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.crossmod.waila.part.FluidInvWailaDataProvider;
|
||||
import com.glodblock.github.crossmod.waila.part.FluidMonitorWailaDataProvider;
|
||||
import com.glodblock.github.crossmod.waila.part.SpeedWailaDataProvider;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -32,8 +31,7 @@ public class PartWailaDataProvider implements IWailaDataProvider {
|
||||
public PartWailaDataProvider() {
|
||||
final IPartWailaDataProvider speed = new SpeedWailaDataProvider();
|
||||
final IPartWailaDataProvider fluidInv = new FluidInvWailaDataProvider();
|
||||
final IPartWailaDataProvider fluidMonitor = new FluidMonitorWailaDataProvider();
|
||||
this.providers = Lists.newArrayList(speed, fluidInv, fluidMonitor);
|
||||
this.providers = Lists.newArrayList(speed, fluidInv);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.glodblock.github.crossmod.waila.part;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.glodblock.github.common.parts.base.FCPartMonitor;
|
||||
import com.glodblock.github.crossmod.waila.Tooltip;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.integration.modules.waila.part.BasePartWailaDataProvider;
|
||||
import mcp.mobius.waila.api.IWailaConfigHandler;
|
||||
import mcp.mobius.waila.api.IWailaDataAccessor;
|
||||
|
||||
public class FluidMonitorWailaDataProvider extends BasePartWailaDataProvider {
|
||||
|
||||
private final String key = "fluidStore";
|
||||
|
||||
@Override
|
||||
public List<String> getWailaBody(final IPart part, final List<String> currentToolTip,
|
||||
final IWailaDataAccessor accessor, final IWailaConfigHandler config) {
|
||||
if (part instanceof FCPartMonitor && accessor.getNBTData().hasKey(key)) {
|
||||
IAEFluidStack iaeFluidStack = Util.loadFluidStackFromNBT(accessor.getNBTData().getCompoundTag(key));
|
||||
if (iaeFluidStack != null) currentToolTip.add(
|
||||
Tooltip.fluidFormat(
|
||||
iaeFluidStack.getFluidStack().getLocalizedName(),
|
||||
iaeFluidStack.getStackSize()));
|
||||
}
|
||||
return currentToolTip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getNBTData(final EntityPlayerMP player, final IPart part, final TileEntity te,
|
||||
final NBTTagCompound tag, final World world, final int x, final int y, final int z) {
|
||||
if (part instanceof FCPartMonitor && ((FCPartMonitor) part).getAEStoreFluidStack() != null) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
((FCPartMonitor) part).getAEStoreFluidStack().writeToNBT(data);
|
||||
tag.setTag(key, data);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.event.ClickEvent;
|
||||
import net.minecraft.event.HoverEvent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
|
||||
|
||||
private static boolean WrongFluidRemovedWarnIssued = false;
|
||||
|
||||
private final IFluidHandler handler;
|
||||
private final ForgeDirection side;
|
||||
private IItemList<IAEFluidStack> cache = AEApi.instance().storage().createFluidList();
|
||||
private final HashMap<IMEMonitorHandlerReceiver, Object> listeners = new HashMap<>();
|
||||
private BaseActionSource mySource;
|
||||
private StorageFilter mode;
|
||||
private boolean init = false;
|
||||
|
||||
public MEMonitorIFluidHandler(IFluidHandler handler, ForgeDirection side) {
|
||||
this.mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
this.handler = handler;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
public MEMonitorIFluidHandler(IFluidHandler handler) {
|
||||
this.mode = StorageFilter.EXTRACTABLE_ONLY;
|
||||
this.handler = handler;
|
||||
this.side = ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public void addListener(IMEMonitorHandlerReceiver l, Object verificationToken) {
|
||||
this.listeners.put(l, verificationToken);
|
||||
}
|
||||
|
||||
public void removeListener(IMEMonitorHandlerReceiver l) {
|
||||
this.listeners.remove(l);
|
||||
}
|
||||
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
|
||||
if (!this.handler.canFill(this.side, input.getFluid())) {
|
||||
return input;
|
||||
}
|
||||
|
||||
int filled = this.handler.fill(this.side, input.getFluidStack(), type == Actionable.MODULATE);
|
||||
|
||||
if (type == Actionable.MODULATE) {
|
||||
this.onTick();
|
||||
}
|
||||
|
||||
if ((long) filled == input.getStackSize()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IAEFluidStack o = input.copy();
|
||||
o.setStackSize(input.getStackSize() - (long) filled);
|
||||
return o;
|
||||
}
|
||||
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
|
||||
if (!this.handler.canDrain(this.side, request.getFluid())) {
|
||||
return null;
|
||||
}
|
||||
FluidStack removed = this.handler.drain(this.side, request.getFluidStack(), type == Actionable.MODULATE);
|
||||
if (removed != null && removed.amount != 0) {
|
||||
// perform a one time log if the removed fluid isn't what's reported since this will create a dupe exploit
|
||||
if (!WrongFluidRemovedWarnIssued && !removed.isFluidEqual(request.getFluidStack())) {
|
||||
WrongFluidRemovedWarnIssued = true;
|
||||
String issuesUrl = "https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/new";
|
||||
String msg = String.format(
|
||||
"[AE2FC] MEMonitorIFluidHandler.extractItems got the wrong fluids while extracting from %s. expected %s got %s. Please report this message if seen: ",
|
||||
this.handler.getClass().getSimpleName(),
|
||||
request.getFluidStack().getUnlocalizedName(),
|
||||
removed.getUnlocalizedName());
|
||||
// elevate log to error if chat msg is removed to make it easier to find.
|
||||
AELog.warn(msg + issuesUrl);
|
||||
|
||||
ChatComponentText chatTxt = new ChatComponentText(msg);
|
||||
chatTxt.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED).setBold(true));
|
||||
|
||||
ChatComponentText chatUrl = new ChatComponentText(issuesUrl);
|
||||
chatUrl.setChatStyle(
|
||||
new ChatStyle().setUnderlined(true)
|
||||
.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, issuesUrl))
|
||||
.setChatHoverEvent(
|
||||
new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ChatComponentText("Click to open link"))));
|
||||
|
||||
ChatComponentText chat = new ChatComponentText("");
|
||||
chat.appendSibling(chatTxt);
|
||||
chat.appendSibling(chatUrl);
|
||||
|
||||
MinecraftServer.getServer().getConfigurationManager().sendChatMsg(chat);
|
||||
}
|
||||
IAEFluidStack o = request.copy();
|
||||
o.setStackSize(removed.amount);
|
||||
if (type == Actionable.MODULATE) {
|
||||
IAEFluidStack cachedStack = this.cache.findPrecise(request);
|
||||
if (cachedStack != null) {
|
||||
cachedStack.decStackSize(o.getStackSize());
|
||||
this.postDifference(Collections.singletonList(o.copy().setStackSize(-o.getStackSize())));
|
||||
}
|
||||
}
|
||||
return o;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageChannel getChannel() {
|
||||
return StorageChannel.FLUIDS;
|
||||
}
|
||||
|
||||
// *Decompiled Stuff*//
|
||||
|
||||
public TickRateModulation onTick() {
|
||||
FluidTankInfo[] tankProperties = this.handler.getTankInfo(this.side);
|
||||
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().createFluidList();
|
||||
|
||||
if (tankProperties != null) {
|
||||
for (FluidTankInfo tankProperty : tankProperties) {
|
||||
if (this.mode != StorageFilter.EXTRACTABLE_ONLY || this.handler.drain(this.side, 1, false) != null) {
|
||||
currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make diff between cache and new contents
|
||||
IItemList<IAEStack<?>> changes = AEApi.instance().storage().createAEStackList();
|
||||
// using non-enhanced for to prevent concurrency errors
|
||||
for (Iterator<IAEFluidStack> iter = this.cache.iterator(); iter.hasNext();) {
|
||||
IAEFluidStack copy = iter.next().copy();
|
||||
copy.setStackSize(-copy.getStackSize());
|
||||
changes.add(copy);
|
||||
}
|
||||
for (IAEFluidStack is : currentlyOnStorage) {
|
||||
changes.add(is);
|
||||
}
|
||||
// update cache as soon as possible
|
||||
this.cache = currentlyOnStorage;
|
||||
// remove unchanged values
|
||||
for (Iterator<IAEStack<?>> iter = changes.iterator(); iter.hasNext();) {
|
||||
if (iter.next().getStackSize() == 0L) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (!changes.isEmpty()) {
|
||||
this.postDifference(changes);
|
||||
return TickRateModulation.URGENT;
|
||||
}
|
||||
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
private void postDifference(Iterable<IAEStack<?>> a) {
|
||||
if (a != null) {
|
||||
Iterator<Map.Entry<IMEMonitorHandlerReceiver, Object>> i = this.listeners.entrySet().iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
Map.Entry<IMEMonitorHandlerReceiver, Object> l = i.next();
|
||||
IMEMonitorHandlerReceiver key = l.getKey();
|
||||
if (key.isValid(l.getValue())) {
|
||||
key.postChange(this, a, this.getActionSource());
|
||||
} else {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AccessRestriction getAccess() {
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
public boolean isPrioritized(IAEFluidStack input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canAccept(IAEFluidStack input) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean validForPass(int i) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out, int iteration) {
|
||||
if (!init) {
|
||||
this.onTick();
|
||||
init = true;
|
||||
}
|
||||
for (IAEFluidStack fs : this.cache) {
|
||||
out.addStorage(fs);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack getAvailableItem(@Nonnull IAEFluidStack request, int iteration) {
|
||||
if (!init) {
|
||||
this.onTick();
|
||||
init = true;
|
||||
}
|
||||
return this.cache.findPrecise(request);
|
||||
}
|
||||
|
||||
public IItemList<IAEFluidStack> getStorageList() {
|
||||
return this.cache;
|
||||
}
|
||||
|
||||
public void setMode(StorageFilter mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
private BaseActionSource getActionSource() {
|
||||
return this.mySource;
|
||||
}
|
||||
|
||||
public void setActionSource(BaseActionSource mySource) {
|
||||
this.mySource = mySource;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.glodblock.github.inventory.external;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
|
||||
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
|
||||
// This handler is too generic, so it will overlap other mods' fluid handler.
|
||||
// It will be injected into external handler by ASM to make sure it is executed at last.
|
||||
public class AEFluidTankHandler implements IExternalStorageHandler {
|
||||
|
||||
public static final AEFluidTankHandler INSTANCE = new AEFluidTankHandler();
|
||||
|
||||
@Override
|
||||
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc) {
|
||||
return channel == StorageChannel.FLUIDS && te instanceof IFluidHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src) {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
return new MEMonitorIFluidHandler((IFluidHandler) te, d);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.crafting.v2.CraftingCalculations;
|
||||
import appeng.crafting.v2.CraftingRequest;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CalculatorV2PluginLoader {
|
||||
|
||||
private static long adjustByteCost(CraftingRequest<IAEItemStack> request, Long originalAmount) {
|
||||
if (request.stack.getItem() instanceof ItemFluidDrop) {
|
||||
return Platform.ceilDiv(originalAmount, 1000L);
|
||||
} else {
|
||||
return originalAmount;
|
||||
}
|
||||
}
|
||||
|
||||
public static void installCalculatorV2Plugins() {
|
||||
CraftingCalculations.registerByteAmountAdjuster(CalculatorV2PluginLoader::adjustByteCost, IAEItemStack.class);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidP2PInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileWalrus;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import com.glodblock.github.crossmod.thaumcraft.ThaumicEnergisticsCrafting;
|
||||
import com.glodblock.github.inventory.external.AEFluidInterfaceHandler;
|
||||
import com.glodblock.github.inventory.item.WirelessMagnet;
|
||||
@@ -89,9 +88,6 @@ public class CommonProxy {
|
||||
|
||||
public void init(FMLInitializationEvent event) {
|
||||
this.registerMovables();
|
||||
if (ModAndClassUtil.ThE) {
|
||||
AspectUtil.init();
|
||||
}
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import static appeng.util.item.AEFluidStackType.FLUID_STACK_TYPE;
|
||||
import static appeng.util.item.AEItemStackType.ITEM_STACK_TYPE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -18,7 +21,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
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 appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -36,7 +38,6 @@ import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
@@ -44,6 +45,7 @@ import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.storage.MEMonitorIFluidHandler;
|
||||
import appeng.me.storage.MEMonitorPassThrough;
|
||||
import appeng.me.storage.NullInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -67,10 +69,10 @@ public class DualityFluidInterface implements IGridTickable, IStorageMonitorable
|
||||
private int isWorking = -1;
|
||||
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<IAEItemStack>(
|
||||
new NullInventory<>(),
|
||||
StorageChannel.ITEMS);
|
||||
ITEM_STACK_TYPE);
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<IAEFluidStack>(
|
||||
new NullInventory<>(),
|
||||
StorageChannel.FLUIDS);
|
||||
FLUID_STACK_TYPE);
|
||||
private boolean resetConfigCache = true;
|
||||
|
||||
public DualityFluidInterface(final AENetworkProxy networkProxy, final IInterfaceHost ih) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.glodblock.github.coremod.registries;
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
Reference in new issue
Block a user