mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 18:44:42 +00:00
wireless universal terminal
This commit is contained in:
1 parent
e1aa537670
commit
513af871aa
17 files changed
+544
-9
No files matched your search
@@ -0,0 +1,89 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
|
||||
import com.glodblock.github.client.me.EssentiaRepo;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectRender;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GuiEssentiaTerminal extends GuiFluidMonitor {
|
||||
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
protected EntityPlayer player;
|
||||
|
||||
public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
|
||||
super(inventoryPlayer, te, new ContainerEssentiaMonitor(inventoryPlayer, te));
|
||||
this.repo = new EssentiaRepo(getScrollBar(), this);
|
||||
this.player = inventoryPlayer.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextFieldValue(String displayName, int mousex, int mousey, ItemStack stack) {
|
||||
if (AspectUtil.getAspectFromJar(stack) != null) {
|
||||
setSearchString(Objects.requireNonNull(AspectUtil.getAspectFromJar(stack)).getName(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_146977_a(final Slot s) {
|
||||
if (drawSlot0(s)) super.func_146977_a(s);
|
||||
}
|
||||
|
||||
public boolean drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotME) {
|
||||
IAEItemStack stack = ((SlotME) slot).getAEStack();
|
||||
if (stack == null) return true;
|
||||
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
|
||||
AspectRender.drawAspect(this.player, slot.xDisplayPosition, slot.yDisplayPosition, this.zLevel, AspectUtil.getAspectFromGas(fluidStack), fluidStack.amount);
|
||||
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
|
||||
stackSizeRenderer.setAeStack(gas);
|
||||
stackSizeRenderer.renderItemOverlayIntoGUI(
|
||||
fontRendererObj,
|
||||
mc.getTextureManager(),
|
||||
gas.getItemStack(),
|
||||
slot.xDisplayPosition,
|
||||
slot.yDisplayPosition);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof SlotME && AspectUtil.isEssentiaContainer(player.inventory.getItemStack())) {
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
ItemStack itemStack = this.player.inventory.getItemStack().copy();
|
||||
tmp.put(0, ItemFluidDrop.getAeFluidStack(((SlotME) slot).getAEStack()));
|
||||
if (!isShiftKeyDown()) {
|
||||
itemStack.stackSize = 1;
|
||||
}
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, itemStack));
|
||||
}
|
||||
if (mouseButton == 3 && slot instanceof SlotME) {
|
||||
return;
|
||||
}
|
||||
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
|
||||
}
|
||||
|
||||
public void update(ItemStack itemStack) {
|
||||
this.player.inventory.setItemStack(itemStack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -375,7 +375,6 @@ public abstract class FCGuiMonitor<T extends IAEStack<T>> extends AEBaseMEGui
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (mouseButton == 3) {
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.container.slot.SlotPlayerHotBar;
|
||||
import appeng.container.slot.SlotPlayerInv;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.network.CPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import com.glodblock.github.network.SPacketMEInventoryUpdate;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContainerEssentiaMonitor extends ContainerFluidPortableCell {
|
||||
|
||||
public ContainerEssentiaMonitor(InventoryPlayer ip, IWirelessTerminal monitorable) {
|
||||
super(ip, monitorable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
|
||||
&& AspectUtil.isEssentiaContainer(clickSlot.getStack())) {
|
||||
ItemStack tis = clickSlot.getStack();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
tmp.put(0, null);
|
||||
int index = Util.findItemInPlayerInvSlot(p, clickSlot.getStack());
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidUpdate(tmp, tis, index));
|
||||
}
|
||||
}
|
||||
return super.transferStackInSlot(p, idx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) {
|
||||
for (IAEFluidStack fluid : change) {
|
||||
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
|
||||
ItemStack out = fluidContainer.copy();
|
||||
out.stackSize = 1;
|
||||
if (AspectUtil.isEmptyEssentiaContainer(fluidContainer) && AspectUtil.isEssentiaGas(fluid)) {
|
||||
// add essentia to jars
|
||||
if (nfluid.getStackSize() / AspectUtil.R <= 0) continue;
|
||||
final IAEFluidStack toExtract = nfluid.copy();
|
||||
MutablePair<Integer, ItemStack> fillStack = AspectUtil.fillEssentiaFromGas(out, toExtract.getFluidStack());
|
||||
if (fillStack == null || fillStack.right == null || fillStack.left <= 0) continue;
|
||||
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
|
||||
IAEFluidStack tmp = this.host.getFluidInventory().extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
|
||||
if (tmp == null) continue;
|
||||
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
|
||||
this.dropItem(fillStack.right);
|
||||
out.stackSize = fillStack.right.stackSize;
|
||||
if (AspectUtil.isEssentiaContainer(fillStack.right)) {
|
||||
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
|
||||
if ((int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R > 0) {
|
||||
this.dropItem(
|
||||
AspectUtil.setAspectAmount(
|
||||
fillStack.right,
|
||||
(int) (tmp.getStackSize() % fillStack.left) / AspectUtil.R,
|
||||
AspectUtil.getAspectFromGas(toExtract)),
|
||||
1);
|
||||
out.stackSize++;
|
||||
}
|
||||
}
|
||||
} else if (!AspectUtil.isEmptyEssentiaContainer(fluidContainer)) {
|
||||
// add essentia to ae network
|
||||
AEFluidStack fluidStack = AspectUtil.getAEGasFromContainer(fluidContainer);
|
||||
if (fluidStack == null) {
|
||||
continue;
|
||||
}
|
||||
final IAEFluidStack aeFluidStack = fluidStack.copy();
|
||||
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
|
||||
final IAEFluidStack notInserted = this.host.getFluidInventory()
|
||||
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
MutablePair<Integer, ItemStack> drainStack = AspectUtil.drainEssentiaFromGas(out.copy(), aeFluidStack.getFluidStack());
|
||||
if (notInserted != null && notInserted.getStackSize() > 0 && drainStack != null) {
|
||||
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
|
||||
if (drainStack.left > aeFluidStack.getStackSize()
|
||||
&& AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
|
||||
this.host.getFluidInventory()
|
||||
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
|
||||
continue;
|
||||
}
|
||||
|
||||
// drop empty item
|
||||
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left));
|
||||
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
|
||||
if (AspectUtil.isEssentiaContainer(drainStack.right)) {
|
||||
if (notInserted.getStackSize() % drainStack.left > 0) {
|
||||
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
|
||||
AspectUtil.fillEssentiaFromGas(drainStack.right, fluidStack.getFluidStack());
|
||||
this.dropItem(drainStack.right, 1);
|
||||
}
|
||||
}
|
||||
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
|
||||
} else if (drainStack != null) {
|
||||
if (slotIndex == -1) {
|
||||
out.stackSize = fluidContainer.stackSize;
|
||||
} else {
|
||||
if (drainStack != null) {
|
||||
System.out.print("---------\n");
|
||||
System.out.print(drainStack.right + "\n");
|
||||
System.out.print(drainStack.left + "\n");
|
||||
System.out.print(aeFluidStack.getStackSize() + "\n");
|
||||
}
|
||||
out.stackSize = (int) (fluidContainer.stackSize
|
||||
- (aeFluidStack.getStackSize() / drainStack.left));
|
||||
}
|
||||
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
if (slotIndex == -1) {
|
||||
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
|
||||
if (player.inventory.getItemStack().stackSize > 0) {
|
||||
FluidCraft.proxy.netHandler.sendTo(
|
||||
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
|
||||
(EntityPlayerMP) player);
|
||||
} else {
|
||||
player.inventory.setItemStack(null);
|
||||
FluidCraft.proxy.netHandler
|
||||
.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
|
||||
}
|
||||
} else {
|
||||
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
|
||||
}
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEssentiaMode() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -50,7 +50,7 @@ import com.glodblock.github.util.Util;
|
||||
|
||||
public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
|
||||
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
protected final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().createFluidList();
|
||||
|
||||
public ContainerFluidMonitor(final InventoryPlayer ip, final ITerminalHost monitorable) {
|
||||
this(ip, monitorable, true);
|
||||
@@ -109,7 +109,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
|
||||
if (Platform.isClient()) {
|
||||
if (Platform.isClient() && !isEssentiaMode()) {
|
||||
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
|
||||
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack()
|
||||
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
|
||||
@@ -183,7 +183,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(ItemStack is) {
|
||||
protected void dropItem(ItemStack is) {
|
||||
if (is == null || is.stackSize <= 0) return;
|
||||
ItemStack itemStack = is.copy();
|
||||
int i = itemStack.getMaxStackSize();
|
||||
@@ -204,7 +204,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
private void dropItem(ItemStack itemStack, int stackSize) {
|
||||
protected void dropItem(ItemStack itemStack, int stackSize) {
|
||||
if (itemStack == null || itemStack.stackSize <= 0) return;
|
||||
ItemStack is = itemStack.copy();
|
||||
is.stackSize = stackSize;
|
||||
@@ -314,4 +314,8 @@ public class ContainerFluidMonitor extends FCContainerMonitor<IAEFluidStack> {
|
||||
}
|
||||
this.detectAndSendChanges();
|
||||
}
|
||||
|
||||
protected boolean isEssentiaMode() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.glodblock.github.client.me;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.crossmod.thaumcraft.AspectUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class EssentiaRepo extends FluidRepo {
|
||||
|
||||
public EssentiaRepo(final IScrollSource src, final ISortSource sortSrc) {
|
||||
super(src, sortSrc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateView() {
|
||||
super.updateView();
|
||||
Iterator<IAEItemStack> it1 = this.view.iterator();
|
||||
while (it1.hasNext()) {
|
||||
IAEFluidStack fluid = ItemFluidDrop.getAeFluidStack(it1.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it1.remove();
|
||||
}
|
||||
}
|
||||
Iterator<ItemStack> it2 = this.dsp.iterator();
|
||||
while (it2.hasNext()) {
|
||||
FluidStack fluid = ItemFluidDrop.getFluidStack(it2.next());
|
||||
if (!AspectUtil.isEssentiaGas(fluid)) {
|
||||
it2.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,8 +39,8 @@ import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
public class FluidRepo extends ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<IAEItemStack>();
|
||||
private final ArrayList<ItemStack> dsp = new ArrayList<ItemStack>();
|
||||
protected final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
protected final ArrayList<ItemStack> dsp = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
@@ -182,7 +182,7 @@ public class FluidRepo extends ItemRepo {
|
||||
private void updateNEI(final String filter) {
|
||||
try {
|
||||
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
|
||||
final Class c = ReflectionHelper
|
||||
final Class<?> c = ReflectionHelper
|
||||
.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
|
||||
final Field fldSearchField = c.getField("searchField");
|
||||
final Object searchField = fldSearchField.get(c);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.util.Platform;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.WirelessFluidTerminal;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
|
||||
implements IRegister<ItemWirelessUltraTerminal> {
|
||||
|
||||
public ItemWirelessUltraTerminal() {
|
||||
super(GuiType.WIRELESS_ESSENTIA_TERMINAL);
|
||||
AEApi.instance().registries().wireless().registerWirelessHandler(this);
|
||||
this.setFeature(EnumSet.of(AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools));
|
||||
setUnlocalizedName(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL);
|
||||
setTextureName(FluidCraft.resource(NameConst.ITEM_WIRELESS_ULTRA_TERMINAL).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemWirelessUltraTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_WIRELESS_ULTRA_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getInventory(ItemStack stack, World world, int x, int y, int z, EntityPlayer player) {
|
||||
try {
|
||||
IGridNode gridNode = Util.getWirelessGrid(stack);
|
||||
if (gridNode != null) {
|
||||
return new WirelessFluidTerminal(stack, x, gridNode, player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (Platform.isClient()) player.addChatMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,9 @@ public class PartFluidPatternTerminal extends FCFluidEncodeTerminal {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inv == this.crafting) {
|
||||
this.fixCraftingRecipes();
|
||||
}
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.glodblock.github.crossmod.thaumcraft;
|
||||
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.glodblock.github.crossmod.thaumcraft;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.aspects.IEssentiaContainerItem;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import thaumicenergistics.api.storage.IAspectStack;
|
||||
import thaumicenergistics.common.fluids.GaseousEssentia;
|
||||
import thaumicenergistics.common.integration.tc.EssentiaItemContainerHelper;
|
||||
import thaumicenergistics.common.storage.AspectStack;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class AspectUtil {
|
||||
|
||||
public static final EssentiaItemContainerHelper HELPER = EssentiaItemContainerHelper.INSTANCE;
|
||||
public static final int R = 128;
|
||||
|
||||
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(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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,6 +208,7 @@ public enum GuiType {
|
||||
return new GuiFluidPortableCell(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
WIRELESS_FLUID_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
@@ -220,6 +221,20 @@ public enum GuiType {
|
||||
return new GuiFluidPortableCell(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
WIRELESS_ESSENTIA_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new ContainerEssentiaMonitor(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
|
||||
return new GuiEssentiaTerminal(player.inventory, inv);
|
||||
}
|
||||
}),
|
||||
|
||||
WIRELESS_FLUID_PATTERN_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ public class ItemAndBlockHolder {
|
||||
public static ItemFluidConversionMonitor FLUID_CONVERSION_MONITOR = new ItemFluidConversionMonitor().register();
|
||||
public static ItemPortableFluidCell PORTABLE_FLUID_CELL = new ItemPortableFluidCell().register();
|
||||
public static ItemWirelessFluidTerminal WIRELESS_FLUID_TERM = new ItemWirelessFluidTerminal().register();
|
||||
public static ItemWirelessUltraTerminal WIRELESS_ULTRA_TERM = new ItemWirelessUltraTerminal().register();
|
||||
public static ItemWirelessPatternTerminal WIRELESS_PATTERN_TERM = new ItemWirelessPatternTerminal().register();
|
||||
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
|
||||
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
|
||||
|
||||
@@ -98,6 +98,12 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
} else {
|
||||
((GuiFluidTerminal) gs).update(null);
|
||||
}
|
||||
} else if (gs instanceof GuiEssentiaTerminal) {
|
||||
if (message.itemStack != null) {
|
||||
((GuiEssentiaTerminal) gs).update(message.itemStack.getItemStack());
|
||||
} else {
|
||||
((GuiEssentiaTerminal) gs).update(null);
|
||||
}
|
||||
} else if (gs instanceof GuiFluidStorageBus) {
|
||||
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet())
|
||||
((GuiFluidStorageBus) gs).update(e.getKey(), e.getValue());
|
||||
|
||||
@@ -37,6 +37,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
|
||||
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
|
||||
public static final String ITEM_WIRELESS_ULTRA_TERMINAL = "wireless_ultra_terminal";
|
||||
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ public final class Util {
|
||||
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 it's a fluid container item instance
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
// Call the fill method on it.
|
||||
int filled = ((IFluidContainerItem) item).fill(itemStack, fluid, true);
|
||||
|
||||
Reference in new issue
Block a user