Merge pull request #1 from GlodBlock/1.7.10

Update
This commit is contained in:
StrangeMan1580 authored and GitHub committed 2022-05-31 20:40:07 +03:00
commit be9e39465e
52 files changed
+1436 -1450

No files matched your search

+2
View File
@@ -25,6 +25,8 @@ This is a rework and ported version of [ae2-fluid-crafting](https://github.com/p
- [1.12.2] Fix the fluid amount display error when removing fluid.
- [1.12.2] Upgrade cards can be inserted in Dual Interface.
- [1.12.2] Fluid pattern is searchable in interface terminal.
- [1.12.2] Fix crash when using block mode, fluid will also be considered as blockable.
- [1.12.2] Fluid export bus supports crafting card.
## Installation
+4 -49
View File
@@ -180,11 +180,6 @@ catch (Exception ignored) {
}
// Pulls version first from the VERSION env and then git tag
String identifiedVersion
String versionOverride = System.getenv("VERSION") ?: null
try {
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
}
catch (Exception ignored) {
out.style(Style.Failure).text(
'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
@@ -192,15 +187,11 @@ catch (Exception ignored) {
'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
)
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
version = minecraftVersion + '-' + identifiedVersion
String versionTag = gitVersion().split("-")[gitVersion().split("-").length - 1]
version = minecraftVersion + '-' + versionTag
ext {
modVersion = identifiedVersion
}
if(identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
modVersion = versionTag
}
group = modGroup
@@ -569,7 +560,7 @@ publishing {
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
// Using the identified version, not project.version as it has the prepended 1.7.10
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
version = System.getenv("RELEASE_VERSION") ?: versionTag
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
@@ -606,46 +597,10 @@ publishing {
// Updating
task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
print("Build script already up-to-date!")
}
}
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
out.style(Style.SuccessHeader).println("Build script update available! Run 'gradle updateBuildScript'")
}
}
static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
}
boolean performBuildScriptUpdate(String projectDir) {
if (isNewBuildScriptVersionAvailable(projectDir)) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
return true
}
return false
}
boolean isNewBuildScriptVersionAvailable(String projectDir) {
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
String currentBuildScript = getFile("build.gradle").getText()
String currentBuildScriptHash = getVersionHash(currentBuildScript)
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
String availableBuildScriptHash = getVersionHash(availableBuildScript)
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
return !isUpToDate
}
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
if(versionLine != null) {
@@ -1,11 +1,13 @@
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.inventory.InventoryHandler;
import com.glodblock.github.loader.*;
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
import com.glodblock.github.loader.ChannelLoader;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.loader.RecipeLoader;
import com.glodblock.github.proxy.CommonProxy;
import com.glodblock.github.util.ModAndClassUtil;
import cpw.mods.fml.common.Mod;
@@ -15,6 +17,7 @@ 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(modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME)
@@ -49,6 +52,23 @@ public class FluidCraft {
public static void postInit(FMLPostInitializationEvent event) {
NetworkRegistry.INSTANCE.registerGuiHandler(FluidCraft.INSTANCE, new InventoryHandler());
(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 );
}
proxy.postInit(event);
}
@@ -0,0 +1,93 @@
package com.glodblock.github.client.gui;
import appeng.client.gui.widgets.ITooltip;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class FCGuiTextField extends GuiTextField {
private static final int PADDING = 2;
private String tooltip;
private final int _xPos;
private final int _yPos;
private final int _width;
private final int _height;
/**
* Uses the values to instantiate a padded version of a text field.
* Pays attention to the '_' caret.
*
* @param fontRenderer renderer for the strings
* @param xPos absolute left position
* @param yPos absolute top position
* @param width absolute width
* @param height absolute height
*/
public FCGuiTextField(final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height) {
super(fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth('_'), height - 2 * PADDING);
this._xPos = xPos;
this._yPos = yPos;
this._width = width;
this._height = height;
}
@Override
public void mouseClicked(final int xPos, final int yPos, final int button) {
super.mouseClicked(xPos, yPos, button);
final boolean requiresFocus = this.isMouseIn(xPos, yPos);
this.setFocused(requiresFocus);
}
/**
* Checks if the mouse is within the element
*
* @param xCoord current x coord of the mouse
* @param yCoord current y coord of the mouse
* @return true if mouse position is within the text field area
*/
public boolean isMouseIn(final int xCoord, final int yCoord) {
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
return withinXRange && withinYRange;
}
public void setMessage(String t)
{
tooltip = t;
}
public class TooltipProvider implements ITooltip
{
@Override
public String getMessage() {
return tooltip;
}
@Override
public int xPos() {
return _xPos;
}
@Override
public int yPos() {
return _yPos;
}
@Override
public int getHeight() {
return _height;
}
@Override
public int getWidth() { return _width; }
@Override
public boolean isVisible() {
return getVisible();
}
}
}
@@ -12,11 +12,14 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
@@ -41,7 +44,7 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
{
super( inventoryPlayer, te, new FCBasePartContainer( inventoryPlayer, te ) );
this.container = (FCBasePartContainer) this.inventorySlots;
Ae2Reflect.setReservedSpace(this, 81);
Ae2ReflectClient.setReservedSpace(this, 81);
}
@Override
@@ -134,7 +137,7 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - Ae2Reflect.getReservedSpace(this), 4210752 );
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
}
@Override
@@ -11,9 +11,12 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
@@ -36,7 +39,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
{
super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) );
this.container = (FCBasePartContainerEx) this.inventorySlots;
Ae2Reflect.setReservedSpace(this, 81);
Ae2ReflectClient.setReservedSpace(this, 81);
}
@Override
@@ -108,7 +111,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - Ae2Reflect.getReservedSpace(this), 4210752 );
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
}
@Override
@@ -34,7 +34,7 @@ import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
@@ -66,8 +66,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
public FCBaseMonitorContain monitorableContainer;
private GuiTabButton craftingStatusBtn;
private GuiImgButton craftingStatusImgBtn;
private MEGuiTextField searchField;
private String myName;
private FCGuiTextField searchField;
private int perRow = 9;
private int reservedSpace = 0;
private boolean customSortOrder = true;
@@ -110,14 +109,6 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.viewCell = te instanceof IViewCellStorage;
if( te instanceof PartFluidPatternTerminal)
{
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL;
}
if (te instanceof PartFluidPatternTerminalEx)
{
this.myName = NameConst.GUI_FLUID_PATTERN_TERMINAL_EX;
}
}
public void postUpdate( final List<IAEItemStack> list )
@@ -282,7 +273,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) );
offset += 20;
this.searchField = new MEGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
this.searchField = new FCGuiTextField( this.fontRendererObj, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
this.searchField.setEnableBackgroundDrawing( false );
this.searchField.setMaxStringLength( 25 );
this.searchField.setTextColor( 0xFFFFFF );
@@ -387,7 +378,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if( Ae2Reflect.getDragClick(this).size() > 1 )
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
return;
}
@@ -448,7 +439,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
stack = ( (SlotME) slot ).getAEStack();
}
int slotNum = Ae2Reflect.getInventorySlots(this).size();
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if( !( slot instanceof SlotME ) && slot != null )
{
@@ -464,7 +455,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if( slot instanceof SlotDisconnected)
{
if( Ae2Reflect.getDragClick(this).size() > 1 )
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
return;
}
@@ -555,12 +546,12 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack( stack );
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2Reflect.getInventorySlots(this).size(), 0, stack));
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
}
else if( action != null )
{
( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack );
final PacketInventoryAction p = new PacketInventoryAction( action, Ae2Reflect.getInventorySlots(this).size(), 0 );
final PacketInventoryAction p = new PacketInventoryAction( action, Ae2ReflectClient.getInventorySlots(this).size(), 0 );
NetworkHandler.instance.sendToServer( p );
}
@@ -0,0 +1,32 @@
package com.glodblock.github.client.gui;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.core.localization.GuiText;
import com.glodblock.github.client.gui.container.ContainerFluidIO;
import com.glodblock.github.common.parts.PartFluidImportBus;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidIO extends GuiUpgradeable
{
private final PartSharedFluidBus bus;
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
{
super( new ContainerFluidIO( inventoryPlayer, te ) );
this.bus = te;
}
@Override
protected GuiText getName()
{
return this.bus instanceof PartFluidImportBus ? GuiText.ImportBus : GuiText.ExportBus;
}
public void update(int id, IAEFluidStack stack) {
((ContainerFluidIO)this.cvb).getBus().setFluidInSlot(id, stack);
}
}
@@ -13,6 +13,7 @@ import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
@@ -33,7 +34,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
private final ContainerFluidPatternEncoder cont;
private final MouseRegionManager mouseRegions = new MouseRegionManager(this);
private final AppEngRenderItem stackSizeRenderer = Ae2Reflect.getStackSizeRenderer(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
@@ -12,6 +12,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
@@ -19,20 +20,20 @@ import net.minecraft.inventory.Slot;
public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2Reflect.getStackSizeRenderer(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternTerminal(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
ContainerFluidPatternTerminal container = new ContainerFluidPatternTerminal(inventoryPlayer, te);
container.setGui(this);
this.inventorySlots = container;
Ae2Reflect.setGuiContainer(this, container);
Ae2ReflectClient.setGuiContainer(this, container);
}
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2Reflect.getCraftingStatusButton(this);
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
}
@Override
@@ -9,6 +9,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
@@ -26,11 +27,11 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2Reflect.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
else if (host instanceof PartFluidPatternTerminalEx)
Ae2Reflect.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
super.initGui();
originalGuiBtn = Ae2Reflect.getOriginalGuiButton(this);
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
@Override
@@ -12,6 +12,7 @@ import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
@@ -19,7 +20,7 @@ import net.minecraft.inventory.Slot;
public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
private GuiTabButton craftingStatusBtn;
private final AppEngRenderItem stackSizeRenderer = Ae2Reflect.getStackSizeRenderer(this);
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public GuiFluidPatternTerminalEx(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
@@ -34,7 +35,7 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
@Override
public void initGui() {
super.initGui();
craftingStatusBtn = Ae2Reflect.getCraftingStatusButton(this);
craftingStatusBtn = Ae2ReflectClient.getCraftingStatusButton(this);
}
@Override
@@ -10,7 +10,6 @@ import com.glodblock.github.inventory.IAEFluidTank;
import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.GlStateManager;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
@@ -62,22 +61,21 @@ public class GuiIngredientBuffer extends AEBaseGui {
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GlStateManager.color(1F, 1F, 1F, 1F);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
Tessellator tess = Tessellator.instance;
for (int i = 0; i < 4; i++) {
renderFluidIntoGui(tess, TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GlStateManager.color(1F, 1F, 1F, 1F);
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(Tessellator tess, int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
if (aeFluidStack != null) {
GL11.glDisable(2896);
GL11.glColor3f(1.0F, 1.0F, 1.0F);
@@ -0,0 +1,141 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Upgrades;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.storage.data.IAEFluidStack;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.slot.AppEngSlot;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Util;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
import java.util.Map;
public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
public ContainerFluidConfigurable(InventoryPlayer ip, IUpgradeableHost te)
{
super( ip, te );
}
public abstract AppEngInternalAEInventory getFakeFluidInv();
@Override
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx )
{
AppEngSlot clickSlot = (AppEngSlot)this.inventorySlots.get(idx);
if (clickSlot == null || !clickSlot.getHasStack()) return null;
ItemStack tis = clickSlot.getStack();
FluidStack fs = Util.getFluidFromItem(tis);
if( fs != null )
{
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final IAEFluidStack stack = AEFluidStack.create( fs );
for( int i = 0; i < inv.getSizeInventory(); ++i )
{
if( inv.getStackInSlot(i) == null && this.isValidForConfig( i, stack ) )
{
ItemStack tmp = ItemFluidPacket.newStack(fs);
if (tmp != null) {
tmp.setStackDisplayName(fs.getLocalizedName());
}
inv.setInventorySlotContents( i, tmp );
break;
}
}
}
this.standardDetectAndSendChanges();
return null;
}
protected void setupConfig()
{
this.setupUpgrades();
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" );
final int y = 40;
final int x = 80;
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 0, x, y, 0, 0, 0 ) );
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 1, x, y, -1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 2, x, y, 1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 3, x, y, 0, -1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 4, x, y, 0, 1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 5, x, y, -1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 6, x, y, 1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 7, x, y, -1, 1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, this, 8, x, y, 1, 1, 2 ) );
}
}
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
{
if( this.supportCapacity() )
{
// assumes 4 slots per upgrade
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades( Upgrades.CAPACITY );
if( slot > 0 && upgrades < 1 )
{
return false;
}
return slot <= 4 || upgrades >= 2;
}
return true;
}
@Override
protected void standardDetectAndSendChanges()
{
if( Platform.isServer() )
{
// clear out config items that are no longer valid (eg capacity upgrade removed)
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
final Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for( int i = 0; i < inv.getSizeInventory(); ++i )
{
if( inv.getStackInSlot( i ) != null && !this.isValidForConfig( i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i )))) )
{
inv.setInventorySlotContents( i, null );
}
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot( i ))));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
super.standardDetectAndSendChanges();
}
public void setFluid(int id, IAEFluidStack fluidStack) {
final AppEngInternalAEInventory inv = this.getFakeFluidInv();
if (inv != null && this.isValidForConfig(id, AEFluidStack.create(fluidStack))) {
ItemStack tmp = ItemFluidPacket.newStack(fluidStack.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluidStack.getFluidStack().getLocalizedName());
}
inv.setInventorySlotContents(id, tmp);
}
}
}
@@ -0,0 +1,25 @@
package com.glodblock.github.client.gui.container;
import appeng.tile.inventory.AppEngInternalAEInventory;
import com.glodblock.github.common.parts.PartSharedFluidBus;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidIO extends ContainerFluidConfigurable
{
private final PartSharedFluidBus bus;
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te )
{
super( ip, te );
this.bus = te;
}
public PartSharedFluidBus getBus() {
return this.bus;
}
@Override
public AppEngInternalAEInventory getFakeFluidInv() {
return (AppEngInternalAEInventory) this.bus.getInventoryByName("config");
}
}
@@ -150,6 +150,10 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
@@ -143,6 +143,10 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
}
Slot slot = getSlot(slotId);
ItemStack stack = player.inventory.getItemStack();
if (Util.getFluidFromItem(stack) == null || Util.getFluidFromItem(stack).amount <= 0) {
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
@@ -21,6 +21,7 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.util.Util;
@@ -208,6 +209,12 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
}
// encode the slot.
@@ -298,7 +305,9 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
{
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
@@ -10,6 +10,7 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.util.Util;
@@ -151,6 +152,12 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
}
}
// encode the slot.
@@ -228,7 +235,9 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
{
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
@@ -12,6 +12,7 @@ public enum FCPartsTexture {
PartFluidPatternTerminal_Bright("pattern_terminal_bright"), PartFluidPatternTerminal_Dark("pattern_terminal_dark"),
PartFluidPatternTerminal_Colored("pattern_terminal_medium"), PartTerminalBroad("terminal_broad"),
PartFluidImportBus("fluid_import_face"), PartFluidExportBus("fluid_export_face"),
BlockFluidInterfaceAlternate_Arrow("fluid_interface_arrow"), BlockInterfaceAlternate("fluid_interface_a"),
BlockInterface_Face("fluid_interface");
@@ -11,6 +11,7 @@ public class Config {
public static boolean fluidCells;
public static boolean noFluidPacket;
public static boolean fluidIOBus;
public static void run() {
loadCategory();
@@ -20,6 +21,7 @@ public class Config {
private static void loadProperty() {
fluidCells = Config.getBoolean("Enable Fluid Storage Cell", "Fluid Craft for AE2", true, "Enable this to generate the fluid storage cells. If you are playing with EC2, you can turn it off.");
noFluidPacket = Config.getBoolean("No Fluid Packet", "Fluid Craft for AE2", false, "Enable this to make normal ME Interface can emit fluid with fluid pattern, like the Fluid Interface.");
fluidIOBus = Config.getBoolean("Enable AE2FC's Fluid I/O Bus", "Fluid Craft for AE2", true, "Enable this to add Fluid Import/Export Bus like EC2's one.");
if (Config.hasChanged())
Config.save();
@@ -49,7 +49,6 @@ public class ItemBasicFluidStorageCell extends AEBaseItem implements IStorageFlu
private final int totalBytes;
private final int perType;
private final double idleDrain;
@SideOnly(Side.CLIENT)
private final static HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemBasicFluidStorageCell( final CellType whichCell, final int kilobytes )
@@ -19,7 +19,6 @@ import java.util.List;
public class ItemBasicFluidStoragePart extends Item {
public static final int types = 7;
@SideOnly(Side.CLIENT)
private final static HashMap<Integer, IIcon> icon = new HashMap<>();
public ItemBasicFluidStoragePart() {
@@ -0,0 +1,64 @@
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.Config;
import com.glodblock.github.common.parts.PartFluidExportBus;
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 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;
import javax.annotation.Nullable;
public class ItemFluidExportBus extends Item implements IPartItem {
public ItemFluidExportBus() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_EXPORT);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartFluidExportBus createPartFromItemStack(ItemStack is) {
return new PartFluidExportBus(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 ItemFluidExportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_EXPORT, FluidCraft.MODID);
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,63 @@
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.Config;
import com.glodblock.github.common.parts.PartFluidImportBus;
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 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;
import javax.annotation.Nullable;
public class ItemFluidImportBus extends Item implements IPartItem {
public ItemFluidImportBus() {
this.setMaxStackSize(64);
this.setUnlocalizedName(NameConst.ITEM_PART_FLUID_IMPORT);
AEApi.instance().partHelper().setItemBusRenderer(this);
}
@Nullable
@Override
public PartFluidImportBus createPartFromItemStack(ItemStack is) {
return new PartFluidImportBus(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 ItemFluidImportBus register() {
if (!Config.fluidIOBus) return null;
GameRegistry.registerItem(this, NameConst.ITEM_PART_FLUID_IMPORT, FluidCraft.MODID);
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,172 @@
package com.glodblock.github.common.parts;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidExportBus extends PartSharedFluidBus {
private final BaseActionSource source;
public PartFluidExportBus( ItemStack is )
{
super( is );
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
this.source = new MachineSource( this );
}
@Override
public IIcon getFaceIcon() {
return FCPartsTexture.PartFluidExportBus.getIcon();
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( 5, 40, this.isSleeping(), false );
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
{
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
}
@Override
protected boolean canDoBusWork()
{
return this.getProxy().isActive();
}
@Override
protected TickRateModulation doBusWork()
{
if( !this.canDoBusWork() )
{
return TickRateModulation.IDLE;
}
final TileEntity te = this.getConnectedTE();
if(te instanceof IFluidHandler)
{
try
{
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
IAEFluidStack fluid = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( fluid != null )
{
final IAEFluidStack toExtract = fluid.copy();
toExtract.setStackSize( this.calculateAmountToSend() );
final IAEFluidStack out = inv.extractItems( toExtract, Actionable.SIMULATE, this.source );
if( out != null )
{
int wasInserted = fh.fill( this.getSide().getOpposite(), out.getFluidStack(), true );
if( wasInserted > 0 )
{
toExtract.setStackSize( wasInserted );
inv.extractItems( toExtract, Actionable.MODULATE, this.source );
return TickRateModulation.FASTER;
}
}
}
}
return TickRateModulation.SLOWER;
}
catch( GridAccessException e )
{
// Ignore
}
}
return TickRateModulation.SLEEP;
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
bch.addBox( 4, 4, 12, 12, 12, 14 );
bch.addBox( 5, 5, 14, 11, 11, 15 );
bch.addBox( 6, 6, 15, 10, 10, 16 );
bch.addBox( 6, 6, 11, 10, 10, 12 );
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
rh.setBounds( 4, 4, 12, 12, 12, 14 );
rh.renderInventoryBox( renderer );
rh.setBounds( 5, 5, 14, 11, 11, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds( 6, 6, 15, 10, 10, 16 );
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.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartExportSides.getIcon(), CableBusTextures.PartExportSides.getIcon() );
rh.setBounds( 4, 4, 12, 12, 12, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 5, 5, 14, 11, 11, 15 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 15, 10, 10, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 6, 6, 11, 10, 10, 12 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
@Override
public RedstoneMode getRSMode()
{
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
}
@@ -0,0 +1,194 @@
package com.glodblock.github.common.parts;
import appeng.api.config.*;
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidPacket;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidHandler;
public class PartFluidImportBus extends PartSharedFluidBus {
private final BaseActionSource source;
public PartFluidImportBus( ItemStack is )
{
super( is );
this.getConfigManager().registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
this.getConfigManager().registerSetting( Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.getConfigManager().registerSetting( Settings.CRAFT_ONLY, YesNo.NO );
this.getConfigManager().registerSetting( Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
this.source = new MachineSource( this );
}
@Override
public IIcon getFaceIcon() {
return FCPartsTexture.PartFluidImportBus.getIcon();
}
@Override
public TickingRequest getTickingRequest( IGridNode node )
{
return new TickingRequest( 5, 40, this.isSleeping(), false );
}
@Override
public TickRateModulation tickingRequest(IGridNode node, int ticksSinceLastCall )
{
return this.canDoBusWork() ? this.doBusWork() : TickRateModulation.IDLE;
}
@Override
protected TickRateModulation doBusWork()
{
if( !this.canDoBusWork() )
{
return TickRateModulation.IDLE;
}
final TileEntity te = this.getConnectedTE();
if(te instanceof IFluidHandler)
{
try
{
final IFluidHandler fh = (IFluidHandler) te;
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
final FluidStack fluidStack = fh.drain( this.getSide().getOpposite(), this.calculateAmountToSend(), false );
if( this.filterEnabled() && !this.isInFilter( fluidStack ) )
{
return TickRateModulation.SLOWER;
}
final AEFluidStack aeFluidStack = AEFluidStack.create( fluidStack );
if( aeFluidStack != null )
{
final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source );
if( notInserted != null && notInserted.getStackSize() > 0 )
{
aeFluidStack.decStackSize( notInserted.getStackSize() );
}
fh.drain( this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true );
return TickRateModulation.FASTER;
}
return TickRateModulation.IDLE;
}
catch(GridAccessException e )
{
e.printStackTrace();
}
}
return TickRateModulation.SLEEP;
}
@Override
protected boolean canDoBusWork()
{
return this.getProxy().isActive();
}
private boolean isInFilter( FluidStack fluid )
{
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( stack != null && stack.getFluidStack().equals( fluid ) )
{
return true;
}
}
return false;
}
private boolean filterEnabled()
{
for( int i = 0; i < this.getInventoryByName("config").getSizeInventory(); i++ )
{
final IAEFluidStack stack = AEFluidStack.create(ItemFluidPacket.getFluidStack(this.getInventoryByName("config").getStackInSlot(i)));
if( stack != null )
{
return true;
}
}
return false;
}
@Override
public RedstoneMode getRSMode()
{
return (RedstoneMode) this.getConfigManager().getSetting( Settings.REDSTONE_CONTROLLED );
}
@Override
public void getBoxes( final IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 13 );
bch.addBox( 5, 5, 13, 11, 11, 14 );
bch.addBox( 4, 4, 14, 12, 12, 16 );
}
@Override
@SideOnly( Side.CLIENT )
public void renderInventory(final IPartRenderHelper rh, final RenderBlocks renderer )
{
rh.setTexture( CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
rh.setBounds( 3, 3, 15, 13, 13, 16 );
rh.renderInventoryBox( renderer );
rh.setBounds( 4, 4, 14, 12, 12, 15 );
rh.renderInventoryBox( renderer );
rh.setBounds( 5, 5, 13, 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.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartImportSides.getIcon(), CableBusTextures.PartImportSides.getIcon() );
rh.setBounds( 4, 4, 14, 12, 12, 16 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 5, 5, 13, 11, 11, 14 );
rh.renderBlock( x, y, z, renderer );
rh.setBounds( 6, 6, 12, 10, 10, 13 );
rh.renderBlock( x, y, z, renderer );
rh.setTexture( CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), this.getFaceIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon(), CableBusTextures.PartMonitorSidesStatus.getIcon() );
rh.setBounds( 6, 6, 11, 10, 10, 12 );
rh.renderBlock( x, y, z, renderer );
this.renderLights( x, y, z, rh, renderer );
}
}
@@ -1,6 +1,7 @@
package com.glodblock.github.common.parts;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
@@ -71,6 +72,12 @@ public class PartFluidInterface extends PartInterface implements IFluidHandler {
rh.renderInventoryBox( renderer );
}
@Override
public int getInstalledUpgrades( final Upgrades u )
{
return getInterfaceDuality().getInstalledUpgrades( u );
}
private IMEMonitor<IAEFluidStack> getFluidGrid() {
try {
return getProxy().getGrid().<IStorageGrid>getCache(IStorageGrid.class).getFluidInventory();
@@ -131,6 +131,16 @@ public class PartFluidPatternTerminal extends FCBasePart {
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
@@ -166,6 +176,16 @@ public class PartFluidPatternTerminal extends FCBasePart {
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
@@ -127,6 +127,16 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
@@ -157,6 +167,16 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
@@ -0,0 +1,188 @@
package com.glodblock.github.common.parts;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Upgrades;
import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.texture.CableBusTextures;
import appeng.me.GridAccessException;
import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.util.Platform;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.IIcon;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import java.util.Objects;
public abstract class PartSharedFluidBus extends PartUpgradeable implements IGridTickable
{
private final AppEngInternalAEInventory config = new AppEngInternalAEInventory( this, 9 );
private boolean lastRedstone;
public PartSharedFluidBus( ItemStack is )
{
super( is );
}
public abstract IIcon getFaceIcon();
@Override
public void upgradesChanged()
{
this.updateState();
}
@Override
public void onNeighborChanged()
{
this.updateState();
if( this.lastRedstone != this.getHost().hasRedstone( this.getSide() ) )
{
this.lastRedstone = !this.lastRedstone;
if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE )
{
this.doBusWork();
}
}
}
private void updateState()
{
try
{
if( !this.isSleeping() )
{
this.getProxy().getTick().wakeDevice( this.getProxy().getNode() );
}
else
{
this.getProxy().getTick().sleepDevice( this.getProxy().getNode() );
}
}
catch( final GridAccessException e )
{
// :P
}
}
@Override
public boolean onPartActivate(final EntityPlayer player, final Vec3 pos)
{
if( Platform.isServer() )
{
InventoryHandler.openGui(player, this.getHost().getTile().getWorldObj(), new BlockPos(this.getHost().getTile()), Objects.requireNonNull(Util.from(this.getSide())), GuiType.FLUID_BUS_IO);
}
return true;
}
@Override
public void getBoxes( IPartCollisionHelper bch )
{
bch.addBox( 6, 6, 11, 10, 10, 13 );
bch.addBox( 5, 5, 13, 11, 11, 14 );
bch.addBox( 4, 4, 14, 12, 12, 16 );
}
protected TileEntity getConnectedTE()
{
TileEntity self = this.getHost().getTile();
return this.getTileEntity( self, (new BlockPos(self)).getOffSet( this.getSide() ) );
}
private TileEntity getTileEntity( final TileEntity self, final BlockPos pos )
{
final World w = self.getWorldObj();
if( w.getChunkProvider().chunkExists( pos.getX() >> 4, pos.getZ() >> 4 ) )
{
return w.getTileEntity( pos.getX(), pos.getY(), pos.getZ() );
}
return null;
}
protected int calculateAmountToSend()
{
double amount = 1000D;
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
{
case 4:
amount = amount * 1.5;
case 3:
amount = amount * 2;
case 2:
amount = amount * 4;
case 1:
amount = amount * 8;
case 0:
default:
return (int) Math.floor( amount );
}
}
@Override
public void readFromNBT( NBTTagCompound extra )
{
super.readFromNBT( extra );
this.config.readFromNBT( extra, "config" );
}
@Override
public void writeToNBT( NBTTagCompound extra )
{
super.writeToNBT( extra );
this.config.writeToNBT( extra, "config" );
}
@Override
public IInventory getInventoryByName(String name) {
if (name.equals("config")) {
return this.config;
}
return super.getInventoryByName(name);
}
public void setFluidInSlot(int id, IAEFluidStack fluid) {
ItemStack tmp = ItemFluidPacket.newStack(fluid == null ? null : fluid.getFluidStack());
if (tmp != null) {
tmp.setStackDisplayName(fluid.getFluidStack().getLocalizedName());
}
this.config.setInventorySlotContents(id, tmp);
}
protected StorageChannel getChannel()
{
return StorageChannel.FLUIDS;
}
protected abstract TickRateModulation doBusWork();
protected abstract boolean canDoBusWork();
@Override
public int cableConnectionRenderTo()
{
return 5;
}
}
@@ -1,22 +1,28 @@
package com.glodblock.github.common.tile;
import appeng.api.config.Actionable;
import appeng.api.config.Upgrades;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.security.MachineSource;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.features.IStackSrc;
import appeng.me.GridAccessException;
import appeng.tile.misc.TileInterface;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.loader.ItemAndBlockHolder;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import javax.annotation.Nullable;
public class TileFluidInterface extends TileInterface implements IFluidHandler
{
@@ -38,6 +44,21 @@ public class TileFluidInterface extends TileInterface implements IFluidHandler
}
}
@Nullable
protected ItemStack getItemFromTile( final Object obj )
{
if (obj instanceof TileFluidInterface) {
return ItemAndBlockHolder.INTERFACE.stack();
}
return null;
}
@Override
public int getInstalledUpgrades( final Upgrades u )
{
return getInterfaceDuality().getInstalledUpgrades( u );
}
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IMEMonitor<IAEFluidStack> fluidGrid = getFluidGrid();
@@ -5,6 +5,8 @@ import appeng.core.AELog;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.util.Util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
@@ -105,7 +105,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
@Override
public boolean containsItems() {
if (invFluids != null) {
if (invFluids != null && invFluids.getTankInfo(side) != null) {
for (FluidTankInfo tank : invFluids.getTankInfo(side)) {
FluidStack fluid = tank.fluid;
if (fluid != null && fluid.amount > 0) {
@@ -6,6 +6,7 @@ import appeng.container.implementations.ContainerCraftingStatus;
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.PartSharedFluidBus;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.common.tile.TileFluidPatternEncoder;
import com.glodblock.github.common.tile.TileIngredientBuffer;
@@ -17,6 +18,18 @@ import java.util.List;
public enum GuiType {
FLUID_BUS_IO(new PartGuiFactory<PartSharedFluidBus>(PartSharedFluidBus.class) {
@Override
protected Object createServerGui(EntityPlayer player, PartSharedFluidBus inv) {
return new ContainerFluidIO(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, PartSharedFluidBus inv) {
return new GuiFluidIO(player.inventory, inv);
}
}),
INGREDIENT_BUFFER(new TileGuiFactory<TileIngredientBuffer>(TileIngredientBuffer.class) {
@Override
protected Object createServerGui(EntityPlayer player, TileIngredientBuffer inv) {
@@ -1,6 +1,7 @@
package com.glodblock.github.inventory.gui;
import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.Ae2ReflectClient;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.util.ResourceLocation;
@@ -22,8 +23,8 @@ public class MouseRegionManager {
}
public boolean onClick(int mX, int mY, int button) {
mX -= Ae2Reflect.getGuiLeft(gui);
mY -= Ae2Reflect.getGuiTop(gui);
mX -= Ae2ReflectClient.getGuiLeft(gui);
mY -= Ae2ReflectClient.getGuiTop(gui);
for (Region region : regions) {
if (region.containsMouse(mX, mY) && region.handler.onClick(button)) {
gui.mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1F));
@@ -34,8 +35,8 @@ public class MouseRegionManager {
}
public void render(int mX, int mY) {
mX -= Ae2Reflect.getGuiLeft(gui);
mY -= Ae2Reflect.getGuiTop(gui);
mX -= Ae2ReflectClient.getGuiLeft(gui);
mY -= Ae2ReflectClient.getGuiTop(gui);
for (Region region : regions) {
if (region.containsMouse(mX, mY)) {
List<String> tooltip = region.handler.getTooltip();
@@ -0,0 +1,31 @@
package com.glodblock.github.inventory.slot;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.OptionalSlotFakeTypeOnly;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.util.Util;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
public class OptionalFluidSlotFakeTypeOnly extends OptionalSlotFakeTypeOnly {
public OptionalFluidSlotFakeTypeOnly(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
}
@Override
public void putStack( ItemStack is )
{
FluidStack fluidStack = Util.getFluidFromItem(is);
if (fluidStack != null) {
ItemStack tmp = ItemFluidPacket.newStack(fluidStack);
tmp.setStackDisplayName(fluidStack.getLocalizedName());
super.putStack(tmp);
}
else {
super.putStack(null);
}
}
}
@@ -6,6 +6,7 @@ import cpw.mods.fml.relauncher.Side;
public class ChannelLoader implements Runnable {
@Override
@SuppressWarnings("all")
public void run() {
int id = 0;
FluidCraft.proxy.netHandler.registerMessage(new CPacketSwitchGuis.Handler(), CPacketSwitchGuis.class, id ++, Side.SERVER);
@@ -19,5 +20,6 @@ public class ChannelLoader implements Runnable {
FluidCraft.proxy.netHandler.registerMessage(new CPacketTransferRecipe.Handler(), CPacketTransferRecipe.class, id ++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new CPacketDumpTank.Handler(), CPacketDumpTank.class, id ++, Side.SERVER);
FluidCraft.proxy.netHandler.registerMessage(new SPacketFluidUpdate.Handler(), SPacketFluidUpdate.class, id ++, Side.CLIENT);
FluidCraft.proxy.netHandler.registerMessage(new CPacketFluidUpdate.Handler(), CPacketFluidUpdate.class, id ++, Side.SERVER);
}
}
@@ -12,6 +12,8 @@ public class ItemAndBlockHolder {
public static ItemPartFluidPatternTerminal FLUID_TERMINAL = new ItemPartFluidPatternTerminal().register();
public static ItemPartFluidPatternTerminalEx FLUID_TERMINAL_EX = new ItemPartFluidPatternTerminalEx().register();
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 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();
@@ -31,6 +31,7 @@ public class RecipeLoader implements Runnable {
public final static ItemStack AE2_CELL_1K = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 35);
public final static ItemStack AE2_CORE_ANN = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 44);
public final static ItemStack AE2_CORE_FOM = new ItemStack(GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"), 1, 43);
public final static ItemStack PISTON = new ItemStack(Blocks.piston, 1);
@Override
public void run() {
@@ -67,5 +68,10 @@ public class RecipeLoader implements Runnable {
}
}
if (Config.fluidIOBus) {
GameRegistry.addRecipe(new ShapedOreRecipe(FLUID_EXPORT_BUS, "ICI", "BPB", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_FOM));
GameRegistry.addRecipe(new ShapedOreRecipe(FLUID_IMPORT_BUS, "BCB", "IPI", 'B', "dyeBlue", 'I', "ingotIron", 'P', PISTON, 'C', AE2_CORE_ANN));
}
}
}
@@ -0,0 +1,80 @@
package com.glodblock.github.network;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.gui.container.ContainerFluidConfigurable;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.Container;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class CPacketFluidUpdate implements IMessage {
private Map<Integer, IAEFluidStack> list;
public CPacketFluidUpdate() {
}
public CPacketFluidUpdate(Map<Integer, IAEFluidStack> data) {
this.list = data;
}
@Override
public void fromBytes(ByteBuf buf) {
int size = buf.readInt();
this.list = new HashMap<>();
try {
for (int i = 0; i < size; i ++) {
int id = buf.readInt();
boolean isNull = buf.readBoolean();
if (!isNull)
list.put(id, null);
else {
IAEFluidStack fluid = AEFluidStack.loadFluidStackFromPacket(buf);
list.put(id, fluid);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(list.size());
try {
for (Map.Entry<Integer, IAEFluidStack> fs : list.entrySet()) {
buf.writeInt(fs.getKey());
if (fs.getValue() == null)
buf.writeBoolean(false);
else {
buf.writeBoolean(true);
fs.getValue().writeToPacket(buf);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static class Handler implements IMessageHandler<CPacketFluidUpdate, IMessage> {
@Override
public IMessage onMessage(CPacketFluidUpdate message, MessageContext ctx) {
final Container c = ctx.getServerHandler().playerEntity.openContainer;
if( c instanceof ContainerFluidConfigurable)
{
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (ContainerFluidConfigurable) c ).setFluid(e.getKey(), e.getValue());
}
}
return null;
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.network;
import appeng.api.storage.data.IAEFluidStack;
import appeng.util.item.AEFluidStack;
import com.glodblock.github.client.gui.GuiFluidIO;
import com.glodblock.github.client.gui.GuiIngredientBuffer;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
@@ -73,6 +74,11 @@ public class SPacketFluidUpdate implements IMessage {
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (GuiIngredientBuffer) gs ).update(e.getKey(), e.getValue());
}
} else if( gs instanceof GuiFluidIO)
{
for (Map.Entry<Integer, IAEFluidStack> e : message.list.entrySet() ) {
( (GuiFluidIO) gs ).update(e.getKey(), e.getValue());
}
}
return null;
}
@@ -1,11 +1,13 @@
package com.glodblock.github.util;
import appeng.api.implementations.IUpgradeableHost;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.storage.IMEInventory;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.CraftingCPURecord;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEPassThrough;
@@ -29,17 +31,27 @@ import java.util.Set;
public class Ae2Reflect {
private static final Field fInventory_container;
private static final Field fInventory_containerUpgrade;
private static final Field fInventory_width;
private static final Field fAEPass_internal;
private static final Field fAEInv_partitionList;
private static final Field fCPU_cpu;
private static final Field fCPU_myName;
private static final Field fCPU_processors;
private static final Field fCPU_size;
private static final Method mItemSlot_setExtractable;
static {
try {
fInventory_container = reflectField(InventoryCrafting.class, "eventHandler", "field_70465_c", "c");
fInventory_containerUpgrade = reflectField(ContainerUpgradeable.class, "upgradeable");
fInventory_width = reflectField(InventoryCrafting.class, "inventoryWidth", "field_70464_b", "b");
fAEPass_internal = reflectField(MEPassThrough.class, "internal");
fAEInv_partitionList = reflectField(MEInventoryHandler.class, "myPartitionList");
fCPU_cpu = Ae2Reflect.reflectField(CraftingCPURecord.class, "cpu");
fCPU_myName = Ae2Reflect.reflectField(CraftingCPURecord.class, "myName");
fCPU_processors = Ae2Reflect.reflectField(CraftingCPURecord.class, "processors");
fCPU_size = Ae2Reflect.reflectField(CraftingCPURecord.class, "size");
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
@@ -108,65 +120,6 @@ public class Ae2Reflect {
}
}
private static final Field fAEBaseGui_stackSizeRenderer;
private static final Field fGuiCraftingStatus_originalGuiBtn;
private static final Field fGuiPatternTerm_container;
private static final Field fGuiCPUStatus_icon;
private static final Field fGuiMEMonitorable_monitorableContainer;
private static final Field fGuiMEMonitorable_configSrc;
private static final Field fGuiMEMonitorable_craftingStatusBtn;
private static final Field fGuiContainer_guiLeft;
private static final Field fGuiContainer_guiTop;
private static final Field fCPU_cpu;
private static final Field fCPU_myName;
private static final Field fCPU_processors;
private static final Field fCPU_size;
private static final Field fGui_drag;
private static final Method mGuiPatternTerm_inventorySlots;
private static final Method mGuiPatternTerm_reservedSpace;
private static final Method mGuiPatternTerm_reservedSpaceSetter;
static {
try {
fAEBaseGui_stackSizeRenderer = Ae2Reflect.reflectField(AEBaseGui.class, "aeRenderItem");
fGuiCraftingStatus_originalGuiBtn = Ae2Reflect.reflectField(GuiCraftingStatus.class, "originalGuiBtn");
fGuiPatternTerm_container = Ae2Reflect.reflectField(GuiBaseFluidPatternTerminal.class, "container");
fGuiMEMonitorable_monitorableContainer = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "monitorableContainer");
fGuiMEMonitorable_configSrc = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "configSrc");
fGuiMEMonitorable_craftingStatusBtn = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "craftingStatusBtn");
fGuiCPUStatus_icon = Ae2Reflect.reflectField(GuiCraftingStatus.class, "myIcon");
fGuiContainer_guiLeft = Ae2Reflect.reflectField(GuiContainer.class, "guiLeft", "field_147003_i", "i");
fGuiContainer_guiTop = Ae2Reflect.reflectField(GuiContainer.class, "guiTop", "field_147009_r", "r");
fCPU_cpu = Ae2Reflect.reflectField(CraftingCPURecord.class, "cpu");
fCPU_myName = Ae2Reflect.reflectField(CraftingCPURecord.class, "myName");
fCPU_processors = Ae2Reflect.reflectField(CraftingCPURecord.class, "processors");
fCPU_size = Ae2Reflect.reflectField(CraftingCPURecord.class, "size");
fGui_drag = Ae2Reflect.reflectField(AEBaseGui.class, "drag_click");
mGuiPatternTerm_inventorySlots = Ae2Reflect.reflectMethod(AEBaseGui.class, "getInventorySlots");
mGuiPatternTerm_reservedSpace = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "getReservedSpace");
mGuiPatternTerm_reservedSpaceSetter = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "setReservedSpace", int.class);
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
}
}
@SuppressWarnings("unchecked")
public static List<Slot> getInventorySlots(AEBaseGui gui) {
try {
return (List<Slot>) mGuiPatternTerm_inventorySlots.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_inventorySlots, e);
}
}
public static void rewriteIcon(GuiCraftingStatus gui, ItemStack icon) {
Ae2Reflect.writeField(gui, fGuiCPUStatus_icon, icon);
}
public static Set<Slot> getDragClick(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fGui_drag);
}
public static ICraftingCPU getCPU(CraftingCPURecord cpu) {
return Ae2Reflect.readField(cpu, fCPU_cpu);
}
@@ -183,46 +136,8 @@ public class Ae2Reflect {
return Ae2Reflect.readField(cpu, fCPU_size);
}
public static int getGuiLeft(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiLeft);
}
public static int getGuiTop(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiTop);
}
public static void setReservedSpace(GuiFCBaseMonitor gui, int size) {
try {
mGuiPatternTerm_reservedSpaceSetter.invoke(gui, size);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpaceSetter, e);
}
}
public static int getReservedSpace(GuiFCBaseMonitor gui) {
try {
return (int) mGuiPatternTerm_reservedSpace.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpace, e);
}
}
public static AppEngRenderItem getStackSizeRenderer(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fAEBaseGui_stackSizeRenderer);
}
public static GuiTabButton getOriginalGuiButton(GuiCraftingStatus gui) {
return Ae2Reflect.readField(gui, fGuiCraftingStatus_originalGuiBtn);
}
public static void setGuiContainer(GuiBaseFluidPatternTerminal instance, ContainerFluidPatternTerminal container) {
Ae2Reflect.writeField(instance, fGuiPatternTerm_container, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_monitorableContainer, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_configSrc, container.getConfigManager());
}
public static GuiTabButton getCraftingStatusButton(GuiFCBaseMonitor gui) {
return Ae2Reflect.readField(gui, fGuiMEMonitorable_craftingStatusBtn);
public static IUpgradeableHost getUpgradeList(ContainerUpgradeable container) {
return Ae2Reflect.readField(container, fInventory_containerUpgrade);
}
}
@@ -0,0 +1,118 @@
package com.glodblock.github.util;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.render.AppEngRenderItem;
import com.glodblock.github.client.gui.GuiBaseFluidPatternTerminal;
import com.glodblock.github.client.gui.GuiFCBaseMonitor;
import com.glodblock.github.client.gui.container.ContainerFluidPatternTerminal;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Set;
@SideOnly(Side.CLIENT)
public class Ae2ReflectClient {
private static final Field fAEBaseGui_stackSizeRenderer;
private static final Field fGuiCraftingStatus_originalGuiBtn;
private static final Field fGuiPatternTerm_container;
private static final Field fGuiCPUStatus_icon;
private static final Field fGuiMEMonitorable_monitorableContainer;
private static final Field fGuiMEMonitorable_configSrc;
private static final Field fGuiMEMonitorable_craftingStatusBtn;
private static final Field fGuiContainer_guiLeft;
private static final Field fGuiContainer_guiTop;
private static final Field fGui_drag;
private static final Method mGuiPatternTerm_inventorySlots;
private static final Method mGuiPatternTerm_reservedSpace;
private static final Method mGuiPatternTerm_reservedSpaceSetter;
static {
try {
fAEBaseGui_stackSizeRenderer = Ae2Reflect.reflectField(AEBaseGui.class, "aeRenderItem");
fGuiCraftingStatus_originalGuiBtn = Ae2Reflect.reflectField(GuiCraftingStatus.class, "originalGuiBtn");
fGuiPatternTerm_container = Ae2Reflect.reflectField(GuiBaseFluidPatternTerminal.class, "container");
fGuiMEMonitorable_monitorableContainer = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "monitorableContainer");
fGuiMEMonitorable_configSrc = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "configSrc");
fGuiMEMonitorable_craftingStatusBtn = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "craftingStatusBtn");
fGuiCPUStatus_icon = Ae2Reflect.reflectField(GuiCraftingStatus.class, "myIcon");
fGuiContainer_guiLeft = Ae2Reflect.reflectField(GuiContainer.class, "guiLeft", "field_147003_i", "i");
fGuiContainer_guiTop = Ae2Reflect.reflectField(GuiContainer.class, "guiTop", "field_147009_r", "r");
fGui_drag = Ae2Reflect.reflectField(AEBaseGui.class, "drag_click");
mGuiPatternTerm_inventorySlots = Ae2Reflect.reflectMethod(AEBaseGui.class, "getInventorySlots");
mGuiPatternTerm_reservedSpace = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "getReservedSpace");
mGuiPatternTerm_reservedSpaceSetter = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "setReservedSpace", int.class);
} catch (NoSuchFieldException | NoSuchMethodException e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
}
}
@SuppressWarnings("unchecked")
public static List<Slot> getInventorySlots(AEBaseGui gui) {
try {
return (List<Slot>) mGuiPatternTerm_inventorySlots.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_inventorySlots, e);
}
}
public static void rewriteIcon(GuiCraftingStatus gui, ItemStack icon) {
Ae2Reflect.writeField(gui, fGuiCPUStatus_icon, icon);
}
public static Set<Slot> getDragClick(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fGui_drag);
}
public static int getGuiLeft(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiLeft);
}
public static int getGuiTop(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiTop);
}
public static void setReservedSpace(GuiFCBaseMonitor gui, int size) {
try {
mGuiPatternTerm_reservedSpaceSetter.invoke(gui, size);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpaceSetter, e);
}
}
public static int getReservedSpace(GuiFCBaseMonitor gui) {
try {
return (int) mGuiPatternTerm_reservedSpace.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpace, e);
}
}
public static AppEngRenderItem getStackSizeRenderer(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fAEBaseGui_stackSizeRenderer);
}
public static GuiTabButton getOriginalGuiButton(GuiCraftingStatus gui) {
return Ae2Reflect.readField(gui, fGuiCraftingStatus_originalGuiBtn);
}
public static void setGuiContainer(GuiBaseFluidPatternTerminal instance, ContainerFluidPatternTerminal container) {
Ae2Reflect.writeField(instance, fGuiPatternTerm_container, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_monitorableContainer, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_configSrc, container.getConfigManager());
}
public static GuiTabButton getCraftingStatusButton(GuiFCBaseMonitor gui) {
return Ae2Reflect.readField(gui, fGuiMEMonitorable_craftingStatusBtn);
}
}
@@ -1,6 +1,7 @@
package com.glodblock.github.util;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nonnull;
@@ -22,6 +23,10 @@ public class BlockPos {
this.z = te.zCoord;
}
public BlockPos getOffSet(ForgeDirection face) {
return new BlockPos(this.x + face.offsetX, this.y + face.offsetY, this.z + face.offsetZ);
}
public int getX() {
return x;
}
@@ -186,8 +186,8 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
NBTTagCompound tag = Objects.requireNonNull(patternStack.getTagCompound());
// may be possible to enter a partially-correct state if setInputs succeeds but setOutputs failed
// but outside code should treat it as completely incorrect and not attempt to make calls
return setInputs(readStackArray(tag.getTagList("Inputs", Constants.NBT.TAG_COMPOUND), 9))
&& setOutputs(readStackArray(tag.getTagList("Outputs", Constants.NBT.TAG_COMPOUND), 3));
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND), 16))
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND), 4));
}
public static IAEItemStack[] readStackArray(NBTTagList listTag, int maxCount) {
File diff suppressed because it is too large. Load diff
@@ -2,6 +2,7 @@ package com.glodblock.github.util;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.core.AEConfig;
import appeng.core.localization.ButtonToolTips;
import appeng.core.localization.GuiText;
@@ -23,10 +24,19 @@ public final class ModAndClassUtil {
public static boolean isCraftStatus;
public static boolean isSearchBar;
public static boolean isShiftTooltip;
public static boolean isBigInterface;
@SuppressWarnings("all")
public static void init() {
try {
Field d = Upgrades.class.getDeclaredField("PATTERN_CAPACITY");
if (d == null) isBigInterface = false;
isBigInterface = true;
} catch (NoSuchFieldException e) {
isBigInterface = false;
}
try {
Field d = GuiText.class.getDeclaredField("HoldShiftForTooltip");
if (d == null) isShiftTooltip = false;
@@ -15,6 +15,8 @@ public class NameConst {
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL = "part_fluid_pattern_terminal";
public static final String ITEM_PART_FLUID_PATTERN_TERMINAL_EX = "part_fluid_pattern_terminal_ex";
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_FLUID_PACKET = "fluid_packet";
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
public static final String ITEM_FLUID_PART = "fluid_part";
@@ -3,6 +3,8 @@ item.fluid_encoded_pattern.name=Encode Pattern
item.part_fluid_pattern_terminal.name=ME Fluid Pattern Terminal
item.part_fluid_pattern_terminal_ex.name=ME Fluid Processing Pattern Terminal
item.part_fluid_interface.name=Fluid Interface
item.part_fluid_import.name=ME Fluid Import Bus
item.part_fluid_export.name=ME Fluid Export 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
Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B