Adjusted Timing for MAs
MAs now save when things change. Fixed a sleeping issue with MAs MAs now drop their upgrades properly.
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package appeng.tile.crafting;
|
package appeng.tile.crafting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.InventoryCrafting;
|
||||||
@@ -60,6 +62,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
private boolean isAwake = false;
|
private boolean isAwake = false;
|
||||||
private boolean forcePlan = false;
|
private boolean forcePlan = false;
|
||||||
|
|
||||||
|
private boolean reboot = true;
|
||||||
|
|
||||||
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
public boolean pushPattern(ICraftingPatternDetails patternDetails, InventoryCrafting table, ForgeDirection where)
|
||||||
{
|
{
|
||||||
if ( myPattern == null )
|
if ( myPattern == null )
|
||||||
@@ -78,6 +82,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
inv.setInventorySlotContents( x, table.getStackInSlot( x ) );
|
inv.setInventorySlotContents( x, table.getStackInSlot( x ) );
|
||||||
|
|
||||||
updateSleepyness();
|
updateSleepyness();
|
||||||
|
markDirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +91,8 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
|
|
||||||
private void recalculatePlan()
|
private void recalculatePlan()
|
||||||
{
|
{
|
||||||
|
reboot = true;
|
||||||
|
|
||||||
if ( forcePlan )
|
if ( forcePlan )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -305,10 +312,25 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
return (int) progress;
|
return (int) progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getDrops(World w, int x, int y, int z, ArrayList<ItemStack> drops)
|
||||||
|
{
|
||||||
|
super.getDrops( w, x, y, z, drops );
|
||||||
|
|
||||||
|
for (int h = 0; h < upgrades.getSizeInventory(); h++)
|
||||||
|
{
|
||||||
|
ItemStack is = upgrades.getStackInSlot( h );
|
||||||
|
if ( is != null )
|
||||||
|
drops.add( is );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TickingRequest getTickingRequest(IGridNode node)
|
public TickingRequest getTickingRequest(IGridNode node)
|
||||||
{
|
{
|
||||||
return new TickingRequest( 1, 5, isAwake = hasPattern() && hasMats() || canPush(), false );
|
recalculatePlan();
|
||||||
|
updateSleepyness();
|
||||||
|
return new TickingRequest( 1, 1, !isAwake, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasMats()
|
private boolean hasMats()
|
||||||
@@ -329,35 +351,39 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
{
|
{
|
||||||
pushOut( inv.getStackInSlot( 9 ) );
|
pushOut( inv.getStackInSlot( 9 ) );
|
||||||
ejectHeldItems();
|
ejectHeldItems();
|
||||||
isAwake = inv.getStackInSlot( 9 ) != null;
|
updateSleepyness();
|
||||||
return isAwake ? TickRateModulation.SLEEP : TickRateModulation.IDLE;
|
return isAwake ? TickRateModulation.SLEEP : TickRateModulation.IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( myPlan == null )
|
if ( myPlan == null )
|
||||||
{
|
{
|
||||||
isAwake = false;
|
updateSleepyness();
|
||||||
return TickRateModulation.SLEEP;
|
return TickRateModulation.SLEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( reboot )
|
||||||
|
TicksSinceLastCall = 1;
|
||||||
|
|
||||||
|
reboot = false;
|
||||||
switch (upgrades.getInstalledUpgrades( Upgrades.SPEED ))
|
switch (upgrades.getInstalledUpgrades( Upgrades.SPEED ))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
progress += userPower( TicksSinceLastCall );
|
progress += userPower( TicksSinceLastCall * 10 );
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
progress += userPower( TicksSinceLastCall * 2 );
|
progress += userPower( TicksSinceLastCall * 13 );
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
progress += userPower( TicksSinceLastCall * 6 );
|
progress += userPower( TicksSinceLastCall * 17 );
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
progress += userPower( TicksSinceLastCall * 12 );
|
progress += userPower( TicksSinceLastCall * 20 );
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
progress += userPower( TicksSinceLastCall * 30 );
|
progress += userPower( TicksSinceLastCall * 25 );
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
progress += userPower( TicksSinceLastCall * 120 );
|
progress += userPower( TicksSinceLastCall * 50 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +408,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
|
|
||||||
ejectHeldItems();
|
ejectHeldItems();
|
||||||
|
|
||||||
isAwake = inv.getStackInSlot( 9 ) != null;
|
updateSleepyness();
|
||||||
return isAwake ? TickRateModulation.SLEEP : TickRateModulation.IDLE;
|
return isAwake ? TickRateModulation.SLEEP : TickRateModulation.IDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,6 +427,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
{
|
{
|
||||||
inv.setInventorySlotContents( 9, is );
|
inv.setInventorySlotContents( 9, is );
|
||||||
inv.setInventorySlotContents( x, null );
|
inv.setInventorySlotContents( x, null );
|
||||||
|
markDirty();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,7 +480,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||||||
if ( adaptor == null )
|
if ( adaptor == null )
|
||||||
return output;
|
return output;
|
||||||
|
|
||||||
return adaptor.addItems( output );
|
int size = output.stackSize;
|
||||||
|
output = adaptor.addItems( output );
|
||||||
|
int newSize = output == null ? 0 : output.stackSize;
|
||||||
|
|
||||||
|
if ( size != newSize )
|
||||||
|
markDirty();
|
||||||
|
|
||||||
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user