Fixes #675 No disabled feature should log spam or crash anymore.
Deprecates the old usage of the AEItemDefinitions via the direct method access of * blocks() * parts() * items() * materials() and thus use the new re-direct via definitions(). All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
@@ -22,12 +22,12 @@ package appeng.items;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.FeatureNameExtractor;
|
||||
import appeng.core.features.IAEFeature;
|
||||
@@ -35,22 +35,22 @@ import appeng.core.features.IFeatureHandler;
|
||||
import appeng.core.features.ItemFeatureHandler;
|
||||
|
||||
|
||||
public class AEBaseItem extends Item implements IAEFeature
|
||||
public abstract class AEBaseItem extends Item implements IAEFeature
|
||||
{
|
||||
private final String fullName;
|
||||
private final Optional<String> subName;
|
||||
private IFeatureHandler feature;
|
||||
|
||||
public AEBaseItem( Class c )
|
||||
public AEBaseItem()
|
||||
{
|
||||
this( c, Optional.<String> absent() );
|
||||
this.canRepair = false;
|
||||
this( Optional.<String> absent() );
|
||||
this.setNoRepair();
|
||||
}
|
||||
|
||||
public AEBaseItem( Class<?> c, Optional<String> subName )
|
||||
public AEBaseItem( Optional<String> subName )
|
||||
{
|
||||
this.subName = subName;
|
||||
this.fullName = new FeatureNameExtractor( c, subName ).get();
|
||||
this.fullName = new FeatureNameExtractor( this.getClass(), subName ).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,18 +18,20 @@
|
||||
|
||||
package appeng.items.contents;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.parts.automation.StackUpgradeInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CellUpgrades extends UpgradeInventory
|
||||
{
|
||||
|
||||
public final class CellUpgrades extends StackUpgradeInventory
|
||||
{
|
||||
final ItemStack is;
|
||||
|
||||
public CellUpgrades(ItemStack is, int upgrades) {
|
||||
super( is.getItem(), null, upgrades );
|
||||
public CellUpgrades( ItemStack is, int upgrades )
|
||||
{
|
||||
super( is, null, upgrades );
|
||||
this.is = is;
|
||||
this.readFromNBT( Platform.openNbtData( is ), "upgrades" );
|
||||
}
|
||||
@@ -39,5 +41,4 @@ public class CellUpgrades extends UpgradeInventory
|
||||
{
|
||||
this.writeToNBT( Platform.openNbtData( this.is ), "upgrades" );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
package appeng.items.materials;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
@@ -27,12 +26,11 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -49,70 +47,45 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.api.implementations.tiles.ISegmentedInventory;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.SelectedPart;
|
||||
import appeng.client.texture.MissingIcon;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.core.features.MaterialStackSrc;
|
||||
import appeng.core.features.NameResolver;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.InventoryAdaptor;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, IUpgradeModule
|
||||
{
|
||||
|
||||
final HashMap<Integer, MaterialType> dmgToMaterial = new HashMap<Integer, MaterialType>();
|
||||
|
||||
public static final int KILO = 1024;
|
||||
public static ItemMultiMaterial instance;
|
||||
|
||||
public ItemMultiMaterial() {
|
||||
super( ItemMultiMaterial.class );
|
||||
private final Map<Integer, MaterialType> dmgToMaterial = new HashMap<Integer, MaterialType>();
|
||||
private final NameResolver nameResolver;
|
||||
|
||||
public ItemMultiMaterial()
|
||||
{
|
||||
this.nameResolver = new NameResolver( this.getClass() );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
this.setHasSubtypes( true );
|
||||
instance = this;
|
||||
}
|
||||
|
||||
static class SlightlyBetterSort implements Comparator<String>
|
||||
{
|
||||
|
||||
final Pattern p;
|
||||
|
||||
public SlightlyBetterSort(Pattern p) {
|
||||
this.p = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2)
|
||||
{
|
||||
try
|
||||
{
|
||||
Matcher a = this.p.matcher( o1 );
|
||||
Matcher b = this.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 addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
|
||||
@@ -130,7 +103,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
if ( u != null )
|
||||
{
|
||||
List<String> textList = new LinkedList<String>();
|
||||
for (Entry<ItemStack, Integer> j : u.getSupported().entrySet())
|
||||
for ( Entry<ItemStack, Integer> j : u.getSupported().entrySet() )
|
||||
{
|
||||
String name = null;
|
||||
|
||||
@@ -141,11 +114,11 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
IItemGroup ig = (IItemGroup) j.getKey().getItem();
|
||||
String str = ig.getUnlocalizedGroupName( u.getSupported().keySet(), j.getKey() );
|
||||
if ( str != null )
|
||||
name = Platform.gui_localize( str ) + (limit > 1 ? " (" + limit + ')' : "");
|
||||
name = Platform.gui_localize( str ) + ( limit > 1 ? " (" + limit + ')' : "" );
|
||||
}
|
||||
|
||||
if ( name == null )
|
||||
name = j.getKey().getDisplayName() + (limit > 1 ? " (" + limit + ')' : "");
|
||||
name = j.getKey().getDisplayName() + ( limit > 1 ? " (" + limit + ')' : "" );
|
||||
|
||||
if ( !textList.contains( name ) )
|
||||
textList.add( name );
|
||||
@@ -158,12 +131,41 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
}
|
||||
|
||||
public IStackSrc createMaterial(MaterialType mat)
|
||||
public MaterialType getTypeByStack( ItemStack is )
|
||||
{
|
||||
if ( this.dmgToMaterial.containsKey( is.getItemDamage() ) )
|
||||
return this.dmgToMaterial.get( is.getItemDamage() );
|
||||
return MaterialType.InvalidType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Upgrades getType( ItemStack itemstack )
|
||||
{
|
||||
switch ( this.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;
|
||||
case CardCrafting:
|
||||
return Upgrades.CRAFTING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IStackSrc createMaterial( MaterialType mat )
|
||||
{
|
||||
if ( !mat.isRegistered() )
|
||||
{
|
||||
boolean enabled = true;
|
||||
for (AEFeature f : mat.getFeature())
|
||||
for ( AEFeature f : mat.getFeature() )
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
if ( enabled )
|
||||
@@ -172,17 +174,17 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
int newMaterialNum = mat.damageValue;
|
||||
mat.markReady();
|
||||
|
||||
IStackSrc output = mat.stackSrc = new MaterialStackSrc( mat );
|
||||
mat.stackSrc = new MaterialStackSrc( mat );
|
||||
|
||||
if ( this.dmgToMaterial.get( newMaterialNum ) == null )
|
||||
this.dmgToMaterial.put( newMaterialNum, mat );
|
||||
else
|
||||
throw new RuntimeException( "Meta Overlap detected." );
|
||||
|
||||
return output;
|
||||
return mat.stackSrc;
|
||||
}
|
||||
|
||||
return null;
|
||||
return mat.stackSrc;
|
||||
}
|
||||
else
|
||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
||||
@@ -190,7 +192,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
public void makeUnique()
|
||||
{
|
||||
for (MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() ))
|
||||
for ( MaterialType mt : ImmutableSet.copyOf( this.dmgToMaterial.values() ) )
|
||||
{
|
||||
if ( mt.getOreName() != null )
|
||||
{
|
||||
@@ -198,15 +200,15 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
String[] names = mt.getOreName().split( "," );
|
||||
|
||||
for (String name : names)
|
||||
for ( String name : names )
|
||||
{
|
||||
if ( replacement != null )
|
||||
break;
|
||||
|
||||
ArrayList<ItemStack> options = OreDictionary.getOres( name );
|
||||
List<ItemStack> options = OreDictionary.getOres( name );
|
||||
if ( options != null && options.size() > 0 )
|
||||
{
|
||||
for (ItemStack is : options)
|
||||
for ( ItemStack is : options )
|
||||
{
|
||||
if ( is != null && is.getItem() != null )
|
||||
{
|
||||
@@ -220,7 +222,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
if ( replacement == null || AEConfig.instance.useAEVersion( mt ) )
|
||||
{
|
||||
// continue using the AE2 item.
|
||||
for (String name : names)
|
||||
for ( String name : names )
|
||||
OreDictionary.registerOre( name, mt.stack( 1 ) );
|
||||
}
|
||||
else
|
||||
@@ -231,27 +233,25 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
mt.itemInstance = replacement.getItem();
|
||||
mt.damageValue = replacement.getItemDamage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialType getTypeByStack(ItemStack is)
|
||||
{
|
||||
if ( this.dmgToMaterial.containsKey( is.getItemDamage() ) )
|
||||
return this.dmgToMaterial.get( is.getItemDamage() );
|
||||
return MaterialType.InvalidType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int dmg)
|
||||
public IIcon getIconFromDamage( int dmg )
|
||||
{
|
||||
if ( this.dmgToMaterial.containsKey( dmg ) )
|
||||
return this.dmgToMaterial.get( dmg ).IIcon;
|
||||
return new MissingIcon( this );
|
||||
}
|
||||
|
||||
private String nameOf(ItemStack is)
|
||||
@Override
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
return "item.appliedenergistics2." + this.nameOf( is );
|
||||
}
|
||||
|
||||
private String nameOf( ItemStack is )
|
||||
{
|
||||
if ( is == null )
|
||||
return "null";
|
||||
@@ -260,19 +260,34 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
if ( mt == null )
|
||||
return "null";
|
||||
|
||||
return AEFeatureHandler.getName( ItemMultiMaterial.class, mt.name() );
|
||||
return this.nameResolver.getName( mt.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
public void getSubItems( Item par1, CreativeTabs par2CreativeTabs, List cList )
|
||||
{
|
||||
return "item.appliedenergistics2." + this.nameOf( is );
|
||||
List<MaterialType> types = Arrays.asList( MaterialType.values() );
|
||||
Collections.sort( types, new Comparator<MaterialType>()
|
||||
{
|
||||
|
||||
@Override
|
||||
public int compare( MaterialType o1, MaterialType o2 )
|
||||
{
|
||||
return o1.name().compareTo( o2.name() );
|
||||
}
|
||||
} );
|
||||
|
||||
for ( MaterialType mat : types )
|
||||
{
|
||||
if ( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this )
|
||||
cList.add( new ItemStack( this, 1, mat.damageValue ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister icoRegister)
|
||||
public void registerIcons( IIconRegister icoRegister )
|
||||
{
|
||||
for (MaterialType mat : MaterialType.values())
|
||||
for ( MaterialType mat : MaterialType.values() )
|
||||
{
|
||||
if ( mat.damageValue != -1 )
|
||||
{
|
||||
@@ -287,94 +302,7 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack is)
|
||||
{
|
||||
return this.getTypeByStack( is ).hasCustomEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(World w, Entity location, ItemStack itemstack)
|
||||
{
|
||||
Class<? extends Entity> droppedEntity = this.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 (this.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 (this.getTypeByStack( is ))
|
||||
{
|
||||
case Cell1kPart:
|
||||
case Cell4kPart:
|
||||
case Cell16kPart:
|
||||
case Cell64kPart:
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Upgrades getType(ItemStack itemstack)
|
||||
{
|
||||
switch (this.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;
|
||||
case CardCrafting:
|
||||
return Upgrades.CRAFTING;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
public boolean onItemUseFirst( ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
@@ -383,12 +311,12 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
|
||||
if ( te instanceof IPartHost )
|
||||
{
|
||||
SelectedPart sp = ((IPartHost) te).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
SelectedPart sp = ( (IPartHost) te ).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) );
|
||||
if ( sp.part instanceof IUpgradeableHost )
|
||||
upgrades = ((IUpgradeableHost) sp.part).getInventoryByName( "upgrades" );
|
||||
upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" );
|
||||
}
|
||||
else if ( te instanceof IUpgradeableHost )
|
||||
upgrades = ((IUpgradeableHost) te).getInventoryByName( "upgrades" );
|
||||
upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" );
|
||||
|
||||
if ( upgrades != null && is != null && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
@@ -414,23 +342,97 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List cList)
|
||||
public boolean hasCustomEntity( ItemStack is )
|
||||
{
|
||||
List<MaterialType> types = Arrays.asList( MaterialType.values() );
|
||||
Collections.sort( types, new Comparator<MaterialType>() {
|
||||
return this.getTypeByStack( is ).hasCustomEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(MaterialType o1, MaterialType o2)
|
||||
{
|
||||
return o1.name().compareTo( o2.name() );
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity( World w, Entity location, ItemStack itemstack )
|
||||
{
|
||||
Class<? extends Entity> droppedEntity = this.getTypeByStack( itemstack ).getCustomEntityClass();
|
||||
Entity eqi;
|
||||
|
||||
} );
|
||||
|
||||
for (MaterialType mat : types)
|
||||
try
|
||||
{
|
||||
if ( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this )
|
||||
cList.add( new ItemStack( this, 1, mat.damageValue ) );
|
||||
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 ( this.getTypeByStack( is ) )
|
||||
{
|
||||
case Cell1kPart:
|
||||
return KILO;
|
||||
case Cell4kPart:
|
||||
return KILO * 4;
|
||||
case Cell16kPart:
|
||||
return KILO * 16;
|
||||
case Cell64kPart:
|
||||
return KILO * 64;
|
||||
default:
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageComponent( ItemStack is )
|
||||
{
|
||||
switch ( this.getTypeByStack( is ) )
|
||||
{
|
||||
case Cell1kPart:
|
||||
case Cell4kPart:
|
||||
case Cell16kPart:
|
||||
case Cell64kPart:
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class SlightlyBetterSort implements Comparator<String>
|
||||
{
|
||||
private final Pattern pattern;
|
||||
|
||||
public SlightlyBetterSort( Pattern pattern )
|
||||
{
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare( String o1, String o2 )
|
||||
{
|
||||
try
|
||||
{
|
||||
Matcher a = this.pattern.matcher( o1 );
|
||||
Matcher b = this.pattern.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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
package appeng.items.misc;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -38,6 +40,7 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
import appeng.api.implementations.items.IGrowableCrystal;
|
||||
import appeng.api.recipes.ResolverResult;
|
||||
import appeng.core.AppEng;
|
||||
@@ -48,6 +51,7 @@ import appeng.entity.EntityIds;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
{
|
||||
|
||||
@@ -63,7 +67,36 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
final IIcon[] fluix = new IIcon[3];
|
||||
final IIcon[] nether = new IIcon[3];
|
||||
|
||||
private int getProgress(ItemStack is)
|
||||
public ItemCrystalSeed()
|
||||
{
|
||||
this.setHasSubtypes( true );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
|
||||
EntityRegistry.registerModEntity( EntityGrowingCrystal.class, EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ), AppEng.instance, 16, 4, true );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResolverResult getResolver( int certus2 )
|
||||
{
|
||||
ResolverResult resolver = null;
|
||||
|
||||
for ( ItemStack crystalSeedStack : AEApi.instance().definitions().items().crystalSeed().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
crystalSeedStack.setItemDamage( certus2 );
|
||||
crystalSeedStack = newStyle( crystalSeedStack );
|
||||
resolver = new ResolverResult( "ItemCrystalSeed", crystalSeedStack.getItemDamage(), crystalSeedStack.getTagCompound() );
|
||||
}
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
private static ItemStack newStyle( ItemStack itemStack )
|
||||
{
|
||||
( (ItemCrystalSeed) itemStack.getItem() ).getProgress( itemStack );
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
private int getProgress( ItemStack is )
|
||||
{
|
||||
if ( is.hasTagCompound() )
|
||||
{
|
||||
@@ -74,35 +107,74 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
int progress;
|
||||
NBTTagCompound comp = Platform.openNbtData( is );
|
||||
comp.setInteger( "progress", progress = is.getItemDamage() );
|
||||
is.setItemDamage( (is.getItemDamage() / SINGLE_OFFSET) * SINGLE_OFFSET );
|
||||
is.setItemDamage( ( is.getItemDamage() / SINGLE_OFFSET ) * SINGLE_OFFSET );
|
||||
return progress;
|
||||
}
|
||||
}
|
||||
|
||||
private void setProgress(ItemStack is, int newDamage)
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack triggerGrowth( ItemStack is )
|
||||
{
|
||||
int newDamage = this.getProgress( is ) + 1;
|
||||
final IMaterials materials = AEApi.instance().definitions().materials();
|
||||
final int size = is.stackSize;
|
||||
|
||||
if ( newDamage == Certus + SINGLE_OFFSET )
|
||||
{
|
||||
for ( ItemStack quartzStack : materials.purifiedCertusQuartzCrystal().maybeStack( size ).asSet() )
|
||||
{
|
||||
return quartzStack;
|
||||
}
|
||||
}
|
||||
if ( newDamage == Nether + SINGLE_OFFSET )
|
||||
{
|
||||
for ( ItemStack quartzStack : materials.purifiedNetherQuartzCrystal().maybeStack( size ).asSet() )
|
||||
{
|
||||
return quartzStack;
|
||||
}
|
||||
}
|
||||
if ( newDamage == Fluix + SINGLE_OFFSET )
|
||||
{
|
||||
for ( ItemStack quartzStack : materials.purifiedFluixCrystal().maybeStack( size ).asSet() )
|
||||
{
|
||||
return quartzStack;
|
||||
}
|
||||
}
|
||||
if ( newDamage > END )
|
||||
return null;
|
||||
|
||||
this.setProgress( is, newDamage );
|
||||
return is;
|
||||
}
|
||||
|
||||
private void setProgress( ItemStack is, int newDamage )
|
||||
{
|
||||
NBTTagCompound comp = Platform.openNbtData( is );
|
||||
comp.setInteger( "progress", newDamage );
|
||||
is.setItemDamage( is.getItemDamage() / LEVEL_OFFSET * LEVEL_OFFSET );
|
||||
}
|
||||
|
||||
public ItemCrystalSeed() {
|
||||
super( ItemCrystalSeed.class );
|
||||
this.setHasSubtypes( true );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
|
||||
EntityRegistry.registerModEntity( EntityGrowingCrystal.class, EntityGrowingCrystal.class.getSimpleName(), EntityIds.get( EntityGrowingCrystal.class ),
|
||||
AppEng.instance, 16, 4, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityLifespan(ItemStack itemStack, World world)
|
||||
} @Override
|
||||
public int getEntityLifespan( ItemStack itemStack, World world )
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack is)
|
||||
public float getMultiplier( Block blk, Material mat )
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
|
||||
int progress = this.getProgress( stack ) % SINGLE_OFFSET;
|
||||
lines.add( Math.floor( (float) progress / (float) ( SINGLE_OFFSET / 100 ) ) + "%" );
|
||||
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
} @Override
|
||||
public String getUnlocalizedName( ItemStack is )
|
||||
{
|
||||
int damage = this.getProgress( is );
|
||||
|
||||
@@ -118,23 +190,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack triggerGrowth(ItemStack is)
|
||||
{
|
||||
int newDamage = this.getProgress( is ) + 1;
|
||||
|
||||
if ( newDamage == Certus + SINGLE_OFFSET )
|
||||
return AEApi.instance().materials().materialPurifiedCertusQuartzCrystal.stack( is.stackSize );
|
||||
if ( newDamage == Nether + SINGLE_OFFSET )
|
||||
return AEApi.instance().materials().materialPurifiedNetherQuartzCrystal.stack( is.stackSize );
|
||||
if ( newDamage == Fluix + SINGLE_OFFSET )
|
||||
return AEApi.instance().materials().materialPurifiedFluixCrystal.stack( is.stackSize );
|
||||
if ( newDamage > END )
|
||||
return null;
|
||||
|
||||
this.setProgress( is, newDamage );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamageable()
|
||||
@@ -143,35 +199,25 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
lines.add( ButtonToolTips.DoesntDespawn.getLocal() );
|
||||
int progress = this.getProgress( stack ) % SINGLE_OFFSET;
|
||||
lines.add( Math.floor( (float) progress / (float) (SINGLE_OFFSET / 100) ) + "%" );
|
||||
|
||||
super.addCheckedInformation( stack, player, lines, displayAdditionalInformation );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDamaged(ItemStack stack)
|
||||
public boolean isDamaged( ItemStack stack )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDamage(ItemStack stack)
|
||||
public int getMaxDamage( ItemStack stack )
|
||||
{
|
||||
return END;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(ItemStack stack, int pass)
|
||||
public IIcon getIcon( ItemStack stack, int pass )
|
||||
{
|
||||
return this.getIconIndex( stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconIndex(ItemStack stack)
|
||||
public IIcon getIconIndex( ItemStack stack )
|
||||
{
|
||||
IIcon[] list = null;
|
||||
|
||||
@@ -204,13 +250,7 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMultiplier(Block blk, Material mat)
|
||||
{
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister ir)
|
||||
public void registerIcons( IIconRegister ir )
|
||||
{
|
||||
String preFix = "appliedenergistics2:ItemCrystalSeed.";
|
||||
|
||||
@@ -228,13 +268,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack stack)
|
||||
public boolean hasCustomEntity( ItemStack stack )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack)
|
||||
public Entity createEntity( World world, Entity location, ItemStack itemstack )
|
||||
{
|
||||
EntityGrowingCrystal egc = new EntityGrowingCrystal( world, location.posX, location.posY, location.posZ, itemstack );
|
||||
|
||||
@@ -243,13 +283,13 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
egc.motionZ = location.motionZ;
|
||||
|
||||
if ( location instanceof EntityItem )
|
||||
egc.delayBeforeCanPickup = ((EntityItem) location).delayBeforeCanPickup;
|
||||
egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup;
|
||||
|
||||
return egc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item i, CreativeTabs t, List l)
|
||||
public void getSubItems( Item i, CreativeTabs t, List l )
|
||||
{
|
||||
// lvl 0
|
||||
l.add( newStyle( new ItemStack( this, 1, Certus ) ) );
|
||||
@@ -267,18 +307,5 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal
|
||||
l.add( newStyle( new ItemStack( this, 1, LEVEL_OFFSET * 2 + Fluix ) ) );
|
||||
}
|
||||
|
||||
private static ItemStack newStyle(ItemStack itemStack)
|
||||
{
|
||||
((ItemCrystalSeed) itemStack.getItem()).getProgress( itemStack );
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static ResolverResult getResolver(int certus2)
|
||||
{
|
||||
ItemStack is = AEApi.instance().items().itemCrystalSeed.stack( 1 );
|
||||
is.setItemDamage( certus2 );
|
||||
is = newStyle( is );
|
||||
return new ResolverResult( "ItemCrystalSeed", is.getItemDamage(), is.getTagCompound() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.items.misc;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -42,18 +43,35 @@ import appeng.helpers.PatternHelper;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternItem
|
||||
{
|
||||
// rather simple client side caching.
|
||||
private static final Map<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<ItemStack, ItemStack>();
|
||||
|
||||
public ItemEncodedPattern() {
|
||||
super( ItemEncodedPattern.class );
|
||||
public ItemEncodedPattern()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.Patterns ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, new ItemEncodedPatternRenderer() );
|
||||
}
|
||||
|
||||
private boolean clearPattern(ItemStack stack, EntityPlayer player)
|
||||
@Override
|
||||
public ItemStack onItemRightClick( ItemStack stack, World w, EntityPlayer player )
|
||||
{
|
||||
this.clearPattern( stack, player );
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ )
|
||||
{
|
||||
return this.clearPattern( stack, player );
|
||||
}
|
||||
|
||||
private boolean clearPattern( ItemStack stack, EntityPlayer player )
|
||||
{
|
||||
if ( player.isSneaking() )
|
||||
{
|
||||
@@ -62,11 +80,15 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
|
||||
InventoryPlayer inv = player.inventory;
|
||||
|
||||
for (int s = 0; s < player.inventory.getSizeInventory(); s++)
|
||||
for ( int s = 0; s < player.inventory.getSizeInventory(); s++ )
|
||||
{
|
||||
if ( inv.getStackInSlot( s ) == stack )
|
||||
{
|
||||
inv.setInventorySlotContents( s, AEApi.instance().materials().materialBlankPattern.stack( stack.stackSize ) );
|
||||
for ( ItemStack blankPattern : AEApi.instance().definitions().materials().blankPattern().maybeStack( stack.stackSize ).asSet() )
|
||||
{
|
||||
inv.setInventorySlotContents( s, blankPattern );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -76,20 +98,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
return this.clearPattern( stack, player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer player)
|
||||
{
|
||||
this.clearPattern( stack, player );
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
ICraftingPatternDetails details = this.getPatternForItem( stack, player.worldObj );
|
||||
|
||||
@@ -104,39 +113,49 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
IAEItemStack[] in = details.getCondensedInputs();
|
||||
IAEItemStack[] out = details.getCondensedOutputs();
|
||||
|
||||
String label = (isCrafting ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal()) + ": ";
|
||||
String label = ( isCrafting ? GuiText.Crafts.getLocal() : GuiText.Creates.getLocal() ) + ": ";
|
||||
String and = ' ' + GuiText.And.getLocal() + ' ';
|
||||
String with = GuiText.With.getLocal() + ": ";
|
||||
|
||||
boolean first = true;
|
||||
for (IAEItemStack anOut : out)
|
||||
for ( IAEItemStack anOut : out )
|
||||
{
|
||||
if ( anOut == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
lines.add( (first ? label : and) + anOut.getStackSize() + ' ' + Platform.getItemDisplayName( anOut ) );
|
||||
lines.add( ( first ? label : and ) + anOut.getStackSize() + ' ' + Platform.getItemDisplayName( anOut ) );
|
||||
first = false;
|
||||
}
|
||||
|
||||
first = true;
|
||||
for (IAEItemStack anIn : in)
|
||||
for ( IAEItemStack anIn : in )
|
||||
{
|
||||
if ( anIn == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
lines.add( (first ? with : and) + anIn.getStackSize() + ' ' + Platform.getItemDisplayName( anIn ) );
|
||||
lines.add( ( first ? with : and ) + anIn.getStackSize() + ' ' + Platform.getItemDisplayName( anIn ) );
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
// rather simple client side caching.
|
||||
static final WeakHashMap<ItemStack, ItemStack> SIMPLE_CACHE = new WeakHashMap<ItemStack, ItemStack>();
|
||||
@Override
|
||||
public ICraftingPatternDetails getPatternForItem( ItemStack is, World w )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PatternHelper( is, w );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getOutput(ItemStack item)
|
||||
public ItemStack getOutput( ItemStack item )
|
||||
{
|
||||
ItemStack out = SIMPLE_CACHE.get( item );
|
||||
if ( out != null )
|
||||
@@ -154,18 +173,4 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
|
||||
SIMPLE_CACHE.put( item, out = details.getCondensedOutputs()[0].getItemStack() );
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingPatternDetails getPatternForItem(ItemStack is, World w)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PatternHelper( is, w );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,33 +34,37 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemPaintBall extends AEBaseItem
|
||||
{
|
||||
|
||||
public ItemPaintBall() {
|
||||
super( ItemPaintBall.class );
|
||||
public static final int DAMAGE_THRESHOLD = 20;
|
||||
|
||||
public ItemPaintBall()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.PaintBalls ) );
|
||||
this.hasSubtypes = true;
|
||||
this.setHasSubtypes( true );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, new PaintBallRender() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack is)
|
||||
public String getItemStackDisplayName( ItemStack is )
|
||||
{
|
||||
return super.getItemStackDisplayName( is ) + " - " + this.getExtraName( is );
|
||||
}
|
||||
|
||||
public String getExtraName(ItemStack is)
|
||||
public String getExtraName( ItemStack is )
|
||||
{
|
||||
return (is.getItemDamage() >= 20 ? GuiText.Lumen.getLocal() + ' ' : "") + this.getColor( is );
|
||||
return ( is.getItemDamage() >= DAMAGE_THRESHOLD ? GuiText.Lumen.getLocal() + ' ' : "" ) + this.getColor( is );
|
||||
}
|
||||
|
||||
public AEColor getColor(ItemStack is)
|
||||
public AEColor getColor( ItemStack is )
|
||||
{
|
||||
int dmg = is.getItemDamage();
|
||||
if ( dmg >= 20 )
|
||||
dmg -= 20;
|
||||
if ( dmg >= DAMAGE_THRESHOLD )
|
||||
dmg -= DAMAGE_THRESHOLD;
|
||||
|
||||
if ( dmg >= AEColor.values().length )
|
||||
return AEColor.Transparent;
|
||||
@@ -69,21 +73,20 @@ public class ItemPaintBall extends AEBaseItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item i, CreativeTabs ct, List l)
|
||||
public void getSubItems( Item i, CreativeTabs ct, List l )
|
||||
{
|
||||
for (AEColor c : AEColor.values())
|
||||
for ( AEColor c : AEColor.values() )
|
||||
if ( c != AEColor.Transparent )
|
||||
l.add( new ItemStack( this, 1, c.ordinal() ) );
|
||||
|
||||
for (AEColor c : AEColor.values())
|
||||
for ( AEColor c : AEColor.values() )
|
||||
if ( c != AEColor.Transparent )
|
||||
l.add( new ItemStack( this, 1, 20 + c.ordinal() ) );
|
||||
l.add( new ItemStack( this, 1, DAMAGE_THRESHOLD + c.ordinal() ) );
|
||||
}
|
||||
|
||||
public boolean isLumen(ItemStack is)
|
||||
public boolean isLumen( ItemStack is )
|
||||
{
|
||||
int dmg = is.getItemDamage();
|
||||
return dmg >= 20;
|
||||
return dmg >= DAMAGE_THRESHOLD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.items.parts;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
@@ -42,6 +43,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.api.parts.IAlphaPassItem;
|
||||
import appeng.block.solids.OreQuartz;
|
||||
import appeng.client.render.BusRenderer;
|
||||
@@ -52,11 +54,14 @@ import appeng.facade.IFacadeItem;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassItem
|
||||
{
|
||||
|
||||
public ItemFacade() {
|
||||
super( ItemFacade.class );
|
||||
private List<ItemStack> subTypes = null;
|
||||
|
||||
public ItemFacade()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.Facades ) );
|
||||
this.setHasSubtypes( true );
|
||||
if ( Platform.isClient() )
|
||||
@@ -64,20 +69,46 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SideOnly( Side.CLIENT )
|
||||
public int getSpriteNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||
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 FacadePart createPartFromItemStack(ItemStack is, ForgeDirection side)
|
||||
public String getItemStackDisplayName( ItemStack is )
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack in = this.getTextureItem( is );
|
||||
if ( in != null )
|
||||
{
|
||||
return super.getItemStackDisplayName( is ) + " - " + in.getDisplayName();
|
||||
}
|
||||
}
|
||||
catch ( Throwable ignored )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems( Item number, CreativeTabs tab, List list )
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
list.addAll( this.subTypes );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FacadePart createPartFromItemStack( ItemStack is, ForgeDirection side )
|
||||
{
|
||||
ItemStack in = this.getTextureItem( is );
|
||||
if ( in != null )
|
||||
@@ -85,40 +116,8 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ItemStack> subTypes = null;
|
||||
|
||||
public List<ItemStack> getFacades()
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
return this.subTypes;
|
||||
}
|
||||
|
||||
public ItemStack getCreativeTabIcon()
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
if ( this.subTypes.isEmpty() )
|
||||
return new ItemStack( Items.cake );
|
||||
return this.subTypes.get( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item number, CreativeTabs tab, List list)
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
list.addAll( this.subTypes );
|
||||
}
|
||||
|
||||
public ItemStack createFromIDs(int[] ids)
|
||||
{
|
||||
ItemStack is = new ItemStack( AEApi.instance().items().itemFacade.item() );
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setIntArray( "x", ids.clone() );
|
||||
is.setTagCompound( data );
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getTextureItem(ItemStack is)
|
||||
public ItemStack getTextureItem( ItemStack is )
|
||||
{
|
||||
Block blk = this.getBlock( is );
|
||||
if ( blk != null )
|
||||
@@ -126,12 +125,51 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta( ItemStack is )
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return blk[1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock( ItemStack is )
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
{
|
||||
if ( data.hasKey( "modid" ) && data.hasKey( "itemname" ) )
|
||||
{
|
||||
return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return Block.getBlockById( blk[0] );
|
||||
}
|
||||
}
|
||||
return Blocks.glass;
|
||||
}
|
||||
|
||||
public List<ItemStack> getFacades()
|
||||
{
|
||||
this.calculateSubTypes();
|
||||
return this.subTypes;
|
||||
}
|
||||
|
||||
private void calculateSubTypes()
|
||||
{
|
||||
if ( this.subTypes == null )
|
||||
{
|
||||
this.subTypes = new ArrayList<ItemStack>();
|
||||
for (Object blk : Block.blockRegistry)
|
||||
for ( Object blk : Block.blockRegistry )
|
||||
{
|
||||
Block b = (Block) blk;
|
||||
try
|
||||
@@ -140,14 +178,14 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
|
||||
List<ItemStack> tmpList = new ArrayList<ItemStack>();
|
||||
b.getSubBlocks( item, b.getCreativeTabToDisplayOn(), tmpList );
|
||||
for (ItemStack l : tmpList)
|
||||
for ( ItemStack l : tmpList )
|
||||
{
|
||||
ItemStack facade = this.createFacadeForItem( l, false );
|
||||
if ( facade != null )
|
||||
this.subTypes.add( facade );
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch ( Throwable t )
|
||||
{
|
||||
// just absorb..
|
||||
}
|
||||
@@ -156,10 +194,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
if ( FacadeConfig.instance.hasChanged() )
|
||||
FacadeConfig.instance.save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ItemStack createFacadeForItem(ItemStack l, boolean returnItem)
|
||||
public ItemStack createFacadeForItem( ItemStack l, boolean returnItem )
|
||||
{
|
||||
if ( l == null )
|
||||
return null;
|
||||
@@ -174,7 +211,7 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
boolean enableGlass = b instanceof BlockGlass || b instanceof BlockStainedGlass;
|
||||
boolean disableOre = b instanceof OreQuartz;
|
||||
|
||||
boolean defaultValue = (b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre) || enableGlass;
|
||||
boolean defaultValue = ( b.isOpaqueCube() && !b.getTickRandomly() && !hasTile && !disableOre ) || enableGlass;
|
||||
if ( FacadeConfig.instance.checkEnabled( b, metadata, defaultValue ) )
|
||||
{
|
||||
if ( returnItem )
|
||||
@@ -195,60 +232,30 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(ItemStack is)
|
||||
public ItemStack getCreativeTabIcon()
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
this.calculateSubTypes();
|
||||
if ( this.subTypes.isEmpty() )
|
||||
return new ItemStack( Items.cake );
|
||||
return this.subTypes.get( 0 );
|
||||
}
|
||||
|
||||
public ItemStack createFromIDs( int[] ids )
|
||||
{
|
||||
for ( ItemStack facadeStack : AEApi.instance().definitions().items().facade().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
if ( data.hasKey( "modid" ) && data.hasKey( "itemname" ) )
|
||||
{
|
||||
return GameRegistry.findBlock( data.getString( "modid" ), data.getString( "itemname" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return Block.getBlockById( blk[0] );
|
||||
}
|
||||
NBTTagCompound facadeTag = new NBTTagCompound();
|
||||
facadeTag.setIntArray( "x", ids.clone() );
|
||||
facadeStack.setTagCompound( facadeTag );
|
||||
|
||||
return facadeStack;
|
||||
}
|
||||
return Blocks.glass;
|
||||
|
||||
throw new MissingDefinition( "Tried to create a facade, while facades are being deactivated." );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMeta(ItemStack is)
|
||||
{
|
||||
NBTTagCompound data = is.getTagCompound();
|
||||
if ( data != null )
|
||||
{
|
||||
int[] blk = data.getIntArray( "x" );
|
||||
if ( blk != null && blk.length == 2 )
|
||||
return blk[1];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack is)
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack in = this.getTextureItem( is );
|
||||
if ( in != null )
|
||||
{
|
||||
return super.getItemStackDisplayName( is ) + " - " + in.getDisplayName();
|
||||
}
|
||||
}
|
||||
catch (Throwable ignored)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return super.getItemStackDisplayName( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAlphaPass(ItemStack is)
|
||||
public boolean useAlphaPass( ItemStack is )
|
||||
{
|
||||
ItemStack out = this.getTextureItem( is );
|
||||
|
||||
@@ -261,5 +268,4 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@ import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -41,40 +44,80 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.parts.IPartItem;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.AEFeatureHandler;
|
||||
import appeng.core.features.NameResolver;
|
||||
import appeng.core.features.ItemStackSrc;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
{
|
||||
private final NameResolver nameResolver;
|
||||
|
||||
static class PartTypeIst
|
||||
private static class PartTypeIst
|
||||
{
|
||||
|
||||
PartType part;
|
||||
int variant;
|
||||
private PartType part;
|
||||
private int variant;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
IIcon ico;
|
||||
private IIcon ico;
|
||||
}
|
||||
|
||||
final HashMap<Integer, PartTypeIst> dmgToPart = new HashMap<Integer, PartTypeIst>();
|
||||
private final Map<Integer, PartTypeIst> dmgToPart = new HashMap<Integer, PartTypeIst>();
|
||||
|
||||
public static ItemMultiPart instance;
|
||||
|
||||
public ItemMultiPart() {
|
||||
super( ItemMultiPart.class );
|
||||
public ItemMultiPart( IPartHelper partHelper ) {
|
||||
this.nameResolver = new NameResolver( this.getClass() );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
AEApi.instance().partHelper().setItemBusRenderer( this );
|
||||
partHelper.setItemBusRenderer( this );
|
||||
this.setHasSubtypes( true );
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public final ItemStackSrc createPart( PartType mat )
|
||||
{
|
||||
int varID = 0;
|
||||
|
||||
// verify
|
||||
for (PartTypeIst p : this.dmgToPart.values())
|
||||
{
|
||||
if ( p.part == mat && p.variant == varID )
|
||||
throw new RuntimeException( "Cannot create the same material twice..." );
|
||||
}
|
||||
|
||||
boolean enabled = true;
|
||||
for (AEFeature f : mat.getFeature())
|
||||
enabled = enabled && AEConfig.instance.isFeatureEnabled( f );
|
||||
|
||||
int newPartNum = mat.baseDamage + varID;
|
||||
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
|
||||
|
||||
if ( enabled )
|
||||
{
|
||||
PartTypeIst pti = new PartTypeIst();
|
||||
pti.part = mat;
|
||||
pti.variant = varID;
|
||||
|
||||
if ( this.dmgToPart.get( newPartNum ) == null )
|
||||
{
|
||||
this.dmgToPart.put( newPartNum, pti );
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new RuntimeException( "Meta Overlap detected." );
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public ItemStackSrc createPart(PartType mat, Enum variant)
|
||||
{
|
||||
try
|
||||
@@ -86,6 +129,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.integration( e );
|
||||
e.printStackTrace();
|
||||
return null; // part not supported..
|
||||
}
|
||||
|
||||
@@ -133,6 +177,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PartType getTypeByStack(ItemStack is)
|
||||
{
|
||||
if ( is == null )
|
||||
@@ -166,7 +211,7 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
|
||||
public String getName(ItemStack is)
|
||||
{
|
||||
return AEFeatureHandler.getName( ItemMultiPart.class, this.getTypeByStack( is ).name() );
|
||||
return this.nameResolver.getName( this.getTypeByStack( is ).name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -176,10 +221,12 @@ public class ItemMultiPart extends AEBaseItem implements IPartItem, IItemGroup
|
||||
if ( pt == null )
|
||||
return "Unnamed";
|
||||
|
||||
Enum[] variants = pt.getVariants();
|
||||
if ( pt.isCable() )
|
||||
{
|
||||
final AEColor[] variants = AEColor.values();
|
||||
|
||||
if ( variants != null )
|
||||
return super.getItemStackDisplayName( is ) + " - " + variants[this.dmgToPart.get( is.getItemDamage() ).variant].toString();
|
||||
}
|
||||
|
||||
if ( pt.getExtraName() != null )
|
||||
return super.getItemStackDisplayName( is ) + " - " + pt.getExtraName().getLocal();
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.lang.reflect.Constructor;
|
||||
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;
|
||||
@@ -61,95 +60,121 @@ import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public enum PartType
|
||||
{
|
||||
InvalidType( -1, AEFeature.Core, null ),
|
||||
InvalidType( -1, EnumSet.of( AEFeature.Core ), null ),
|
||||
|
||||
CableGlass( 0, AEFeature.Core, PartCableGlass.class ),
|
||||
CableGlass( 0, EnumSet.of( AEFeature.Core ), PartCableGlass.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CableCovered( 20, AEFeature.Core, PartCableCovered.class ),
|
||||
CableCovered( 20, EnumSet.of( AEFeature.Core ), PartCableCovered.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CableSmart( 40, AEFeature.Channels, PartCableSmart.class ),
|
||||
CableSmart( 40, EnumSet.of( AEFeature.Channels ), PartCableSmart.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
CableDense( 60, AEFeature.Channels, PartDenseCable.class ),
|
||||
CableDense( 60, EnumSet.of( AEFeature.Channels ), PartDenseCable.class )
|
||||
{
|
||||
@Override
|
||||
public boolean isCable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
ToggleBus( 80, AEFeature.Core, PartToggleBus.class ),
|
||||
ToggleBus( 80, EnumSet.of( AEFeature.Core ), PartToggleBus.class ),
|
||||
|
||||
InvertedToggleBus( 100, AEFeature.Core, PartInvertedToggleBus.class ),
|
||||
InvertedToggleBus( 100, EnumSet.of( AEFeature.Core ), PartInvertedToggleBus.class ),
|
||||
|
||||
CableAnchor( 120, AEFeature.Core, PartCableAnchor.class ),
|
||||
CableAnchor( 120, EnumSet.of( AEFeature.Core ), PartCableAnchor.class ),
|
||||
|
||||
QuartzFiber( 140, AEFeature.Core, PartQuartzFiber.class ),
|
||||
QuartzFiber( 140, EnumSet.of( AEFeature.Core ), PartQuartzFiber.class ),
|
||||
|
||||
Monitor( 160, AEFeature.Core, PartMonitor.class ),
|
||||
Monitor( 160, EnumSet.of( AEFeature.Core ), PartMonitor.class ),
|
||||
|
||||
SemiDarkMonitor( 180, AEFeature.Core, PartSemiDarkMonitor.class ),
|
||||
SemiDarkMonitor( 180, EnumSet.of( AEFeature.Core ), PartSemiDarkMonitor.class ),
|
||||
|
||||
DarkMonitor( 200, AEFeature.Core, PartDarkMonitor.class ),
|
||||
DarkMonitor( 200, EnumSet.of( AEFeature.Core ), PartDarkMonitor.class ),
|
||||
|
||||
StorageBus( 220, AEFeature.StorageBus, PartStorageBus.class ),
|
||||
StorageBus( 220, EnumSet.of( AEFeature.StorageBus ), PartStorageBus.class ),
|
||||
|
||||
ImportBus( 240, AEFeature.ImportBus, PartImportBus.class ),
|
||||
ImportBus( 240, EnumSet.of( AEFeature.ImportBus ), PartImportBus.class ),
|
||||
|
||||
ExportBus( 260, AEFeature.ExportBus, PartExportBus.class ),
|
||||
ExportBus( 260, EnumSet.of( AEFeature.ExportBus ), PartExportBus.class ),
|
||||
|
||||
LevelEmitter( 280, AEFeature.LevelEmitter, PartLevelEmitter.class ),
|
||||
LevelEmitter( 280, EnumSet.of( AEFeature.LevelEmitter ), PartLevelEmitter.class ),
|
||||
|
||||
AnnihilationPlane( 300, AEFeature.AnnihilationPlane, PartAnnihilationPlane.class ),
|
||||
AnnihilationPlane( 300, EnumSet.of( AEFeature.AnnihilationPlane ), PartAnnihilationPlane.class ),
|
||||
|
||||
FormationPlane( 320, AEFeature.FormationPlane, PartFormationPlane.class ),
|
||||
FormationPlane( 320, EnumSet.of( AEFeature.FormationPlane ), PartFormationPlane.class ),
|
||||
|
||||
PatternTerminal( 340, AEFeature.Patterns, PartPatternTerminal.class ),
|
||||
PatternTerminal( 340, EnumSet.of( AEFeature.Patterns ), PartPatternTerminal.class ),
|
||||
|
||||
CraftingTerminal( 360, AEFeature.CraftingTerminal, PartCraftingTerminal.class ),
|
||||
CraftingTerminal( 360, EnumSet.of( AEFeature.CraftingTerminal ), PartCraftingTerminal.class ),
|
||||
|
||||
Terminal( 380, AEFeature.Core, PartTerminal.class ),
|
||||
Terminal( 380, EnumSet.of( AEFeature.Core ), PartTerminal.class ),
|
||||
|
||||
StorageMonitor( 400, AEFeature.StorageMonitor, PartStorageMonitor.class ),
|
||||
StorageMonitor( 400, EnumSet.of( AEFeature.StorageMonitor ), PartStorageMonitor.class ),
|
||||
|
||||
ConversionMonitor( 420, AEFeature.PartConversionMonitor, PartConversionMonitor.class ),
|
||||
ConversionMonitor( 420, EnumSet.of( AEFeature.PartConversionMonitor ), PartConversionMonitor.class ),
|
||||
|
||||
Interface( 440, AEFeature.Core, PartInterface.class ),
|
||||
Interface( 440, EnumSet.of( AEFeature.Core ), PartInterface.class ),
|
||||
|
||||
P2PTunnelME( 460, AEFeature.P2PTunnelME, PartP2PTunnelME.class, GuiText.METunnel ),
|
||||
P2PTunnelME( 460, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelME ), PartP2PTunnelME.class, GuiText.METunnel ),
|
||||
|
||||
P2PTunnelRedstone( 461, AEFeature.P2PTunnelRedstone, PartP2PRedstone.class, GuiText.RedstoneTunnel ),
|
||||
P2PTunnelRedstone( 461, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRedstone ), PartP2PRedstone.class, GuiText.RedstoneTunnel ),
|
||||
|
||||
P2PTunnelItems( 462, AEFeature.P2PTunnelItems, PartP2PItems.class, GuiText.ItemTunnel ),
|
||||
P2PTunnelItems( 462, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelItems ), PartP2PItems.class, GuiText.ItemTunnel ),
|
||||
|
||||
P2PTunnelLiquids( 463, AEFeature.P2PTunnelLiquids, PartP2PLiquids.class, GuiText.FluidTunnel ),
|
||||
P2PTunnelLiquids( 463, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLiquids ), PartP2PLiquids.class, GuiText.FluidTunnel ),
|
||||
|
||||
P2PTunnelEU( 465, AEFeature.P2PTunnelEU, PartP2PIC2Power.class, GuiText.EUTunnel ),
|
||||
P2PTunnelEU( 465, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelEU ), PartP2PIC2Power.class, GuiText.EUTunnel ),
|
||||
|
||||
P2PTunnelRF( 466, AEFeature.P2PTunnelRF, PartP2PRFPower.class, GuiText.RFTunnel ),
|
||||
P2PTunnelRF( 466, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelRF ), PartP2PRFPower.class, GuiText.RFTunnel ),
|
||||
|
||||
P2PTunnelLight( 467, AEFeature.P2PTunnelLight, PartP2PLight.class, GuiText.LightTunnel ),
|
||||
P2PTunnelLight( 467, EnumSet.of( AEFeature.P2PTunnel, AEFeature.P2PTunnelLight ), PartP2PLight.class, GuiText.LightTunnel ),
|
||||
|
||||
InterfaceTerminal( 480, AEFeature.InterfaceTerminal, PartInterfaceTerminal.class );
|
||||
InterfaceTerminal( 480, EnumSet.of( AEFeature.InterfaceTerminal ), PartInterfaceTerminal.class );
|
||||
|
||||
public final int baseDamage;
|
||||
private final EnumSet<AEFeature> features;
|
||||
private final Class<? extends IPart> myPart;
|
||||
private final GuiText extraName;
|
||||
public final int baseDamage;
|
||||
|
||||
public Constructor<? extends IPart> constructor;
|
||||
|
||||
PartType( int baseMetaValue, AEFeature part, Class<? extends IPart> c )
|
||||
PartType( int baseMetaValue, EnumSet<AEFeature> features, Class<? extends IPart> c )
|
||||
{
|
||||
this( baseMetaValue, part, c, null );
|
||||
this( baseMetaValue, features, c, null );
|
||||
}
|
||||
|
||||
PartType( int baseMetaValue, AEFeature part, Class<? extends IPart> c, GuiText en )
|
||||
PartType( int baseMetaValue, EnumSet<AEFeature> features, Class<? extends IPart> c, GuiText en )
|
||||
{
|
||||
this.features = EnumSet.of( part );
|
||||
this.features = features;
|
||||
this.myPart = c;
|
||||
this.extraName = en;
|
||||
this.baseDamage = baseMetaValue;
|
||||
}
|
||||
|
||||
public Enum<AEColor>[] getVariants()
|
||||
public boolean isCable()
|
||||
{
|
||||
if ( this == CableSmart || this == CableCovered || this == CableGlass || this == CableDense )
|
||||
return AEColor.values();
|
||||
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnumSet<AEFeature> getFeature()
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -32,9 +30,12 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.exceptions.MissingDefinition;
|
||||
import appeng.api.implementations.items.IItemGroup;
|
||||
import appeng.api.implementations.items.IStorageCell;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
@@ -63,7 +64,7 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
|
||||
public ItemBasicStorageCell( MaterialType whichCell, int kilobytes )
|
||||
{
|
||||
super( ItemBasicStorageCell.class, Optional.of( kilobytes + "k" ) );
|
||||
super( Optional.of( kilobytes + "k" ) );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
@@ -240,13 +241,18 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
playerInventory.setInventorySlotContents( playerInventory.currentItem, null );
|
||||
|
||||
ItemStack extraB = ia.addItems( this.component.stack( 1 ) );
|
||||
ItemStack extraA = ia.addItems( AEApi.instance().materials().materialEmptyStorageCell.stack( 1 ) );
|
||||
|
||||
if ( extraA != null )
|
||||
player.dropPlayerItemWithRandomChoice( extraA, false );
|
||||
if ( extraB != null )
|
||||
player.dropPlayerItemWithRandomChoice( extraB, false );
|
||||
|
||||
for ( ItemStack storageCellStack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
final ItemStack extraA = ia.addItems( storageCellStack );
|
||||
if ( extraA != null )
|
||||
{
|
||||
player.dropPlayerItemWithRandomChoice( extraA, false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( player.inventoryContainer != null )
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
|
||||
@@ -266,7 +272,12 @@ public class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, II
|
||||
@Override
|
||||
public ItemStack getContainerItem( ItemStack itemStack )
|
||||
{
|
||||
return AEApi.instance().materials().materialEmptyStorageCell.stack( 1 );
|
||||
for ( ItemStack stack : AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).asSet() )
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
throw new MissingDefinition( "Tried to use empty storage cells while basic storage cells are defined." );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -29,41 +30,42 @@ import appeng.core.features.AEFeature;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.contents.CellConfig;
|
||||
|
||||
|
||||
public class ItemCreativeStorageCell extends AEBaseItem implements ICellWorkbenchItem
|
||||
{
|
||||
|
||||
public ItemCreativeStorageCell() {
|
||||
super( ItemCreativeStorageCell.class );
|
||||
public ItemCreativeStorageCell()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.StorageCells, AEFeature.Creative ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is)
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is)
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is)
|
||||
public IInventory getConfigInventory( ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is)
|
||||
public FuzzyMode getFuzzyMode( ItemStack is )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ package appeng.items.storage;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.implementations.TransitionResult;
|
||||
import appeng.api.implementations.items.ISpatialStorageCell;
|
||||
import appeng.api.util.WorldCoord;
|
||||
@@ -37,7 +37,6 @@ import appeng.core.WorldSettings;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.materials.MaterialType;
|
||||
import appeng.spatial.StorageHelper;
|
||||
import appeng.spatial.StorageWorldProvider;
|
||||
import appeng.util.Platform;
|
||||
@@ -45,17 +44,14 @@ import appeng.util.Platform;
|
||||
|
||||
public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorageCell
|
||||
{
|
||||
private final int maxRegion;
|
||||
|
||||
final MaterialType component;
|
||||
final int maxRegion;
|
||||
|
||||
public ItemSpatialStorageCell( MaterialType whichCell, int spatialScale )
|
||||
public ItemSpatialStorageCell( int spatialScale )
|
||||
{
|
||||
super( ItemSpatialStorageCell.class, Optional.of( spatialScale + "Cubed" ) );
|
||||
super( Optional.of( spatialScale + "Cubed" ) );
|
||||
this.setFeature( EnumSet.of( AEFeature.SpatialIO ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
this.maxRegion = spatialScale;
|
||||
this.component = whichCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package appeng.items.storage;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -41,102 +42,61 @@ import appeng.util.prioitylist.IPartitionList;
|
||||
import appeng.util.prioitylist.MergedPriorityList;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
|
||||
public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
|
||||
{
|
||||
|
||||
public ItemViewCell()
|
||||
{
|
||||
super( ItemViewCell.class );
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable(ItemStack is)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory(ItemStack is)
|
||||
{
|
||||
return new CellUpgrades( is, 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory(ItemStack is)
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode(ItemStack is)
|
||||
{
|
||||
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode(ItemStack is, FuzzyMode fzMode)
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
|
||||
public static IPartitionList<IAEItemStack> createFilter(ItemStack[] list)
|
||||
public static IPartitionList<IAEItemStack> createFilter( ItemStack[] list )
|
||||
{
|
||||
IPartitionList<IAEItemStack> myPartitionList = null;
|
||||
|
||||
MergedPriorityList<IAEItemStack> myMergedList = new MergedPriorityList<IAEItemStack>();
|
||||
|
||||
for (ItemStack currentViewCell : list)
|
||||
for ( ItemStack currentViewCell : list )
|
||||
{
|
||||
if ( currentViewCell == null )
|
||||
continue;
|
||||
|
||||
if ( (currentViewCell.getItem() instanceof ItemViewCell) )
|
||||
if ( ( currentViewCell.getItem() instanceof ItemViewCell ) )
|
||||
{
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
ItemViewCell vc = (ItemViewCell) currentViewCell.getItem();
|
||||
ICellWorkbenchItem vc = (ICellWorkbenchItem) currentViewCell.getItem();
|
||||
IInventory upgrades = vc.getUpgradesInventory( currentViewCell );
|
||||
IInventory config = vc.getConfigInventory( currentViewCell );
|
||||
FuzzyMode fzMode = vc.getFuzzyMode( currentViewCell );
|
||||
|
||||
hasInverter = false;
|
||||
hasFuzzy = false;
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
|
||||
for (int x = 0; x < upgrades.getSizeInventory(); x++)
|
||||
for ( int x = 0; x < upgrades.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack is = upgrades.getStackInSlot( x );
|
||||
if ( is != null && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
Upgrades u = ((IUpgradeModule) is.getItem()).getType( is );
|
||||
Upgrades u = ( (IUpgradeModule) is.getItem() ).getType( is );
|
||||
if ( u != null )
|
||||
{
|
||||
switch (u)
|
||||
switch ( u )
|
||||
{
|
||||
case FUZZY:
|
||||
hasFuzzy = true;
|
||||
break;
|
||||
case INVERTER:
|
||||
hasInverter = true;
|
||||
break;
|
||||
default:
|
||||
case FUZZY:
|
||||
hasFuzzy = true;
|
||||
break;
|
||||
case INVERTER:
|
||||
hasInverter = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < config.getSizeInventory(); x++)
|
||||
for ( int x = 0; x < config.getSizeInventory(); x++ )
|
||||
{
|
||||
ItemStack is = config.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
@@ -157,4 +117,42 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem
|
||||
|
||||
return myPartitionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable( ItemStack is )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getUpgradesInventory( ItemStack is )
|
||||
{
|
||||
return new CellUpgrades( is, 2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getConfigInventory( ItemStack is )
|
||||
{
|
||||
return new CellConfig( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public FuzzyMode getFuzzyMode( ItemStack is )
|
||||
{
|
||||
String fz = Platform.openNbtData( is ).getString( "FuzzyMode" );
|
||||
try
|
||||
{
|
||||
return FuzzyMode.valueOf( fz );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
return FuzzyMode.IGNORE_ALL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuzzyMode( ItemStack is, FuzzyMode fzMode )
|
||||
{
|
||||
Platform.openNbtData( is ).setString( "FuzzyMode", fzMode.name() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
|
||||
package appeng.items.tools;
|
||||
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -31,6 +30,8 @@ import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.IPlayerRegistry;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
@@ -41,26 +42,33 @@ import appeng.core.localization.GuiText;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
{
|
||||
|
||||
public ToolBiometricCard() {
|
||||
super( ToolBiometricCard.class );
|
||||
public ToolBiometricCard()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.Security ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, new ToolBiometricCardRender() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack is)
|
||||
public ItemStack onItemRightClick( ItemStack is, World w, EntityPlayer p )
|
||||
{
|
||||
GameProfile username = this.getProfile( is );
|
||||
return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is );
|
||||
if ( p.isSneaking() )
|
||||
{
|
||||
this.encode( is, p );
|
||||
p.swingItem();
|
||||
return is;
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemInteractionForEntity(ItemStack is, EntityPlayer par2EntityPlayer, EntityLivingBase target)
|
||||
public boolean itemInteractionForEntity( ItemStack is, EntityPlayer par2EntityPlayer, EntityLivingBase target )
|
||||
{
|
||||
if ( target instanceof EntityPlayer && !par2EntityPlayer.isSneaking() )
|
||||
{
|
||||
@@ -74,66 +82,53 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack is, World w, EntityPlayer p)
|
||||
public String getItemStackDisplayName( ItemStack is )
|
||||
{
|
||||
if ( p.isSneaking() )
|
||||
{
|
||||
this.encode( is, p );
|
||||
p.swingItem();
|
||||
return is;
|
||||
}
|
||||
|
||||
return is;
|
||||
GameProfile username = this.getProfile( is );
|
||||
return username != null ? super.getItemStackDisplayName( is ) + " - " + username.getName() : super.getItemStackDisplayName( is );
|
||||
}
|
||||
|
||||
private void encode(ItemStack is, EntityPlayer p)
|
||||
private void encode( ItemStack is, EntityPlayer p )
|
||||
{
|
||||
GameProfile username = this.getProfile( is );
|
||||
|
||||
if (username != null && username.equals(p.getGameProfile()))
|
||||
if ( username != null && username.equals( p.getGameProfile() ) )
|
||||
this.setProfile( is, null );
|
||||
else
|
||||
this.setProfile( is, p.getGameProfile() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void setProfile( ItemStack itemStack, GameProfile profile )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
|
||||
if ( perms.isEmpty() )
|
||||
lines.add( GuiText.NoPermissions.getLocal() );
|
||||
else
|
||||
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
|
||||
if ( profile != null )
|
||||
{
|
||||
String msg = null;
|
||||
|
||||
for (SecurityPermissions sp : perms)
|
||||
{
|
||||
if ( msg == null )
|
||||
msg = Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
else
|
||||
msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
}
|
||||
lines.add( msg );
|
||||
NBTTagCompound pNBT = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a( pNBT, profile );
|
||||
tag.setTag( "profile", pNBT );
|
||||
}
|
||||
|
||||
else
|
||||
tag.removeTag( "profile" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameProfile getProfile(ItemStack is)
|
||||
public GameProfile getProfile( ItemStack is )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( is );
|
||||
if ( tag.hasKey("profile") )
|
||||
return NBTUtil.func_152459_a(tag.getCompoundTag("profile") );
|
||||
if ( tag.hasKey( "profile" ) )
|
||||
return NBTUtil.func_152459_a( tag.getCompoundTag( "profile" ) );
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<SecurityPermissions> getPermissions(ItemStack is)
|
||||
public EnumSet<SecurityPermissions> getPermissions( ItemStack is )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( is );
|
||||
EnumSet<SecurityPermissions> result = EnumSet.noneOf( SecurityPermissions.class );
|
||||
|
||||
for (SecurityPermissions sp : SecurityPermissions.values())
|
||||
for ( SecurityPermissions sp : SecurityPermissions.values() )
|
||||
{
|
||||
if ( tag.getBoolean( sp.name() ) )
|
||||
result.add( sp );
|
||||
@@ -143,29 +138,14 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(ItemStack is, SecurityPermissions permission)
|
||||
public boolean hasPermission( ItemStack is, SecurityPermissions permission )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( is );
|
||||
return tag.getBoolean( permission.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProfile(ItemStack itemStack, GameProfile profile)
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
|
||||
if ( profile!= null )
|
||||
{
|
||||
NBTTagCompound pNBT = new NBTTagCompound();
|
||||
NBTUtil.func_152460_a( pNBT, profile );
|
||||
tag.setTag( "profile", pNBT );
|
||||
}
|
||||
else
|
||||
tag.removeTag("profile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(ItemStack itemStack, SecurityPermissions permission)
|
||||
public void removePermission( ItemStack itemStack, SecurityPermissions permission )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
if ( tag.hasKey( permission.name() ) )
|
||||
@@ -173,15 +153,36 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(ItemStack itemStack, SecurityPermissions permission)
|
||||
public void addPermission( ItemStack itemStack, SecurityPermissions permission )
|
||||
{
|
||||
NBTTagCompound tag = Platform.openNbtData( itemStack );
|
||||
tag.setBoolean( permission.name(), true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPermissions(ISecurityRegistry register, IPlayerRegistry pr, ItemStack is)
|
||||
public void registerPermissions( ISecurityRegistry register, IPlayerRegistry pr, ItemStack is )
|
||||
{
|
||||
register.addPlayer( pr.getID( this.getProfile( is ) ), this.getPermissions( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
EnumSet<SecurityPermissions> perms = this.getPermissions( stack );
|
||||
if ( perms.isEmpty() )
|
||||
lines.add( GuiText.NoPermissions.getLocal() );
|
||||
else
|
||||
{
|
||||
String msg = null;
|
||||
|
||||
for ( SecurityPermissions sp : perms )
|
||||
{
|
||||
if ( msg == null )
|
||||
msg = Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
else
|
||||
msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() );
|
||||
}
|
||||
lines.add( msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,38 +36,17 @@ import appeng.core.localization.PlayerMessages;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
{
|
||||
|
||||
public ToolMemoryCard() {
|
||||
super( ToolMemoryCard.class );
|
||||
public ToolMemoryCard()
|
||||
{
|
||||
this.setFeature( EnumSet.of( AEFeature.Core ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
* @return localized name
|
||||
*/
|
||||
private String getLocalizedName(String... name)
|
||||
{
|
||||
for (String n : name)
|
||||
{
|
||||
String l = StatCollector.translateToLocal( n );
|
||||
if ( !l.equals( n ) )
|
||||
return l;
|
||||
}
|
||||
|
||||
for (String n : name)
|
||||
return n;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCheckedInformation(ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
public void addCheckedInformation( ItemStack stack, EntityPlayer player, List<String> lines, boolean displayAdditionalInformation )
|
||||
{
|
||||
lines.add( this.getLocalizedName( this.getSettingsName( stack ) + ".name", this.getSettingsName( stack ) ) );
|
||||
|
||||
@@ -76,22 +55,38 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
lines.add( StatCollector.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player)
|
||||
/**
|
||||
* Find the localized string...
|
||||
*
|
||||
* @param name possible names for the localized string
|
||||
*
|
||||
* @return localized name
|
||||
*/
|
||||
private String getLocalizedName( String... name )
|
||||
{
|
||||
return true;
|
||||
for ( String n : name )
|
||||
{
|
||||
String l = StatCollector.translateToLocal( n );
|
||||
if ( !l.equals( n ) )
|
||||
return l;
|
||||
}
|
||||
|
||||
for ( String n : name )
|
||||
return n;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMemoryCardContents(ItemStack is, String SettingsName, NBTTagCompound data)
|
||||
public void setMemoryCardContents( ItemStack is, String settingsName, NBTTagCompound data )
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
c.setString( "Config", SettingsName );
|
||||
c.setString( "Config", settingsName );
|
||||
c.setTag( "Data", data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSettingsName(ItemStack is)
|
||||
public String getSettingsName( ItemStack is )
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
String name = c.getString( "Config" );
|
||||
@@ -99,7 +94,7 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound getData(ItemStack is)
|
||||
public NBTTagCompound getData( ItemStack is )
|
||||
{
|
||||
NBTTagCompound c = Platform.openNbtData( is );
|
||||
NBTTagCompound o = c.getCompoundTag( "Data" );
|
||||
@@ -109,7 +104,31 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz)
|
||||
public void notifyUser( EntityPlayer player, MemoryCardMessages msg )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
switch ( msg )
|
||||
{
|
||||
case SETTINGS_CLEARED:
|
||||
player.addChatMessage( PlayerMessages.SettingCleared.get() );
|
||||
break;
|
||||
case INVALID_MACHINE:
|
||||
player.addChatMessage( PlayerMessages.InvalidMachine.get() );
|
||||
break;
|
||||
case SETTINGS_LOADED:
|
||||
player.addChatMessage( PlayerMessages.LoadedSettings.get() );
|
||||
break;
|
||||
case SETTINGS_SAVED:
|
||||
player.addChatMessage( PlayerMessages.SavedSettings.get() );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse( ItemStack is, EntityPlayer player, World w, int x, int y, int z, int side, float hx, float hy, float hz )
|
||||
{
|
||||
if ( player.isSneaking() && !w.isRemote )
|
||||
{
|
||||
@@ -123,27 +142,8 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUser(EntityPlayer player, MemoryCardMessages msg)
|
||||
public boolean doesSneakBypassUse( World world, int x, int y, int z, EntityPlayer player )
|
||||
{
|
||||
if ( Platform.isClient() )
|
||||
return;
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case SETTINGS_CLEARED:
|
||||
player.addChatMessage( PlayerMessages.SettingCleared.get() );
|
||||
break;
|
||||
case INVALID_MACHINE:
|
||||
player.addChatMessage( PlayerMessages.InvalidMachine.get() );
|
||||
break;
|
||||
case SETTINGS_LOADED:
|
||||
player.addChatMessage( PlayerMessages.LoadedSettings.get() );
|
||||
break;
|
||||
case SETTINGS_SAVED:
|
||||
player.addChatMessage( PlayerMessages.SavedSettings.get() );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ package appeng.items.tools;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -33,6 +31,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
@@ -60,7 +59,7 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench,
|
||||
|
||||
public ToolNetworkTool()
|
||||
{
|
||||
super( ToolNetworkTool.class, Optional.<String> absent() );
|
||||
super( Optional.<String> absent() );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.NetworkTool ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
|
||||
@@ -21,12 +21,12 @@ package appeng.items.tools.powered;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
@@ -40,9 +40,8 @@ public class ToolChargedStaff extends AEBasePoweredItem
|
||||
|
||||
public ToolChargedStaff()
|
||||
{
|
||||
super( ToolChargedStaff.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.chargedStaffBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.ChargedStaff, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.chargedStaffBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -44,6 +42,8 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -99,9 +99,8 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
|
||||
|
||||
public ToolColorApplicator()
|
||||
{
|
||||
super( ToolColorApplicator.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.colorApplicatorBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.ColorApplicator, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.colorApplicatorBattery;
|
||||
if ( Platform.isClient() )
|
||||
MinecraftForgeClient.registerItemRenderer( this, new ToolColorApplicatorRender() );
|
||||
}
|
||||
|
||||
@@ -62,15 +62,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT
|
||||
|
||||
public ToolEntropyManipulator()
|
||||
{
|
||||
super( ToolEntropyManipulator.class, Optional.<String>absent() );
|
||||
super( AEConfig.instance.entropyManipulatorBattery, Optional.<String>absent() );
|
||||
|
||||
this.setFeature( EnumSet.of( AEFeature.EntropyManipulator, AEFeature.PoweredTools ) );
|
||||
|
||||
this.heatUp = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
|
||||
this.coolDown = new HashMap<InWorldToolOperationIngredient, InWorldToolOperationResult>();
|
||||
|
||||
this.maxStoredPower = AEConfig.instance.entropyManipulatorBattery;
|
||||
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stone, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.cobblestone ) ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.stonebrick, 0 ), new InWorldToolOperationResult( new ItemStack( Blocks.stonebrick, 1, 2 ) ) );
|
||||
this.coolDown.put( new InWorldToolOperationIngredient( Blocks.lava, OreDictionary.WILDCARD_VALUE ), new InWorldToolOperationResult( new ItemStack( Blocks.obsidian ) ) );
|
||||
|
||||
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -43,6 +41,8 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -83,9 +83,8 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
|
||||
public ToolMassCannon()
|
||||
{
|
||||
super( ToolMassCannon.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.matterCannonBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.MatterCannon, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.matterCannonBattery;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -297,7 +296,10 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell
|
||||
Block whatsThere = w.getBlock( x, y, z );
|
||||
if ( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) )
|
||||
{
|
||||
w.setBlock( x, y, z, AEApi.instance().blocks().blockPaint.block(), 0, 3 );
|
||||
for ( Block paintBlock : AEApi.instance().definitions().blocks().paint().maybeBlock().asSet() )
|
||||
{
|
||||
w.setBlock( x, y, z, paintBlock, 0, 3 );
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity te = w.getTileEntity( x, y, z );
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -34,6 +32,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
@@ -61,9 +61,8 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
|
||||
{
|
||||
public ToolPortableCell()
|
||||
{
|
||||
super( ToolPortableCell.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.portableCellBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.PortableCell, AEFeature.StorageCells, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.portableCellBattery;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -22,8 +22,6 @@ package appeng.items.tools.powered;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -33,6 +31,8 @@ import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
@@ -54,9 +54,8 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
|
||||
public ToolWirelessTerminal()
|
||||
{
|
||||
super( ToolWirelessTerminal.class, Optional.<String> absent() );
|
||||
super( AEConfig.instance.wirelessTerminalBattery, Optional.<String> absent() );
|
||||
this.setFeature( EnumSet.of( AEFeature.WirelessAccessTerminal, AEFeature.PoweredTools ) );
|
||||
this.maxStoredPower = AEConfig.instance.wirelessTerminalBattery;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -98,7 +97,7 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
@Override
|
||||
public boolean canHandle( ItemStack is )
|
||||
{
|
||||
return AEApi.instance().items().itemWirelessTerminal.sameAsStack( is );
|
||||
return AEApi.instance().definitions().items().wirelessTerminal().isSameAs( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,12 +22,11 @@ package appeng.items.tools.powered.powersink;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
|
||||
public class AEBasePoweredItem extends RedstoneFlux
|
||||
public abstract class AEBasePoweredItem extends RedstoneFlux
|
||||
{
|
||||
|
||||
public AEBasePoweredItem( Class c, Optional<String> subName )
|
||||
public AEBasePoweredItem( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ package appeng.items.tools.powered.powersink;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
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 com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
@@ -38,18 +38,19 @@ import appeng.items.AEBaseItem;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
private static final String POWER_NBT_KEY = "internalCurrentPower";
|
||||
private final double powerCapacity;
|
||||
|
||||
final String EnergyVar = "internalCurrentPower";
|
||||
public double maxStoredPower = 200000;
|
||||
|
||||
public AERootPoweredItem( Class c, Optional<String> subName )
|
||||
public AERootPoweredItem( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( subName );
|
||||
this.setMaxDamage( 32 );
|
||||
this.hasSubtypes = false;
|
||||
this.setFull3D();
|
||||
|
||||
this.powerCapacity = powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,7 +149,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( is );
|
||||
|
||||
double currentStorage = data.getDouble( this.EnergyVar );
|
||||
double currentStorage = data.getDouble( this.POWER_NBT_KEY );
|
||||
double maxStorage = this.getAEMaxPower( is );
|
||||
|
||||
switch ( op )
|
||||
@@ -158,19 +159,19 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
if ( currentStorage > maxStorage )
|
||||
{
|
||||
double diff = currentStorage - maxStorage;
|
||||
data.setDouble( this.EnergyVar, maxStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, maxStorage );
|
||||
return diff;
|
||||
}
|
||||
data.setDouble( this.EnergyVar, currentStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, currentStorage );
|
||||
return 0;
|
||||
case EXTRACT:
|
||||
if ( currentStorage > adjustment )
|
||||
{
|
||||
currentStorage -= adjustment;
|
||||
data.setDouble( this.EnergyVar, currentStorage );
|
||||
data.setDouble( this.POWER_NBT_KEY, currentStorage );
|
||||
return adjustment;
|
||||
}
|
||||
data.setDouble( this.EnergyVar, 0 );
|
||||
data.setDouble( this.POWER_NBT_KEY, 0 );
|
||||
return currentStorage;
|
||||
default:
|
||||
break;
|
||||
@@ -182,7 +183,7 @@ public class AERootPoweredItem extends AEBaseItem implements IAEItemPowerStorage
|
||||
@Override
|
||||
public double getAEMaxPower( ItemStack is )
|
||||
{
|
||||
return this.maxStoredPower;
|
||||
return this.powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import ic2.api.item.IElectricItemManager;
|
||||
import ic2.api.item.ISpecialElectricItem;
|
||||
|
||||
@@ -36,12 +35,11 @@ import appeng.transformer.annotations.Integration.Method;
|
||||
|
||||
@InterfaceList( value = { @Interface( iface = "ic2.api.item.ISpecialElectricItem", iname = "IC2" ),
|
||||
@Interface( iface = "ic2.api.item.IElectricItemManager", iname = "IC2" ) } )
|
||||
public class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
||||
public abstract class IC2 extends AERootPoweredItem implements IElectricItemManager, ISpecialElectricItem
|
||||
{
|
||||
|
||||
public IC2( Class c, Optional<String> subName )
|
||||
public IC2( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,29 +19,27 @@
|
||||
package appeng.items.tools.powered.powersink;
|
||||
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.transformer.annotations.Integration.Interface;
|
||||
|
||||
|
||||
@Interface( iface = "cofh.api.energy.IEnergyContainerItem", iname = "RFItem" )
|
||||
public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
public abstract class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
{
|
||||
|
||||
public RedstoneFlux( Class c, Optional<String> subName )
|
||||
public RedstoneFlux( double powerCapacity, Optional<String> subName )
|
||||
{
|
||||
super( c, subName );
|
||||
super( powerCapacity, subName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy( ItemStack is, int maxReceive, boolean simulate )
|
||||
{
|
||||
return maxReceive - ( int ) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
return maxReceive - (int) this.injectExternalPower( PowerUnits.RF, is, maxReceive, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,13 +51,12 @@ public class RedstoneFlux extends IC2 implements IEnergyContainerItem
|
||||
@Override
|
||||
public int getEnergyStored( ItemStack is )
|
||||
{
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) );
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAECurrentPower( is ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored( ItemStack is )
|
||||
{
|
||||
return ( int ) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) );
|
||||
return (int) PowerUnits.AE.convertTo( PowerUnits.RF, this.getAEMaxPower( is ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ package appeng.items.tools.quartz;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.core.features.AEFeature;
|
||||
@@ -39,14 +39,14 @@ import appeng.util.Platform;
|
||||
|
||||
public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem
|
||||
{
|
||||
private final AEFeature type;
|
||||
|
||||
final AEFeature type;
|
||||
|
||||
public ToolQuartzCuttingKnife( AEFeature Type )
|
||||
public ToolQuartzCuttingKnife( AEFeature type )
|
||||
{
|
||||
super( ToolQuartzCuttingKnife.class, Optional.of( Type.name() ) );
|
||||
super( Optional.of( type.name() ) );
|
||||
|
||||
this.setFeature( EnumSet.of( this.type = Type, AEFeature.QuartzKnife ) );
|
||||
this.type = type;
|
||||
this.setFeature( EnumSet.of( type, AEFeature.QuartzKnife ) );
|
||||
this.setMaxDamage( 50 );
|
||||
this.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ package appeng.items.tools.quartz;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -30,6 +28,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import appeng.api.implementations.items.IAEWrench;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
@@ -45,7 +44,7 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren
|
||||
|
||||
public ToolQuartzWrench( AEFeature type )
|
||||
{
|
||||
super( ToolQuartzWrench.class, Optional.of( type.name() ) );
|
||||
super( Optional.of( type.name() ) );
|
||||
|
||||
this.setFeature( EnumSet.of( type, AEFeature.QuartzWrench ) );
|
||||
this.setMaxStackSize( 1 );
|
||||
|
||||
Reference in New Issue
Block a user