fixed #10 #12 #13 #17 -- implemented #11

This commit is contained in:
p455w0rd committed 2016-05-03 15:34:13 -04:00
1 parent 230d5321b0
commit 9d60cc01d3
18 files changed
+344 -334

No files matched your search

@@ -1,13 +1,12 @@
package net.p455w0rd.wirelesscraftingterminal.client.gui;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import com.google.common.base.Joiner;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@@ -29,9 +28,7 @@ import appeng.api.storage.data.IItemList;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
public class GuiCraftConfirm extends WCTBaseGui
{
public class GuiCraftConfirm extends WCTBaseGui {
private final ContainerCraftConfirm ccc;
@@ -43,83 +40,78 @@ public class GuiCraftConfirm extends WCTBaseGui
private final List<IAEItemStack> visual = new ArrayList<IAEItemStack>();
private int OriginalGui=0;
private int OriginalGui = 0;
private GuiButton cancel;
private GuiButton start;
private GuiButton selectCPU;
private int tooltip = -1;
InventoryPlayer inventoryPlayer;
private static int jobBytes;
private static int currCPUAvailBytes;
private static int currCPUCoCPUs;
public GuiCraftConfirm( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super(new ContainerCraftConfirm( inventoryPlayer, te ) );
public GuiCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(new ContainerCraftConfirm(inventoryPlayer, te));
this.xSize = 238;
this.ySize = 206;
final GuiScrollbar scrollbar = new GuiScrollbar();
this.setScrollBar( scrollbar );
this.setScrollBar(scrollbar);
this.ccc = (ContainerCraftConfirm) this.inventorySlots;
this.inventoryPlayer = inventoryPlayer;
if( te instanceof WirelessTerminalGuiObject )
{
if (te instanceof WirelessTerminalGuiObject) {
this.OriginalGui = Reference.GUI_WCT;
}
}
boolean isAutoStart()
{
return ( (ContainerCraftConfirm) this.inventorySlots ).isAutoStart();
boolean isAutoStart() {
return ((ContainerCraftConfirm) this.inventorySlots).isAutoStart();
}
@SuppressWarnings("unchecked")
@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 > 0 )
{
this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
if (this.OriginalGui > 0) {
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;
}
@@ -127,69 +119,84 @@ public class GuiCraftConfirm extends WCTBaseGui
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 ( (ContainerCraftConfirm) this.inventorySlots ).isSimulation();
private boolean isSimulation() {
return ((ContainerCraftConfirm) this.inventorySlots).isSimulation();
}
public int getJobBytes() {
return GuiCraftConfirm.jobBytes;
}
public static void setJobBytes( int numBytes ) {
jobBytes = numBytes;
}
public int getCurrentCPUAvailBytes() {
return GuiCraftConfirm.currCPUAvailBytes;
}
public static void setCurrentCPUAvailBytes( int numBytes ) {
currCPUAvailBytes = numBytes;
}
public int getCurrentCPUCoCPUs() {
return GuiCraftConfirm.currCPUCoCPUs;
}
public static void setCurrentCPUCoCPUs( int coCPUs ) {
currCPUCoCPUs = coCPUs;
}
@Override
public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY )
{
//final long BytesUsed = this.ccc.getUsedBytes();
//final long BytesUsed = ((ContainerCraftConfirm) this.inventorySlots).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 );
this.fontRendererObj.drawString( GuiText.CraftingPlan.getLocal(), 8, 7, 4210752 );
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
int bytesUsed = this.getJobBytes();
int availBytes = this.getCurrentCPUAvailBytes();
int availCoCPUs = this.getCurrentCPUCoCPUs();
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";
dsp = "";
else {
dsp = availBytes > 0 ? (GuiText.Bytes.getLocal() + ": " + availBytes + " : " + GuiText.CoProcessors.getLocal() + ": " + availCoCPUs) : 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;
@@ -207,339 +214,280 @@ public class GuiCraftConfirm extends WCTBaseGui
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() + ": " + Long.toString( stored.getStackSize() ) );
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(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() + ": " + Long.toString( missingStack.getStackSize() ) );
if (this.tooltip == z - viewStart) {
lineList.add(GuiText.Missing.getLocal() + ": " + Long.toString(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 = refStack.copy().getItemStack();
if( this.tooltip == z - viewStart )
{
dspToolTip = Platform.getItemDisplayName( is );
if (this.tooltip == z - viewStart) {
dspToolTip = Platform.getItemDisplayName(is);
if( lineList.size() > 0 )
{
dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList );
if (lineList.size() > 0) {
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;
}
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( "appliedenergistics2", "guis/craftingreport.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize );
this.bindTexture("appliedenergistics2", "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 )
{
case 0:
for( final IAEItemStack l : list )
{
this.handleInput( this.storage, l );
}
break;
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.pending, l );
}
break;
case 1:
for (final IAEItemStack l : list) {
this.handleInput(this.pending, l);
}
break;
case 2:
for( final IAEItemStack l : list )
{
this.handleInput( this.missing, l );
}
break;
case 2:
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 );
if (amt <= 0) {
this.deleteVisualStack(l);
}
else
{
final IAEItemStack is = this.findVisualStack( l );
is.setStackSize( amt );
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 )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
if (btn == this.selectCPU) {
try {
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Cpu", backwards ? "Prev" : "Next"));
}
catch( final IOException e )
{
WCTLog.debug( e.getMessage() );
catch (final IOException e) {
WCTLog.debug(e.getMessage());
}
}
if( btn == this.cancel )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( this.OriginalGui ) );
if (btn == this.cancel) {
NetworkHandler.instance.sendToServer(new PacketSwitchGuis(this.OriginalGui));
}
if( btn == this.start )
{
try
{
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
if (btn == this.start) {
try {
NetworkHandler.instance.sendToServer(new PacketValueConfig("Terminal.Start", "Start"));
}
catch( final Throwable e )
{
WCTLog.debug( e.getMessage() );
catch (final Throwable e) {
WCTLog.debug(e.getMessage());
}
}
}
@@ -69,6 +69,9 @@ public class GuiMagnet extends GuiContainer {
}
private synchronized boolean getMode() {
if (!magnetItem.hasTagCompound()) {
NetworkHandler.instance.sendToServer(new PacketMagnetFilterMode(true));
}
NBTTagCompound nbtTC = magnetItem.getTagCompound();
if (nbtTC.hasKey("Whitelisting")) {
return nbtTC.getBoolean("Whitelisting");
@@ -22,7 +22,10 @@ import net.p455w0rd.wirelesscraftingterminal.common.container.guisync.GuiSync;
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.PacketSetJobBytes;
import net.p455w0rd.wirelesscraftingterminal.common.container.CraftingCPURecord;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketUpdateCPUInfo;
import net.p455w0rd.wirelesscraftingterminal.helpers.WirelessTerminalGuiObject;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
import appeng.api.AEApi;
@@ -45,7 +48,7 @@ import appeng.util.Platform;
public class ContainerCraftConfirm extends WCTBaseContainer
{
private final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
public final ArrayList<CraftingCPURecord> cpus = new ArrayList<CraftingCPURecord>();
private Future<ICraftingJob> job;
private ICraftingJob result;
@GuiSync( 0 )
@@ -64,10 +67,12 @@ public class ContainerCraftConfirm extends WCTBaseContainer
public boolean noCPU = true;
@GuiSync( 7 )
public String myName = "";
InventoryPlayer inventoryPlayer;
public ContainerCraftConfirm( final InventoryPlayer ip, final ITerminalHost te )
{
super( ip, te );
inventoryPlayer = ip;
}
public void cycleCpu( final boolean next )
@@ -95,12 +100,24 @@ public class ContainerCraftConfirm extends WCTBaseContainer
this.setCpuAvailableBytes( 0 );
this.setCpuCoProcessors( 0 );
this.setName( "" );
try {
NetworkHandler.instance.sendTo(new PacketUpdateCPUInfo(0, 0), (EntityPlayerMP) this.getPlayerInv().player);
}
catch (IOException e) {
//
}
}
else
{
else {
this.setName( this.cpus.get( this.getSelectedCpu() ).getName() );
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
try {
NetworkHandler.instance.sendTo(new PacketUpdateCPUInfo((int)this.getCpuAvailableBytes(), (int)this.getCpuCoProcessors()), (EntityPlayerMP) this.getPlayerInv().player);
}
catch (IOException e) {
//
}
}
}
@@ -187,6 +204,13 @@ public class ContainerCraftConfirm extends WCTBaseContainer
final IItemList<IAEItemStack> plan = AEApi.instance().storage().createItemList();
this.result.populatePlan( plan );
try {
NetworkHandler.instance.sendTo(new PacketSetJobBytes((int)this.result.getByteTotal()), (EntityPlayerMP) this.getPlayerInv().player);
}
catch (IOException e) {
//
}
this.setUsedBytes( this.result.getByteTotal() );
@@ -293,7 +317,6 @@ public class ContainerCraftConfirm extends WCTBaseContainer
this.setName( this.cpus.get( this.getSelectedCpu() ).getName() );
this.setCpuAvailableBytes( this.cpus.get( this.getSelectedCpu() ).getSize() );
this.setCpuCoProcessors( this.cpus.get( this.getSelectedCpu() ).getProcessors() );
System.out.println("XD");
}
}
@@ -320,9 +343,9 @@ public class ContainerCraftConfirm extends WCTBaseContainer
//Platform.openGUI( this.getInventoryPlayer().player, te, this.getOpenContext().getSide(), originalGui );
EntityPlayerMP player = (EntityPlayerMP) this.getInventoryPlayer().player;
World world = player.worldObj;
int x = player.serverPosX;
int y = player.serverPosY;
int z = player.serverPosZ;
int x = (int)player.posX;
int y = (int)player.posY;
int z = (int)player.posZ;
WCTGuiHandler.launchGui(originalGui, player, world, x, y, z);
}
}
@@ -440,7 +463,7 @@ public class ContainerCraftConfirm extends WCTBaseContainer
this.simulation = simulation;
}
private Future<ICraftingJob> getJob()
public Future<ICraftingJob> getJob()
{
return this.job;
}
@@ -33,7 +33,7 @@ public class CraftingCPURecord implements Comparable<CraftingCPURecord>
return ItemSorters.compareLong( o.getSize(), this.getSize() );
}
ICraftingCPU getCpu()
public ICraftingCPU getCpu()
{
return this.cpu;
}
@@ -68,7 +68,7 @@ public abstract class WCTBaseContainer extends Container {
private final HashSet<Integer> locked = new HashSet<Integer>();
private final TileEntity tileEntity;
private final IPart part;
private final IGuiItemObject obj;
public final IGuiItemObject obj;
private final List<PacketPartialItem> dataChunks = new LinkedList<PacketPartialItem>();
private final HashMap<Integer, SyncData> syncData = new HashMap<Integer, SyncData>();
private boolean isContainerValid = true;
@@ -67,8 +67,8 @@ public class RandomUtils {
return playerInv.player.getHeldItem();
}
int invSize = playerInv.getSizeInventory();
// if not true, try to return first wireless crafting terminal
// that has a MagnetCard installed
// if not true, try to return first magnet card from first
// wireless term that has a MagnetCard installed
ItemStack wirelessTerm = getWirelessTerm(playerInv);
if (wirelessTerm != null && wirelessTerm.getItem() instanceof ItemWirelessCraftingTerminal) {
NBTTagCompound nbtTC = wirelessTerm.getTagCompound();
@@ -16,9 +16,11 @@ import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketMagnetFilte
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketNEIRecipe;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketOpenGui;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketPartialItem;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSetJobBytes;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwapSlots;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchGuis;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketSwitchMagnetMode;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketUpdateCPUInfo;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketValueConfig;
public class WCTPacketHandlerBase {
@@ -49,7 +51,11 @@ public class WCTPacketHandlerBase {
PACKET_EMPTY_TRASH(PacketEmptyTrash.class),
PACKET_SYNC_CONFIGS(PacketConfigSync.class);
PACKET_SYNC_CONFIGS(PacketConfigSync.class),
PACKET_SET_JOB(PacketSetJobBytes.class),
PACKET_UPDATECPUINFO(PacketUpdateCPUInfo.class);
private final Class<? extends WCTPacket> packetClass;
private final Constructor<? extends WCTPacket> packetConstructor;
@@ -67,9 +67,9 @@ public class PacketCraftRequest extends WCTPacket {
final ICraftingGrid cg = g.getCache(ICraftingGrid.class);
futureJob = cg.beginCraftingJob(cca.getWorld(), cca.getGrid(), cca.getActionSrc(), cca.getItemToCraft(), null);
int x = player.serverPosX;
int y = player.serverPosY;
int z = player.serverPosZ;
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_CONFIRM, player, player.worldObj, x, y, z);
@@ -84,7 +84,7 @@ public class PacketCraftRequest extends WCTPacket {
if (futureJob != null) {
futureJob.cancel(true);
}
WCTLog.debug(e.getMessage());
WCTLog.debug(e.getLocalizedMessage());
}
}
}
@@ -122,9 +122,9 @@ public class PacketInventoryAction extends WCTPacket
//{
//final TileEntity te = context.getTile();
int x = player.serverPosX;
int y = player.serverPosY;
int z = player.serverPosZ;
int x = (int)player.posX;
int y = (int)player.posY;
int z = (int)player.posZ;
WCTGuiHandler.launchGui(Reference.GUI_CRAFT_AMOUNT, player, player.worldObj, x, y, z);
@@ -7,10 +7,9 @@ import net.minecraft.inventory.ContainerPlayer;
import net.p455w0rd.wirelesscraftingterminal.common.WCTGuiHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class PacketOpenGui extends WCTPacket {
private final int whichGui;
// automatic.
@@ -29,12 +28,7 @@ public class PacketOpenGui extends WCTPacket {
@Override
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
if (player.openContainer instanceof ContainerPlayer) {
if (this.whichGui == Reference.GUI_WCT) {
WCTGuiHandler.launchGui(Reference.GUI_WCT, player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
else {
WCTGuiHandler.launchGui(this.whichGui, player, player.worldObj, (int)player.posX, (int)player.posY, (int)player.posZ);
}
WCTGuiHandler.launchGui(this.whichGui, player, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
}
@@ -0,0 +1,32 @@
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm;
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
public class PacketSetJobBytes extends WCTPacket {
private final int bytez;
// automatic.
public PacketSetJobBytes(final ByteBuf stream) throws IOException, ClassNotFoundException {
this.bytez = stream.readInt();
}
public PacketSetJobBytes(int numBytes) throws IOException {
this.bytez = numBytes;
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeInt(this.bytez);
this.configureWrite(data);
}
@Override
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
GuiCraftConfirm.setJobBytes(this.bytez);
}
}
@@ -38,18 +38,10 @@ public class PacketSwitchGuis extends WCTPacket {
@Override
public void serverPacketData(final INetworkInfo manager, final WCTPacket packet, final EntityPlayer player) {
World world = player.worldObj;
if (world.isRemote) {
int x = player.serverPosX;
int y = player.serverPosY;
int z = player.serverPosZ;
WCTGuiHandler.launchGui(newGui, player, world, x, y, z);
}
else {
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
WCTGuiHandler.launchGui(newGui, player, world, x, y, z);
}
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
WCTGuiHandler.launchGui(newGui, player, world, x, y, z);
}
@Override
@@ -0,0 +1,38 @@
package net.p455w0rd.wirelesscraftingterminal.core.sync.packets;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import net.p455w0rd.wirelesscraftingterminal.client.gui.GuiCraftConfirm;
import net.p455w0rd.wirelesscraftingterminal.core.sync.WCTPacket;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.INetworkInfo;
public class PacketUpdateCPUInfo extends WCTPacket {
private final int bytez;
private final int coCPUz;
// automatic.
public PacketUpdateCPUInfo(final ByteBuf stream) throws IOException, ClassNotFoundException {
this.bytez = stream.readInt();
this.coCPUz = stream.readInt();
}
public PacketUpdateCPUInfo(int numBytes, int numCoCPUs) throws IOException {
this.bytez = numBytes;
this.coCPUz = numCoCPUs;
final ByteBuf data = Unpooled.buffer();
data.writeInt(this.getPacketID());
data.writeInt(this.bytez);
data.writeInt(this.coCPUz);
this.configureWrite(data);
}
@Override
public void clientPacketData(final INetworkInfo network, final WCTPacket packet, final EntityPlayer player) {
GuiCraftConfirm.setCurrentCPUAvailBytes(this.bytez);
GuiCraftConfirm.setCurrentCPUCoCPUs(this.coCPUz);
}
}
@@ -58,18 +58,10 @@ public class KeybindHandler {
}
}
else if (openMagnetFilter.isPressed()) {
ItemStack is = RandomUtils.getWirelessTerm(p.inventory);
if (is == null) {
return;
}
ItemWirelessCraftingTerminal wirelessTerm = (ItemWirelessCraftingTerminal) is.getItem();
// ensure player has a Wireless Crafting Terminal (with Magnet
// Card Installed) or Magnet Card in their inventory
if (wirelessTerm != null) {
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_MAGNET));
}
ItemStack magnetItem = RandomUtils.getMagnet(p.inventory);
//ensure player has a Wireless Crafting Terminal (with Magnet Card Installed) or Magnet Card in their inventory
if (magnetItem != null && magnetItem.getItem() instanceof ItemMagnet) {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_MAGNET));
}
}
else if (changeMagnetMode.isPressed()) {
@@ -74,6 +74,10 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
}
}
}
public IGrid getTargetGrid() {
return this.targetGrid;
}
public double getRange() {
return this.myRange;
@@ -1,9 +1,5 @@
package net.p455w0rd.wirelesscraftingterminal.implementation;
import java.util.ArrayList;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.core.localization.PlayerMessages;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.player.EntityPlayer;
@@ -15,7 +11,6 @@ import net.p455w0rd.wirelesscraftingterminal.api.IWirelessCraftingTermHandler;
import net.p455w0rd.wirelesscraftingterminal.common.utils.RandomUtils;
import net.p455w0rd.wirelesscraftingterminal.core.sync.network.NetworkHandler;
import net.p455w0rd.wirelesscraftingterminal.core.sync.packets.PacketOpenGui;
import net.p455w0rd.wirelesscraftingterminal.items.ItemWirelessCraftingTerminal;
import net.p455w0rd.wirelesscraftingterminal.reference.Reference;
public class WCTInteractionHelper implements IWCTInteractionHelper {
@@ -27,29 +22,12 @@ public class WCTInteractionHelper implements IWCTInteractionHelper {
}
// Get the first wireless terminal
// If one is held, it takes precidence
// If one is held, it takes precedence
ItemStack is = RandomUtils.getWirelessTerm(player.inventory);
if (is == null) {
return;
}
ItemWirelessCraftingTerminal wirelessTerminal = (ItemWirelessCraftingTerminal) is.getItem();
IWirelessCraftingTermHandler terminalInterface = (IWirelessCraftingTermHandler) wirelessTerminal;
if (terminalInterface.getAECurrentPower(is) <= 0) {
player.addChatMessage(PlayerMessages.DeviceNotPowered.get());
return;
}
if (!isTerminalLinked(terminalInterface, is)) {
player.addChatMessage(PlayerMessages.DeviceNotLinked.get());
return;
}
String encKey = terminalInterface.getEncryptionKey(is);
ArrayList<IWirelessAccessPoint> accessPoints = WirelessAELink.locateAPsInRangeOfPlayer(player, encKey);
if (accessPoints == null) {
player.addChatMessage(PlayerMessages.StationCanNotBeLocated.get());
}
else {
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
NetworkHandler.instance.sendToServer(new PacketOpenGui(Reference.GUI_WCT));
}
public static boolean isTerminalLinked(final IWirelessCraftingTermHandler wirelessTerminal, final ItemStack wirelessTerminalItemstack) {
@@ -2,7 +2,7 @@ package net.p455w0rd.wirelesscraftingterminal.reference;
public class Reference {
public static final String MODID = "ae2wct";
public static final String VERSION = "1.7.10-rv3-1.4b";
public static final String VERSION = "1.7.10-rv3-1.5b";
public static final String NAME = "AE2 Wireless Crafting Terminal";
public static final String SERVER_PROXY_CLASS = "net.p455w0rd.wirelesscraftingterminal.proxy.CommonProxy";
public static final String CLIENT_PROXY_CLASS = "net.p455w0rd.wirelesscraftingterminal.proxy.ClientProxy";