Removed Alpha Migration.

Fixed a crash when AE is rendering as a FMP Part.
Meteorite Loot is now less random.
Added support for CLApi ( might be neat as it develops )
This commit is contained in:
AlgorithmX2 2014-05-15 21:18:30 -05:00
parent 9ba1b133d7
commit 6f96ae6074
16 changed files with 75 additions and 1001 deletions

View file

@ -123,8 +123,6 @@ import appeng.me.cache.SecurityCache;
import appeng.me.cache.SpatialPylonCache;
import appeng.me.cache.TickManagerCache;
import appeng.me.storage.AEExternalHandler;
import appeng.migration.OldItemMaterial;
import appeng.migration.OldItemPart;
import appeng.parts.PartPlacement;
import appeng.recipes.AEItemResolver;
import appeng.recipes.RecipeHandler;
@ -354,12 +352,6 @@ public class Registration
items.itemFacade = addFeature( ItemFacade.class );
items.itemCrystalSeed = addFeature( ItemCrystalSeed.class );
if ( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaMigration ) )
{
GameRegistry.registerItem( new OldItemMaterial(), "item.ItemMaterial" );
GameRegistry.registerItem( new OldItemPart(), "item.ItemPart" );
}
addFeature( ToolEraser.class );
addFeature( ToolMeteoritePlacer.class );
addFeature( ToolDebugCard.class );

View file

@ -238,6 +238,14 @@ public class WorldSettings extends Configuration
return null;
}
public int getNextOrderedValue(String name)
{
Property p = this.get( "orderedValues", name, 0 );
int myValue = p.getInt();
p.set( myValue + 1 );
return myValue;
}
public int getPlayerID(String username)
{
ConfigCategory playerList = this.getCategory( "players" );

View file

@ -35,6 +35,7 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.client.render.BusRenderHelper;
import appeng.client.render.BusRenderer;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
@ -275,6 +276,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
if ( pass == 0 || (pass == 1 && AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass )) )
{
BusRenderHelper.instance.setPass( pass );
BusRenderer.instance.renderer.renderAllFaces = true;
BusRenderer.instance.renderer.blockAccess = world();
BusRenderer.instance.renderer.overrideBlockTexture = null;
cb.renderStatic( pos.x, pos.y, pos.z );
return BusRenderHelper.instance.getItemsRendered() > 0;
}

View file

