Implementing Crafting Upgrade.

This commit is contained in:
AlgorithmX2 2014-07-01 20:44:12 -05:00
parent 4ce40869f4
commit 9a2614540d
4 changed files with 48 additions and 2 deletions

View file

@ -288,6 +288,8 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
return Upgrades.SPEED;
case CardInverter:
return Upgrades.INVERTER;
case CardCrafting:
return Upgrades.CRAFTING;
default:
return null;
}

View file

@ -62,7 +62,7 @@ public enum MaterialType
EnderDust(46, AEFeature.QuantumNetworkBridge, "dustEnder", EntitySingularity.class), Singularity(47, AEFeature.QuantumNetworkBridge,
EntitySingularity.class), QESingularity(48, AEFeature.QuantumNetworkBridge, EntitySingularity.class),
BlankPattern(52);
BlankPattern(52), CardCrafting(53);
private String oreName;
private EnumSet<AEFeature> features;

View file

@ -25,6 +25,7 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
private int RedstoneUpgrades = 0;
private int CapacityUpgrades = 0;
private int InverterUpgrades = 0;
private int CraftingUpgrades = 0;
public UpgradeInventory(Object itemOrBlock, IAEAppEngInventory _te, int s) {
super( null, s );
@ -98,7 +99,7 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
private void updateUpgradeInfo()
{
cached = true;
InverterUpgrades = CapacityUpgrades = RedstoneUpgrades = SpeedUpgrades = FuzzyUpgrades = 0;
InverterUpgrades = CapacityUpgrades = RedstoneUpgrades = SpeedUpgrades = FuzzyUpgrades = CraftingUpgrades = 0;
for (ItemStack is : this)
{
@ -123,6 +124,9 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
case INVERTER:
InverterUpgrades++;
break;
case CRAFTING:
CraftingUpgrades++;
break;
default:
break;
}
@ -133,6 +137,7 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
RedstoneUpgrades = Math.min( RedstoneUpgrades, getMaxInstalled( Upgrades.REDSTONE ) );
SpeedUpgrades = Math.min( SpeedUpgrades, getMaxInstalled( Upgrades.SPEED ) );
InverterUpgrades = Math.min( InverterUpgrades, getMaxInstalled( Upgrades.INVERTER ) );
CraftingUpgrades = Math.min( CraftingUpgrades, getMaxInstalled( Upgrades.CRAFTING ) );
}
public int getInstalledUpgrades(Upgrades u)
@ -152,6 +157,8 @@ public class UpgradeInventory extends AppEngInternalInventory implements IAEAppE
return SpeedUpgrades;
case INVERTER:
return InverterUpgrades;
case CRAFTING:
return CraftingUpgrades;
default:
return 0;
}

View file

@ -2,6 +2,7 @@ package appeng.tile.crafting;
import java.util.EnumSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
@ -15,6 +16,8 @@ import appeng.me.cluster.implementations.CraftingCPUCalculator;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.AENetworkProxyMultiblock;
import appeng.tile.events.AETileEventHandler;
import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkTile;
import appeng.util.Platform;
@ -25,6 +28,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
final CraftingCPUCalculator calc = new CraftingCPUCalculator( this );
public ISimplifiedBundle lightCache;
public NBTTagCompound previousState = null;
public boolean isCoreBlock = false;
@Override
protected AENetworkProxy createProxy()
{
@ -42,7 +48,38 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
calc.calculateMultiblock( worldObj, getLocation() );
}
private class CraftingHandler extends AETileEventHandler
{
public CraftingHandler() {
super( TileEventType.WORLD_NBT );
}
@Override
public void writeToNBT(NBTTagCompound data)
{
data.setBoolean( "core", isCoreBlock );
if ( isCoreBlock && clust != null )
clust.writeToNBT( data );
}
@Override
public void readFromNBT(NBTTagCompound data)
{
isCoreBlock = data.getBoolean( "core" );
if ( isCoreBlock )
{
if ( clust != null )
clust.readFromNBT( data );
else
previousState = (NBTTagCompound) data.copy();
}
}
};
public TileCraftingTile() {
addNewHandler( new CraftingHandler() );
gridProxy.setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL );
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
}