Use IItemHandler instead of IInventory internally (#2971)

* Use IItemHandler instead of IInventory internally
This commit is contained in:
fscan
2017-07-28 22:04:32 +02:00
committed by yueh
parent c077840988
commit 52d28fabe3
156 changed files with 2410 additions and 4604 deletions
@@ -34,8 +34,6 @@ import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -48,6 +46,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.implementations.items.IMemoryCard;
import appeng.api.implementations.items.MemoryCardMessages;
@@ -56,6 +55,7 @@ import appeng.api.util.AEColor;
import appeng.api.util.IOrientable;
import appeng.block.networking.BlockCableBus;
import appeng.helpers.ICustomCollision;
import appeng.tile.AEBaseInvTile;
import appeng.tile.AEBaseTile;
import appeng.tile.networking.TileCableBus;
import appeng.tile.storage.TileSkyChest;
@@ -115,7 +115,7 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
public void setTileEntity( final Class<? extends AEBaseTile> c )
{
this.tileEntityType = c;
this.setInventory( IInventory.class.isAssignableFrom( c ) );
this.setInventory( AEBaseInvTile.class.isAssignableFrom( c ) );
}
@Override
@@ -241,9 +241,13 @@ public abstract class AEBaseTileBlock extends AEBaseBlock implements ITileEntity
public int getComparatorInputOverride( IBlockState state, final World w, final BlockPos pos )
{
final TileEntity te = this.getTileEntity( w, pos );
if( te instanceof IInventory )
if( te instanceof AEBaseInvTile )
{
return Container.calcRedstoneFromInventory( (IInventory) te );
AEBaseInvTile invTile = (AEBaseInvTile) te;
if( invTile.getInternalInventory().getSlots() > 0 )
{
return ItemHandlerHelper.calcRedstoneFromInventory( invTile.getInternalInventory() );
}
}
return 0;
}
@@ -18,6 +18,7 @@
package appeng.block.crafting;
public class BlockCraftingStorage extends BlockCraftingUnit
{
@@ -109,7 +109,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
{
final TileCharger tc = (TileCharger) tile;
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getStackInSlot( 0 ) ) )
if( AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( tc.getInternalInventory().getStackInSlot( 0 ) ) )
{
final double xOff = 0.0;
final double yOff = 0.0;
@@ -201,7 +201,7 @@ public class BlockCharger extends AEBaseTileBlock implements ICustomCollision
{
Matrix4f transform = new Matrix4f();
transform.translate( new Vector3f( 0.5f, 0.4f, 0.5f ) );
return new ImmutablePair<>( tile.getStackInSlot( 0 ), transform );
return new ImmutablePair<>( tile.getInternalInventory().getStackInSlot( 0 ), transform );
}
}
@@ -18,6 +18,7 @@
package appeng.block.networking;
public class BlockDenseEnergyCell extends BlockEnergyCell
{
@@ -108,7 +108,7 @@ public class BlockChest extends AEBaseTileBlock
}
else
{
final ItemStack cell = tg.getStackInSlot( 1 );
final ItemStack cell = tg.getCell();
if( !cell.isEmpty() )
{
final ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell );