mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
refactor 5
This commit is contained in:
1 parent
d9449622b9
commit
5b62c4fdc8
17 files changed
+204
-510
No files matched your search
@@ -30,6 +30,7 @@ import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
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;
|
||||
@@ -64,7 +65,7 @@ public class DualityFluidInterface
|
||||
private final IAEFluidStack[] requireWork;
|
||||
private int isWorking = -1;
|
||||
private final MEMonitorPassThrough<IAEItemStack> items =
|
||||
new MEMonitorPassThrough<IAEItemStack>(new NullInventory<IAEItemStack>(), StorageChannel.ITEMS);
|
||||
new MEMonitorPassThrough<IAEItemStack>(new NullInventory<>(), StorageChannel.ITEMS);
|
||||
private final MEMonitorPassThrough<IAEFluidStack> fluids =
|
||||
new MEMonitorPassThrough<IAEFluidStack>(new NullInventory<>(), StorageChannel.FLUIDS);
|
||||
private boolean resetConfigCache = true;
|
||||
@@ -133,6 +134,13 @@ public class DualityFluidInterface
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public void loadConfigFromPacket(IInventory packet) {
|
||||
for (int i = 0; i < packet.getSizeInventory(); i++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(packet.getStackInSlot(i));
|
||||
config.setFluidInSlot(i, this.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
|
||||
public AEFluidInventory getTanks() {
|
||||
return this.tanks;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.IIcon;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class RenderUtil {
|
||||
|
||||
@@ -37,4 +43,27 @@ public final class RenderUtil {
|
||||
}
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
|
||||
public static void renderFluidIntoGui(
|
||||
Gui gui, int x, int y, int width, int height, @Nullable IAEFluidStack aeFluidStack, int capacity) {
|
||||
if (aeFluidStack != null) {
|
||||
GL11.glDisable(2896);
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
int hi = (int) (height * ((double) aeFluidStack.getStackSize() / capacity));
|
||||
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
|
||||
GL11.glColor3f(
|
||||
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
|
||||
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
|
||||
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
|
||||
for (int th = 0; th <= hi; th += 16) {
|
||||
if (hi - th <= 0) break;
|
||||
gui.drawTexturedModelRectFromIcon(
|
||||
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
|
||||
}
|
||||
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,11 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -190,6 +192,17 @@ public final class Util {
|
||||
return fluid1.isFluidEqual(fluid2);
|
||||
}
|
||||
|
||||
public static void mirrorFluidToPacket(IInventory packet, IAEFluidTank fluidTank) {
|
||||
for (int i = 0; i < fluidTank.getSlots(); i++) {
|
||||
IAEFluidStack fluid = fluidTank.getFluidInSlot(i);
|
||||
if (fluid == null) {
|
||||
packet.setInventorySlotContents(i, null);
|
||||
} else {
|
||||
packet.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FluidUtil {
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
|
||||
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
|
||||
@@ -301,12 +314,11 @@ public final class Util {
|
||||
if (item instanceof IFluidContainerItem) {
|
||||
FluidStack drained = ((IFluidContainerItem) item).drain(itemStack, fluid.amount, true);
|
||||
int amountDrained = drained != null && drained.getFluid() == fluid.getFluid() ? drained.amount : 0;
|
||||
return new MutablePair<Integer, ItemStack>(amountDrained, itemStack);
|
||||
return new MutablePair<>(amountDrained, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
FluidStack content = FluidContainerRegistry.getFluidForFilledItem(itemStack);
|
||||
int amountDrained = content != null && content.getFluid() == fluid.getFluid() ? content.amount : 0;
|
||||
return new MutablePair<Integer, ItemStack>(
|
||||
amountDrained, FluidContainerRegistry.drainFluidContainer(itemStack));
|
||||
return new MutablePair<>(amountDrained, FluidContainerRegistry.drainFluidContainer(itemStack));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -321,14 +333,14 @@ public final class Util {
|
||||
int filled = ((IFluidContainerItem) item).fill(itemStack, fluid, true);
|
||||
|
||||
// Return the filled itemstack.
|
||||
return new MutablePair<Integer, ItemStack>(filled, itemStack);
|
||||
return new MutablePair<>(filled, itemStack);
|
||||
} else if (FluidContainerRegistry.isContainer(itemStack)) {
|
||||
// Fill it through the fluidcontainer registry.
|
||||
ItemStack filledContainer = FluidContainerRegistry.fillFluidContainer(fluid, itemStack);
|
||||
// get the filled fluidstack.
|
||||
FluidStack filled = FluidContainerRegistry.getFluidForFilledItem(filledContainer);
|
||||
// Return filled container and fill amount.
|
||||
return new MutablePair<Integer, ItemStack>(filled != null ? filled.amount : 0, filledContainer);
|
||||
return new MutablePair<>(filled != null ? filled.amount : 0, filledContainer);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user