Compare commits

...
Author SHA1 Message Date
Yang Xizhi 510cd6d4bd Merge pull request #63 from GTNewHorizons/fix/fluidterminal-spotless-fixes
Spotless apply for branch fix/fluidterminal for #62
2023-01-17 22:44:39 +08:00
GitHub GTNH Actions f0aef4e73c spotlessApply 2023-01-17 14:44:20 +00:00
Yang Xizhi 11bf706a32 Merge fe1ec6276d into b1dff2ec2c 2023-01-17 14:43:10 +00:00
GlodBlock fe1ec6276d add fluid storage bus 2023-01-17 22:41:49 +08:00
Martin Robertz b1dff2ec2c Merge pull request #60 from asdflj/levelmaintainer
fix level maintainer bug
2023-01-16 16:22:43 +01:00
Martin Robertz 101f4de7ed Merge pull request #61 from GTNewHorizons/crafting-calc-v2-compat
Crafting calculator v2 compatibility
2023-01-15 21:54:47 +01:00
Martin Robertz 2679df71c4 Update dependencies.gradle 2023-01-15 15:56:05 +00:00
Raven Szewczyk 18630c9618 Add crafting calculator v2 compat for newer AE2-GTNH versions 2023-01-14 18:04:23 +00:00
Raven Szewczyk f203c24551 Update dependencies 2023-01-14 12:48:06 +00:00
Raven Szewczyk 7a1b507b08 Update buildscript 2023-01-14 11:28:25 +00:00
asdflj f07d996eb7 fix level maintainer if item can't be craft, it always requests item to crafting 2023-01-14 19:23:23 +08:00
Martin Robertz 36a9507c22 Merge pull request #59 from asdflj/levelmaintainer
fix fluid dupe
2023-01-13 09:35:28 +01:00
asdflj 5b5b11b330 fix fluid terminal bug
update zh-cn lang
2023-01-13 15:47:58 +08:00
Martin Robertz 91720df96d Merge pull request #56 from asdflj/levelmaintainer
update level maintainer
2023-01-12 06:24:12 +01:00
asdflj de63822afb update level_maintainer 2023-01-12 09:43:06 +08:00
Martin Robertz 669c83917f Merge pull request #55 from asdflj/master
fix fluid terminal bug
2023-01-11 16:25:38 +01:00
asdflj 606bac83f4 fix fluid terminal bug 2023-01-11 18:09:55 +08:00
44 changed files with 1744 additions and 165 deletions

No files matched your search

