mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 10:34:40 +00:00
refactor 6
This commit is contained in:
1 parent
5b62c4fdc8
commit
8d072f0c89
78 files changed
+525
-882
No files matched your search
@@ -69,14 +69,9 @@ public class FluidCraft {
|
||||
if (!Config.removeRecipe) {
|
||||
(new RecipeLoader()).run();
|
||||
}
|
||||
try {
|
||||
Class<?> calculatorV2 = Class.forName("appeng.crafting.v2.CraftingCalculations");
|
||||
if (calculatorV2 != null) {
|
||||
// Only run this if GTNH AE2 is installed
|
||||
CalculatorV2PluginLoader.installCalculatorV2Plugins();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
// no-op
|
||||
|
||||
if (ModAndClassUtil.isV2) {
|
||||
CalculatorV2PluginLoader.installCalculatorV2Plugins();
|
||||
}
|
||||
|
||||
proxy.postInit(event);
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.glodblock.github.client.gui.container.ContainerFluidPatternEncoder;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.inventory.slot.ISlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketEncodePattern;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
@@ -82,8 +82,8 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
|
||||
}
|
||||
|
||||
public void drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotFluid) {
|
||||
IAEItemStack stack = ((SlotFluid) slot).getAeStack();
|
||||
if (slot instanceof ISlotFluid) {
|
||||
IAEItemStack stack = ((ISlotFluid) slot).getAeStack();
|
||||
super.func_146977_a(new SlotSingleItem(slot));
|
||||
if (stack == null) return;
|
||||
IAEItemStack fake = stack.copy();
|
||||
|
||||
@@ -14,13 +14,15 @@ import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.inventory.gui.MouseRegionManager;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.inventory.slot.SlotSingleItem;
|
||||
import com.glodblock.github.network.CPacketLevelMaintainer;
|
||||
import com.glodblock.github.util.Ae2ReflectClient;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -29,7 +31,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -41,10 +42,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
private final Component[] component = new Component[TileLevelMaintainer.REQ_COUNT];
|
||||
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
|
||||
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
|
||||
private TileLevelMaintainer tile;
|
||||
private FCGuiTextField input;
|
||||
private int lastWorkingTick;
|
||||
private final int interval = 20;
|
||||
private int refreshTick;
|
||||
private final CoFHFontRenderer render;
|
||||
|
||||
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
@@ -52,12 +52,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
this.cont = (ContainerLevelMaintainer) inventorySlots;
|
||||
this.xSize = 195;
|
||||
this.ySize = 214;
|
||||
this.tile = tile;
|
||||
this.render = new CoFHFontRenderer(
|
||||
Minecraft.getMinecraft().gameSettings,
|
||||
TEX_BG,
|
||||
Minecraft.getMinecraft().getTextureManager(),
|
||||
true);
|
||||
this.refreshTick = 0;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list) {
|
||||
@@ -81,7 +81,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
this.lastWorkingTick = this.refreshTick;
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
component[i] = new Component(
|
||||
new Widget(
|
||||
@@ -104,6 +104,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
|
||||
this.refreshTick++;
|
||||
super.drawScreen(mouseX, mouseY, btn);
|
||||
for (Component com : this.component) {
|
||||
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
|
||||
@@ -116,10 +117,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
mc.getTextureManager().bindTexture(TEX_BG);
|
||||
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
|
||||
int tick = MinecraftServer.getServer().getTickCounter();
|
||||
int tick = this.refreshTick;
|
||||
int interval = 20;
|
||||
if (tick > lastWorkingTick + interval && this.input == null) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
|
||||
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
|
||||
lastWorkingTick = this.refreshTick;
|
||||
}
|
||||
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
|
||||
this.component[i].draw();
|
||||
@@ -139,7 +141,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
public boolean drawSlot0(Slot slot) {
|
||||
if (slot instanceof SlotFake) {
|
||||
IAEItemStack stack = ((ContainerLevelMaintainer.FakeSlot) slot).getAeStack();
|
||||
IAEItemStack stack = ((SlotFluidConvertingFake) slot).getAeStack();
|
||||
super.func_146977_a(new SlotSingleItem(slot));
|
||||
if (stack == null) return true;
|
||||
IAEItemStack fake = stack.copy();
|
||||
@@ -206,8 +208,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
|
||||
if (slot instanceof ContainerLevelMaintainer.FakeSlot
|
||||
&& this.cont.getPlayerInv().getItemStack() != null) {
|
||||
if (slot instanceof SlotFluidConvertingFake && this.cont.getPlayerInv().getItemStack() != null) {
|
||||
this.component[slot.getSlotIndex()]
|
||||
.getQty()
|
||||
.textField
|
||||
@@ -252,7 +253,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
|
||||
for (ContainerLevelMaintainer.FakeSlot slot : this.cont.getRequestSlots()) {
|
||||
for (SlotFluidConvertingFake slot : this.cont.getRequestSlots()) {
|
||||
if (getSlotArea(slot).contains(mouseX, mouseY)) {
|
||||
slot.putStack(draggedStack);
|
||||
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(draggedStack, slot.getSlotIndex()));
|
||||
@@ -313,7 +314,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
|
||||
}
|
||||
|
||||
private boolean send(Widget widget) {
|
||||
if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) {
|
||||
if (((SlotFluidConvertingFake) cont.inventorySlots.get(widget.idx)).getHasStack()) {
|
||||
if (!widget.textField.getText().isEmpty()
|
||||
&& widget.textField.getText().matches("^[0-9]+")) {
|
||||
String str = widget.textField.getText().replaceAll("^(0+)", "");
|
||||
|
||||
+1
-2
@@ -29,7 +29,6 @@ import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.network.SPacketMEInventoryUpdate;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -281,7 +280,7 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
|
||||
this.getInventoryPlayer().player,
|
||||
getWorld(),
|
||||
new BlockPos(this.getOpenContext().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getOpenContext().getSide())),
|
||||
Objects.requireNonNull(this.getOpenContext().getSide()),
|
||||
originalGui);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-61
@@ -3,10 +3,8 @@ package com.glodblock.github.client.gui.container;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
@@ -14,21 +12,17 @@ import com.glodblock.github.common.tile.TileFluidPatternEncoder;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import com.glodblock.github.inventory.IPatternConsumer;
|
||||
import com.glodblock.github.inventory.slot.SlotFluid;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPatternConsumer {
|
||||
|
||||
@@ -171,58 +165,4 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements IPa
|
||||
dest.setStack(i, src[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotFluidConvertingFake extends SlotFake implements SlotFluid {
|
||||
|
||||
private final AeStackInventory<IAEItemStack> inv;
|
||||
|
||||
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.inv = inv.getAeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack stack) {
|
||||
inv.setStack(getSlotIndex(), AEItemStack.create(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
|
||||
inv.setStack(getSlotIndex(), stack);
|
||||
}
|
||||
|
||||
public void putConvertedStack(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
setAeStack(null, false);
|
||||
return;
|
||||
} else if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(stack)) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
putStack(stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IAEItemStack getAeStack() {
|
||||
return inv.getStack(getSlotIndex());
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-11
@@ -4,6 +4,7 @@ import appeng.container.AEBaseContainer;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.tile.TileLevelMaintainer;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.slot.SlotFluidConvertingFake;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -11,14 +12,14 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
private final TileLevelMaintainer tile;
|
||||
private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT];
|
||||
private final SlotFluidConvertingFake[] requestSlots = new SlotFluidConvertingFake[TileLevelMaintainer.REQ_COUNT];
|
||||
|
||||
public ContainerLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
|
||||
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
|
||||
FakeSlot slot = new FakeSlot(request, y, 27, 20 + y * 19);
|
||||
SlotFluidConvertingFake slot = new SlotFluidConvertingFake(request, y, 27, 20 + y * 19);
|
||||
addSlotToContainer(slot);
|
||||
requestSlots[y] = slot;
|
||||
}
|
||||
@@ -29,13 +30,13 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
return tile;
|
||||
}
|
||||
|
||||
public FakeSlot[] getRequestSlots() {
|
||||
public SlotFluidConvertingFake[] getRequestSlots() {
|
||||
return this.requestSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int idx) {
|
||||
for (FakeSlot slot : this.getRequestSlots()) {
|
||||
for (SlotFluidConvertingFake slot : this.getRequestSlots()) {
|
||||
if (!slot.getHasStack()) {
|
||||
slot.setAeStack(AEItemStack.create(((Slot) this.inventorySlots.get(idx)).getStack()), true);
|
||||
break;
|
||||
@@ -44,11 +45,4 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
|
||||
this.detectAndSendChanges();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class FakeSlot extends ContainerFluidPatternEncoder.SlotFluidConvertingFake {
|
||||
|
||||
public FakeSlot(AeItemStackHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public class BlockFluidBuffer extends FCBaseBlock {
|
||||
return fs != null || (player.isSneaking() && itemStack == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidBuffer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileFluidBuffer.class, NameConst.BLOCK_FLUID_BUFFER);
|
||||
@@ -67,17 +68,8 @@ public class BlockFluidBuffer extends FCBaseBlock {
|
||||
return new RenderBlockFluidBuffer();
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -23,6 +23,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
|
||||
setTileEntity(TileFluidDiscretizer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidDiscretizer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
|
||||
GameRegistry.registerTileEntity(TileFluidDiscretizer.class, NameConst.BLOCK_FLUID_DISCRETIZER);
|
||||
@@ -30,17 +31,8 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -18,8 +18,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.EnumSet;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -57,7 +55,11 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
if (tg != null) {
|
||||
if (Platform.isServer()) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.DUAL_INTERFACE);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.DUAL_INTERFACE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -76,18 +78,11 @@ public class BlockFluidInterface extends FCBaseBlock {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidInterface register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_INTERFACE);
|
||||
GameRegistry.registerTileEntity(TileFluidInterface.class, NameConst.BLOCK_FLUID_INTERFACE);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,8 @@ import java.util.List;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.FLUID_PACKET_DECODER);
|
||||
}
|
||||
return true;
|
||||
@@ -49,6 +49,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidPacketDecoder register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
|
||||
GameRegistry.registerTileEntity(TileFluidPacketDecoder.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
|
||||
@@ -56,17 +57,8 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
|
||||
@@ -36,7 +35,7 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.FLUID_PATTERN_ENCODER);
|
||||
}
|
||||
return true;
|
||||
@@ -44,18 +43,11 @@ public class BlockFluidPatternEncoder extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockFluidPatternEncoder register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
|
||||
GameRegistry.registerTileEntity(TileFluidPatternEncoder.class, NameConst.BLOCK_FLUID_PATTERN_ENCODER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockIngredientBuffer extends FCBaseBlock {
|
||||
|
||||
@@ -34,25 +33,22 @@ public class BlockIngredientBuffer extends FCBaseBlock {
|
||||
if (tile != null) {
|
||||
if (!world.isRemote) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.INGREDIENT_BUFFER);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.INGREDIENT_BUFFER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockIngredientBuffer register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_INGREDIENT_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileIngredientBuffer.class, NameConst.BLOCK_INGREDIENT_BUFFER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
|
||||
@@ -37,7 +36,7 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.LARGE_INGREDIENT_BUFFER);
|
||||
}
|
||||
return true;
|
||||
@@ -45,18 +44,11 @@ public class BlockLargeIngredientBuffer extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockLargeIngredientBuffer register() {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
|
||||
GameRegistry.registerTileEntity(TileLargeIngredientBuffer.class, NameConst.BLOCK_LARGE_INGREDIENT_BUFFER);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
setTileEntity(TileLevelMaintainer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockLevelMaintainer register() {
|
||||
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER);
|
||||
GameRegistry.registerTileEntity(TileLevelMaintainer.class, NameConst.BLOCK_LEVEL_MAINTAINER);
|
||||
@@ -61,7 +62,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
EnumFacing.getFront(facing),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.LEVEL_MAINTAINER);
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
@@ -72,17 +73,8 @@ public class BlockLevelMaintainer extends FCBaseBlock {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -11,9 +11,8 @@ import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
|
||||
@@ -34,13 +33,18 @@ public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
if (tile != null) {
|
||||
if (!world.isRemote) {
|
||||
InventoryHandler.openGui(
|
||||
player, world, new BlockPos(x, y, z), EnumFacing.getFront(facing), GuiType.OC_PATTERN_EDITOR);
|
||||
player,
|
||||
world,
|
||||
new BlockPos(x, y, z),
|
||||
ForgeDirection.getOrientation(facing),
|
||||
GuiType.OC_PATTERN_EDITOR);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockOCPatternEditor register() {
|
||||
if (ModAndClassUtil.OC) {
|
||||
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_OC_PATTERN_EDITOR);
|
||||
@@ -50,12 +54,4 @@ public class BlockOCPatternEditor extends FCBaseBlock {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.glodblock.github.common.block;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.core.features.AEFeature;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.EnumSet;
|
||||
@@ -13,7 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class FCBaseBlock extends AEBaseTileBlock {
|
||||
public abstract class FCBaseBlock extends AEBaseTileBlock implements IRegister<FCBaseBlock> {
|
||||
|
||||
public FCBaseBlock(Material mat, String name) {
|
||||
super(mat);
|
||||
@@ -39,7 +40,6 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
super.setFeature(f);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(
|
||||
final ItemStack itemStack,
|
||||
@@ -47,7 +47,8 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
final List<String> toolTip,
|
||||
final boolean advancedToolTips) {}
|
||||
|
||||
protected final List listFormattedStringToWidth(String str) {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final List<String> listFormattedStringToWidth(String str) {
|
||||
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
|
||||
}
|
||||
|
||||
@@ -55,4 +56,12 @@ public class FCBaseBlock extends AEBaseTileBlock {
|
||||
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {
|
||||
this.addInformation(itemStack, player, toolTip, advancedToolTips);
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class FCBaseItem extends Item implements IRegister<FCBaseItem> {
|
||||
|
||||
public ItemStack stack(int size, int meta) {
|
||||
return new ItemStack(this, size, meta);
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public class FCBaseItemBlock extends AEBaseItemBlock {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addCheckedInformation(
|
||||
final ItemStack itemStack,
|
||||
final EntityPlayer player,
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.glodblock.github.common.storage.IFluidCellInventory;
|
||||
import com.glodblock.github.common.storage.IFluidCellInventoryHandler;
|
||||
import com.glodblock.github.common.storage.IStorageFluidCell;
|
||||
import com.glodblock.github.common.tabs.FluidCraftingTabs;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import com.google.common.base.Optional;
|
||||
@@ -46,7 +47,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
|
||||
public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFluidCell {
|
||||
public class ItemBasicFluidStorageCell extends AEBaseItem
|
||||
implements IStorageFluidCell, IRegister<ItemBasicFluidStorageCell> {
|
||||
private final CellType component;
|
||||
private final int totalBytes;
|
||||
private final int perType;
|
||||
@@ -151,7 +153,11 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
format.toWideReadableForm(fluid.getStackSize())));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CELL_EMPTY));
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_CTRL_FOR_MORE));
|
||||
}
|
||||
|
||||
if (handler.isPreformatted()) {
|
||||
@@ -167,6 +173,8 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
if (aeFluidStack != null)
|
||||
lines.add(" " + aeFluidStack.getFluidStack().getLocalizedName());
|
||||
}
|
||||
} else {
|
||||
lines.add(StatCollector.translateToLocal(NameConst.TT_SHIFT_FOR_MORE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +263,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
return stack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean disassembleDrive(final ItemStack stack, final World world, final EntityPlayer player) {
|
||||
if (player.isSneaking()) {
|
||||
if (Platform.isClient()) {
|
||||
@@ -297,11 +306,9 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
player.dropPlayerItemWithRandomChoice(extraA, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (player.inventoryContainer != null) {
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -322,7 +329,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
final float hitY,
|
||||
final float hitZ) {
|
||||
if (ForgeEventFactory.onItemUseStart(player, stack, 1) <= 0) return true;
|
||||
|
||||
return this.disassembleDrive(stack, world, player);
|
||||
}
|
||||
|
||||
@@ -336,7 +342,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
.asSet()) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
throw new MissingDefinition("Tried to use empty storage cells while basic storage cells are defined.");
|
||||
}
|
||||
|
||||
@@ -345,6 +350,7 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
|
||||
return AEConfig.instance.isFeatureEnabled(AEFeature.EnableDisassemblyCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBasicFluidStorageCell register() {
|
||||
if (!Config.fluidCells) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_STORAGE + this.totalBytes / 1024, FluidCraft.MODID);
|
||||
|
||||
@@ -16,7 +16,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemBasicFluidStoragePart extends Item {
|
||||
public class ItemBasicFluidStoragePart extends FCBaseItem {
|
||||
|
||||
public static final int types = 7;
|
||||
private static final HashMap<Integer, IIcon> icon = new HashMap<>();
|
||||
@@ -56,6 +56,7 @@ public class ItemBasicFluidStoragePart extends Item {
|
||||
return icon.get(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBasicFluidStoragePart register() {
|
||||
if (!Config.fluidCells) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PART, FluidCraft.MODID);
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ItemFluidDrop extends Item {
|
||||
public class ItemFluidDrop extends FCBaseItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon shape;
|
||||
@@ -96,22 +96,14 @@ public class ItemFluidDrop extends Item {
|
||||
}
|
||||
|
||||
public static boolean isFluidStack(ItemStack stack) {
|
||||
if (getFluidStack(stack) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return getFluidStack(stack) != null;
|
||||
}
|
||||
|
||||
public static boolean isFluidStack(@Nullable IAEItemStack stack) {
|
||||
if (stack == null) {
|
||||
return false;
|
||||
}
|
||||
if (getFluidStack(stack.getItemStack()) != null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return getFluidStack(stack.getItemStack()) != null;
|
||||
}
|
||||
|
||||
public static FluidStack getFluidStack(ItemStack stack) {
|
||||
@@ -169,6 +161,7 @@ public class ItemFluidDrop extends Item {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidDrop register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_DROP, FluidCraft.MODID);
|
||||
return this;
|
||||
|
||||
@@ -3,13 +3,14 @@ package com.glodblock.github.common.item;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.loader.IRegister;
|
||||
import com.glodblock.github.util.FluidPatternDetails;
|
||||
import com.glodblock.github.util.NameConst;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidEncodedPattern extends ItemEncodedPattern {
|
||||
public class ItemFluidEncodedPattern extends ItemEncodedPattern implements IRegister<ItemFluidEncodedPattern> {
|
||||
|
||||
public ItemFluidEncodedPattern() {
|
||||
super();
|
||||
@@ -23,6 +24,7 @@ public class ItemFluidEncodedPattern extends ItemEncodedPattern {
|
||||
return pattern.readFromStack() ? pattern : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidEncodedPattern register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_ENCODED_PATTERN, FluidCraft.MODID);
|
||||
return this;
|
||||
|
||||
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
public class ItemFluidExportBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidExportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -46,6 +45,7 @@ public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidExportBus register() {
|
||||
if (!Config.fluidIOBus) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
|
||||
@@ -61,12 +61,4 @@ public class ItemFluidExportBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
public class ItemFluidImportBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidImportBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -46,6 +45,7 @@ public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidImportBus register() {
|
||||
if (!Config.fluidIOBus) return null;
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
|
||||
@@ -61,12 +61,4 @@ public class ItemFluidImportBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,12 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
public class ItemFluidLevelEmitter extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemFluidLevelEmitter() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -47,6 +46,7 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidLevelEmitter register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_LEVEL_EMITTER, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -63,12 +63,4 @@ public class ItemFluidLevelEmitter extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@@ -24,7 +23,7 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ItemFluidPacket extends Item {
|
||||
public class ItemFluidPacket extends FCBaseItem {
|
||||
|
||||
public ItemFluidPacket() {
|
||||
setUnlocalizedName(NameConst.ITEM_FLUID_PACKET);
|
||||
@@ -141,12 +140,9 @@ public class ItemFluidPacket extends Item {
|
||||
return tFluid == null ? 16777215 : tFluid.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFluidPacket register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_FLUID_PACKET, FluidCraft.MODID);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
public class ItemPartFluidInterface extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidInterface() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidInterface register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_INTERFACE, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidInterface extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
public class ItemPartFluidPatternTerminal extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidPatternTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidPatternTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminal extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
public class ItemPartFluidPatternTerminalEx extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidPatternTerminalEx() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidPatternTerminalEx register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_PATTERN_TERMINAL_EX, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidPatternTerminalEx extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
public class ItemPartFluidStorageBus extends FCBaseItem implements IPartItem {
|
||||
|
||||
public ItemPartFluidStorageBus() {
|
||||
this.setMaxStackSize(64);
|
||||
@@ -45,6 +44,7 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidStorageBus register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_STORAGE_BUS, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -59,12 +59,4 @@ public class ItemPartFluidStorageBus extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,11 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
public class ItemPartFluidTerminal extends FCBaseItem implements IPartItem {
|
||||
public ItemPartFluidTerminal() {
|
||||
this.setMaxStackSize(64);
|
||||
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_TERMINAL);
|
||||
@@ -55,6 +54,7 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
if (isShiftKeyDown()) tooltip.add(StatCollector.translateToLocalFormatted(NameConst.TT_FLUID_TERMINAL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPartFluidTerminal register() {
|
||||
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_TERMINAL, FluidCraft.MODID);
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
@@ -69,12 +69,4 @@ public class ItemPartFluidTerminal extends Item implements IPartItem {
|
||||
public int getSpriteNumber() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ItemStack stack(int size) {
|
||||
return new ItemStack(this, size);
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.base.FCSharedFluidBus;
|
||||
import com.glodblock.github.inventory.FluidConvertingInventoryAdaptor;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -230,8 +229,7 @@ public class PartFluidExportBus extends FCSharedFluidBus implements ICraftingReq
|
||||
|
||||
protected InventoryAdaptor getHandler(TileEntity target) {
|
||||
return target != null
|
||||
? FluidConvertingInventoryAdaptor.wrap(
|
||||
target, Util.from(this.getSide().getOpposite()))
|
||||
? FluidConvertingInventoryAdaptor.wrap(target, this.getSide().getOpposite())
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ public class PartFluidInterface extends PartInterface implements IDualHost {
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.DUAL_INTERFACE_PART);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -570,7 +570,7 @@ public class PartFluidLevelEmitter extends PartUpgradeable
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(getSide())),
|
||||
Objects.requireNonNull(getSide()),
|
||||
GuiType.FLUID_LEVEL_EMITTER);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import com.glodblock.github.inventory.*;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.ModAndClassUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import extracells.tileentity.TileEntityFluidInterface;
|
||||
@@ -305,7 +304,7 @@ public class PartFluidStorageBus extends PartUpgradeable
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_STORAGE_BUS);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -224,8 +224,7 @@ public abstract class FCPart extends AEBasePart
|
||||
if (Platform.isServer()) {
|
||||
if (Util.hasPermission(player, SecurityPermissions.INJECT, (IGridHost) this)
|
||||
|| Util.hasPermission(player, SecurityPermissions.EXTRACT, (IGridHost) this)) {
|
||||
InventoryHandler.openGui(
|
||||
player, te.getWorldObj(), tePos, Objects.requireNonNull(Util.from(getSide())), getGui());
|
||||
InventoryHandler.openGui(player, te.getWorldObj(), tePos, Objects.requireNonNull(getSide()), getGui());
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText("You don't have permission to view."));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -75,7 +74,7 @@ public abstract class FCSharedFluidBus extends PartUpgradeable implements IGridT
|
||||
player,
|
||||
this.getHost().getTile().getWorldObj(),
|
||||
new BlockPos(this.getHost().getTile()),
|
||||
Objects.requireNonNull(Util.from(this.getSide())),
|
||||
Objects.requireNonNull(this.getSide()),
|
||||
GuiType.FLUID_BUS_IO);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,15 +31,14 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
private static String[] fluidSlotCount;
|
||||
private final ItemStack cellItem;
|
||||
private final ISaveProvider container;
|
||||
private static final int MAX_TYPE = 1;
|
||||
private final int MAX_TYPE = 1;
|
||||
private long storedFluidCount;
|
||||
private short storedFluids;
|
||||
private IItemList<IAEFluidStack> cellItems;
|
||||
private IItemList<IAEFluidStack> cellFluids;
|
||||
private final NBTTagCompound tagCompound;
|
||||
public static final int singleByteAmount = 256 * 8;
|
||||
|
||||
public FluidCellInventory(final ItemStack o, final ISaveProvider container) throws AppEngException {
|
||||
|
||||
if (fluidSlots == null) {
|
||||
fluidSlots = new String[MAX_TYPE];
|
||||
fluidSlotCount = new String[MAX_TYPE];
|
||||
@@ -75,7 +74,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.tagCompound = Platform.openNbtData(o);
|
||||
this.storedFluids = this.tagCompound.getShort(FLUID_TYPE_TAG);
|
||||
this.storedFluidCount = this.tagCompound.getLong(FLUID_COUNT_TAG);
|
||||
this.cellItems = null;
|
||||
this.cellFluids = null;
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler<IAEFluidStack> getCell(final ItemStack o, final ISaveProvider container2) {
|
||||
@@ -90,13 +89,10 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Item type = itemStack.getItem();
|
||||
|
||||
if (type instanceof IStorageFluidCell) {
|
||||
return ((IStorageFluidCell) type).isStorageCell(itemStack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,7 +118,10 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public boolean canHoldNewFluid() {
|
||||
return this.getRemainingFluidCount() > 0 && getRemainingFluidTypes() > 0;
|
||||
final long bytesFree = this.getFreeBytes();
|
||||
return (bytesFree > this.getBytesPerType()
|
||||
|| (bytesFree == this.getBytesPerType() && this.getUnusedFluidCount() > 0))
|
||||
&& this.getRemainingFluidTypes() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,10 +136,8 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public long getUsedBytes() {
|
||||
long bytesForItemCount = this.getStoredFluidCount() / singleByteAmount;
|
||||
long tmp = (this.getStoredFluidTypes() * this.getBytesPerType()) + bytesForItemCount;
|
||||
if (this.getUnusedFluidCount() > 0 && tmp < this.getTotalBytes()) tmp++;
|
||||
return tmp;
|
||||
final long bytesForFluidCount = (this.getStoredFluidCount() + this.getUnusedFluidCount()) / singleByteAmount;
|
||||
return this.getStoredFluidTypes() * this.getBytesPerType() + bytesForFluidCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,22 +155,26 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
return this.storedFluids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidTypes() {
|
||||
final long basedOnStorage = this.getFreeBytes() / this.getBytesPerType();
|
||||
final long baseOnTotal = this.getTotalFluidTypes() - this.getStoredFluidTypes();
|
||||
|
||||
return Math.min(basedOnStorage, baseOnTotal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRemainingFluidCount() {
|
||||
final long remaining = this.getTotalBytes() * singleByteAmount - this.getStoredFluidCount();
|
||||
final long remaining = this.getFreeBytes() * singleByteAmount + this.getUnusedFluidCount();
|
||||
return remaining > 0 ? remaining : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnusedFluidCount() {
|
||||
return (int) (this.getStoredFluidCount() % singleByteAmount);
|
||||
final int div = (int) (this.getStoredFluidCount() % singleByteAmount);
|
||||
if (div == 0) {
|
||||
return 0;
|
||||
}
|
||||
return singleByteAmount - div;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,35 +188,29 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
return 3;
|
||||
}
|
||||
|
||||
private void loadCellItems() {
|
||||
if (this.cellItems == null) {
|
||||
this.cellItems = AEApi.instance().storage().createFluidList();
|
||||
private void loadCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.cellFluids = AEApi.instance().storage().createFluidList();
|
||||
}
|
||||
|
||||
this.cellItems.resetStatus(); // clears totals and stuff.
|
||||
|
||||
this.cellFluids.resetStatus(); // clears totals and stuff.
|
||||
final int types = (int) this.getStoredFluidTypes();
|
||||
|
||||
for (int x = 0; x < types; x++) {
|
||||
final FluidStack t = FluidStack.loadFluidStackFromNBT(this.tagCompound.getCompoundTag(fluidSlots[x]));
|
||||
final AEFluidStack aet = AEFluidStack.create(t);
|
||||
|
||||
if (aet != null) {
|
||||
aet.setStackSize(this.tagCompound.getLong(fluidSlotCount[x]));
|
||||
|
||||
if (aet.getStackSize() > 0) {
|
||||
this.cellItems.add(aet);
|
||||
this.cellFluids.add(aet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IItemList<IAEFluidStack> getCellItems() {
|
||||
if (this.cellItems == null) {
|
||||
this.loadCellItems();
|
||||
private IItemList<IAEFluidStack> getCellFluids() {
|
||||
if (this.cellFluids == null) {
|
||||
this.loadCellFluids();
|
||||
}
|
||||
|
||||
return this.cellItems;
|
||||
return this.cellFluids;
|
||||
}
|
||||
|
||||
private void updateFluidCount(final long delta) {
|
||||
@@ -224,15 +219,12 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
}
|
||||
|
||||
private void saveChanges() {
|
||||
long itemCount = 0;
|
||||
|
||||
long fluidCount = 0;
|
||||
int x = 0;
|
||||
|
||||
for (final IAEFluidStack v : this.cellItems) {
|
||||
itemCount += v.getStackSize();
|
||||
|
||||
for (final IAEFluidStack v : this.cellFluids) {
|
||||
fluidCount += v.getStackSize();
|
||||
final NBTBase c = this.tagCompound.getTag(fluidSlots[x]);
|
||||
|
||||
if (c instanceof NBTTagCompound) {
|
||||
v.writeToNBT((NBTTagCompound) c);
|
||||
} else {
|
||||
@@ -240,45 +232,29 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
v.writeToNBT(g);
|
||||
this.tagCompound.setTag(fluidSlots[x], g);
|
||||
}
|
||||
|
||||
/*
|
||||
* NBTBase tagSlotCount = tagCompound.getTag( itemSlotCount[x] ); if ( tagSlotCount instanceof
|
||||
* NBTTagInt ) ((NBTTagInt) tagSlotCount).data = (int) v.getStackSize(); else
|
||||
*/
|
||||
this.tagCompound.setLong(fluidSlotCount[x], v.getStackSize());
|
||||
|
||||
x++;
|
||||
}
|
||||
|
||||
// NBTBase tagType = tagCompound.getTag( ITEM_TYPE_TAG );
|
||||
// NBTBase tagCount = tagCompound.getTag( ITEM_COUNT_TAG );
|
||||
final short oldStoredItems = this.storedFluids;
|
||||
final short oldStoredFluids = this.storedFluids;
|
||||
this.storedFluids = (short) this.cellFluids.size();
|
||||
|
||||
/*
|
||||
* if ( tagType instanceof NBTTagShort ) ((NBTTagShort) tagType).data = storedItems = (short) cellItems.size();
|
||||
* else
|
||||
*/
|
||||
this.storedFluids = (short) this.cellItems.size();
|
||||
|
||||
if (this.cellItems.isEmpty()) {
|
||||
if (this.cellFluids.isEmpty()) {
|
||||
this.tagCompound.removeTag(FLUID_TYPE_TAG);
|
||||
} else {
|
||||
this.tagCompound.setShort(FLUID_TYPE_TAG, this.storedFluids);
|
||||
}
|
||||
|
||||
/*
|
||||
* if ( tagCount instanceof NBTTagInt ) ((NBTTagInt) tagCount).data = storedItemCount = itemCount; else
|
||||
*/
|
||||
this.storedFluidCount = itemCount;
|
||||
this.storedFluidCount = fluidCount;
|
||||
|
||||
if (itemCount == 0) {
|
||||
if (fluidCount == 0) {
|
||||
this.tagCompound.removeTag(FLUID_COUNT_TAG);
|
||||
} else {
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, itemCount);
|
||||
this.tagCompound.setLong(FLUID_COUNT_TAG, fluidCount);
|
||||
}
|
||||
|
||||
// clean any old crusty stuff...
|
||||
for (; x < oldStoredItems && x < MAX_TYPE; x++) {
|
||||
for (; x < oldStoredFluids && x < MAX_TYPE; x++) {
|
||||
this.tagCompound.removeTag(fluidSlots[x]);
|
||||
this.tagCompound.removeTag(fluidSlotCount[x]);
|
||||
}
|
||||
@@ -293,32 +269,27 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (input.getStackSize() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.cellType.isBlackListed(this.cellItem, input)) {
|
||||
return input;
|
||||
}
|
||||
|
||||
final IAEFluidStack l = this.getCellItems().findPrecise(input);
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(input);
|
||||
|
||||
if (l != null) {
|
||||
final long remainingItemSlots =
|
||||
this.getRemainingFluidCount() - (long) this.getBytesPerType() * singleByteAmount;
|
||||
final long remainingFluidSlots = this.getRemainingFluidCount();
|
||||
|
||||
if (remainingItemSlots < 0) {
|
||||
if (remainingFluidSlots < 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
if (input.getStackSize() > remainingItemSlots) {
|
||||
if (input.getStackSize() > remainingFluidSlots) {
|
||||
final IAEFluidStack r = input.copy();
|
||||
r.setStackSize(r.getStackSize() - remainingItemSlots);
|
||||
|
||||
r.setStackSize(r.getStackSize() - remainingFluidSlots);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
l.setStackSize(l.getStackSize() + remainingItemSlots);
|
||||
this.updateFluidCount(remainingItemSlots);
|
||||
l.setStackSize(l.getStackSize() + remainingFluidSlots);
|
||||
this.updateFluidCount(remainingFluidSlots);
|
||||
this.saveChanges();
|
||||
}
|
||||
return r;
|
||||
@@ -328,40 +299,33 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.canHoldNewFluid()) // room for new type, and for at least one item!
|
||||
{
|
||||
final long remainingItemCount =
|
||||
final long remainingFluidCount =
|
||||
this.getRemainingFluidCount() - ((long) this.getBytesPerType() * singleByteAmount);
|
||||
|
||||
if (remainingItemCount > 0) {
|
||||
if (input.getStackSize() > remainingItemCount) {
|
||||
if (remainingFluidCount > 0) {
|
||||
if (input.getStackSize() > remainingFluidCount) {
|
||||
final IAEFluidStack toReturn = input.copy();
|
||||
toReturn.decStackSize(remainingItemCount);
|
||||
|
||||
toReturn.decStackSize(remainingFluidCount);
|
||||
if (mode == Actionable.MODULATE) {
|
||||
IAEFluidStack toWrite = input.copy();
|
||||
toWrite.setStackSize(remainingItemCount);
|
||||
|
||||
this.cellItems.add(toWrite);
|
||||
toWrite.setStackSize(remainingFluidCount);
|
||||
this.cellFluids.add(toWrite);
|
||||
this.updateFluidCount(toWrite.getStackSize());
|
||||
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
if (mode == Actionable.MODULATE) {
|
||||
this.updateFluidCount(input.getStackSize());
|
||||
this.cellItems.add(input);
|
||||
this.cellFluids.add(input);
|
||||
this.saveChanges();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -379,7 +343,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
IAEFluidStack results = null;
|
||||
|
||||
final IAEFluidStack l = this.getCellItems().findPrecise(request);
|
||||
final IAEFluidStack l = this.getCellFluids().findPrecise(request);
|
||||
|
||||
if (l != null) {
|
||||
results = l.copy();
|
||||
@@ -408,7 +372,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> getAvailableItems(IItemList<IAEFluidStack> out) {
|
||||
for (final IAEFluidStack i : this.getCellItems()) {
|
||||
for (final IAEFluidStack i : this.getCellFluids()) {
|
||||
out.add(i);
|
||||
}
|
||||
return out;
|
||||
@@ -417,7 +381,7 @@ public class FluidCellInventory implements IFluidCellInventory {
|
||||
@Override
|
||||
public List<IAEFluidStack> getContents() {
|
||||
List<IAEFluidStack> ret = new ArrayList<>();
|
||||
for (IAEFluidStack fluid : this.getCellItems()) {
|
||||
for (IAEFluidStack fluid : this.getCellFluids()) {
|
||||
ret.add(fluid);
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
AEApi.instance().storage().createFluidList();
|
||||
for (int x = 0; x < config.getSizeInventory(); x++) {
|
||||
final ItemStack is = config.getStackInSlot(x);
|
||||
if (is != null && Util.getFluidFromItem(is) != null) {
|
||||
if (Util.getFluidFromItem(is) != null) {
|
||||
priorityList.add(AEFluidStack.create(Util.getFluidFromItem(is)));
|
||||
break;
|
||||
}
|
||||
@@ -43,15 +43,14 @@ public class FluidCellInventoryHandler extends MEInventoryHandler<IAEFluidStack>
|
||||
@Override
|
||||
public IFluidCellInventory getCellInv() {
|
||||
Object o = this.getInternal();
|
||||
|
||||
if (o instanceof MEPassThrough) {
|
||||
o = Ae2Reflect.getInternal((MEPassThrough) o);
|
||||
o = Ae2Reflect.getInternal((MEPassThrough<?>) o);
|
||||
}
|
||||
|
||||
return (IFluidCellInventory) (o instanceof IFluidCellInventory ? o : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterable<IAEFluidStack> getPartitionInv() {
|
||||
return (Iterable<IAEFluidStack>) Ae2Reflect.getPartitionList(this).getItems();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
int getBytesPerType();
|
||||
|
||||
/**
|
||||
* @return true if a new item type can be added.
|
||||
* @return true if a new fluid type can be added.
|
||||
*/
|
||||
boolean canHoldNewFluid();
|
||||
|
||||
@@ -49,17 +49,22 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
long getUsedBytes();
|
||||
|
||||
/**
|
||||
* @return how many items are stored.
|
||||
* @return how many fluids are stored.
|
||||
*/
|
||||
long getStoredFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many more items can be stored.
|
||||
* @return how many more fluids can be stored.
|
||||
*/
|
||||
long getRemainingFluidCount();
|
||||
|
||||
/**
|
||||
* @return how many items can be added without consuming another byte.
|
||||
* @return how many fluid types remain.
|
||||
*/
|
||||
long getRemainingFluidTypes();
|
||||
|
||||
/**
|
||||
* @return how many fluids can be added without consuming another byte.
|
||||
*/
|
||||
int getUnusedFluidCount();
|
||||
|
||||
@@ -68,8 +73,14 @@ public interface IFluidCellInventory extends IMEInventory<IAEFluidStack> {
|
||||
*/
|
||||
int getStatusForCell();
|
||||
|
||||
/**
|
||||
* @return how many items types are currently stored.
|
||||
*/
|
||||
long getStoredFluidTypes();
|
||||
|
||||
/**
|
||||
* @return max number of types.
|
||||
*/
|
||||
long getTotalFluidTypes();
|
||||
|
||||
List<IAEFluidStack> getContents();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.GridFlags;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
@@ -134,7 +135,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
implements IMEInventory<IAEItemStack>, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
private final MEInventoryHandler<IAEItemStack> invHandler = new MEInventoryHandler<>(this, getChannel());
|
||||
private List<IAEItemStack> itemCache = null;
|
||||
private IItemList<IAEItemStack> itemCache = null;
|
||||
|
||||
FluidDiscretizingInventory() {
|
||||
invHandler.setPriority(Integer.MAX_VALUE);
|
||||
@@ -185,7 +186,7 @@ public class TileFluidDiscretizer extends AENetworkTile implements IPriorityHost
|
||||
@Override
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList<IAEItemStack> out) {
|
||||
if (itemCache == null) {
|
||||
itemCache = new ArrayList<>();
|
||||
itemCache = AEApi.instance().storage().createItemList();
|
||||
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
|
||||
if (fluidGrid != null) {
|
||||
for (IAEFluidStack fluid : fluidGrid.getStorageList()) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingLink> getRequestedJobs() {
|
||||
return ImmutableSet.copyOf(new NonNullArrayIterator<ICraftingLink>(this.requests.getLinks()));
|
||||
return ImmutableSet.copyOf(new NonNullArrayIterator<>(this.requests.getLinks()));
|
||||
}
|
||||
|
||||
private IAEItemStack setState(ICraftingLink link, IAEItemStack items) {
|
||||
@@ -176,8 +176,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final GridAccessException e) {
|
||||
// :P
|
||||
} catch (final GridAccessException ignore) {
|
||||
}
|
||||
return didSomething ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
@@ -245,8 +244,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
if (!this.requests.isDone(i)) this.requests.setState(i, State.Crafting);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// :P You don't have job to do XD
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,6 +329,7 @@ public class TileLevelMaintainer extends AENetworkTile
|
||||
private final ICraftingLink[] links;
|
||||
private final State[] state = new State[REQ_COUNT];
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public InventoryRequest(TileLevelMaintainer tile) {
|
||||
this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
|
||||
this.requestBatches = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.glodblock.github.inventory.FluidConvertingInventoryCrafting;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.util.Ae2Reflect;
|
||||
import com.glodblock.github.util.SetBackedMachineSet;
|
||||
import com.glodblock.github.util.Util;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -68,7 +67,7 @@ public class CoreModHooks {
|
||||
|
||||
@Nullable
|
||||
public static InventoryAdaptor wrapInventory(@Nullable TileEntity tile, ForgeDirection face) {
|
||||
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, Util.from(face)) : null;
|
||||
return tile != null ? FluidConvertingInventoryAdaptor.wrap(tile, face) : null;
|
||||
}
|
||||
|
||||
public static long getCraftingByteCost(IAEItemStack stack) {
|
||||
|
||||
@@ -5,13 +5,11 @@ import appeng.api.config.InsertionMode;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.p2p.PartP2PLiquids;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.ItemSlot;
|
||||
import cofh.api.transport.IItemDuct;
|
||||
import com.glodblock.github.common.Config;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.parts.PartFluidExportBus;
|
||||
import com.glodblock.github.common.parts.PartFluidInterface;
|
||||
@@ -27,7 +25,6 @@ import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
@@ -38,13 +35,13 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
public FluidConvertingInventoryAdaptor(
|
||||
@Nullable InventoryAdaptor invItems,
|
||||
@Nullable IFluidHandler invFluids,
|
||||
EnumFacing facing,
|
||||
ForgeDirection facing,
|
||||
BlockPos pos,
|
||||
boolean isOnmi,
|
||||
Object eioConduct) {
|
||||
this.invItems = invItems;
|
||||
this.invFluids = invFluids;
|
||||
this.side = Util.from(facing);
|
||||
this.side = facing;
|
||||
this.posInterface = pos;
|
||||
this.eioDuct = eioConduct;
|
||||
this.onmi = isOnmi;
|
||||
@@ -57,21 +54,20 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
private final Object eioDuct;
|
||||
private final boolean onmi;
|
||||
|
||||
public static InventoryAdaptor wrap(TileEntity capProvider, EnumFacing face) {
|
||||
public static InventoryAdaptor wrap(TileEntity capProvider, ForgeDirection face) {
|
||||
// sometimes i wish 1.7.10 has cap system.
|
||||
ForgeDirection f = Util.from(face);
|
||||
TileEntity inter = capProvider
|
||||
.getWorldObj()
|
||||
.getTileEntity(
|
||||
capProvider.xCoord + f.offsetX, capProvider.yCoord + f.offsetY, capProvider.zCoord + f.offsetZ);
|
||||
capProvider.xCoord + face.offsetX,
|
||||
capProvider.yCoord + face.offsetY,
|
||||
capProvider.zCoord + face.offsetZ);
|
||||
if (!Config.noFluidPacket
|
||||
&& !(inter instanceof TileFluidInterface
|
||||
|| (inter instanceof TileCableBus
|
||||
&& (((TileCableBus) inter).getPart(f.getOpposite()) instanceof PartFluidInterface
|
||||
|| ((TileCableBus) inter).getPart(f.getOpposite())
|
||||
instanceof PartFluidExportBus))))
|
||||
return InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, f);
|
||||
|| Util.getPart(inter, face.getOpposite()) instanceof PartFluidInterface
|
||||
|| Util.getPart(inter, face.getOpposite()) instanceof PartFluidExportBus))
|
||||
return InventoryAdaptor.getAdaptor(capProvider, face);
|
||||
InventoryAdaptor item = InventoryAdaptor.getAdaptor(capProvider, face);
|
||||
IFluidHandler fluid = capProvider instanceof IFluidHandler ? (IFluidHandler) capProvider : null;
|
||||
boolean onmi = false;
|
||||
if (inter instanceof TileInterface) {
|
||||
@@ -85,16 +81,10 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
|
||||
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
|
||||
if (toBeAdded.getItem() instanceof ItemFluidPacket || toBeAdded.getItem() instanceof ItemFluidDrop) {
|
||||
FluidStack fluid = Util.getFluidFromVirtual(toBeAdded);
|
||||
if (fluid != null) {
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid;
|
||||
if (toBeAdded.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeAdded);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeAdded);
|
||||
}
|
||||
|
||||
if (fluid != null && invFluids.canFill(side, fluid.getFluid())) {
|
||||
if (invFluids.canFill(side, fluid.getFluid())) {
|
||||
int filled = invFluids.fill(side, fluid, true);
|
||||
if (filled > 0) {
|
||||
fluid.amount -= filled;
|
||||
@@ -122,46 +112,27 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
|
||||
@Override
|
||||
public ItemStack simulateAdd(ItemStack toBeSimulated, InsertionMode insertionMode) {
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket || toBeSimulated.getItem() instanceof ItemFluidDrop) {
|
||||
FluidStack fluid = Util.getFluidFromVirtual(toBeSimulated);
|
||||
if (fluid != null) {
|
||||
if (onmi) {
|
||||
boolean sus = false;
|
||||
FluidStack fluid;
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
|
||||
}
|
||||
|
||||
if (fluid != null) {
|
||||
for (ForgeDirection dir : ForgeDirection.values()) {
|
||||
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
|
||||
if (te instanceof IFluidHandler) {
|
||||
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
|
||||
if (filled > 0) {
|
||||
sus = true;
|
||||
break;
|
||||
}
|
||||
for (ForgeDirection dir : ForgeDirection.values()) {
|
||||
TileEntity te = posInterface.getOffSet(dir).getTileEntity();
|
||||
if (te instanceof IFluidHandler) {
|
||||
int filled = ((IFluidHandler) te).fill(dir.getOpposite(), fluid, false);
|
||||
if (filled > 0) {
|
||||
sus = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sus = true;
|
||||
}
|
||||
return sus ? null : toBeSimulated;
|
||||
}
|
||||
if (invFluids != null) {
|
||||
FluidStack fluid;
|
||||
if (toBeSimulated.getItem() instanceof ItemFluidPacket) {
|
||||
fluid = ItemFluidPacket.getFluidStack(toBeSimulated);
|
||||
} else {
|
||||
fluid = ItemFluidDrop.getFluidStack(toBeSimulated);
|
||||
}
|
||||
|
||||
if (fluid != null) {
|
||||
int filled = invFluids.fill(side, fluid, false);
|
||||
if (filled > 0) {
|
||||
fluid.amount -= filled;
|
||||
return ItemFluidPacket.newStack(fluid);
|
||||
}
|
||||
int filled = invFluids.fill(side, fluid, false);
|
||||
if (filled > 0) {
|
||||
fluid.amount -= filled;
|
||||
return ItemFluidPacket.newStack(fluid);
|
||||
}
|
||||
}
|
||||
return toBeSimulated;
|
||||
@@ -203,10 +174,9 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
}
|
||||
if (invFluids != null && invFluids.getTankInfo(this.side) != null) {
|
||||
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
|
||||
if (invFluids instanceof TileCableBus
|
||||
&& ((TileCableBus) invFluids).getPart(this.side) instanceof PartP2PLiquids) {
|
||||
if (Util.getPart(invFluids, this.side) instanceof PartP2PLiquids) {
|
||||
// read other ends of p2p for blocking mode
|
||||
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) ((TileCableBus) invFluids).getPart(this.side);
|
||||
PartP2PLiquids invFluidsP2P = (PartP2PLiquids) Util.getPart(invFluids, this.side);
|
||||
try {
|
||||
Iterator<PartP2PLiquids> it = invFluidsP2P.getOutputs().iterator();
|
||||
boolean checkedInput = false;
|
||||
@@ -223,8 +193,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
|
||||
if (target == null) continue;
|
||||
tankInfos.add(target.getTankInfo(p2p.getSide().getOpposite()));
|
||||
}
|
||||
} catch (GridAccessException e) {
|
||||
// ignore
|
||||
} catch (GridAccessException ignore) {
|
||||
}
|
||||
} else {
|
||||
tankInfos.add(invFluids.getTankInfo(this.side));
|
||||
|
||||
@@ -9,8 +9,8 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class InventoryHandler implements IGuiHandler {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class InventoryHandler implements IGuiHandler {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(guiType));
|
||||
}
|
||||
|
||||
public static void openGui(EntityPlayer player, World world, BlockPos pos, EnumFacing face, GuiType guiType) {
|
||||
public static void openGui(EntityPlayer player, World world, BlockPos pos, ForgeDirection face, GuiType guiType) {
|
||||
player.openGui(
|
||||
FluidCraft.INSTANCE,
|
||||
(guiType.ordinal() << 3) | face.ordinal(),
|
||||
@@ -32,10 +32,10 @@ public class InventoryHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int faceOrd = id & 0x7;
|
||||
if (faceOrd > EnumFacing.values().length) {
|
||||
if (faceOrd > ForgeDirection.values().length) {
|
||||
return null;
|
||||
}
|
||||
EnumFacing face = EnumFacing.getFront(faceOrd);
|
||||
ForgeDirection face = ForgeDirection.getOrientation(faceOrd);
|
||||
GuiType type = GuiType.getByOrdinal(id >>> 3);
|
||||
return type != null ? type.guiFactory.createServerGui(player, world, x, y, z, face) : null;
|
||||
}
|
||||
@@ -45,10 +45,10 @@ public class InventoryHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
int faceOrd = id & 0x7;
|
||||
if (faceOrd > EnumFacing.values().length) {
|
||||
if (faceOrd > ForgeDirection.values().length) {
|
||||
return null;
|
||||
}
|
||||
EnumFacing face = EnumFacing.getFront(faceOrd);
|
||||
ForgeDirection face = ForgeDirection.getOrientation(faceOrd);
|
||||
GuiType type = GuiType.getByOrdinal(id >>> 3);
|
||||
return type != null ? type.guiFactory.createClientGui(player, world, x, y, z, face) : null;
|
||||
}
|
||||
|
||||
+4
-7
@@ -5,7 +5,7 @@ import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IExternalStorageHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import com.glodblock.github.util.Util;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@@ -16,9 +16,7 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
if (te instanceof ITileStorageMonitorable) {
|
||||
return true;
|
||||
} else
|
||||
return te instanceof TileCableBus
|
||||
&& ((TileCableBus) te).getPart(d.getOpposite()) instanceof ITileStorageMonitorable;
|
||||
} else return Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -29,9 +27,8 @@ public class AEFluidInterfaceHandler implements IExternalStorageHandler {
|
||||
if (channel == StorageChannel.FLUIDS) {
|
||||
if (te instanceof ITileStorageMonitorable) {
|
||||
return ((ITileStorageMonitorable) te).getMonitorable(d, src).getFluidInventory();
|
||||
} else if (te instanceof TileCableBus
|
||||
&& ((TileCableBus) te).getPart(d.getOpposite()) instanceof ITileStorageMonitorable) {
|
||||
ITileStorageMonitorable part = (ITileStorageMonitorable) ((TileCableBus) te).getPart(d.getOpposite());
|
||||
} else if (Util.getPart(te, d.getOpposite()) instanceof ITileStorageMonitorable) {
|
||||
ITileStorageMonitorable part = (ITileStorageMonitorable) Util.getPart(te, d.getOpposite());
|
||||
return part.getMonitorable(d, src).getFluidInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IGuiFactory {
|
||||
|
||||
@Nullable
|
||||
Object createServerGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face);
|
||||
Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face);
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Nullable
|
||||
Object createClientGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face);
|
||||
Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face);
|
||||
}
|
||||
@@ -2,10 +2,9 @@ package com.glodblock.github.inventory.gui;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import com.glodblock.github.util.Util;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class PartGuiFactory<T> extends TileGuiFactory<T> {
|
||||
|
||||
@@ -15,9 +14,9 @@ public abstract class PartGuiFactory<T> extends TileGuiFactory<T> {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected T getInventory(TileEntity tile, EnumFacing face) {
|
||||
protected T getInventory(TileEntity tile, ForgeDirection face) {
|
||||
if (tile instanceof IPartHost) {
|
||||
IPart part = ((IPartHost) tile).getPart(Util.from(face));
|
||||
IPart part = ((IPartHost) tile).getPart(face);
|
||||
if (invClass.isInstance(part)) {
|
||||
return invClass.cast(part);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.glodblock.github.inventory.gui;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.util.Util;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileGuiFactory<T> implements IGuiFactory {
|
||||
|
||||
@@ -18,13 +17,13 @@ public abstract class TileGuiFactory<T> implements IGuiFactory {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected T getInventory(TileEntity tile, EnumFacing face) {
|
||||
protected T getInventory(TileEntity tile, ForgeDirection face) {
|
||||
return invClass.isInstance(tile) ? invClass.cast(tile) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face) {
|
||||
public Object createServerGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile == null) {
|
||||
return null;
|
||||
@@ -40,7 +39,7 @@ public abstract class TileGuiFactory<T> implements IGuiFactory {
|
||||
ctx.setX(x);
|
||||
ctx.setY(y);
|
||||
ctx.setZ(z);
|
||||
ctx.setSide(Util.from(face));
|
||||
ctx.setSide(face);
|
||||
((AEBaseContainer) gui).setOpenContext(ctx);
|
||||
}
|
||||
return gui;
|
||||
@@ -51,7 +50,7 @@ public abstract class TileGuiFactory<T> implements IGuiFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, EnumFacing face) {
|
||||
public Object createClientGui(EntityPlayer player, World world, int x, int y, int z, ForgeDirection face) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile == null) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.glodblock.github.inventory.slot;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface SlotFluid {
|
||||
public interface ISlotFluid {
|
||||
|
||||
@Nullable
|
||||
IAEItemStack getAeStack();
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.glodblock.github.inventory.slot;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.AeItemStackHandler;
|
||||
import com.glodblock.github.inventory.AeStackInventory;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class SlotFluidConvertingFake extends SlotFake implements ISlotFluid {
|
||||
|
||||
private final AeStackInventory<IAEItemStack> inv;
|
||||
|
||||
public SlotFluidConvertingFake(AeItemStackHandler inv, int idx, int x, int y) {
|
||||
super(inv, idx, x, y);
|
||||
this.inv = inv.getAeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack stack) {
|
||||
inv.setStack(getSlotIndex(), AEItemStack.create(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAeStack(@Nullable IAEItemStack stack, boolean sync) {
|
||||
inv.setStack(getSlotIndex(), stack);
|
||||
}
|
||||
|
||||
public void putConvertedStack(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
setAeStack(null, false);
|
||||
return;
|
||||
} else if (stack.getItem() instanceof IFluidContainerItem) {
|
||||
FluidStack fluid = ((IFluidContainerItem) stack.getItem()).getFluid(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (FluidContainerRegistry.isContainer(stack)) {
|
||||
FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
|
||||
if (fluid != null) {
|
||||
fluid.amount *= stack.stackSize;
|
||||
IAEItemStack aeStack = ItemFluidPacket.newAeStack(fluid);
|
||||
if (aeStack != null) {
|
||||
setAeStack(aeStack, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
putStack(stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IAEItemStack getAeStack() {
|
||||
return inv.getStack(getSlotIndex());
|
||||
}
|
||||
}
|
||||
@@ -21,8 +21,6 @@ public class ChannelLoader implements Runnable {
|
||||
new CPacketCraftRequest.Handler(), CPacketCraftRequest.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
new CPacketInventoryAction.Handler(), CPacketInventoryAction.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
new CPacketSetTargetItem.Handler(), CPacketSetTargetItem.class, id++, Side.SERVER);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id++, Side.CLIENT);
|
||||
FluidCraft.proxy.netHandler.registerMessage(
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.glodblock.github.loader;
|
||||
|
||||
public interface IRegister<T> {
|
||||
|
||||
T register();
|
||||
}
|
||||
+3
-11
@@ -4,8 +4,7 @@ import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.GuiFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.base.FCGuiEncodeTerminal;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import com.glodblock.github.nei.recipes.FluidRecipe;
|
||||
import com.glodblock.github.network.CPacketTransferRecipe;
|
||||
@@ -29,11 +28,8 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
if (isCorrectGui(firstGui)) {
|
||||
boolean priority = false;
|
||||
if (firstGui instanceof GuiFluidPatternTerminalEx) {
|
||||
priority = ((GuiFluidPatternTerminalEx) firstGui).container.prioritize;
|
||||
}
|
||||
if (firstGui instanceof FCGuiEncodeTerminal) {
|
||||
boolean priority = ((FCGuiEncodeTerminal) firstGui).container.prioritize;
|
||||
List<OrderStack<?>> in = FluidRecipe.getPackageInputs(recipe, recipeIndex, priority);
|
||||
List<OrderStack<?>> out = FluidRecipe.getPackageOutputs(recipe, recipeIndex, !notUseOther(recipe));
|
||||
boolean craft = shouldCraft(recipe);
|
||||
@@ -41,10 +37,6 @@ public class FluidPatternTerminalRecipeTransferHandler implements IOverlayHandle
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCorrectGui(GuiContainer firstGui) {
|
||||
return firstGui instanceof GuiFluidPatternTerminal || firstGui instanceof GuiFluidPatternTerminalEx;
|
||||
}
|
||||
|
||||
private boolean notUseOther(IRecipeHandler recipeHandler) {
|
||||
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipeHandler;
|
||||
return notOtherSet.contains(tRecipe.getOverlayIdentifier());
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.glodblock.github.nei.object;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public interface IFluidDummy {
|
||||
|
||||
FluidStack getFluidStack();
|
||||
}
|
||||
@@ -38,12 +38,12 @@ public final class FluidRecipe {
|
||||
byte numFluids = 0;
|
||||
for (OrderStack<?> orderStack : out) {
|
||||
if (orderStack != null && orderStack.getStack() instanceof FluidStack) {
|
||||
reordered.add(new OrderStack(orderStack.getStack(), numFluids++));
|
||||
reordered.add(new OrderStack<>(orderStack.getStack(), numFluids++));
|
||||
}
|
||||
}
|
||||
for (OrderStack<?> orderStack : out) {
|
||||
if (orderStack != null && orderStack.getStack() instanceof ItemStack) {
|
||||
reordered.add(new OrderStack(orderStack.getStack(), numFluids++));
|
||||
reordered.add(new OrderStack<>(orderStack.getStack(), numFluids++));
|
||||
}
|
||||
}
|
||||
return reordered;
|
||||
|
||||
+4
-20
@@ -20,38 +20,22 @@ public class EnderIORecipeExtractor implements IRecipeExtractor {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawInputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
OrderStack<?> stack = OrderStack.pack(rawOutputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawOutputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
|
||||
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
List<OrderStack<?>> tmp;
|
||||
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe) {
|
||||
VatRecipeHandler.InnerVatRecipe vatRecipe = (VatRecipeHandler.InnerVatRecipe) tRecipe.arecipes.get(index);
|
||||
ArrayList<PositionedStack> inputs = ReflectEIO.getInputs(vatRecipe);
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
if (inputs.get(i) == null) continue;
|
||||
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
tmp = ExtractorUtil.packItemStack(inputs);
|
||||
FluidStack in = ReflectEIO.getInputFluid(vatRecipe);
|
||||
if (in != null) {
|
||||
tmp.add(new OrderStack<>(in, inputs.size()));
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.glodblock.github.nei.recipes.extractor;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class ExtractorUtil {
|
||||
|
||||
public static List<OrderStack<?>> packItemStack(List<PositionedStack> items) {
|
||||
AtomicInteger index = new AtomicInteger(-1);
|
||||
return items.stream()
|
||||
.map(item -> {
|
||||
index.getAndIncrement();
|
||||
return OrderStack.pack(item, index.get());
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<OrderStack<?>> packItemStack(
|
||||
List<PositionedStack> items, Function<PositionedStack, Object> transformer) {
|
||||
AtomicInteger index = new AtomicInteger(-1);
|
||||
return items.stream()
|
||||
.map(item -> {
|
||||
index.getAndIncrement();
|
||||
Object o = transformer.apply(item);
|
||||
return o != null ? new OrderStack<>(o, index.get()) : null;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -10,7 +10,6 @@ import forestry.core.recipes.nei.RecipeHandlerBase;
|
||||
import forestry.factory.recipes.nei.NEIHandlerFabricator;
|
||||
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -29,24 +28,12 @@ public class ForestryRecipeExtractor implements IRecipeExtractorLegacy {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawInputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
OrderStack<?> stack = OrderStack.pack(rawOutputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawOutputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,4 @@ public class GTPPRecipeExtractor extends GregTech5RecipeExtractor {
|
||||
public GTPPRecipeExtractor() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
public GTPPRecipeExtractor(boolean removeSpecial) {
|
||||
super(removeSpecial);
|
||||
}
|
||||
}
|
||||
+19
-36
@@ -5,10 +5,9 @@ import com.glodblock.github.nei.object.IRecipeExtractor;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import gregtech.api.enums.ItemList;
|
||||
import gregtech.common.items.GT_FluidDisplayItem;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -23,44 +22,12 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor {
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
if (removeSpecial) removeSpecial(rawInputs);
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
ItemStack item = rawInputs.get(i).items[0].copy();
|
||||
OrderStack<?> stack;
|
||||
if (item.getItem() instanceof GT_FluidDisplayItem) {
|
||||
NBTTagCompound aNBT = item.getTagCompound();
|
||||
int amt = (int) aNBT.getLong("mFluidDisplayAmount");
|
||||
if (amt <= 0) continue;
|
||||
stack = new OrderStack<>(new FluidStack(FluidRegistry.getFluid(item.getItemDamage()), amt), i);
|
||||
tmp.add(stack);
|
||||
} else {
|
||||
stack = OrderStack.pack(rawInputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawInputs, GregTech5RecipeExtractor::getFluidFromDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
ItemStack item = rawOutputs.get(i).items[0].copy();
|
||||
OrderStack<?> stack;
|
||||
if (item.getItem() instanceof GT_FluidDisplayItem) {
|
||||
NBTTagCompound aNBT = item.getTagCompound();
|
||||
int amt = (int) aNBT.getLong("mFluidDisplayAmount");
|
||||
if (amt <= 0) continue;
|
||||
stack = new OrderStack<>(new FluidStack(FluidRegistry.getFluid(item.getItemDamage()), amt), i);
|
||||
tmp.add(stack);
|
||||
} else {
|
||||
stack = OrderStack.pack(rawOutputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawOutputs, GregTech5RecipeExtractor::getFluidFromDisplay);
|
||||
}
|
||||
|
||||
private void removeSpecial(List<PositionedStack> list) {
|
||||
@@ -74,4 +41,20 @@ public class GregTech5RecipeExtractor implements IRecipeExtractor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFluidFromDisplay(PositionedStack stack) {
|
||||
if (stack != null) {
|
||||
ItemStack item = stack.items[0].copy();
|
||||
if (item.getItem() instanceof GT_FluidDisplayItem) {
|
||||
if (item.getTagCompound() != null) {
|
||||
Fluid fluid = FluidRegistry.getFluid(item.getItemDamage());
|
||||
int amt = (int) item.getTagCompound().getLong("mFluidDisplayAmount");
|
||||
return amt > 0 && fluid != null ? new FluidStack(fluid, amt) : null;
|
||||
}
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+17
-33
@@ -5,7 +5,6 @@ import com.glodblock.github.nei.object.IRecipeExtractor;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
import gregapi.item.ItemFluidDisplay;
|
||||
import gregapi.recipes.Recipe;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -21,42 +20,12 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor {
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
this.removeMachine(rawInputs);
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
ItemStack item = rawInputs.get(i).items[0].copy();
|
||||
OrderStack<?> stack;
|
||||
if (item.getItem() instanceof ItemFluidDisplay) {
|
||||
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
|
||||
if (fluid == null || fluid.amount <= 0) continue;
|
||||
stack = new OrderStack<>(fluid, i);
|
||||
tmp.add(stack);
|
||||
} else {
|
||||
stack = OrderStack.pack(rawInputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawInputs, GregTech6RecipeExtractor::getFluidFromDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
ItemStack item = rawOutputs.get(i).items[0].copy();
|
||||
OrderStack<?> stack;
|
||||
if (item.getItem() instanceof ItemFluidDisplay) {
|
||||
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
|
||||
if (fluid == null || fluid.amount <= 0) continue;
|
||||
stack = new OrderStack<>(fluid, i);
|
||||
tmp.add(stack);
|
||||
} else {
|
||||
stack = OrderStack.pack(rawOutputs.get(i), i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawOutputs, GregTech6RecipeExtractor::getFluidFromDisplay);
|
||||
}
|
||||
|
||||
private void removeMachine(List<PositionedStack> list) {
|
||||
@@ -72,4 +41,19 @@ public class GregTech6RecipeExtractor implements IRecipeExtractor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFluidFromDisplay(PositionedStack stack) {
|
||||
if (stack != null) {
|
||||
ItemStack item = stack.items[0].copy();
|
||||
if (item.getItem() instanceof ItemFluidDisplay) {
|
||||
if (item.getTagCompound() != null) {
|
||||
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
|
||||
return fluid != null && fluid.amount > 0 ? fluid : null;
|
||||
}
|
||||
} else {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+2
-12
@@ -20,22 +20,12 @@ public class IndustrialCraftRecipeExtractor implements IRecipeExtractor {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawInputs.size(); i++) {
|
||||
if (rawInputs.get(i) == null) continue;
|
||||
tmp.add(OrderStack.pack(rawInputs.get(i), i));
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawInputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
tmp.add(OrderStack.pack(rawOutputs.get(i), i));
|
||||
}
|
||||
return tmp;
|
||||
return ExtractorUtil.packItemStack(rawOutputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-10
@@ -30,15 +30,6 @@ public class VanillaRecipeExtractor implements IRecipeExtractor {
|
||||
|
||||
@Override
|
||||
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
|
||||
List<OrderStack<?>> tmp = new LinkedList<>();
|
||||
for (int i = 0; i < rawOutputs.size(); i++) {
|
||||
if (rawOutputs.get(i) == null) continue;
|
||||
final int col = (rawOutputs.get(i).relx - 25) / 18;
|
||||
final int row = (rawOutputs.get(i).rely - 6) / 18;
|
||||
int index = col + row * 3;
|
||||
OrderStack<?> stack = OrderStack.pack(rawOutputs.get(i), c ? index : i);
|
||||
if (stack != null) tmp.add(stack);
|
||||
}
|
||||
return tmp;
|
||||
return getInputIngredients(rawOutputs);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -87,7 +86,7 @@ public class CPacketCraftRequest implements IMessage {
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(Util.from(context.getSide())),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
GuiType.FLUID_CRAFTING_CONFIRM);
|
||||
|
||||
if (player.openContainer instanceof ContainerFluidCraftConfirm) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidMonitor;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -42,23 +42,13 @@ public class CPacketFluidUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull) list.put(id, null);
|
||||
else {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
Util.readFluidMapFromBuf(this.list, buf);
|
||||
if (buf.readBoolean()) {
|
||||
this.itemStack = AEItemStack.loadItemStackFromPacket(buf).getItemStack();
|
||||
this.slotIndex = buf.readInt();
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -66,16 +56,8 @@ public class CPacketFluidUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(list.size());
|
||||
try {
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
if (fs.getValue() == null) buf.writeBoolean(false);
|
||||
else {
|
||||
buf.writeBoolean(true);
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
Util.writeFluidMapToBuf(this.list, buf);
|
||||
if (this.itemStack != null) {
|
||||
buf.writeBoolean(true);
|
||||
AEItemStack.create(itemStack).writeToPacket(buf);
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -97,7 +96,7 @@ public class CPacketInventoryAction implements IMessage {
|
||||
te.getWorldObj(),
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(
|
||||
Util.from(baseContainer.getOpenContext().getSide())),
|
||||
baseContainer.getOpenContext().getSide()),
|
||||
GuiType.FLUID_CRAFTING_AMOUNT);
|
||||
if (sender.openContainer instanceof ContainerCraftAmount) {
|
||||
final ContainerCraftAmount cca = (ContainerCraftAmount) sender.openContainer;
|
||||
@@ -118,7 +117,7 @@ public class CPacketInventoryAction implements IMessage {
|
||||
te.getWorldObj(),
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(
|
||||
Util.from(baseContainer.getOpenContext().getSide())),
|
||||
baseContainer.getOpenContext().getSide()),
|
||||
GuiType.PATTERN_VALUE_SET);
|
||||
int amt = (int) message.stack.getStackSize();
|
||||
if (message.stack.getItem() instanceof ItemFluidPacket) {
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CPacketPatternValueSet implements IMessage {
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(Util.from(context.getSide())),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.originGui);
|
||||
if (player.openContainer instanceof FCContainerEncodeTerminal) {
|
||||
Slot slot = player.openContainer.getSlot(message.valueIndex);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class CPacketSetTargetItem implements IMessage {
|
||||
|
||||
private IAEItemStack stack;
|
||||
|
||||
public CPacketSetTargetItem() {}
|
||||
|
||||
public CPacketSetTargetItem(IAEItemStack stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
try {
|
||||
stack.writeToPacket(buf);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
try {
|
||||
stack = AEItemStack.loadItemStackFromPacket(buf);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<CPacketSetTargetItem, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(CPacketSetTargetItem message, MessageContext ctx) {
|
||||
Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if (c instanceof AEBaseContainer) {
|
||||
((AEBaseContainer) c).setTargetStack(message.stack);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import appeng.container.ContainerOpenContext;
|
||||
import com.glodblock.github.inventory.InventoryHandler;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.util.BlockPos;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -62,7 +61,7 @@ public class CPacketSwitchGuis implements IMessage {
|
||||
player,
|
||||
player.worldObj,
|
||||
new BlockPos(te),
|
||||
Objects.requireNonNull(Util.from(context.getSide())),
|
||||
Objects.requireNonNull(context.getSide()),
|
||||
message.guiType);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.glodblock.github.network;
|
||||
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
|
||||
import com.glodblock.github.client.gui.container.base.FCContainerEncodeTerminal;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.nei.NEIUtils;
|
||||
import com.glodblock.github.nei.object.OrderStack;
|
||||
@@ -77,8 +76,8 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
@Override
|
||||
public IMessage onMessage(CPacketTransferRecipe message, MessageContext ctx) {
|
||||
Container c = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if (c instanceof ContainerFluidPatternTerminal) {
|
||||
ContainerFluidPatternTerminal cf = (ContainerFluidPatternTerminal) c;
|
||||
if (c instanceof FCContainerEncodeTerminal) {
|
||||
FCContainerEncodeTerminal cf = (FCContainerEncodeTerminal) c;
|
||||
boolean combine = cf.combine;
|
||||
cf.getPatternTerminal().setCraftingRecipe(message.isCraft);
|
||||
IInventory inputSlot = cf.getInventoryByName("crafting");
|
||||
@@ -98,80 +97,27 @@ public class CPacketTransferRecipe implements IMessage {
|
||||
message.inputs = NEIUtils.clearNull(message.inputs);
|
||||
message.outputs = NEIUtils.clearNull(message.outputs);
|
||||
}
|
||||
|
||||
for (OrderStack<?> stack : message.inputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
} else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
for (OrderStack<?> stack : message.outputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
} else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
c.onCraftMatrixChanged(inputSlot);
|
||||
c.onCraftMatrixChanged(outputSlot);
|
||||
} else if (c instanceof ContainerFluidPatternTerminalEx) {
|
||||
ContainerFluidPatternTerminalEx cf = (ContainerFluidPatternTerminalEx) c;
|
||||
boolean combine = cf.combine;
|
||||
IInventory inputSlot = cf.getInventoryByName("crafting");
|
||||
IInventory outputSlot = cf.getInventoryByName("output");
|
||||
for (int i = 0; i < inputSlot.getSizeInventory(); i++) {
|
||||
inputSlot.setInventorySlotContents(i, null);
|
||||
}
|
||||
for (int i = 0; i < outputSlot.getSizeInventory(); i++) {
|
||||
outputSlot.setInventorySlotContents(i, null);
|
||||
}
|
||||
|
||||
if (combine) {
|
||||
message.inputs = NEIUtils.compress(message.inputs);
|
||||
message.outputs = NEIUtils.compress(message.outputs);
|
||||
}
|
||||
message.inputs = NEIUtils.clearNull(message.inputs);
|
||||
message.outputs = NEIUtils.clearNull(message.outputs);
|
||||
|
||||
for (OrderStack<?> stack : message.inputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
} else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < inputSlot.getSizeInventory()) inputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
for (OrderStack<?> stack : message.outputs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
} else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < outputSlot.getSizeInventory()) outputSlot.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
transferPack(message.inputs, inputSlot);
|
||||
transferPack(message.outputs, outputSlot);
|
||||
c.onCraftMatrixChanged(inputSlot);
|
||||
c.onCraftMatrixChanged(outputSlot);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void transferPack(List<OrderStack<?>> packs, IInventory inv) {
|
||||
for (OrderStack<?> stack : packs) {
|
||||
if (stack != null) {
|
||||
int index = stack.getIndex();
|
||||
ItemStack stack1;
|
||||
if (stack.getStack() instanceof ItemStack) {
|
||||
stack1 = ((ItemStack) stack.getStack()).copy();
|
||||
} else if (stack.getStack() instanceof FluidStack) {
|
||||
stack1 = ItemFluidPacket.newStack((FluidStack) stack.getStack());
|
||||
} else throw new UnsupportedOperationException("Trying to get an unsupported item!");
|
||||
if (index < inv.getSizeInventory()) inv.setInventorySlotContents(index, stack1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@ package com.glodblock.github.network;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import com.glodblock.github.client.gui.*;
|
||||
import com.glodblock.github.util.Util;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -40,18 +40,9 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
int size = buf.readInt();
|
||||
this.list = new HashMap<>();
|
||||
try {
|
||||
for (int i = 0; i < size; i++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull) list.put(id, null);
|
||||
else {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
Util.readFluidMapFromBuf(this.list, buf);
|
||||
if (buf.readBoolean()) {
|
||||
this.itemStack = AEItemStack.loadItemStackFromPacket(buf);
|
||||
}
|
||||
@@ -62,16 +53,8 @@ public class SPacketFluidUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(list.size());
|
||||
try {
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
if (fs.getValue() == null) buf.writeBoolean(false);
|
||||
else {
|
||||
buf.writeBoolean(true);
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
Util.writeFluidMapToBuf(this.list, buf);
|
||||
if (this.itemStack != null) {
|
||||
buf.writeBoolean(true);
|
||||
this.itemStack.writeToPacket(buf);
|
||||
|
||||
@@ -62,11 +62,7 @@ public class SPacketMEInventoryUpdate implements IMessage {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
if (isFluid) {
|
||||
buf.writeBoolean(true);
|
||||
} else {
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
buf.writeBoolean(isFluid);
|
||||
buf.writeLong(list.size());
|
||||
buf.writeByte(ref);
|
||||
try {
|
||||
@@ -94,16 +90,17 @@ public class SPacketMEInventoryUpdate implements IMessage {
|
||||
public static class Handler implements IMessageHandler<SPacketMEInventoryUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public IMessage onMessage(SPacketMEInventoryUpdate message, MessageContext ctx) {
|
||||
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
if (gs instanceof GuiFluidMonitor) {
|
||||
((GuiFluidMonitor) gs).postUpdate((List<IAEFluidStack>) (List<?>) message.list);
|
||||
((GuiFluidMonitor) gs).postUpdate((List) message.list);
|
||||
} else if (gs instanceof GuiItemMonitor) {
|
||||
((GuiItemMonitor) gs).postUpdate((List<IAEItemStack>) (List<?>) message.list);
|
||||
((GuiItemMonitor) gs).postUpdate((List) message.list);
|
||||
} else if (gs instanceof GuiFluidCraftConfirm) {
|
||||
((GuiFluidCraftConfirm) gs).postUpdate((List<IAEItemStack>) (List<?>) message.list, message.ref);
|
||||
((GuiFluidCraftConfirm) gs).postUpdate((List) message.list, message.ref);
|
||||
} else if (gs instanceof GuiLevelMaintainer) {
|
||||
((GuiLevelMaintainer) gs).postUpdate((List<IAEItemStack>) (List<?>) message.list);
|
||||
((GuiLevelMaintainer) gs).postUpdate((List) message.list);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public final class ModAndClassUtil {
|
||||
public static boolean COFH = false;
|
||||
public static boolean GTPP = false;
|
||||
public static boolean WAILA = false;
|
||||
public static boolean isV2;
|
||||
public static boolean isDoubleButton;
|
||||
public static boolean isSaveText;
|
||||
public static boolean isSearchStringTooltip;
|
||||
@@ -101,6 +102,14 @@ public final class ModAndClassUtil {
|
||||
isCraftStatus = false;
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> calculatorV2 = Class.forName("appeng.crafting.v2.CraftingCalculations");
|
||||
if (calculatorV2 == null) isV2 = false;
|
||||
isV2 = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
isV2 = false;
|
||||
}
|
||||
|
||||
try {
|
||||
essentiaGas = Class.forName("thaumicenergistics.common.fluids.GaseousEssentia");
|
||||
} catch (ClassNotFoundException e) {
|
||||
|
||||
@@ -39,6 +39,7 @@ public class NameConst {
|
||||
public static final String TT_EMPTY = TT_KEY + "empty";
|
||||
public static final String TT_DUMP_TANK = TT_KEY + "dump_tank";
|
||||
public static final String TT_SHIFT_FOR_MORE = TT_KEY + "shift_for_more";
|
||||
public static final String TT_CTRL_FOR_MORE = TT_KEY + "ctrl_for_more";
|
||||
public static final String TT_FLUID_BUFFER = TT_KEY + "fluid_buffer.";
|
||||
public static final String TT_FLUID_PACKET_DECODER = TT_KEY + "fluid_packet_decoder.";
|
||||
public static final String TT_FLUID_PACKET_DECODER_DESC = TT_FLUID_PACKET_DECODER + "desc";
|
||||
@@ -60,6 +61,7 @@ public class NameConst {
|
||||
public static final String TT_LEVEL_MAINTAINER_EXPORT = TT_LEVEL_MAINTAINER + "export";
|
||||
public static final String TT_LEVEL_MAINTAINER_EXPORT_DESC = TT_LEVEL_MAINTAINER + "export_desc";
|
||||
public static final String TT_CELL_CONTENTS = TT_KEY + "cell_contents";
|
||||
public static final String TT_CELL_EMPTY = TT_KEY + "cell_empty";
|
||||
|
||||
public static final String WAILA_KEY = FluidCraft.MODID + ".waila.";
|
||||
public static final String WAILA_ENABLE = WAILA_KEY + "enable";
|
||||
|
||||
@@ -8,51 +8,26 @@ import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
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 io.netty.buffer.ByteBuf;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
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;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import org.apache.commons.lang3.tuple.MutablePair;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static EnumFacing from(ForgeDirection direction) {
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
return EnumFacing.EAST;
|
||||
case EAST:
|
||||
return EnumFacing.WEST;
|
||||
case UNKNOWN:
|
||||
return null;
|
||||
default: {
|
||||
int o = direction.ordinal();
|
||||
return EnumFacing.values()[o];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ForgeDirection from(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case WEST:
|
||||
return ForgeDirection.EAST;
|
||||
case EAST:
|
||||
return ForgeDirection.WEST;
|
||||
default: {
|
||||
int o = direction.ordinal();
|
||||
return ForgeDirection.values()[o];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int findItemInPlayerInvSlot(EntityPlayer player, ItemStack itemStack) {
|
||||
for (int i = 0; i < player.inventory.mainInventory.length; i++) {
|
||||
if (player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i] == itemStack) return i;
|
||||
@@ -146,11 +121,6 @@ public final class Util {
|
||||
return stack != null && stack.getItem() instanceof ItemFluidPacket;
|
||||
}
|
||||
|
||||
public static FluidStack cloneFluidStack(FluidStack fluidStack) {
|
||||
if (fluidStack != null) return fluidStack.copy();
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getFluidModID(Fluid fluid) {
|
||||
String name = FluidRegistry.getDefaultFluidName(fluid);
|
||||
try {
|
||||
@@ -187,11 +157,6 @@ public final class Util {
|
||||
return fluid;
|
||||
}
|
||||
|
||||
public static boolean areFluidsEqual(FluidStack fluid1, FluidStack fluid2) {
|
||||
if (fluid1 == null || fluid2 == null) return false;
|
||||
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);
|
||||
@@ -203,6 +168,50 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static FluidStack getFluidFromVirtual(ItemStack virtual) {
|
||||
if (virtual == null) {
|
||||
return null;
|
||||
}
|
||||
if (virtual.getItem() instanceof ItemFluidPacket) {
|
||||
return ItemFluidPacket.getFluidStack(virtual);
|
||||
} else if (virtual.getItem() instanceof ItemFluidDrop) {
|
||||
return ItemFluidDrop.getFluidStack(virtual);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IPart getPart(Object te, ForgeDirection face) {
|
||||
if (te instanceof TileCableBus) {
|
||||
return ((TileCableBus) te).getPart(face);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeFluidMapToBuf(Map<Integer, IAEFluidStack> list, ByteBuf buf) throws IOException {
|
||||
buf.writeInt(list.size());
|
||||
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
|
||||
buf.writeInt(fs.getKey());
|
||||
if (fs.getValue() == null) buf.writeBoolean(false);
|
||||
else {
|
||||
buf.writeBoolean(true);
|
||||
fs.getValue().writeToPacket(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void readFluidMapFromBuf(Map<Integer, IAEFluidStack> list, ByteBuf buf) throws IOException {
|
||||
int size = buf.readInt();
|
||||
for (int i = 0; i < size; i++) {
|
||||
int id = buf.readInt();
|
||||
boolean isNull = buf.readBoolean();
|
||||
if (!isNull) list.put(id, null);
|
||||
else {
|
||||
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
|
||||
list.put(id, fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FluidUtil {
|
||||
public static IAEFluidStack createAEFluidStack(Fluid fluid) {
|
||||
return createAEFluidStack(new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME));
|
||||
|
||||
@@ -38,7 +38,8 @@ ae2fc.waila.speed=Speed
|
||||
ae2fc.waila.enable=Enable
|
||||
ae2fc.waila.disable=Disable
|
||||
|
||||
ae2fc.tooltip.shift_for_more=> Hold §3Shift§r for more information
|
||||
ae2fc.tooltip.shift_for_more=§r> Hold §3Shift§r for more information
|
||||
ae2fc.tooltip.ctrl_for_more=§r> Hold §3Ctrl§r for more information
|
||||
ae2fc.tooltip.fluid_packet_decoder.desc=The Fluid Decoder can decode Fluid packets. It has to be connected to a ME System and a place to store the liquid in otherwise it won't work.
|
||||
ae2fc.tooltip.discretizer.desc=When the ME Fluid Discretizer is attached to your ME System, it will represent the Fluids that are stored in your ME Fluid Storage Cells (Or Storage bus) as drops. They will be the item equivalent of fluids. Its just another way to show fluids, it won't actually convert your fluids to items.
|
||||
ae2fc.tooltip.fluid_buffer.desc=This is a high speed fluid IO
|
||||
@@ -59,6 +60,7 @@ ae2fc.tooltip.level_maintainer.request_size=§6Amount to Maintain§r
|
||||
ae2fc.tooltip.level_maintainer.request_size.hint=The count defines how many items should be held in stock before the Requester starts requesting new crafts.
|
||||
|
||||
ae2fc.tooltip.cell_contents=Contains Fluid:
|
||||
ae2fc.tooltip.cell_empty=Cell is empty
|
||||
ae2fc.tooltip.fluid_terminal=uh So we don't need EC2 anymore?
|
||||
ae2fc.tooltip.invalid_fluid=Invalid fluid!
|
||||
ae2fc.tooltip.encode_pattern=Encode Patter
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Reference in new issue
Block a user