Compare commits

...

13 Commits

Author SHA1 Message Date
yueh 0c88d1e7ee Fixes #3746: Revert OreDict use for cable anchors. Blame Forge for crashes. (#3764) 2018-10-06 00:02:41 +02:00
fscan d88f550eb0 Switch to new IItemHandler (#3669) 2018-10-04 20:39:06 +02:00
yueh e21c59b326 Fixes #3146: Prevent crash when GlassState is missing. (#3758) 2018-10-04 19:33:10 +02:00
yueh d8af8d26be Updated to new Forge RB (#3760) 2018-10-04 19:32:47 +02:00
yueh 02426bc101 Update bug_report.md
Fixed missing *
2018-10-02 17:38:22 +02:00
yueh 11f8471772 Updated issue templates
Updated bug report
Added feature request
2018-10-01 13:12:44 +02:00
yueh d35b720a16 Update issue templates (#3751) 2018-10-01 13:00:07 +02:00
mezz 7a5b84c10a Allow JEI to differentiate between different cable facades (#3750) 2018-10-01 11:18:38 +02:00
covers1624 800860d4e6 Fixes #3747: Fix issues with facade breaking textures. (#3748) 2018-10-01 11:12:38 +02:00
yueh ac81418684 Changed some fluid recipes to match their item variant. (#3744) 2018-09-28 18:25:05 +02:00
yueh 7daad58607 Fixes #3742: Do not use storableInStorageCell() to identify generic c… (#3743)
Annotated IStorageCell with Nonnull where appropriate.
2018-09-28 17:38:08 +02:00
yueh 038ca23523 Fixes #3688: Invalidate Storage Bus cache immediately upon missing TE. (#3737) 2018-09-28 17:36:58 +02:00
yueh 37d8833b95 Fixes #3708: Move knifes/wrenches to oredict as constants are unreliable (#3729) 2018-09-22 20:14:28 +02:00
29 changed files with 186 additions and 233 deletions
+30
View File
@@ -0,0 +1,30 @@
---
name: Bug report
about: You found a bug or encountered a crash? Please report it here.
---
<!-- Provide a summary of the issue in the Title above, please do not "[Tag]" it. -->
**Describe the bug**
<!-- Always use the most recent version from ae-mod.info, it might already be fixed. -->
**To Reproduce**
<!-- Please provide the steps to reproduce it, otherwise we might not be able to fix it. -->
**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
**Additional context**
<!-- Screenshots, crashlogs, etc. -->
<!-- A complete crashlog is required when reporting a crash. No excerpts. -->
<!-- Please use pastebin or gist for posting the complete crashlog. -->
**Environment**
<!-- Include as many relevant details about the environment -->
<!-- Like the used version, SP/MP, other mods and their version -->
<!-- The following ones are required, please note "latest" is not a version -->
- Minecraft Version:
- AE2 Version:
- Forge Version:
+17
View File
@@ -0,0 +1,17 @@
---
name: Feature Request
about: A feature request or suggestion to improve Applied Energistics 2
---
<!-- Provide a summary of the issue in the Title above, please do not "[Tag]" it. -->
**Describe the feature**
<!-- Tell us how it should work. -->
**Reasons why it should be considered**
<!-- This can help us in various degrees, e.g. to determine if it fits our design ideas. -->
**Additional Context**
<!-- Use this for further details, e.g. screenshots, links to mods for integrations. -->
<!-- Features will only be considered for the latest/next version. -->
+2 -2
View File
@@ -9,7 +9,7 @@ aebasename=appliedenergistics2
######################################################### #########################################################
minecraft_version=1.12.2 minecraft_version=1.12.2
mcp_mappings=snapshot_20171003 mcp_mappings=snapshot_20171003
forge_version=14.23.3.2655 forge_version=14.23.5.2768
######################################################### #########################################################
# Installable # # Installable #
@@ -19,7 +19,7 @@ hwyla_version=1.8.26-B41_1.12.2
######################################################### #########################################################
# Provided APIs # # Provided APIs #
######################################################### #########################################################
jei_version=4.10.0.198 jei_version=4.13.0.219
tesla_version=1.0.63 tesla_version=1.0.63
ic2_version=2.8.73-ex112 ic2_version=2.8.73-ex112
top_version=1.12-1.4.23-16 top_version=1.12-1.4.23-16
@@ -24,6 +24,8 @@
package appeng.api.implementations.items; package appeng.api.implementations.items;
import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.ICellWorkbenchItem; import appeng.api.storage.ICellWorkbenchItem;
@@ -52,7 +54,7 @@ public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem
* *
* @return number of bytes * @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. * 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 * @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 * 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 * @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 * 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 * @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 * 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. * @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. * @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 * @return the type of channel your cell should be part of
*/ */
@Nonnull
IStorageChannel<T> getChannel(); IStorageChannel<T> getChannel();
} }
@@ -67,8 +67,8 @@ import appeng.thirdparty.codechicken.lib.model.pipeline.transformers.QuadTinter;
public class FacadeBuilder public class FacadeBuilder
{ {
public static double THICK_THICKNESS = 2D / 16D; public static final double THICK_THICKNESS = 2D / 16D;
public static double THIN_THICKNESS = 1D / 16D; public static final double THIN_THICKNESS = 1D / 16D;
public static final AxisAlignedBB[] THICK_FACADE_BOXES = new AxisAlignedBB[] { public static final AxisAlignedBB[] THICK_FACADE_BOXES = new AxisAlignedBB[] {
new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, THICK_THICKNESS, 1.0 ), new AxisAlignedBB( 0.0, 0.0, 0.0, 1.0, THICK_THICKNESS, 1.0 ),
@@ -141,7 +141,7 @@ public class FacadeBuilder
IBlockState blockState = facadeRenderState.getSourceBlock(); IBlockState blockState = facadeRenderState.getSourceBlock();
// If we aren't forcing transparency let the block decide if it should render. // If we aren't forcing transparency let the block decide if it should render.
if( !transparent ) if( !transparent && layer != null )
{ {
if( !blockState.getBlock().canRenderInLayer( blockState, layer ) ) if( !blockState.getBlock().canRenderInLayer( blockState, layer ) )
{ {
@@ -224,7 +224,7 @@ public class FacadeBuilder
List<BakedQuad> modelQuads = new ArrayList<>(); List<BakedQuad> modelQuads = new ArrayList<>();
// If we are forcing transparent facades, fake the render layer, and grab all quads. // If we are forcing transparent facades, fake the render layer, and grab all quads.
if( transparent ) if( transparent || layer == null )
{ {
for( BlockRenderLayer forcedLayer : BlockRenderLayer.values() ) for( BlockRenderLayer forcedLayer : BlockRenderLayer.values() )
{ {
@@ -100,15 +100,18 @@ class GlassBakedModel implements IBakedModel
@Override @Override
public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand ) public List<BakedQuad> getQuads( @Nullable IBlockState state, @Nullable EnumFacing side, long rand )
{ {
if( !( state instanceof IExtendedBlockState ) || side == null ) if( !( state instanceof IExtendedBlockState ) || side == null )
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
IExtendedBlockState extState = (IExtendedBlockState) state; final IExtendedBlockState extState = (IExtendedBlockState) state;
final GlassState glassState = extState.getValue( BlockQuartzGlass.GLASS_STATE );
GlassState glassState = extState.getValue( BlockQuartzGlass.GLASS_STATE ); if( glassState == null )
{
return Collections.emptyList();
}
final int cx = Math.abs( glassState.getX() % 10 ); final int cx = Math.abs( glassState.getX() % 10 );
final int cy = Math.abs( glassState.getY() % 10 ); final int cy = Math.abs( glassState.getY() % 10 );
@@ -125,12 +128,12 @@ class GlassBakedModel implements IBakedModel
v /= 2; v /= 2;
} }
TextureAtlasSprite glassTexture = this.glassTextures[texIdx]; final TextureAtlasSprite glassTexture = this.glassTextures[texIdx];
// Render the glass side // Render the glass side
List<BakedQuad> quads = new ArrayList<>( 5 ); // At most 5 final List<BakedQuad> quads = new ArrayList<>( 5 ); // At most 5
List<Vec3d> corners = RenderHelper.getFaceCorners( side ); final List<Vec3d> corners = RenderHelper.getFaceCorners( side );
quads.add( this.createQuad( side, corners, glassTexture, u, v ) ); quads.add( this.createQuad( side, corners, glassTexture, u, v ) );
/* /*
@@ -143,8 +146,9 @@ class GlassBakedModel implements IBakedModel
* Converted to a number, this bitmask is 5. So the texture at index 5 is used. * Converted to a number, this bitmask is 5. So the texture at index 5 is used.
* That texture had "0101" in its filename to indicate this. * That texture had "0101" in its filename to indicate this.
*/ */
int edgeBitmask = makeBitmask( glassState, side ); final int edgeBitmask = makeBitmask( glassState, side );
TextureAtlasSprite sideSprite = this.frameTextures[edgeBitmask]; final TextureAtlasSprite sideSprite = this.frameTextures[edgeBitmask];
if( sideSprite != null ) if( sideSprite != null )
{ {
quads.add( this.createQuad( side, corners, sideSprite, 0, 0 ) ); quads.add( this.createQuad( side, corners, sideSprite, 0, 0 ) );
@@ -462,7 +462,6 @@ public abstract class AEBaseContainer extends Container
else if( destination.isEmpty() ) else if( destination.isEmpty() )
{ {
cs.putStack( tis.copy() ); cs.putStack( tis.copy() );
cs.onSlotChanged();
this.updateSlot( cs ); this.updateSlot( cs );
break; break;
} }
@@ -87,7 +87,7 @@ public class AppEngSlot extends Slot
{ {
if( this.isSlotEnabled() ) if( this.isSlotEnabled() )
{ {
return ItemHandlerUtil.isItemValidForSlot( this.itemHandler, this.index, par1ItemStack ); return this.itemHandler.isItemValid( this.index, par1ItemStack );
} }
return false; return false;
} }
@@ -121,7 +121,6 @@ public class AppEngSlot extends Slot
if( this.isSlotEnabled() ) if( this.isSlotEnabled() )
{ {
ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack ); ItemHandlerUtil.setStackInSlot( this.itemHandler, this.index, stack );
this.onSlotChanged();
if( this.getContainer() != null ) if( this.getContainer() != null )
{ {
@@ -138,7 +137,6 @@ public class AppEngSlot extends Slot
@Override @Override
public void onSlotChanged() public void onSlotChanged()
{ {
ItemHandlerUtil.markDirty( this.itemHandler, this.index );
this.setIsValid( hasCalculatedValidness.NotAvailable ); this.setIsValid( hasCalculatedValidness.NotAvailable );
} }
@@ -19,14 +19,17 @@
package appeng.core.api.definitions; package appeng.core.api.definitions;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntryBuilder; import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.util.AEColoredItemDefinition; import appeng.api.util.AEColoredItemDefinition;
import appeng.bootstrap.FeatureFactory; import appeng.bootstrap.FeatureFactory;
import appeng.bootstrap.components.IEntityRegistrationComponent; import appeng.bootstrap.components.IEntityRegistrationComponent;
import appeng.bootstrap.components.IOreDictComponent;
import appeng.client.render.crafting.ItemEncodedPatternRendering; import appeng.client.render.crafting.ItemEncodedPatternRendering;
import appeng.core.CreativeTabFacade; import appeng.core.CreativeTabFacade;
import appeng.core.features.AEFeature; 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 ) ) this.certusQuartzSword = certusTools.item( "certus_quartz_sword", () -> new ToolQuartzSword( AEFeature.CERTUS_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_SWORD ) .addFeatures( AEFeature.QUARTZ_SWORD )
.build(); .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 ) ) this.certusQuartzKnife = certusTools.item( "certus_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.CERTUS_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE ) .addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build(); .build();
FeatureFactory netherTools = registry.features( AEFeature.NETHER_QUARTZ_TOOLS ); 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 ) ) this.netherQuartzSword = netherTools.item( "nether_quartz_sword", () -> new ToolQuartzSword( AEFeature.NETHER_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_SWORD ) .addFeatures( AEFeature.QUARTZ_SWORD )
.build(); .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 ) ) this.netherQuartzKnife = netherTools.item( "nether_quartz_cutting_knife", () -> new ToolQuartzCuttingKnife( AEFeature.NETHER_QUARTZ_TOOLS ) )
.addFeatures( AEFeature.QUARTZ_KNIFE ) .addFeatures( AEFeature.QUARTZ_KNIFE )
.bootstrap( item -> (IOreDictComponent) side -> OreDictionary.registerOre( "itemQuartzKnife", new ItemStack( item ) ) )
.build(); .build();
FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS ); FeatureFactory powerTools = registry.features( AEFeature.POWERED_TOOLS );
@@ -85,11 +85,11 @@ public class FluidCellConfig extends CellConfig
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
if( stack.isEmpty() || stack.getItem() instanceof FluidDummyItem ) if( stack.isEmpty() || stack.getItem() instanceof FluidDummyItem )
{ {
super.isItemValidForSlot( slot, stack ); super.isItemValid( slot, stack );
} }
FluidStack fluid = FluidUtil.getFluidContained( stack ); FluidStack fluid = FluidUtil.getFluidContained( stack );
if( fluid == null || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() ) if( fluid == null || !Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).isPresent() )
@@ -100,7 +100,7 @@ public class FluidCellConfig extends CellConfig
ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get(); ItemStack is = Api.INSTANCE.definitions().items().dummyFluidItem().maybeStack( 1 ).get();
FluidDummyItem item = (FluidDummyItem) is.getItem(); FluidDummyItem item = (FluidDummyItem) is.getItem();
item.setFluidStack( is, fluid ); item.setFluidStack( is, fluid );
return super.isItemValidForSlot( slot, is ); return super.isItemValid( slot, is );
} }
} }
@@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
import mezz.jei.api.IJeiRuntime; import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin; import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry; import mezz.jei.api.IModRegistry;
import mezz.jei.api.ISubtypeRegistry;
import mezz.jei.api.recipe.IRecipeCategoryRegistration; import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
@@ -54,6 +55,12 @@ import appeng.items.parts.ItemFacade;
@mezz.jei.api.JEIPlugin @mezz.jei.api.JEIPlugin
public class JEIPlugin implements IModPlugin public class JEIPlugin implements IModPlugin
{ {
@Override
public void registerItemSubtypes( ISubtypeRegistry subtypeRegistry )
{
final Optional<Item> maybeFacade = AEApi.instance().definitions().items().facade().maybeItem();
maybeFacade.ifPresent( subtypeRegistry::useNbtForSubtypes );
}
@Override @Override
public void registerCategories( IRecipeCategoryRegistration registry ) public void registerCategories( IRecipeCategoryRegistration registry )
@@ -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 ) final IStorageCell<?> type = getStorageCell( input );
{
return false;
}
final Item type = input.getItem(); return type != null && type.getChannel() == channel;
if( type instanceof IStorageCell )
{
return ( (IStorageCell) type ).getChannel() == channel;
}
return false;
} }
public static boolean isCell( final ItemStack input ) public static boolean isCell( final ItemStack input )
{ {
if( input == null ) return getStorageCell( input ) != null;
{ }
return false;
}
try private boolean isStorageCell( final T input )
{
if( input instanceof IAEItemStack )
{ {
final Item type = input.getItem(); final IAEItemStack stack = (IAEItemStack) input;
if( type instanceof IStorageCell ) final IStorageCell<?> type = getStorageCell( stack.getDefinition() );
{
return !( (IStorageCell) type ).storableInStorageCell(); return type != null && !type.storableInStorageCell();
}
}
catch( final Throwable err )
{
return true;
} }
return false; 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" } ) @SuppressWarnings( { "rawtypes", "unchecked" } )
@@ -288,7 +288,18 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{ {
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) 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 );
}
} }
} }
@@ -3,15 +3,15 @@ package appeng.tile.inventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.api.storage.ICellInventory; import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler; import appeng.api.storage.ICellInventoryHandler;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInternalItemHandler;
import appeng.util.inv.filter.IAEItemFilter; import appeng.util.inv.filter.IAEItemFilter;
public class AppEngCellInventory implements IInternalItemHandler public class AppEngCellInventory implements IItemHandlerModifiable
{ {
private final AppEngInternalInventory inv; private final AppEngInternalInventory inv;
private final ICellInventoryHandler handlerForSlot[]; private final ICellInventoryHandler handlerForSlot[];
@@ -78,17 +78,9 @@ public class AppEngCellInventory implements IInternalItemHandler
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
return this.inv.isItemValidForSlot( slot, stack ); return this.inv.isItemValid( slot, stack );
}
@Override
public void markDirty( int slot )
{
this.persist( slot );
this.inv.markDirty( slot );
this.cleanup( slot );
} }
public void persist() public void persist()
@@ -25,6 +25,7 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.AEApi; import appeng.api.AEApi;
@@ -33,14 +34,13 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInternalItemHandler;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import appeng.util.iterators.AEInvIterator; import appeng.util.iterators.AEInvIterator;
import appeng.util.iterators.InvIterator; import appeng.util.iterators.InvIterator;
public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable<ItemStack> public class AppEngInternalAEInventory implements IItemHandlerModifiable, Iterable<ItemStack>
{ {
private final IAEAppEngInventory te; private final IAEAppEngInventory te;
private final IAEItemStack[] inv; private final IAEItemStack[] inv;
@@ -254,7 +254,7 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
private void fireOnChangeInventory( int slot, InvOperation op, ItemStack removed, ItemStack inserted ) private void fireOnChangeInventory( int slot, InvOperation op, ItemStack removed, ItemStack inserted )
{ {
if( this.te != null && Platform.isServer() ) if( this.te != null && Platform.isServer() && !this.dirtyFlag )
{ {
this.dirtyFlag = true; this.dirtyFlag = true;
this.te.onChangeInventory( this, slot, op, removed, inserted ); this.te.onChangeInventory( this, slot, op, removed, inserted );
@@ -281,17 +281,8 @@ public class AppEngInternalAEInventory implements IInternalItemHandler, Iterable
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
return true; return true;
} }
@Override
public void markDirty( int slot )
{
if( !this.dirtyFlag )
{
this.fireOnChangeInventory( slot, InvOperation.DIRTY, ItemStack.EMPTY, ItemStack.EMPTY );
}
}
} }
@@ -31,12 +31,11 @@ import net.minecraftforge.items.ItemStackHandler;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.IInternalItemHandler;
import appeng.util.inv.InvOperation; import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.IAEItemFilter; import appeng.util.inv.filter.IAEItemFilter;
public class AppEngInternalInventory extends ItemStackHandler implements IInternalItemHandler, Iterable<ItemStack> public class AppEngInternalInventory extends ItemStackHandler implements Iterable<ItemStack>
{ {
private boolean enableClientEvents = false; private boolean enableClientEvents = false;
private IAEAppEngInventory te; private IAEAppEngInventory te;
@@ -117,7 +116,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
@Override @Override
protected void onContentsChanged( int slot ) protected void onContentsChanged( int slot )
{ {
if( this.getTileEntity() != null && this.eventsEnabled() ) if( this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag )
{ {
this.dirtyFlag = true; this.dirtyFlag = true;
ItemStack newStack = this.getStackInSlot( slot ).copy(); ItemStack newStack = this.getStackInSlot( slot ).copy();
@@ -159,19 +158,7 @@ public class AppEngInternalInventory extends ItemStackHandler implements IIntern
} }
@Override @Override
public void markDirty( final int slot ) public boolean isItemValid( int slot, ItemStack stack )
{
if( this.getTileEntity() != null && this.eventsEnabled() && !this.dirtyFlag )
{
this.dirtyFlag = true;
this.getTileEntity().onChangeInventory( this, slot, InvOperation.DIRTY, ItemStack.EMPTY, ItemStack.EMPTY );
this.getTileEntity().saveChanges();
this.dirtyFlag = false;
}
}
@Override
public boolean isItemValidForSlot( int slot, ItemStack stack )
{ {
if( this.maxStack[slot] == 0 ) if( this.maxStack[slot] == 0 )
{ {
@@ -24,8 +24,6 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.inv.IInternalItemHandler;
public class ItemHandlerUtil public class ItemHandlerUtil
{ {
@@ -66,37 +64,6 @@ public class ItemHandlerUtil
return true; return true;
} }
public static void markDirty( final IItemHandler inv, final int slot )
{
if( inv instanceof IInternalItemHandler )
{
( (IInternalItemHandler) inv ).markDirty( slot );
}
}
public static boolean isItemValidForSlot( final IItemHandler inv, int slot, ItemStack stack )
{
if( stack.isEmpty() )
{
return false;
}
if( inv instanceof IInternalItemHandler )
{
return ( (IInternalItemHandler) inv ).isItemValidForSlot( slot, stack );
}
// empty slot
ItemStack currentStack = inv.getStackInSlot( slot );
setStackInSlot( inv, slot, ItemStack.EMPTY );
// test insert
ItemStack remainder = inv.insertItem( slot, stack, true );
// restore slot
setStackInSlot( inv, slot, currentStack );
return remainder.isEmpty() || remainder.getCount() < stack.getCount();
}
public static void copy( final IItemHandler from, final IItemHandler to, boolean deepCopy ) public static void copy( final IItemHandler from, final IItemHandler to, boolean deepCopy )
{ {
for( int i = 0; i < Math.min( from.getSlots(), to.getSlots() ); ++i ) for( int i = 0; i < Math.min( from.getSlots(), to.getSlots() ); ++i )
@@ -1,31 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.util.inv;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
public interface IInternalItemHandler extends IItemHandlerModifiable
{
boolean isItemValidForSlot( int slot, ItemStack stack );
void markDirty( int slot );
}
@@ -21,5 +21,5 @@ package appeng.util.inv;
public enum InvOperation public enum InvOperation
{ {
EXTRACT, INSERT, SET, DIRTY EXTRACT, INSERT, SET
} }
@@ -25,12 +25,13 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.EmptyHandler; import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
public class WrapperChainedItemHandler implements IInternalItemHandler public class WrapperChainedItemHandler implements IItemHandlerModifiable
{ {
private IItemHandler[] itemHandler; // the handlers private IItemHandler[] itemHandler; // the handlers
private int[] baseIndex; // index-offsets of the different handlers private int[] baseIndex; // index-offsets of the different handlers
@@ -159,20 +160,11 @@ public class WrapperChainedItemHandler implements IInternalItemHandler
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
int index = this.getIndexForSlot( slot ); int index = this.getIndexForSlot( slot );
IItemHandler handler = this.getHandlerFromIndex( index ); IItemHandler handler = this.getHandlerFromIndex( index );
int targetSlot = this.getSlotFromIndex( slot, index ); int targetSlot = this.getSlotFromIndex( slot, index );
return ItemHandlerUtil.isItemValidForSlot( handler, targetSlot, stack ); return handler.isItemValid( targetSlot, stack );
}
@Override
public void markDirty( int slot )
{
int index = this.getIndexForSlot( slot );
IItemHandler handler = this.getHandlerFromIndex( index );
int targetSlot = this.getSlotFromIndex( slot, index );
ItemHandlerUtil.markDirty( handler, targetSlot );
} }
} }
@@ -23,12 +23,13 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.filter.IAEItemFilter; import appeng.util.inv.filter.IAEItemFilter;
public class WrapperFilteredItemHandler implements IInternalItemHandler public class WrapperFilteredItemHandler implements IItemHandlerModifiable
{ {
private final IItemHandler handler; private final IItemHandler handler;
private final IAEItemFilter filter; private final IAEItemFilter filter;
@@ -86,18 +87,12 @@ public class WrapperFilteredItemHandler implements IInternalItemHandler
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
if( !this.filter.allowInsert( this.handler, slot, stack ) ) if( !this.filter.allowInsert( this.handler, slot, stack ) )
{ {
return false; return false;
} }
return ItemHandlerUtil.isItemValidForSlot( this.handler, slot, stack ); return this.handler.isItemValid( slot, stack );
}
@Override
public void markDirty( int slot )
{
ItemHandlerUtil.markDirty( this.handler, slot );
} }
} }
@@ -105,7 +105,7 @@ public class WrapperInvItemHandler implements IInventory
@Override @Override
public void markDirty() public void markDirty()
{ {
ItemHandlerUtil.markDirty( this.inv, -1 ); // NOP
} }
@Override @Override
@@ -129,7 +129,7 @@ public class WrapperInvItemHandler implements IInventory
@Override @Override
public boolean isItemValidForSlot( int index, ItemStack stack ) public boolean isItemValidForSlot( int index, ItemStack stack )
{ {
return ItemHandlerUtil.isItemValidForSlot( this.inv, index, stack ); return this.inv.isItemValid( index, stack );
} }
@Override @Override
@@ -23,12 +23,13 @@ import java.util.function.Supplier;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.Lazy; import appeng.util.Lazy;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
public class WrapperLazyItemHandler implements IInternalItemHandler public class WrapperLazyItemHandler implements IItemHandlerModifiable
{ {
private final Lazy<IItemHandler> sourceHandler; private final Lazy<IItemHandler> sourceHandler;
@@ -74,14 +75,8 @@ public class WrapperLazyItemHandler implements IInternalItemHandler
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
return ItemHandlerUtil.isItemValidForSlot( this.sourceHandler.get(), slot, stack ); return this.sourceHandler.get().isItemValid( slot, stack );
}
@Override
public void markDirty( int slot )
{
ItemHandlerUtil.markDirty( this.sourceHandler.get(), slot );
} }
} }
@@ -23,11 +23,12 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
public class WrapperRangeItemHandler implements IInternalItemHandler public class WrapperRangeItemHandler implements IItemHandlerModifiable
{ {
private final IItemHandler compose; private final IItemHandler compose;
private final int minSlot; private final int minSlot;
@@ -108,22 +109,12 @@ public class WrapperRangeItemHandler implements IInternalItemHandler
} }
@Override @Override
public boolean isItemValidForSlot( int slot, ItemStack stack ) public boolean isItemValid( int slot, ItemStack stack )
{ {
if( this.checkSlot( slot ) ) if( this.checkSlot( slot ) )
{ {
return ItemHandlerUtil.isItemValidForSlot( this.compose, slot + this.minSlot, stack ); return this.compose.isItemValid( slot + this.minSlot, stack );
} }
return false; return false;
} }
@Override
public void markDirty( int slot )
{
if( this.checkSlot( slot ) )
{
ItemHandlerUtil.markDirty( this.compose, slot + this.minSlot );
}
}
} }
@@ -19,6 +19,26 @@
} }
] ]
}, },
{
"name": "appliedenergistics2:fluid_interface",
"conditions": [
{
"type": "appliedenergistics2:features",
"features": [
"fluid_interface"
]
}
],
"ingredient": [
{
"item": "appliedenergistics2:fluid_interface"
},
{
"type": "appliedenergistics2:part",
"part": "part.fluid_interface"
}
]
},
{ {
"name": "appliedenergistics2:knife", "name": "appliedenergistics2:knife",
"conditions": [ "conditions": [
@@ -38,25 +58,6 @@
} }
] ]
}, },
{
"name": "appliedenergistics2:wrench",
"conditions": [
{
"type": "appliedenergistics2:features",
"features": [
"quartz_wrench"
]
}
],
"ingredient": [
{
"item": "appliedenergistics2:certus_quartz_wrench"
},
{
"item": "appliedenergistics2:nether_quartz_wrench"
}
]
},
{ {
"name": "appliedenergistics2:cable", "name": "appliedenergistics2:cable",
"ingredient": [ "ingredient": [
@@ -12,7 +12,7 @@
"key": { "key": {
"b": { "b": {
"type": "appliedenergistics2:part", "type": "appliedenergistics2:part",
"part": "material.engineering_processor" "part": "material.calculation_processor"
}, },
"d": { "d": {
"item": "appliedenergistics2:quartz_glass" "item": "appliedenergistics2:quartz_glass"
@@ -12,7 +12,7 @@
"key": { "key": {
"b": { "b": {
"type": "appliedenergistics2:part", "type": "appliedenergistics2:part",
"part": "material.engineering_processor" "part": "material.calculation_processor"
}, },
"c": { "c": {
"type": "appliedenergistics2:part", "type": "appliedenergistics2:part",
@@ -9,7 +9,7 @@
"item": "minecraft:sticky_piston" "item": "minecraft:sticky_piston"
}, },
{ {
"item": "#appliedenergistics2:interface" "item": "#appliedenergistics2:fluid_interface"
}, },
{ {
"item": "minecraft:piston" "item": "minecraft:piston"
@@ -13,7 +13,8 @@
"ore": "chestWood" "ore": "chestWood"
}, },
{ {
"item": "#appliedenergistics2:wrench" "type": "forge:ore_dict",
"ore": "itemQuartzWrench"
}, },
{ {
"type": "appliedenergistics2:part", "type": "appliedenergistics2:part",