mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
refactor 5
This commit is contained in:
1 parent
d9449622b9
commit
5b62c4fdc8
17 files changed
+204
-510
No files matched your search
@@ -120,9 +120,10 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
final boolean backwards = Mouse.isButtonDown(1);
|
||||
|
||||
if (btn == null) {
|
||||
return;
|
||||
}
|
||||
if (btn == this.priority) {
|
||||
if (isTile()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY_TILE));
|
||||
@@ -149,7 +150,7 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
if (btn == this.insertionMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards));
|
||||
}
|
||||
if (btn == this.sidelessMode && this.sidelessMode != null) {
|
||||
if (btn == this.sidelessMode) {
|
||||
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,23 +7,21 @@ import appeng.core.localization.GuiText;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidInterface;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketSwitchGuis;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -34,20 +32,12 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png");
|
||||
private static final int TANK_X = 35, TANK_X_OFF = 18, TANK_Y = 53;
|
||||
private static final int TANK_WIDTH = 16, TANK_HEIGHT = 68;
|
||||
|
||||
private final ContainerFluidInterface cont;
|
||||
|
||||
private GuiTabButton switcher;
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
|
||||
public GuiFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
|
||||
super(new ContainerFluidInterface(ipl, tile));
|
||||
this.cont = (ContainerFluidInterface) inventorySlots;
|
||||
this.ySize = 231;
|
||||
this.addMouseRegin();
|
||||
}
|
||||
|
||||
public GuiFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
|
||||
public GuiFluidInterface(InventoryPlayer ipl, IDualHost tile) {
|
||||
super(new ContainerFluidInterface(ipl, tile));
|
||||
this.cont = (ContainerFluidInterface) inventorySlots;
|
||||
this.ySize = 231;
|
||||
@@ -61,11 +51,7 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
TANK_HEIGHT,
|
||||
new TankMouseHandler(
|
||||
isPart()
|
||||
? ((PartFluidInterface) cont.getTile()).getInternalFluid()
|
||||
: ((TileFluidInterface) cont.getTile()).getInternalFluid(),
|
||||
i));
|
||||
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,19 +84,14 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
IAEFluidTank fluidInv;
|
||||
if (isPart()) {
|
||||
fluidInv = ((PartFluidInterface) cont.getTile()).getInternalFluid();
|
||||
} else {
|
||||
fluidInv = ((TileFluidInterface) cont.getTile()).getInternalFluid();
|
||||
}
|
||||
|
||||
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (!isPart()) {
|
||||
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
|
||||
}
|
||||
renderFluidIntoGui(
|
||||
RenderUtil.renderFluidIntoGui(
|
||||
this,
|
||||
TANK_X + i * TANK_X_OFF,
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
@@ -132,29 +113,6 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
}
|
||||
|
||||
public void renderFluidIntoGui(
|
||||
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;
|
||||
this.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
@@ -166,18 +124,9 @@ public class GuiFluidInterface extends AEBaseGui {
|
||||
|
||||
public void update(int id, IAEFluidStack stack) {
|
||||
if (id >= 100) {
|
||||
id -= 100;
|
||||
if (isPart()) {
|
||||
((PartFluidInterface) cont.getTile()).setConfig(id, stack);
|
||||
} else {
|
||||
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
|
||||
}
|
||||
cont.getTile().setConfig(id - 100, stack);
|
||||
} else {
|
||||
if (isPart()) {
|
||||
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
|
||||
} else {
|
||||
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
|
||||
}
|
||||
cont.getTile().setFluidInv(id, stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,10 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -40,7 +38,7 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
TANK_HEIGHT,
|
||||
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
|
||||
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
|
||||
mouseRegions.addRegion(
|
||||
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
|
||||
}
|
||||
@@ -65,10 +63,11 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
|
||||
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
renderFluidIntoGui(
|
||||
RenderUtil.renderFluidIntoGui(
|
||||
this,
|
||||
TANK_X + i * TANK_X_OFF,
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
@@ -77,34 +76,10 @@ public class GuiIngredientBuffer extends AEBaseGui {
|
||||
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
|
||||
}
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
mouseRegions.render(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void renderFluidIntoGui(
|
||||
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;
|
||||
this.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update(int slot, IAEFluidStack aeFluidStack) {
|
||||
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
|
||||
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,10 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.gui.TankMouseHandler;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -40,7 +38,7 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
TANK_HEIGHT,
|
||||
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
|
||||
new TankMouseHandler(cont.getTile().getInternalFluid(), i));
|
||||
mouseRegions.addRegion(
|
||||
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
|
||||
}
|
||||
@@ -66,10 +64,11 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
|
||||
IAEFluidTank fluidInv = cont.getTile().getInternalFluid();
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
for (int i = 0; i < 7; i++) {
|
||||
renderFluidIntoGui(
|
||||
RenderUtil.renderFluidIntoGui(
|
||||
this,
|
||||
TANK_X + i * TANK_X_OFF,
|
||||
TANK_Y,
|
||||
TANK_WIDTH,
|
||||
@@ -78,34 +77,10 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
|
||||
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
|
||||
}
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
|
||||
mouseRegions.render(mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void renderFluidIntoGui(
|
||||
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;
|
||||
this.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update(int slot, IAEFluidStack aeFluidStack) {
|
||||
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
|
||||
cont.getTile().getInternalFluid().setFluidInSlot(slot, aeFluidStack);
|
||||
}
|
||||
}
|
||||
+12
-39
@@ -6,8 +6,7 @@ import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
import com.glodblock.github.common.tile.TileFluidInterface;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import java.util.HashMap;
|
||||
@@ -19,9 +18,9 @@ import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost {
|
||||
|
||||
private final Object tile;
|
||||
private final IDualHost tile;
|
||||
|
||||
public ContainerFluidInterface(InventoryPlayer ipl, TileFluidInterface tile) {
|
||||
public ContainerFluidInterface(InventoryPlayer ipl, IDualHost tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
IInventory inv = tile.getConfig();
|
||||
@@ -34,20 +33,7 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
|
||||
bindPlayerInventory(ipl, 0, 149);
|
||||
}
|
||||
|
||||
public ContainerFluidInterface(InventoryPlayer ipl, PartFluidInterface tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
IInventory inv = tile.getConfig();
|
||||
final int y = 35;
|
||||
final int x = 35;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(
|
||||
inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
|
||||
}
|
||||
bindPlayerInventory(ipl, 0, 149);
|
||||
}
|
||||
|
||||
public Object getTile() {
|
||||
public IDualHost getTile() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
@@ -60,28 +46,15 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
if (tile instanceof TileFluidInterface) {
|
||||
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i++) {
|
||||
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
|
||||
}
|
||||
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i++) {
|
||||
tmp.put(
|
||||
i + 100,
|
||||
AEFluidStack.create(ItemFluidPacket.getFluidStack(
|
||||
((TileFluidInterface) tile).getConfig().getStackInSlot(i))));
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i++) {
|
||||
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
|
||||
}
|
||||
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i++) {
|
||||
tmp.put(
|
||||
i + 100,
|
||||
AEFluidStack.create(ItemFluidPacket.getFluidStack(
|
||||
((PartFluidInterface) tile).getConfig().getStackInSlot(i))));
|
||||
}
|
||||
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
|
||||
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
|
||||
}
|
||||
for (int i = 0; i < tile.getConfig().getSizeInventory(); i++) {
|
||||
tmp.put(
|
||||
i + 100,
|
||||
AEFluidStack.create(
|
||||
ItemFluidPacket.getFluidStack(tile.getConfig().getStackInSlot(i))));
|
||||
}
|
||||
|
||||
for (final Object g : this.crafters) {
|
||||
if (g instanceof EntityPlayer) {
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
|
||||
|
||||
+10
-6
@@ -22,10 +22,14 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements ITankD
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
IInventory inv = tile.getInternalInventory();
|
||||
addSlots(inv);
|
||||
bindPlayerInventory(ipl, 0, 140);
|
||||
}
|
||||
|
||||
protected void addSlots(IInventory inv) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new SlotNormal(inv, i, 8 + 18 * i, 108));
|
||||
}
|
||||
bindPlayerInventory(ipl, 0, 140);
|
||||
}
|
||||
|
||||
public TileIngredientBuffer getTile() {
|
||||
@@ -34,13 +38,13 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements ITankD
|
||||
|
||||
@Override
|
||||
public boolean canDumpTank(int index) {
|
||||
return tile.getFluidInventory().getFluidInSlot(index) != null;
|
||||
return tile.getInternalFluid().getFluidInSlot(index) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpTank(int index) {
|
||||
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
|
||||
tile.getFluidInventory().setFluidInSlot(index, null);
|
||||
if (index >= 0 && index < tile.getInternalFluid().getSlots()) {
|
||||
tile.getInternalFluid().setFluidInSlot(index, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +52,8 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements ITankD
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
|
||||
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
|
||||
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
|
||||
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
|
||||
}
|
||||
for (final Object g : this.crafters) {
|
||||
if (g instanceof EntityPlayer) {
|
||||
|
||||
+4
-45
@@ -1,62 +1,21 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotNormal;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.ITankDump;
|
||||
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements ITankDump {
|
||||
|
||||
private final TileLargeIngredientBuffer tile;
|
||||
public class ContainerLargeIngredientBuffer extends ContainerIngredientBuffer {
|
||||
|
||||
public ContainerLargeIngredientBuffer(InventoryPlayer ipl, TileLargeIngredientBuffer tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
IInventory inv = tile.getInternalInventory();
|
||||
}
|
||||
|
||||
protected void addSlots(IInventory inv) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
addSlotToContainer(new SlotNormal(inv, i * 9 + j, 8 + 18 * j, 72 + 18 * i));
|
||||
}
|
||||
}
|
||||
bindPlayerInventory(ipl, 0, 140);
|
||||
}
|
||||
|
||||
public TileLargeIngredientBuffer getTile() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDumpTank(int index) {
|
||||
return tile.getFluidInventory().getFluidInSlot(index) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpTank(int index) {
|
||||
if (index >= 0 && index < tile.getFluidInventory().getSlots()) {
|
||||
tile.getFluidInventory().setFluidInSlot(index, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
|
||||
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
|
||||
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
|
||||
}
|
||||
for (final Object g : this.crafters) {
|
||||
if (g instanceof EntityPlayer) {
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.client.textures.FCPartsTexture;
|
||||
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.IDualHost;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
@@ -46,9 +46,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidInterface extends PartInterface implements IFluidHandler, IAEFluidInventory {
|
||||
public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
|
||||
private final BaseActionSource ownActionSource = new MachineSource(this);
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
@@ -136,23 +135,19 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
fluidDuality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualityFluidInterface getDualityFluid() {
|
||||
return fluidDuality;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFluidInventory getInternalFluid() {
|
||||
return fluidDuality.getTanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngInternalAEInventory getConfig() {
|
||||
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
|
||||
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
|
||||
if (fluid == null) {
|
||||
config.setInventorySlotContents(i, null);
|
||||
} else {
|
||||
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
|
||||
}
|
||||
}
|
||||
Util.mirrorFluidToPacket(this.config, fluidDuality.getConfig());
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -161,24 +156,8 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
super.writeToStream(data);
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
getInternalFluid().writeToBuf(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -191,27 +170,9 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
config.setInventorySlotContents(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
getInternalFluid().setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
getInternalFluid().setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
changed |= getInternalFluid().readFromBuf(data);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -219,10 +180,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
config.readFromNBT(data, "ConfigInv");
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
|
||||
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
getInternalFluid().readFromNBT(data, "FluidInv");
|
||||
}
|
||||
|
||||
@@ -320,6 +278,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
fluidDuality.onFluidInventoryChanged(inv, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
config.setInventorySlotContents(
|
||||
@@ -328,6 +287,7 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInv(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
getInternalFluid().setFluidInSlot(id, fluid);
|
||||
|
||||
@@ -33,7 +33,6 @@ import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
@@ -233,7 +232,7 @@ public class PartFluidStorageBus extends PartUpgradeable
|
||||
final BaseActionSource source) {
|
||||
if (this.getProxy().isActive()) {
|
||||
AccessRestriction currentAccess =
|
||||
(AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
|
||||
(AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
|
||||
if (readOncePass) {
|
||||
readOncePass = false;
|
||||
try {
|
||||
|
||||
@@ -15,13 +15,13 @@ import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
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;
|
||||
import com.glodblock.github.inventory.IDualHost;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
@@ -32,31 +32,28 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory {
|
||||
public class TileFluidInterface extends TileInterface implements IDualHost {
|
||||
|
||||
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
|
||||
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
|
||||
private final IConfigManager dualityConfigManager =
|
||||
getInterfaceDuality().getConfigManager();
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
SidelessMode mode = (SidelessMode) dualityConfigManager.getSetting(Settings.SIDELESS_MODE);
|
||||
if (mode == SidelessMode.SIDELESS) {
|
||||
return this.getTanks().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
return this.getTanks().drain(from.ordinal(), maxDrain, doDrain);
|
||||
}
|
||||
};
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
|
||||
public TileFluidInterface() {
|
||||
super.getInterfaceDuality().getConfigManager().registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
|
||||
}
|
||||
|
||||
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 6);
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void stateChange(final MENetworkChannelsChanged c) {
|
||||
fluidDuality.onChannelStateChange(c);
|
||||
@@ -75,23 +72,19 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
fluidDuality.gridChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DualityFluidInterface getDualityFluid() {
|
||||
return fluidDuality;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFluidInventory getInternalFluid() {
|
||||
return fluidDuality.getTanks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppEngInternalAEInventory getConfig() {
|
||||
for (int i = 0; i < fluidDuality.getConfig().getSlots(); i++) {
|
||||
IAEFluidStack fluid = fluidDuality.getConfig().getFluidInSlot(i);
|
||||
if (fluid == null) {
|
||||
config.setInventorySlotContents(i, null);
|
||||
} else {
|
||||
config.setInventorySlotContents(i, ItemFluidPacket.newDisplayStack(fluid.getFluidStack()));
|
||||
}
|
||||
}
|
||||
Util.mirrorFluidToPacket(this.config, fluidDuality.getConfig());
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -121,24 +114,8 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
protected void writeToStream(ByteBuf data) throws IOException {
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, config.getStackInSlot(i));
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
IAEFluidStack fluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
getInternalFluid().writeToBuf(data);
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
@@ -150,37 +127,16 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
config.setInventorySlotContents(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
for (int j = 0; j < config.getSizeInventory(); j++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(j));
|
||||
fluidDuality.getConfig().setFluidInSlot(j, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < getInternalFluid().getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = getInternalFluid().getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
getInternalFluid().setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (getInternalFluid().getFluidInSlot(i) != null) {
|
||||
getInternalFluid().setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
changed |= getInternalFluid().readFromBuf(data);
|
||||
return changed;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBTEvent(NBTTagCompound data) {
|
||||
config.readFromNBT(data, "ConfigInv");
|
||||
for (int i = 0; i < config.getSizeInventory(); i++) {
|
||||
FluidStack fluid = ItemFluidPacket.getFluidStack(config.getStackInSlot(i));
|
||||
fluidDuality.getConfig().setFluidInSlot(i, fluidDuality.getStandardFluid(fluid));
|
||||
}
|
||||
fluidDuality.loadConfigFromPacket(this.config);
|
||||
getInternalFluid().readFromNBT(data, "FluidInv");
|
||||
}
|
||||
|
||||
@@ -241,6 +197,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
fluidDuality.onFluidInventoryChanged(inv, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfig(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
config.setInventorySlotContents(
|
||||
@@ -249,6 +206,7 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFluidInv(int id, IAEFluidStack fluid) {
|
||||
if (id >= 0 && id < 6) {
|
||||
getInternalFluid().setFluidInSlot(id, fluid);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
@@ -25,8 +23,13 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
|
||||
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 9);
|
||||
private final AEFluidInventory invFluids = new AEFluidInventory(this, 4, 64000);
|
||||
protected AppEngInternalInventory invItems;
|
||||
protected AEFluidInventory invFluids;
|
||||
|
||||
public TileIngredientBuffer() {
|
||||
this.invFluids = new AEFluidInventory(this, 4, 64000);
|
||||
this.invItems = new AppEngInternalInventory(this, 9);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@@ -34,10 +37,6 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
|
||||
return invItems;
|
||||
}
|
||||
|
||||
public IAEFluidTank getFluidInventory() {
|
||||
return invFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
@@ -69,19 +68,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
|
||||
for (int i = 0; i < invItems.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i));
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if (invFluids.getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
this.invFluids.writeToBuf(data);
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
@@ -94,22 +81,7 @@ public class TileIngredientBuffer extends AEBaseInvTile implements IAEFluidInven
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
invFluids.setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (invFluids.getFluidInSlot(i) != null) {
|
||||
invFluids.setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
changed |= this.invFluids.readFromBuf(data);
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +1,14 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.inventory.AEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidInventory;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import javax.annotation.Nonnull;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluidInventory, IFluidHandler {
|
||||
public class TileLargeIngredientBuffer extends TileIngredientBuffer {
|
||||
|
||||
private final AppEngInternalInventory invItems = new AppEngInternalInventory(this, 27);
|
||||
private final AEFluidInventory invFluids = new AEFluidInventory(this, 7, 64000);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IInventory getInternalInventory() {
|
||||
return invItems;
|
||||
}
|
||||
|
||||
public IAEFluidTank getFluidInventory() {
|
||||
return invFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRotated() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added) {
|
||||
markForUpdate();
|
||||
public TileLargeIngredientBuffer() {
|
||||
this.invFluids = new AEFluidInventory(this, 7, 64000);
|
||||
this.invItems = new AppEngInternalInventory(this, 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,106 +18,8 @@ public class TileLargeIngredientBuffer extends AEBaseInvTile implements IAEFluid
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
|
||||
saveChanges();
|
||||
markForUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AEFluidInventory getInternalFluid() {
|
||||
return this.invFluids;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
protected void writeToStream(ByteBuf data) throws IOException {
|
||||
for (int i = 0; i < invItems.getSizeInventory(); i++) {
|
||||
ByteBufUtils.writeItemStack(data, invItems.getStackInSlot(i));
|
||||
}
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if (invFluids.getFluidInSlot(i) != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
IAEFluidStack fluid = invFluids.getFluidInSlot(i);
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
protected boolean readFromStream(ByteBuf data) throws IOException {
|
||||
boolean changed = false;
|
||||
for (int i = 0; i < invItems.getSizeInventory(); i++) {
|
||||
ItemStack stack = ByteBufUtils.readItemStack(data);
|
||||
if (!ItemStack.areItemStacksEqual(stack, invItems.getStackInSlot(i))) {
|
||||
invItems.setInventorySlotContents(i, stack);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < invFluids.getSlots(); i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = invFluids.getFluidInSlot(i);
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
invFluids.setFluidInSlot(i, fluid);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (invFluids.getFluidInSlot(i) != null) {
|
||||
invFluids.setFluidInSlot(i, null);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBTEvent(NBTTagCompound data) {
|
||||
invItems.readFromNBT(data, "ItemInv");
|
||||
invFluids.readFromNBT(data, "FluidInv");
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public NBTTagCompound writeToNBTEvent(NBTTagCompound data) {
|
||||
invItems.writeToNBT(data, "ItemInv");
|
||||
invFluids.writeToNBT(data, "FluidInv");
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return invFluids.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return invFluids.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return invFluids.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return invFluids.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return invFluids.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return invFluids.getTankInfo(from);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.util.Util;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -251,6 +253,42 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
data.setTag(name, c);
|
||||
}
|
||||
|
||||
public void writeToBuf(final ByteBuf data) throws IOException {
|
||||
int fluidMask = 0;
|
||||
for (int i = 0; i < this.fluids.length; i++) {
|
||||
if (this.fluids[i] != null) {
|
||||
fluidMask |= 1 << i;
|
||||
}
|
||||
}
|
||||
data.writeByte(fluidMask);
|
||||
for (IAEFluidStack fluid : this.fluids) {
|
||||
if (fluid != null) {
|
||||
fluid.writeToPacket(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean readFromBuf(final ByteBuf data) throws IOException {
|
||||
boolean changed = false;
|
||||
int fluidMask = data.readByte();
|
||||
for (int i = 0; i < this.fluids.length; i++) {
|
||||
if ((fluidMask & (1 << i)) != 0) {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(data);
|
||||
if (fluid != null) { // this shouldn't happen, but better safe than sorry
|
||||
IAEFluidStack origFluid = this.fluids[i];
|
||||
if (!fluid.equals(origFluid) || fluid.getStackSize() != origFluid.getStackSize()) {
|
||||
this.fluids[i] = fluid;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} else if (this.fluids[i] != null) {
|
||||
this.fluids[i] = null;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private void writeToNBT(final NBTTagCompound target) {
|
||||
for (int x = 0; x < this.fluids.length; x++) {
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.glodblock.github.inventory;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import com.glodblock.github.util.DualityFluidInterface;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public interface IDualHost extends IFluidHandler, IAEFluidInventory {
|
||||
|
||||
DualityFluidInterface getDualityFluid();
|
||||
|
||||
AppEngInternalAEInventory getConfig();
|
||||
|
||||
void setConfig(int id, IAEFluidStack fluid);
|
||||
|
||||
void setFluidInv(int id, IAEFluidStack fluid);
|
||||
}
|
||||
@@ -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