Compare commits

...

4 Commits

10 changed files with 67 additions and 66 deletions
@@ -24,6 +24,8 @@
package appeng.api.implementations.items;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellWorkbenchItem;
@@ -52,7 +54,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
*
* @return number of bytes
*/
int getBytes( ItemStack cellItem );
int getBytes( @Nonnull ItemStack cellItem );
/**
* Determines the number of bytes used for any type included on the cell.
@@ -61,7 +63,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
*
* @return number of bytes
*/
int getBytesPerType( ItemStack cellItem );
int getBytesPerType( @Nonnull ItemStack cellItem );
/**
* Must be between 1 and 63, indicates how many types you want to store on
@@ -71,7 +73,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
*
* @return number of types
*/
int getTotalTypes( ItemStack cellItem );
int getTotalTypes( @Nonnull ItemStack cellItem );
/**
* Allows you to fine tune which items are allowed on a given cell, if you
@@ -83,7 +85,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
*
* @return true to preventAdditionOfItem
*/
boolean isBlackListed( ItemStack cellItem, T requestedAddition );
boolean isBlackListed( @Nonnull ItemStack cellItem, @Nonnull T requestedAddition );
/**
* Allows you to specify if this storage cell can be stored inside other
@@ -104,7 +106,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
*
* @return if the ItemStack should behavior as a storage cell.
*/
boolean isStorageCell( ItemStack i );
boolean isStorageCell( @Nonnull ItemStack i );
/**
* @return drain in ae/t this storage cell will use.
@@ -114,5 +116,6 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
/**
* @return the type of channel your cell should be part of
*/
@Nonnull
IStorageChannel<T> getChannel();
}
@@ -19,14 +19,17 @@
package appeng.core.api.definitions;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IOreDictComponent;
import appeng.client.render.crafting.ItemEncodedPatternRendering;
import appeng.core.CreativeTabFacade;
import appeng.core.features.AEFeature;
@@ -158,9 +161,13 @@ public final class ApiItems implements IItems
this.certusQuartzSword = certusTools.item( "certus_quartz_sword", () -> new ToolQuartzSword( AEFeature.CERTUS_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_SWORD )
.build();
this.certusQuartzWrench = certusTools.item( "certus_quartz_wrench", ToolQuartzWrench::new ).addFeatures( AEFeature.QUARTZ_WRENCH ).build();
this.certusQuartzWrench = certusTools.item( "certus_quartz_wrench", ToolQuartzWrench::new )
.addFeatures( AEFeature.QUARTZ_WRENCH )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
.build();
this.certusQuartzKnife = certusTools.item( "certus_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.CERTUS_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build();
FeatureFactory netherTools = registry.features( AEFeature.NETHER_QUARTZ_TOOLS );
@@ -179,9 +186,13 @@ public final class ApiItems implements IItems
this.netherQuartzSword = netherTools.item( "nether_quartz_sword", () -> new ToolQuartzSword( AEFeature.NETHER_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_SWORD )
.build();
this.netherQuartzWrench = netherTools.item( "nether_quartz_wrench", ToolQuartzWrench::new ).addFeatures( AEFeature.QUARTZ_WRENCH ).build();
this.netherQuartzWrench = netherTools.item( "nether_quartz_wrench", ToolQuartzWrench::new )
.addFeatures( AEFeature.QUARTZ_WRENCH )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzWrench", new ItemStack( item ) ) )
.build();
this.netherQuartzKnife = netherTools.item( "nether_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.NETHER_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build();
FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS );
@@ -64,52 +64,44 @@ public class BasicCellInventory<T extends IAEStack<T>> extends AbstractCellInven
}
}
public static <T extends AEStack<T>> boolean isCellOfType( final ItemStack input, IStorageChannel channel )
public static <T extends AEStack<T>> boolean isCellOfType( final ItemStack input, IStorageChannel<?> channel )
{
if( input == null )
{
return false;
}
final IStorageCell<?> type = getStorageCell( input );
final Item type = input.getItem();
if( type instanceof IStorageCell )
{
return ( (IStorageCell) type ).getChannel() == channel;
}
return false;
return type != null && type.getChannel() == channel;
}
public static boolean isCell( final ItemStack input )
{
if( input == null )
{
return false;
}
return getStorageCell( input ) != null;
}
try
private boolean isStorageCell( final T input )
{
if( input instanceof IAEItemStack )
{
final Item type = input.getItem();
if( type instanceof IStorageCell )
{
return !( (IStorageCell) type ).storableInStorageCell();
}
}
catch( final Throwable err )
{
return true;
final IAEItemStack stack = (IAEItemStack) input;
final IStorageCell<?> type = getStorageCell( stack.getDefinition() );
return type != null && !type.storableInStorageCell();
}
return false;
}
private boolean isStorageCell( final T input )
private static IStorageCell<?> getStorageCell( final ItemStack input )
{
if( !input.isItem() )
if( input != null )
{
return false;
final Item type = input.getItem();
if( type instanceof IStorageCell )
{
return (IStorageCell<?>) type;
}
}
return isCell( ( (IAEItemStack) input ).getDefinition() );
return null;
}
@SuppressWarnings( { "rawtypes", "unchecked" } )
@@ -288,7 +288,18 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
{
this.resetCache( false );
final TileEntity te = w.getTileEntity( neighbor );
// In case the TE was destroyed, we have to do a full reset immediately.
if( te == null )
{
this.resetCache( true );
this.resetCache();
}
else
{
this.resetCache( false );
}
}
}
@@ -20,40 +20,22 @@
]
},
{
"name": "appliedenergistics2:knife",
"conditions": [
{
"type": "appliedenergistics2:features",
"features": "quartz_knife"
}
],
"ingredient": [
{
"item": "appliedenergistics2:certus_quartz_cutting_knife",
"data": 32767
},
{
"item": "appliedenergistics2:nether_quartz_cutting_knife",
"data": 32767
}
]
},
{
"name": "appliedenergistics2:wrench",
"name": "appliedenergistics2:fluid_interface",
"conditions": [
{
"type": "appliedenergistics2:features",
"features": [
"quartz_wrench"
"fluid_interface"
]
}
],
"ingredient": [
{
"item": "appliedenergistics2:certus_quartz_wrench"
"item": "appliedenergistics2:fluid_interface"
},
{
"item": "appliedenergistics2:nether_quartz_wrench"
"type": "appliedenergistics2:part",
"part": "part.fluid_interface"
}
]
},
@@ -12,7 +12,7 @@
"key": {
"b": {
"type": "appliedenergistics2:part",
"part": "material.engineering_processor"
"part": "material.calculation_processor"
},
"d": {
"item": "appliedenergistics2:quartz_glass"
@@ -12,7 +12,7 @@
"key": {
"b": {
"type": "appliedenergistics2:part",
"part": "material.engineering_processor"
"part": "material.calculation_processor"
},
"c": {
"type": "appliedenergistics2:part",
@@ -9,7 +9,8 @@
"item": "#appliedenergistics2:metalIngots"
},
{
"item": "#appliedenergistics2:knife"
"type": "forge:ore_dict",
"ore": "itemQuartzKnife"
}
]
}
@@ -9,7 +9,7 @@
"item": "minecraft:sticky_piston"
},
{
"item": "#appliedenergistics2:interface"
"item": "#appliedenergistics2:fluid_interface"
},
{
"item": "minecraft:piston"
@@ -13,7 +13,8 @@
"ore": "chestWood"
},
{
"item": "#appliedenergistics2:wrench"
"type": "forge:ore_dict",
"ore": "itemQuartzWrench"
},
{
"type": "appliedenergistics2:part",