Fixed an issue where Parts/Blocks would not properly identify them selves with the proper ItemStack.
This commit is contained in:
@@ -35,6 +35,7 @@ import appeng.client.texture.FlipableIcon;
|
|||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.AEFeatureHandler;
|
import appeng.core.features.AEFeatureHandler;
|
||||||
import appeng.core.features.IAEFeature;
|
import appeng.core.features.IAEFeature;
|
||||||
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.helpers.ICustomCollision;
|
import appeng.helpers.ICustomCollision;
|
||||||
import appeng.tile.AEBaseTile;
|
import appeng.tile.AEBaseTile;
|
||||||
import appeng.tile.networking.TileCableBus;
|
import appeng.tile.networking.TileCableBus;
|
||||||
@@ -151,7 +152,7 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature
|
|||||||
|
|
||||||
protected void setTileEntiy(Class<? extends TileEntity> c)
|
protected void setTileEntiy(Class<? extends TileEntity> c)
|
||||||
{
|
{
|
||||||
AEBaseTile.registerTileItem( c, new ItemStack( this ) );
|
AEBaseTile.registerTileItem( c, new ItemStackSrc( this, 0 ) );
|
||||||
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
|
GameRegistry.registerTileEntity( tileEntityType = c, FeatureFullname );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class ContainerNetworkStatus extends AEBaseContainer
|
|||||||
{
|
{
|
||||||
IGridBlock blk = machine.getGridBlock();
|
IGridBlock blk = machine.getGridBlock();
|
||||||
ItemStack is = blk.getMachineRepresentation();
|
ItemStack is = blk.getMachineRepresentation();
|
||||||
if ( is != null )
|
if ( is != null && is.getItem() != null )
|
||||||
{
|
{
|
||||||
IAEItemStack ais = AEItemStack.create( is );
|
IAEItemStack ais = AEItemStack.create( is );
|
||||||
ais.setStackSize( 1 );
|
ais.setStackSize( 1 );
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package appeng.core;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.WeightedRandomChestContent;
|
import net.minecraft.util.WeightedRandomChestContent;
|
||||||
import net.minecraft.world.biome.BiomeGenBase;
|
import net.minecraft.world.biome.BiomeGenBase;
|
||||||
import net.minecraftforge.common.ChestGenHooks;
|
import net.minecraftforge.common.ChestGenHooks;
|
||||||
@@ -63,6 +62,7 @@ import appeng.core.features.AEFeatureHandler;
|
|||||||
import appeng.core.features.ColoredItemDefinition;
|
import appeng.core.features.ColoredItemDefinition;
|
||||||
import appeng.core.features.DamagedItemDefinition;
|
import appeng.core.features.DamagedItemDefinition;
|
||||||
import appeng.core.features.IAEFeature;
|
import appeng.core.features.IAEFeature;
|
||||||
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.core.features.NullItemDefinition;
|
import appeng.core.features.NullItemDefinition;
|
||||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||||
import appeng.core.features.registries.entries.BasicCellHandler;
|
import appeng.core.features.registries.entries.BasicCellHandler;
|
||||||
@@ -149,7 +149,7 @@ public class Registration
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Field f = materialClass.getField( "material" + mat.name() );
|
Field f = materialClass.getField( "material" + mat.name() );
|
||||||
ItemStack is = ((ItemMaterial) materialItem.item()).createMaterial( mat );
|
ItemStackSrc is = ((ItemMaterial) materialItem.item()).createMaterial( mat );
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
f.set( materials, new DamagedItemDefinition( is ) );
|
f.set( materials, new DamagedItemDefinition( is ) );
|
||||||
else
|
else
|
||||||
@@ -173,7 +173,7 @@ public class Registration
|
|||||||
Enum varients[] = type.getVarients();
|
Enum varients[] = type.getVarients();
|
||||||
if ( varients == null )
|
if ( varients == null )
|
||||||
{
|
{
|
||||||
ItemStack is = ((ItemPart) partItem.item()).createPart( type, null );
|
ItemStackSrc is = ((ItemPart) partItem.item()).createPart( type, null );
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
f.set( parts, new DamagedItemDefinition( is ) );
|
f.set( parts, new DamagedItemDefinition( is ) );
|
||||||
else
|
else
|
||||||
@@ -187,7 +187,7 @@ public class Registration
|
|||||||
|
|
||||||
for (Enum v : varients)
|
for (Enum v : varients)
|
||||||
{
|
{
|
||||||
ItemStack is = ((ItemPart) partItem.item()).createPart( type, v );
|
ItemStackSrc is = ((ItemPart) partItem.item()).createPart( type, v );
|
||||||
if ( is != null )
|
if ( is != null )
|
||||||
def.add( (AEColor) v, is );
|
def.add( (AEColor) v, is );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,42 +10,42 @@ import appeng.api.util.AEColoredItemDefinition;
|
|||||||
public class ColoredItemDefinition implements AEColoredItemDefinition
|
public class ColoredItemDefinition implements AEColoredItemDefinition
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemStack colors[] = new ItemStack[17];
|
ItemStackSrc colors[] = new ItemStackSrc[17];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item item(AEColor color)
|
public Item item(AEColor color)
|
||||||
{
|
{
|
||||||
ItemStack is = colors[color.ordinal()];
|
ItemStackSrc is = colors[color.ordinal()];
|
||||||
|
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return is.getItem();
|
return is.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack stack(AEColor color, int stackSize)
|
public ItemStack stack(AEColor color, int stackSize)
|
||||||
{
|
{
|
||||||
ItemStack is = colors[color.ordinal()];
|
ItemStackSrc is = colors[color.ordinal()];
|
||||||
|
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new ItemStack( is.getItem(), stackSize, is.getItemDamage() );
|
return is.stack( stackSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean sameAs(AEColor color, ItemStack comparableItem)
|
public boolean sameAs(AEColor color, ItemStack comparableItem)
|
||||||
{
|
{
|
||||||
ItemStack is = colors[color.ordinal()];
|
ItemStackSrc is = colors[color.ordinal()];
|
||||||
|
|
||||||
if ( comparableItem == null )
|
if ( comparableItem == null )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return comparableItem.getItem() == is.getItem() && comparableItem.getItemDamage() == is.getItemDamage();
|
return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(AEColor v, ItemStack is)
|
public void add(AEColor v, ItemStackSrc is)
|
||||||
{
|
{
|
||||||
colors[v.ordinal()] = is;
|
colors[v.ordinal()] = is;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class DamagedItemDefinition implements AEItemDefinition
|
|||||||
final Item baseItem;
|
final Item baseItem;
|
||||||
final int damage;
|
final int damage;
|
||||||
|
|
||||||
public DamagedItemDefinition(ItemStack is) {
|
public DamagedItemDefinition(ItemStackSrc is) {
|
||||||
if ( is == null )
|
if ( is == null )
|
||||||
{
|
{
|
||||||
baseItem = null;
|
baseItem = null;
|
||||||
@@ -20,8 +20,8 @@ public class DamagedItemDefinition implements AEItemDefinition
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
baseItem = is.getItem();
|
baseItem = is.item;
|
||||||
damage = is.getItemDamage();
|
damage = is.damage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package appeng.core.features;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ItemStackSrc
|
||||||
|
{
|
||||||
|
|
||||||
|
public final Item item;
|
||||||
|
public final Block block;
|
||||||
|
public final int damage;
|
||||||
|
|
||||||
|
public ItemStackSrc(Item i, int dmg) {
|
||||||
|
block = null;
|
||||||
|
item = i;
|
||||||
|
damage = dmg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackSrc(Block b, int dmg) {
|
||||||
|
item = null;
|
||||||
|
block = b;
|
||||||
|
damage = dmg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack stack(int i)
|
||||||
|
{
|
||||||
|
if ( block != null )
|
||||||
|
return new ItemStack( block, i, damage );
|
||||||
|
return new ItemStack( item, i, damage );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import appeng.api.implementations.items.IUpgradeModule;
|
|||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.AEFeatureHandler;
|
import appeng.core.features.AEFeatureHandler;
|
||||||
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.items.AEBaseItem;
|
import appeng.items.AEBaseItem;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ public class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack createMaterial(MaterialType mat)
|
public ItemStackSrc createMaterial(MaterialType mat)
|
||||||
{
|
{
|
||||||
String name = mat.name();
|
String name = mat.name();
|
||||||
|
|
||||||
@@ -123,13 +124,12 @@ public class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgr
|
|||||||
{
|
{
|
||||||
int newMaterialNum = AEConfig.instance.get( "materials", name, AEConfig.instance.getFreeMaterial() ).getInt();
|
int newMaterialNum = AEConfig.instance.get( "materials", name, AEConfig.instance.getFreeMaterial() ).getInt();
|
||||||
mat.damageValue = newMaterialNum;
|
mat.damageValue = newMaterialNum;
|
||||||
ItemStack output = new ItemStack( this, 1, newMaterialNum );
|
ItemStackSrc output = new ItemStackSrc( this, newMaterialNum );
|
||||||
output.setItemDamage( newMaterialNum );
|
|
||||||
|
|
||||||
dmgToMaterial.put( newMaterialNum, mat );
|
dmgToMaterial.put( newMaterialNum, mat );
|
||||||
|
|
||||||
if ( mat.getOreName() != null )
|
if ( mat.getOreName() != null )
|
||||||
OreDictionary.registerOre( mat.getOreName(), output );
|
OreDictionary.registerOre( mat.getOreName(), output.stack( 1 ) );
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import appeng.api.parts.IPartItem;
|
|||||||
import appeng.core.AEConfig;
|
import appeng.core.AEConfig;
|
||||||
import appeng.core.features.AEFeature;
|
import appeng.core.features.AEFeature;
|
||||||
import appeng.core.features.AEFeatureHandler;
|
import appeng.core.features.AEFeatureHandler;
|
||||||
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.core.localization.GuiText;
|
import appeng.core.localization.GuiText;
|
||||||
import appeng.items.AEBaseItem;
|
import appeng.items.AEBaseItem;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
@@ -47,10 +48,11 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
|
|||||||
setHasSubtypes( true );
|
setHasSubtypes( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack createPart(PartType mat, Enum varient)
|
public ItemStackSrc createPart(PartType mat, Enum varient)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// I think this still works?
|
||||||
ItemStack is = new ItemStack( this );
|
ItemStack is = new ItemStack( this );
|
||||||
mat.getPart().getConstructor( ItemStack.class ).newInstance( is );
|
mat.getPart().getConstructor( ItemStack.class ).newInstance( is );
|
||||||
}
|
}
|
||||||
@@ -76,8 +78,7 @@ public class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
|
|||||||
if ( enabled )
|
if ( enabled )
|
||||||
{
|
{
|
||||||
int newPartNum = AEConfig.instance.get( "parts", name, AEConfig.instance.getFreePart() ).getInt();
|
int newPartNum = AEConfig.instance.get( "parts", name, AEConfig.instance.getFreePart() ).getInt();
|
||||||
ItemStack output = new ItemStack( this );
|
ItemStackSrc output = new ItemStackSrc( this, newPartNum );
|
||||||
output.setItemDamage( newPartNum );
|
|
||||||
|
|
||||||
PartTypeIst pti = new PartTypeIst();
|
PartTypeIst pti = new PartTypeIst();
|
||||||
pti.part = mat;
|
pti.part = mat;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||||||
import appeng.api.util.ICommonTile;
|
import appeng.api.util.ICommonTile;
|
||||||
import appeng.api.util.IOrientable;
|
import appeng.api.util.IOrientable;
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
import appeng.core.features.ItemStackSrc;
|
||||||
import appeng.tile.events.AETileEventHandler;
|
import appeng.tile.events.AETileEventHandler;
|
||||||
import appeng.tile.events.TileEventType;
|
import appeng.tile.events.TileEventType;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -32,7 +33,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final EnumMap<TileEventType, List<AETileEventHandler>> handlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
|
private final EnumMap<TileEventType, List<AETileEventHandler>> handlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
|
||||||
private final static HashMap<Class, ItemStack> myItem = new HashMap();
|
private final static HashMap<Class, ItemStackSrc> myItem = new HashMap();
|
||||||
|
|
||||||
private ForgeDirection forward = ForgeDirection.UNKNOWN;
|
private ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||||
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||||
@@ -45,14 +46,17 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void registerTileItem(Class c, ItemStack wat)
|
static public void registerTileItem(Class c, ItemStackSrc wat)
|
||||||
{
|
{
|
||||||
myItem.put( c, wat );
|
myItem.put( c, wat );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack getItemFromTile(Object obj)
|
protected ItemStack getItemFromTile(Object obj)
|
||||||
{
|
{
|
||||||
return myItem.get( obj.getClass() );
|
ItemStackSrc src = myItem.get( obj.getClass() );
|
||||||
|
if ( src == null )
|
||||||
|
return null;
|
||||||
|
return src.stack( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user