mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 10:55:06 +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,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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user