@ -16,6 +16,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
import appeng.core.WorldSettings;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
@ -326,7 +327,14 @@ public class MeteoritePlacer
int primary = Math.max( 1, (int) (Math.random() * 4) );
for (int zz = 0; zz < primary; zz++)
{
switch ((int) (Math.random() * 1000) % 4)
int r = 0;
if ( Math.random() > 0.7 )
r = WorldSettings.getInstance().getNextOrderedValue( "presses" );
else
r = (int) (Math.random() * 1000);
switch (r % 4)
{
case 0:
ap.addItems( AEApi.instance().materials().materialCalcProcessorPress.stack( 1 ) );

View file

@ -0,0 +1,10 @@
package appeng.integration.abstraction;
import appeng.api.util.AEColor;
public interface ICLApi
{
int colorLight(AEColor color, int light);
}

View file

@ -0,0 +1,35 @@
package appeng.integration.modules;
import appeng.api.util.AEColor;
import appeng.integration.BaseModule;
import appeng.integration.abstraction.ICLApi;
public class CLApi extends BaseModule implements ICLApi
{
public static CLApi instance;
@Override
public void Init() throws Throwable
{
TestClass( coloredlightscore.src.api.CLApi.class );
}
@Override
public void PostInit() throws Throwable
{
// :P
}
@Override
public int colorLight(AEColor color, int light)
{
int mv = color.mediumVariant;
float r = (mv >> 16) & 0xff;
float g = (mv >> 8) & 0xff;
float b = (mv >> 0) & 0xff;
return coloredlightscore.src.api.CLApi.makeRGBLightValue( r / 255.0f, g / 255.0f, b / 255.0f, light / 15.0f );
}
}

View file

@ -1,10 +0,0 @@
package appeng.migration;
import net.minecraft.item.ItemStack;
public interface IItemMigrate
{
void modifyItemStack(ItemStack is);
}

View file

@ -1,310 +0,0 @@
package appeng.migration;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.texture.MissingIcon;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
import appeng.core.features.ItemStackSrc;
import appeng.items.AEBaseItem;
import appeng.items.materials.ItemMultiMaterial;
import appeng.items.materials.MaterialType;
import appeng.util.Platform;
public class OldItemMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule, IItemMigrate
{
HashMap<Integer, OldMaterialType> dmgToMaterial = new HashMap();
public static OldItemMaterial instance;
public OldItemMaterial() {
super( OldItemMaterial.class );
setfeature( EnumSet.of( AEFeature.AlphaMigration ) );
setHasSubtypes( true );
instance = this;
for (OldMaterialType omt : OldMaterialType.values())
{
createMaterial( omt );
}
}
class SlightlyBetterSort implements Comparator<String>
{
Pattern p;
public SlightlyBetterSort(Pattern p) {
this.p = p;
}
@Override
public int compare(String o1, String o2)
{
try
{
Matcher a = p.matcher( o1 );
Matcher b = p.matcher( o2 );
if ( a.find() && b.find() )
{
int ia = Integer.parseInt( a.group( 1 ) );
int ib = Integer.parseInt( b.group( 1 ) );
return Integer.compare( ia, ib );
}
}
catch (Throwable t)
{
// ek!
}
return o1.compareTo( o2 );
}
}
@Override
public void addInformation(ItemStack is, EntityPlayer player, List details, boolean moar)
{
super.addInformation( is, player, details, moar );
OldMaterialType mt = getTypeByStack( is );
if ( mt == null )
return;
if ( mt == OldMaterialType.NamePress )
{
NBTTagCompound c = Platform.openNbtData( is );
details.add( c.getString( "InscribeName" ) );
}
Upgrades u = getType( is );
if ( u != null )
{
List<String> textList = new LinkedList();
for (Entry<ItemStack, Integer> j : u.getSupported().entrySet())
{
String name = null;
int limit = j.getValue();
if ( j.getKey().getItem() instanceof IItemGroup )
{
IItemGroup ig = (IItemGroup) j.getKey().getItem();
String str = ig.getUnlocalizedGroupName( j.getKey() );
if ( str != null )
name = Platform.gui_localize( str ) + (limit > 1 ? " (" + limit + ")" : "");
}
if ( name == null )
name = j.getKey().getDisplayName() + (limit > 1 ? " (" + limit + ")" : "");
if ( !textList.contains( name ) )
textList.add( name );
}
Pattern p = Pattern.compile( "(\\d+)[^\\d]" );
SlightlyBetterSort s = new SlightlyBetterSort( p );
Collections.sort( textList, s );
details.addAll( textList );
}
}
public ItemStackSrc createMaterial(OldMaterialType mat)
{
String name = mat.name();
if ( mat.damageValue == -1 )
{
boolean enabled = true;
for (AEFeature f : mat.getFeature())
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
if ( enabled )
{
int newMaterialNum = AEConfig.instance.get( "materials", name, AEConfig.instance.getFreeMaterial( mat.ordinal() ) ).getInt();
mat.damageValue = newMaterialNum;
ItemStackSrc output = new ItemStackSrc( this, newMaterialNum );
dmgToMaterial.put( newMaterialNum, mat );
return output;
}
return null;
}
else
throw new RuntimeException( "Cannot create the same material twice..." );
}
public OldMaterialType getTypeByStack(ItemStack is)
{
if ( dmgToMaterial.containsKey( is.getItemDamage() ) )
return dmgToMaterial.get( is.getItemDamage() );
return null;
}
@Override
public IIcon getIconFromDamage(int dmg)
{
if ( dmgToMaterial.containsKey( dmg ) )
return dmgToMaterial.get( dmg ).IIcon;
return new MissingIcon( this );
}
@Override
public String getUnlocalizedName(ItemStack is)
{
return "AE2-OLD-ITEM";
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return "AE2-OLD-ITEM";
}
@Override
public void registerIcons(IIconRegister icoRegister)
{
}
@Override
public boolean hasCustomEntity(ItemStack is)
{
return getTypeByStack( is ).hasCustomEntity();
}
@Override
public Entity createEntity(World w, Entity location, ItemStack itemstack)
{
Class<? extends Entity> droppedEntity = getTypeByStack( itemstack ).getCustomEntityClass();
Entity eqi;
try
{
eqi = droppedEntity.getConstructor( World.class, double.class, double.class, double.class, ItemStack.class ).newInstance( w, location.posX,
location.posY, location.posZ, itemstack );
}
catch (Throwable t)
{
throw new RuntimeException( t );
}
eqi.motionX = location.motionX;
eqi.motionY = location.motionY;
eqi.motionZ = location.motionZ;
if ( location instanceof EntityItem && eqi instanceof EntityItem )
((EntityItem) eqi).delayBeforeCanPickup = ((EntityItem) location).delayBeforeCanPickup;
return eqi;
}
@Override
public int getBytes(ItemStack is)
{
switch (getTypeByStack( is ))
{
case Cell1kPart:
return 1024;
case Cell4kPart:
return 1024 * 4;
case Cell16kPart:
return 1024 * 16;
case Cell64kPart:
return 1024 * 64;
default:
}
return 0;
}
@Override
public boolean isStorageComponent(ItemStack is)
{
switch (getTypeByStack( is ))
{
case Cell1kPart:
case Cell4kPart:
case Cell16kPart:
case Cell64kPart:
return true;
default:
}
return false;
}
@Override
public Upgrades getType(ItemStack itemstack)
{
switch (getTypeByStack( itemstack ))
{
case CardCapacity:
return Upgrades.CAPACITY;
case CardFuzzy:
return Upgrades.FUZZY;
case CardRedstone:
return Upgrades.REDSTONE;
case CardSpeed:
return Upgrades.SPEED;
case CardInverter:
return Upgrades.INVERTER;
default:
return null;
}
}
@Override
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List cList)
{
}
@Override
public void modifyItemStack(ItemStack is)
{
if ( is.getItem() == this )
{
OldMaterialType omt = getTypeByStack( is );
for (MaterialType mt : MaterialType.values())
{
if ( omt != null && mt.toString().equals( omt.toString() ) )
{
ItemStack newStack = ItemMultiMaterial.instance.getStackByType( mt );
if ( newStack != null )
{
NBTTagCompound tmp = new NBTTagCompound();
newStack.stackSize = is.stackSize;
newStack.setTagCompound( is.getTagCompound() );
// write then read...
newStack.writeToNBT( tmp );
is.readFromNBT( tmp );
return;
}
}
}
}
}
}

View file

@ -1,240 +0,0 @@
package appeng.migration;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.implementations.items.IItemGroup;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartItem;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.features.AEFeature;
import appeng.core.features.ItemStackSrc;
import appeng.core.localization.GuiText;
import appeng.items.AEBaseItem;
import appeng.items.parts.ItemMultiPart;
import appeng.items.parts.PartType;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class OldItemPart extends AEBaseItem implements IPartItem, IItemGroup, IItemMigrate
{
class OldPartTypeIst
{
OldPartType part;
int varient;
@SideOnly(Side.CLIENT)
IIcon ico;
};
HashMap<Integer, OldPartTypeIst> dmgToPart = new HashMap();
public static OldItemPart instance;
public OldItemPart() {
super( OldItemPart.class );
setfeature( EnumSet.of( AEFeature.Core ) );
AEApi.instance().partHelper().setItemBusRenderer( this );
setHasSubtypes( true );
instance = this;
for (OldPartType omt : OldPartType.values())
{
if ( omt.getVarients() == null )
createPart( omt, null );
else
{
for (Enum e : omt.getVarients())
createPart( omt, e );
}
}
}
public ItemStackSrc createPart(OldPartType mat, Enum varient)
{
try
{
// I think this still works?
ItemStack is = new ItemStack( this );
mat.getPart().getConstructor( ItemStack.class ).newInstance( is );
}
catch (Throwable e)
{
AELog.integration(e);
return null; // part not supported..
}
String name = varient == null ? mat.name() : mat.name() + "." + varient.name();
int varID = varient == null ? 0 : varient.ordinal();
// verify
for (OldPartTypeIst p : dmgToPart.values())
{
if ( p.part == mat && p.varient == varID )
throw new RuntimeException( "Cannot create the same material twice..." );
}
boolean enabled = true;
for (AEFeature f : mat.getFeature())
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
if ( enabled )
{
int newPartNum = AEConfig.instance.get( "parts", name, AEConfig.instance.getFreePart( mat.ordinal() * 32 + varID ) ).getInt();
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
OldPartTypeIst pti = new OldPartTypeIst();
pti.part = mat;
pti.varient = varID;
dmgToPart.put( newPartNum, pti );
return output;
}
return null;
}
public int getDamageByType(OldPartType t)
{
for (Entry<Integer, OldPartTypeIst> pt : dmgToPart.entrySet())
{
if ( pt.getValue().part == t )
return pt.getKey();
}
return -1;
}
public OldPartType getTypeByStack(ItemStack is)
{
if ( is == null )
return null;
OldPartTypeIst pt = dmgToPart.get( is.getItemDamage() );
if ( pt != null )
return pt.part;
return null;
}
@Override
@SideOnly(Side.CLIENT)
public int getSpriteNumber()
{
return 0;
}
@Override
public IIcon getIconFromDamage(int dmg)
{
IIcon ico = dmgToPart.get( dmg ).ico;
return ico;
}
@Override
public String getUnlocalizedName(ItemStack is)
{
return "PART";
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack)
{
return "AE2-OLD-PART";
}
@Override
public void registerIcons(IIconRegister par1IconRegister)
{
}
@Override
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
{
return AEApi.instance().partHelper().placeBus( is, x, y, z, side, player, w );
}
@Override
public IPart createPartFromItemStack(ItemStack is)
{
try
{
OldPartType t = getTypeByStack( is );
if ( t != null )
return t.getPart().getConstructor( ItemStack.class ).newInstance( is );
}
catch (Throwable e)
{
throw new RuntimeException( "Unable to construct IBusPart from IBusItem : " + getTypeByStack( is ).getPart().getName()
+ " ; Possibly didn't have correct constructor( ItemStack )", e );
}
return null;
}
@Override
public void getSubItems(Item number, CreativeTabs tab, List cList)
{
}
public int varientOf(int itemDamage)
{
return dmgToPart.get( itemDamage ).varient;
}
@Override
public String getUnlocalizedGroupName(ItemStack is)
{
switch (getTypeByStack( is ))
{
case ImportBus:
case ExportBus:
return GuiText.IOBuses.getUnlocalized();
default:
}
return null;
}
@Override
public void modifyItemStack(ItemStack is)
{
if ( is.getItem() == this )
{
OldPartTypeIst omt = dmgToPart.get( is.getItemDamage() );
for (PartType mt : PartType.values())
{
if ( omt != null && omt.part != null && mt.toString().equals( omt.part.toString() ) )
{
ItemStack newStack = ItemMultiPart.instance.getStackFromTypeAndVarient( mt, omt.varient );
if ( newStack != null )
{
NBTTagCompound tmp = new NBTTagCompound();
newStack.stackSize = is.stackSize;
newStack.setTagCompound( is.getTagCompound() );
// write then read...
newStack.writeToNBT( tmp );
is.readFromNBT( tmp );
return;
}
}
}
}
}
}

View file

@ -1,125 +0,0 @@
package appeng.migration;
import java.util.EnumSet;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.entity.EntityChargedQuartz;
import appeng.entity.EntityIds;
import appeng.entity.EntitySingularity;
import appeng.items.materials.ItemMultiMaterial;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum OldMaterialType
{
CertusQuartzCrystal(AEFeature.Core, "crystalCertusQuartz"), CertusQuartzCrystalCharged(AEFeature.Core, EntityChargedQuartz.class),
CertusQuartzDust(AEFeature.Core, "dustCertusQuartz"), NetherQuartzDust(AEFeature.Core, "dustNetherQuartz"), Flour(AEFeature.Flour, "dustWheat"), GoldDust(
AEFeature.Core, "dustGold"), IronDust(AEFeature.Core, "dustIron"), IronNugget(AEFeature.Core, "nuggetIron"),
Silicon(AEFeature.Core, "itemSilicon"), MatterBall,
FluixCrystal(AEFeature.Core, "crystalFluix"), FluixDust(AEFeature.Core, "dustFluix"), FluixPearl(AEFeature.Core, "pearlFluix"),
PureifiedCertusQuartzCrystal, PureifiedNetherQuartzCrystal, PureifiedFluixCrystal,
CalcProcessorPress, EngProcessorPress, LogicProcessorPress,
CalcProcessorPrint, EngProcessorPrint, LogicProcessorPrint,
SiliconPress, SiliconPrint,
NamePress,
LogicProcessor, CalcProcessor, EngProcessor,
// Basic Cards
BasicCard, CardRedstone, CardCapacity,
// Adv Cards
AdvCard, CardFuzzy, CardSpeed, CardInverter,
Cell2SpatialPart(AEFeature.SpatialIO), Cell16SpatialPart(AEFeature.SpatialIO), Cell128SpatialPart(AEFeature.SpatialIO),
Cell1kPart(AEFeature.StorageCells), Cell4kPart(AEFeature.StorageCells), Cell16kPart(AEFeature.StorageCells), Cell64kPart(AEFeature.StorageCells), EmptyStorageCell(
AEFeature.StorageCells),
WoodenGear(AEFeature.GrindStone, "gearWood"),
Wireless(AEFeature.WirelessAccessTerminal), WirelessBooster(AEFeature.WirelessAccessTerminal),
FormationCore, AnnihilationCore,
SkyDust(AEFeature.Core),
EnderDust(AEFeature.QuantumNetworkBridge, "dustEnder", EntitySingularity.class), Singularity(AEFeature.QuantumNetworkBridge, EntitySingularity.class), QESingularity(
AEFeature.QuantumNetworkBridge, EntitySingularity.class);
private String oreName;
private EnumSet<AEFeature> features;
private Class<? extends Entity> droppedEntity;
// IIcon for the material.
@SideOnly(Side.CLIENT)
public IIcon IIcon;
public int damageValue = -1;
OldMaterialType() {
features = EnumSet.of( AEFeature.Core );
}
OldMaterialType(AEFeature part) {
features = EnumSet.of( part );
}
OldMaterialType(AEFeature part, Class<? extends Entity> c) {
features = EnumSet.of( part );
droppedEntity = c;
EntityRegistry.registerModEntity( droppedEntity, droppedEntity.getSimpleName(), EntityIds.get( droppedEntity ), AppEng.instance, 16, 4, true );
}
OldMaterialType(AEFeature part, String oreDictionary, Class<? extends Entity> c) {
features = EnumSet.of( part );
oreName = oreDictionary;
droppedEntity = c;
EntityRegistry.registerModEntity( droppedEntity, droppedEntity.getSimpleName(), EntityIds.get( droppedEntity ), AppEng.instance, 16, 4, true );
}
OldMaterialType(AEFeature part, String oreDictionary) {
features = EnumSet.of( part );
oreName = oreDictionary;
}
public ItemStack stack(int size)
{
return new ItemStack( ItemMultiMaterial.instance, size, damageValue );
}
public EnumSet<AEFeature> getFeature()
{
return features;
}
public String getOreName()
{
return oreName;
}
public boolean hasCustomEntity()
{
return droppedEntity != null;
}
public Class<? extends Entity> getCustomEntityClass()
{
return droppedEntity;
}
}

View file

@ -1,134 +0,0 @@
package appeng.migration;
import java.util.EnumSet;
import appeng.api.parts.IPart;
import appeng.api.util.AEColor;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.parts.automation.PartAnnihilationPlane;
import appeng.parts.automation.PartExportBus;
import appeng.parts.automation.PartFormationPlane;
import appeng.parts.automation.PartImportBus;
import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.misc.PartCableAnchor;
import appeng.parts.misc.PartInterface;
import appeng.parts.misc.PartInvertedToggleBus;
import appeng.parts.misc.PartStorageBus;
import appeng.parts.misc.PartToggleBus;
import appeng.parts.networking.PartCableCovered;
import appeng.parts.networking.PartCableGlass;
import appeng.parts.networking.PartCableSmart;
import appeng.parts.networking.PartDenseCable;
import appeng.parts.networking.PartQuartzFiber;
import appeng.parts.p2p.PartP2PBCPower;
import appeng.parts.p2p.PartP2PIC2Power;
import appeng.parts.p2p.PartP2PItems;
import appeng.parts.p2p.PartP2PLiquids;
import appeng.parts.p2p.PartP2PRFPower;
import appeng.parts.p2p.PartP2PRedstone;
import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartDarkMonitor;
import appeng.parts.reporting.PartMonitor;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.parts.reporting.PartSemiDarkMonitor;
import appeng.parts.reporting.PartStorageMonitor;
import appeng.parts.reporting.PartTerminal;
public enum OldPartType
{
ToggleBus(AEFeature.Core, PartToggleBus.class),
InvertedToggleBus(AEFeature.Core, PartInvertedToggleBus.class),
CableSmart(AEFeature.Core, PartCableSmart.class), CableCovered(AEFeature.Core, PartCableCovered.class), CableGlass(AEFeature.Core, PartCableGlass.class),
CableDense(AEFeature.DenseCables, PartDenseCable.class),
CableAnchor(AEFeature.Core, PartCableAnchor.class),
QuartzFiber(AEFeature.Core, PartQuartzFiber.class),
Monitor(AEFeature.Core, PartMonitor.class),
SemiDarkMonitor(AEFeature.Core, PartSemiDarkMonitor.class),
DarkMonitor(AEFeature.Core, PartDarkMonitor.class),
StorageBus(AEFeature.StorageBus, PartStorageBus.class),
ImportBus(AEFeature.ImportBus, PartImportBus.class),
ExportBus(AEFeature.ExportBus, PartExportBus.class),
LevelEmitter(AEFeature.LevelEmiter, PartLevelEmitter.class),
AnnihilationPlane(AEFeature.AnnihilationPlane, PartAnnihilationPlane.class),
FormationPlane(AEFeature.FormationPlane, PartFormationPlane.class),
P2PTunnelME(AEFeature.P2PTunnelME, PartP2PTunnelME.class, GuiText.METunnel),
P2PTunnelRedstone(AEFeature.P2PTunnelRedstone, PartP2PRedstone.class, GuiText.RedstoneTunnel),
P2PTunnelItems(AEFeature.P2PTunnelItems, PartP2PItems.class, GuiText.ItemTunnel),
P2PTunnelLiquids(AEFeature.P2PTunnelLiquids, PartP2PLiquids.class, GuiText.FluidTunnel),
P2PTunnelMJ(AEFeature.P2PTunnelMJ, PartP2PBCPower.class, GuiText.MJTunnel),
P2PTunnelEU(AEFeature.P2PTunnelEU, PartP2PIC2Power.class, GuiText.EUTunnel),
// CraftingMonitor(AEFeature.Crafting, PartCraftingMonitor.class),
PatternTerminal(AEFeature.CraftingTerminal, PartPatternTerminal.class),
CraftingTerminal(AEFeature.CraftingTerminal, PartCraftingTerminal.class),
Terminal(AEFeature.Core, PartTerminal.class),
StorageMonitor(AEFeature.StorageMonitor, PartStorageMonitor.class),
ConversionMonitor(AEFeature.PartConversionMonitor, PartConversionMonitor.class),
Interface(AEFeature.Core, PartInterface.class),
P2PTunnelRF(AEFeature.P2PTunnelRF, PartP2PRFPower.class, GuiText.RFTunnel);
private final EnumSet<AEFeature> features;
private final Class<? extends IPart> myPart;
private final GuiText extraName;
OldPartType(AEFeature part, Class<? extends IPart> c) {
this( part, c, null );
}
OldPartType(AEFeature part, Class<? extends IPart> c, GuiText en) {
features = EnumSet.of( part );
myPart = c;
extraName = en;
}
public Enum[] getVarients()
{
return (this == CableSmart || this == CableCovered || this == CableGlass || this == CableDense) ? AEColor.values() : null;
}
public EnumSet<AEFeature> getFeature()
{
return features;
}
public Class<? extends IPart> getPart()
{
return myPart;
}
public GuiText getExtraName()
{
return extraName;
}
}

View file

@ -40,8 +40,10 @@ import appeng.api.util.AEColor;
import appeng.api.util.DimensionalCoord;
import appeng.client.render.BusRenderHelper;
import appeng.client.render.CableRenderHelper;
import appeng.core.AppEng;
import appeng.facade.FacadeContainer;
import appeng.helpers.AEMultiTile;
import appeng.integration.abstraction.ICLApi;
import appeng.me.GridConnection;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
@ -800,12 +802,17 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
public int getLightValue()
{
int light = 0;
for (ForgeDirection d : ForgeDirection.values())
{
IPart p = getPart( d );
if ( p != null )
light = Math.max( p.getLightLevel(), light );
}
if ( light > 0 && AppEng.instance.isIntegrationEnabled( "CLApi" ) )
return ((ICLApi) AppEng.instance.getIntegration( "CLApi" )).colorLight( getColor(), light );
return light;
}

View file

@ -37,7 +37,6 @@ import appeng.client.texture.TaughtIcon;
import appeng.items.parts.ItemMultiPart;
import appeng.me.GridAccessException;
import appeng.me.helpers.AENetworkProxy;
import appeng.migration.OldItemPart;
import appeng.parts.AEBasePart;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.Side;
@ -54,10 +53,7 @@ public class PartCable extends AEBasePart implements IPartCable
public PartCable(Class c, ItemStack is) {
super( c, is );
proxy.setIdlePowerUsage( 0.0 );
if ( is.getItem() instanceof OldItemPart )
proxy.myColor = AEColor.values()[((OldItemPart) is.getItem()).varientOf( is.getItemDamage() )];
else
proxy.myColor = AEColor.values()[((ItemMultiPart) is.getItem()).varientOf( is.getItemDamage() )];
proxy.myColor = AEColor.values()[((ItemMultiPart) is.getItem()).varientOf( is.getItemDamage() )];
}
@Override

View file

@ -49,6 +49,7 @@ public class ASMIntegration implements IClassTransformer
// integrationModules.add( IntegrationSide.BOTH, "Forestry", "Forestry", "Forestry" );
// integrationModules.add( IntegrationSide.BOTH, "Mekanism", "Mekanism", "Mekanism" );
integrationModules.add( IntegrationSide.CLIENT, "Waila", "Waila", "Waila" );
integrationModules.add( IntegrationSide.BOTH, "Colored Lights Core", "coloredlightscore", "CLApi" );
integrationModules.add( IntegrationSide.BOTH, "Rotatable Blocks", "RotatableBlocks", "RB" );
integrationModules.add( IntegrationSide.CLIENT, "Inventory Tweaks", "inventorytweaks", "InvTweaks" );
integrationModules.add( IntegrationSide.CLIENT, "Not Enough Items", "NotEnoughItems", "NEI" );

View file

@ -1,153 +0,0 @@
package appeng.transformer.asm;
import java.io.InputStream;
import java.util.Iterator;
import net.minecraft.item.ItemStack;
import net.minecraft.launchwrapper.IClassTransformer;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.LabelNode;
import org.objectweb.asm.tree.LineNumberNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import appeng.migration.IItemMigrate;
public class ASMMigration implements IClassTransformer
{
@Override
public byte[] transform(String name, String transformedName, byte[] basicClass)
{
try
{
if ( transformedName != null && transformedName.equals( "net.minecraft.item.ItemStack" ) )
{
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader( basicClass );
classReader.accept( classNode, 0 );
ClassNode srcNode = new ClassNode();
InputStream is = getClass().getResourceAsStream( "/appeng/transformer/template/ItemStackTemplate.class" );
ClassReader srcReader = new ClassReader( is );
srcReader.accept( srcNode, 0 );
// MD: net/minecraft/item/ItemStack/readFromNBT (Lnet/minecraft/nbt/NBTTagCompound;)V
// abp/c (Ldg;)V
for (MethodNode mn : classNode.methods)
{
boolean signatureMatch = mn.desc.equals( "(Ldg;)V" ) || mn.desc.equals( "(Lnet/minecraft/nbt/NBTTagCompound;)V" );
boolean nameMatch = mn.name.equals( "readFromNBT" ) || mn.name.equals( "c" ) || mn.name.equals( "func_77963_c" );
if ( nameMatch && signatureMatch )
{
for (MethodNode smn : srcNode.methods)
{
if ( smn.name.equals( "readFromNBT" ) )
handleChunkAddition( classNode, srcNode.name, mn, smn, false );
}
}
}
ClassWriter writer = new ClassWriter( ClassWriter.COMPUTE_MAXS );
classNode.accept( writer );
return writer.toByteArray();
}
}
catch (Throwable t)
{
t.printStackTrace();
}
return basicClass;
}
private void handleChunkAddition(ClassNode classNode, String from, MethodNode tmn, MethodNode mn, boolean atbeginning)
{
Iterator<AbstractInsnNode> i = mn.instructions.iterator();
while (i.hasNext())
{
processNode( i.next(), from, classNode.name );
}
Iterator<AbstractInsnNode> g = mn.instructions.iterator();
while (g.hasNext())
{
AbstractInsnNode ain = g.next();
if ( ain instanceof LineNumberNode )
g.remove();
else if ( ain instanceof LabelNode )
g.remove();
}
AbstractInsnNode finalReturn = mn.instructions.getLast();
while (!isReturn( finalReturn.getOpcode() ))
{
mn.instructions.remove( finalReturn );
finalReturn = mn.instructions.getLast();
}
mn.instructions.remove( finalReturn );
if ( atbeginning )
tmn.instructions.insert( mn.instructions );
else
{
AbstractInsnNode node = tmn.instructions.getLast();
while (!isReturn( node.getOpcode() ))
node = node.getPrevious();
tmn.instructions.insertBefore( node.getPrevious(), mn.instructions );
}
}
private boolean isReturn(int opcode)
{
switch (opcode)
{
case Opcodes.ARETURN:
case Opcodes.DRETURN:
case Opcodes.FRETURN:
case Opcodes.LRETURN:
case Opcodes.IRETURN:
case Opcodes.RETURN:
return true;
}
return false;
}
private void processNode(AbstractInsnNode next, String from, String nePar)
{
if ( next instanceof FieldInsnNode )
{
FieldInsnNode min = (FieldInsnNode) next;
if ( min.owner.equals( from ) )
{
min.owner = nePar;
}
}
if ( next instanceof MethodInsnNode )
{
MethodInsnNode min = (MethodInsnNode) next;
if ( min.owner.equals( from ) )
{
min.owner = nePar;
}
}
}
public static void handleMigration(Object itemStackTemplate)
{
ItemStack is = (ItemStack) itemStackTemplate;
if ( is.getItem() != null && is.getItem() instanceof IItemMigrate )
((IItemMigrate) is.getItem()).modifyItemStack( (ItemStack) itemStackTemplate );
}
}

View file

@ -1,15 +0,0 @@
package appeng.transformer.template;
import net.minecraft.nbt.NBTTagCompound;
import appeng.transformer.asm.ASMMigration;
public class ItemStackTemplate
{
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
ASMMigration.handleMigration( this );
return;
}
}