Fixed Crafting CPU Render.
Finished Crafting Confirm Screen Added logic to prevent crafting in cpus with too little storage.
This commit is contained in:
@@ -9,7 +9,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingMonitor;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPUMonitor;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BlockCraftingMonitor extends BlockCraftingUnit
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCraftingMonitor.class;
|
||||
return RenderBlockCraftingCPUMonitor.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.BaseBlockRender;
|
||||
import appeng.client.render.blocks.RenderBlockCrafting;
|
||||
import appeng.client.render.blocks.RenderBlockCraftingCPU;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
@@ -74,6 +74,12 @@ public class BlockCraftingUnit extends AEBaseBlock
|
||||
return super.getUnlocalizedName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderStateByMeta(int itemDamage)
|
||||
{
|
||||
getRendererInstance().setTemporaryRenderIcon( getIcon( 0, itemDamage ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int direction, int metadata)
|
||||
{
|
||||
@@ -94,7 +100,7 @@ public class BlockCraftingUnit extends AEBaseBlock
|
||||
@Override
|
||||
protected Class<? extends BaseBlockRender> getRenderer()
|
||||
{
|
||||
return RenderBlockCrafting.class;
|
||||
return RenderBlockCraftingCPU.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ 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 appeng.api.AEApi;
|
||||
@@ -37,6 +38,8 @@ import com.google.common.base.Joiner;
|
||||
public class GuiCraftConfirm extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerCraftConfirm ccc;
|
||||
|
||||
int rows = 5;
|
||||
|
||||
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
@@ -63,6 +66,8 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
ySize = 206;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
|
||||
ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
|
||||
if ( te instanceof WirelessTerminalGuiObject )
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
|
||||
@@ -90,7 +95,7 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
start.enabled = false;
|
||||
buttonList.add( start );
|
||||
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + (219 - 150) / 2, this.guiTop + ySize - 68, 150, 20, GuiText.CraftingCPU.getLocal() + ": "
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
|
||||
+ GuiText.Automatic );
|
||||
selectcpu.enabled = false;
|
||||
buttonList.add( selectcpu );
|
||||
@@ -101,11 +106,36 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
buttonList.add( cancel );
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic;
|
||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
|
||||
if ( ccc.noCPU )
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
|
||||
selectcpu.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == selectcpu )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == cancel )
|
||||
{
|
||||
try
|
||||
@@ -273,7 +303,9 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
start.enabled = isSimulation() ? false : true;
|
||||
updateCPUButtonText();
|
||||
|
||||
start.enabled = ccc.noCPU || isSimulation() ? false : true;
|
||||
selectcpu.enabled = isSimulation() ? false : true;
|
||||
|
||||
int x = 0;
|
||||
@@ -315,9 +347,7 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
ContainerCraftConfirm c = (ContainerCraftConfirm) inventorySlots;
|
||||
|
||||
long BytesUsed = c.bytesUsed;
|
||||
long BytesUsed = ccc.bytesUsed;
|
||||
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
|
||||
String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
||||
fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
|
||||
@@ -327,7 +357,7 @@ public class GuiCraftConfirm extends AEBaseGui
|
||||
if ( isSimulation() )
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
else
|
||||
dsp = c.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + c.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + c.cpuCoProcessors)
|
||||
dsp = ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + ccc.cpuCoProcessors)
|
||||
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
|
||||
int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2;
|
||||
|
||||
@@ -464,4 +464,22 @@ public class BusRenderHelper implements IPartRenderHelper
|
||||
az = dz == null ? ForgeDirection.SOUTH : dz;
|
||||
}
|
||||
|
||||
public double[] getBounds()
|
||||
{
|
||||
return new double[] { minX, minY, minZ, maxX, maxY, maxZ };
|
||||
}
|
||||
|
||||
public void setBounds(double[] bounds)
|
||||
{
|
||||
if ( bounds == null || bounds.length != 6 )
|
||||
return;
|
||||
|
||||
minX = bounds[0];
|
||||
minY = bounds[1];
|
||||
minZ = bounds[2];
|
||||
maxX = bounds[3];
|
||||
maxY = bounds[4];
|
||||
maxZ = bounds[5];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -524,10 +524,10 @@ public class RenderBlocksWorkaround extends RenderBlocks
|
||||
}
|
||||
else
|
||||
{
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d3, d6 );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d4, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d12, d13, d15, d4, d6 );
|
||||
tessellator.addVertexWithUV( d12, d13, d14, d4, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d14, d3, d5 );
|
||||
tessellator.addVertexWithUV( d11, d13, d15, d3, d6 );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -179,6 +179,7 @@ public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvide
|
||||
|
||||
BusRenderer.instance.renderer.blockAccess = renderer.blockAccess;
|
||||
renderer = BusRenderer.instance.renderer;
|
||||
BusRenderer.instance.renderer.isFacade = true;
|
||||
|
||||
preRenderInWorld( block, world, x, y, z, renderer );
|
||||
|
||||
@@ -242,6 +243,7 @@ public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvide
|
||||
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
||||
|
||||
renderer.renderAllFaces = false;
|
||||
BusRenderer.instance.renderer.isFacade = false;
|
||||
|
||||
postRenderInWorld( renderer );
|
||||
|
||||
|
||||
+21
-11
@@ -19,14 +19,14 @@ import appeng.client.render.BusRenderer;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
|
||||
public class RenderBlockCrafting extends BaseBlockRender
|
||||
public class RenderBlockCraftingCPU extends BaseBlockRender
|
||||
{
|
||||
|
||||
protected RenderBlockCrafting(boolean useTesr, int range) {
|
||||
protected RenderBlockCraftingCPU(boolean useTesr, int range) {
|
||||
super( useTesr, range );
|
||||
}
|
||||
|
||||
public RenderBlockCrafting() {
|
||||
public RenderBlockCraftingCPU() {
|
||||
super( false, 20 );
|
||||
}
|
||||
|
||||
@@ -55,16 +55,17 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
theIcon = blk.getIcon( ForgeDirection.SOUTH.ordinal(), meta | (formed ? 8 : 0) );
|
||||
|
||||
IIcon nonForward = theIcon;
|
||||
if ( blk instanceof BlockCraftingMonitor )
|
||||
if ( isMonitor )
|
||||
nonForward = AEApi.instance().blocks().blockCraftingUnit.block().getIcon( 0, meta | (formed ? 8 : 0) );
|
||||
|
||||
if ( formed )
|
||||
{
|
||||
renderer = BusRenderer.instance.renderer;
|
||||
BusRenderHelper i = BusRenderHelper.instance;
|
||||
BusRenderer.instance.renderer.isFacade = true;
|
||||
|
||||
renderer.blockAccess = w;
|
||||
i.setPass( 0 );
|
||||
|
||||
i.setOrientation( ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH );
|
||||
|
||||
try
|
||||
@@ -73,9 +74,9 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
t.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
float highX = isConnected( w, x, y, z, ForgeDirection.EAST ) ? 16 : 13.01f;
|
||||
float lowX = isConnected( w, x, y, z, ForgeDirection.WEST ) ? 0 : 2.99f;
|
||||
|
||||
@@ -100,9 +101,14 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
fso( side, highX, ForgeDirection.EAST ), fso( side, highY, ForgeDirection.UP ), fso( side, highZ, ForgeDirection.SOUTH ) );
|
||||
i.prepareBounds( renderer );
|
||||
|
||||
handleSide( blk, meta, x, y, z, i, renderer, ct.getForward().equals( side ) ? theIcon : nonForward, emitsLight, isMonitor, side, w );
|
||||
boolean LocalEmit = emitsLight;
|
||||
if ( blk instanceof BlockCraftingMonitor && !ct.getForward().equals( side ) )
|
||||
LocalEmit = false;
|
||||
|
||||
handleSide( blk, meta, x, y, z, i, renderer, ct.getForward().equals( side ) ? theIcon : nonForward, LocalEmit, isMonitor, side, w );
|
||||
}
|
||||
|
||||
BusRenderer.instance.renderer.isFacade = false;
|
||||
i.setFacesToRender( EnumSet.allOf( ForgeDirection.class ) );
|
||||
i.normalRendering();
|
||||
|
||||
@@ -165,8 +171,6 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
return;
|
||||
|
||||
i.setFacesToRender( EnumSet.of( side ) );
|
||||
renderer = BusRenderer.instance.renderer;
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateWest = renderer.uvRotateTop = 0;
|
||||
|
||||
if ( meta == 0 && blk.getClass() == BlockCraftingUnit.class )
|
||||
{
|
||||
@@ -200,12 +204,19 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
}
|
||||
}
|
||||
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLong.getIcon() );
|
||||
for (ForgeDirection a : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if ( a == side || a == side.getOpposite() )
|
||||
continue;
|
||||
|
||||
if ( (side.offsetX != 0 || side.offsetZ != 0)
|
||||
&& (a == ForgeDirection.NORTH || a == ForgeDirection.EAST || a == ForgeDirection.WEST || a == ForgeDirection.SOUTH) )
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() );
|
||||
else if ( (side.offsetY != 0) && (a == ForgeDirection.EAST || a == ForgeDirection.WEST) )
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() );
|
||||
else
|
||||
i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLong.getIcon() );
|
||||
|
||||
double width = 3.0 / 16.0;
|
||||
|
||||
if ( !(i.getBound( a ) < 0.001 || i.getBound( a ) > 15.999) )
|
||||
@@ -255,7 +266,6 @@ public class RenderBlockCrafting extends BaseBlockRender
|
||||
|
||||
i.renderBlockCurrentBounds( x, y, z, renderer );
|
||||
i.prepareBounds( renderer );
|
||||
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateWest = renderer.uvRotateTop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -20,10 +20,10 @@ import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.crafting.TileCraftingMonitorTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class RenderBlockCraftingMonitor extends RenderBlockCrafting
|
||||
public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU
|
||||
{
|
||||
|
||||
public RenderBlockCraftingMonitor() {
|
||||
public RenderBlockCraftingCPUMonitor() {
|
||||
super( true, 20 );
|
||||
}
|
||||
|
||||
@@ -67,8 +67,17 @@ public class RenderBlockCraftingMonitor extends RenderBlockCrafting
|
||||
private void tesrRenderScreen(Tessellator tess, TileCraftingMonitorTile cmt, IAEItemStack ais)
|
||||
{
|
||||
ForgeDirection side = cmt.getForward();
|
||||
|
||||
ForgeDirection walrus = side.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP;
|
||||
int spin = 0;
|
||||
|
||||
int max = 5;
|
||||
while (walrus != cmt.getUp() && max-- > 0)
|
||||
{
|
||||
spin++;
|
||||
walrus = Platform.rotateAround( walrus, side );
|
||||
}
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
ForgeDirection d = side;
|
||||
GL11.glTranslated( d.offsetX * 0.69, d.offsetY * 0.69, d.offsetZ * 0.69 );
|
||||
@@ -66,7 +66,8 @@ public enum ExtraBlockTextures
|
||||
BlockCraftingStorage1kFit("BlockCraftingStorageFit"), BlockCraftingStorage4kFit("BlockCraftingStorage4kFit"), BlockCraftingStorage16kFit(
|
||||
"BlockCraftingStorage16kFit"), BlockCraftingStorage64kFit("BlockCraftingStorage64kFit"),
|
||||
|
||||
BlockCraftingUnitRing("BlockCraftingUnitRing"), BlockCraftingUnitRingLong("BlockCraftingUnitRingLong"), BlockCraftingUnitFit("BlockCraftingUnitFit"),
|
||||
BlockCraftingUnitRing("BlockCraftingUnitRing"), BlockCraftingUnitRingLongRotated("BlockCraftingUnitRingLongRotated"), BlockCraftingUnitRingLong(
|
||||
"BlockCraftingUnitRingLong"), BlockCraftingUnitFit("BlockCraftingUnitFit"),
|
||||
|
||||
BlockCraftingMonitorOuter("BlockCraftingMonitorOuter"), BlockCraftingFitSolid("BlockCraftingFitSolid");
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package appeng.container.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -13,6 +15,7 @@ import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.crafting.ICraftingCPU;
|
||||
import appeng.api.networking.crafting.ICraftingGrid;
|
||||
import appeng.api.networking.crafting.ICraftingJob;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
@@ -28,6 +31,10 @@ import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.util.ItemSorters;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
public class ContainerCraftConfirm extends AEBaseContainer
|
||||
{
|
||||
@@ -51,15 +58,131 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
||||
@GuiSync(4)
|
||||
public boolean simulation = true;
|
||||
|
||||
@GuiSync(5)
|
||||
public int selectedCpu = -1;
|
||||
|
||||
@GuiSync(6)
|
||||
public boolean noCPU = true;
|
||||
|
||||
protected long cpuIdx = Long.MIN_VALUE;
|
||||
|
||||
public class CraftingCPURecord implements Comparable<CraftingCPURecord>
|
||||
{
|
||||
|
||||
ICraftingCPU cpu;
|
||||
|
||||
long id = cpuIdx++;
|
||||
long size;
|
||||
int processors;
|
||||
|
||||
CraftingCPURecord(long size, int proc, ICraftingCPU server) {
|
||||
this.size = size;
|
||||
this.processors = proc;
|
||||
this.cpu = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(CraftingCPURecord o)
|
||||
{
|
||||
int a = ItemSorters.compareLong( o.processors, processors );
|
||||
if ( a != 0 )
|
||||
return a;
|
||||
return ItemSorters.compareLong( o.size, size );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public ArrayList<CraftingCPURecord> cpus = new ArrayList();
|
||||
|
||||
public ContainerCraftConfirm(InventoryPlayer ip, ITerminalHost te) {
|
||||
super( ip, te );
|
||||
priHost = te;
|
||||
}
|
||||
|
||||
private void sendCPUs()
|
||||
{
|
||||
Collections.sort( cpus );
|
||||
|
||||
if ( selectedCpu >= cpus.size() )
|
||||
{
|
||||
selectedCpu = -1;
|
||||
cpuBytesAvail = 0;
|
||||
cpuCoProcessors = 0;
|
||||
}
|
||||
else if ( selectedCpu != -1 )
|
||||
{
|
||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||
}
|
||||
}
|
||||
|
||||
public void cycleCpu(boolean next)
|
||||
{
|
||||
if ( next )
|
||||
selectedCpu++;
|
||||
else
|
||||
selectedCpu--;
|
||||
|
||||
if ( selectedCpu < -1 )
|
||||
selectedCpu = cpus.size() - 1;
|
||||
else if ( selectedCpu >= cpus.size() )
|
||||
selectedCpu = -1;
|
||||
|
||||
if ( selectedCpu == -1 )
|
||||
{
|
||||
cpuBytesAvail = 0;
|
||||
cpuCoProcessors = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cpuBytesAvail = cpus.get( selectedCpu ).size;
|
||||
cpuCoProcessors = cpus.get( selectedCpu ).processors;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class );
|
||||
ImmutableSet<ICraftingCPU> cpuSet = cc.getCpus();
|
||||
|
||||
int matches = 0;
|
||||
boolean changed = false;
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
boolean found = false;
|
||||
for (CraftingCPURecord ccr : cpus)
|
||||
if ( ccr.cpu == c )
|
||||
found = true;
|
||||
|
||||
boolean matched = cpuMatches( c );
|
||||
|
||||
if ( matched )
|
||||
matches++;
|
||||
|
||||
if ( !found != matched )
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if ( changed || cpus.size() != matches )
|
||||
{
|
||||
cpus.clear();
|
||||
for (ICraftingCPU c : cpuSet)
|
||||
{
|
||||
if ( cpuMatches( c ) )
|
||||
cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) );
|
||||
}
|
||||
|
||||
sendCPUs();
|
||||
}
|
||||
|
||||
noCPU = cpus.size() == 0;
|
||||
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if ( job != null && job.isDone() )
|
||||
{
|
||||
try
|
||||
@@ -157,12 +280,17 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
||||
verifyPermissions( SecurityPermissions.CRAFT, false );
|
||||
}
|
||||
|
||||
private boolean cpuMatches(ICraftingCPU c)
|
||||
{
|
||||
return c.getAvailableStorage() >= bytesUsed && !c.isBusy();
|
||||
}
|
||||
|
||||
public void startJob()
|
||||
{
|
||||
if ( result != null && simulation == false )
|
||||
{
|
||||
ICraftingGrid cc = getGrid().getCache( ICraftingGrid.class );
|
||||
cc.submitJob( result, null, null, getActionSrc() );
|
||||
cc.submitJob( result, null, selectedCpu == -1 ? null : cpus.get( selectedCpu ).cpu, getActionSrc() );
|
||||
this.isContainerValid = false;
|
||||
}
|
||||
}
|
||||
@@ -204,5 +332,4 @@ public class ContainerCraftConfirm extends AEBaseContainer
|
||||
{
|
||||
return new PlayerSource( getPlayerInv().player, (IActionHost) getTarget() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public enum GuiText
|
||||
|
||||
OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting,
|
||||
|
||||
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal;
|
||||
Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs;
|
||||
|
||||
String root;
|
||||
|
||||
|
||||
@@ -55,6 +55,12 @@ public class PacketValueConfig extends AppEngPacket
|
||||
si.onWheel( is, Value.equals( "WheelUp" ) );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "Terminal.Cpu" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
qk.cycleCpu( Value.equals( "Next" ) );
|
||||
return;
|
||||
}
|
||||
else if ( Name.equals( "Terminal.Start" ) && c instanceof ContainerCraftConfirm )
|
||||
{
|
||||
ContainerCraftConfirm qk = (ContainerCraftConfirm) c;
|
||||
|
||||
Vendored
+30
-3
@@ -1,6 +1,8 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -49,6 +51,7 @@ import appeng.crafting.CraftingLinkNexus;
|
||||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
import appeng.tile.crafting.TileCraftingStorageTile;
|
||||
import appeng.tile.crafting.TileCraftingTile;
|
||||
import appeng.util.ItemSorters;
|
||||
|
||||
import com.google.common.collect.ImmutableCollection;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -70,6 +73,12 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
boolean updateList = false;
|
||||
|
||||
@Override
|
||||
public ImmutableSet<ICraftingCPU> getCpus()
|
||||
{
|
||||
return ImmutableSet.copyOf( (HashSet<ICraftingCPU>) (HashSet) cpuClusters );
|
||||
}
|
||||
|
||||
public CraftingGridCache(IGrid g) {
|
||||
grid = g;
|
||||
}
|
||||
@@ -345,19 +354,37 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
|
||||
|
||||
if ( target == null )
|
||||
{
|
||||
// TODO real stuff...
|
||||
List<CraftingCPUCluster> validCpusClusters = new ArrayList<CraftingCPUCluster>();
|
||||
for (CraftingCPUCluster cpu : cpuClusters)
|
||||
{
|
||||
if ( !cpu.isBusy() )
|
||||
if ( !cpu.isBusy() && cpu.getAvailableStorage() >= job.getByteTotal() )
|
||||
{
|
||||
cpuClust = cpu;
|
||||
validCpusClusters.add( cpu );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort( validCpusClusters, new Comparator<CraftingCPUCluster>() {
|
||||
|
||||
@Override
|
||||
public int compare(CraftingCPUCluster o1, CraftingCPUCluster o2)
|
||||
{
|
||||
int a = ItemSorters.compareLong( o2.getCoProcessors(), o1.getCoProcessors() );
|
||||
if ( a != 0 )
|
||||
return a;
|
||||
return ItemSorters.compareLong( o2.getAvailableStorage(), o1.getAvailableStorage() );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
if ( !validCpusClusters.isEmpty() )
|
||||
cpuClust = validCpusClusters.get( 0 );
|
||||
}
|
||||
|
||||
if ( cpuClust != null )
|
||||
{
|
||||
return cpuClust.submitJob( grid, job, src, requestingMachine );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -386,8 +386,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
|
||||
private void updateCPU()
|
||||
{
|
||||
IAEItemStack send = finalOutput;
|
||||
|
||||
if ( finalOutput != null && finalOutput.getStackSize() <= 0 )
|
||||
send = null;
|
||||
|
||||
for (TileCraftingMonitorTile t : status)
|
||||
t.setJob( finalOutput );
|
||||
t.setJob( send );
|
||||
}
|
||||
|
||||
public IGrid getGrid()
|
||||
@@ -468,6 +473,10 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
myLastLink = null;
|
||||
tasks.clear();
|
||||
waitingFor.resetStatus();
|
||||
|
||||
finalOutput = null;
|
||||
updateCPU();
|
||||
|
||||
storeItems(); // marks dirty
|
||||
}
|
||||
|
||||
@@ -701,6 +710,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU
|
||||
if ( !(job instanceof CraftingJob) )
|
||||
return null;
|
||||
|
||||
if ( isBusy() || getAvailableStorage() < job.getByteTotal() )
|
||||
return null;
|
||||
|
||||
IStorageGrid sg = g.getCache( IStorageGrid.class );
|
||||
IMEInventory<IAEItemStack> storage = sg.getItemInventory();
|
||||
MECraftingInventory ci = new MECraftingInventory( storage, true, false, false );
|
||||
|
||||
Reference in New Issue
Block a user