Merge branch 'master' into fixs

This commit is contained in:
Yang Xizhi authored and GitHub committed 2022-12-06 00:39:24 +08:00
commit 31d5e89144
194 files changed
+5678 -5310

No files matched your search

@@ -9,13 +9,10 @@ import net.minecraftforge.common.MinecraftForge;
public class ClientHelper {
@SubscribeEvent
public void updateTextureSheet( final TextureStitchEvent.Pre ev )
{
if( ev.map.getTextureType() == 0 )
{
for( final FCPartsTexture cb : FCPartsTexture.values() )
{
cb.registerIcon( ev.map );
public void updateTextureSheet(final TextureStitchEvent.Pre ev) {
if (ev.map.getTextureType() == 0) {
for (final FCPartsTexture cb : FCPartsTexture.values()) {
cb.registerIcon(ev.map);
}
}
}
@@ -25,5 +22,4 @@ public class ClientHelper {
MinecraftForge.EVENT_BUS.register(handler);
FMLCommonHandler.instance().bus().register(handler);
}
}
@@ -26,8 +26,14 @@ public class FCGuiTextField extends GuiTextField {
* @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);
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;
@@ -41,12 +47,11 @@ public class FCGuiTextField extends GuiTextField {
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(),
this.getColor()
);
this._xPos - this.getBorder(),
this._yPos - this.getBorder(),
this._width - 2 * PADDING - this._fontRender.getCharWidth('_') + this.getBorder(),
this._height - 2 * PADDING + this.getBorder(),
this.getColor());
}
}
@@ -100,13 +105,11 @@ public class FCGuiTextField extends GuiTextField {
return withinXRange && withinYRange;
}
public void setMessage(String t)
{
public void setMessage(String t) {
tooltip = t;
}
public class TooltipProvider implements ITooltip
{
public class TooltipProvider implements ITooltip {
@Override
public String getMessage() {
return tooltip;
@@ -128,7 +131,9 @@ public class FCGuiTextField extends GuiTextField {
}
@Override
public int getWidth() { return _width; }
public int getWidth() {
return _width;
}
@Override
public boolean isVisible() {
@@ -50,132 +50,136 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if( this.tabCraftButton == btn || this.tabProcessButton == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) );
}
else if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0) ));
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0"));
if (this.tabCraftButton == btn || this.tabProcessButton == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.CraftMode",
this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING));
} else if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Combine", this.combineDisableBtn == btn ? "1" : "0"));
} else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminal.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1"));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "1"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminal.beSubstitute", "0"));
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ), GuiText.CraftingPattern.getLocal(), itemRender );
this.buttonList.add( this.tabCraftButton );
this.tabCraftButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.crafting_table),
GuiText.CraftingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabCraftButton);
this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ), GuiText.ProcessingPattern.getLocal(), itemRender );
this.buttonList.add( this.tabProcessButton );
this.tabProcessButton = new GuiTabButton(
this.guiLeft + 173,
this.guiTop + this.ySize - 177,
new ItemStack(Blocks.furnace),
GuiText.ProcessingPattern.getLocal(),
itemRender);
this.buttonList.add(this.tabProcessButton);
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.clearBtn = new GuiImgButton(
this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.encodeBtn = new GuiImgButton(
this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
int combineLeft = 74;
int combineTop = 153;
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE);
this.doubleBtn = new GuiImgButton(
this.guiLeft + 74, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE);
this.doubleBtn.setHalfSize(true);
this.buttonList.add(this.doubleBtn);
combineLeft = 84;
}
// if (ModAndClassUtil.isBeSubstitutionsButton) {
// combineLeft = 74;
// combineTop -= 11;
// this.beSubstitutionsEnabledBtn = new GuiImgButton(
// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.ENABLED);
// this.beSubstitutionsEnabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsEnabledBtn);
//
// this.beSubstitutionsDisabledBtn = new GuiImgButton(
// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS, PatternBeSubstitution.DISABLED);
// this.beSubstitutionsDisabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsDisabledBtn);
// }
this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE");
// if (ModAndClassUtil.isBeSubstitutionsButton) {
// combineLeft = 74;
// combineTop -= 11;
// this.beSubstitutionsEnabledBtn = new GuiImgButton(
// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS,
// PatternBeSubstitution.ENABLED);
// this.beSubstitutionsEnabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsEnabledBtn);
//
// this.beSubstitutionsDisabledBtn = new GuiImgButton(
// this.guiLeft + 84, this.guiTop + this.ySize - 153, Settings.ACTIONS,
// PatternBeSubstitution.DISABLED);
// this.beSubstitutionsDisabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsDisabledBtn);
// }
this.combineEnableBtn = new GuiFCImgButton(
this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "FORCE_COMBINE", "DO_COMBINE");
this.combineEnableBtn.setHalfSize(true);
this.buttonList.add(this.combineEnableBtn);
this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "NOT_COMBINE", "DONT_COMBINE");
this.combineDisableBtn = new GuiFCImgButton(
this.guiLeft + combineLeft, this.guiTop + this.ySize - combineTop, "NOT_COMBINE", "DONT_COMBINE");
this.combineDisableBtn.setHalfSize(true);
this.buttonList.add(this.combineDisableBtn);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( !this.container.isCraftingMode() )
{
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (!this.container.isCraftingMode()) {
this.tabCraftButton.visible = false;
this.tabProcessButton.visible = true;
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = true;
}
else
{
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true;
} else {
this.tabCraftButton.visible = true;
this.tabProcessButton.visible = false;
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = false;
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = false;
}
if( this.container.substitute )
{
if (this.container.substitute) {
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
}
else
{
} else {
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if (!this.container.isCraftingMode())
{
if ( this.container.combine )
{
if (!this.container.isCraftingMode()) {
if (this.container.combine) {
this.combineEnableBtn.visible = true;
this.combineDisableBtn.visible = false;
}
else {
} else {
this.combineEnableBtn.visible = false;
this.combineDisableBtn.visible = true;
}
@@ -194,30 +198,27 @@ public class GuiBaseFluidPatternTerminal extends GuiFCBaseMonitor {
}
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL),
8,
this.ySize - 96 + 2 - getReservedSpace(),
4210752);
}
@Override
protected String getBackground()
{
if( this.container.isCraftingMode() )
{
protected String getBackground() {
if (this.container.isCraftingMode()) {
return "gui/pattern.png";
}
return "gui/pattern2.png";
}
@Override
protected void repositionSlot( final AppEngSlot s )
{
if( s.isPlayerSide() )
{
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
else
{
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
}
@@ -53,126 +53,128 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Encode",(isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)) );
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE ) );
}
else if( this.invertBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Invert", container.inverted ? "0" : "1" ) );
}
else if( this.combineDisableBtn == btn || this.combineEnableBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0"));
if (this.encodeBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Encode", (isCtrlKeyDown() ? 1 : 0) << 1 | (isShiftKeyDown() ? 1 : 0)));
} else if (this.clearBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.Clear", "1"));
} else if (this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Substitute",
this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE));
} else if (this.fluidPrioritizedEnabledBtn == btn || this.fluidPrioritizedDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Prioritize", container.prioritize ? PRIORITY_DISABLE : PRIORITY_ENABLE));
} else if (this.invertBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminalEx.Invert", container.inverted ? "0" : "1"));
} else if (this.combineDisableBtn == btn || this.combineEnableBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Combine", this.combineDisableBtn == btn ? "1" : "0"));
} else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.Double", Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) ? "1" : "0"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsDisabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "1"));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "1"));
} else if (ModAndClassUtil.isBeSubstitutionsButton && beSubstitutionsEnabledBtn == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "0"));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("PatternTerminalEx.beSubstitute", "0"));
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED );
this.substitutionsEnabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsEnabledBtn );
this.substitutionsEnabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED);
this.substitutionsEnabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsEnabledBtn);
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED );
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED);
this.substitutionsDisabledBtn.setHalfSize(true);
this.buttonList.add(this.substitutionsDisabledBtn);
this.fluidPrioritizedEnabledBtn = new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "FORCE_PRIO", "DO_PRIO");
this.fluidPrioritizedEnabledBtn =
new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "FORCE_PRIO", "DO_PRIO");
this.fluidPrioritizedEnabledBtn.setHalfSize(true);
this.buttonList.add( this.fluidPrioritizedEnabledBtn );
this.buttonList.add(this.fluidPrioritizedEnabledBtn);
this.fluidPrioritizedDisabledBtn = new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "NOT_PRIO", "DONT_PRIO");
this.fluidPrioritizedDisabledBtn =
new GuiFCImgButton(this.guiLeft + 97, this.guiTop + this.ySize - 114, "NOT_PRIO", "DONT_PRIO");
this.fluidPrioritizedDisabledBtn.setHalfSize(true);
this.buttonList.add( this.fluidPrioritizedDisabledBtn );
this.buttonList.add(this.fluidPrioritizedDisabledBtn);
invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize( true );
this.buttonList.add( this.invertBtn );
invertBtn = new GuiImgButton(
this.guiLeft + 87,
this.guiTop + this.ySize - 153,
Settings.ACTIONS,
container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize(true);
this.buttonList.add(this.invertBtn);
this.clearBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
this.clearBtn = new GuiImgButton(
this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE);
this.clearBtn.setHalfSize(true);
this.buttonList.add(this.clearBtn);
this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE );
this.buttonList.add( this.encodeBtn );
this.encodeBtn = new GuiImgButton(
this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE);
this.buttonList.add(this.encodeBtn);
if (ModAndClassUtil.isDoubleButton) {
this.doubleBtn = new GuiImgButton( this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE );
this.doubleBtn.setHalfSize( true );
this.doubleBtn = new GuiImgButton(
this.guiLeft + 97, this.guiTop + this.ySize - 153, Settings.ACTIONS, ActionItems.DOUBLE);
this.doubleBtn.setHalfSize(true);
this.buttonList.add(this.doubleBtn);
}
this.combineEnableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "FORCE_COMBINE", "DO_COMBINE");
this.combineEnableBtn =
new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "FORCE_COMBINE", "DO_COMBINE");
this.combineEnableBtn.setHalfSize(true);
this.buttonList.add(this.combineEnableBtn);
this.combineDisableBtn = new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE");
this.combineDisableBtn =
new GuiFCImgButton(this.guiLeft + 87, this.guiTop + this.ySize - 114, "NOT_COMBINE", "DONT_COMBINE");
this.combineDisableBtn.setHalfSize(true);
this.buttonList.add(this.combineDisableBtn);
// if (ModAndClassUtil.isBeSubstitutionsButton) {
// this.beSubstitutionsEnabledBtn = new GuiImgButton(
// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.ENABLED);
// this.beSubstitutionsEnabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsEnabledBtn);
//
// this.beSubstitutionsDisabledBtn = new GuiImgButton(
// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS, PatternBeSubstitution.DISABLED);
// this.beSubstitutionsDisabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsDisabledBtn);
// }
// if (ModAndClassUtil.isBeSubstitutionsButton) {
// this.beSubstitutionsEnabledBtn = new GuiImgButton(
// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS,
// PatternBeSubstitution.ENABLED);
// this.beSubstitutionsEnabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsEnabledBtn);
//
// this.beSubstitutionsDisabledBtn = new GuiImgButton(
// this.guiLeft + 87, this.guiTop + this.ySize - 103, Settings.ACTIONS,
// PatternBeSubstitution.DISABLED);
// this.beSubstitutionsDisabledBtn.setHalfSize(true);
// this.buttonList.add(this.beSubstitutionsDisabledBtn);
// }
processingScrollBar.setTop(this.ySize - 164);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if (ModAndClassUtil.isDoubleButton)
this.doubleBtn.visible = true;
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (ModAndClassUtil.isDoubleButton) this.doubleBtn.visible = true;
if( this.container.substitute )
{
if (this.container.substitute) {
this.substitutionsEnabledBtn.visible = true;
this.substitutionsDisabledBtn.visible = false;
}
else
{
} else {
this.substitutionsEnabledBtn.visible = false;
this.substitutionsDisabledBtn.visible = true;
}
if( this.container.prioritize )
{
if (this.container.prioritize) {
this.fluidPrioritizedEnabledBtn.visible = false;
this.fluidPrioritizedDisabledBtn.visible = true;
}
else
{
} else {
this.fluidPrioritizedEnabledBtn.visible = true;
this.fluidPrioritizedDisabledBtn.visible = false;
}
@@ -195,32 +197,30 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
super.drawFG(offsetX, offsetY, mouseX, mouseY);
this.fontRendererObj.drawString(StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - getReservedSpace(), 4210752);
this.fontRendererObj.drawString(
StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX),
8,
this.ySize - 96 + 2 - getReservedSpace(),
4210752);
this.processingScrollBar.draw(this);
}
@Override
protected String getBackground()
{
protected String getBackground() {
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
protected void repositionSlot( final AppEngSlot s )
{
if( s.isPlayerSide() )
{
protected void repositionSlot(final AppEngSlot s) {
if (s.isPlayerSide()) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
else
{
} else {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 3;
}
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
if (container.substitute) {
substitutionsEnabledBtn.visible = true;
@@ -237,14 +237,14 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
fluidPrioritizedDisabledBtn.visible = true;
}
final int offset = container.inverted? 18 * -3: 0;
final int offset = container.inverted ? 18 * -3 : 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedEnabledBtn.xPosition = this.guiLeft + 97 + offset;
fluidPrioritizedDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
combineEnableBtn.xPosition = this.guiLeft + 87 + offset;
combineDisableBtn.xPosition = this.guiLeft + 87 + offset;
@@ -255,8 +255,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
@@ -267,10 +266,9 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
@Override
protected void mouseClickMove( final int x, final int y, final int c, final long d )
{
protected void mouseClickMove(final int x, final int y, final int c, final long d) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop );
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop);
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
@@ -279,8 +277,7 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
@Override
public void handleMouseInput()
{
public void handleMouseInput() {
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
@@ -296,15 +293,12 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage()
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
private void changeActivePage() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns(
"PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -9,7 +9,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor {
protected EntityPlayer player;
@@ -51,5 +50,4 @@ public class GuiBaseFluidTerminal extends GuiFCBaseFluidMonitor {
super.actionPerformed(btn);
}
}
}
@@ -2,6 +2,7 @@ package com.glodblock.github.client.gui;
import appeng.api.config.InsertionMode;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.api.config.YesNo;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
@@ -13,6 +14,7 @@ import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.helpers.IInterfaceHost;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerDualInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
@@ -32,61 +34,79 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiImgButton BlockMode;
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
super(new ContainerInterface(inventoryPlayer, te));
super(new ContainerDualInterface(inventoryPlayer, te));
this.host = te;
this.ySize = 211;
}
@Override
@SuppressWarnings("unchecked")
protected void addButtons()
{
this.priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
this.buttonList.add( this.priority );
protected void addButtons() {
this.priority =
new GuiTabButton(this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender);
this.buttonList.add(this.priority);
this.switcher = new GuiTabButton( this.guiLeft + 132, this.guiTop, host instanceof PartFluidInterface ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.switcher = new GuiTabButton(
this.guiLeft + 132,
this.guiTop,
host instanceof PartFluidInterface
? ItemAndBlockHolder.FLUID_INTERFACE.stack()
: ItemAndBlockHolder.INTERFACE.stack(),
StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"),
itemRender);
this.buttonList.add(this.switcher);
this.BlockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.buttonList.add( this.BlockMode );
this.BlockMode = new GuiImgButton(this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO);
this.buttonList.add(this.BlockMode);
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(), GuiText.InterfaceTerminalHint.getLocal() );
this.buttonList.add( this.interfaceMode );
this.interfaceMode = new GuiToggleButton(
this.guiLeft - 18,
this.guiTop + 26,
84,
85,
GuiText.InterfaceTerminal.getLocal(),
GuiText.InterfaceTerminalHint.getLocal());
this.buttonList.add(this.interfaceMode);
this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT );
this.buttonList.add( this.insertionMode );
this.insertionMode =
new GuiImgButton(this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT);
this.buttonList.add(this.insertionMode);
if (isTile()) {
this.sidelessMode = new GuiImgButton(
this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
this.buttonList.add(this.sidelessMode);
}
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
if( this.BlockMode != null )
{
this.BlockMode.set( ( (ContainerInterface) this.cvb ).getBlockingMode() );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
if (this.BlockMode != null) {
this.BlockMode.set(((ContainerInterface) this.cvb).getBlockingMode());
}
if( this.interfaceMode != null )
{
this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).getInterfaceTerminalMode() == YesNo.YES );
if (this.interfaceMode != null) {
this.interfaceMode.setState(((ContainerInterface) this.cvb).getInterfaceTerminalMode() == YesNo.YES);
}
if( this.insertionMode != null )
{
this.insertionMode.set( ( (ContainerInterface) this.cvb ).getInsertionMode());
if (this.insertionMode != null) {
this.insertionMode.set(((ContainerInterface) this.cvb).getInsertionMode());
}
if (this.sidelessMode != null) {
this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode());
}
this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 );
this.fontRendererObj.drawString(
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752);
}
@Override
protected String getBackground()
{
if (!ModAndClassUtil.isBigInterface)
return "guis/interface.png";
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled())
{
protected String getBackground() {
if (!ModAndClassUtil.isBigInterface) return "guis/interface.png";
switch (((ContainerInterface) this.cvb).getPatternCapacityCardsInstalled()) {
case 1:
return "guis/interface2.png";
case 2:
@@ -98,44 +118,47 @@ public class GuiDualInterface extends GuiUpgradeable {
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.priority )
{
if (host instanceof TileFluidInterface) {
if (btn == this.priority) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
}
else if(host instanceof PartFluidInterface) {
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
}
}
if( btn == this.switcher )
{
if (host instanceof TileFluidInterface) {
if (btn == this.switcher) {
if (isTile()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
}
else if (host instanceof PartFluidInterface) {
} else if (isPart()) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
}
}
if( btn == this.interfaceMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
if (btn == this.interfaceMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
}
if( btn == this.BlockMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) );
if (btn == this.BlockMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.BlockMode.getSetting(), backwards));
}
if( btn == this.insertionMode )
{
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) );
if (btn == this.insertionMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.insertionMode.getSetting(), backwards));
}
if (btn == this.sidelessMode && this.sidelessMode != null) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
}
}
private boolean isPart() {
return this.host instanceof PartFluidInterface;
}
private boolean isTile() {
return this.host instanceof TileFluidInterface;
}
}
@@ -40,6 +40,9 @@ import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import com.glodblock.github.util.Util;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
@@ -51,11 +54,8 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public class GuiFCBaseFluidMonitor extends AEBaseMEGui
implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
public static int craftingGridOffsetY;
@@ -84,7 +84,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseFluidMonitor(final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) {
public GuiFCBaseFluidMonitor(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseFluidMonitorContain c) {
super(c);
@@ -101,7 +102,6 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
(this.monitorableContainer = (FCBaseFluidMonitorContain) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate(final List<IAEFluidStack> list) {
@@ -117,7 +117,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar().setRange(0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
this.getScrollBar()
.setRange(
0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
}
@Override
@@ -133,7 +135,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
final GuiImgButton iBtn = (GuiImgButton) btn;
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
final Enum<?> next =
Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
@@ -143,7 +146,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
} else {
try {
NetworkHandler.instance.sendToServer(new PacketValueConfig(iBtn.getSetting().name(), next.name()));
NetworkHandler.instance.sendToServer(
new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
@@ -169,7 +173,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL ? 9 : 9 + ((this.width - this.standardSize) / 18);
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL
? 9
: 9 + ((this.width - this.standardSize) / 18);
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
@@ -196,7 +202,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
this.getMeSlots().clear();
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots().add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
this.getMeSlots()
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
@@ -219,28 +226,52 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
int offset = this.guiTop + 8;
if (this.customSortOrder) {
this.buttonList.add(this.SortByBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
this.buttonList.add(
this.SortByBox = new GuiImgButton(
this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
}
// this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
// offset += 20;
// this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE,
// this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
// offset += 20;
this.buttonList.add(this.SortDirBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting(Settings.SORT_DIRECTION)));
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.buttonList.add(this.searchBoxSettings = new GuiImgButton(this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add(this.searchStringSave = new GuiImgButton(this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
}
this.buttonList.add(this.terminalStyleBox = new GuiImgButton(this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting(Settings.TERMINAL_STYLE)));
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 FCGuiTextField(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);
@@ -249,10 +280,25 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if (this.viewCell) {
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
if (ModAndClassUtil.isCraftStatus
&& AEConfig.instance
.getConfigManager()
.getSetting(Settings.CRAFTING_STATUS)
.equals(CraftingStatus.BUTTON)) {
this.buttonList.add(
this.craftingStatusImgBtn = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.CRAFTING_STATUS,
AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
} else {
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + 170,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
}
}
@@ -303,7 +349,8 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
@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_TERMINAL)), 8, 6, 4210752);
this.fontRendererObj.drawString(
this.getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_TERMINAL)), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@@ -340,11 +387,11 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
direction = TextHistory.Direction.NEXT;
}
history.get(direction, this.searchField.getText())
.map(newText -> {
setSearchString(newText, true);
return true;
})
.orElse(false);
.map(newText -> {
setSearchString(newText, true);
return true;
})
.orElse(false);
return;
} catch (NoSuchFieldException | IllegalAccessException e) {
}
@@ -364,14 +411,16 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if (slot instanceof SlotFake) {
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
InventoryAction action =
ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
@@ -449,20 +498,19 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
switch (mouseButton) {
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
@@ -475,7 +523,10 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
}
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(action, slot.getSlotIndex(), ((SlotDisconnected) slot).getSlot().getId());
final PacketInventoryAction p = new PacketInventoryAction(
action,
slot.getSlotIndex(),
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
@@ -491,7 +542,10 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ((SlotME) slot).getAEStack();
if (stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null) {
if (stack != null
&& action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
@@ -502,7 +556,6 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
break;
case 3: // creative dupe:
stack = ((SlotME) slot).getAEStack();
if (stack.getItem() instanceof ItemFluidDrop) {
stack = ItemFluidDrop.newAeStack(ItemFluidDrop.getAeFluidStack(stack));
@@ -524,10 +577,12 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
if (action == InventoryAction.AUTO_CRAFT) {
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.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, Ae2ReflectClient.getInventorySlots(this).size(), 0);
final PacketInventoryAction p = new PacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0);
NetworkHandler.instance.sendToServer(p);
}
@@ -564,15 +619,23 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect(offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset);
this.drawTexturedModalRect(
offsetX,
offsetY + 16 + this.rows * 18 + this.lowerTextureOffset,
0,
106 - 18 - 18,
x_width,
99 + this.reservedSpace - this.lowerTextureOffset);
if (this.viewCell) {
boolean update = false;
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot(i).getStack()) {
if (this.myCurrentViewCells[i]
!= this.monitorableContainer.getCellViewSlot(i).getStack()) {
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot(i).getStack();
this.myCurrentViewCells[i] =
this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
@@ -596,7 +659,9 @@ public class GuiFCBaseFluidMonitor extends AEBaseMEGui implements ISortSource, I
}
int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? 6
: Integer.MAX_VALUE;
}
protected void repositionSlot(final AppEngSlot s) {
@@ -36,6 +36,9 @@ import com.glodblock.github.client.gui.container.FCBaseMonitorContain;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
@@ -46,10 +49,6 @@ import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.List;
public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfigManagerHost, IDropToFillTextField {
public static int craftingGridOffsetX;
@@ -79,113 +78,98 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
public GuiFCBaseMonitor( final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c )
{
public GuiFCBaseMonitor(
final InventoryPlayer inventoryPlayer, final ITerminalHost te, final FCBaseMonitorContain c) {
super( c );
super(c);
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
this.setScrollBar(scrollbar);
this.repo = new ItemRepo(scrollbar, this);
this.xSize = 195;
this.ySize = 204;
this.standardSize = this.xSize;
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
( this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots ).setGui( this );
this.configSrc = ((IConfigurableObject) this.inventorySlots).getConfigManager();
(this.monitorableContainer = (FCBaseMonitorContain) this.inventorySlots).setGui(this);
this.viewCell = te instanceof IViewCellStorage;
}
public void postUpdate( final List<IAEItemStack> list )
{
for( final IAEItemStack is : list )
{
this.repo.postUpdate( is );
public void postUpdate(final List<IAEItemStack> list) {
for (final IAEItemStack is : list) {
this.repo.postUpdate(is);
}
this.repo.updateView();
this.setScrollBar();
}
private void setScrollBar()
{
this.getScrollBar().setTop( 18 ).setLeft( 175 ).setHeight( this.rows * 18 - 2 );
this.getScrollBar().setRange( 0, ( this.repo.size() + this.perRow - 1 ) / this.perRow - this.rows, Math.max( 1, this.rows / 6 ) );
private void setScrollBar() {
this.getScrollBar().setTop(18).setLeft(175).setHeight(this.rows * 18 - 2);
this.getScrollBar()
.setRange(
0, (this.repo.size() + this.perRow - 1) / this.perRow - this.rows, Math.max(1, this.rows / 6));
}
@Override
protected void actionPerformed( final GuiButton btn )
{
protected void actionPerformed(final GuiButton btn) {
if( btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
if (btn == this.craftingStatusBtn || btn == this.craftingStatusImgBtn) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_CRAFTING_STATUS));
}
if( btn instanceof GuiImgButton )
{
final boolean backwards = Mouse.isButtonDown( 1 );
if (btn instanceof GuiImgButton) {
final boolean backwards = Mouse.isButtonDown(1);
final GuiImgButton iBtn = (GuiImgButton) btn;
if( iBtn.getSetting() != Settings.ACTIONS )
{
if (iBtn.getSetting() != Settings.ACTIONS) {
final Enum<?> cv = iBtn.getCurrentValue();
final Enum<?> next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
final Enum<?> next =
Platform.rotateEnum(cv, backwards, iBtn.getSetting().getPossibleValues());
if( btn == this.terminalStyleBox )
{
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
}
else if( btn == this.searchBoxSettings )
{
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
}
else if( ModAndClassUtil.isSaveText && btn == this.searchStringSave )
{
if (btn == this.terminalStyleBox) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (btn == this.searchBoxSettings) {
AEConfig.instance.settings.putSetting(iBtn.getSetting(), next);
} else if (ModAndClassUtil.isSaveText && btn == this.searchStringSave) {
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
}
else
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
}
catch( final IOException e )
{
AELog.debug( e );
} else {
try {
NetworkHandler.instance.sendToServer(
new PacketValueConfig(iBtn.getSetting().name(), next.name()));
} catch (final IOException e) {
AELog.debug(e);
}
}
iBtn.set( next );
iBtn.set(next);
if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
{
if (next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class) {
this.reinitalize();
}
}
}
}
private void reinitalize()
{
private void reinitalize() {
this.buttonList.clear();
this.initGui();
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
Keyboard.enableRepeatEvents( true );
public void initGui() {
Keyboard.enableRepeatEvents(true);
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
this.perRow = AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL
? 9
: 9 + ((this.width - this.standardSize) / 18);
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.NEI );
final boolean hasNEI = IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI);
final int NEI = hasNEI ? 0 : 0;
int top = hasNEI ? 22 : 0;
@@ -193,38 +177,31 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - NEI - top - this.reservedSpace;
this.rows = (int) Math.floor( extraSpace / 18.0 );
if( this.rows > this.maxRows )
{
top += ( this.rows - this.maxRows ) * 18 / 2;
this.rows = (int) Math.floor(extraSpace / 18.0);
if (this.rows > this.maxRows) {
top += (this.rows - this.maxRows) * 18 / 2;
this.rows = this.maxRows;
}
if( hasNEI )
{
if (hasNEI) {
this.rows--;
}
if( this.rows < 3 )
{
if (this.rows < 3) {
this.rows = 3;
}
this.getMeSlots().clear();
for( int y = 0; y < this.rows; y++ )
{
for( int x = 0; x < this.perRow; x++ )
{
this.getMeSlots().add( new InternalSlotME( this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18 ) );
for (int y = 0; y < this.rows; y++) {
for (int x = 0; x < this.perRow; x++) {
this.getMeSlots()
.add(new InternalSlotME(this.repo, x + y * this.perRow, this.offsetX + x * 18, 18 + y * 18));
}
}
if( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
{
this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 );
}
else
{
if (AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) != TerminalStyle.FULL) {
this.xSize = this.standardSize + ((this.perRow - 9) * 18);
} else {
this.xSize = this.standardSize;
}
@@ -236,61 +213,97 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.ySize = magicNumber + this.rows * 18 + this.reservedSpace;
// this.guiTop = top;
final int unusedSpace = this.height - this.ySize;
this.guiTop = (int) Math.floor( unusedSpace / ( unusedSpace < 0 ? 3.8f : 2.0f ) );
this.guiTop = (int) Math.floor(unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f));
int offset = this.guiTop + 8;
if( this.customSortOrder )
{
this.buttonList.add( this.SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ) ) );
if (this.customSortOrder) {
this.buttonList.add(
this.SortByBox = new GuiImgButton(
this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting(Settings.SORT_BY)));
offset += 20;
}
this.buttonList.add( this.ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ) ) );
this.buttonList.add(
this.ViewBox = new GuiImgButton(
this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting(Settings.VIEW_MODE)));
offset += 20;
this.buttonList.add( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
this.buttonList.add(
this.SortDirBox = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SORT_DIRECTION,
this.configSrc.getSetting(Settings.SORT_DIRECTION)));
offset += 20;
this.buttonList.add( this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ) ) );
this.buttonList.add(
this.searchBoxSettings = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SEARCH_MODE,
AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
if (ModAndClassUtil.isSaveText) {
this.buttonList.add( this.searchStringSave = new GuiImgButton( this.guiLeft - 18, offset, Settings.SAVE_SEARCH, AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO ) );
this.buttonList.add(
this.searchStringSave = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.SAVE_SEARCH,
AEConfig.instance.preserveSearchBar ? YesNo.YES : YesNo.NO));
offset += 20;
}
this.buttonList.add( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings.getSetting( Settings.TERMINAL_STYLE ) ) );
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 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 );
this.searchField.setVisible( true );
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);
this.searchField.setVisible(true);
if (ModAndClassUtil.isSearchStringTooltip)
searchField.setMessage(ButtonToolTips.SearchStringTooltip.getLocal());
if( this.viewCell)
{
if (ModAndClassUtil.isCraftStatus && AEConfig.instance.getConfigManager().getSetting(Settings.CRAFTING_STATUS).equals(CraftingStatus.BUTTON)) {
this.buttonList.add(this.craftingStatusImgBtn = new GuiImgButton(this.guiLeft - 18, offset, Settings.CRAFTING_STATUS, AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
if (this.viewCell) {
if (ModAndClassUtil.isCraftStatus
&& AEConfig.instance
.getConfigManager()
.getSetting(Settings.CRAFTING_STATUS)
.equals(CraftingStatus.BUTTON)) {
this.buttonList.add(
this.craftingStatusImgBtn = new GuiImgButton(
this.guiLeft - 18,
offset,
Settings.CRAFTING_STATUS,
AEConfig.instance.settings.getSetting(Settings.CRAFTING_STATUS)));
} else {
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
this.craftingStatusBtn.setHideEdge( 13 ); // GuiTabButton implementation //
this.buttonList.add(
this.craftingStatusBtn = new GuiTabButton(
this.guiLeft + 170,
this.guiTop - 4,
2 + 11 * 16,
GuiText.CraftingStatus.getLocal(),
itemRender));
this.craftingStatusBtn.setHideEdge(13); // GuiTabButton implementation //
}
}
// Enum setting = AEConfig.INSTANCE.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
final Enum<?> setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
this.searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
final Enum<?> setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui()))
{
if (ModAndClassUtil.isSearchBar && (AEConfig.instance.preserveSearchBar || this.isSubGui())) {
setSearchString(memoryText, false);
}
if( this.isSubGui() )
{
if (this.isSubGui()) {
this.repo.updateView();
this.setScrollBar();
}
@@ -298,23 +311,18 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
craftingGridOffsetX = Integer.MAX_VALUE;
craftingGridOffsetY = Integer.MAX_VALUE;
for( final Object s : this.inventorySlots.inventorySlots )
{
if( s instanceof AppEngSlot)
{
if( ( (Slot) s ).xDisplayPosition < 195 )
{
this.repositionSlot( (AppEngSlot) s );
for (final Object s : this.inventorySlots.inventorySlots) {
if (s instanceof AppEngSlot) {
if (((Slot) s).xDisplayPosition < 195) {
this.repositionSlot((AppEngSlot) s);
}
}
if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix)
{
if (s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix) {
final Slot g = (Slot) s;
if( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
{
craftingGridOffsetX = Math.min( craftingGridOffsetX, g.xDisplayPosition );
craftingGridOffsetY = Math.min( craftingGridOffsetY, g.yDisplayPosition );
if (g.xDisplayPosition > 0 && g.yDisplayPosition > 0) {
craftingGridOffsetX = Math.min(craftingGridOffsetX, g.xDisplayPosition);
craftingGridOffsetY = Math.min(craftingGridOffsetY, g.yDisplayPosition);
}
}
}
@@ -323,26 +331,23 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
craftingGridOffsetY -= 6;
}
public void setSearchString(String memoryText, boolean updateView)
{
public void setSearchString(String memoryText, boolean updateView) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
if (updateView)
{
if (updateView) {
this.repo.updateView();
this.setScrollBar();
}
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Terminal.getLocal() ), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.Terminal.getLocal()), 8, 6, 4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn ) {
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final Enum<?> searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack is = player.inventory.getItemStack();
@@ -376,11 +381,11 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
direction = TextHistory.Direction.NEXT;
}
history.get(direction, this.searchField.getText())
.map(newText -> {
setSearchString(newText, true);
return true;
})
.orElse(false);
.map(newText -> {
setSearchString(newText, true);
return true;
})
.orElse(false);
return;
} catch (NoSuchFieldException | IllegalAccessException e) {
}
@@ -395,7 +400,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
if (mouseButton == 3) {
if (this instanceof GuiBaseFluidPatternTerminal
&& ((GuiBaseFluidPatternTerminal) this).container.isCraftingMode()) {
&& ((GuiBaseFluidPatternTerminal) this).container.isCraftingMode()) {
return;
}
if (slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix) {
@@ -404,128 +409,107 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
IAEItemStack stack = AEItemStack.create(slot.getStack());
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(
action, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
return;
}
}
}
if( slot instanceof SlotFake)
{
InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (slot instanceof SlotFake) {
InventoryAction action =
ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
if (action == InventoryAction.SPLIT_OR_PLACE_SINGLE) {
action = InventoryAction.MOVE_REGION;
}
else {
} else {
action = InventoryAction.PICKUP_SINGLE;
}
}
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if( slot instanceof SlotPatternTerm)
{
if( mouseButton == 6 )
{
if (slot instanceof SlotPatternTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
try
{
NetworkHandler.instance.sendToServer( ( (SlotPatternTerm) slot ).getRequest( isShiftKeyDown() ) );
try {
NetworkHandler.instance.sendToServer(((SlotPatternTerm) slot).getRequest(isShiftKeyDown()));
} catch (final IOException e) {
AELog.debug(e);
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else if( slot instanceof SlotCraftingTerm )
{
if( mouseButton == 6 )
{
} else if (slot instanceof SlotCraftingTerm) {
if (mouseButton == 6) {
return; // prevent weird double clicks..
}
InventoryAction action;
if( isShiftKeyDown() )
{
if (isShiftKeyDown()) {
action = InventoryAction.CRAFT_SHIFT;
}
else
{
} else {
// Craft stack on right-click, craft single on left-click
action = ( mouseButton == 1 ) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
action = (mouseButton == 1) ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
}
final PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
NetworkHandler.instance.sendToServer( p );
final PacketInventoryAction p = new PacketInventoryAction(action, slotIdx, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
if( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
{
if( this.enableSpaceClicking() && !( slot instanceof SlotPatternTerm ) )
{
if (Keyboard.isKeyDown(Keyboard.KEY_SPACE)) {
if (this.enableSpaceClicking() && !(slot instanceof SlotPatternTerm)) {
IAEItemStack stack = null;
if( slot instanceof SlotME )
{
stack = ( (SlotME) slot ).getAEStack();
if (slot instanceof SlotME) {
stack = ((SlotME) slot).getAEStack();
}
int slotNum = Ae2ReflectClient.getInventorySlots(this).size();
if( !( slot instanceof SlotME ) && slot != null )
{
if (!(slot instanceof SlotME) && slot != null) {
slotNum = slot.slotNumber;
}
( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack );
final PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
NetworkHandler.instance.sendToServer( p );
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, slotNum, 0);
NetworkHandler.instance.sendToServer(p);
return;
}
}
if( slot instanceof SlotDisconnected)
{
if( Ae2ReflectClient.getDragClick(this).size() > 1 )
{
if (slot instanceof SlotDisconnected) {
if (Ae2ReflectClient.getDragClick(this).size() > 1) {
return;
}
InventoryAction action = null;
switch( mouseButton )
{
switch (mouseButton) {
case 0: // pickup / set-down.
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
{
ItemStack heldStack = player.inventory.getItemStack();
if (slot.getStack() == null && heldStack != null)
action = InventoryAction.SPLIT_OR_PLACE_SINGLE;
else if (slot.getStack() != null && (heldStack == null || heldStack.stackSize <= 1))
action = InventoryAction.PICKUP_OR_SET_DOWN;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
break;
case 3: // creative dupe:
if( player.capabilities.isCreativeMode )
{
if (player.capabilities.isCreativeMode) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
@@ -536,49 +520,46 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
case 6:
}
if( action != null )
{
final PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ( (SlotDisconnected) slot ).getSlot().getId() );
NetworkHandler.instance.sendToServer( p );
if (action != null) {
final PacketInventoryAction p = new PacketInventoryAction(
action,
slot.getSlotIndex(),
((SlotDisconnected) slot).getSlot().getId());
NetworkHandler.instance.sendToServer(p);
}
return;
}
if( slot instanceof SlotME )
{
if (slot instanceof SlotME) {
InventoryAction action = null;
IAEItemStack stack = null;
switch( mouseButton )
{
switch (mouseButton) {
case 0: // pickup / set-down.
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN;
stack = ( (SlotME) slot ).getAEStack();
stack = ((SlotME) slot).getAEStack();
if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
{
if (stack != null
&& action == InventoryAction.PICKUP_OR_SET_DOWN
&& stack.getStackSize() == 0
&& player.inventory.getItemStack() == null) {
action = InventoryAction.AUTO_CRAFT;
}
break;
case 1:
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
stack = ( (SlotME) slot ).getAEStack();
stack = ((SlotME) slot).getAEStack();
break;
case 3: // creative dupe:
stack = ( (SlotME) slot ).getAEStack();
if( stack != null && stack.isCraftable() )
{
stack = ((SlotME) slot).getAEStack();
if (stack != null && stack.isCraftable()) {
action = InventoryAction.AUTO_CRAFT;
}
else if( player.capabilities.isCreativeMode )
{
final IAEItemStack slotItem = ( (SlotME) slot ).getAEStack();
if( slotItem != null )
{
} else if (player.capabilities.isCreativeMode) {
final IAEItemStack slotItem = ((SlotME) slot).getAEStack();
if (slotItem != null) {
action = InventoryAction.CREATIVE_DUPLICATE;
}
}
@@ -590,214 +571,189 @@ 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, Ae2ReflectClient.getInventorySlots(this).size(), 0, stack));
}
else if( action != null )
{
( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack );
final PacketInventoryAction p = new PacketInventoryAction( action, Ae2ReflectClient.getInventorySlots(this).size(), 0 );
NetworkHandler.instance.sendToServer( p );
((AEBaseContainer) this.inventorySlots).setTargetStack(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, Ae2ReflectClient.getInventorySlots(this).size(), 0);
NetworkHandler.instance.sendToServer(p);
}
return;
}
super.handleMouseClick( slot, slotIdx, ctrlDown, mouseButton );
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
}
@Override
public void onGuiClosed()
{
public void onGuiClosed() {
super.onGuiClosed();
Keyboard.enableRepeatEvents( false );
Keyboard.enableRepeatEvents(false);
memoryText = this.searchField.getText();
}
public void bindTextureBack( final String file )
{
final ResourceLocation loc = new ResourceLocation( FluidCraft.MODID, "textures/" + file );
this.mc.getTextureManager().bindTexture( loc );
public void bindTextureBack(final String file) {
final ResourceLocation loc = new ResourceLocation(FluidCraft.MODID, "textures/" + file);
this.mc.getTextureManager().bindTexture(loc);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTextureBack( this.getBackground() );
this.bindTextureBack(this.getBackground());
final int x_width = 195;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, x_width, 18);
if( this.viewCell )
{
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
if (this.viewCell) {
this.drawTexturedModalRect(offsetX + x_width, offsetY, x_width, 0, 46, 128);
}
for( int x = 0; x < this.rows; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
for (int x = 0; x < this.rows; x++) {
this.drawTexturedModalRect(offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18);
}
this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset );
this.drawTexturedModalRect(
offsetX,
offsetY + 16 + this.rows * 18 + this.lowerTextureOffset,
0,
106 - 18 - 18,
x_width,
99 + this.reservedSpace - this.lowerTextureOffset);
if( this.viewCell )
{
if (this.viewCell) {
boolean update = false;
for( int i = 0; i < 5; i++ )
{
if( this.myCurrentViewCells[i] != this.monitorableContainer.getCellViewSlot( i ).getStack() )
{
for (int i = 0; i < 5; i++) {
if (this.myCurrentViewCells[i]
!= this.monitorableContainer.getCellViewSlot(i).getStack()) {
update = true;
this.myCurrentViewCells[i] = this.monitorableContainer.getCellViewSlot( i ).getStack();
this.myCurrentViewCells[i] =
this.monitorableContainer.getCellViewSlot(i).getStack();
}
}
if( update )
{
this.repo.setViewCell( this.myCurrentViewCells );
if (update) {
this.repo.setViewCell(this.myCurrentViewCells);
}
}
if( this.searchField != null )
{
if (this.searchField != null) {
this.searchField.drawTextBox();
}
}
protected String getBackground()
{
protected String getBackground() {
return "gui/terminal.png";
}
@Override
protected boolean isPowered()
{
protected boolean isPowered() {
return this.repo.hasPower();
}
int getMaxRows()
{
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
int getMaxRows() {
return AEConfig.instance.getConfigManager().getSetting(Settings.TERMINAL_STYLE) == TerminalStyle.SMALL
? 6
: Integer.MAX_VALUE;
}
protected void repositionSlot( final AppEngSlot s )
{
protected void repositionSlot(final AppEngSlot s) {
s.yDisplayPosition = s.getY() + this.ySize - 78 - 5;
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( character == ' ' && this.searchField.getText().isEmpty() )
{
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if( this.searchField.textboxKeyTyped( character, key ) )
{
this.repo.setSearchString( this.searchField.getText() );
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
}
else
{
super.keyTyped( character, key );
} else {
super.keyTyped(character, key);
}
}
}
@Override
public void updateScreen()
{
this.repo.setPower( this.monitorableContainer.isPowered() );
public void updateScreen() {
this.repo.setPower(this.monitorableContainer.isPowered());
super.updateScreen();
}
@Override
public Enum<?> getSortBy()
{
return this.configSrc.getSetting( Settings.SORT_BY );
public Enum<?> getSortBy() {
return this.configSrc.getSetting(Settings.SORT_BY);
}
@Override
public Enum<?> getSortDir()
{
return this.configSrc.getSetting( Settings.SORT_DIRECTION );
public Enum<?> getSortDir() {
return this.configSrc.getSetting(Settings.SORT_DIRECTION);
}
@Override
public Enum<?> getSortDisplay()
{
return this.configSrc.getSetting( Settings.VIEW_MODE );
public Enum<?> getSortDisplay() {
return this.configSrc.getSetting(Settings.VIEW_MODE);
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
if( this.SortByBox != null )
{
this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.SortByBox != null) {
this.SortByBox.set(this.configSrc.getSetting(Settings.SORT_BY));
}
if( this.SortDirBox != null )
{
this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) );
if (this.SortDirBox != null) {
this.SortDirBox.set(this.configSrc.getSetting(Settings.SORT_DIRECTION));
}
if( this.ViewBox != null )
{
this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) );
if (this.ViewBox != null) {
this.ViewBox.set(this.configSrc.getSetting(Settings.VIEW_MODE));
}
this.repo.updateView();
}
public int getReservedSpace()
{
public int getReservedSpace() {
return this.reservedSpace;
}
public void setReservedSpace( final int reservedSpace )
{
public void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public boolean isCustomSortOrder()
{
public boolean isCustomSortOrder() {
return this.customSortOrder;
}
public void setCustomSortOrder( final boolean customSortOrder )
{
public void setCustomSortOrder(final boolean customSortOrder) {
this.customSortOrder = customSortOrder;
}
public int getStandardSize()
{
public int getStandardSize() {
return this.standardSize;
}
public void setStandardSize( final int standardSize )
{
public void setStandardSize(final int standardSize) {
this.standardSize = standardSize;
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn ) {
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
super.drawScreen(mouseX, mouseY, btn);
if (ModAndClassUtil.isSearchBar && AEConfig.instance.preserveSearchBar && searchField != null)
handleTooltip(mouseX, mouseY, searchField.new TooltipProvider());
}
public boolean isOverSearchField(int x, int y)
{
return searchField.isMouseIn(x,y);
public boolean isOverSearchField(int x, int y) {
return searchField.isMouseIn(x, y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th)
{
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th) {
if (this.viewCell) {
int rw = 33;
@@ -3,19 +3,18 @@ package com.glodblock.github.client.gui;
import appeng.client.gui.widgets.ITooltip;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.util.NameConst;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public class GuiFCImgButton extends GuiButton implements ITooltip {
private static final Pattern COMPILE = Pattern.compile( "%s" );
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
private static final Pattern COMPILE = Pattern.compile("%s");
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
private static Map<EnumPair, ButtonAppearance> appearances;
private final String buttonSetting;
private boolean halfSize = false;
@@ -23,7 +22,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
private String currentValue;
private static final String prefix = NameConst.TT_KEY;
public GuiFCImgButton( final int x, final int y, final String idx, final String val ) {
public GuiFCImgButton(final int x, final int y, final String idx, final String val) {
super(0, 0, 16, "");
this.buttonSetting = idx;
@@ -33,7 +32,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
this.width = 16;
this.height = 16;
if( appearances == null ) {
if (appearances == null) {
appearances = new HashMap<>();
this.registerApp(0, "NOT_COMBINE", "DONT_COMBINE", "not_combine");
this.registerApp(1, "FORCE_COMBINE", "DO_COMBINE", "combine");
@@ -45,7 +44,7 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
}
}
private void registerApp(final int iconIndex, final String setting, final String val, final String title ) {
private void registerApp(final int iconIndex, final String setting, final String val, final String title) {
final ButtonAppearance a = new ButtonAppearance();
a.displayName = StatCollector.translateToLocal(prefix + title);
if (StatCollector.translateToLocal(prefix + title + ".hint").equals(prefix + title + ".hint")) {
@@ -57,19 +56,15 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
appearances.put(new EnumPair(setting, val), a);
}
public void setVisibility( final boolean vis )
{
public void setVisibility(final boolean vis) {
this.visible = vis;
this.enabled = vis;
}
private int getIconIndex()
{
if( this.buttonSetting != null && this.currentValue != null )
{
final ButtonAppearance app = appearances.get(new EnumPair( this.buttonSetting, this.currentValue ));
if( app == null )
{
private int getIconIndex() {
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance app = appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (app == null) {
return 8;
}
return app.index;
@@ -77,92 +72,77 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
return 8;
}
public String getSetting()
{
public String getSetting() {
return this.buttonSetting;
}
public String getCurrentValue()
{
public String getCurrentValue() {
return this.currentValue;
}
public void set( final String e )
{
if(!this.currentValue.equals(e))
{
public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
}
}
public boolean isHalfSize()
{
public boolean isHalfSize() {
return this.halfSize;
}
public void setHalfSize( final boolean halfSize )
{
public void setHalfSize(final boolean halfSize) {
this.halfSize = halfSize;
}
public String getFillVar()
{
public String getFillVar() {
return this.fillVar;
}
public void setFillVar( final String fillVar )
{
public void setFillVar(final String fillVar) {
this.fillVar = fillVar;
}
@Override
public int xPos()
{
public int xPos() {
return this.xPosition;
}
@Override
public int yPos()
{
public int yPos() {
return this.yPosition;
}
@Override
public int getWidth()
{
public int getWidth() {
return this.halfSize ? 8 : 16;
}
@Override
public int getHeight()
{
public int getHeight() {
return this.halfSize ? 8 : 16;
}
@Override
public boolean isVisible()
{
public boolean isVisible() {
return this.visible;
}
@Override
public String getMessage()
{
public String getMessage() {
String displayName = null;
String displayValue = null;
if( this.buttonSetting != null && this.currentValue != null )
{
final ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) );
if( buttonAppearance == null )
{
if (this.buttonSetting != null && this.currentValue != null) {
final ButtonAppearance buttonAppearance =
appearances.get(new EnumPair(this.buttonSetting, this.currentValue));
if (buttonAppearance == null) {
return "No Such Message";
}
displayName = buttonAppearance.displayName;
displayValue = buttonAppearance.displayValue;
}
if( displayName != null ) {
if (displayName != null) {
String name = StatCollector.translateToLocal(displayName);
if (name == null || name.isEmpty()) {
name = displayName;
@@ -192,38 +172,47 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
}
@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3 )
{
if( this.visible )
{
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
if (this.visible) {
final int iconIndex = this.getIconIndex();
if( this.halfSize )
{
if (this.halfSize) {
this.width = 8;
this.height = 8;
GL11.glPushMatrix();
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
GL11.glScalef( 0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3 );
GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
GL11.glScalef(0.5f / 16 * 3, 0.5f / 16 * 3, 0.5f / 16 * 3);
if( this.enabled )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
if (this.enabled) {
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
}
par1Minecraft.renderEngine.bindTexture( FluidCraft.resource("textures/gui/states.png") );
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png"));
this.field_146123_n = par2 >= this.xPosition
&& par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
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));
this.drawTexturedModalRect(0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F));
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,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
@@ -238,47 +227,56 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
}
par1Minecraft.renderEngine.bindTexture(FluidCraft.resource("textures/gui/states.png"));
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
this.field_146123_n = par2 >= this.xPosition
&& par3 >= this.yPosition
&& par2 < this.xPosition + this.width
&& par3 < this.yPosition + this.height;
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));
this.drawTexturedModalRect(0, 0, Math.round(uv_x * 16F * 16F / 3F), Math.round(uv_y * 16F * 16F / 3F), Math.round(16F * 16F / 3F), Math.round(16F * 16F / 3F));
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,
Math.round(uv_x * 16F * 16F / 3F),
Math.round(uv_y * 16F * 16F / 3F),
Math.round(16F * 16F / 3F),
Math.round(16F * 16F / 3F));
this.mouseDragged(par1Minecraft, par2, par3);
GL11.glPopMatrix();
}
}
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
private static final class EnumPair
{
private static final class EnumPair {
final String setting;
final String value;
EnumPair( final String a, final String b )
{
EnumPair(final String a, final String b) {
this.setting = a;
this.value = b;
}
@Override
public int hashCode()
{
public int hashCode() {
return this.setting.hashCode() ^ this.value.hashCode();
}
@Override
public boolean equals( final Object obj )
{
if( obj == null )
{
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if( this.getClass() != obj.getClass() )
{
if (this.getClass() != obj.getClass()) {
return false;
}
final EnumPair other = (EnumPair) obj;
@@ -286,12 +284,9 @@ public class GuiFCImgButton extends GuiButton implements ITooltip {
}
}
private static class ButtonAppearance
{
private static class ButtonAppearance {
public int index;
public String displayName;
public String displayValue;
}
}
@@ -17,14 +17,12 @@ import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import java.io.IOException;
public class GuiFCPriority extends AEBaseGui
{
public class GuiFCPriority extends AEBaseGui {
private GuiNumberBox priority;
private GuiTabButton originalGuiBtn;
@@ -40,180 +38,162 @@ public class GuiFCPriority extends AEBaseGui
private GuiType OriginalGui;
public GuiFCPriority( final InventoryPlayer inventoryPlayer, final IPriorityHost te )
{
super( new ContainerPriority( inventoryPlayer, te ) );
public GuiFCPriority(final InventoryPlayer inventoryPlayer, final IPriorityHost te) {
super(new ContainerPriority(inventoryPlayer, te));
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
final int a = AEConfig.instance.priorityByStacksAmounts( 0 );
final int b = AEConfig.instance.priorityByStacksAmounts( 1 );
final int c = AEConfig.instance.priorityByStacksAmounts( 2 );
final int d = AEConfig.instance.priorityByStacksAmounts( 3 );
final int a = AEConfig.instance.priorityByStacksAmounts(0);
final int b = AEConfig.instance.priorityByStacksAmounts(1);
final int c = AEConfig.instance.priorityByStacksAmounts(2);
final int d = AEConfig.instance.priorityByStacksAmounts(3);
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d));
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d));
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
if( target instanceof TileFluidInterface)
{
if (target instanceof TileFluidInterface) {
myIcon = ItemAndBlockHolder.INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE;
}
else if (target instanceof PartFluidInterface)
{
} else if (target instanceof PartFluidInterface) {
myIcon = ItemAndBlockHolder.FLUID_INTERFACE.stack();
this.OriginalGui = GuiType.DUAL_INTERFACE_FLUID_PART;
}
if( this.OriginalGui != null && myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
if (this.OriginalGui != null && myIcon != null) {
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class );
this.priority.setEnableBackgroundDrawing( false );
this.priority.setMaxStringLength( 16 );
this.priority.setTextColor( 0xFFFFFF );
this.priority.setVisible( true );
this.priority.setFocused( true );
( (ContainerPriority) this.inventorySlots ).setTextField( this.priority );
this.priority = new GuiNumberBox(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT,
Long.class);
this.priority.setEnableBackgroundDrawing(false);
this.priority.setMaxStringLength(16);
this.priority.setTextColor(0xFFFFFF);
this.priority.setVisible(true);
this.priority.setFocused(true);
((ContainerPriority) this.inventorySlots).setTextField(this.priority);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.Priority.getLocal(), 8, 6, 4210752);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.bindTexture( getBackground() );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.bindTexture(getBackground());
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
this.priority.drawTextBox();
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if( btn == this.originalGuiBtn )
{
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty( final int i )
{
try
{
private void addQty(final int i) {
try {
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
if (fixed) {
this.priority.setText(out);
}
if( out.isEmpty() )
{
if (out.isEmpty()) {
out = "0";
}
long result = Long.parseLong( out );
long result = Long.parseLong(out);
result += i;
this.priority.setText( out = Long.toString( result ) );
this.priority.setText(out = Long.toString(result));
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
}
catch( final NumberFormatException e )
{
NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final NumberFormatException e) {
// nope..
this.priority.setText( "0" );
}
catch( final IOException e )
{
AELog.debug( e );
this.priority.setText("0");
} catch (final IOException e) {
AELog.debug(e);
}
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.priority.textboxKeyTyped( character, key ) )
{
try
{
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if ((key == 211
|| key == 205
|| key == 203
|| key == 14
|| character == '-'
|| Character.isDigit(character))
&& this.priority.textboxKeyTyped(character, key)) {
try {
String out = this.priority.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( fixed )
{
this.priority.setText( out );
if (fixed) {
this.priority.setText(out);
}
if( out.isEmpty() )
{
if (out.isEmpty()) {
out = "0";
}
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) );
NetworkHandler.instance.sendToServer(new PacketValueConfig("PriorityHost.Priority", out));
} catch (final IOException e) {
AELog.debug(e);
}
catch( final IOException e )
{
AELog.debug( e );
}
}
else
{
super.keyTyped( character, key );
} else {
super.keyTyped(character, key);
}
}
}
protected String getBackground()
{
protected String getBackground() {
return "guis/priority.png";
}
}
@@ -24,8 +24,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
public class GuiFluidCraftAmount extends AEBaseGui
{
public class GuiFluidCraftAmount extends AEBaseGui {
private GuiNumberBox amountToCraft;
private GuiTabButton originalGuiBtn;
@@ -43,35 +42,34 @@ public class GuiFluidCraftAmount extends AEBaseGui
private GuiType originalGui;
@Reflected
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerCraftAmount( inventoryPlayer, te ) );
public GuiFluidCraftAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftAmount(inventoryPlayer, te));
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
final int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
final int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
final int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
final int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
final int a = AEConfig.instance.craftItemsByStackAmounts(0);
final int b = AEConfig.instance.craftItemsByStackAmounts(1);
final int c = AEConfig.instance.craftItemsByStackAmounts(2);
final int d = AEConfig.instance.craftItemsByStackAmounts(3);
this.buttonList.add( this.plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
this.buttonList.add( this.plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
this.buttonList.add( this.plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
this.buttonList.add( this.plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
this.buttonList.add(this.plus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a));
this.buttonList.add(this.plus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b));
this.buttonList.add(this.plus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c));
this.buttonList.add(this.plus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d));
this.buttonList.add( this.minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
this.buttonList.add( this.minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
this.buttonList.add( this.minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
this.buttonList.add( this.minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
this.buttonList.add(this.minus1 = new GuiButton(0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a));
this.buttonList.add(this.minus10 = new GuiButton(0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b));
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add( this.next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
this.buttonList.add(
this.next = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ( (AEBaseContainer) this.inventorySlots ).getTarget();
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
@@ -89,40 +87,43 @@ public class GuiFluidCraftAmount extends AEBaseGui
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToCraft = new GuiNumberBox(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Integer.class);
this.amountToCraft = new GuiNumberBox(
this.fontRendererObj,
this.guiLeft + 62,
this.guiTop + 57,
59,
this.fontRendererObj.FONT_HEIGHT,
Integer.class);
this.amountToCraft.setEnableBackgroundDrawing(false);
this.amountToCraft.setMaxStringLength(16);
this.amountToCraft.setTextColor(0xFFFFFF);
this.amountToCraft.setVisible( true );
this.amountToCraft.setFocused( true );
this.amountToCraft.setText( "1" );
this.amountToCraft.setVisible(true);
this.amountToCraft.setFocused(true);
this.amountToCraft.setText("1");
this.amountToCraft.setSelectionPos(0);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 4210752);
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
this.bindTexture( "guis/craftAmt.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.bindTexture("guis/craftAmt.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
try
{
Long.parseLong( this.amountToCraft.getText() );
try {
Long.parseLong(this.amountToCraft.getText());
this.next.enabled = this.amountToCraft.getText().length() > 0;
}
catch( final NumberFormatException e )
{
} catch (final NumberFormatException e) {
this.next.enabled = false;
}
@@ -130,132 +131,110 @@ public class GuiFluidCraftAmount extends AEBaseGui
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.next );
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.next);
}
if( ( key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ) ) && this.amountToCraft.textboxKeyTyped( character, key ) )
{
try
{
if ((key == 211
|| key == 205
|| key == 203
|| key == 14
|| character == '-'
|| Character.isDigit(character))
&& this.amountToCraft.textboxKeyTyped(character, key)) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( fixed )
{
this.amountToCraft.setText( out );
if (fixed) {
this.amountToCraft.setText(out);
}
if( out.isEmpty() )
{
if (out.isEmpty()) {
out = "0";
}
final long result = Long.parseLong( out );
if( result < 0 )
{
this.amountToCraft.setText( "1" );
final long result = Long.parseLong(out);
if (result < 0) {
this.amountToCraft.setText("1");
}
}
catch( final NumberFormatException e )
{
} catch (final NumberFormatException e) {
// :P
}
}
else
{
super.keyTyped( character, key );
} else {
super.keyTyped(character, key);
}
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
try
{
try {
if( btn == this.originalGuiBtn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.originalGui ) );
if (btn == this.originalGuiBtn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
if( btn == this.next )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
if (btn == this.next) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketCraftRequest(Integer.parseInt(this.amountToCraft.getText()), isShiftKeyDown()));
}
}
catch( final NumberFormatException e )
{
} catch (final NumberFormatException e) {
// nope..
this.amountToCraft.setText( "1" );
this.amountToCraft.setText("1");
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if( isPlus || isMinus )
{
this.addQty( this.getQty( btn ) );
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
}
}
private void addQty( final int i )
{
try
{
private void addQty(final int i) {
try {
String out = this.amountToCraft.getText();
boolean fixed = false;
while( out.startsWith( "0" ) && out.length() > 1 )
{
out = out.substring( 1 );
while (out.startsWith("0") && out.length() > 1) {
out = out.substring(1);
fixed = true;
}
if( fixed )
{
this.amountToCraft.setText( out );
if (fixed) {
this.amountToCraft.setText(out);
}
if( out.isEmpty() )
{
if (out.isEmpty()) {
out = "0";
}
long result = Integer.parseInt( out );
long result = Integer.parseInt(out);
if( result == 1 && i > 1 )
{
if (result == 1 && i > 1) {
result = 0;
}
result += i;
if( result < 1 )
{
if (result < 1) {
result = 1;
}
out = Long.toString( result );
Integer.parseInt( out );
this.amountToCraft.setText( out );
}
catch( final NumberFormatException e )
{
out = Long.toString(result);
Integer.parseInt(out);
this.amountToCraft.setText(out);
} catch (final NumberFormatException e) {
// :P
}
}
}
@@ -19,17 +19,16 @@ import com.glodblock.github.network.CPacketFluidPatternTermBtns;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.google.common.base.Joiner;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiFluidCraftConfirm extends AEBaseGui {
@@ -50,78 +49,76 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
private int tooltip = -1;
private ItemStack hoveredStack;
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerFluidCraftConfirm( inventoryPlayer, te ) );
public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerFluidCraftConfirm(inventoryPlayer, te));
this.xSize = 238;
this.ySize = 206;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.setScrollBar(scrollbar);
this.ccc = (ContainerFluidCraftConfirm) this.inventorySlots;
if( te instanceof PartFluidPatternTerminal)
{
if (te instanceof PartFluidPatternTerminal) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if( te instanceof PartFluidPatternTerminalEx)
{
if (te instanceof PartFluidPatternTerminalEx) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
}
boolean isAutoStart()
{
return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isAutoStart();
boolean isAutoStart() {
return ((ContainerFluidCraftConfirm) this.inventorySlots).isAutoStart();
}
@Override
public void initGui()
{
public void initGui() {
super.initGui();
this.start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal() );
this.start =
new GuiButton(0, this.guiLeft + 162, this.guiTop + this.ySize - 25, 50, 20, GuiText.Start.getLocal());
this.start.enabled = false;
this.buttonList.add( this.start );
this.buttonList.add(this.start);
this.selectCPU = new GuiButton( 0, this.guiLeft + ( 219 - 180 ) / 2, this.guiTop + this.ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic );
this.selectCPU = new GuiButton(
0,
this.guiLeft + (219 - 180) / 2,
this.guiTop + this.ySize - 68,
180,
20,
GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic);
this.selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
this.buttonList.add(this.selectCPU);
if( this.OriginalGui != null )
{
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
if (this.OriginalGui != null) {
this.cancel = new GuiButton(
0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal());
}
this.buttonList.add( this.cancel );
this.buttonList.add(this.cancel);
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
public void drawScreen(final int mouseX, final int mouseY, final float btn) {
this.updateCPUButtonText();
this.start.enabled = !( this.ccc.hasNoCPU() || this.isSimulation() );
this.start.enabled = !(this.ccc.hasNoCPU() || this.isSimulation());
this.selectCPU.enabled = !this.isSimulation();
final int gx = ( this.width - this.xSize ) / 2;
final int gy = ( this.height - this.ySize ) / 2;
final int gx = (this.width - this.xSize) / 2;
final int gy = (this.height - this.ySize) / 2;
this.tooltip = -1;
final int offY = 23;
int y = 0;
int x = 0;
for( int z = 0; z <= 4 * 5; z++ )
{
for (int z = 0; z <= 4 * 5; z++) {
final int minX = gx + 9 + x * 67;
final int minY = gy + 22 + y * offY;
if( minX < mouseX && minX + 67 > mouseX )
{
if( minY < mouseY && minY + offY - 2 > mouseY )
{
if (minX < mouseX && minX + 67 > mouseX) {
if (minY < mouseY && minY + offY - 2 > mouseY) {
this.tooltip = z;
break;
}
@@ -129,66 +126,61 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
x++;
if( x > 2 )
{
if (x > 2) {
y++;
x = 0;
}
}
super.drawScreen( mouseX, mouseY, btn );
super.drawScreen(mouseX, mouseY, btn);
}
private void updateCPUButtonText()
{
private void updateCPUButtonText() {
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
if( this.ccc.getSelectedCpu() >= 0 )// && status.selectedCpu < status.cpus.size() )
if (this.ccc.getSelectedCpu() >= 0) // && status.selectedCpu < status.cpus.size() )
{
if( this.ccc.getName().length() > 0 )
{
final String name = this.ccc.getName().substring( 0, Math.min( 20, this.ccc.getName().length() ) );
if (this.ccc.getName().length() > 0) {
final String name = this.ccc
.getName()
.substring(0, Math.min(20, this.ccc.getName().length()));
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
}
else
{
} else {
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.getSelectedCpu();
}
}
if( this.ccc.hasNoCPU() )
{
if (this.ccc.hasNoCPU()) {
btnTextText = GuiText.NoCraftingCPUs.getLocal();
}
this.selectCPU.displayString = btnTextText;
}
private boolean isSimulation()
{
return ( (ContainerFluidCraftConfirm) this.inventorySlots ).isSimulation();
private boolean isSimulation() {
return ((ContainerFluidCraftConfirm) this.inventorySlots).isSimulation();
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
final long BytesUsed = this.ccc.getUsedBytes();
final String byteUsed = NumberFormat.getInstance().format( BytesUsed );
final String Add = BytesUsed > 0 ? ( byteUsed + ' ' + GuiText.BytesUsed.getLocal() ) : GuiText.CalculatingWait.getLocal();
this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
final String byteUsed = NumberFormat.getInstance().format(BytesUsed);
final String Add =
BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752);
String dsp = null;
if( this.isSimulation() )
{
if (this.isSimulation()) {
dsp = GuiText.Simulation.getLocal();
}
else
{
dsp = this.ccc.getCpuAvailableBytes() > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors() ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
} else {
dsp = this.ccc.getCpuAvailableBytes() > 0
? (GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : "
+ GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors())
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
}
final int offset = ( 219 - this.fontRendererObj.getStringWidth( dsp ) ) / 2;
this.fontRendererObj.drawString( dsp, offset, 165, 4210752 );
final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2;
this.fontRendererObj.drawString(dsp, offset, 165, 4210752);
final int sectionLength = 67;
@@ -206,349 +198,297 @@ public class GuiFluidCraftConfirm extends AEBaseGui {
hoveredStack = null;
final int offY = 23;
for( int z = viewStart; z < Math.min( viewEnd, this.visual.size() ); z++ )
{
final IAEItemStack refStack = this.visual.get( z );// repo.getReferenceItem( z );
if( refStack != null )
{
for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
final IAEItemStack refStack = this.visual.get(z); // repo.getReferenceItem( z );
if (refStack != null) {
GL11.glPushMatrix();
GL11.glScaled( 0.5, 0.5, 0.5 );
GL11.glScaled(0.5, 0.5, 0.5);
final IAEItemStack stored = this.storage.findPrecise( refStack );
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
final IAEItemStack missingStack = this.missing.findPrecise( refStack );
final IAEItemStack stored = this.storage.findPrecise(refStack);
final IAEItemStack pendingStack = this.pending.findPrecise(refStack);
final IAEItemStack missingStack = this.missing.findPrecise(refStack);
int lines = 0;
if( stored != null && stored.getStackSize() > 0 )
{
if (stored != null && stored.getStackSize() > 0) {
lines++;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
if (pendingStack != null && pendingStack.getStackSize() > 0) {
lines++;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
if (pendingStack != null && pendingStack.getStackSize() > 0) {
lines++;
}
final int negY = ( ( lines - 1 ) * 5 ) / 2;
final int negY = ((lines - 1) * 5) / 2;
int downY = 0;
if( stored != null && stored.getStackSize() > 0 )
{
String str = Long.toString( stored.getStackSize() );
if( stored.getStackSize() >= 10000 )
{
str = Long.toString( stored.getStackSize() / 1000 ) + 'k';
if (stored != null && stored.getStackSize() > 0) {
String str = Long.toString(stored.getStackSize());
if (stored.getStackSize() >= 10000) {
str = Long.toString(stored.getStackSize() / 1000) + 'k';
}
if( stored.getStackSize() >= 10000000 )
{
str = Long.toString( stored.getStackSize() / 1000000 ) + 'm';
if (stored.getStackSize() >= 10000000) {
str = Long.toString(stored.getStackSize() / 1000000) + 'm';
}
str = GuiText.FromStorage.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.FromStorage.getLocal() + ": " + stored.getStackSize());
}
downY += 5;
}
boolean red = false;
if( missingStack != null && missingStack.getStackSize() > 0 )
{
String str = Long.toString( missingStack.getStackSize() );
if( missingStack.getStackSize() >= 10000 )
{
str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k';
if (missingStack != null && missingStack.getStackSize() > 0) {
String str = Long.toString(missingStack.getStackSize());
if (missingStack.getStackSize() >= 10000) {
str = Long.toString(missingStack.getStackSize() / 1000) + 'k';
}
if( missingStack.getStackSize() >= 10000000 )
{
str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm';
if (missingStack.getStackSize() >= 10000000) {
str = Long.toString(missingStack.getStackSize() / 1000000) + 'm';
}
str = GuiText.Missing.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.Missing.getLocal() + ": " + missingStack.getStackSize());
}
red = true;
downY += 5;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
String str = Long.toString( pendingStack.getStackSize() );
if( pendingStack.getStackSize() >= 10000 )
{
str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k';
if (pendingStack != null && pendingStack.getStackSize() > 0) {
String str = Long.toString(pendingStack.getStackSize());
if (pendingStack.getStackSize() >= 10000) {
str = Long.toString(pendingStack.getStackSize() / 1000) + 'k';
}
if( pendingStack.getStackSize() >= 10000000 )
{
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm';
if (pendingStack.getStackSize() >= 10000000) {
str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm';
}
str = GuiText.ToCraft.getLocal() + ": " + str;
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 );
final int w = 4 + this.fontRendererObj.getStringWidth(str);
this.fontRendererObj.drawString(
str,
(int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2),
(y * offY + yo + 6 - negY + downY) * 2,
4210752);
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
}
}
GL11.glPopMatrix();
final int posX = x * ( 1 + sectionLength ) + xo + sectionLength - 19;
final int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
final int posY = y * offY + yo;
final ItemStack is = CoreModHooks.displayFluid(refStack.copy());
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if( lineList.size() > 0 )
{
if (this.tooltip == z - viewStart) {
dspToolTip = Platform.getItemDisplayName(is);
if (lineList.size() > 0) {
addItemTooltip(is, lineList);
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
}
toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8;
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
toolPosY = y * offY + yo;
hoveredStack = is;
}
this.drawItem( posX, posY, is );
this.drawItem(posX, posY, is);
if( red )
{
final int startX = x * ( 1 + sectionLength ) + xo;
if (red) {
final int startX = x * (1 + sectionLength) + xo;
final int startY = posY - 4;
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000);
}
x++;
if( x > 2 )
{
if (x > 2) {
y++;
x = 0;
}
}
}
if( this.tooltip >= 0 && dspToolTip.length() > 0 )
{
this.drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
if (this.tooltip >= 0 && dspToolTip.length() > 0) {
this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
}
}
@Override
public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.setScrollBar();
this.bindTexture( "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.bindTexture("guis/craftingreport.png");
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize);
}
private void setScrollBar()
{
private void setScrollBar() {
final int size = this.visual.size();
this.getScrollBar().setTop( 19 ).setLeft( 218 ).setHeight( 114 );
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - this.rows, 1 );
this.getScrollBar().setTop(19).setLeft(218).setHeight(114);
this.getScrollBar().setRange(0, (size + 2) / 3 - this.rows, 1);
}
public void postUpdate( final List<IAEItemStack> list, final byte ref )
{
switch( ref )
{
public void postUpdate(final List<IAEItemStack> list, final byte ref) {
switch (ref) {
case 0:
for( final IAEItemStack l : list )
{
this.handleInput( this.storage, l );
for (final IAEItemStack l : list) {
this.handleInput(this.storage, l);
}
break;
case 1:
for( final IAEItemStack l : list )
{
this.handleInput( this.pending, l );
for (final IAEItemStack l : list) {
this.handleInput(this.pending, l);
}
break;
case 2:
for( final IAEItemStack l : list )
{
this.handleInput( this.missing, l );
for (final IAEItemStack l : list) {
this.handleInput(this.missing, l);
}
break;
}
for( final IAEItemStack l : list )
{
final long amt = this.getTotal( l );
for (final IAEItemStack l : list) {
final long amt = this.getTotal(l);
if( amt <= 0 )
{
this.deleteVisualStack( l );
}
else
{
final IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
if (amt <= 0) {
this.deleteVisualStack(l);
} else {
final IAEItemStack is = this.findVisualStack(l);
is.setStackSize(amt);
}
}
this.setScrollBar();
}
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
{
IAEItemStack a = s.findPrecise( l );
private void handleInput(final IItemList<IAEItemStack> s, final IAEItemStack l) {
IAEItemStack a = s.findPrecise(l);
if( l.getStackSize() <= 0 )
{
if( a != null )
{
if (l.getStackSize() <= 0) {
if (a != null) {
a.reset();
}
}
else
{
if( a == null )
{
s.add( l.copy() );
a = s.findPrecise( l );
} else {
if (a == null) {
s.add(l.copy());
a = s.findPrecise(l);
}
if( a != null )
{
a.setStackSize( l.getStackSize() );
if (a != null) {
a.setStackSize(l.getStackSize());
}
}
}
private long getTotal( final IAEItemStack is )
{
final IAEItemStack a = this.storage.findPrecise( is );
final IAEItemStack c = this.pending.findPrecise( is );
final IAEItemStack m = this.missing.findPrecise( is );
private long getTotal(final IAEItemStack is) {
final IAEItemStack a = this.storage.findPrecise(is);
final IAEItemStack c = this.pending.findPrecise(is);
final IAEItemStack m = this.missing.findPrecise(is);
long total = 0;
if( a != null )
{
if (a != null) {
total += a.getStackSize();
}
if( c != null )
{
if (c != null) {
total += c.getStackSize();
}
if( m != null )
{
if (m != null) {
total += m.getStackSize();
}
return total;
}
private void deleteVisualStack( final IAEItemStack l )
{
private void deleteVisualStack(final IAEItemStack l) {
final Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
{
while (i.hasNext()) {
final IAEItemStack o = i.next();
if( o.equals( l ) )
{
if (o.equals(l)) {
i.remove();
return;
}
}
}
private IAEItemStack findVisualStack( final IAEItemStack l )
{
for( final IAEItemStack o : this.visual )
{
if( o.equals( l ) )
{
private IAEItemStack findVisualStack(final IAEItemStack l) {
for (final IAEItemStack o : this.visual) {
if (o.equals(l)) {
return o;
}
}
final IAEItemStack stack = l.copy();
this.visual.add( stack );
this.visual.add(stack);
return stack;
}
@Override
protected void keyTyped( final char character, final int key )
{
if( !this.checkHotbarKeys( key ) )
{
if( key == 28 )
{
this.actionPerformed( this.start );
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == 28) {
this.actionPerformed(this.start);
}
super.keyTyped( character, key );
super.keyTyped(character, key);
}
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown( 1 );
final boolean backwards = Mouse.isButtonDown(1);
if( btn == this.selectCPU )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
if (btn == this.selectCPU) {
FluidCraft.proxy.netHandler.sendToServer(
new CPacketFluidPatternTermBtns("Terminal.Cpu", backwards ? "Prev" : "Next"));
}
if( btn == this.cancel )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketSwitchGuis( this.OriginalGui ) );
if (btn == this.cancel) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
}
if( btn == this.start )
{
try
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "Terminal.Start", "Start" ) );
}
catch( final Throwable e )
{
AELog.debug( e );
if (btn == this.start) {
try {
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("Terminal.Start", "Start"));
} catch (final Throwable e) {
AELog.debug(e);
}
}
}
@SuppressWarnings({"rawtypes", "unchecked"})
protected void addItemTooltip(ItemStack is, List<String> lineList)
{
if (isShiftKeyDown())
{
protected void addItemTooltip(ItemStack is, List<String> lineList) {
if (isShiftKeyDown()) {
List l = is.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
if (!l.isEmpty())
l.remove(0);
if (!l.isEmpty()) l.remove(0);
lineList.addAll(l);
}
else if (ModAndClassUtil.isShiftTooltip)
{
} else if (ModAndClassUtil.isShiftTooltip) {
lineList.add(GuiText.HoldShiftForTooltip.getLocal());
}
}
@@ -10,51 +10,49 @@ import com.glodblock.github.util.NameConst;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
public class GuiFluidIO extends GuiUpgradeable
{
public class GuiFluidIO extends GuiUpgradeable {
private final PartSharedFluidBus bus;
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te )
{
super( new ContainerFluidIO( inventoryPlayer, te ) );
public GuiFluidIO(InventoryPlayer inventoryPlayer, PartSharedFluidBus te) {
super(new ContainerFluidIO(inventoryPlayer, te));
this.bus = te;
}
@Override
protected GuiText getName()
{
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);
((ContainerFluidIO) this.cvb).getBus().setFluidInSlot(id, stack);
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
this.fontRendererObj.drawString( this.getGuiDisplayName(I18n.format(this.bus instanceof PartFluidImportBus ? NameConst.GUI_FLUID_IMPORT : NameConst.GUI_FLUID_EXPORT)), 8, 6, 4210752 );
this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
this.getGuiDisplayName(I18n.format(
this.bus instanceof PartFluidImportBus
? NameConst.GUI_FLUID_IMPORT
: NameConst.GUI_FLUID_EXPORT)),
8,
6,
4210752);
this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);
if( this.redstoneMode != null )
{
this.redstoneMode.set( this.cvb.getRedStoneMode() );
if (this.redstoneMode != null) {
this.redstoneMode.set(this.cvb.getRedStoneMode());
}
if( this.fuzzyMode != null )
{
this.fuzzyMode.set( this.cvb.getFuzzyMode() );
if (this.fuzzyMode != null) {
this.fuzzyMode.set(this.cvb.getFuzzyMode());
}
if( this.craftMode != null )
{
this.craftMode.set( this.cvb.getCraftingMode() );
if (this.craftMode != null) {
this.craftMode.set(this.cvb.getCraftingMode());
}
if( this.schedulingMode != null )
{
this.schedulingMode.set( this.cvb.getSchedulingMode() );
if (this.schedulingMode != null) {
this.schedulingMode.set(this.cvb.getSchedulingMode());
}
}
}
@@ -15,6 +15,7 @@ import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
@@ -28,8 +29,6 @@ import net.minecraft.util.StatCollector;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class GuiFluidInterface extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/interface_fluid.png");
@@ -57,10 +56,16 @@ public class GuiFluidInterface extends AEBaseGui {
private void addMouseRegin() {
for (int i = 0; i < 6; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(
isPart() ? ((PartFluidInterface) cont.getTile()).getInternalFluid() : ((TileFluidInterface) cont.getTile()).getInternalFluid(),
i));
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(
isPart()
? ((PartFluidInterface) cont.getTile()).getInternalFluid()
: ((TileFluidInterface) cont.getTile()).getInternalFluid(),
i));
}
}
@@ -68,19 +73,23 @@ public class GuiFluidInterface extends AEBaseGui {
public void func_146977_a(final Slot s) {
try {
GuiContainer.class
.getDeclaredMethod("func_146977_a_original", Slot.class)
.invoke(this, s);
.getDeclaredMethod("func_146977_a_original", Slot.class)
.invoke(this, s);
} catch (final Exception ignore) {
}
}
@Override
@SuppressWarnings("unchecked")
public void initGui()
{
public void initGui() {
super.initGui();
this.switcher = new GuiTabButton( this.guiLeft + 154, this.guiTop, isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(), StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"), itemRender );
this.buttonList.add( this.switcher );
this.switcher = new GuiTabButton(
this.guiLeft + 154,
this.guiTop,
isPart() ? ItemAndBlockHolder.FLUID_INTERFACE.stack() : ItemAndBlockHolder.INTERFACE.stack(),
StatCollector.translateToLocal("ae2fc.tooltip.switch_fluid_interface"),
itemRender);
this.buttonList.add(this.switcher);
}
@Override
@@ -101,8 +110,13 @@ public class GuiFluidInterface extends AEBaseGui {
if (!isPart()) {
fontRendererObj.drawString(dirName(i), TANK_X + i * TANK_X_OFF + 5, 22, 0x404040);
}
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
renderFluidIntoGui(
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
@@ -118,8 +132,8 @@ public class GuiFluidInterface extends AEBaseGui {
drawTexturedModalRect(offsetX, offsetY, 0, 0, 176, ySize);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
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);
@@ -127,10 +141,14 @@ public class GuiFluidInterface extends AEBaseGui {
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
@@ -138,11 +156,11 @@ public class GuiFluidInterface extends AEBaseGui {
}
@Override
protected void actionPerformed( final GuiButton btn )
{
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketSwitchGuis(isPart() ? GuiType.DUAL_INTERFACE_PART : GuiType.DUAL_INTERFACE));
}
}
@@ -154,9 +172,8 @@ public class GuiFluidInterface extends AEBaseGui {
} else {
((TileFluidInterface) cont.getTile()).setConfig(id, stack);
}
}
else {
if(isPart()) {
} else {
if (isPart()) {
((PartFluidInterface) cont.getTile()).setFluidInv(id, stack);
} else {
((TileFluidInterface) cont.getTile()).setFluidInv(id, stack);
@@ -167,6 +184,4 @@ public class GuiFluidInterface extends AEBaseGui {
private boolean isPart() {
return this.cont.getTile() instanceof PartFluidInterface;
}
}
@@ -29,5 +29,4 @@ public class GuiFluidPacketDecoder extends AEBaseGui {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_FLUID_PACKET_DECODER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
}
}
@@ -14,6 +14,9 @@ import com.glodblock.github.inventory.slot.SlotSingleItem;
import com.glodblock.github.network.CPacketEncodePattern;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.NameConst;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
@@ -23,10 +26,6 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class GuiFluidPatternEncoder extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/fluid_pattern_encoder.png");
@@ -37,7 +36,7 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
public GuiFluidPatternEncoder(InventoryPlayer ipl, TileFluidPatternEncoder tile) {
super(new ContainerFluidPatternEncoder(ipl, tile));
this.cont = (ContainerFluidPatternEncoder)inventorySlots;
this.cont = (ContainerFluidPatternEncoder) inventorySlots;
mouseRegions.addRegion(141, 38, 10, 10, new MouseRegionManager.Handler() {
@Override
public List<String> getTooltip() {
@@ -78,14 +77,13 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
}
@Override
public void func_146977_a( final Slot s )
{
this.drawSlot0( s );
public void func_146977_a(final Slot s) {
this.drawSlot0(s);
}
public void drawSlot0(Slot slot) {
if (slot instanceof SlotFluid) {
IAEItemStack stack = ((SlotFluid)slot).getAeStack();
IAEItemStack stack = ((SlotFluid) slot).getAeStack();
super.func_146977_a(new SlotSingleItem(slot));
if (stack == null) return;
IAEItemStack fake = stack.copy();
@@ -94,7 +92,12 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
} else {
super.func_146977_a(slot);
}
@@ -107,29 +110,23 @@ public class GuiFluidPatternEncoder extends AEBaseGui {
if (stack.getItem() instanceof ItemFluidPacket) {
FluidStack fluid = ItemFluidPacket.getFluidStack(stack);
if (fluid != null) {
list = Arrays.asList(fluid.getLocalizedName(), String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount));
}
else {
list = Arrays.asList(
fluid.getLocalizedName(), String.format(EnumChatFormatting.GRAY + "%,d mB", fluid.amount));
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
}
else {
} else {
list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
}
for (int k = 0; k < list.size(); ++k)
{
if (k == 0)
{
list.set(k, stack.getRarity().rarityColor + (String)list.get(k));
}
else
{
list.set(k, EnumChatFormatting.GRAY + (String)list.get(k));
for (int k = 0; k < list.size(); ++k) {
if (k == 0) {
list.set(k, stack.getRarity().rarityColor + (String) list.get(k));
} else {
list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
}
}
FontRenderer font = stack.getItem().getFontRenderer(stack);
drawHoveringText(list, x, y, (font == null ? fontRendererObj : font));
}
}
@@ -38,10 +38,8 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
}
@Override
public void func_146977_a( final Slot s )
{
if (drawSlot0(s))
super.func_146977_a( s );
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
@@ -53,11 +51,14 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
else
return true;
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
@@ -71,5 +72,4 @@ public class GuiFluidPatternTerminal extends GuiBaseFluidPatternTerminal {
super.actionPerformed(btn);
}
}
}
@@ -40,15 +40,12 @@ public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
@Override
protected void actionPerformed(final GuiButton btn) {
if (btn == originalGuiBtn) {
if (host instanceof PartFluidPatternTerminal)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
if (host instanceof PartFluidPatternTerminal) InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL);
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal)
InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
} else {
super.actionPerformed(btn);
}
}
}
@@ -38,10 +38,8 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
}
@Override
public void func_146977_a( final Slot s )
{
if (drawSlot0(s))
super.func_146977_a( s );
public void func_146977_a(final Slot s) {
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
@@ -53,11 +51,14 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
if (fake.getItemStack().getItem() instanceof ItemFluidPacket) {
if (ItemFluidPacket.getFluidStack(stack) != null && ItemFluidPacket.getFluidStack(stack).amount > 0)
fake.setStackSize(ItemFluidPacket.getFluidStack(stack).amount);
}
else
return true;
} else return true;
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
@@ -71,5 +72,4 @@ public class GuiFluidPatternTerminalEx extends GuiBaseFluidPatternTerminalEx {
super.actionPerformed(btn);
}
}
}
@@ -12,6 +12,8 @@ import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.Util;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
@@ -21,9 +23,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
public class GuiFluidTerminal extends GuiBaseFluidTerminal {
private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
public ContainerFluidTerminal container;
@@ -40,11 +39,9 @@ public class GuiFluidTerminal extends GuiBaseFluidTerminal {
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s))
super.func_146977_a(s);
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
if (slot instanceof SlotME) {
IAEItemStack stack = ((SlotME) slot).getAEStack();
@@ -52,23 +49,29 @@ public class GuiFluidTerminal extends GuiBaseFluidTerminal {
FluidStack fluidStack = ItemFluidDrop.getFluidStack(slot.getStack());
this.drawWidget(slot.xDisplayPosition, slot.yDisplayPosition, fluidStack.getFluid());
stackSizeRenderer.setAeStack(stack);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
}
private void drawWidget(int posX, int posY, Fluid fluid) {
Minecraft.getMinecraft().renderEngine
.bindTexture(TextureMap.locationBlocksTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor3f(1, 1, 1);
if (fluid != null && fluid.getIcon() != null) {
GL11.glColor3f((fluid.getColor() >> 16 & 0xFF) / 255.0F, (fluid.getColor() >> 8 & 0xFF) / 255.0F, (fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY,
fluid.getIcon(), 16, 16);
GL11.glColor3f(
(fluid.getColor() >> 16 & 0xFF) / 255.0F,
(fluid.getColor() >> 8 & 0xFF) / 255.0F,
(fluid.getColor() & 0xFF) / 255.0F);
drawTexturedModelRectFromIcon(posX, posY, fluid.getIcon(), 16, 16);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
@@ -11,6 +11,7 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
@@ -20,8 +21,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class GuiIngredientBuffer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/ingredient_buffer.png");
@@ -36,10 +35,14 @@ public class GuiIngredientBuffer extends AEBaseGui {
this.cont = (ContainerIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 4; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7,
ButtonMouseHandler.dumpTank(cont, i));
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
}
}
@@ -65,16 +68,21 @@ public class GuiIngredientBuffer extends AEBaseGui {
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 4; i++) {
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
renderFluidIntoGui(
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
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);
@@ -82,10 +90,14 @@ public class GuiIngredientBuffer extends AEBaseGui {
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
@@ -95,5 +107,4 @@ public class GuiIngredientBuffer extends AEBaseGui {
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -11,6 +11,7 @@ import com.glodblock.github.inventory.gui.ButtonMouseHandler;
import com.glodblock.github.inventory.gui.MouseRegionManager;
import com.glodblock.github.inventory.gui.TankMouseHandler;
import com.glodblock.github.util.NameConst;
import javax.annotation.Nullable;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.resources.I18n;
@@ -20,8 +21,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nullable;
public class GuiLargeIngredientBuffer extends AEBaseGui {
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/large_ingredient_buffer.png");
@@ -36,10 +35,14 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
this.cont = (ContainerLargeIngredientBuffer) inventorySlots;
this.ySize = 222;
for (int i = 0; i < 7; i++) {
mouseRegions.addRegion(TANK_X + TANK_X_OFF * i, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7,
ButtonMouseHandler.dumpTank(cont, i));
mouseRegions.addRegion(
TANK_X + TANK_X_OFF * i,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
new TankMouseHandler(cont.getTile().getFluidInventory(), i));
mouseRegions.addRegion(
TANK_X + 10 + 22 * i, TANK_Y + TANK_HEIGHT + 2, 7, 7, ButtonMouseHandler.dumpTank(cont, i));
}
}
@@ -58,23 +61,29 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(
getGuiDisplayName(I18n.format(NameConst.GUI_LARGE_INGREDIENT_BUFFER)), 8, 6, 0x404040);
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
GL11.glColor4f(1F, 1F, 1F, 1F);
IAEFluidTank fluidInv = cont.getTile().getFluidInventory();
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
for (int i = 0; i < 7; i++) {
renderFluidIntoGui(TANK_X + i * TANK_X_OFF, TANK_Y, TANK_WIDTH, TANK_HEIGHT,
fluidInv.getFluidInSlot(i), fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
renderFluidIntoGui(
TANK_X + i * TANK_X_OFF,
TANK_Y,
TANK_WIDTH,
TANK_HEIGHT,
fluidInv.getFluidInSlot(i),
fluidInv.getTankInfo(ForgeDirection.UNKNOWN)[i].capacity);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
mouseRegions.render(mouseX, mouseY);
}
public void renderFluidIntoGui(int x, int y, int width, int height,
@Nullable IAEFluidStack aeFluidStack, int capacity) {
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);
@@ -82,10 +91,14 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
if (aeFluidStack.getStackSize() > 0 && hi > 0) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
IIcon fluidIcon = aeFluidStack.getFluid().getStillIcon();
GL11.glColor3f((float)(aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F, (float)(aeFluidStack.getFluid().getColor() & 255) / 255.0F);
GL11.glColor3f(
(float) (aeFluidStack.getFluid().getColor() >> 16 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() >> 8 & 255) / 255.0F,
(float) (aeFluidStack.getFluid().getColor() & 255) / 255.0F);
for (int th = 0; th <= hi; th += 16) {
if (hi - th <= 0) break;
this.drawTexturedModelRectFromIcon(x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
this.drawTexturedModelRectFromIcon(
x, y + height - Math.min(16, hi - th) - th, fluidIcon, width, Math.min(16, hi - th));
}
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
@@ -95,5 +108,4 @@ public class GuiLargeIngredientBuffer extends AEBaseGui {
public void update(int slot, IAEFluidStack aeFluidStack) {
cont.getTile().getFluidInventory().setFluidInSlot(slot, aeFluidStack);
}
}
@@ -19,6 +19,9 @@ 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.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
@@ -28,10 +31,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.util.Collections;
import java.util.List;
@Optional.Interface(modid = "NotEnoughItems", iface = "codechicken.nei.api.INEIGuiHandler")
public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@@ -76,18 +75,21 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
super.initGui();
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),
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),
i, "TileLevelMaintainer.Batch"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"),
this.buttonList
);
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),
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),
i,
"TileLevelMaintainer.Batch"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "ENABLE", "ENABLE"),
new GuiFCImgButton(guiLeft + 4, guiTop + 23 + 20 * i, "DISABLE", "DISABLE"),
this.buttonList);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.refresh"));
}
@@ -109,8 +111,7 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
public void func_146977_a(final Slot s) {
if (drawSlot0(s))
super.func_146977_a(s);
if (drawSlot0(s)) super.func_146977_a(s);
}
public boolean drawSlot0(Slot slot) {
@@ -120,12 +121,18 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
if (stack == null) return true;
IAEItemStack fake = stack.copy();
if (this.component[slot.getSlotIndex()].getQty().textField.getText().matches("[0-9]+")) {
fake.setStackSize(Long.parseLong(this.component[slot.getSlotIndex()].getQty().textField.getText()));
fake.setStackSize(Long.parseLong(
this.component[slot.getSlotIndex()].getQty().textField.getText()));
} else {
fake.setStackSize(0);
}
stackSizeRenderer.setAeStack(fake);
stackSizeRenderer.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), stack.getItemStack(), slot.xDisplayPosition, slot.yDisplayPosition);
stackSizeRenderer.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
stack.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
return false;
}
return true;
@@ -176,8 +183,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
@Override
protected void handleMouseClick(final Slot slot, final int slotIdx, final int ctrlDown, final int mouseButton) {
if (slot instanceof ContainerLevelMaintainer.FakeSlot && this.cont.getPlayerInv().getItemStack() != null) {
this.component[slot.getSlotIndex()].getQty().textField.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize));
if (slot instanceof ContainerLevelMaintainer.FakeSlot
&& this.cont.getPlayerInv().getItemStack() != null) {
this.component[slot.getSlotIndex()]
.getQty()
.textField
.setText(String.valueOf(this.cont.getPlayerInv().getItemStack().stackSize));
return;
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
@@ -187,7 +198,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.component[idx].getQty().textField.setText(String.valueOf(stackSize));
}
@Override
protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
@@ -248,7 +258,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private GuiFCImgButton disable;
private GuiFCImgButton enable;
public Component(Widget qtyInput, Widget batchInput, GuiFCImgButton enableBtn, GuiFCImgButton disableBtn, List buttonList) {
public Component(
Widget qtyInput,
Widget batchInput,
GuiFCImgButton enableBtn,
GuiFCImgButton disableBtn,
List buttonList) {
this.qty = qtyInput;
this.batch = batchInput;
this.enable = enableBtn;
@@ -271,10 +286,12 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
private boolean send(Widget widget) {
if (((ContainerLevelMaintainer.FakeSlot) cont.inventorySlots.get(widget.idx)).getHasStack()) {
if (!widget.textField.getText().isEmpty() && widget.textField.getText().matches("^[0-9]+")) {
if (!widget.textField.getText().isEmpty()
&& widget.textField.getText().matches("^[0-9]+")) {
String str = widget.textField.getText().replaceAll("^(0+)", "");
widget.textField.setText(str.isEmpty() ? "0" : str);
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText()));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer(widget.action, widget.idx, widget.textField.getText()));
widget.textField.setTextColor(0xFFFFFF);
return true;
} else {
@@ -293,9 +310,11 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
return this.send(this.getBatch());
}
if (this.enable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer("TileLevelMaintainer.Enable", this.getIndex()));
} else if (this.disable == btn) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketLevelMaintainer("TileLevelMaintainer.Disable", this.getIndex()));
}
return false;
}
@@ -325,7 +344,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
this.disable.visible = true;
}
}
}
private class Widget {
@@ -356,7 +374,5 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
public void setTooltip(String message) {
this.textField.setMessage(message);
}
}
}
@@ -85,8 +85,8 @@ public class GuiPatternValueAmount extends AEBaseGui {
this.buttonList.add(this.minus100 = new GuiButton(0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c));
this.buttonList.add(this.minus1000 = new GuiButton(0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d));
this.buttonList.add(this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
this.buttonList.add(
this.set = new GuiButton(0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal()));
ItemStack myIcon = null;
final Object target = ((AEBaseContainer) this.inventorySlots).getTarget();
@@ -104,10 +104,13 @@ public class GuiPatternValueAmount extends AEBaseGui {
}
if (this.originalGui != null && myIcon != null) {
this.buttonList.add(this.originalGuiBtn = new GuiTabButton(this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
this.buttonList.add(
this.originalGuiBtn = new GuiTabButton(
this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender));
}
this.amountToSet = new GuiTextField(this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToSet = new GuiTextField(
this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT);
this.amountToSet.setEnableBackgroundDrawing(false);
this.amountToSet.setMaxStringLength(16);
this.amountToSet.setTextColor(0xFFFFFF);
@@ -115,10 +118,8 @@ public class GuiPatternValueAmount extends AEBaseGui {
this.amountToSet.setFocused(true);
this.amountToSet.setText(String.valueOf(originalAmount));
this.amountToSet.setSelectionPos(0);
}
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(GuiText.SelectAmount.getLocal(), 8, 6, 0x404040);
@@ -183,7 +184,8 @@ public class GuiPatternValueAmount extends AEBaseGui {
resultI = (int) ArithHelper.round(resultD, 0);
}
FluidCraft.proxy.netHandler.sendToServer(new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
FluidCraft.proxy.netHandler.sendToServer(
new CPacketPatternValueSet(originalGui.ordinal(), resultI, valueIndex));
}
} catch (final NumberFormatException e) {
// nope..
@@ -191,7 +193,8 @@ public class GuiPatternValueAmount extends AEBaseGui {
}
final boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000;
final boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
final boolean isMinus =
btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000;
if (isPlus || isMinus) {
this.addQty(this.getQty(btn));
@@ -236,5 +239,4 @@ public class GuiPatternValueAmount extends AEBaseGui {
return stack.stackSize;
}
}
}
@@ -5,5 +5,4 @@ public interface TankDumpable {
boolean canDumpTank(int index);
void dumpTank(int index);
}
@@ -0,0 +1,30 @@
package com.glodblock.github.client.gui.container;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.api.util.IConfigManager;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerInterface;
import appeng.helpers.IInterfaceHost;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerDualInterface extends ContainerInterface {
@GuiSync(10)
public SidelessMode sidelessMode;
public ContainerDualInterface(InventoryPlayer ip, IInterfaceHost te) {
super(ip, te);
this.sidelessMode = SidelessMode.SIDELESS;
}
public SidelessMode getSidelessMode() {
return this.sidelessMode;
}
@Override
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
this.sidelessMode = (SidelessMode) cm.getSetting(Settings.SIDELESS_MODE);
}
}
@@ -14,58 +14,54 @@ 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 java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
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 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);
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 )
{
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 ) )
{
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 );
inv.setInventorySlotContents(i, tmp);
break;
}
}
this.standardDetectAndSendChanges();
return null;
} else {
if(idx < this.availableUpgrades()){
if(!mergeItemStack(tis, this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades(), this.inventorySlots.size(), false)) return null;
}else if(idx>=this.getFakeFluidInv().getSizeInventory()+this.availableUpgrades()){
if(!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null;
if (idx < this.availableUpgrades()) {
if (!mergeItemStack(
tis,
this.getFakeFluidInv().getSizeInventory() + this.availableUpgrades(),
this.inventorySlots.size(),
false)) return null;
} else if (idx >= this.getFakeFluidInv().getSizeInventory() + this.availableUpgrades()) {
if (!mergeItemStack(tis, 0, this.availableUpgrades(), false)) return null;
}
if (tis.stackSize == 0) {
clickSlot.putStack(null);
@@ -77,37 +73,32 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
}
}
protected void setupConfig()
{
protected void setupConfig() {
this.setupUpgrades();
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName( "config" );
final IInventory inv = Ae2Reflect.getUpgradeList(this).getInventoryByName("config");
final int y = 40;
final int x = 80;
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 0, x, y, 0, 0, 0 ) );
if( this.supportCapacity() )
{
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 1, x, y, -1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 2, x, y, 1, 0, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 3, x, y, 0, -1, 1 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 4, x, y, 0, 1, 1 ) );
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 0, x, y, 0, 0, 0));
if (this.supportCapacity()) {
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 1, x, y, -1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 2, x, y, 1, 0, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 3, x, y, 0, -1, 1));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 4, x, y, 0, 1, 1));
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 5, x, y, -1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 6, x, y, 1, -1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 7, x, y, -1, 1, 2 ) );
this.addSlotToContainer( new OptionalFluidSlotFakeTypeOnly( inv, null, this, 8, x, y, 1, 1, 2 ) );
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 5, x, y, -1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 6, x, y, 1, -1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 7, x, y, -1, 1, 2));
this.addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, null, this, 8, x, y, 1, 1, 2));
}
}
protected boolean isValidForConfig( int slot, IAEFluidStack fs )
{
if( this.supportCapacity() )
{
protected boolean isValidForConfig(int slot, IAEFluidStack fs) {
if (this.supportCapacity()) {
// assumes 4 slots per upgrade
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades( Upgrades.CAPACITY );
final int upgrades = Ae2Reflect.getUpgradeList(this).getInstalledUpgrades(Upgrades.CAPACITY);
if( slot > 0 && upgrades < 1 )
{
if (slot > 0 && upgrades < 1) {
return false;
}
return slot <= 4 || upgrades >= 2;
@@ -117,30 +108,25 @@ public abstract class ContainerFluidConfigurable extends ContainerUpgradeable {
}
@Override
protected void standardDetectAndSendChanges()
{
if( Platform.isServer() )
{
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 );
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 ))));
tmp.put(i, AEFluidStack.create(ItemFluidPacket.getFluidStack(inv.getStackInSlot(i))));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
super.standardDetectAndSendChanges();
}
}
@@ -31,6 +31,11 @@ import com.glodblock.github.util.Ae2Reflect;
import com.glodblock.github.util.BlockPos;
import com.glodblock.github.util.Util;
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -38,67 +43,58 @@ import net.minecraft.inventory.ICrafting;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;
import java.util.concurrent.Future;
public class ContainerFluidCraftConfirm extends AEBaseContainer {
private final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
private Future<ICraftingJob> job;
private ICraftingJob result;
@GuiSync( 0 )
@GuiSync(0)
public long bytesUsed;
@GuiSync( 1 )
@GuiSync(1)
public long cpuBytesAvail;
@GuiSync( 2 )
@GuiSync(2)
public int cpuCoProcessors;
@GuiSync( 3 )
@GuiSync(3)
public boolean autoStart = false;
@GuiSync( 4 )
@GuiSync(4)
public boolean simulation = true;
@GuiSync( 5 )
@GuiSync(5)
public int selectedCpu = -1;
@GuiSync( 6 )
@GuiSync(6)
public boolean noCPU = true;
@GuiSync( 7 )
@GuiSync(7)
public String myName = "";
public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
public ContainerFluidCraftConfirm(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
}
public void cycleCpu( final boolean next )
{
if( next )
{
this.setSelectedCpu( this.getSelectedCpu() + 1 );
}
else
{
this.setSelectedCpu( this.getSelectedCpu() - 1 );
public void cycleCpu(final boolean next) {
if (next) {
this.setSelectedCpu(this.getSelectedCpu() + 1);
} else {
this.setSelectedCpu(this.getSelectedCpu() - 1);
}
if( this.getSelectedCpu() < -1 )
{
this.setSelectedCpu( this.cpus.size() - 1 );
}
else if( this.getSelectedCpu() >= this.cpus.size() )
{
this.setSelectedCpu( -1 );
if (this.getSelectedCpu() < -1) {
this.setSelectedCpu(this.cpus.size() - 1);
} else if (this.getSelectedCpu() >= this.cpus.size()) {
this.setSelectedCpu(-1);
}
if( this.getSelectedCpu() == -1 )
{
this.setCpuAvailableBytes( 0 );
this.setCpuCoProcessors( 0 );
this.setName( "" );
}
else
{
if (this.getSelectedCpu() == -1) {
this.setCpuAvailableBytes(0);
this.setCpuCoProcessors(0);
this.setName("");
} else {
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
@@ -106,339 +102,286 @@ public class ContainerFluidCraftConfirm extends AEBaseContainer {
}
@Override
public void detectAndSendChanges()
{
if( Platform.isClient() )
{
public void detectAndSendChanges() {
if (Platform.isClient()) {
return;
}
if (getGrid() == null)
return;
if (getGrid() == null) return;
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
{
for (final ICraftingCPU c : cpuSet) {
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
if( Ae2Reflect.getCPU(ccr) == c )
{
for (final CraftingCPURecord ccr : this.cpus) {
if (Ae2Reflect.getCPU(ccr) == c) {
found = true;
}
}
final boolean matched = this.cpuMatches( c );
final boolean matched = this.cpuMatches(c);
if( matched )
{
if (matched) {
matches++;
}
if( found == !matched )
{
if (found == !matched) {
changed = true;
}
}
if( changed || this.cpus.size() != matches )
{
if (changed || this.cpus.size() != matches) {
this.cpus.clear();
for( final ICraftingCPU c : cpuSet )
{
if( this.cpuMatches( c ) )
{
this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
for (final ICraftingCPU c : cpuSet) {
if (this.cpuMatches(c)) {
this.cpus.add(new CraftingCPURecord(c.getAvailableStorage(), c.getCoProcessors(), c));
}
}
this.sendCPUs();
}
this.setNoCPU( this.cpus.isEmpty() );
this.setNoCPU(this.cpus.isEmpty());
super.detectAndSendChanges();
if( this.getJob() != null && this.getJob().isDone() )
{
try
{
if (this.getJob() != null && this.getJob().isDone()) {
try {
this.result = this.getJob().get();
if( !this.result.isSimulation() )
{
this.setSimulation( false );
if( this.isAutoStart() )
{
if (!this.result.isSimulation()) {
this.setSimulation(false);
if (this.isAutoStart()) {
this.startJob();
return;
}
}
else
{
this.setSimulation( true );
} else {
this.setSimulation(true);
}
final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate( (byte) 0 );
final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate( (byte) 1 );
final SPacketMEInventoryUpdate c = this.result.isSimulation() ? new SPacketMEInventoryUpdate( (byte) 2 ) : null;
final SPacketMEInventoryUpdate a = new SPacketMEInventoryUpdate((byte) 0);
final SPacketMEInventoryUpdate b = new SPacketMEInventoryUpdate((byte) 1);
final SPacketMEInventoryUpdate c =
this.result.isSimulation() ? new SPacketMEInventoryUpdate((byte) 2) : null;
final IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
this.result.populatePlan( plan );
this.result.populatePlan(plan);
this.setUsedBytes( this.result.getByteTotal() );
this.setUsedBytes(this.result.getByteTotal());
for( final IAEItemStack out : plan )
{
for (final IAEItemStack out : plan) {
IAEItemStack o = out.copy();
o.reset();
o.setStackSize( out.getStackSize() );
o.setStackSize(out.getStackSize());
final IAEItemStack p = out.copy();
p.reset();
p.setStackSize( out.getCountRequestable() );
p.setStackSize(out.getCountRequestable());
final IStorageGrid sg = this.getGrid().getCache( IStorageGrid.class );
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
final IMEInventory<IAEItemStack> items = sg.getItemInventory();
IAEItemStack m = null;
if( c != null && this.result.isSimulation() )
{
if (c != null && this.result.isSimulation()) {
m = o.copy();
o = items.extractItems( o, Actionable.SIMULATE, this.getActionSource() );
o = items.extractItems(o, Actionable.SIMULATE, this.getActionSource());
if( o == null )
{
if (o == null) {
o = m.copy();
o.setStackSize( 0 );
o.setStackSize(0);
}
m.setStackSize( m.getStackSize() - o.getStackSize() );
m.setStackSize(m.getStackSize() - o.getStackSize());
}
if( o.getStackSize() > 0 )
{
a.appendItem( o );
if (o.getStackSize() > 0) {
a.appendItem(o);
}
if( p.getStackSize() > 0 )
{
b.appendItem( p );
if (p.getStackSize() > 0) {
b.appendItem(p);
}
if( c != null && m != null && m.getStackSize() > 0 )
{
c.appendItem( m );
if (c != null && m != null && m.getStackSize() > 0) {
c.appendItem(m);
}
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
FluidCraft.proxy.netHandler.sendTo( a, (EntityPlayerMP) g );
FluidCraft.proxy.netHandler.sendTo( b, (EntityPlayerMP) g );
if( c != null )
{
FluidCraft.proxy.netHandler.sendTo( c, (EntityPlayerMP) g );
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(a, (EntityPlayerMP) g);
FluidCraft.proxy.netHandler.sendTo(b, (EntityPlayerMP) g);
if (c != null) {
FluidCraft.proxy.netHandler.sendTo(c, (EntityPlayerMP) g);
}
}
}
}
catch( final Throwable e )
{
this.getPlayerInv().player.addChatMessage( new ChatComponentText( "Error: " + e.toString() ) );
AELog.debug( e );
this.setValidContainer( false );
} catch (final Throwable e) {
this.getPlayerInv().player.addChatMessage(new ChatComponentText("Error: " + e.toString()));
AELog.debug(e);
this.setValidContainer(false);
this.result = null;
}
this.setJob( null );
this.setJob(null);
}
this.verifyPermissions( SecurityPermissions.CRAFT, false );
this.verifyPermissions(SecurityPermissions.CRAFT, false);
}
private IGrid getGrid()
{
final IActionHost h = ( (IActionHost) this.getTarget() );
if (h == null || h.getActionableNode() == null)
return null;
private IGrid getGrid() {
final IActionHost h = ((IActionHost) this.getTarget());
if (h == null || h.getActionableNode() == null) return null;
return h.getActionableNode().getGrid();
}
private boolean cpuMatches( final ICraftingCPU c )
{
private boolean cpuMatches(final ICraftingCPU c) {
return c.getAvailableStorage() >= this.getUsedBytes() && !c.isBusy();
}
private void sendCPUs()
{
Collections.sort( this.cpus );
private void sendCPUs() {
Collections.sort(this.cpus);
if( this.getSelectedCpu() >= this.cpus.size() )
{
this.setSelectedCpu( -1 );
this.setCpuAvailableBytes( 0 );
this.setCpuCoProcessors( 0 );
this.setName( "" );
}
else if( this.getSelectedCpu() != -1 )
{
if (this.getSelectedCpu() >= this.cpus.size()) {
this.setSelectedCpu(-1);
this.setCpuAvailableBytes(0);
this.setCpuCoProcessors(0);
this.setName("");
} else if (this.getSelectedCpu() != -1) {
this.setName(Ae2Reflect.getName(this.cpus.get(this.getSelectedCpu())));
this.setCpuAvailableBytes(Ae2Reflect.getSize(this.cpus.get(this.getSelectedCpu())));
this.setCpuCoProcessors(Ae2Reflect.getProcessors(this.cpus.get(this.getSelectedCpu())));
}
}
public void startJob()
{
public void startJob() {
GuiType originalGui = null;
final IActionHost ah = this.getActionHost();
if( ah instanceof PartFluidPatternTerminal)
{
if (ah instanceof PartFluidPatternTerminal) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL;
}
if( ah instanceof PartFluidPatternTerminalEx)
{
if (ah instanceof PartFluidPatternTerminalEx) {
originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
}
if( this.result != null && !this.isSimulation() && getGrid() != null)
{
final ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class );
final ICraftingLink g = cc.submitJob( this.result, null, this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())), true, this.getActionSrc() );
this.setAutoStart( false );
if( g != null && originalGui != null && this.getOpenContext() != null )
{
InventoryHandler.openGui(this.getInventoryPlayer().player, getWorld(), new BlockPos(this.getOpenContext().getTile()), Objects.requireNonNull(Util.from(this.getOpenContext().getSide())), originalGui);
if (this.result != null && !this.isSimulation() && getGrid() != null) {
final ICraftingGrid cc = this.getGrid().getCache(ICraftingGrid.class);
final ICraftingLink g = cc.submitJob(
this.result,
null,
this.getSelectedCpu() == -1 ? null : Ae2Reflect.getCPU(this.cpus.get(this.getSelectedCpu())),
true,
this.getActionSrc());
this.setAutoStart(false);
if (g != null && originalGui != null && this.getOpenContext() != null) {
InventoryHandler.openGui(
this.getInventoryPlayer().player,
getWorld(),
new BlockPos(this.getOpenContext().getTile()),
Objects.requireNonNull(Util.from(this.getOpenContext().getSide())),
originalGui);
}
}
}
private BaseActionSource getActionSrc()
{
return new PlayerSource( this.getPlayerInv().player, (IActionHost) this.getTarget() );
private BaseActionSource getActionSrc() {
return new PlayerSource(this.getPlayerInv().player, (IActionHost) this.getTarget());
}
@Override
public void removeCraftingFromCrafters( final ICrafting c )
{
super.removeCraftingFromCrafters( c );
if( this.getJob() != null )
{
this.getJob().cancel( true );
this.setJob( null );
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if (this.getJob() != null) {
this.getJob().cancel(true);
this.setJob(null);
}
}
@Override
public void onContainerClosed( final EntityPlayer par1EntityPlayer )
{
super.onContainerClosed( par1EntityPlayer );
if( this.getJob() != null )
{
this.getJob().cancel( true );
this.setJob( null );
public void onContainerClosed(final EntityPlayer par1EntityPlayer) {
super.onContainerClosed(par1EntityPlayer);
if (this.getJob() != null) {
this.getJob().cancel(true);
this.setJob(null);
}
}
public World getWorld()
{
public World getWorld() {
return this.getPlayerInv().player.worldObj;
}
public boolean isAutoStart()
{
public boolean isAutoStart() {
return this.autoStart;
}
public void setAutoStart( final boolean autoStart )
{
public void setAutoStart(final boolean autoStart) {
this.autoStart = autoStart;
}
public long getUsedBytes()
{
public long getUsedBytes() {
return this.bytesUsed;
}
private void setUsedBytes( final long bytesUsed )
{
private void setUsedBytes(final long bytesUsed) {
this.bytesUsed = bytesUsed;
}
public long getCpuAvailableBytes()
{
public long getCpuAvailableBytes() {
return this.cpuBytesAvail;
}
private void setCpuAvailableBytes( final long cpuBytesAvail )
{
private void setCpuAvailableBytes(final long cpuBytesAvail) {
this.cpuBytesAvail = cpuBytesAvail;
}
public int getCpuCoProcessors()
{
public int getCpuCoProcessors() {
return this.cpuCoProcessors;
}
private void setCpuCoProcessors( final int cpuCoProcessors )
{
private void setCpuCoProcessors(final int cpuCoProcessors) {
this.cpuCoProcessors = cpuCoProcessors;
}
public int getSelectedCpu()
{
public int getSelectedCpu() {
return this.selectedCpu;
}
private void setSelectedCpu( final int selectedCpu )
{
private void setSelectedCpu(final int selectedCpu) {
this.selectedCpu = selectedCpu;
}
public String getName()
{
public String getName() {
return this.myName;
}
private void setName( @Nonnull final String myName )
{
private void setName(@Nonnull final String myName) {
this.myName = myName;
}
public boolean hasNoCPU()
{
public boolean hasNoCPU() {
return this.noCPU;
}
private void setNoCPU( final boolean noCPU )
{
private void setNoCPU(final boolean noCPU) {
this.noCPU = noCPU;
}
public boolean isSimulation()
{
public boolean isSimulation() {
return this.simulation;
}
private void setSimulation( final boolean simulation )
{
private void setSimulation(final boolean simulation) {
this.simulation = simulation;
}
private Future<ICraftingJob> getJob()
{
private Future<ICraftingJob> getJob() {
return this.job;
}
public void setJob( final Future<ICraftingJob> job )
{
public void setJob(final Future<ICraftingJob> job) {
this.job = job;
}
}
@@ -9,13 +9,11 @@ import com.glodblock.github.common.parts.PartSharedFluidBus;
import com.glodblock.github.util.Ae2Reflect;
import net.minecraft.entity.player.InventoryPlayer;
public class ContainerFluidIO extends ContainerFluidConfigurable
{
public class ContainerFluidIO extends ContainerFluidConfigurable {
private final PartSharedFluidBus bus;
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te )
{
super( ip, te );
public ContainerFluidIO(InventoryPlayer ip, PartSharedFluidBus te) {
super(ip, te);
this.bus = te;
}
@@ -32,7 +30,7 @@ public class ContainerFluidIO extends ContainerFluidConfigurable
protected void loadSettingsFromHost(IConfigManager cm) {
super.loadSettingsFromHost(cm);
if (Ae2Reflect.getUpgradeableHost(this) instanceof PartFluidExportBus) {
this.setCraftingMode((YesNo)cm.getSetting(Settings.CRAFT_ONLY));
this.setCraftingMode((YesNo) cm.getSetting(Settings.CRAFT_ONLY));
}
}
}
@@ -10,14 +10,13 @@ import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFakeTypeOnly;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
public class ContainerFluidInterface extends AEBaseContainer implements IOptionalSlotHost {
private final Object tile;
@@ -29,7 +28,8 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(
inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
@@ -41,7 +41,8 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
final int y = 35;
final int x = 35;
for (int i = 0; i < 6; i++) {
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
addSlotToContainer(new OptionalFluidSlotFakeTypeOnly(
inv, tile.getDualityFluid().getConfig(), this, i, x, y, i, 0, 0));
}
bindPlayerInventory(ipl, 0, 149);
}
@@ -60,29 +61,31 @@ public class ContainerFluidInterface extends AEBaseContainer implements IOptiona
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
if (tile instanceof TileFluidInterface) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
for (int i = 0; i < ((TileFluidInterface) tile).getInternalFluid().getSlots(); i++) {
tmp.put(i, ((TileFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((TileFluidInterface) tile).getConfig().getStackInSlot( i ))));
for (int i = 0; i < ((TileFluidInterface) tile).getConfig().getSizeInventory(); i++) {
tmp.put(
i + 100,
AEFluidStack.create(ItemFluidPacket.getFluidStack(
((TileFluidInterface) tile).getConfig().getStackInSlot(i))));
}
}
else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i ++) {
} else {
for (int i = 0; i < ((PartFluidInterface) tile).getInternalFluid().getSlots(); i++) {
tmp.put(i, ((PartFluidInterface) tile).getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i ++) {
tmp.put(i + 100, AEFluidStack.create(ItemFluidPacket.getFluidStack(((PartFluidInterface) tile).getConfig().getStackInSlot( i ))));
for (int i = 0; i < ((PartFluidInterface) tile).getConfig().getSizeInventory(); i++) {
tmp.put(
i + 100,
AEFluidStack.create(ItemFluidPacket.getFluidStack(
((PartFluidInterface) tile).getConfig().getStackInSlot(i))));
}
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -1,12 +1,12 @@
package com.glodblock.github.client.gui.container;
import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET;
import appeng.container.AEBaseContainer;
import com.glodblock.github.common.tile.TileFluidPacketDecoder;
import com.glodblock.github.inventory.slot.FCSlotRestrictedInput;
import net.minecraft.entity.player.InventoryPlayer;
import static com.glodblock.github.loader.ItemAndBlockHolder.PACKET;
public class ContainerFluidPacketDecoder extends AEBaseContainer {
public ContainerFluidPacketDecoder(InventoryPlayer ipl, TileFluidPacketDecoder tile) {
@@ -14,5 +14,4 @@ public class ContainerFluidPacketDecoder extends AEBaseContainer {
addSlotToContainer(new FCSlotRestrictedInput(PACKET.stack(), tile.getInventory(), 0, 80, 35, ipl));
bindPlayerInventory(ipl, 0, 84);
}
}
@@ -18,6 +18,10 @@ import com.glodblock.github.inventory.slot.SlotFluid;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.FluidPatternDetails;
import com.glodblock.github.util.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
@@ -26,11 +30,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ContainerFluidPatternEncoder extends AEBaseContainer implements PatternConsumer {
private final TileFluidPatternEncoder tile;
@@ -47,9 +46,9 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
addSlotToContainer(new SlotFluidConvertingFake(output, y, 113, 17 + y * 18));
}
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl));
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, tile.getInventory(), 0, 138, 20, ipl));
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl));
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, tile.getInventory(), 1, 138, 50, ipl));
bindPlayerInventory(ipl, 0, 84);
}
@@ -57,8 +56,15 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
return tile;
}
private static boolean isNotPattern(ItemStack stack) {
return stack == null
|| !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public boolean canEncodePattern() {
if (isNotPattern(tile.getInventory().getStackInSlot(0)) && isNotPattern(tile.getInventory().getStackInSlot(1))) {
if (isNotPattern(tile.getInventory().getStackInSlot(0))
&& isNotPattern(tile.getInventory().getStackInSlot(1))) {
return false;
}
find_input:
@@ -78,11 +84,6 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
return false;
}
private static boolean isNotPattern(ItemStack stack) {
return stack == null || !(AEApi.instance().definitions().materials().blankPattern().isSameAs(stack)
|| (stack.getItem() instanceof ItemFluidEncodedPattern));
}
public void encodePattern() {
if (canEncodePattern()) {
// if there is an encoded pattern, overwrite it; otherwise, consume a blank
@@ -126,12 +127,13 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
if (stack == null) {
slot.putStack(null);
} else {
((SlotFluidConvertingFake)slot).putConvertedStack(stack.copy());
((SlotFluidConvertingFake) slot).putConvertedStack(stack.copy());
}
break;
case PLACE_SINGLE:
if (stack != null) {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
case SPLIT_OR_PLACE_SINGLE:
@@ -140,13 +142,15 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
if (stack == null) {
slot.putStack(Util.copyStackWithSize(inSlot, Math.max(1, inSlot.stackSize - 1)));
} else if (stack.isItemEqual(inSlot)) {
slot.putStack(Util.copyStackWithSize(inSlot,
Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1)));
slot.putStack(Util.copyStackWithSize(
inSlot, Math.min(inSlot.getMaxStackSize(), inSlot.stackSize + 1)));
} else {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
} else if (stack != null) {
((SlotFluidConvertingFake)slot).putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
((SlotFluidConvertingFake) slot)
.putConvertedStack(Objects.requireNonNull(Util.copyStackWithSize(stack, 1)));
}
break;
}
@@ -220,7 +224,5 @@ public class ContainerFluidPatternEncoder extends AEBaseContainer implements Pat
public IAEItemStack getAeStack() {
return inv.getStack(getSlotIndex());
}
}
}
@@ -31,15 +31,27 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
super(ip, monitorable);
}
public void encodeAllItemAndMoveToInventory(){
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output)
|| defs.materials().blankPattern().isSameAs(output);
}
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
}
@@ -59,7 +71,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize --;
stack.stackSize--;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
@@ -67,17 +79,6 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
}
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
if (this.craftingMode) {
return false;
@@ -119,7 +120,7 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
}
@@ -174,7 +175,8 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs)
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
@@ -204,7 +206,10 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null && !patternSlotOUT.getHasStack() && is.stackSize == 1 && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
if (is != null
&& !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
@@ -30,15 +30,27 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
super(ip, monitorable);
}
public void encodeAllItemAndMoveToInventory(){
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output)
|| defs.materials().blankPattern().isSameAs(output);
}
public void encodeAllItemAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if(output != null){
if(this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory( output )){
if (output != null) {
if (this.patternSlotIN.getStack() != null) output.stackSize += this.patternSlotIN.getStack().stackSize;
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotOUT.putStack(null);
this.patternSlotIN.putStack(null);
}
}
@@ -58,7 +70,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
if (stack.stackSize == 1) {
this.patternSlotIN.putStack(null);
} else {
stack.stackSize --;
stack.stackSize--;
}
encodeFluidPattern();
} else if (isPattern(stack)) {
@@ -66,17 +78,6 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
}
}
private static boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
return true;
}
final IDefinitions defs = AEApi.instance().definitions();
return defs.items().encodedPattern().isSameAs(output) || defs.materials().blankPattern().isSameAs(output);
}
private boolean checkHasFluidPattern() {
boolean hasFluid = false, search = false;
for (Slot craftingSlot : this.craftingSlots) {
@@ -113,10 +114,10 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
private void encodeFluidPattern() {
ItemStack patternStack = new ItemStack(ItemAndBlockHolder.PATTERN);
FluidPatternDetails pattern = new FluidPatternDetails(patternStack);
pattern.setCombine(this.combine ? 1:0);
pattern.setCombine(this.combine ? 1 : 0);
pattern.setInputs(collectInventory(craftingSlots));
pattern.setOutputs(collectInventory(outputSlots));
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
// pattern.setCanBeSubstitute(this.beSubstitute ? 1 : 0);
patternSlotOUT.putStack(pattern.writeToStack());
}
@@ -167,7 +168,9 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof OptionalSlotFake) && stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if ((slot instanceof OptionalSlotFake)
&& stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
@@ -202,7 +205,10 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
public ItemStack transferStackInSlot(EntityPlayer p, int idx) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
ItemStack is = clickSlot.getStack();
if (is != null && !patternSlotOUT.getHasStack() && is.stackSize == 1 && (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
if (is != null
&& !patternSlotOUT.getHasStack()
&& is.stackSize == 1
&& (is.getItem() instanceof ItemFluidEncodedPattern || is.getItem() instanceof ItemEncodedPattern)) {
ItemStack output = is.copy();
patternSlotOUT.putStack(output);
p.inventory.setInventorySlotContents(clickSlot.getSlotIndex(), null);
@@ -7,14 +7,13 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
public class ContainerIngredientBuffer extends AEBaseContainer implements TankDumpable {
private final TileIngredientBuffer tile;
@@ -46,17 +45,14 @@ public class ContainerIngredientBuffer extends AEBaseContainer implements TankDu
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) {
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
@@ -7,14 +7,13 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.TankDumpable;
import com.glodblock.github.common.tile.TileLargeIngredientBuffer;
import com.glodblock.github.network.SPacketFluidUpdate;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import java.util.HashMap;
import java.util.Map;
public class ContainerLargeIngredientBuffer extends AEBaseContainer implements TankDumpable {
private final TileLargeIngredientBuffer tile;
@@ -48,20 +47,16 @@ public class ContainerLargeIngredientBuffer extends AEBaseContainer implements T
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
for (int i = 0; i < tile.getFluidInventory().getSlots(); i ++) {
for (int i = 0; i < tile.getFluidInventory().getSlots(); i++) {
tmp.put(i, tile.getFluidInventory().getFluidInSlot(i));
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer)
{
for (final Object g : this.crafters) {
if (g instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(tmp), (EntityPlayerMP) g);
}
}
}
}
@@ -9,7 +9,6 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerLevelMaintainer extends AEBaseContainer {
private final TileLevelMaintainer tile;
private final FakeSlot[] requestSlots = new FakeSlot[TileLevelMaintainer.REQ_COUNT];
@@ -9,15 +9,17 @@ public class ContainerOCPatternEditor extends AEBaseContainer {
public ContainerOCPatternEditor(InventoryPlayer ipl, TileOCPatternEditor tile) {
super(ipl, tile);
for (int i = 0; i < 4; i ++) {
for (int j = 0; j < 4; j ++) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
addSlotToContainer(new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.PATTERN, tile.getInternalInventory(),
j * 4 + i, 55 + i * 18, 17 + j * 18, ipl
));
SlotRestrictedInput.PlacableItemType.PATTERN,
tile.getInternalInventory(),
j * 4 + i,
55 + i * 18,
17 + j * 18,
ipl));
}
}
bindPlayerInventory(ipl, 0, 104);
}
}
@@ -10,36 +10,30 @@ import net.minecraft.inventory.Slot;
public class ContainerPatternValueAmount extends AEBaseContainer {
private final Slot patternValue;
private int valueIndex;
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
this.patternValue = new SlotInaccessible( new AppEngInternalInventory( null, 1 ), 0, 34, 53 );
this.addSlotToContainer( patternValue );
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) {
super(ip, te);
this.patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
this.addSlotToContainer(patternValue);
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
this.verifyPermissions( SecurityPermissions.CRAFT, false );
this.verifyPermissions(SecurityPermissions.CRAFT, false);
}
public Slot getPatternValue()
{
public Slot getPatternValue() {
return patternValue;
}
public int getValueIndex()
{
public int getValueIndex() {
return valueIndex;
}
public void setValueIndex( int valueIndex )
{
public void setValueIndex(int valueIndex) {
this.valueIndex = valueIndex;
}
}
@@ -41,6 +41,11 @@ import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.network.SPacketFluidUpdate;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import com.glodblock.github.util.Util;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -53,22 +58,20 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.apache.commons.lang3.tuple.MutablePair;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
import java.util.HashMap;
import java.util.Map;
public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
public class FCBaseFluidMonitorContain extends AEBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEFluidStack> monitor;
private final IItemList<IAEFluidStack> items = AEApi.instance().storage().createFluidList();
private final IConfigManager clientCM;
private final ITerminalHost host;
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync(98)
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
@@ -77,8 +80,12 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
this(ip, monitorable, true);
}
protected FCBaseFluidMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null);
protected FCBaseFluidMonitorContain(
final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(
ip,
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
monitorable instanceof IPart ? (IPart) monitorable : null);
this.host = monitorable;
this.clientCM = new ConfigManager(this);
@@ -92,7 +99,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
if (this.monitor != null) {
this.monitor.addListener(this, null);
// this.setCellInventory( this.monitor );
// this.setCellInventory( this.monitor );
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
@@ -118,7 +125,13 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
this.canAccessViewCells = false;
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.VIEW_CELL, ((IViewCellStorage) monitorable).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer());
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
@@ -137,7 +150,9 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
public ItemStack transferStackInSlot(final EntityPlayer p, final int idx) {
if (Platform.isClient()) {
Slot clickSlot = (Slot) this.inventorySlots.get(idx);
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar) && clickSlot.getHasStack() && Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
if ((clickSlot instanceof SlotPlayerInv || clickSlot instanceof SlotPlayerHotBar)
&& clickSlot.getHasStack()
&& Util.FluidUtil.isFluidContainer(clickSlot.getStack())) {
ItemStack tis = clickSlot.getStack();
Map<Integer, IAEFluidStack> tmp = new HashMap<>();
tmp.put(0, ItemFluidDrop.getAeFluidStack(AEItemStack.create(tis)));
@@ -163,7 +178,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
@@ -201,8 +217,7 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject
|| this.hasAccess(SecurityPermissions.BUILD, false);
this.host instanceof WirelessTerminalGuiObject || this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
@@ -221,7 +236,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
} else if (this.getPowerSource() instanceof IEnergyGrid) {
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
} else {
this.setPowered(this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
this.setPowered(
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
} catch (final Throwable t) {
// :P
@@ -318,7 +334,8 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
}
@Override
public void postChange(IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
public void postChange(
IBaseMonitor<IAEFluidStack> monitor, Iterable<IAEFluidStack> change, BaseActionSource actionSource) {
for (final IAEFluidStack is : change) {
this.items.add(is);
}
@@ -352,26 +369,33 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
this.dropItem(is);
}
public void postChange(Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) {
public void postChange(
Iterable<IAEFluidStack> change, ItemStack fluidContainer, EntityPlayer player, int slotIndex) {
for (IAEFluidStack fluid : change) {
IAEFluidStack nfluid = this.monitor.getStorageList().findPrecise(fluid);
ItemStack out = fluidContainer.copy();
out.stackSize = 1;
if (Util.FluidUtil.isEmpty(fluidContainer) && fluid != null) {
// add fluid to tanks
// add fluid to tanks
if (nfluid.getStackSize() <= 0) continue;
final IAEFluidStack toExtract = nfluid.copy();
MutablePair<Integer, ItemStack> fillStack = Util.FluidUtil.fillStack(out, toExtract.getFluidStack());
if (fillStack.right == null || fillStack.left <= 0) continue;
toExtract.setStackSize((long) fillStack.left * fluidContainer.stackSize);
IAEFluidStack tmp = this.host.getFluidInventory().extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
IAEFluidStack tmp = this.host
.getFluidInventory()
.extractItems(toExtract, Actionable.SIMULATE, this.getActionSource());
fillStack.right.stackSize = (int) (tmp.getStackSize() / fillStack.left);
this.dropItem(fillStack.right);
out.stackSize = fillStack.right.stackSize;
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);
((IFluidContainerItem) fillStack.right.getItem())
.drain(
fillStack.right,
fillStack.left - (int) (tmp.getStackSize() % fillStack.left),
true);
this.dropItem(fillStack.right, 1);
out.stackSize++;
}
@@ -380,34 +404,44 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
this.host.getFluidInventory().extractItems(toExtract, Actionable.MODULATE, this.getActionSource());
}
} else if (!Util.FluidUtil.isEmpty(fluidContainer)) {
// add fluid to ae network
// add fluid to ae network
AEFluidStack fluidStack = Util.getAEFluidFromItem(fluidContainer);
final IAEFluidStack aeFluidStack = fluidStack.copy();
// simulate result is incorrect. so I'm using other solution and ec2 both mod have same issues
final IAEFluidStack notInserted = this.host.getFluidInventory().injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack = Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack());
final IAEFluidStack notInserted = this.host
.getFluidInventory()
.injectItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
MutablePair<Integer, ItemStack> drainStack =
Util.FluidUtil.drainStack(out.copy(), aeFluidStack.getFluidStack());
if (notInserted != null && notInserted.getStackSize() > 0) {
if (fluidStack.getStackSize() == notInserted.getStackSize()) continue;
aeFluidStack.decStackSize(notInserted.getStackSize());
if (drainStack.left > aeFluidStack.getStackSize() && FluidContainerRegistry.isContainer(drainStack.right)) {
if (drainStack.left > aeFluidStack.getStackSize()
&& FluidContainerRegistry.isContainer(drainStack.right)) {
aeFluidStack.setStackSize(drainStack.left - aeFluidStack.getStackSize());
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
this.host
.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
continue;
}
this.dropItem(drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item
this.dropItem(
drainStack.right, (int) (aeFluidStack.getStackSize() / drainStack.left)); // drop empty item
out.stackSize = (int) (notInserted.getStackSize() / drainStack.left);
if (drainStack.right.getItem() instanceof IFluidContainerItem) {
if (notInserted.getStackSize() % drainStack.left > 0) {
fluidStack.setStackSize((notInserted.getStackSize() % drainStack.left));
((IFluidContainerItem) drainStack.right.getItem()).fill(drainStack.right, fluidStack.getFluidStack(), true);
((IFluidContainerItem) drainStack.right.getItem())
.fill(drainStack.right, fluidStack.getFluidStack(), true);
this.dropItem(drainStack.right, 1);
}
} else if (FluidContainerRegistry.isContainer(drainStack.right)) {
if (notInserted.getStackSize() % drainStack.left > 0) {
aeFluidStack.setStackSize(aeFluidStack.getStackSize() % drainStack.left);
this.host.getFluidInventory().extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
this.host
.getFluidInventory()
.extractItems(aeFluidStack, Actionable.MODULATE, this.getActionSource());
out.stackSize++;
}
}
@@ -423,10 +457,13 @@ public class FCBaseFluidMonitorContain extends AEBaseContainer implements IConfi
if (slotIndex == -1) {
player.inventory.getItemStack().stackSize = player.inventory.getItemStack().stackSize - out.stackSize;
if (player.inventory.getItemStack().stackSize > 0) {
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()), (EntityPlayerMP) player);
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>(), player.inventory.getItemStack()),
(EntityPlayerMP) player);
} else {
player.inventory.setItemStack(null);
FluidCraft.proxy.netHandler.sendTo(new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
FluidCraft.proxy.netHandler.sendTo(
new SPacketFluidUpdate(new HashMap<>()), (EntityPlayerMP) player);
}
} else {
player.inventory.setInventorySlotContents(slotIndex, out.stackSize > 0 ? out : null);
@@ -33,6 +33,9 @@ import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.network.SPacketMEInventoryUpdate;
import java.io.IOException;
import java.nio.BufferOverflowException;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -41,167 +44,142 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.BufferOverflowException;
public class FCBaseMonitorContain extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack>
{
public class FCBaseMonitorContain extends AEBaseContainer
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = AEApi.instance().storage().createItemList();
private final IConfigManager clientCM;
private final ITerminalHost host;
@GuiSync( 99 )
@GuiSync(99)
public boolean canAccessViewCells = false;
@GuiSync( 98 )
@GuiSync(98)
public boolean hasPower = false;
private IConfigManagerHost gui;
private IConfigManager serverCM;
private IGridNode networkNode;
public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable )
{
this( ip, monitorable, true );
public FCBaseMonitorContain(final InventoryPlayer ip, final ITerminalHost monitorable) {
this(ip, monitorable, true);
}
protected FCBaseMonitorContain( final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory )
{
super( ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null );
protected FCBaseMonitorContain(
final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
super(
ip,
monitorable instanceof TileEntity ? (TileEntity) monitorable : null,
monitorable instanceof IPart ? (IPart) monitorable : null);
this.host = monitorable;
this.clientCM = new ConfigManager( this );
this.clientCM = new ConfigManager(this);
this.clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
this.clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
this.clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
this.clientCM.registerSetting(Settings.SORT_BY, SortOrder.NAME);
this.clientCM.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
this.clientCM.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
if( Platform.isServer() )
{
if (Platform.isServer()) {
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable.getItemInventory();
if( this.monitor != null )
{
this.monitor.addListener( this, null );
if (this.monitor != null) {
this.monitor.addListener(this, null);
this.setCellInventory( this.monitor );
this.setCellInventory(this.monitor);
if( monitorable instanceof IPortableCell)
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IMEChest)
{
this.setPowerSource( (IEnergySource) monitorable );
}
else if( monitorable instanceof IGridHost)
{
final IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN );
if( node != null )
{
if (monitorable instanceof IPortableCell) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IMEChest) {
this.setPowerSource((IEnergySource) monitorable);
} else if (monitorable instanceof IGridHost) {
final IGridNode node = ((IGridHost) monitorable).getGridNode(ForgeDirection.UNKNOWN);
if (node != null) {
this.networkNode = node;
final IGrid g = node.getGrid();
if( g != null )
{
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
if (g != null) {
this.setPowerSource(new ChannelPowerSrc(
this.networkNode, (IEnergySource) g.getCache(IEnergyGrid.class)));
}
}
}
} else {
this.setValidContainer(false);
}
else
{
this.setValidContainer( false );
}
}
else
{
} else {
this.monitor = null;
}
this.canAccessViewCells = false;
if( monitorable instanceof IViewCellStorage)
{
for( int y = 0; y < 5; y++ )
{
this.cellView[y] = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.VIEW_CELL, ( (IViewCellStorage) monitorable ).getViewCellStorage(), y, 206, y * 18 + 8, this.getInventoryPlayer() );
this.cellView[y].setAllowEdit( this.canAccessViewCells );
this.addSlotToContainer( this.cellView[y] );
if (monitorable instanceof IViewCellStorage) {
for (int y = 0; y < 5; y++) {
this.cellView[y] = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.VIEW_CELL,
((IViewCellStorage) monitorable).getViewCellStorage(),
y,
206,
y * 18 + 8,
this.getInventoryPlayer());
this.cellView[y].setAllowEdit(this.canAccessViewCells);
this.addSlotToContainer(this.cellView[y]);
}
}
if( bindInventory )
{
this.bindPlayerInventory( ip, 0, 0 );
if (bindInventory) {
this.bindPlayerInventory(ip, 0, 0);
}
}
public IGridNode getNetworkNode()
{
public IGridNode getNetworkNode() {
return this.networkNode;
}
@Override
public void detectAndSendChanges()
{
if( Platform.isServer() )
{
if( this.monitor != this.host.getItemInventory() )
{
this.setValidContainer( false );
public void detectAndSendChanges() {
if (Platform.isServer()) {
if (this.monitor != this.host.getItemInventory()) {
this.setValidContainer(false);
}
for( final Settings set : this.serverCM.getSettings() )
{
final Enum<?> sideLocal = this.serverCM.getSetting( set );
final Enum<?> sideRemote = this.clientCM.getSetting( set );
for (final Settings set : this.serverCM.getSettings()) {
final Enum<?> sideLocal = this.serverCM.getSetting(set);
final Enum<?> sideRemote = this.clientCM.getSetting(set);
if( sideLocal != sideRemote )
{
this.clientCM.putSetting( set, sideLocal );
for( final Object crafter : this.crafters )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) crafter );
}
catch( final IOException e )
{
AELog.debug( e );
if (sideLocal != sideRemote) {
this.clientCM.putSetting(set, sideLocal);
for (final Object crafter : this.crafters) {
try {
NetworkHandler.instance.sendTo(
new PacketValueConfig(set.name(), sideLocal.name()), (EntityPlayerMP) crafter);
} catch (final IOException e) {
AELog.debug(e);
}
}
}
}
if( !this.items.isEmpty() )
{
if (!this.items.isEmpty()) {
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
final SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
for( final IAEItemStack is : this.items )
{
final IAEItemStack send = monitorCache.findPrecise( is );
if( send == null )
{
is.setStackSize( 0 );
piu.appendItem( is );
}
else
{
piu.appendItem( send );
for (final IAEItemStack is : this.items) {
final IAEItemStack send = monitorCache.findPrecise(is);
if (send == null) {
is.setStackSize(0);
piu.appendItem(is);
} else {
piu.appendItem(send);
}
}
if( !piu.isEmpty() )
{
if (!piu.isEmpty()) {
this.items.resetStatus();
for( final Object c : this.crafters )
{
if( c instanceof EntityPlayer)
{
for (final Object c : this.crafters) {
if (c instanceof EntityPlayer) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
@@ -212,15 +190,11 @@ public class FCBaseMonitorContain extends AEBaseContainer implements IConfigMana
final boolean oldAccessible = this.canAccessViewCells;
this.canAccessViewCells =
this.host instanceof WirelessTerminalGuiObject
|| this.hasAccess( SecurityPermissions.BUILD, false );
if( this.canAccessViewCells != oldAccessible )
{
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].setAllowEdit( this.canAccessViewCells );
this.host instanceof WirelessTerminalGuiObject || this.hasAccess(SecurityPermissions.BUILD, false);
if (this.canAccessViewCells != oldAccessible) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
@@ -229,180 +203,143 @@ public class FCBaseMonitorContain extends AEBaseContainer implements IConfigMana
}
}
protected void updatePowerStatus()
{
try
{
if( this.networkNode != null )
{
this.setPowered( this.networkNode.isActive() );
protected void updatePowerStatus() {
try {
if (this.networkNode != null) {
this.setPowered(this.networkNode.isActive());
} else if (this.getPowerSource() instanceof IEnergyGrid) {
this.setPowered(((IEnergyGrid) this.getPowerSource()).isNetworkPowered());
} else {
this.setPowered(
this.getPowerSource().extractAEPower(1, Actionable.SIMULATE, PowerMultiplier.CONFIG) > 0.8);
}
else if( this.getPowerSource() instanceof IEnergyGrid )
{
this.setPowered( ( (IEnergyGrid) this.getPowerSource() ).isNetworkPowered() );
}
else
{
this.setPowered( this.getPowerSource().extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8 );
}
}
catch( final Throwable t )
{
} catch (final Throwable t) {
// :P
}
}
@Override
public void onUpdate( final String field, final Object oldValue, final Object newValue )
{
if( field.equals( "canAccessViewCells" ) )
{
for( int y = 0; y < 5; y++ )
{
if( this.cellView[y] != null )
{
this.cellView[y].setAllowEdit( this.canAccessViewCells );
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
if (field.equals("canAccessViewCells")) {
for (int y = 0; y < 5; y++) {
if (this.cellView[y] != null) {
this.cellView[y].setAllowEdit(this.canAccessViewCells);
}
}
}
super.onUpdate( field, oldValue, newValue );
super.onUpdate(field, oldValue, newValue);
}
@Override
public void addCraftingToCrafters( final ICrafting c )
{
super.addCraftingToCrafters( c );
this.queueInventory( c );
public void addCraftingToCrafters(final ICrafting c) {
super.addCraftingToCrafters(c);
this.queueInventory(c);
}
private void queueInventory( final ICrafting c )
{
if( Platform.isServer() && c instanceof EntityPlayer && this.monitor != null )
{
private void queueInventory(final ICrafting c) {
if (Platform.isServer() && c instanceof EntityPlayer && this.monitor != null) {
SPacketMEInventoryUpdate piu = new SPacketMEInventoryUpdate();
final IItemList<IAEItemStack> monitorCache = this.monitor.getStorageList();
for( final IAEItemStack send : monitorCache )
{
try
{
piu.appendItem( send );
}
catch( final BufferOverflowException boe )
{
FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c );
for (final IAEItemStack send : monitorCache) {
try {
piu.appendItem(send);
} catch (final BufferOverflowException boe) {
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
piu = new SPacketMEInventoryUpdate();
piu.appendItem( send );
piu.appendItem(send);
}
}
FluidCraft.proxy.netHandler.sendTo( piu, (EntityPlayerMP) c );
FluidCraft.proxy.netHandler.sendTo(piu, (EntityPlayerMP) c);
}
}
@Override
public void removeCraftingFromCrafters( final ICrafting c )
{
super.removeCraftingFromCrafters( c );
public void removeCraftingFromCrafters(final ICrafting c) {
super.removeCraftingFromCrafters(c);
if( this.crafters.isEmpty() && this.monitor != null )
{
this.monitor.removeListener( this );
if (this.crafters.isEmpty() && this.monitor != null) {
this.monitor.removeListener(this);
}
}
@Override
public void onContainerClosed( final EntityPlayer player )
{
super.onContainerClosed( player );
if( this.monitor != null )
{
this.monitor.removeListener( this );
public void onContainerClosed(final EntityPlayer player) {
super.onContainerClosed(player);
if (this.monitor != null) {
this.monitor.removeListener(this);
}
}
@Override
public boolean isValid( final Object verificationToken )
{
public boolean isValid(final Object verificationToken) {
return true;
}
@Override
public void postChange(final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource source )
{
for( final IAEItemStack is : change )
{
this.items.add( is );
public void postChange(
final IBaseMonitor<IAEItemStack> monitor,
final Iterable<IAEItemStack> change,
final BaseActionSource source) {
for (final IAEItemStack is : change) {
this.items.add(is);
}
}
@Override
public void onListUpdate()
{
for( final Object c : this.crafters )
{
if( c instanceof ICrafting )
{
public void onListUpdate() {
for (final Object c : this.crafters) {
if (c instanceof ICrafting) {
final ICrafting cr = (ICrafting) c;
this.queueInventory( cr );
this.queueInventory(cr);
}
}
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
{
if( this.getGui() != null )
{
this.getGui().updateSetting( manager, settingName, newValue );
public void updateSetting(final IConfigManager manager, final Enum settingName, final Enum newValue) {
if (this.getGui() != null) {
this.getGui().updateSetting(manager, settingName, newValue);
}
}
@Override
public IConfigManager getConfigManager()
{
if( Platform.isServer() )
{
public IConfigManager getConfigManager() {
if (Platform.isServer()) {
return this.serverCM;
}
return this.clientCM;
}
public ItemStack[] getViewCells()
{
public ItemStack[] getViewCells() {
final ItemStack[] list = new ItemStack[this.cellView.length];
for( int x = 0; x < this.cellView.length; x++ )
{
for (int x = 0; x < this.cellView.length; x++) {
list[x] = this.cellView[x].getStack();
}
return list;
}
public SlotRestrictedInput getCellViewSlot( final int index )
{
public SlotRestrictedInput getCellViewSlot(final int index) {
return this.cellView[index];
}
public boolean isPowered()
{
public boolean isPowered() {
return this.hasPower;
}
private void setPowered( final boolean isPowered )
{
private void setPowered(final boolean isPowered) {
this.hasPower = isPowered;
}
private IConfigManagerHost getGui()
{
private IConfigManagerHost getGui() {
return this.gui;
}
public void setGui( @Nonnull final IConfigManagerHost gui )
{
public void setGui(@Nonnull final IConfigManagerHost gui) {
this.gui = gui;
}
}
@@ -25,6 +25,11 @@ 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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
@@ -38,32 +43,30 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
public class FCBasePartContainer extends FCBaseMonitorContain
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private final PartFluidPatternTerminal patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final AppEngInternalInventory cOut = new AppEngInternalInventory(null, 1);
private final IInventory crafting;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
protected final SlotPatternTerm craftSlot;
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync(97)
public boolean craftingMode = true;
@GuiSync(96)
public boolean substitute = false;
@GuiSync(95)
public boolean combine = false;
@GuiSync(94)
public boolean beSubstitute = false;
public FCBasePartContainer(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable, false);
this.patternTerminal = (PartFluidPatternTerminal) monitorable;
@@ -71,153 +74,228 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
final IInventory patternInv = this.getPatternTerminal().getInventoryByName("pattern");
final IInventory output = this.getPatternTerminal().getInventoryByName("output");
this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" );
this.crafting = this.getPatternTerminal().getInventoryByName("crafting");
for( int y = 0; y < 3; y++ )
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) );
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
this.addSlotToContainer(
this.craftingSlots[x + y * 3] =
new SlotFakeCraftingMatrix(this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18));
}
}
this.addSlotToContainer( this.craftSlot = new SlotPatternTerm( ip.player, this.getActionSource(), this.getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) );
this.craftSlot.setIIcon( -1 );
this.addSlotToContainer(
this.craftSlot = new SlotPatternTerm(
ip.player,
this.getActionSource(),
this.getPowerSource(),
monitorable,
this.crafting,
patternInv,
this.cOut,
110,
-76 + 18,
this,
2,
this));
this.craftSlot.setIIcon(-1);
for( int y = 0; y < 3; y++ )
{
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 110, -76 + y * 18, 0, 0, 1 ) );
this.outputSlots[y].setRenderDisabled( false );
for (int y = 0; y < 3; y++) {
this.addSlotToContainer(
this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false);
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
patternInv,
0,
147,
-72 - 9,
this.getInventoryPlayer()));
this.addSlotToContainer(
this.patternSlotOUT = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
patternInv,
1,
147,
-72 + 34,
this.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit( 1 );
this.patternSlotOUT.setStackLimit(1);
this.bindPlayerInventory( ip, 0, 0 );
this.bindPlayerInventory(ip, 0, 0);
this.updateOrderOfOutputSlots();
}
private void updateOrderOfOutputSlots()
{
if( !this.isCraftingMode() )
{
this.craftSlot.xDisplayPosition = -9000;
static boolean canDoubleStacks(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots =
enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream()
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
.count();
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
for( int y = 0; y < 3; y++ )
{
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
static void doubleStacksInternal(SlotFake[] slots) {
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st == null) continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
} else if (st.stackSize * 2 > 127) {
overFlowStacks.add(st.copy());
} else {
st.stackSize *= 2;
s.putStack(st);
}
}
else
{
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext()) break;
if (s.getStack() != null) continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream()
.filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack()))
.count();
return item > 0;
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream()
.filter(s -> Util.isFluidPacket(s.getStack()))
.count();
return fluid > 0;
}
private void updateOrderOfOutputSlots() {
if (!this.isCraftingMode()) {
this.craftSlot.xDisplayPosition = -9000;
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = this.outputSlots[y].getX();
}
} else {
this.craftSlot.xDisplayPosition = this.craftSlot.getX();
for( int y = 0; y < 3; y++ )
{
for (int y = 0; y < 3; y++) {
this.outputSlots[y].xDisplayPosition = -9000;
}
}
}
@Override
public void putStackInSlot( final int par1, final ItemStack par2ItemStack )
{
super.putStackInSlot( par1, par2ItemStack );
public void putStackInSlot(final int par1, final ItemStack par2ItemStack) {
super.putStackInSlot(par1, par2ItemStack);
this.getAndUpdateOutput();
}
@Override
public void putStacksInSlots( final ItemStack[] par1ArrayOfItemStack )
{
super.putStacksInSlots( par1ArrayOfItemStack );
public void putStacksInSlots(final ItemStack[] par1ArrayOfItemStack) {
super.putStacksInSlots(par1ArrayOfItemStack);
this.getAndUpdateOutput();
}
private ItemStack getAndUpdateOutput()
{
final InventoryCrafting ic = new InventoryCrafting( this, 3, 3 );
private ItemStack getAndUpdateOutput() {
final InventoryCrafting ic = new InventoryCrafting(this, 3, 3);
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) );
for (int x = 0; x < ic.getSizeInventory(); x++) {
ic.setInventorySlotContents(x, this.crafting.getStackInSlot(x));
}
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj );
this.cOut.setInventorySlotContents( 0, is );
final ItemStack is = CraftingManager.getInstance().findMatchingRecipe(ic, this.getPlayerInv().player.worldObj);
this.cOut.setInventorySlotContents(0, is);
return is;
}
@Override
public void saveChanges()
{
}
public void saveChanges() {}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {}
}
public void encodeAndMoveToInventory()
{
public void encodeAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
if (output != null) {
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotOUT.putStack(null);
}
}
public void encode()
{
public void encode() {
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if( in == null || out == null )
{
if (in == null || out == null) {
return;
}
// first check the output slots, should either be null, or a pattern
if( output != null && !this.isPattern( output ) )
{
if (output != null && !this.isPattern(output)) {
return;
}// if nothing is there we should snag a new pattern.
else if( output == null )
{
} // if nothing is there we should snag a new pattern.
else if (output == null) {
output = this.patternSlotIN.getStack();
if (!this.isPattern( output ))
{
if (!this.isPattern(output)) {
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if( output.stackSize == 0 )
{
this.patternSlotIN.putStack( null );
if (output.stackSize == 0) {
this.patternSlotIN.putStack(null);
}
// add a new encoded pattern.
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
this.patternSlotOUT.putStack(output);
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
this.patternSlotOUT.putStack(output);
}
}
@@ -227,86 +305,70 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for( final ItemStack i : in )
{
tagIn.appendTag( this.createItemTag( i ) );
for (final ItemStack i : in) {
tagIn.appendTag(this.createItemTag(i));
}
for( final ItemStack i : out )
{
tagOut.appendTag( this.createItemTag( i ) );
for (final ItemStack i : out) {
tagOut.appendTag(this.createItemTag(i));
}
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "crafting", this.isCraftingMode() );
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("crafting", this.isCraftingMode());
encodedValue.setBoolean("substitute", this.isSubstitute());
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
output.setTagCompound(encodedValue);
}
private ItemStack[] getInputs()
{
private ItemStack[] getInputs() {
final ItemStack[] input = new ItemStack[9];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
{
for (int x = 0; x < this.craftingSlots.length; x++) {
input[x] = this.craftingSlots[x].getStack();
if( input[x] != null )
{
if (input[x] != null) {
hasValue = true;
}
}
if( hasValue )
{
if (hasValue) {
return input;
}
return null;
}
private ItemStack[] getOutputs()
{
if( this.isCraftingMode() )
{
private ItemStack[] getOutputs() {
if (this.isCraftingMode()) {
final ItemStack out = this.getAndUpdateOutput();
if( out != null && out.stackSize > 0 )
{
return new ItemStack[] { out };
if (out != null && out.stackSize > 0) {
return new ItemStack[] {out};
}
}
else
{
final List<ItemStack> list = new ArrayList<>( 3 );
} else {
final List<ItemStack> list = new ArrayList<>(3);
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
for (final OptionalSlotFake outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if( out != null && out.stackSize > 0 )
{
list.add( out );
if (out != null && out.stackSize > 0) {
list.add(out);
hasValue = true;
}
}
if( hasValue )
{
return list.toArray( new ItemStack[list.size()] );
if (hasValue) {
return list.toArray(new ItemStack[list.size()]);
}
}
return null;
}
private boolean isPattern( final ItemStack output )
{
if( output == null )
{
private boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
@@ -314,14 +376,13 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
isPattern |= definitions.materials().blankPattern().isSameAs( output );
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return isPattern;
}
private NBTBase createItemTag(final ItemStack i )
{
private NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if( i != null )
@@ -334,115 +395,110 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
}
@Override
public boolean isSlotEnabled( final int idx )
{
if( idx == 1 )
{
public boolean isSlotEnabled(final int idx) {
if (idx == 1) {
return Platform.isServer() ? !this.getPatternTerminal().isCraftingRecipe() : !this.isCraftingMode();
}
else if( idx == 2 )
{
} else if (idx == 2) {
return Platform.isServer() ? this.getPatternTerminal().isCraftingRecipe() : this.isCraftingMode();
}
else
{
} else {
return false;
}
}
public void craftOrGetItem( final PacketPatternSlot packetPatternSlot )
{
if( packetPatternSlot.slotItem != null && this.getCellInventory() != null )
{
public void craftOrGetItem(final PacketPatternSlot packetPatternSlot) {
if (packetPatternSlot.slotItem != null && this.getCellInventory() != null) {
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN );
InventoryAdaptor inv = new AdaptorPlayerHand(this.getPlayerInv().player);
final InventoryAdaptor playerInv =
InventoryAdaptor.getAdaptor(this.getPlayerInv().player, ForgeDirection.UNKNOWN);
if( packetPatternSlot.shift )
{
if (packetPatternSlot.shift) {
inv = playerInv;
}
if( inv.simulateAdd( out.getItemStack() ) != null )
{
if (inv.simulateAdd(out.getItemStack()) != null) {
return;
}
final IAEItemStack extracted = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), out, this.getActionSource() );
final IAEItemStack extracted = Platform.poweredExtraction(
this.getPowerSource(), this.getCellInventory(), out, this.getActionSource());
final EntityPlayer p = this.getPlayerInv().player;
if( extracted != null )
{
inv.addItems( extracted.getItemStack() );
if( p instanceof EntityPlayerMP)
{
this.updateHeld( (EntityPlayerMP) p );
if (extracted != null) {
inv.addItems(extracted.getItemStack());
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
return;
}
final InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 );
final InventoryCrafting real = new InventoryCrafting( new ContainerNull(), 3, 3 );
final InventoryCrafting ic = new InventoryCrafting(new ContainerNull(), 3, 3);
final InventoryCrafting real = new InventoryCrafting(new ContainerNull(), 3, 3);
for( int x = 0; x < 9; x++ )
{
ic.setInventorySlotContents( x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack() );
for (int x = 0; x < 9; x++) {
ic.setInventorySlotContents(
x, packetPatternSlot.pattern[x] == null ? null : packetPatternSlot.pattern[x].getItemStack());
}
final IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj );
final IRecipe r = Platform.findMatchingRecipe(ic, p.worldObj);
if( r == null )
{
if (r == null) {
return;
}
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal().getItemInventory();
final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.getCraftingResult( ic );
final ItemStack is = r.getCraftingResult(ic);
for( int x = 0; x < ic.getSizeInventory(); x++ )
{
if( ic.getStackInSlot( x ) != null )
{
final ItemStack pulled = Platform.extractItemsByRecipe( this.getPowerSource(), this.getActionSource(), storage, p.worldObj, r, is, ic, ic.getStackInSlot( x ), x, all, Actionable.MODULATE, ItemViewCell.createFilter( this.getViewCells() ) );
real.setInventorySlotContents( x, pulled );
for (int x = 0; x < ic.getSizeInventory(); x++) {
if (ic.getStackInSlot(x) != null) {
final ItemStack pulled = Platform.extractItemsByRecipe(
this.getPowerSource(),
this.getActionSource(),
storage,
p.worldObj,
r,
is,
ic,
ic.getStackInSlot(x),
x,
all,
Actionable.MODULATE,
ItemViewCell.createFilter(this.getViewCells()));
real.setInventorySlotContents(x, pulled);
}
}
final IRecipe rr = Platform.findMatchingRecipe( real, p.worldObj );
final IRecipe rr = Platform.findMatchingRecipe(real, p.worldObj);
if( rr == r && Platform.isSameItemPrecise( rr.getCraftingResult( real ), is ) )
{
final SlotCrafting sc = new SlotCrafting( p, real, this.cOut, 0, 0, 0 );
sc.onPickupFromSlot( p, is );
if (rr == r && Platform.isSameItemPrecise(rr.getCraftingResult(real), is)) {
final SlotCrafting sc = new SlotCrafting(p, real, this.cOut, 0, 0, 0);
sc.onPickupFromSlot(p, is);
for( int x = 0; x < real.getSizeInventory(); x++ )
{
final ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) );
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = playerInv.addItems(real.getStackInSlot(x));
if( failed != null )
{
p.dropPlayerItemWithRandomChoice( failed, false );
if (failed != null) {
p.dropPlayerItemWithRandomChoice(failed, false);
}
}
inv.addItems( is );
if( p instanceof EntityPlayerMP )
{
this.updateHeld( (EntityPlayerMP) p );
inv.addItems(is);
if (p instanceof EntityPlayerMP) {
this.updateHeld((EntityPlayerMP) p);
}
this.detectAndSendChanges();
}
else
{
for( int x = 0; x < real.getSizeInventory(); x++ )
{
final ItemStack failed = real.getStackInSlot( x );
if( failed != null )
{
this.getCellInventory().injectItems( AEItemStack.create( failed ), Actionable.MODULATE, new MachineSource( this.getPatternTerminal() ) );
} else {
for (int x = 0; x < real.getSizeInventory(); x++) {
final ItemStack failed = real.getStackInSlot(x);
if (failed != null) {
this.getCellInventory()
.injectItems(
AEItemStack.create(failed),
Actionable.MODULATE,
new MachineSource(this.getPatternTerminal()));
}
}
}
@@ -450,14 +506,11 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
if( Platform.isServer() )
{
if( this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe() )
{
this.setCraftingMode( this.getPatternTerminal().isCraftingRecipe() );
if (Platform.isServer()) {
if (this.isCraftingMode() != this.getPatternTerminal().isCraftingRecipe()) {
this.setCraftingMode(this.getPatternTerminal().isCraftingRecipe());
this.updateOrderOfOutputSlots();
}
@@ -468,85 +521,46 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
}
@Override
public void onUpdate( final String field, final Object oldValue, final Object newValue )
{
super.onUpdate( field, oldValue, newValue );
public void onUpdate(final String field, final Object oldValue, final Object newValue) {
super.onUpdate(field, oldValue, newValue);
if( field.equals( "craftingMode" ) )
{
if (field.equals("craftingMode")) {
this.getAndUpdateOutput();
this.updateOrderOfOutputSlots();
}
}
@Override
public void onSlotChange( final Slot s )
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
for( final Object crafter : this.crafters )
{
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
for (final Object crafter : this.crafters) {
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
{
for (final Object g : this.inventorySlots) {
if (g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix) {
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
}
}
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
}
public void clear()
{
for( final Slot s : this.craftingSlots )
{
s.putStack( null );
public void clear() {
for (final Slot s : this.craftingSlots) {
s.putStack(null);
}
for( final Slot s : this.outputSlots )
{
s.putStack( null );
for (final Slot s : this.outputSlots) {
s.putStack(null);
}
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName( name );
}
@Override
public boolean useRealItems()
{
return false;
}
public void toggleSubstitute()
{
this.substitute = !this.substitute;
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
public boolean isCraftingMode()
{
return this.craftingMode;
}
private void setCraftingMode(final boolean craftingMode) {
this.craftingMode = craftingMode;
}
@@ -567,63 +581,28 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
this.substitute = substitute;
}
static boolean canDoubleStacks(SlotFake[] slots)
{
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
static void doubleStacksInternal(SlotFake[] slots)
{
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots)
{
ItemStack st = s.getStack();
if (st == null)
continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2)
fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
}
else if (st.stackSize * 2 > 127)
{
overFlowStacks.add(st.copy());
}
else
{
st.stackSize *= 2;
s.putStack(st);
}
@Override
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext())
break;
if (s.getStack() != null)
continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
return this.getPatternTerminal().getInventoryByName(name);
}
static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count();
return item > 0;
@Override
public boolean useRealItems() {
return false;
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count();
return fluid > 0;
public void toggleSubstitute() {
this.substitute = !this.substitute;
this.detectAndSendChanges();
this.getAndUpdateOutput();
}
public boolean isCraftingMode() {
return this.craftingMode;
}
public void doubleStacks(boolean isShift) {
@@ -639,5 +618,4 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
this.detectAndSendChanges();
}
}
}
@@ -16,6 +16,11 @@ 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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
@@ -27,54 +32,20 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
public class FCBasePartContainerEx extends FCBaseMonitorContain
implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(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);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
protected final ProcessingSlotFake[] craftingSlots =
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
private final PartFluidPatternTerminalEx patternTerminal;
protected final ProcessingSlotFake[] craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync(96 + (17 - 9) + 11)
public boolean combine = false;
@GuiSync(96 + (17 - 9) + 12)
public boolean substitute = false;
@GuiSync(96 + (17 - 9) + 16)
public boolean inverted;
@GuiSync(96 + (17 - 9) + 17)
public int activePage = 0;
@GuiSync(96 + (17 - 9) + 13)
public boolean prioritize = false;
@GuiSync(96 + (17 - 9) + 14)
public boolean beSubstitute = false;
protected final ProcessingSlotFake[] outputSlots =
new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable) {
super(ip, monitorable, false);
@@ -88,108 +59,218 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(crafting, this, x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, 15, -83, x, y, x + 4));
this.addSlotToContainer(
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
crafting,
this,
x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS,
15,
-83,
x,
y,
x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(output, this, x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, 112, -83, -x, y, x));
this.addSlotToContainer(
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] =
new ProcessingSlotFake(
output,
this,
x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS,
112,
-83,
-x,
y,
x));
}
}
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.patternSlotIN = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.BLANK_PATTERN,
patternInv,
0,
147,
-72 - 9,
this.getInventoryPlayer()));
this.addSlotToContainer(
this.patternSlotOUT = new SlotRestrictedInput(
SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN,
patternInv,
1,
147,
-72 + 34,
this.getInventoryPlayer()));
this.patternSlotOUT.setStackLimit( 1 );
this.patternSlotOUT.setStackLimit(1);
this.bindPlayerInventory( ip, 0, 0 );
this.bindPlayerInventory(ip, 0, 0);
}
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync(96 + (17 - 9) + 11)
public boolean combine = false;
@GuiSync(96 + (17 - 9) + 12)
public boolean substitute = false;
@GuiSync(96 + (17 - 9) + 16)
public boolean inverted;
@GuiSync(96 + (17 - 9) + 17)
public int activePage = 0;
@GuiSync(96 + (17 - 9) + 13)
public boolean prioritize = false;
@GuiSync(96 + (17 - 9) + 14)
public boolean beSubstitute = false;
static boolean canDoubleStacks(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots =
enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream()
.filter(s -> s.getStack() != null && s.getStack().stackSize * 2 > 127)
.count();
return fullSlots <= emptyStots;
}
static void doubleStacksInternal(SlotFake[] slots) {
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots) {
ItemStack st = s.getStack();
if (st == null) continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2) fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
} else if (st.stackSize * 2 > 127) {
overFlowStacks.add(st.copy());
} else {
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext()) break;
if (s.getStack() != null) continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream()
.filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack()))
.count();
return item > 0;
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots =
Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream()
.filter(s -> Util.isFluidPacket(s.getStack()))
.count();
return fluid > 0;
}
@Override
public void saveChanges()
{
public void saveChanges() {}
}
public void clear()
{
for( final Slot s : this.craftingSlots )
{
s.putStack( null );
public void clear() {
for (final Slot s : this.craftingSlots) {
s.putStack(null);
}
for( final Slot s : this.outputSlots )
{
s.putStack( null );
for (final Slot s : this.outputSlots) {
s.putStack(null);
}
this.detectAndSendChanges();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
public void onChangeInventory(
final IInventory inv,
final int slot,
final InvOperation mc,
final ItemStack removedStack,
final ItemStack newStack) {}
}
public void encodeAndMoveToInventory()
{
public void encodeAndMoveToInventory() {
encode();
ItemStack output = this.patternSlotOUT.getStack();
if ( output != null )
{
if (!getPlayerInv().addItemStackToInventory( output )){
if (output != null) {
if (!getPlayerInv().addItemStackToInventory(output)) {
getPlayerInv().player.entityDropItem(output, 0);
}
this.patternSlotOUT.putStack( null );
this.patternSlotOUT.putStack(null);
}
}
public void encode()
{
public void encode() {
ItemStack output = this.patternSlotOUT.getStack();
final ItemStack[] in = this.getInputs();
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if( in == null || out == null )
{
if (in == null || out == null) {
return;
}
// first check the output slots, should either be null, or a pattern
if( output != null && !this.isPattern( output ) )
{
if (output != null && !this.isPattern(output)) {
return;
}// if nothing is there we should snag a new pattern.
else if( output == null )
{
} // if nothing is there we should snag a new pattern.
else if (output == null) {
output = this.patternSlotIN.getStack();
if (!this.isPattern( output ))
{
if (!this.isPattern(output)) {
return; // no blanks.
}
// remove one, and clear the input slot.
output.stackSize--;
if( output.stackSize == 0 )
{
this.patternSlotIN.putStack( null );
if (output.stackSize == 0) {
this.patternSlotIN.putStack(null);
}
// add a new encoded pattern.
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
this.patternSlotOUT.putStack(output);
}
} else if ( output.getItem() instanceof ItemFluidEncodedPattern ) {
for( final ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() )
{
} else if (output.getItem() instanceof ItemFluidEncodedPattern) {
for (final ItemStack encodedPatternStack : AEApi.instance()
.definitions()
.items()
.encodedPattern()
.maybeStack(1)
.asSet()) {
output = encodedPatternStack;
this.patternSlotOUT.putStack( output );
this.patternSlotOUT.putStack(output);
}
}
@@ -199,77 +280,65 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
final NBTTagList tagIn = new NBTTagList();
final NBTTagList tagOut = new NBTTagList();
for( final ItemStack i : in )
{
tagIn.appendTag( this.createItemTag( i ) );
for (final ItemStack i : in) {
tagIn.appendTag(this.createItemTag(i));
}
for( final ItemStack i : out )
{
tagOut.appendTag( this.createItemTag( i ) );
for (final ItemStack i : out) {
tagOut.appendTag(this.createItemTag(i));
}
encodedValue.setTag( "in", tagIn );
encodedValue.setTag( "out", tagOut );
encodedValue.setTag("in", tagIn);
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("substitute", this.isSubstitute());
encodedValue.setBoolean("beSubstitute", this.canBeSubstitute());
encodedValue.setTag("in", tagIn);
encodedValue.setTag( "out", tagOut );
encodedValue.setBoolean( "prioritize", this.isPrioritize() );
encodedValue.setTag("out", tagOut);
encodedValue.setBoolean("prioritize", this.isPrioritize());
output.setTagCompound( encodedValue );
output.setTagCompound(encodedValue);
}
private ItemStack[] getInputs()
{
private ItemStack[] getInputs() {
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
{
for (int x = 0; x < this.craftingSlots.length; x++) {
input[x] = this.craftingSlots[x].getStack();
if( input[x] != null )
{
if (input[x] != null) {
hasValue = true;
}
}
if( hasValue )
{
if (hasValue) {
return input;
}
return null;
}
private ItemStack[] getOutputs()
{
final List<ItemStack> list = new ArrayList<>( CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES );
private ItemStack[] getOutputs() {
final List<ItemStack> list = new ArrayList<>(CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES);
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
{
for (final OptionalSlotFake outputSlot : this.outputSlots) {
final ItemStack out = outputSlot.getStack();
if( out != null && out.stackSize > 0 )
{
list.add( out );
if (out != null && out.stackSize > 0) {
list.add(out);
hasValue = true;
}
}
if( hasValue )
{
if (hasValue) {
return list.toArray(new ItemStack[0]);
}
return null;
}
private boolean isPattern( final ItemStack output )
{
if( output == null )
{
private boolean isPattern(final ItemStack output) {
if (output == null) {
return false;
}
if (output.getItem() instanceof ItemFluidEncodedPattern) {
@@ -277,14 +346,13 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
}
final IDefinitions definitions = AEApi.instance().definitions();
boolean isPattern = definitions.items().encodedPattern().isSameAs( output );
isPattern |= definitions.materials().blankPattern().isSameAs( output );
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return isPattern;
}
private NBTBase createItemTag(final ItemStack i )
{
private NBTBase createItemTag(final ItemStack i) {
final NBTTagCompound c = new NBTTagCompound();
if( i != null )
@@ -297,26 +365,21 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
}
@Override
public boolean isSlotEnabled( final int idx )
{
public boolean isSlotEnabled(final int idx) {
if (idx < 4) // outputs
{
return inverted || idx == 0;
}
else
{
} else {
return !inverted || idx == 4;
}
}
@Override
public void detectAndSendChanges()
{
public void detectAndSendChanges() {
super.detectAndSendChanges();
if( Platform.isServer() )
{
if (Platform.isServer()) {
this.substitute = this.patternTerminal.isSubstitution();
this.combine = this.patternTerminal.shouldCombine(); //Check out
this.combine = this.patternTerminal.shouldCombine(); // Check out
this.beSubstitute = this.patternTerminal.canBeSubstitute();
this.prioritize = this.patternTerminal.isPrioritize();
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
@@ -327,13 +390,14 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
}
}
private void offsetSlots()
{
private void offsetSlots() {
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && !inverted);
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(
page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(
page != activePage || x > 0 && !inverted);
}
}
}
@@ -341,127 +405,86 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate( field, oldValue, newValue );
super.onUpdate(field, oldValue, newValue);
if (field.equals( "inverted" ) || field.equals( "activePage" )) {
if (field.equals("inverted") || field.equals("activePage")) {
offsetSlots();
}
}
@Override
public void onSlotChange( final Slot s )
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
public void onSlotChange(final Slot s) {
if (s == this.patternSlotOUT && Platform.isServer()) {
inverted = patternTerminal.isInverted();
for( final Object crafter : this.crafters )
{
for (final Object crafter : this.crafters) {
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake )
{
for (final Object g : this.inventorySlots) {
if (g instanceof OptionalSlotFake) {
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
icrafting.sendSlotContents(this, sri.slotNumber, sri.getStack());
}
}
( (EntityPlayerMP) icrafting ).isChangingQuantityOnly = false;
((EntityPlayerMP) icrafting).isChangingQuantityOnly = false;
}
this.detectAndSendChanges();
}
}
@Override
public IInventory getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
public IInventory getInventoryByName(final String name) {
if (name.equals("player")) {
return this.getInventoryPlayer();
}
return this.getPatternTerminal().getInventoryByName( name );
return this.getPatternTerminal().getInventoryByName(name);
}
@Override
public boolean useRealItems()
{
public boolean useRealItems() {
return false;
}
public PartFluidPatternTerminalEx getPatternTerminal()
{
public PartFluidPatternTerminalEx getPatternTerminal() {
return this.patternTerminal;
}
private boolean isSubstitute()
{
private boolean isSubstitute() {
return this.substitute;
}
private boolean isPrioritize() { return this.prioritize; }
static boolean canDoubleStacks(SlotFake[] slots)
{
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots;
}
static void doubleStacksInternal(SlotFake[] slots)
{
List<ItemStack> overFlowStacks = new ArrayList<>();
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
for (final Slot s : enabledSlots)
{
ItemStack st = s.getStack();
if (st == null)
continue;
if (Util.isFluidPacket(st)) {
FluidStack fluidStack = ItemFluidPacket.getFluidStack(st);
if (fluidStack != null) {
fluidStack = ItemFluidPacket.getFluidStack(st).copy();
if (fluidStack.amount < Integer.MAX_VALUE / 2)
fluidStack.amount *= 2;
}
s.putStack(ItemFluidPacket.newStack(fluidStack));
}
else if (st.stackSize * 2 > 127)
{
overFlowStacks.add(st.copy());
}
else
{
st.stackSize *= 2;
s.putStack(st);
}
}
Iterator<ItemStack> ow = overFlowStacks.iterator();
for (final Slot s : enabledSlots) {
if (!ow.hasNext())
break;
if (s.getStack() != null)
continue;
s.putStack(ow.next());
}
assert !ow.hasNext();
}
static boolean containsItem(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long item = enabledSlots.stream().filter(s -> s.getStack() != null && !Util.isFluidPacket(s.getStack())).count();
return item > 0;
private boolean isPrioritize() {
return this.prioritize;
}
private boolean canBeSubstitute() {
return this.beSubstitute;
}
static boolean containsFluid(SlotFake[] slots) {
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long fluid = enabledSlots.stream().filter(s -> Util.isFluidPacket(s.getStack())).count();
return fluid > 0;
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(
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);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
public void doubleStacks(boolean isShift) {
@@ -485,5 +508,4 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
public int getActivePage() {
return this.activePage;
}
}
@@ -1,12 +1,6 @@
package com.glodblock.github.client.gui.container;
import akka.actor.Status;
import java.lang.reflect.Type;
public enum FluidPrioritization {
ENABLED,
DISABLED;
}
@@ -32,16 +32,14 @@ import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.util.FluidSorters;
import com.glodblock.github.util.Util;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
public class FluidRepo extends ItemRepo {
@@ -117,7 +115,7 @@ public class FluidRepo extends ItemRepo {
this.innerSearch = this.searchString;
final boolean terminalSearchToolTips =
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
AEConfig.instance.settings.getSetting(Settings.SEARCH_TOOLTIPS) != YesNo.NO;
// boolean terminalSearchMods = Configuration.INSTANCE.settings.getSetting( Settings.SEARCH_MODS ) != YesNo.NO;
boolean searchMod = false;
@@ -159,8 +157,8 @@ public class FluidRepo extends ItemRepo {
}
Fluid fluid = ItemFluidDrop.getAeFluidStack(is).getFluid();
if (searchMod) {
if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find() ||
m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) {
if (m.matcher(Util.getFluidModID(fluid).toLowerCase()).find()
|| m.matcher(Util.getFluidModName(fluid).toLowerCase()).find()) {
this.view.add(is);
}
} else {
@@ -200,7 +198,7 @@ public class FluidRepo extends ItemRepo {
try {
if (this.NEIWord == null || !this.NEIWord.equals(filter)) {
final Class c =
ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
ReflectionHelper.getClass(this.getClass().getClassLoader(), "codechicken.nei.LayoutManager");
final Field fldSearchField = c.getField("searchField");
final Object searchField = fldSearchField.get(c);
@@ -5,6 +5,8 @@ import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.RenderUtil;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
@@ -18,9 +20,6 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
import java.util.Map;
@SideOnly(Side.CLIENT)
public class ItemDropRender implements IItemRenderer {
@@ -62,7 +61,15 @@ public class ItemDropRender implements IItemRenderer {
if (type.equals(ItemRenderType.INVENTORY)) {
RenderUtil.renderItemIcon(shape, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
} else {
ItemRenderer.renderItemIn2D(Tessellator.instance, shape.getMaxU(), shape.getMinV(), shape.getMinU(), shape.getMaxV(), shape.getIconWidth(), shape.getIconHeight(), 0.0625F);
ItemRenderer.renderItemIn2D(
Tessellator.instance,
shape.getMaxU(),
shape.getMinV(),
shape.getMinU(),
shape.getMaxV(),
shape.getIconWidth(),
shape.getIconHeight(),
0.0625F);
}
GL11.glDisable(GL11.GL_ALPHA_TEST);
@@ -84,8 +91,9 @@ public class ItemDropRender implements IItemRenderer {
if (colour == 0xFFFFFF) {
TextureAtlasSprite sprite;
try {
sprite = Minecraft.getMinecraft().getTextureMapBlocks()
.getTextureExtry(fluid.getStillIcon().getIconName());
sprite = Minecraft.getMinecraft()
.getTextureMapBlocks()
.getTextureExtry(fluid.getStillIcon().getIconName());
} catch (NullPointerException e) {
colourCache.put(fluid.getName(), colour);
return colour;
@@ -34,8 +34,7 @@ public class ItemPacketRender implements IItemRenderer {
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemFluidPacket))
return;
if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemFluidPacket)) return;
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
@@ -46,7 +45,9 @@ public class ItemPacketRender implements IItemRenderer {
if (fluid != null) {
RGB = fluid.getFluid().getColor(fluid);
}
IIcon icon = fluid == null ? FluidRegistry.WATER.getStillIcon() : fluid.getFluid().getStillIcon();
IIcon icon = fluid == null
? FluidRegistry.WATER.getStillIcon()
: fluid.getFluid().getStillIcon();
if (RGB != 0xFFFFFF) {
GL11.glColor3f((RGB >> 16 & 0xFF) / 255.0F, (RGB >> 8 & 0xFF) / 255.0F, (RGB & 0xFF) / 255.0F);
@@ -55,11 +56,18 @@ public class ItemPacketRender implements IItemRenderer {
if (type.equals(ItemRenderType.INVENTORY)) {
RenderUtil.renderItemIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
} else {
ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
ItemRenderer.renderItemIn2D(
Tessellator.instance,
icon.getMaxU(),
icon.getMinV(),
icon.getMinU(),
icon.getMaxV(),
icon.getIconWidth(),
icon.getIconHeight(),
0.0625F);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
}
@@ -11,29 +11,32 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
public class RenderBlockFluidInterface extends BaseBlockRender<BlockFluidInterface, TileFluidInterface>
{
public class RenderBlockFluidInterface extends BaseBlockRender<BlockFluidInterface, TileFluidInterface> {
public RenderBlockFluidInterface()
{
super( false, 20 );
public RenderBlockFluidInterface() {
super(false, 20);
}
@Override
public boolean renderInWorld(final BlockFluidInterface block, final IBlockAccess world, final int x, final int y, final int z, final RenderBlocks renderer )
{
final TileInterface ti = block.getTileEntity( world, x, y, z );
public boolean renderInWorld(
final BlockFluidInterface block,
final IBlockAccess world,
final int x,
final int y,
final int z,
final RenderBlocks renderer) {
final TileInterface ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();
if( ti != null && ti.getForward() != ForgeDirection.UNKNOWN )
{
if (ti != null && ti.getForward() != ForgeDirection.UNKNOWN) {
final IIcon side = FCPartsTexture.BlockFluidInterfaceAlternate_Arrow.getIcon();
info.setTemporaryRenderIcons( FCPartsTexture.BlockInterfaceAlternate.getIcon(), block.getIcon( 0, 0 ), side, side, side, side );
info.setTemporaryRenderIcons(
FCPartsTexture.BlockInterfaceAlternate.getIcon(), block.getIcon(0, 0), side, side, side, side);
}
final boolean fz = super.renderInWorld( block, world, x, y, z, renderer );
final boolean fz = super.renderInWorld(block, world, x, y, z, renderer);
info.setTemporaryRenderIcon( null );
info.setTemporaryRenderIcon(null);
return fz;
}
@@ -15,9 +15,14 @@ public class RenderBlockLevelMaintainer extends BaseBlockRender<BlockLevelMainta
super(false, 20);
}
@Override
public boolean renderInWorld(final BlockLevelMaintainer block, final IBlockAccess world, final int x, final int y, final int z, final RenderBlocks renderer) {
public boolean renderInWorld(
final BlockLevelMaintainer block,
final IBlockAccess world,
final int x,
final int y,
final int z,
final RenderBlocks renderer) {
final TileLevelMaintainer ti = block.getTileEntity(world, x, y, z);
final BlockRenderInfo info = block.getRendererInstance();
@@ -9,12 +9,20 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
public enum FCPartsTexture {
PartFluidTerminal_Bright("fluid_terminal_bright"), PartFluidTerminal_Dark("fluid_terminal_dark"), PartFluidTerminal_Colored("fluid_terminal_medium"),
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"), BlockLevelMaintainer("level_maintainer"), BlockLevelMaintainer_Active("level_maintainer_active");
PartFluidTerminal_Bright("fluid_terminal_bright"),
PartFluidTerminal_Dark("fluid_terminal_dark"),
PartFluidTerminal_Colored("fluid_terminal_medium"),
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"),
BlockLevelMaintainer("level_maintainer"),
BlockLevelMaintainer_Active("level_maintainer_active");
private final String name;
public net.minecraft.util.IIcon IIcon;
@@ -27,24 +35,21 @@ public enum FCPartsTexture {
return null;
}
@SideOnly( Side.CLIENT )
public static IIcon getMissing()
{
return ( (TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture( TextureMap.locationBlocksTexture ) ).getAtlasSprite( "missingno" );
@SideOnly(Side.CLIENT)
public static IIcon getMissing() {
return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture))
.getAtlasSprite("missingno");
}
public String getName()
{
public String getName() {
return this.name;
}
public IIcon getIcon()
{
public IIcon getIcon() {
return this.IIcon;
}
public void registerIcon( final TextureMap map )
{
this.IIcon = map.registerIcon( NameConst.RES_KEY + this.name );
public void registerIcon(final TextureMap map) {
this.IIcon = map.registerIcon(NameConst.RES_KEY + this.name);
}
}