Err too much.

This commit is contained in:
AlgorithmX2
2014-01-20 10:41:37 -06:00
parent 5652ec30ec
commit 834e9c04c5
159 changed files with 7953 additions and 1541 deletions
+4 -6
View File
@@ -111,7 +111,7 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
bch.addBox( 6, 6, 11, 10, 10, 12 );
}
int itemToSend = 1;
long itemToSend = 1;
boolean didSomething = false;
@Override
@@ -140,8 +140,6 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
break;
}
boolean didSomething = false;
try
{
InventoryAdaptor d = getHandler();
@@ -183,10 +181,10 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
private void pushItemIntoTarget(InventoryAdaptor d, IEnergyGrid energy, FuzzyMode fzMode, IMEInventory<IAEItemStack> inv, IAEItemStack ais)
{
ItemStack is = ais.getItemStack();
is.stackSize = itemToSend;
is.stackSize = (int) itemToSend;
ItemStack o = d.simulateAdd( is );
int canFit = o == null ? itemToSend : itemToSend - o.stackSize;
long canFit = o == null ? itemToSend : itemToSend - o.stackSize;
if ( canFit > 0 )
{
@@ -202,7 +200,7 @@ public class PartExportBus extends PartSharedItemBus implements IGridTickable
if ( failed != null )
{
ais.setStackSize( failed.stackSize );
inv.injectItems( ais, Actionable.MODULATE );
inv.injectItems( ais, Actionable.MODULATE, mySrc );
}
else
didSomething = true;
+1 -1
View File
@@ -63,7 +63,7 @@ public class PartImportBus extends PartSharedItemBus implements IGridTickable, I
@Override
public boolean canInsert(ItemStack stack)
{
IAEItemStack out = destination.injectItems( lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE );
IAEItemStack out = destination.injectItems( lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, mySrc );
if ( out == null )
return true;
return out.getStackSize() != stack.stackSize;
+15 -1
View File
@@ -3,6 +3,7 @@ package appeng.parts.automation;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Upgrades;
import appeng.api.networking.IGridNode;
@@ -17,6 +18,19 @@ import appeng.util.Platform;
public abstract class PartSharedItemBus extends PartUpgradeable implements IGridTickable
{
private TileEntity getBlockTileEntity(TileEntity self, int x, int y, int z)
{
World w = self.worldObj;
if ( w.getChunkProvider().chunkExists( x >> 4, z >> 4 ) )
{
TileEntity te = w.getBlockTileEntity( x, y, z );
return te;
}
return null;
}
public PartSharedItemBus(Class c, ItemStack is) {
super( c, is );
}
@@ -57,7 +71,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
cached = true;
TileEntity self = getHost().getTile();
TileEntity target = self.worldObj.getBlockTileEntity( self.xCoord + side.offsetX, self.yCoord + side.offsetY, self.zCoord + side.offsetZ );
TileEntity target = getBlockTileEntity( self, self.xCoord + side.offsetX, self.yCoord + side.offsetY, self.zCoord + side.offsetZ );
int newAdaptorHash = Platform.generateTileHash( target );
+1 -1
View File
@@ -16,7 +16,7 @@ public class PartUpgradeable extends PartBasicState implements ISegmentedInvento
{
IConfigManager settings = new ConfigManager( this );
private UpgradeInventory upgrades = new UpgradeInventory( this, 4 );
private UpgradeInventory upgrades = new UpgradeInventory( is.getItem(), this, 4 );
@Override
public int getInstalledUpgrades(Upgrades u)
+49 -9
View File
@@ -1,7 +1,9 @@
package appeng.parts.automation;
import net.minecraft.block.Block;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import appeng.api.config.Upgrades;
@@ -14,18 +16,21 @@ import appeng.util.Platform;
public class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory
{
private final Object itemorblock;
private final IAEAppEngInventory parent;
private boolean cached = false;
private int FuzzyUpgrades = 0;
private int SpeedUpgrades = 0;
private int RedstoneUpgrades = 0;
private int CapacityUpgrades = 0;
private int InverterUpgrades = 0;
IAEAppEngInventory parent;
public UpgradeInventory(IAEAppEngInventory _te, int s) {
public UpgradeInventory(Object itemOrBlock, IAEAppEngInventory _te, int s) {
super( null, s );
te = this;
parent = _te;
itemorblock = itemOrBlock;
}
@Override
@@ -51,16 +56,45 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
Upgrades u = ((IUpgradeModule) it).getType( itemstack );
if ( u != null )
{
return getInstalledUpgrades( u ) < u.maxInstalled;
return getInstalledUpgrades( u ) < getMaxInstalled( u );
}
}
return false;
}
private int getMaxInstalled(Upgrades u)
{
Integer max = null;
for (ItemStack is : u.getSupported().keySet())
{
if ( is.getItem() == itemorblock )
{
max = u.getSupported().get( is );
break;
}
else if ( is.getItem() instanceof ItemBlock && Block.blocksList[((ItemBlock) is.getItem()).getBlockID()] == itemorblock )
{
max = u.getSupported().get( is );
break;
}
}
if ( max == null )
return 0;
return max;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
private void updateUpgradeInfo()
{
cached = true;
CapacityUpgrades = RedstoneUpgrades = SpeedUpgrades = FuzzyUpgrades = 0;
InverterUpgrades = CapacityUpgrades = RedstoneUpgrades = SpeedUpgrades = FuzzyUpgrades = 0;
for (ItemStack is : this)
{
@@ -82,15 +116,19 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
case SPEED:
SpeedUpgrades++;
break;
case INVERTER:
InverterUpgrades++;
break;
default:
break;
}
}
CapacityUpgrades = Math.min( CapacityUpgrades, Upgrades.CAPACITY.maxInstalled );
FuzzyUpgrades = Math.min( FuzzyUpgrades, Upgrades.FUZZY.maxInstalled );
RedstoneUpgrades = Math.min( RedstoneUpgrades, Upgrades.REDSTONE.maxInstalled );
SpeedUpgrades = Math.min( SpeedUpgrades, Upgrades.SPEED.maxInstalled );
CapacityUpgrades = Math.min( CapacityUpgrades, getMaxInstalled( Upgrades.CAPACITY ) );
FuzzyUpgrades = Math.min( FuzzyUpgrades, getMaxInstalled( Upgrades.FUZZY ) );
RedstoneUpgrades = Math.min( RedstoneUpgrades, getMaxInstalled( Upgrades.REDSTONE ) );
SpeedUpgrades = Math.min( SpeedUpgrades, getMaxInstalled( Upgrades.SPEED ) );
InverterUpgrades = Math.min( InverterUpgrades, getMaxInstalled( Upgrades.INVERTER ) );
}
public int getInstalledUpgrades(Upgrades u)
@@ -108,6 +146,8 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
return RedstoneUpgrades;
case SPEED:
return SpeedUpgrades;
case INVERTER:
return InverterUpgrades;
default:
return 0;
}