Compare commits

...
9 Commits
Author SHA1 Message Date
Martin Robertz 626b96a91e Merge pull request #16 from GTNewHorizons/use-new-crafting-monitor
Use the new crafting monitor
2022-05-06 18:24:40 +02:00
Jakub Szewczyk 506cf78f4e Use AE2 crafting status screen instead of a copy of the old one 2022-05-05 18:10:21 +01:00
Jakub Szewczyk 3aa59a3cba Update buildscript 2022-05-05 17:29:47 +01:00
Martin Robertz ee5bfc213d Merge pull request #15 from GTNewHorizons/openTerminal
Fix not being able to open terminal in some cases
2022-05-03 15:22:57 +02:00
miozune c265b71dc3 Fix not being able to open terminal in some cases 2022-05-02 19:42:06 +09:00
Martin Robertz ba49449781 Merge pull request #14 from GTNewHorizons/searchbox-improvements
Searchbox improvements
2022-04-22 18:09:42 +02:00
miozune 89189dbff1 Searchbox improvements 2022-04-22 23:34:06 +09:00
Martin Robertz eb2e654b52 Merge pull request #13 from GTNewHorizons/feature/saveSearchConfig
Use AE2 config setting to save search string in WCT
2022-04-02 16:13:33 +02:00
repo_alt db9977b715 Use AE2 config setting to save search string in WCT
closes https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/9848
2022-04-02 11:51:49 +03:00
15 changed files with 146 additions and 1076 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
compileJava {
options.encoding = "UTF-8"
}
+4 -3
View File
@@ -1,4 +1,4 @@
//version: 1644894948
//version: 1650343995
/*
DO NOT CHANGE THIS FILE!
@@ -103,6 +103,7 @@ checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
boolean usesMixinDebug = project.findProperty('usesMixinDebug') ?: project.usesMixins.toBoolean()
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
@@ -217,7 +218,7 @@ if (usesMixins.toBoolean()) {
arguments += [
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
if (!project.hasProperty(usesMixinDebug) || usesMixinDebug.toBoolean()) {
if (usesMixinDebug.toBoolean()) {
jvmArguments += [
"-Dmixin.debug.countInjections=true",
"-Dmixin.debug.verbose=true",
@@ -567,7 +568,7 @@ publishing {
artifact source: shadowJar, classifier: ""
}
if(!noPublishedSources) {
artifact source: sourcesJar, classifier: "src"
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
if (apiPackage) {
+3 -3
View File
@@ -1,10 +1,10 @@
// Add your dependencies here
dependencies {
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-70-GTNH:dev")
compile("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-83-GTNH:dev")
compile("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
compile("curse.maven:cofh-core-69162:2388751")
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.6-GTNH:dev")
compile("com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev")
compile("com.github.GTNewHorizons:CodeChickenLib:1.1.5.3:dev")
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.27:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:EnderIO:2.3.1.32:dev") { transitive = false }
}
+1 -1
View File
@@ -19,7 +19,7 @@ forgeVersion = 10.13.4.1614
# restart Minecraft in development. Choose this dependent on your mod:
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
developmentEnvironmentUserName = "Developer"
developmentEnvironmentUserName = Developer
# Define a source file of your project with:
# public static final String VERSION = "GRADLETOKEN_VERSION";
@@ -1,476 +0,0 @@
package net.p455w0rd.wirelesscraftingterminal.client.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.lwjgl.opengl.GL11;
import com.google.common.base.Joiner;
import appeng.api.AEApi;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AEColor;
import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiScrollbar;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingCPU;
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
public class GuiCraftingCPU extends WCTBaseGui implements ISortSource
{
private static final int GUI_HEIGHT = 184;
private static final int GUI_WIDTH = 238;
private static final int DISPLAYED_ROWS = 6;
private static final int TEXT_COLOR = 0x404040;
private static final int BACKGROUND_ALPHA = 0x5A000000;
private static final int SECTION_LENGTH = 67;
private static final int SCROLLBAR_TOP = 19;
private static final int SCROLLBAR_LEFT = 218;
private static final int SCROLLBAR_HEIGHT = 137;
private static final int CANCEL_LEFT_OFFSET = 163;
private static final int CANCEL_TOP_OFFSET = 25;
private static final int CANCEL_HEIGHT = 20;
private static final int CANCEL_WIDTH = 50;
private static final int TITLE_TOP_OFFSET = 7;
private static final int TITLE_LEFT_OFFSET = 8;
private static final int ITEMSTACK_LEFT_OFFSET = 9;
private static final int ITEMSTACK_TOP_OFFSET = 22;
private final ContainerCraftingCPU craftingCpu;
private IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
private IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
private IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
private List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
private GuiButton cancel;
private int tooltip = -1;
public GuiCraftingCPU( final InventoryPlayer inventoryPlayer, final Object te )
{
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
}
protected GuiCraftingCPU( final ContainerCraftingCPU container )
{
super( container );
this.craftingCpu = container;
this.ySize = GUI_HEIGHT;
this.xSize = GUI_WIDTH;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
}
public void clearItems()
{
this.storage = AEApi.instance().storage().createItemList();
this.active = AEApi.instance().storage().createItemList();
this.pending = AEApi.instance().storage().createItemList();
this.visual = new ArrayList<IAEItemStack>();
}
@Override
protected void actionPerformed( final GuiButton btn )
{
super.actionPerformed( btn );
if( this.cancel == btn )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
}
catch( final IOException e )
{
WCTLog.debug( e.getMessage() );
}
}
}
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
super.initGui();
this.setScrollBar();
this.cancel = new GuiButton( 0, this.guiLeft + CANCEL_LEFT_OFFSET, this.guiTop + this.ySize - CANCEL_TOP_OFFSET, CANCEL_WIDTH, CANCEL_HEIGHT, GuiText.Cancel.getLocal() );
this.buttonList.add( this.cancel );
}
private void setScrollBar()
{
final int size = this.visual.size();
this.getScrollBar().setTop( SCROLLBAR_TOP ).setLeft( SCROLLBAR_LEFT ).setHeight( SCROLLBAR_HEIGHT );
this.getScrollBar().setRange( 0, ( size + 2 ) / 3 - DISPLAYED_ROWS, 1 );
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
this.cancel.enabled = !this.visual.isEmpty();
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++ )
{
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 )
{
this.tooltip = z;
break;
}
}
x++;
if( x > 2 )
{
y++;
x = 0;
}
}
super.drawScreen( mouseX, mouseY, btn );
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
String title = this.getGuiDisplayName( GuiText.CraftingStatus.getLocal() );
if( this.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty() )
{
final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert( this.craftingCpu.getEstimatedTime(), TimeUnit.NANOSECONDS );
final String etaTimeText = DurationFormatUtils.formatDuration( etaInMilliseconds, GuiText.ETAFormat.getLocal() );
title += " - " + etaTimeText;
}
this.fontRendererObj.drawString( title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR );
int x = 0;
int y = 0;
final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
final int viewEnd = viewStart + 3 * 6;
String dspToolTip = "";
final List<String> lineList = new LinkedList<String>();
int toolPosX = 0;
int toolPosY = 0;
final int offY = 23;
final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
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 );
final IAEItemStack stored = this.storage.findPrecise( refStack );
final IAEItemStack activeStack = this.active.findPrecise( refStack );
final IAEItemStack pendingStack = this.pending.findPrecise( refStack );
int lines = 0;
if( stored != null && stored.getStackSize() > 0 )
{
lines++;
}
boolean active = false;
if( activeStack != null && activeStack.getStackSize() > 0 )
{
lines++;
active = true;
}
boolean scheduled = false;
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
lines++;
scheduled = true;
}
if( AEConfig.instance.useColoredCraftingStatus && ( active || scheduled ) )
{
final int bgColor = ( active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant ) | BACKGROUND_ALPHA;
final int startX = ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET ) * 2;
final int startY = ( ( y * offY + ITEMSTACK_TOP_OFFSET ) - 3 ) * 2;
drawRect( startX, startY, startX + ( SECTION_LENGTH * 2 ), startY + ( offY * 2 ) - 2, bgColor );
}
final int negY = ( ( lines - 1 ) * 5 ) / 2;
int downY = 0;
if( stored != null && stored.getStackSize() > 0 )
{
final String str = GuiText.Stored.getLocal() + ": " + converter.toWideReadableForm( stored.getStackSize() );
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
}
downY += 5;
}
if( activeStack != null && activeStack.getStackSize() > 0 )
{
final String str = GuiText.Crafting.getLocal() + ": " + converter.toWideReadableForm( activeStack.getStackSize() );
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
}
downY += 5;
}
if( pendingStack != null && pendingStack.getStackSize() > 0 )
{
final String str = GuiText.Scheduled.getLocal() + ": " + converter.toWideReadableForm( pendingStack.getStackSize() );
final int w = 4 + this.fontRendererObj.getStringWidth( str );
this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY ) * 2, TEXT_COLOR );
if( this.tooltip == z - viewStart )
{
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
}
}
GL11.glPopMatrix();
final int posX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
final int posY = y * offY + ITEMSTACK_TOP_OFFSET;
final ItemStack is = refStack.copy().getItemStack();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if( lineList.size() > 0 )
{
addItemTooltip(is, lineList);
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
}
toolPosX = x * ( 1 + SECTION_LENGTH ) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
}
this.drawItem( posX, posY, is );
x++;
if( x > 2 )
{
y++;
x = 0;
}
}
}
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 )
{
this.bindTexture( "appliedenergistics2", "guis/craftingcpu.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
}
public void postUpdate( final List<IAEItemStack> list, final byte ref )
{
switch( ref )
{
case 0:
for( final IAEItemStack l : list )
{
this.handleInput( this.storage, l );
}
break;
case 1:
for( final IAEItemStack l : list )
{
this.handleInput( this.active, l );
}
break;
case 2:
for( final IAEItemStack l : list )
{
this.handleInput( this.pending, l );
}
break;
}
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 );
}
}
this.setScrollBar();
}
private void handleInput( final IItemList<IAEItemStack> s, final IAEItemStack l )
{
IAEItemStack a = s.findPrecise( l );
if( l.getStackSize() <= 0 )
{
if( a != null )
{
a.reset();
}
}
else
{
if( a == null )
{
s.add( l.copy() );
a = s.findPrecise( l );
}
if( a != null )
{
a.setStackSize( l.getStackSize() );
}
}
}
private long getTotal( final IAEItemStack is )
{
final IAEItemStack a = this.storage.findPrecise( is );
final IAEItemStack b = this.active.findPrecise( is );
final IAEItemStack c = this.pending.findPrecise( is );
long total = 0;
if( a != null )
{
total += a.getStackSize();
}
if( b != null )
{
total += b.getStackSize();
}
if( c != null )
{
total += c.getStackSize();
}
return total;
}
private void deleteVisualStack( final IAEItemStack l )
{
final Iterator<IAEItemStack> i = this.visual.iterator();
while( i.hasNext() )
{
final IAEItemStack o = i.next();
if( o.equals( l ) )
{
i.remove();
return;
}
}
}
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 );
return stack;
}
@SuppressWarnings("rawtypes")
@Override
public Enum getSortBy()
{
return SortOrder.NAME;
}
@SuppressWarnings("rawtypes")
@Override
public Enum getSortDir()
{
return SortDir.ASCENDING;
}
@SuppressWarnings("rawtypes")
@Override
public Enum getSortDisplay()
{
return ViewItems.ALL;
}
}
@@ -1,35 +1,25 @@
package net.p455w0rd.wirelesscraftingterminal.client.gui;
import java.io.IOException;
import org.lwjgl.input.Mouse;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.storage.ITerminalHost;
import appeng.core.localization.GuiText;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.p455w0rd.wirelesscraftingterminal.client.gui.widgets.GuiTabButton;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class GuiCraftingStatus extends GuiCraftingCPU
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus
{
private final ContainerCraftingStatus status;
private GuiButton selectCPU;
private GuiTabButton originalGuiBtn;
private int originalGui;
private ItemStack myIcon = null;
@@ -37,10 +27,10 @@ public class GuiCraftingStatus extends GuiCraftingCPU
@SuppressWarnings("unused")
public GuiCraftingStatus( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
super( inventoryPlayer, te );
this.status = (ContainerCraftingStatus) this.inventorySlots;
final Object target = this.status.getTarget();
ContainerCraftingStatus status = (ContainerCraftingStatus) this.inventorySlots;
final Object target = status.getTarget();
final IDefinitions definitions = AEApi.instance().definitions();
final IParts parts = definitions.parts();
@@ -50,7 +40,7 @@ public class GuiCraftingStatus extends GuiCraftingCPU
{
this.myIcon = wirelessTerminalStack;
}
ItemStack is = new ItemStack(ItemEnum.WIRELESS_CRAFTING_TERMINAL.getItem());
((ItemWirelessCraftingTerminal) is.getItem()).injectAEPower(is, 6400001);
myIcon = is;
@@ -64,20 +54,6 @@ public class GuiCraftingStatus extends GuiCraftingCPU
{
super.actionPerformed( btn );
final boolean backwards = Mouse.isButtonDown( 1 );
if( btn == this.selectCPU )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
}
catch( final IOException e )
{
WCTLog.debug( e.getMessage() );
}
}
if( btn == this.originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.originalGui ) );
@@ -90,52 +66,10 @@ public class GuiCraftingStatus extends GuiCraftingCPU
{
super.initGui();
this.selectCPU = new GuiButton( 0, this.guiLeft + 8, this.guiTop + this.ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
// selectCPU.enabled = false;
this.buttonList.add( this.selectCPU );
if( this.myIcon != null )
{
this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, this.myIcon, this.myIcon.getDisplayName(), itemRender ) );
this.originalGuiBtn.setHideEdge( 13 );
}
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
this.updateCPUButtonText();
super.drawScreen( mouseX, mouseY, btn );
}
private void updateCPUButtonText()
{
String btnTextText = GuiText.NoCraftingJobs.getLocal();
if( this.status.selectedCpu >= 0 )// && status.selectedCpu < status.cpus.size() )
{
if( this.status.myName.length() > 0 )
{
final String name = this.status.myName.substring( 0, Math.min( 20, this.status.myName.length() ) );
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
}
else
{
btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu;
}
}
if( this.status.noCPU )
{
btnTextText = GuiText.NoCraftingJobs.getLocal();
}
this.selectCPU.displayString = btnTextText;
}
@Override
protected String getGuiDisplayName( final String in )
{
return in; // the cup name is on the button
}
}
@@ -1,6 +1,7 @@
package net.p455w0rd.wirelesscraftingterminal.client.gui;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
@@ -13,6 +14,10 @@ import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import appeng.client.ActionKey;
import appeng.core.CommonHelper;
import codechicken.nei.TextField;
import cpw.mods.fml.relauncher.ReflectionHelper;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -81,7 +86,6 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketInventoryAc
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwapSlots;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
import net.p455w0rd.wirelesscraftingterminal.handlers.ConfigHandler;
import net.p455w0rd.wirelesscraftingterminal.handlers.LocaleHandler;
import net.p455w0rd.wirelesscraftingterminal.integration.IntegrationRegistry;
import net.p455w0rd.wirelesscraftingterminal.integration.IntegrationType;
@@ -132,6 +136,9 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
private GuiTrashButton trashBtn;
private GuiImgButton terminalStyleBox;
private GuiImgButton searchStringSave;
private boolean isAutoFocus = false;
private int currentMouseX = 0;
private int currentMouseY = 0;
public boolean devicePowered = false;
private boolean isNEIEnabled;
private boolean wasTextboxFocused = false;
@@ -173,7 +180,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.getScrollBar().setTop( 18 ).setLeft( 174 ).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 ) );
}
protected void setScrollBar(final GuiScrollbar myScrollBar) {
this.scrollBar = myScrollBar;
}
@@ -202,7 +209,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
}
else if( btn == this.searchStringSave )
{
ConfigHandler.saveSearchString = next == YesNo.YES;
AEConfig.instance.preserveSearchBar = next == YesNo.YES;
}
else {
try {
@@ -286,7 +293,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
void setReservedSpace(final int reservedSpace) {
this.reservedSpace = reservedSpace;
}
public int getStandardSize()
{
return this.standardSize;
@@ -375,7 +382,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.buttonList.add(this.searchBoxSettings = new GuiImgButton(this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE)));
offset += 20;
this.buttonList.add( this.searchStringSave = new GuiImgButton( this.guiLeft - 18, offset, Settings.SAVE_SEARCH, ConfigHandler.saveSearchString ? 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 ) ) );
@@ -391,10 +398,12 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.buttonList.add(this.craftingStatusBtn = new GuiTabButton(this.guiLeft + 169, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(), itemRender));
this.craftingStatusBtn.setHideEdge(13);
final Enum setting = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.searchField.setFocused(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting);
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.NEI_AUTOSEARCH == searchMode;
if (ConfigHandler.saveSearchString || this.isSubGui()) {
this.searchField.setFocused(this.isAutoFocus);
if (AEConfig.instance.preserveSearchBar || this.isSubGui()) {
this.searchField.setText(memoryText);
this.repo.setSearchString(memoryText);
}
@@ -439,10 +448,10 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
/**
* Called every tick. It is used in this instance to detect screen size
* changes to automatically update the gui height.
*
*
* reInit variable is used to call initGui() on the next tick. It has to be
* called this way to update correctly.
*
*
* @author p455w0rd
*/
@Override
@@ -491,7 +500,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
/**
* Detects if the window has been resized
*
*
* @return True if window has been resized
* @author p455w0rd
*/
@@ -644,6 +653,9 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
if (this.searchField != null) {
this.searchField.drawTextBox();
}
this.currentMouseX = mouseX;
this.currentMouseY = mouseY;
}
/**
@@ -683,7 +695,7 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
//draw "over inventory area"
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
for( int x = 0; x < this.rows; x++ )
{
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
@@ -711,16 +723,14 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
if (update) {
repo.setViewCell(myCurrentViewCells);
}
}
@SuppressWarnings("rawtypes")
@Override
protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
final Enum searchMode = AEConfig.instance.settings.getSetting(Settings.SEARCH_MODE);
if (searchMode != SearchBoxMode.AUTOSEARCH && searchMode != SearchBoxMode.NEI_AUTOSEARCH) {
if(!this.isAutoFocus) {
this.searchField.mouseClicked(xCoord - this.guiLeft, yCoord - this.guiTop, btn);
}
@@ -1195,11 +1205,31 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
@Override
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
if (isNEIFocused()) {
return;
}
if (this.searchField.textboxKeyTyped(character, key)) {
if (CommonHelper.proxy.isActionKey(ActionKey.TOGGLE_FOCUS, key)) {
this.searchField.setFocused(!this.searchField.isFocused());
return;
}
if (this.searchField.isFocused() && key == Keyboard.KEY_RETURN) {
this.searchField.setFocused( false );
return;
}
if (character == ' ' && this.searchField.getText().isEmpty()) {
return;
}
final boolean mouseInGui = this.isPointInRegion( 0, 0, this.xSize, this.ySize, this.currentMouseX, this.currentMouseY );
if (this.isAutoFocus && !this.searchField.isFocused() && mouseInGui) {
this.searchField.setFocused(true);
}
if (this.searchField.textboxKeyTyped(character, key)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
@@ -1386,4 +1416,28 @@ public class GuiWirelessCraftingTerminal extends GuiContainer implements ISortSo
this.repo.updateView();
this.setScrollBar();
}
@SuppressWarnings("SameParameterValue")
protected boolean isPointInRegion(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY) {
int i = this.guiLeft;
int j = this.guiTop;
pointX -= i;
pointY -= j;
return pointX >= rectX - 1 && pointX < rectX + rectWidth + 1 && pointY >= rectY - 1 && pointY < rectY + rectHeight + 1;
}
private boolean isNEIFocused() {
if (!Loader.isModLoaded("NotEnoughItems")) {
return false;
}
try {
final Class<? super Object> c = ReflectionHelper.getClass( this.getClass().getClassLoader(), "codechicken.nei.LayoutManager" );
final Field fldSearchField = c.getField( "searchField" );
final TextField searchField = (TextField) fldSearchField.get( c );
return searchField.focused();
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
return false;
}
}
@@ -21,7 +21,7 @@ public class MEGuiTextField extends GuiTextField
private final int _width;
private final int _height;
/**
/**
* Uses the values to instantiate a padded version of a text field.
* Pays attention to the '_' caret.
*
@@ -39,7 +39,7 @@ public class MEGuiTextField extends GuiTextField
this._yPos = yPos;
this._width = width;
this._height = height;
}
}
@Override
public void mouseClicked( final int xPos, final int yPos, final int button )
@@ -66,4 +66,19 @@ public class MEGuiTextField extends GuiTextField
return withinXRange && withinYRange;
}
@Override
public void drawTextBox() {
if (this.getVisible()) {
if (this.isFocused()) {
drawRect(this.xPosition - 1, this.yPosition, this.xPosition + this.width - 1, this.yPosition + this.height + 2,
0xFF606060 );
}
else {
drawRect(this.xPosition - 1, this.yPosition, this.xPosition + this.width - 1, this.yPosition + this.height + 2,
0xFFA8A8A8 );
}
super.drawTextBox();
}
}
}
@@ -2,6 +2,7 @@ package net.p455w0rd.wirelesscraftingterminal.common;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.container.implementations.ContainerCraftingStatus;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -13,7 +14,6 @@ import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiMagnet;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftAmount;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerMagnet;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
@@ -1,277 +0,0 @@
package net.p455w0rd.wirelesscraftingterminal.common.container;
import java.io.IOException;
import appeng.api.AEApi;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.CraftingItemList;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.networking.storage.IBaseMonitor;
import appeng.api.storage.IMEMonitorHandlerReceiver;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.helpers.ICustomNameObject;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.util.Platform;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMEInventoryUpdate;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
public class ContainerCraftingCPU extends WCTBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>, ICustomNameObject
{
private final IItemList<IAEItemStack> list = AEApi.instance().storage().createItemList();
private CraftingCPUCluster monitor = null;
private String cpuName = null;
private final WirelessTerminalGuiObject obj;
@GuiSync( 0 )
public long eta = -1;
public ContainerCraftingCPU( final InventoryPlayer ip, final Object te )
{
super( ip, te );
this.obj = getGuiObject(RandomUtils.getWirelessTerm(ip), ip.player, ip.player.worldObj, (int) ip.player.posX, (int) ip.player.posY, (int) ip.player.posZ);
if (this.obj == null) {
this.setValidContainer(false);
}
/*
final IGridHost host = (IGridHost) ( te instanceof IGridHost ? te : null );
if( host != null )
{
this.findNode( host, ForgeDirection.UNKNOWN );
for( final ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
{
this.findNode( host, d );
}
}
if( te instanceof TileCraftingTile )
{
this.setCPU( (ICraftingCPU) ( (IAEMultiBlock) te ).getCluster() );
}
if( this.getNetwork() == null && Platform.isServer() )
{
this.setValidContainer( false );
}
*/
}
protected WirelessTerminalGuiObject getGuiObject(final ItemStack it, final EntityPlayer player, final World w, final int x, final int y, final int z) {
if (it != null) {
final IWirelessCraftingTermHandler wh = (IWirelessCraftingTermHandler) AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
if (wh != null) {
return new WirelessTerminalGuiObject(wh, it, player, w, x, y, z);
}
}
return null;
}
protected void setCPU( final ICraftingCPU c )
{
if( c == this.getMonitor() )
{
return;
}
if( this.getMonitor() != null )
{
this.getMonitor().removeListener( this );
}
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer )
{
try
{
NetworkHandler.instance.sendTo( new PacketValueConfig( "CraftingStatus", "Clear" ), (EntityPlayerMP) g );
}
catch( final IOException e )
{
WCTLog.debug( e.getMessage() );
}
}
}
if( c instanceof CraftingCPUCluster )
{
this.cpuName = c.getName();
this.setMonitor( (CraftingCPUCluster) c );
this.list.resetStatus();
this.getMonitor().getListOfItem( this.list, CraftingItemList.ALL );
this.getMonitor().addListener( this, null );
this.setEstimatedTime( 0 );
}
else
{
this.setMonitor( null );
this.cpuName = "";
this.setEstimatedTime( -1 );
}
}
public void cancelCrafting()
{
if( this.getMonitor() != null )
{
this.getMonitor().cancel();
}
this.setEstimatedTime( -1 );
}
@Override
public void removeCraftingFromCrafters( final ICrafting c )
{
super.removeCraftingFromCrafters( c );
if( this.crafters.isEmpty() && this.getMonitor() != null )
{
this.getMonitor().removeListener( this );
}
}
@Override
public void onContainerClosed( final EntityPlayer player )
{
super.onContainerClosed( player );
if( this.getMonitor() != null )
{
this.getMonitor().removeListener( this );
}
}
@Override
public void detectAndSendChanges()
{
if( Platform.isServer() && this.getMonitor() != null && !this.list.isEmpty() )
{
try
{
if( this.getEstimatedTime() >= 0 )
{
final long elapsedTime = this.getMonitor().getElapsedTime();
final double remainingItems = this.getMonitor().getRemainingItemCount();
final double startItems = this.getMonitor().getStartItemCount();
final long eta = (long) ( elapsedTime / Math.max( 1d, ( startItems - remainingItems ) ) * remainingItems );
this.setEstimatedTime( eta );
}
final PacketMEInventoryUpdate a = new PacketMEInventoryUpdate( (byte) 0 );
final PacketMEInventoryUpdate b = new PacketMEInventoryUpdate( (byte) 1 );
final PacketMEInventoryUpdate c = new PacketMEInventoryUpdate( (byte) 2 );
for( final IAEItemStack out : this.list )
{
a.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.STORAGE ) );
b.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.ACTIVE ) );
c.appendItem( this.getMonitor().getItemStack( out, CraftingItemList.PENDING ) );
}
this.list.resetStatus();
for( final Object g : this.crafters )
{
if( g instanceof EntityPlayer )
{
if( !a.isEmpty() )
{
NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g );
}
if( !b.isEmpty() )
{
NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g );
}
if( !c.isEmpty() )
{
NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g );
}
}
}
}
catch( final IOException e )
{
// :P
}
}
super.detectAndSendChanges();
}
@Override
public boolean isValid( final Object verificationToken )
{
return true;
}
@Override
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final BaseActionSource actionSource )
{
for( IAEItemStack is : change )
{
is = is.copy();
is.setStackSize( 1 );
this.list.add( is );
}
}
@Override
public void onListUpdate()
{
}
@Override
public String getCustomName()
{
return this.cpuName;
}
@Override
public boolean hasCustomName()
{
return this.cpuName != null && this.cpuName.length() > 0;
}
public long getEstimatedTime()
{
return this.eta;
}
private void setEstimatedTime( final long eta )
{
this.eta = eta;
}
CraftingCPUCluster getMonitor()
{
return this.monitor;
}
private void setMonitor( final CraftingCPUCluster monitor )
{
this.monitor = monitor;
}
IGrid getNetwork()
{
return this.obj.getTargetGrid();
}
}
@@ -1,156 +0,0 @@
package net.p455w0rd.wirelesscraftingterminal.common.container;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableSet;
import appeng.api.networking.crafting.ICraftingCPU;
import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.storage.ITerminalHost;
import net.minecraft.entity.player.InventoryPlayer;
import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
public class ContainerCraftingStatus extends ContainerCraftingCPU
{
private final List<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
@GuiSync( 5 )
public int selectedCpu = -1;
@GuiSync( 6 )
public boolean noCPU = true;
@GuiSync( 7 )
public String myName = "";
public ContainerCraftingStatus( final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
}
@Override
public void detectAndSendChanges()
{
final ICraftingGrid cc = this.getNetwork().getCache( ICraftingGrid.class );
final ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
int matches = 0;
boolean changed = false;
for( final ICraftingCPU c : cpuSet )
{
boolean found = false;
for( final CraftingCPURecord ccr : this.cpus )
{
if( ccr.getCpu() == c )
{
found = true;
}
}
final boolean matched = this.cpuMatches( c );
if( matched )
{
matches++;
}
if( found == !matched )
{
changed = true;
}
}
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 ) );
}
}
this.sendCPUs();
}
this.noCPU = this.cpus.isEmpty();
super.detectAndSendChanges();
}
private boolean cpuMatches( final ICraftingCPU c )
{
return c.isBusy();
}
private void sendCPUs()
{
Collections.sort( this.cpus );
if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
this.myName = "";
}
else if( this.selectedCpu != -1 )
{
this.myName = this.cpus.get( this.selectedCpu ).getName();
}
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
{
this.selectedCpu = 0;
}
if( this.selectedCpu != -1 )
{
if( this.cpus.get( this.selectedCpu ).getCpu() != this.getMonitor() )
{
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
}
}
else
{
this.setCPU( null );
}
}
public void cycleCpu( final boolean next )
{
if( next )
{
this.selectedCpu++;
}
else
{
this.selectedCpu--;
}
if( this.selectedCpu < -1 )
{
this.selectedCpu = this.cpus.size() - 1;
}
else if( this.selectedCpu >= this.cpus.size() )
{
this.selectedCpu = -1;
}
if( this.selectedCpu == -1 && this.cpus.size() > 0 )
{
this.selectedCpu = 0;
}
if( this.selectedCpu == -1 )
{
this.myName = "";
this.setCPU( null );
}
else
{
this.myName = this.cpus.get( this.selectedCpu ).getName();
this.setCPU( this.cpus.get( this.selectedCpu ).getCpu() );
}
}
}
@@ -22,7 +22,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftingCPU;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.common.utils.WCTLog;
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
@@ -129,11 +128,6 @@ public class PacketMEInventoryUpdate extends WCTPacket
( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref );
}
if( gs instanceof GuiCraftingCPU )
{
( (GuiCraftingCPU) gs ).postUpdate( this.list, this.ref );
}
if( gs instanceof GuiWirelessCraftingTerminal )
{
( (GuiWirelessCraftingTerminal) gs ).postUpdate( this.list );
@@ -187,4 +181,4 @@ public class PacketMEInventoryUpdate extends WCTPacket
{
return this.empty;
}
}
}
@@ -12,15 +12,10 @@ import appeng.api.util.IConfigurableObject;
import appeng.helpers.IMouseWheelItem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftingCPU;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftConfirm;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingCPU;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerCraftingStatus;
import net.p455w0rd.wirelesscraftingterminal.common.container.ContainerWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.common.container.WCTBaseContainer;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
@@ -65,10 +60,6 @@ public class PacketValueConfig extends WCTPacket {
final IMouseWheelItem si = (IMouseWheelItem) is.getItem();
si.onWheel(is, this.Value.equals("WheelUp"));
}
else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftingStatus) {
final ContainerCraftingStatus qk = (ContainerCraftingStatus) c;
qk.cycleCpu(this.Value.equals("Next"));
}
else if (this.Name.equals("Terminal.Cpu") && c instanceof ContainerCraftConfirm) {
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
qk.cycleCpu(this.Value.equals("Next"));
@@ -77,10 +68,6 @@ public class PacketValueConfig extends WCTPacket {
final ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
qk.startJob();
}
else if (this.Name.equals("TileCrafting.Cancel") && c instanceof ContainerCraftingCPU) {
final ContainerCraftingCPU qk = (ContainerCraftingCPU) c;
qk.cancelCrafting();
}
else if (c instanceof IConfigurableObject) {
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
@@ -122,12 +109,6 @@ public class PacketValueConfig extends WCTPacket {
((WCTBaseContainer) c).stringSync(Integer.parseInt(this.Name.substring(8)), this.Value);
}
}
else if (this.Name.equals("CraftingStatus") && this.Value.equals("Clear")) {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiCraftingCPU) {
((GuiCraftingCPU) gs).clearItems();
}
}
else if (c instanceof IConfigurableObject) {
final IConfigManager cm = ((IConfigurableObject) c).getConfigManager();
@@ -146,4 +127,4 @@ public class PacketValueConfig extends WCTPacket {
}
}
}
}
}
@@ -29,7 +29,6 @@ public class ConfigHandler {
public static boolean firstLoad = true;
private static int pwrInCfgFile, boosterDropInCfgFile;
private static boolean mtChanged = false;
public static boolean saveSearchString = false;
public static void init(File configFile) {
if (config == null) {
@@ -60,7 +59,6 @@ public class ConfigHandler {
boosterDropsEnabled = config.getBoolean("boosterDropsEnabled", Configuration.CATEGORY_GENERAL, true, boosterDropEnabledDesc);
mineTweakerOverride = config.getBoolean("mineTweakerOverride", Configuration.CATEGORY_GENERAL, false, mineTweakerOverrideDesc);
doVersionCheck = config.getBoolean("doVersionCheck", Configuration.CATEGORY_GENERAL, true, doVersionCheckDesc);
saveSearchString = config.getBoolean("saveSearchString", Configuration.CATEGORY_GENERAL, false, saveSearchStringDesc);
/*
* I did the max power cfg loading like this because while using
* Configuration#getInt did enforce the min/max values in-game, it
@@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTerminalItem;
@@ -40,45 +39,45 @@ public class KeybindHandler {
@SubscribeEvent
public void onKeyInput(KeyInputEvent event) {
EntityClientPlayerMP p = (EntityClientPlayerMP) Minecraft.getMinecraft().thePlayer;
EntityClientPlayerMP p = Minecraft.getMinecraft().thePlayer;
if (p.openContainer == null) {
return;
}
if (p.openContainer != null && p.openContainer instanceof ContainerPlayer) {
if (openTerminal.isPressed()) {
ItemStack is = RandomUtils.getWirelessTerm(p.inventory);
if (is == null) {
return;
}
IWirelessCraftingTerminalItem wirelessTerm = (IWirelessCraftingTerminalItem) is.getItem();
if (wirelessTerm != null && wirelessTerm.isWirelessCraftingEnabled(is)) {
if (!FMLClientHandler.instance().isGUIOpen(GuiWirelessCraftingTerminal.class)) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
}
}
else if (openMagnetFilter.isPressed()) {
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
//ensure player has a Wireless Crafting Terminal (with Magnet Card Installed) or Magnet Card in their inventory
//and that they have manually right=clicked it to initialize it
if (RandomUtils.isMagnetInitialized(magnetItem)) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_MAGNET));
}
else {
p.addChatMessage(new ChatComponentText(LocaleHandler.InitializeMagnet.getLocal()));
}
}
if (openTerminal.isPressed()) {
ItemStack is = RandomUtils.getWirelessTerm(p.inventory);
if (is == null) {
return;
}
IWirelessCraftingTerminalItem wirelessTerm = (IWirelessCraftingTerminalItem) is.getItem();
if (wirelessTerm != null && wirelessTerm.isWirelessCraftingEnabled(is)) {
if (!FMLClientHandler.instance().isGUIOpen(GuiWirelessCraftingTerminal.class)) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
}
}
else if (changeMagnetMode.isPressed()) {
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
if (magnetItem != null) {
NetworkHandler.instance.sendToServer(new PacketSetMagnet(magnetItem.getItemDamage()));
}
}
else {
return;
}
}
else if (openMagnetFilter.isPressed()) {
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
//ensure player has a Wireless Crafting Terminal (with Magnet Card Installed) or Magnet Card in their inventory
//and that they have manually right=clicked it to initialize it
if (RandomUtils.isMagnetInitialized(magnetItem)) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_MAGNET));
}
else {
p.addChatMessage(new ChatComponentText(LocaleHandler.InitializeMagnet.getLocal()));
}
}
else if (changeMagnetMode.isPressed()) {
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
if (magnetItem != null) {
NetworkHandler.instance.sendToServer(new PacketSetMagnet(magnetItem.getItemDamage()));
}
}
else {
return;
}
}
}