+28 -10
View File
@@ -1,4 +1,4 @@
//version: 1669411416
//version: 1673027205
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -31,7 +31,7 @@ buildscript {
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH ForgeGradle Fork
// GTNH ForgeGradle and ASM Fork
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
@@ -45,7 +45,9 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.11'
//Overwrite the current ASM version to fix shading newer than java 8 applicatations.
classpath 'org.ow2.asm:asm-debug-all-custom:5.0.3'
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.13'
}
}
plugins {
@@ -278,7 +280,9 @@ minecraft {
runDir = 'run'
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
for (f in replaceGradleTokenInFile.split(',')) {
replaceIn f
}
if (gradleTokenModId) {
replace gradleTokenModId, modId
}
@@ -315,9 +319,13 @@ if (file('addon.gradle').exists()) {
apply from: 'repositories.gradle'
configurations {
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
// TODO: remove Compile after all uses are refactored to Implementation
for (config in [shadowImplementation, shadowCompile, shadeCompile]) {
compileClasspath.extendsFrom(config)
runtimeClasspath.extendsFrom(config)
testCompileClasspath.extendsFrom(config)
testRuntimeClasspath.extendsFrom(config)
}
}
repositories {
@@ -330,6 +338,12 @@ repositories {
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
}
if (usesMixinDebug.toBoolean()) {
maven {
name = "Fabric Maven"
url = "https://maven.fabricmc.net/"
}
}
}
}
@@ -338,10 +352,14 @@ dependencies {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.1:processor')
annotationProcessor('com.gtnewhorizon:gtnhmixins:2.1.3:processor')
if (usesMixinDebug.toBoolean()) {
runtimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
testRuntimeClasspath('org.jetbrains:intellij-fernflower:1.2.1.16')
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
compile('com.gtnewhorizon:gtnhmixins:2.1.1')
compile('com.gtnewhorizon:gtnhmixins:2.1.3')
}
}
@@ -694,7 +712,7 @@ if (modrinthProjectId.size() != 0 && System.getenv("MODRINTH_TOKEN") != null) {
}
}
if (usesMixins.toBoolean()) {
addModrinthDep("required", "version", "gtnhmixins")
addModrinthDep("required", "project", "gtnhmixins")
}
tasks.modrinth.dependsOn(build)
tasks.publish.dependsOn(tasks.modrinth)
+12 -13
View File
@@ -1,28 +1,27 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.10-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-133-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.3.20-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-138-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:waila:1.5.22:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.25:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.8.9.2:dev")
compileOnly('com.github.GTNewHorizons:ForestryMC:4.4.7:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.48:dev')
compileOnly('com.github.GTNewHorizons:ForestryMC:4.5.6:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.49:dev')
compileOnly('com.github.GTNewHorizons:EnderCore:0.2.11:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.40.41:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.0.15:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.41.216:dev')
compileOnly('com.github.GTNewHorizons:StructureLib:1.2.0-beta.2:dev')
compileOnly('net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev')
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.github.GTNewHorizons:AppleCore:3.1.9:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:AppleCore:3.2.5:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.28:dev') { transitive = false }
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.7.5.23-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.19-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:EnderIO:2.3.1.29:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.49:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.8.0.5-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.3.27-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.7.191:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.22:dev')
compileOnly('com.github.GTNewHorizons:KekzTech:0.6.25:dev')
runtime('com.github.GTNewHorizons:Baubles:1.0.1.14:dev')
}
Vendored Regular → Executable
View File
File mode changed.
@@ -1,12 +1,12 @@
package com.glodblock.github;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import com.glodblock.github.common.Config;
import com.glodblock.github.common.storage.FluidCellHandler;
import com.glodblock.github.crossmod.opencomputers.OCDriverInit;
import com.glodblock.github.crossmod.waila.WailaInit;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.loader.CalculatorV2PluginLoader;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
@@ -19,7 +19,6 @@ import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
@Mod(
@@ -70,24 +69,14 @@ public class FluidCraft {
if (!Config.removeRecipe) {
(new RecipeLoader()).run();
}
if (ModAndClassUtil.isBigInterface) {
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3);
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3);
}
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
if (Config.fluidIOBus) {
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2);
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1);
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4);
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4);
Upgrades.SUPERSPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4);
Upgrades.SUPERSPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
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
}
proxy.postInit(event);
@@ -0,0 +1,29 @@
package com.glodblock.github.client.gui;
import net.minecraft.client.gui.FontRenderer;
public class FCGuiLineField extends FCGuiTextField {
private final int _xPos;
private final int _yPos;
private final int _width;
private final FontRenderer _fontRender;
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width) {
this(fontRenderer, xPos, yPos, width, 5);
}
public FCGuiLineField(FontRenderer fontRenderer, int xPos, int yPos, int width, int height) {
super(fontRenderer, xPos, yPos, width, height);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._fontRender = fontRenderer;
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
drawRect(this._xPos, this._yPos, this.xPosition + this.width, this.yPosition + this.height, getColor());
}
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.ITooltip;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
@@ -46,15 +47,36 @@ public class FCGuiTextField extends GuiTextField {
public void drawTextBox() {
super.drawTextBox();
if (this.getBorder() > 0 && this.getVisible()) {
GuiTextField.drawRect(
this._xPos - this.getBorder(),
this._yPos - this.getBorder(),
this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(),
this._height - 2 * PADDING + this.getBorder(),
drawRect(
this._xPos - getBorder(),
this._yPos - getBorder(),
this.xPosition + this.width + getBorder(),
this.yPosition + this.height + getBorder(),
this.getColor());
}
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui) {
this.handleTooltip(mouseX, mouseY, gui, 0);
}
public void handleTooltip(int mouseX, int mouseY, AEBaseGui gui, int offsetY) {
if (isMouseIn(mouseX, mouseY) && this.tooltip != null && !"".equals(this.tooltip)) {
int length = 0;
for (String s : this.getMessage().split("\n")) {
length = Math.max(this._fontRender.getStringWidth(s), length);
}
if (mouseY < 15) {
mouseY = 15;
}
if (mouseX + length + 20 >= gui.width) {
gui.drawTooltip(mouseX - length - 20, mouseY + 4 + offsetY, 0, this.getMessage());
} else {
gui.drawTooltip(mouseX, mouseY + 4 + offsetY, 0, this.getMessage());
}
}
}
public int getBorder() {
return this._border;
}
@@ -109,6 +131,10 @@ public class FCGuiTextField extends GuiTextField {
tooltip = t;
}
public String getMessage() {
return tooltip;
}
public class TooltipProvider implements ITooltip {
@Override
public String getMessage() {
@@ -20,11 +20,16 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
private boolean halfSize = false;
private String fillVar;
private String currentValue;
private final boolean background;
private static final String prefix = NameConst.TT_KEY;
public GuiFCImgButton(final int x, final int y, final String idx, final String val) {
super(0, 0, 16, "");
this(x, y, idx, val, true);
}
public GuiFCImgButton(final int x, final int y, final String idx, final String val, boolean background) {
super(0, 0, 16, "");
this.background = background;
this.buttonSetting = idx;
this.currentValue = val;
this.xPosition = x;
@@ -198,14 +203,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
@@ -234,14 +240,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
final int uv_y = (int) Math.floor(iconIndex / 3.0);
final int uv_x = iconIndex - uv_y * 3;
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
if (this.background) {
this.drawTexturedModalRect(
0,
0,
Math.round(32F * 16F / 3F),
Math.round(32F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
}
this.drawTexturedModalRect(
0,
0,
@@ -13,6 +13,7 @@ import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
@@ -71,6 +72,9 @@ public class GuiFCPriority extends AEBaseGui {
} else if (target instanceof PartFluidInterface) {
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
} else if (target instanceof PartFluidStorageBus) {
myIcon = ItemAndBlockHolder.FLUID_STORAGE_BUS.stack();
this.OriginalGui = GuiType.FLUID_STORAGE_BUS;
}
if (this.OriginalGui != null && myIcon != null) {
@@ -0,0 +1,92 @@
package com.glodblock.github.client.gui;
import appeng.api.config.AccessRestriction;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.core.localization.GuiColors;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.input.Mouse;
public class GuiFluidStorageBus extends GuiUpgradeable {
private GuiImgButton rwMode;
private GuiTabButton priority;
private GuiImgButton partition;
private GuiImgButton clear;
public GuiFluidStorageBus(InventoryPlayer inventoryPlayer, PartFluidStorageBus te) {
super(new ContainerFluidStorageBus(inventoryPlayer, te));
this.ySize = 251;
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons() {
this.clear = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE);
this.partition = new GuiImgButton(this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH);
this.rwMode =
new GuiImgButton(this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE);
this.priority =
new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender);
this.buttonList.add(this.priority);
this.buttonList.add(this.rwMode);
this.buttonList.add(this.partition);
this.buttonList.add(this.clear);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_STORAGE_BUS)),
8,
6,
GuiColors.StorageBusTitle.getColor());
this.fontRendererObj.drawString(
GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, GuiColors.StorageBusInventory.getColor());
if (this.rwMode != null) {
this.rwMode.set(((ContainerFluidStorageBus) this.cvb).getReadWriteMode());
}
}
@Override
protected String getBackground() {
return "guis/storagebus.png";
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.partition) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Partition"));
} else if (btn == this.clear) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("StorageBus.Action", "Clear"));
} else if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.FLUID_STORAGE_BUS_PRIORITY));
} else if (btn == this.rwMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.rwMode.getSetting(), backwards));
}
}
public void update(int id, IAEFluidStack stack) {
((ContainerFluidStorageBus) this.cvb).bus.setFluidInSlot(id, stack);
}
}
@@ -9,6 +9,7 @@ import appeng.core.sync.packets.PacketNEIDragClick;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import cofh.core.render.CoFHFontRenderer;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerLevelMaintainer;
import com.glodblock.github.common.tile.TileLevelMaintainer;
@@ -16,18 +17,19 @@ import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketLevelMaintainer;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.Optional;
import java.awt.*;
import java.util.Collections;
import java.util.*;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
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,6 +43,9 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
private TileLevelMaintainer tile;
private FCGuiTextField input;
private int lastWorkingTick;
private final int interval = 20;
private final CoFHFontRenderer render;
public GuiLevelMaintainer(InventoryPlayer ipl, TileLevelMaintainer tile) {
super(new ContainerLevelMaintainer(ipl, tile));
@@ -48,56 +53,74 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.xSize = 195;
this.ySize = 214;
this.tile = tile;
this.render = new CoFHFontRenderer(
Minecraft.getMinecraft().gameSettings,
TEX_BG,
Minecraft.getMinecraft().getTextureManager(),
true);
}
public void postUpdate(List<IAEItemStack> list) {
for (Slot slot : this.cont.getRequestSlots()) {
if (!slot.getHasStack()) {
component[slot.getSlotIndex()].setState(TileLevelMaintainer.State.Nothing);
}
}
for (IAEItemStack is : list) {
long size = is.getItemStack().getTagCompound().getLong("Batch");
int i = is.getItemStack().getTagCompound().getInteger("Index");
boolean isEnable = is.getItemStack().getTagCompound().getBoolean("Enable");
NBTTagCompound data = is.getItemStack().getTagCompound();
long size = data.getLong("Batch");
int i = data.getInteger("Index");
boolean isEnable = data.getBoolean("Enable");
TileLevelMaintainer.State state = TileLevelMaintainer.State.values()[data.getInteger("State")];
component[i].getQty().textField.setText(String.valueOf(is.getStackSize()));
component[i].getBatch().textField.setText(String.valueOf(size));
component[i].setEnable(isEnable);
}
}
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar) {
for (Component com : this.component) {
handleTooltip(mouseX, mouseY, com.getQty().textField.new TooltipProvider());
handleTooltip(mouseX, mouseY, com.getBatch().textField.new TooltipProvider());
}
component[i].setState(state);
}
}
public void initGui() {
super.initGui();
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
component[i] = new Component(
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 37, guiTop + 21 + 20 * i, 52, 16),
new GuiFCImgButton(guiLeft + 37 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"),
I18n.format(NameConst.TT_REQUEST_SIZE),
new FCGuiTextField(this.fontRendererObj, guiLeft + 46, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_REQUEST_SIZE,
i,
"TileLevelMaintainer.Quantity"),
new Widget(
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 21 + 20 * i, 52, 16),
new GuiFCImgButton(guiLeft + 100 + 47, guiTop + 20 + 20 * i, "SUBMIT", "SUBMIT"),
I18n.format(NameConst.TT_BATCH_SIZE),
new FCGuiTextField(this.fontRendererObj, guiLeft + 100, guiTop + 19 + 19 * i, 52, 14),
NameConst.TT_LEVEL_MAINTAINER_BATCH_SIZE,
i,
"TileLevelMaintainer.Batch"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"),
new GuiFCImgButton(guiLeft + 105 + 47, guiTop + 17 + 19 * i, "SUBMIT", "SUBMIT", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "ENABLE", "ENABLE", false),
new GuiFCImgButton(guiLeft + 9, guiTop + 20 + 19 * i, "DISABLE", "DISABLE", false),
new FCGuiLineField(fontRendererObj, guiLeft + 47, guiTop + 33 + 19 * i, 125),
this.buttonList);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
}
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
for (Component com : this.component) {
com.getQty().textField.handleTooltip(mouseX, mouseY, this);
com.getBatch().textField.handleTooltip(mouseX, mouseY, this);
com.getLine().handleTooltip(mouseX, mouseY, this);
}
}
@Override
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();
if (tick > lastWorkingTick + interval && this.input == null) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
lastWorkingTick = MinecraftServer.getServer().getTickCounter();
}
for (int i = 0; i < TileLevelMaintainer.REQ_COUNT; i++) {
this.component[i].draw();
}
@@ -105,7 +128,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
fontRendererObj.drawString(getGuiDisplayName(NameConst.i18n(NameConst.GUI_LEVEL_MAINTAINER)), 8, 6, 0x404040);
mouseRegions.render(mouseX, mouseY);
}
@@ -253,25 +276,30 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private class Component {
public boolean isEnable = true;
private Widget qty;
private Widget batch;
private GuiFCImgButton disable;
private GuiFCImgButton enable;
private final Widget qty;
private final Widget batch;
private final GuiFCImgButton disable;
private final GuiFCImgButton enable;
private final GuiFCImgButton submit;
private final FCGuiLineField line;
private TileLevelMaintainer.State state;
public Component(
Widget qtyInput,
Widget batchInput,
GuiFCImgButton submitBtn,
GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn,
FCGuiLineField line,
List buttonList) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
this.disable = disableBtn;
this.enable.setHalfSize(true);
this.disable.setHalfSize(true);
buttonList.add(this.qty.button);
buttonList.add(this.batch.button);
this.submit = submitBtn;
this.line = line;
this.state = TileLevelMaintainer.State.Nothing;
buttonList.add(this.submit);
buttonList.add(this.enable);
buttonList.add(this.disable);
}
@@ -303,20 +331,20 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
protected boolean sendToServer(GuiButton btn) {
if (this.getQty().button == btn) {
return this.send(this.getQty());
}
if (this.getBatch().button == btn) {
return this.send(this.getBatch());
}
if (this.enable == btn) {
boolean didSomething = false;
if (this.submit == btn) {
if (this.send(this.getQty())) this.send(this.getBatch());
didSomething = true;
} else if (this.enable == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
didSomething = true;
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
didSomething = true;
}
return false;
return didSomething;
}
public FCGuiTextField isMouseIn(final int xCoord, final int yCoord) {
@@ -333,9 +361,50 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
return this.batch;
}
public FCGuiLineField getLine() {
return this.line;
}
public void draw() {
this.getQty().draw();
this.getBatch().draw();
ArrayList<String> message = new ArrayList<String>();
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_TITLE) + "\n");
switch (this.state) {
case Idling:
this.line.setColor(0xFF55FF55);
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
break;
case Crafting:
this.line.setColor(0xFFFFFF55);
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
break;
case Exporting:
this.line.setColor(0xFFAA00AA);
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
break;
default:
this.line.setColor(0);
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_CURRENT)
+ NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_NONE));
}
message.add("");
if (isShiftKeyDown()) {
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_IDLE_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_LINK_DESC) + "\n");
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT));
message.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_EXPORT_DESC));
} else {
message.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
this.line.setMessage(
render.wrapFormattedStringToWidth(String.join("\n", message), (int) Math.floor(xSize * 0.8)));
this.line.drawTextBox();
if (this.isEnable) {
this.enable.visible = true;
this.disable.visible = false;
@@ -344,33 +413,39 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.disable.visible = true;
}
}
public void setState(TileLevelMaintainer.State state) {
this.state = state;
}
}
private class Widget {
public final int idx;
public final String action;
private FCGuiTextField textField;
private GuiFCImgButton button;
private final FCGuiTextField textField;
private final String tooltip;
public Widget(FCGuiTextField textField, GuiFCImgButton button, String tooltip, int idx, String action) {
public Widget(FCGuiTextField textField, String tooltip, int idx, String action) {
this.textField = textField;
this.textField.setMessage(tooltip);
this.textField.setEnableBackgroundDrawing(false);
this.textField.setText("0");
this.textField.setMaxStringLength(10); // it's enough to useful
this.button = button;
this.idx = idx;
this.action = action;
this.tooltip = tooltip;
}
public void draw() {
if (isShiftKeyDown()) {
this.setTooltip(render.wrapFormattedStringToWidth(NameConst.i18n(this.tooltip), xSize / 2));
} else {
this.setTooltip(render.wrapFormattedStringToWidth(
NameConst.i18n(this.tooltip, "\n", false) + "\n" + NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE),
(int) Math.floor(xSize * 0.8)));
}
this.textField.drawTextBox();
}
public GuiFCImgButton btn() {
return this.button;
}
public void setTooltip(String message) {
this.textField.setMessage(message);
}
@@ -0,0 +1,179 @@
package com.glodblock.github.client.gui.container;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IItemList;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.iterators.NullIterator;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.util.Ae2Reflect;
import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
public class ContainerFluidStorageBus extends ContainerFluidConfigurable {
public final PartFluidStorageBus bus;
@GuiSync(3)
public AccessRestriction rwMode = AccessRestriction.READ_WRITE;
@GuiSync(4)
public StorageFilter storageFilter = StorageFilter.EXTRACTABLE_ONLY;
public ContainerFluidStorageBus(InventoryPlayer ip, PartFluidStorageBus te) {
super(ip, te);
this.bus = te;
}
@Override
protected int getHeight() {
return 251;
}
@Override
protected void setupConfig() {
final int xo = 8;
final int yo = 23 + 6;
final IInventory upgrades = Ae2Reflect.getUpgradeList(this).getInventoryByName("upgrades");
final IInventory config = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
for (int y = 0; y < 7; y++) {
for (int x = 0; x < 9; x++) {
this.addSlotToContainer(
new OptionalFluidSlotFakeTypeOnly(config, null, this, y * 9 + x, xo, yo, x, y, y));
}
}
this.addSlotToContainer((new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer()))
.setNotDraggable());
this.addSlotToContainer((new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
1,
187,
8 + 18,
this.getInventoryPlayer()))
.setNotDraggable());
this.addSlotToContainer((new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
2,
187,
8 + 18 * 2,
this.getInventoryPlayer()))
.setNotDraggable());
this.addSlotToContainer((new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
3,
187,
8 + 18 * 3,
this.getInventoryPlayer()))
.setNotDraggable());
this.addSlotToContainer((new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.UPGRADES,
upgrades,
4,
187,
8 + 18 * 4,
this.getInventoryPlayer()))
.setNotDraggable());
}
@Override
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
final int y = slot / 9;
return y < upgrades + 2;
}
return true;
}
@Override
protected boolean supportCapacity() {
return true;
}
@Override
public int availableUpgrades() {
return 5;
}
@Override
public void detectAndSendChanges() {
this.verifyPermissions(SecurityPermissions.BUILD, false);
if (Platform.isServer()) {
this.setReadWriteMode((AccessRestriction)
Ae2Reflect.getUpgradeList(this).getConfigManager().getSetting(Settings.ACCESS));
this.setStorageFilter((StorageFilter)
Ae2Reflect.getUpgradeList(this).getConfigManager().getSetting(Settings.STORAGE_FILTER));
}
this.standardDetectAndSendChanges();
}
@Override
public boolean isSlotEnabled(final int idx) {
if (Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.ORE_FILTER) > 0) return false;
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
return upgrades > (idx - 2);
}
public void clear() {
AppEngInternalAEInventory h = this.bus.getConfig();
for (int i = 0; i < h.getSizeInventory(); ++i) {
h.setInventorySlotContents(i, null);
}
this.detectAndSendChanges();
}
public void partition() {
AppEngInternalAEInventory h = this.bus.getConfig();
final IMEInventory<IAEFluidStack> cellInv = this.bus.getInternalHandler();
Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEFluidStack> list =
cellInv.getAvailableItems(AEApi.instance().storage().createFluidList());
i = list.iterator();
}
for (int x = 0; x < h.getSizeInventory(); x++) {
if (i.hasNext() && this.isSlotEnabled((x / 9) - 2)) {
h.setInventorySlotContents(x, ItemFluidPacket.newStack(i.next()));
} else {
h.setInventorySlotContents(x, null);
}
}
this.detectAndSendChanges();
}
public AccessRestriction getReadWriteMode() {
return this.rwMode;
}
public StorageFilter getStorageFilter() {
return this.storageFilter;
}
@Override
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
private void setReadWriteMode(final AccessRestriction rwMode) {
this.rwMode = rwMode;
}
private void setStorageFilter(final StorageFilter storageFilter) {
this.storageFilter = storageFilter;
}
}
@@ -18,11 +18,11 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
this.tile = tile;
AeItemStackHandler request = new AeItemStackHandler(tile.getRequestSlots());
for (int y = 0; y < TileLevelMaintainer.REQ_COUNT; y++) {
FakeSlot slot = new FakeSlot(request, y, 17, 19 + y * 20);
FakeSlot slot = new FakeSlot(request, y, 27, 20 + y * 19);
addSlotToContainer(slot);
requestSlots[y] = slot;
}
bindPlayerInventory(ipl, 0, 132);
bindPlayerInventory(ipl, 0, 130);
}
public TileLevelMaintainer getTile() {
@@ -342,7 +342,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
private void dropItem(ItemStack is) {
if (is.stackSize <= 0) return;
if (is == null || is.stackSize <= 0) return;
ItemStack itemStack = is.copy();
int i = itemStack.getMaxStackSize();
while (itemStack.stackSize > 0) {
@@ -363,7 +363,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
private void dropItem(ItemStack itemStack, int stackSize) {
if (itemStack.stackSize <= 0) return;
if (itemStack == null || itemStack.stackSize <= 0) return;
ItemStack is = itemStack.copy();
is.stackSize = stackSize;
this.dropItem(is);
@@ -392,12 +392,10 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
if (fillStack.right.getItem() instanceof IFluidContainerItem) {
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
if ((int) (tmp.getStackSize() % fillStack.left) > 0) {
((IFluidContainerItem) fillStack.right.getItem())
.drain(
fillStack.right,
fillStack.left - (int) (tmp.getStackSize() % fillStack.left),
true);
this.dropItem(fillStack.right, 1);
this.dropItem(
Util.FluidUtil.setFluidContainerAmount(
fillStack.right, (int) (tmp.getStackSize() % fillStack.left)),
1);
out.stackSize++;
}
} else if (FluidContainerRegistry.isContainer(fillStack.right)) {
@@ -448,9 +446,13 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer
}
if (slotIndex == -1) out.stackSize = fluidContainer.stackSize - out.stackSize;
} else {
out.stackSize = (int) (fluidContainer.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
if (slotIndex == -1) {
out.stackSize = fluidContainer.stackSize;
} else {
out.stackSize =
(int) (fluidContainer.stackSize - (aeFluidStack.getStackSize() / drainStack.left));
}
this.dropItem(drainStack.right, fluidContainer.stackSize); // drop empty item
if (slotIndex == -1) out.stackSize++;
}
} else {
continue;
@@ -18,6 +18,7 @@ public enum FCPartsTexture {
PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"),
PartFluidExportBus("fluid_export_face"),
PartFluidStorageBus("fluid_storage_bus"),
BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"),
BlockInterfaceAlternate("fluid_interface_a"),
BlockInterface_Face("fluid_interface"),
@@ -1,9 +1,11 @@
package com.glodblock.github.common.block;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import appeng.api.storage.data.IAEFluidStack;
import appeng.block.AEBaseItemBlock;
import appeng.util.Platform;
import com.glodblock.github.client.render.RenderBlockFluidBuffer;
import com.glodblock.github.common.item.FCBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidBuffer;
import com.glodblock.github.crossmod.waila.Tooltip;
@@ -12,6 +14,7 @@ import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -52,7 +55,7 @@ public class BlockFluidBuffer extends FCBaseBlock {
}
public BlockFluidBuffer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_BUFFER);
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_BUFFER);
GameRegistry.registerTileEntity(TileFluidBuffer.class, NameConst.BLOCK_FLUID_BUFFER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
@@ -71,4 +74,19 @@ public class BlockFluidBuffer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_FLUID_BUFFER_DESC));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -1,11 +1,17 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import com.glodblock.github.common.item.FCBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidDiscretizer;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class BlockFluidDiscretizer extends FCBaseBlock {
@@ -18,7 +24,7 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
}
public BlockFluidDiscretizer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_DISCRETIZER);
GameRegistry.registerTileEntity(TileFluidDiscretizer.class, NameConst.BLOCK_FLUID_DISCRETIZER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
@@ -31,4 +37,20 @@ public class BlockFluidDiscretizer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_DISCRETIZER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -1,6 +1,8 @@
package com.glodblock.github.common.block;
import appeng.block.AEBaseItemBlock;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import com.glodblock.github.common.item.FCBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.inventory.InventoryHandler;
@@ -8,6 +10,9 @@ import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -45,7 +50,7 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
}
public BlockFluidPacketDecoder register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
GameRegistry.registerTileEntity(TileFluidPacketDecoder.class, NameConst.BLOCK_FLUID_PACKET_DECODER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
@@ -58,4 +63,19 @@ public class BlockFluidPacketDecoder extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_FLUID_PACKET_DECODER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -1,9 +1,12 @@
package com.glodblock.github.common.block;
import static net.minecraft.client.gui.GuiScreen.isCtrlKeyDown;
import static net.minecraft.client.gui.GuiScreen.isShiftKeyDown;
import appeng.api.config.SecurityPermissions;
import appeng.block.AEBaseItemBlock;
import appeng.util.Platform;
import com.glodblock.github.client.render.RenderBlockLevelMaintainer;
import com.glodblock.github.common.item.FCBaseItemBlock;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.common.tile.TileLevelMaintainer;
import com.glodblock.github.inventory.InventoryHandler;
@@ -14,6 +17,7 @@ import com.glodblock.github.util.Util;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -31,7 +35,7 @@ public class BlockLevelMaintainer extends FCBaseBlock {
}
public BlockLevelMaintainer register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER);
GameRegistry.registerBlock(this, FCBaseItemBlock.class, NameConst.BLOCK_LEVEL_MAINTAINER);
GameRegistry.registerTileEntity(TileLevelMaintainer.class, NameConst.BLOCK_LEVEL_MAINTAINER);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
@@ -75,4 +79,21 @@ public class BlockLevelMaintainer extends FCBaseBlock {
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {
if (isShiftKeyDown() && isCtrlKeyDown()) {
toolTip.add(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_WHO_AM_I));
} else if (isShiftKeyDown()) {
toolTip.addAll(this.listFormattedStringToWidth(NameConst.i18n(NameConst.TT_LEVEL_MAINTAINER_DESC)));
} else {
toolTip.add(NameConst.i18n(NameConst.TT_SHIFT_FOR_MORE));
}
}
}
@@ -3,8 +3,14 @@ package com.glodblock.github.common.block;
import appeng.block.AEBaseTileBlock;
import appeng.core.features.AEFeature;
import com.glodblock.github.FluidCraft;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.EnumSet;
import java.util.List;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class FCBaseBlock extends AEBaseTileBlock {
@@ -32,4 +38,21 @@ public class FCBaseBlock extends AEBaseTileBlock {
public void setFeature(final EnumSet<AEFeature> f) {
super.setFeature(f);
}
@SuppressWarnings("unchecked")
@SideOnly(Side.CLIENT)
public void addInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {}
protected final List listFormattedStringToWidth(String str) {
return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150);
}
public void addCheckedInformation(
ItemStack itemStack, EntityPlayer player, List<String> toolTip, boolean advancedToolTips) {
this.addInformation(itemStack, player, toolTip, advancedToolTips);
}
}
@@ -0,0 +1,30 @@
package com.glodblock.github.common.item;
import appeng.block.AEBaseItemBlock;
import com.glodblock.github.common.block.FCBaseBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
public class FCBaseItemBlock extends AEBaseItemBlock {
private final FCBaseBlock blockType;
public FCBaseItemBlock(Block id) {
super(id);
blockType = (FCBaseBlock) id;
}
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addCheckedInformation(
final ItemStack itemStack,
final EntityPlayer player,
final List<String> toolTip,
final boolean advancedToolTips) {
blockType.addCheckedInformation(itemStack, player, toolTip, advancedToolTips);
super.addCheckedInformation(itemStack, player, toolTip, advancedToolTips);
}
}
@@ -1,5 +1,6 @@
package com.glodblock.github.common.item;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.util.item.AEItemStack;
import com.glodblock.github.FluidCraft;
@@ -91,6 +92,13 @@ public class ItemFluidPacket extends Item {
return stack;
}
public static ItemStack newStack(@Nullable IAEFluidStack fluid) {
if (fluid == null || fluid.getStackSize() == 0) {
return null;
}
return newStack(fluid.getFluidStack());
}
public static ItemStack newDisplayStack(@Nullable FluidStack fluid) {
if (fluid == null) {
return null;
@@ -0,0 +1,70 @@
package com.glodblock.github.common.item;
import appeng.api.AEApi;
import appeng.api.parts.IPartItem;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.tabs.FluidCraftingTabs;
import com.glodblock.github.util.NameConst;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
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 ItemPartFluidStorageBus() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_STORAGE_BUS);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartFluidStorageBus createPartFromItemStack(ItemStack is) {
return new PartFluidStorageBus(is);
}
@Override
public boolean onItemUse(
ItemStack stack,
EntityPlayer player,
World world,
int x,
int y,
int z,
int side,
float xOffset,
float yOffset,
float zOffset) {
return AEApi.instance().partHelper().placeBus(player.getHeldItem(), x, y, z, side, player, world);
}
public ItemPartFluidStorageBus register() {
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_STORAGE_BUS, FluidCraft.MODID);
setCreativeTab(FluidCraftingTabs.INSTANCE);
return this;
}
@Override
public void registerIcons(IIconRegister _iconRegister) {}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber() {
return 0;
}
public ItemStack stack(int size) {
return new ItemStack(this, size);
}
public ItemStack stack() {
return new ItemStack(this, 1);
}
}
@@ -0,0 +1,517 @@
package com.glodblock.github.common.parts;
import appeng.api.AEApi;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.events.MENetworkCellArrayUpdate;
import appeng.api.networking.events.MENetworkChannelsChanged;
import appeng.api.networking.events.MENetworkEventSubscribe;
import appeng.api.networking.events.MENetworkPowerStatusChange;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.ITickManager;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.*;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.IConfigManager;
import appeng.client.texture.CableBusTextures;
import appeng.core.settings.TickRates;
import appeng.helpers.IPriorityHost;
import appeng.me.GridAccessException;
import appeng.me.cache.GridStorageCache;
import appeng.me.storage.MEInventoryHandler;
import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.prioitylist.PrecisePriorityList;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileFluidInterface;
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;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
public class PartFluidStorageBus extends PartUpgradeable
implements IGridTickable, ICellContainer, IMEMonitorHandlerReceiver<IAEFluidStack>, IPriorityHost {
private final BaseActionSource source;
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory(this, 63);
private int priority = 0;
private boolean cached = false;
private MEMonitorIFluidHandler monitor = null;
private MEInventoryHandler<IAEFluidStack> handler = null;
private int handlerHash = 0;
private boolean wasActive = false;
private byte resetCacheLogic = 0;
private boolean accessChanged;
private boolean readOncePass;
public PartFluidStorageBus(ItemStack is) {
super(is);
this.getConfigManager().registerSetting(Settings.ACCESS, AccessRestriction.READ_WRITE);
this.getConfigManager().registerSetting(Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL);
this.getConfigManager().registerSetting(Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY);
this.source = new MachineSource(this);
}
@Override
@MENetworkEventSubscribe
public void powerRender(final MENetworkPowerStatusChange c) {
this.updateStatus();
}
@Override
@MENetworkEventSubscribe
public void chanRender(final MENetworkChannelsChanged changedChannels) {
this.updateStatus();
}
protected void updateStatus() {
final boolean currentActive = this.getProxy().isActive();
if (this.wasActive != currentActive) {
this.wasActive = currentActive;
try {
this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate());
this.getHost().markForUpdate();
} catch (final GridAccessException e) {
// NO-OP
}
}
}
@Override
protected int getUpgradeSlots() {
return 5;
}
@Override
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (settingName.name().equals("ACCESS")) {
this.accessChanged = true;
}
this.resetCache(true);
this.getHost().markForSave();
}
@Override
public void upgradesChanged() {
super.upgradesChanged();
this.resetCache(true);
}
@Override
public void readFromNBT(final NBTTagCompound data) {
super.readFromNBT(data);
this.config.readFromNBT(data, "config");
this.priority = data.getInteger("priority");
this.accessChanged = false;
}
@Override
public void writeToNBT(final NBTTagCompound data) {
super.writeToNBT(data);
this.config.writeToNBT(data, "config");
data.setInteger("priority", this.priority);
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("config")) {
return this.config;
}
return super.getInventoryByName(name);
}
@Override
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {
super.onChangeInventory(inv, slot, mc, removedStack, newStack);
if (inv == this.config) {
this.resetCache(true);
}
}
protected void resetCache(final boolean fullReset) {
if (this.getHost() == null
|| this.getHost().getTile() == null
|| this.getHost().getTile().getWorldObj() == null
|| this.getHost().getTile().getWorldObj().isRemote) {
return;
}
if (fullReset) {
this.resetCacheLogic = 2;
} else if (this.resetCacheLogic < 2) {
this.resetCacheLogic = 1;
}
try {
this.getProxy().getTick().alertDevice(this.getProxy().getNode());
} catch (final GridAccessException ignore) {
}
}
protected void resetCache() {
final boolean fullReset = this.resetCacheLogic == 2;
this.resetCacheLogic = 0;
final MEInventoryHandler<IAEFluidStack> in = this.getInternalHandler();
IItemList<IAEFluidStack> before = AEApi.instance().storage().createFluidList();
if (in != null) {
if (accessChanged) {
AccessRestriction currentAccess =
(AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS);
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
readOncePass = true;
}
before = in.getAvailableItems(before);
in.setBaseAccess(currentAccess);
accessChanged = false;
} else {
before = in.getAvailableItems(before);
}
}
this.cached = false;
if (fullReset) {
this.handlerHash = 0;
}
final MEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
IItemList<IAEFluidStack> after = AEApi.instance().storage().createFluidList();
if (in != out) {
if (out != null) {
after = out.getAvailableItems(after);
}
Platform.postListChanges(before, after, this, this.source);
}
}
@Override
public boolean isValid(final Object verificationToken) {
return this.handler == verificationToken;
}
@Override
public void postChange(
final IBaseMonitor<IAEFluidStack> monitor,
final Iterable<IAEFluidStack> change,
final BaseActionSource source) {
if (this.getProxy().isActive()) {
AccessRestriction currentAccess =
(AccessRestriction) ((ConfigManager) this.getConfigManager()).getSetting(Settings.ACCESS);
if (readOncePass) {
readOncePass = false;
try {
this.getProxy()
.getStorage()
.postAlterationOfStoredItems(StorageChannel.FLUIDS, change, this.source);
} catch (final GridAccessException ignore) {
}
return;
}
if (!currentAccess.hasPermission(AccessRestriction.READ)) {
return;
}
try {
this.getProxy().getStorage().postAlterationOfStoredItems(StorageChannel.FLUIDS, change, source);
} catch (final GridAccessException ignore) {
}
}
}
@Override
public void onListUpdate() {
// NO-OP
}
@Override
public void getBoxes(final IPartCollisionHelper bch) {
bch.addBox(3, 3, 15, 13, 13, 16);
bch.addBox(2, 2, 14, 14, 14, 15);
bch.addBox(5, 5, 12, 11, 11, 14);
}
@Override
public void onNeighborChanged() {
BlockPos neighbor = new BlockPos(this.getTile()).getOffSet(this.getSide());
final TileEntity te = neighbor.getTileEntity();
// In case the TE was destroyed, we have to do a full reset immediately.
if (te instanceof TileCableBus) {
IPart iPart = ((TileCableBus) te).getPart(this.getSide().getOpposite());
if (iPart == null || iPart instanceof PartFluidInterface) {
this.resetCache(true);
this.resetCache();
}
if (ModAndClassUtil.EC2) {
if (iPart == null || iPart instanceof extracells.part.PartFluidInterface) {
this.resetCache(true);
this.resetCache();
}
}
} else if (te == null || te instanceof TileFluidInterface) {
this.resetCache(true);
this.resetCache();
} else if (ModAndClassUtil.EC2) {
if (te instanceof TileEntityFluidInterface) {
this.resetCache(true);
this.resetCache();
}
} else {
this.resetCache(false);
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {
if (player.isSneaking()) {
return false;
}
if (Platform.isServer()) {
InventoryHandler.openGui(
player,
this.getHost().getTile().getWorldObj(),
new BlockPos(this.getHost().getTile()),
Objects.requireNonNull(Util.from(this.getSide())),
GuiType.FLUID_STORAGE_BUS);
}
return true;
}
@Override
public TickingRequest getTickingRequest(IGridNode node) {
return new TickingRequest(TickRates.StorageBus.getMin(), TickRates.StorageBus.getMax(), monitor == null, true);
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall) {
if (this.resetCacheLogic != 0) {
this.resetCache();
}
if (this.monitor != null) {
return this.monitor.onTick();
}
return TickRateModulation.SLEEP;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public MEInventoryHandler<IAEFluidStack> getInternalHandler() {
if (this.cached) {
return this.handler;
}
final boolean wasSleeping = this.monitor == null;
this.cached = true;
final TileEntity self = this.getHost().getTile();
final TileEntity target = new BlockPos(self).getOffSet(this.getSide()).getTileEntity();
final int newHandlerHash = Platform.generateTileHash(target);
if (newHandlerHash != 0 && newHandlerHash == this.handlerHash) {
return this.handler;
}
this.handlerHash = newHandlerHash;
this.handler = null;
this.monitor = null;
if (target != null) {
final IExternalStorageHandler esh = AEApi.instance()
.registries()
.externalStorage()
.getHandler(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
if (esh != null) {
final IMEInventory<?> inv =
esh.getInventory(target, this.getSide().getOpposite(), StorageChannel.FLUIDS, this.source);
if (inv instanceof MEMonitorIFluidHandler) {
final MEMonitorIFluidHandler h = (MEMonitorIFluidHandler) inv;
h.setMode((StorageFilter) this.getConfigManager().getSetting(Settings.STORAGE_FILTER));
h.setActionSource(new MachineSource(this));
this.monitor = (MEMonitorIFluidHandler) inv;
}
if (inv != null) {
this.handler = new MEInventoryHandler(inv, StorageChannel.FLUIDS);
this.handler.setBaseAccess(
(AccessRestriction) this.getConfigManager().getSetting(Settings.ACCESS));
this.handler.setWhitelist(
this.getInstalledUpgrades(Upgrades.INVERTER) > 0
? IncludeExclude.BLACKLIST
: IncludeExclude.WHITELIST);
this.handler.setPriority(this.priority);
if (inv instanceof IMEMonitor) {
((IBaseMonitor) inv).addListener(this, this.handler);
}
final IItemList<IAEFluidStack> priorityList =
AEApi.instance().storage().createFluidList();
final int slotsToUse = 18 + this.getInstalledUpgrades(Upgrades.CAPACITY) * 9;
for (int x = 0; x < this.config.getSizeInventory() && x < slotsToUse; x++) {
final IAEItemStack is = this.config.getAEStackInSlot(x);
if (is != null) priorityList.add(AEFluidStack.create(ItemFluidPacket.getFluidStack(is)));
}
this.handler.setPartitionList(new PrecisePriorityList(priorityList));
}
}
}
// update sleep state...
if (wasSleeping != (this.monitor == null)) {
try {
final ITickManager tm = this.getProxy().getTick();
if (this.monitor == null) {
tm.sleepDevice(this.getProxy().getNode());
} else {
tm.wakeDevice(this.getProxy().getNode());
}
} catch (final GridAccessException ignore) {
}
}
try {
// force grid to update handlers...
((GridStorageCache) this.getProxy().getGrid().getCache(IStorageGrid.class)).cellUpdate(null);
} catch (final GridAccessException ignore) {
}
return this.handler;
}
@Override
@SuppressWarnings("rawtypes")
public List<IMEInventoryHandler> getCellArray(final StorageChannel channel) {
if (channel == StorageChannel.FLUIDS) {
final IMEInventoryHandler<IAEFluidStack> out = this.getInternalHandler();
if (out != null) {
return Collections.singletonList(out);
}
}
return Collections.emptyList();
}
@Override
public int getPriority() {
return this.priority;
}
@Override
public void setPriority(int newValue) {
this.priority = newValue;
this.getHost().markForSave();
this.resetCache(true);
}
@Override
public void blinkCell(int slot) {
// NO-OP
}
@Override
public void saveChanges(final IMEInventory cellInventory) {
// NO-OP
}
public AppEngInternalAEInventory getConfig() {
return this.config;
}
public void setFluidInSlot(int id, IAEFluidStack fluid) {
ItemStack tmp = ItemFluidPacket.newDisplayStack(fluid == null ? null : fluid.getFluidStack());
this.config.setInventorySlotContents(id, tmp);
}
@Override
@SideOnly(Side.CLIENT)
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer) {
rh.setTexture(
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageBack.getIcon(),
FCPartsTexture.PartFluidStorageBus.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon());
rh.setBounds(3, 3, 15, 13, 13, 16);
rh.renderInventoryBox(renderer);
rh.setBounds(2, 2, 14, 14, 14, 15);
rh.renderInventoryBox(renderer);
rh.setBounds(5, 5, 12, 11, 11, 14);
rh.renderInventoryBox(renderer);
}
@Override
@SideOnly(Side.CLIENT)
public void renderStatic(
final int x, final int y, final int z, final IPartRenderHelper rh, final RenderBlocks renderer) {
this.setRenderCache(rh.useSimplifiedRendering(x, y, z, this, this.getRenderCache()));
rh.setTexture(
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageBack.getIcon(),
FCPartsTexture.PartFluidStorageBus.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon());
rh.setBounds(3, 3, 15, 13, 13, 16);
rh.renderBlock(x, y, z, renderer);
rh.setBounds(2, 2, 14, 14, 14, 15);
rh.renderBlock(x, y, z, renderer);
rh.setTexture(
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageBack.getIcon(),
FCPartsTexture.PartFluidStorageBus.getIcon(),
CableBusTextures.PartStorageSides.getIcon(),
CableBusTextures.PartStorageSides.getIcon());
rh.setBounds(5, 5, 12, 11, 11, 13);
rh.renderBlock(x, y, z, renderer);
rh.setTexture(
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorBack.getIcon(),
FCPartsTexture.PartFluidStorageBus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon(),
CableBusTextures.PartMonitorSidesStatus.getIcon());
rh.setBounds(5, 5, 13, 11, 11, 14);
rh.renderBlock(x, y, z, renderer);
this.renderLights(x, y, z, rh, renderer);
}
}
@@ -69,6 +69,15 @@ public class TileLevelMaintainer extends AENetworkTile
return ImmutableSet.copyOf(new NonNullArrayIterator<ICraftingLink>(this.requests.getLinks()));
}
private IAEItemStack setState(ICraftingLink link, IAEItemStack items) {
if (items != null) {
requests.setState(link, State.Exporting);
} else {
requests.setState(link, State.Crafting);
}
return items;
}
@Override
public IAEItemStack injectCraftedItems(ICraftingLink link, IAEItemStack items, Actionable mode) {
try {
@@ -84,19 +93,21 @@ public class TileLevelMaintainer extends AENetworkTile
.injectItems(ItemFluidDrop.getAeFluidStack(items), mode, this.source);
if (notInserted != null) {
items.setStackSize(notInserted.getStackSize());
return items;
return setState(link, items);
} else {
return null;
}
} else {
return this.getProxy().getStorage().getItemInventory().injectItems(items, mode, this.source);
return setState(
link,
this.getProxy().getStorage().getItemInventory().injectItems(items, mode, this.source));
}
}
}
} catch (GridAccessException e) {
AELog.debug(e);
}
return items;
return setState(link, items);
}
@Override
@@ -135,23 +146,27 @@ public class TileLevelMaintainer extends AENetworkTile
IAEItemStack is = requests.getRequestQtyStack(i);
if (is != null && requests.getBatchSize(i) > 0) {
IAEItemStack craftItem = requests.getCraftItem(i);
if (this.requests.isDone(i)) this.requests.setState(i, State.Idling);
if (cg.canEmitFor(craftItem)
|| cg.isRequesting(craftItem)
|| (inv.findPrecise(is) != null
&& inv.findPrecise(is).getStackSize() >= is.getStackSize())
|| inv.findPrecise(is) == null
|| !inv.findPrecise(is).isCraftable()
|| inv.findPrecise(is).getStackSize() >= is.getStackSize()
|| !this.requests.isDone(i)) continue;
// do crafting
Future<ICraftingJob> jobTask = requests.getJobs()[i];
if (jobTask == null) {
requests.getJobs()[i] = cg.beginCraftingJob(getWorldObj(), grid, this.source, craftItem, null);
} else if (jobTask.isDone()) {
requests.setState(i, State.Idling);
try {
ICraftingJob job = jobTask.get();
if (job != null) {
ICraftingLink link = cg.submitJob(job, this, null, false, this.source);
didSomething = true;
requests.jobs[i] = null;
if (link != null) {
didSomething = true;
requests.setState(i, State.Crafting);
requests.getLinks()[i] = link;
}
}
@@ -227,6 +242,7 @@ public class TileLevelMaintainer extends AENetworkTile
this.requests.getLinks()[i] = null;
} else {
this.requests.getLinks()[i] = AEApi.instance().storage().loadCraftingLink(link, this);
if (!this.requests.isDone(i)) this.requests.setState(i, State.Crafting);
}
}
} catch (Exception e) {
@@ -294,19 +310,26 @@ public class TileLevelMaintainer extends AENetworkTile
} catch (final GridAccessException ignored) {
}
if (newState != this.isPowered) {
this.isPowered = newState;
this.markForUpdate();
}
}
public enum State {
Nothing,
Idling,
Crafting,
Exporting
}
public static class InventoryRequest {
private final AeStackInventoryImpl<IAEItemStack> requestStacks;
private final AeStackInventoryImpl<IAEItemStack> requestBatches;
private final AeStackInventoryImpl<IAEItemStack> requestQtys;
private final Future<ICraftingJob>[] jobs;
private final ICraftingLink[] links;
private final State[] state = new State[REQ_COUNT];
public InventoryRequest(TileLevelMaintainer tile) {
this.requestStacks = new AeStackInventoryImpl<>(StorageChannel.ITEMS, REQ_COUNT, tile);
@@ -330,6 +353,30 @@ public class TileLevelMaintainer extends AENetworkTile
}
}
public State getState(int idx) {
IAEItemStack ias = this.getRequestStacks().getStack(idx);
if (ias == null) {
return State.Nothing;
} else {
return this.state[idx] == null ? State.Idling : this.state[idx];
}
}
public void setState(ICraftingLink link, State state) {
int i = 0;
for (ICraftingLink link1 : this.getLinks()) {
if (link == link1) {
this.setState(i, state);
break;
}
i++;
}
}
public void setState(int idx, State state) {
this.state[idx] = state;
}
public boolean isEnable(int idx) {
IAEItemStack ias = this.getRequestBatches().getStack(idx);
if (ias != null) {
@@ -35,6 +35,9 @@ public class FCClassTransformer implements IClassTransformer {
case "appeng.tile.storage.TileIOPort":
tform = TitleIOPortTransformer.INSTANCE;
break;
case "appeng.core.features.registries.ExternalStorageRegistry":
tform = ExternalStorageRegistryTransformer.INSTANCE;
break;
default:
return code;
}
@@ -53,7 +56,7 @@ public class FCClassTransformer implements IClassTransformer {
public byte[] transformClass(byte[] code) {
ClassReader reader = new ClassReader(code);
ClassWriter writer = new ClassWriter(reader, getWriteFlags());
reader.accept(getClassMapper(writer), 0);
reader.accept(getClassMapper(writer), ClassReader.EXPAND_FRAMES);
return writer.toByteArray();
}
@@ -0,0 +1,99 @@
package com.glodblock.github.coremod.transform;
import com.glodblock.github.coremod.FCClassTransformer;
import org.objectweb.asm.*;
public class ExternalStorageRegistryTransformer extends FCClassTransformer.ClassMapper {
public static final ExternalStorageRegistryTransformer INSTANCE = new ExternalStorageRegistryTransformer();
private ExternalStorageRegistryTransformer() {
// NO-OP
}
@Override
protected ClassVisitor getClassMapper(ClassVisitor downstream) {
return new TransformExternalStorageRegistry(Opcodes.ASM5, downstream);
}
@Override
protected int getWriteFlags() {
return ClassWriter.COMPUTE_FRAMES;
}
private static class TransformExternalStorageRegistry extends ClassVisitor {
public TransformExternalStorageRegistry(int api, ClassVisitor cv) {
super(api, cv);
}
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
if ("getHandler".equals(name)) {
return new TransformGetHandler(api, super.visitMethod(access, name, desc, signature, exceptions));
} else {
return super.visitMethod(access, name, desc, signature, exceptions);
}
}
}
private static class TransformGetHandler extends MethodVisitor {
private int cnt_return = 0;
private int cnt_if = 0;
private Label L6 = null;
private final Label L9 = new Label();
TransformGetHandler(int api, MethodVisitor mv) {
super(api, mv);
}
@Override
public void visitJumpInsn(int opcode, Label label) {
if (opcode == Opcodes.IFEQ) {
cnt_if++;
}
if (cnt_if == 3) {
L6 = label;
cnt_if++;
super.visitJumpInsn(opcode, L9);
return;
}
super.visitJumpInsn(opcode, label);
}
@Override
public void visitInsn(int opcode) {
if (opcode == Opcodes.ARETURN) {
cnt_return++;
}
super.visitInsn(opcode);
if (cnt_return == 2) {
super.visitLabel(L9);
super.visitFieldInsn(
Opcodes.GETSTATIC,
"com/glodblock/github/inventory/external/AEFluidTankHandler",
"INSTANCE",
"Lcom/glodblock/github/inventory/external/AEFluidTankHandler;");
super.visitVarInsn(Opcodes.ALOAD, 1);
super.visitVarInsn(Opcodes.ALOAD, 2);
super.visitVarInsn(Opcodes.ALOAD, 3);
super.visitVarInsn(Opcodes.ALOAD, 4);
super.visitMethodInsn(
Opcodes.INVOKEVIRTUAL,
"com/glodblock/github/inventory/external/AEFluidTankHandler",
"canHandle",
"(Lnet/minecraft/tileentity/TileEntity;Lnet/minecraftforge/common/util/ForgeDirection;Lappeng/api/storage/StorageChannel;Lappeng/api/networking/security/BaseActionSource;)Z",
false);
super.visitJumpInsn(Opcodes.IFEQ, L6);
super.visitFieldInsn(
Opcodes.GETSTATIC,
"com/glodblock/github/inventory/external/AEFluidTankHandler",
"INSTANCE",
"Lcom/glodblock/github/inventory/external/AEFluidTankHandler;");
super.visitInsn(Opcodes.ARETURN);
cnt_return++;
}
}
}
}
@@ -20,14 +20,22 @@ import net.minecraftforge.fluids.IFluidHandler;
public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
private final IFluidHandler handler;
private final ForgeDirection side;
private IItemList<IAEFluidStack> cache = AEApi.instance().storage().createFluidList();
private final HashMap<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> listeners = new HashMap<>();
private BaseActionSource mySource;
private StorageFilter mode;
public MEMonitorIFluidHandler(IFluidHandler handler, ForgeDirection side) {
this.mode = StorageFilter.EXTRACTABLE_ONLY;
this.handler = handler;
this.side = side;
}
public MEMonitorIFluidHandler(IFluidHandler handler) {
this.mode = StorageFilter.EXTRACTABLE_ONLY;
this.handler = handler;
this.side = ForgeDirection.UNKNOWN;
}
public void addListener(IMEMonitorHandlerReceiver<IAEFluidStack> l, Object verificationToken) {
@@ -39,7 +47,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) {
int filled = this.handler.fill(ForgeDirection.UNKNOWN, input.getFluidStack(), type == Actionable.MODULATE);
int filled = this.handler.fill(this.side, input.getFluidStack(), type == Actionable.MODULATE);
if (filled == 0) {
return input.copy();
} else if ((long) filled == input.getStackSize()) {
@@ -58,8 +66,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) {
FluidStack removed =
this.handler.drain(ForgeDirection.UNKNOWN, request.getFluidStack(), type == Actionable.MODULATE);
FluidStack removed = this.handler.drain(this.side, request.getFluidStack(), type == Actionable.MODULATE);
if (removed != null && removed.amount != 0) {
IAEFluidStack o = request.copy();
o.setStackSize(removed.amount);
@@ -86,13 +93,14 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
public TickRateModulation onTick() {
boolean changed = false;
List<IAEFluidStack> changes = new ArrayList<>();
FluidTankInfo[] tankProperties = this.handler.getTankInfo(ForgeDirection.UNKNOWN);
FluidTankInfo[] tankProperties = this.handler.getTankInfo(this.side);
IItemList<IAEFluidStack> currentlyOnStorage = AEApi.instance().storage().createFluidList();
for (FluidTankInfo tankProperty : tankProperties) {
if (this.mode != StorageFilter.EXTRACTABLE_ONLY
|| this.handler.drain(ForgeDirection.UNKNOWN, 1, false) != null) {
currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid));
if (tankProperties != null) {
for (FluidTankInfo tankProperty : tankProperties) {
if (this.mode != StorageFilter.EXTRACTABLE_ONLY || this.handler.drain(this.side, 1, false) != null) {
currentlyOnStorage.add(AEFluidStack.create(tankProperty.fluid));
}
}
}
@@ -131,7 +139,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
private void postDifference(Iterable<IAEFluidStack> a) {
if (a != null) {
Iterator i = this.listeners.entrySet().iterator();
Iterator<?> i = this.listeners.entrySet().iterator();
while (i.hasNext()) {
Map.Entry<IMEMonitorHandlerReceiver<IAEFluidStack>, Object> l = (Map.Entry) i.next();
@@ -170,7 +178,7 @@ public class MEMonitorIFluidHandler implements IMEMonitor<IAEFluidStack> {
}
public IItemList<IAEFluidStack> getAvailableItems(IItemList out) {
Iterator var2 = this.cache.iterator();
Iterator<?> var2 = this.cache.iterator();
while (var2.hasNext()) {
IAEFluidStack fs = (IAEFluidStack) var2.next();
@@ -0,0 +1,40 @@
package com.glodblock.github.inventory.external;
import appeng.api.implementations.tiles.ITileStorageMonitorable;
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 net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class AEFluidInterfaceHandler implements IExternalStorageHandler {
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc) {
if (channel == StorageChannel.FLUIDS) {
if (te instanceof ITileStorageMonitorable) {
return true;
} else
return te instanceof TileCableBus
&& ((TileCableBus) te).getPart(d.getOpposite()) instanceof ITileStorageMonitorable;
}
return false;
}
@Override
@SuppressWarnings("rawtypes")
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src) {
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());
return part.getMonitorable(d, src).getFluidInventory();
}
}
return null;
}
}
@@ -0,0 +1,31 @@
package com.glodblock.github.inventory.external;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import com.glodblock.github.inventory.MEMonitorIFluidHandler;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
// This handler is too generic, so it will overlap other mods' fluid handler.
// It will be injected into external handler by ASM to make sure it is executed at last.
public class AEFluidTankHandler implements IExternalStorageHandler {
public static final AEFluidTankHandler INSTANCE = new AEFluidTankHandler();
@Override
public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc) {
return channel == StorageChannel.FLUIDS && te instanceof IFluidHandler;
}
@Override
@SuppressWarnings("rawtypes")
public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src) {
if (channel == StorageChannel.FLUIDS) {
return new MEMonitorIFluidHandler((IFluidHandler) te, d);
}
return null;
}
}
@@ -10,6 +10,7 @@ import com.glodblock.github.client.gui.*;
import com.glodblock.github.client.gui.container.*;
import com.glodblock.github.common.parts.FCBasePart;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.parts.PartFluidStorageBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.common.tile.*;
import com.google.common.collect.ImmutableList;
@@ -113,6 +114,18 @@ public enum GuiType {
}
}),
FLUID_STORAGE_BUS_PRIORITY(new PartGuiFactory<IPriorityHost>(IPriorityHost.class) {
@Override
protected Object createServerGui(EntityPlayer player, IPriorityHost inv) {
return new ContainerPriority(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IPriorityHost inv) {
return new GuiFCPriority(player.inventory, inv);
}
}),
FLUID_BUS_IO(new PartGuiFactory<PartSharedFluidBus>(PartSharedFluidBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartSharedFluidBus inv) {
@@ -125,6 +138,18 @@ public enum GuiType {
}
}),
FLUID_STORAGE_BUS(new PartGuiFactory<PartFluidStorageBus>(PartFluidStorageBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartFluidStorageBus inv) {
return new ContainerFluidStorageBus(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartFluidStorageBus inv) {
return new GuiFluidStorageBus(player.inventory, inv);
}
}),
INGREDIENT_BUFFER(new TileGuiFactory<TileIngredientBuffer>(TileIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileIngredientBuffer inv) {
@@ -0,0 +1,21 @@
package com.glodblock.github.loader;
import appeng.api.storage.data.IAEItemStack;
import appeng.crafting.v2.CraftingCalculations;
import appeng.crafting.v2.CraftingRequest;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidDrop;
public class CalculatorV2PluginLoader {
private static long adjustByteCost(CraftingRequest<IAEItemStack> request, Long originalAmount) {
if (request.stack.getItem() instanceof ItemFluidDrop) {
return Platform.ceilDiv(originalAmount, 1000L);
} else {
return originalAmount;
}
}
public static void installCalculatorV2Plugins() {
CraftingCalculations.registerByteAmountAdjuster(CalculatorV2PluginLoader::adjustByteCost, IAEItemStack.class);
}
}
@@ -25,6 +25,7 @@ public class ItemAndBlockHolder {
public static ItemPartFluidInterface FLUID_INTERFACE = new ItemPartFluidInterface().register();
public static ItemFluidImportBus FLUID_IMPORT_BUS = new ItemFluidImportBus().register();
public static ItemFluidExportBus FLUID_EXPORT_BUS = new ItemFluidExportBus().register();
public static ItemPartFluidStorageBus FLUID_STORAGE_BUS = new ItemPartFluidStorageBus().register();
public static ItemFluidPacket PACKET = new ItemFluidPacket().register();
public static ItemBasicFluidStorageCell CELL1K = new ItemBasicFluidStorageCell(CellType.Cell1kPart, 1).register();
public static ItemBasicFluidStorageCell CELL4K = new ItemBasicFluidStorageCell(CellType.Cell4kPart, 4).register();
@@ -50,6 +50,7 @@ public class RecipeLoader implements Runnable {
public static final ItemStack AE2_CORE_FOM =
new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43);
public static final ItemStack PISTON = new ItemStack(Blocks.piston, 1);
public static final ItemStack STICKY_PISTON = new ItemStack(Blocks.sticky_piston, 1);
public static final ItemStack AE2_BLANK_PATTERN =
new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 52);
public static final ItemStack AE2_TERMINAL =
@@ -119,6 +120,8 @@ public class RecipeLoader implements Runnable {
AE2_PROCESS_ENG,
'W',
AE2_WORK_BENCH));
GameRegistry.addShapelessRecipe(FLUID_STORAGE_BUS.stack(), FLUID_INTERFACE, STICKY_PISTON, PISTON);
GameRegistry.addShapelessRecipe(FLUID_STORAGE_BUS.stack(), INTERFACE, STICKY_PISTON, PISTON);
GameRegistry.addShapelessRecipe(FLUID_TERMINAL.stack(), AE2_PATTERN_TERM, ENCODER);
GameRegistry.addShapelessRecipe(
FLUID_TERMINAL_EX.stack(), FLUID_TERMINAL.stack(), AE2_PROCESS_CAL, AE2_PROCESS_ENG, AE2_PROCESS_LOG);
@@ -3,6 +3,7 @@ package com.glodblock.github.network;
import com.glodblock.github.client.gui.container.ContainerFluidCraftConfirm;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminalEx;
import com.glodblock.github.client.gui.container.ContainerFluidStorageBus;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@@ -145,6 +146,15 @@ public class CPacketFluidPatternTermBtns implements IMessage {
} else if (Name.equals("Terminal.Start") && c instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
qk.startJob();
} else if (Name.startsWith("StorageBus.") && c instanceof ContainerFluidStorageBus) {
final ContainerFluidStorageBus ccw = (ContainerFluidStorageBus) c;
if (Name.equals("StorageBus.Action")) {
if (Value.equals("Partition")) {
ccw.partition();
} else if (Value.equals("Clear")) {
ccw.clear();
}
}
}
return null;
}
@@ -46,12 +46,13 @@ public class CPacketLevelMaintainer implements IMessage {
this.size = size.isEmpty() ? 0 : Long.parseLong(size);
}
public static IAEItemStack setTag(IAEItemStack ias, long batch, int slotIndex, boolean enable) {
public static IAEItemStack setTag(IAEItemStack ias, long batch, int slotIndex, boolean enable, int state) {
NBTTagCompound data = new NBTTagCompound();
ItemStack is = ias.getItemStack();
data.setLong("Batch", batch);
data.setLong("Index", slotIndex);
data.setBoolean("Enable", enable);
data.setInteger("State", state);
is.setTagCompound(data);
IAEItemStack iaeItemStack = AEItemStack.create(is);
iaeItemStack.setStackSize(ias.getStackSize());
@@ -90,9 +91,14 @@ public class CPacketLevelMaintainer implements IMessage {
if (is1 != null) {
NBTTagCompound data;
data = is1.getItemStack().getTagCompound();
piu.appendItem(setTag(is, is1.getStackSize(), i, data.getBoolean("Enable")));
piu.appendItem(setTag(
is,
is1.getStackSize(),
i,
data.getBoolean("Enable"),
cca.getTile().requests.getState(i).ordinal()));
} else {
piu.appendItem(setTag(is, 0, i, true));
piu.appendItem(setTag(is, 0, i, true, 0));
}
}
}
@@ -111,6 +111,10 @@ public class SPacketFluidUpdate implements IMessage {
} else {
((GuiFluidTerminal) gs).update(null);
}
} else if (gs instanceof GuiFluidStorageBus) {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet()) {
((GuiFluidStorageBus) gs).update(e.getKey(), e.getValue());
}
}
return null;
}
@@ -1,11 +1,18 @@
package com.glodblock.github.proxy;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.Config;
import com.glodblock.github.inventory.external.AEFluidInterfaceHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.ModAndClassUtil;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraft.item.ItemStack;
public class CommonProxy {
@@ -15,5 +22,27 @@ public class CommonProxy {
public void init(FMLInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {
if (ModAndClassUtil.isBigInterface) {
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 3);
Upgrades.PATTERN_CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 3);
}
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 5);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
if (Config.fluidIOBus) {
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2);
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
Upgrades.REDSTONE.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 1);
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4);
Upgrades.SPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4);
Upgrades.SUPERSPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 4);
Upgrades.SUPERSPEED.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 4);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
}
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
}
}
@@ -1,6 +1,9 @@
package com.glodblock.github.util;
import com.glodblock.github.FluidCraft;
import java.util.ArrayList;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.StatCollector;
public class NameConst {
@@ -22,6 +25,7 @@ public class NameConst {
public static final String ITEM_PART_FLUID_INTERFACE = "part_fluid_interface";
public static final String ITEM_PART_FLUID_IMPORT = "part_fluid_import";
public static final String ITEM_PART_FLUID_EXPORT = "part_fluid_export";
public static final String ITEM_PART_FLUID_STORAGE_BUS = "part_fluid_storage_bus";
public static final String ITEM_FLUID_PACKET = "fluid_packet";
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
public static final String ITEM_FLUID_PART = "fluid_part";
@@ -33,8 +37,27 @@ public class NameConst {
public static final String TT_ENCODE_PATTERN = TT_KEY + "encode_pattern";
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_REQUEST_SIZE = TT_KEY + "request_size";
public static final String TT_BATCH_SIZE = TT_KEY + "batch_size";
public static final String TT_SHIFT_FOR_MORE = TT_KEY + "shift_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";
public static final String TT_FLUID_BUFFER_DESC = TT_FLUID_BUFFER + "desc";
public static final String TT_FLUID_DISCRETIZER = TT_KEY + "discretizer.";
public static final String TT_FLUID_DISCRETIZER_DESC = TT_FLUID_DISCRETIZER + "desc";
public static final String TT_LEVEL_MAINTAINER = TT_KEY + "level_maintainer.";
public static final String TT_LEVEL_MAINTAINER_DESC = TT_LEVEL_MAINTAINER + "desc";
public static final String TT_LEVEL_MAINTAINER_WHO_AM_I = TT_LEVEL_MAINTAINER + "Who_Am_I";
public static final String TT_LEVEL_MAINTAINER_TITLE = TT_LEVEL_MAINTAINER + "title";
public static final String TT_LEVEL_MAINTAINER_CURRENT = TT_LEVEL_MAINTAINER + "current";
public static final String TT_LEVEL_MAINTAINER_NONE = TT_LEVEL_MAINTAINER + "none";
public static final String TT_LEVEL_MAINTAINER_REQUEST_SIZE = TT_LEVEL_MAINTAINER + "request_size";
public static final String TT_LEVEL_MAINTAINER_BATCH_SIZE = TT_LEVEL_MAINTAINER + "batch_size";
public static final String TT_LEVEL_MAINTAINER_IDLE = TT_LEVEL_MAINTAINER + "idle";
public static final String TT_LEVEL_MAINTAINER_IDLE_DESC = TT_LEVEL_MAINTAINER + "idle_desc";
public static final String TT_LEVEL_MAINTAINER_LINK = TT_LEVEL_MAINTAINER + "link";
public static final String TT_LEVEL_MAINTAINER_LINK_DESC = TT_LEVEL_MAINTAINER + "link_desc";
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 WAILA_KEY = FluidCraft.MODID + ".waila.";
@@ -56,4 +79,29 @@ public class NameConst {
public static final String GUI_OC_PATTERN_EDITOR = GUI_KEY + BLOCK_OC_PATTERN_EDITOR;
public static final String GUI_FLUID_IMPORT = GUI_KEY + ITEM_PART_FLUID_IMPORT;
public static final String GUI_FLUID_EXPORT = GUI_KEY + ITEM_PART_FLUID_EXPORT;
public static final String GUI_FLUID_STORAGE_BUS = GUI_KEY + ITEM_PART_FLUID_STORAGE_BUS;
public static String i18n(String t, String delimiter, boolean hint) {
if (!hint) {
return I18n.format(t);
}
ArrayList<String> arr = new ArrayList<>();
arr.add(I18n.format(t));
if (!StatCollector.translateToLocal(t + ".hint").equals(t + ".hint")) {
arr.add(I18n.format(t + ".hint"));
}
return String.join(delimiter, arr);
}
public static String i18n(String t) {
return i18n(t, "\n", true);
}
public static String i18n(String t, boolean warp) {
if (warp) {
return i18n(t);
} else {
return i18n(t, "", true);
}
}
}
@@ -279,6 +279,22 @@ public final class Util {
return null;
}
public static ItemStack setFluidContainerAmount(ItemStack itemStack, int amount) {
FluidStack fs = getFluidFromContainer(itemStack);
if (fs == null) return null;
fs.amount = amount;
ItemStack is = itemStack.copy();
is.stackSize = 1;
ItemStack emptyContainer = clearFluid(is);
if (emptyContainer == null) return null;
MutablePair<Integer, ItemStack> result = fillStack(emptyContainer, fs);
if (result != null) {
result.right.stackSize = itemStack.stackSize;
return result.right;
}
return null;
}
public static MutablePair<Integer, ItemStack> drainStack(ItemStack itemStack, FluidStack fluid) {
if (itemStack == null) return null;
Item item = itemStack.getItem();
@@ -6,6 +6,7 @@ item.part_fluid_pattern_terminal_ex.name=ME Fluid Processing Pattern Terminal
item.part_fluid_interface.name=ME Dual Interface
item.part_fluid_import.name=ME Fluid Import Bus
item.part_fluid_export.name=ME Fluid Export Bus
item.part_fluid_storage_bus.name=ME Fluid Storage Bus
item.fluid_packet.name=Fluid Packet
item.fluid_storage.1.name=1k ME Fluid Storage Cell
item.fluid_storage.4.name=4k ME Fluid Storage Cell
@@ -36,8 +37,26 @@ ae2fc.waila.speed=Speed
ae2fc.waila.enable=Enable
ae2fc.waila.disable=Disable
ae2fc.tooltip.request_size=Amount to Maintain
ae2fc.tooltip.batch_size=Crafting Batch Size
ae2fc.tooltip.shift_for_more=> Hold §3Shift§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
ae2fc.tooltip.level_maintainer.Who_Am_I=Who Am I?
ae2fc.tooltip.level_maintainer.title=§6Request Status§r
ae2fc.tooltip.level_maintainer.desc=Automatically keeps items and fluids in stock by requesting new crafts when needed. Has to be connected to an ME network.
ae2fc.tooltip.level_maintainer.current=Currently:
ae2fc.tooltip.level_maintainer.none=No request configured.
ae2fc.tooltip.level_maintainer.idle=§aIdling§r
ae2fc.tooltip.level_maintainer.idle_desc=The Requester is idling when the requested amount is already reached, there is no crafting pattern for this item or fluid or if there are not enough ingredients to request more crafts.
ae2fc.tooltip.level_maintainer.link=§eCrafting§r
ae2fc.tooltip.level_maintainer.link_desc=The system is currently crafting the requested item or fluid.
ae2fc.tooltip.level_maintainer.export=§5Exporting§r
ae2fc.tooltip.level_maintainer.export_desc=The Requester is trying to export the crafting results to the system. If the Requester has this status for a long time, there is no available space for the export.
ae2fc.tooltip.level_maintainer.batch_size=§6Crafting Batch Size§r
ae2fc.tooltip.level_maintainer.batch_size.hint=When craft requests are emitted, the Requester will use the batch size for the request. Using larger batches will increase the speed of stocking up items but will require more crafting storage.
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.fluid_terminal=uh So we don't need EC2 anymore?
ae2fc.tooltip.invalid_fluid=Invalid fluid!
@@ -77,7 +96,8 @@ ae2fc.gui.oc_pattern_editor=OC Pattern Editor
ae2fc.gui.button.set=Set
ae2fc.gui.part_fluid_import=ME Fluid Import Bus
ae2fc.gui.part_fluid_export=ME Fluid Export Bus
ae2fc.gui.part_fluid_terminal=Fluid Terminal
ae2fc.gui.part_fluid_terminal=ME Fluid Terminal
ae2fc.gui.part_fluid_storage_bus=ME Fluid Storage Bus
error.unknown=Unknown
@@ -29,15 +29,33 @@ tile.fluid_interface.name=ME二合一接口
tile.ingredient_buffer.name=原材料缓存仓
tile.large_ingredient_buffer.name=大型原材料缓存仓
tile.oc_pattern_editor.name=OC样板编辑器
tile.level_maintainer.name=ME缓存指令器
tile.level_maintainer.name=ME库存维持器
tile.fluid_buffer.name=ME流体缓存器
ae2fc.waila.speed=速度
ae2fc.waila.enable=启用
ae2fc.waila.disable=禁用
ae2fc.tooltip.request_size=缓存量
ae2fc.tooltip.batch_size=批量制作数量
ae2fc.tooltip.shift_for_more=> 按 §3Shift§r 显示更多信息
ae2fc.tooltip.fluid_packet_decoder.desc=流体解码器可以解码液体数据包。它必须与ME系统连接,并且网络内可以储存流体,否则它就无法工作。
ae2fc.tooltip.discretizer.desc=当ME流体离散器连接到您的ME系统时,它将把存储在的ME流体存储单元(或存储总线)中的流体表现为物品液滴。它们将是流体的等价物。它只是显示流体的另一种方式,它不会真正把你的流体转换成物品。
ae2fc.tooltip.fluid_buffer.desc=这就是一个高速的流体IO接口
ae2fc.tooltip.level_maintainer.Who_Am_I=Who Am I?
ae2fc.tooltip.level_maintainer.title=§6请求状态§r
ae2fc.tooltip.level_maintainer.desc=通过在需要时请求合成,自动保持物品和流体的库存。必须连接到ME网络。
ae2fc.tooltip.level_maintainer.current=目前:
ae2fc.tooltip.level_maintainer.none=没有配置任何请求。
ae2fc.tooltip.level_maintainer.idle=§a空闲中§r
ae2fc.tooltip.level_maintainer.idle_desc=当请求的数量已经达到时,请求器处于空闲状态,该物品没有制作模板,或者没有足够的原料来请求更多的合成。
ae2fc.tooltip.level_maintainer.link=§e合成中§r
ae2fc.tooltip.level_maintainer.link_desc=系统当前正在制作请求的物品或流体。
ae2fc.tooltip.level_maintainer.export=§5输出中§r
ae2fc.tooltip.level_maintainer.export_desc=请求器正在尝试将制作结果导出到ME系统。如果请求器长期处于此状态,则说明没有可用的存储空间。
ae2fc.tooltip.level_maintainer.batch_size=§6单次合成数量§r
ae2fc.tooltip.level_maintainer.batch_size.hint=当发出合成请求时,请求器发送单次合成数量的多少。更多的单次合成数量将提高储存物品的速度,但需要更多的合成存储空间。
ae2fc.tooltip.level_maintainer.request_size=§6缓存量§r
ae2fc.tooltip.level_maintainer.request_size.hint=数量定义了在请求器开始请求新合成之前应该保留多少物品。
ae2fc.tooltip.cell_contents=内含流体:
ae2fc.tooltip.fluid_terminal=我们不再需要EC2了吗?
ae2fc.tooltip.invalid_fluid=流体无效!
Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB