From 142a07f783674a70b1520b3a4c0335d71b138815 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 27 Nov 2016 11:37:55 +0100 Subject: [PATCH] Made filter slots be ignored by comparators and stuff --- .../mod/blocks/BlockAtomicReconstructor.java | 6 - .../mod/blocks/BlockBioReactor.java | 6 - .../mod/blocks/BlockBreaker.java | 6 - .../mod/blocks/BlockCanolaPress.java | 6 - .../mod/blocks/BlockCoalGenerator.java | 6 - .../mod/blocks/BlockCoffeeMachine.java | 6 - .../mod/blocks/BlockCompost.java | 6 - .../mod/blocks/BlockDirectionalBreaker.java | 6 - .../mod/blocks/BlockDisplayStand.java | 6 - .../mod/blocks/BlockDistributorItem.java | 6 - .../mod/blocks/BlockDropper.java | 6 - .../mod/blocks/BlockEmpowerer.java | 6 - .../mod/blocks/BlockEnergizer.java | 6 - .../mod/blocks/BlockFarmer.java | 6 - .../mod/blocks/BlockFeeder.java | 6 - .../mod/blocks/BlockFermentingBarrel.java | 6 - .../mod/blocks/BlockFireworkBox.java | 6 - .../mod/blocks/BlockFluidCollector.java | 6 - .../mod/blocks/BlockFurnaceDouble.java | 6 - .../mod/blocks/BlockGiantChest.java | 9 +- .../mod/blocks/BlockGrinder.java | 6 - .../mod/blocks/BlockInputter.java | 12 -- .../mod/blocks/BlockItemRepairer.java | 6 - .../mod/blocks/BlockLeafGenerator.java | 6 - .../mod/blocks/BlockMiner.java | 6 - .../mod/blocks/BlockOilGenerator.java | 6 - .../mod/blocks/BlockPhantom.java | 8 +- .../mod/blocks/BlockRangedCollector.java | 14 -- .../mod/blocks/BlockSmileyCloud.java | 6 - .../mod/blocks/BlockXPSolidifier.java | 6 - .../mod/blocks/base/BlockContainerBase.java | 17 +- .../mod/inventory/ContainerBag.java | 22 +-- .../mod/inventory/ContainerDrill.java | 4 +- .../mod/inventory/ContainerFilter.java | 4 +- .../mod/inventory/ContainerInputter.java | 2 +- .../ContainerLaserRelayItemWhitelist.java | 2 +- .../inventory/ContainerRangedCollector.java | 6 +- .../mod/inventory/slot/SlotFilter.java | 5 + .../actuallyadditions/mod/items/ItemBag.java | 42 +++-- .../mod/items/ItemDrill.java | 22 +-- .../mod/items/ItemFilter.java | 16 +- .../mod/tile/FilterSettings.java | 44 ++--- .../mod/tile/TileEntityInputter.java | 9 +- .../mod/tile/TileEntityInputterAdvanced.java | 2 +- .../mod/tile/TileEntityInventoryBase.java | 20 +- .../TileEntityLaserRelayItemWhitelist.java | 177 ++---------------- .../mod/tile/TileEntityRangedCollector.java | 13 +- 47 files changed, 150 insertions(+), 456 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java index 2fe108d12..150c9fe1b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockAtomicReconstructor.java @@ -105,12 +105,6 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud return new TileEntityAtomicReconstructor(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override @SideOnly(Side.CLIENT) public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java index 61a447b0c..224c464dc 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBioReactor.java @@ -56,10 +56,4 @@ public class BlockBioReactor extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java index c19f83d53..4bdd714ab 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockBreaker.java @@ -104,10 +104,4 @@ public class BlockBreaker extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java index e28464669..4277158ed 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCanolaPress.java @@ -69,10 +69,4 @@ public class BlockCanolaPress extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java index ade374d80..84aa82a7e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoalGenerator.java @@ -96,12 +96,6 @@ public class BlockCoalGenerator extends BlockContainerBase{ return EnumRarity.RARE; } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public IBlockState getStateFromMeta(int meta){ return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.getHorizontal(meta)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java index ae4e28541..581d33807 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCoffeeMachine.java @@ -81,12 +81,6 @@ public class BlockCoffeeMachine extends BlockContainerBase{ return new TileEntityCoffeeMachine(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java index 88e61fe0a..04deaffb9 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockCompost.java @@ -146,12 +146,6 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{ return new TileEntityCompost(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.UNCOMMON; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java index d0686c357..505c8e167 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDirectionalBreaker.java @@ -100,10 +100,4 @@ public class BlockDirectionalBreaker extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java index a82d4a9fc..f0ded7bff 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDisplayStand.java @@ -95,12 +95,6 @@ public class BlockDisplayStand extends BlockContainerBase{ return false; } - @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state){ - this.dropInventory(worldIn, pos); - super.breakBlock(worldIn, pos, state); - } - @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDistributorItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDistributorItem.java index 4d80ee16c..04fa2a495 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDistributorItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDistributorItem.java @@ -46,12 +46,6 @@ public class BlockDistributorItem extends BlockContainerBase implements IHudDisp return new TileEntityDistributorItem(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos()); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java index 168ecb20c..0a7aabc27 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockDropper.java @@ -99,10 +99,4 @@ public class BlockDropper extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java index ed5451eb3..0ed918afa 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEmpowerer.java @@ -95,12 +95,6 @@ public class BlockEmpowerer extends BlockContainerBase{ return false; } - @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state){ - this.dropInventory(worldIn, pos); - super.breakBlock(worldIn, pos, state); - } - @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java index 6205c9e5b..eb095f656 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockEnergizer.java @@ -70,10 +70,4 @@ public class BlockEnergizer extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java index 50a186547..f2d4b8f9d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFarmer.java @@ -95,10 +95,4 @@ public class BlockFarmer extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java index da0b1393d..8d9ca017d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFeeder.java @@ -58,10 +58,4 @@ public class BlockFeeder extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.UNCOMMON; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java index d49b6a7d4..41094203b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFermentingBarrel.java @@ -51,12 +51,6 @@ public class BlockFermentingBarrel extends BlockContainerBase{ return new TileEntityFermentingBarrel(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){ if(!world.isRemote){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java index 73759b23b..778014cce 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFireworkBox.java @@ -50,10 +50,4 @@ public class BlockFireworkBox extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java index a40956ff0..758fcf2ad 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFluidCollector.java @@ -106,10 +106,4 @@ public class BlockFluidCollector extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockDirectional.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java index 358719c61..2fa274e94 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockFurnaceDouble.java @@ -124,12 +124,6 @@ public class BlockFurnaceDouble extends BlockContainerBase{ return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override protected ItemBlockBase getItemBlock(){ return new TheItemBlock(this); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java index 4fdc9761c..f88f86258 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java @@ -155,15 +155,14 @@ public class BlockGiantChest extends BlockContainerBase{ } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ + public boolean shouldDropInventory(World world, BlockPos pos){ TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityGiantChest){ - if(!ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){ - this.dropInventory(world, pos); + if(ItemUtil.contains(((TileEntityGiantChest)tile).slots, new ItemStack(InitItems.itemCrateKeeper), false)){ + return false; } } - - super.breakBlock(world, pos, state); + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java index f316f1704..51f420f88 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGrinder.java @@ -96,10 +96,4 @@ public class BlockGrinder extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java index 120122221..dd9e3719b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockInputter.java @@ -69,18 +69,6 @@ public class BlockInputter extends BlockContainerBase{ return true; } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - if(!world.isRemote){ - TileEntity aTile = world.getTileEntity(pos); - if(aTile instanceof TileEntityInventoryBase){ - TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile; - this.dropSlotFromInventory(0, tile, world, pos); - } - } - super.breakBlock(world, pos, state); - } - @Override protected ItemBlockBase getItemBlock(){ return new TheItemBlock(this); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java index 2ed22dfb6..b1099c127 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockItemRepairer.java @@ -66,10 +66,4 @@ public class BlockItemRepairer extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java index ffe2ac44d..a002f16df 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockLeafGenerator.java @@ -41,10 +41,4 @@ public class BlockLeafGenerator extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java index da60671e5..d2f75514b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockMiner.java @@ -70,12 +70,6 @@ public class BlockMiner extends BlockContainerBase implements IHudDisplay{ return new TileEntityMiner(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override @SideOnly(Side.CLIENT) public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java index 369265f03..0c7f22b25 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockOilGenerator.java @@ -102,12 +102,6 @@ public class BlockOilGenerator extends BlockContainerBase{ return EnumRarity.RARE; } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public IBlockState getStateFromMeta(int meta){ return this.getDefaultState().withProperty(BlockHorizontal.FACING, EnumFacing.getHorizontal(meta)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java index bf711aee5..19199d851 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockPhantom.java @@ -79,14 +79,10 @@ public class BlockPhantom extends BlockContainerBase implements IHudDisplay{ } @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - if(this.type == Type.PLACER || this.type == Type.BREAKER){ - this.dropInventory(world, pos); - } - super.breakBlock(world, pos, state); + public boolean shouldDropInventory(World world, BlockPos pos){ + return this.type == Type.PLACER || this.type == Type.BREAKER; } - @Override public TileEntity createNewTileEntity(World world, int par2){ switch(this.type){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java index 6d51e8390..3983e1ce2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockRangedCollector.java @@ -58,18 +58,4 @@ public class BlockRangedCollector extends BlockContainerBase{ public EnumRarity getRarity(ItemStack stack){ return EnumRarity.EPIC; } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - if(!world.isRemote){ - TileEntity aTile = world.getTileEntity(pos); - if(aTile instanceof TileEntityRangedCollector){ - TileEntityRangedCollector tile = (TileEntityRangedCollector)aTile; - for(int i = 0; i < TileEntityRangedCollector.WHITELIST_START; i++){ - this.dropSlotFromInventory(i, tile, world, pos); - } - } - } - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java index febd1d212..c91bbb96b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockSmileyCloud.java @@ -86,12 +86,6 @@ public class BlockSmileyCloud extends BlockContainerBase{ return new TileEntitySmileyCloud(); } - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } - @Override public EnumRarity getRarity(ItemStack stack){ return EnumRarity.RARE; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java index 21efecd06..ab9b1b3fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockXPSolidifier.java @@ -96,10 +96,4 @@ public class BlockXPSolidifier extends BlockContainerBase{ public IBlockState withMirror(IBlockState state, Mirror mirror){ return this.withRotation(state, mirror.toRotation(state.getValue(BlockHorizontal.FACING))); } - - @Override - public void breakBlock(World world, BlockPos pos, IBlockState state){ - this.dropInventory(world, pos); - super.breakBlock(world, pos, state); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index 5761dbe9d..2cb2e162c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -82,7 +82,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB return EnumRarity.COMMON; } - public void dropInventory(World world, BlockPos position){ + private void dropInventory(World world, BlockPos position){ if(!world.isRemote){ TileEntity aTile = world.getTileEntity(position); if(aTile instanceof TileEntityInventoryBase){ @@ -96,7 +96,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB } } - public void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){ + private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){ ItemStack stack = tile.getStackInSlot(i); if(StackUtil.isValid(stack)){ float dX = world.rand.nextFloat()*0.8F+0.1F; @@ -286,4 +286,17 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB public EnumBlockRenderType getRenderType(IBlockState state){ return EnumBlockRenderType.MODEL; } + + @Override + public void breakBlock(World world, BlockPos pos, IBlockState state){ + if(this.shouldDropInventory(world, pos)){ + this.dropInventory(world, pos); + } + + super.breakBlock(world, pos, state); + } + + public boolean shouldDropInventory(World world, BlockPos pos){ + return true; + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java index 6e95bfc8e..65060ca01 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerBag.java @@ -32,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerBag extends Container implements IButtonReactor{ - public final FilterSettings filter = new FilterSettings(0, 4, false, true, false, false, 0, -1000); + public final FilterSettings filter = new FilterSettings(4, false, true, false, false, 0, -1000); private final InventoryBag bagInventory; private final InventoryPlayer inventory; private final boolean isVoid; @@ -45,24 +45,24 @@ public class ContainerBag extends Container implements IButtonReactor{ this.isVoid = isVoid; for(int i = 0; i < 4; i++){ - this.addSlotToContainer(new SlotFilter(this.bagInventory, i, 155, 10+i*18)); + this.addSlotToContainer(new SlotFilter(this.filter, i, 155, 10+i*18)); } if(this.isVoid){ - this.addSlotToContainer(new SlotDeletion(this.bagInventory, 4, 64, 65){ + this.addSlotToContainer(new SlotDeletion(this.bagInventory, 0, 64, 65){ @Override public boolean isItemValid(ItemStack stack){ - return ContainerBag.this.filter.check(stack, ContainerBag.this.bagInventory.slots); + return ContainerBag.this.filter.check(stack); } }); } else{ for(int i = 0; i < 4; i++){ for(int j = 0; j < 7; j++){ - this.addSlotToContainer(new Slot(this.bagInventory, j+i*7+4, 10+j*18, 10+i*18){ + this.addSlotToContainer(new Slot(this.bagInventory, j+i*7, 10+j*18, 10+i*18){ @Override public boolean isItemValid(ItemStack stack){ - return ContainerBag.this.filter.check(stack, ContainerBag.this.bagInventory.slots); + return ContainerBag.this.filter.check(stack); } }); } @@ -85,7 +85,7 @@ public class ContainerBag extends Container implements IButtonReactor{ ItemStack stack = inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag){ - ItemDrill.loadSlotsFromNBT(this.bagInventory.slots, inventory.getCurrentItem()); + ItemDrill.loadSlotsFromNBT(this.bagInventory, inventory.getCurrentItem()); if(stack.hasTagCompound()){ NBTTagCompound compound = stack.getTagCompound(); this.filter.readFromNBT(compound, "Filter"); @@ -95,7 +95,7 @@ public class ContainerBag extends Container implements IButtonReactor{ } public static int getSlotAmount(boolean isVoid){ - return isVoid ? 5 : 32; + return isVoid ? 1 : 28; } @Override @@ -141,7 +141,7 @@ public class ContainerBag extends Container implements IButtonReactor{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - int inventoryStart = this.bagInventory.slots.size(); + int inventoryStart = this.bagInventory.slots.size()+4; int inventoryEnd = inventoryStart+26; int hotbarStart = inventoryEnd+1; int hotbarEnd = hotbarStart+8; @@ -155,7 +155,7 @@ public class ContainerBag extends Container implements IButtonReactor{ //Other Slots in Inventory excluded if(slot >= inventoryStart){ //Shift from Inventory - if(this.isVoid || !this.filter.check(newStack, this.bagInventory.slots) || !this.mergeItemStack(newStack, 4, 32, false)){ + if(this.isVoid || !this.filter.check(newStack) || !this.mergeItemStack(newStack, 4, 32, false)){ if(slot >= inventoryStart && slot <= inventoryEnd){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ return StackUtil.getNull(); @@ -207,7 +207,7 @@ public class ContainerBag extends Container implements IButtonReactor{ public void onContainerClosed(EntityPlayer player){ ItemStack stack = this.inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag){ - ItemDrill.writeSlotsToNBT(this.bagInventory.slots, this.inventory.getCurrentItem()); + ItemDrill.writeSlotsToNBT(this.bagInventory, this.inventory.getCurrentItem()); NBTTagCompound compound = stack.getTagCompound(); this.filter.writeToNBT(compound, "Filter"); compound.setBoolean("AutoInsert", this.autoInsert); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java index 73f6e433a..246544f15 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerDrill.java @@ -61,7 +61,7 @@ public class ContainerDrill extends Container{ ItemStack stack = inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){ - ItemDrill.loadSlotsFromNBT(this.drillInventory.slots, inventory.getCurrentItem()); + ItemDrill.loadSlotsFromNBT(this.drillInventory, inventory.getCurrentItem()); } } @@ -132,7 +132,7 @@ public class ContainerDrill extends Container{ public void onContainerClosed(EntityPlayer player){ ItemStack stack = this.inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){ - ItemDrill.writeSlotsToNBT(this.drillInventory.slots, this.inventory.getCurrentItem()); + ItemDrill.writeSlotsToNBT(this.drillInventory, this.inventory.getCurrentItem()); } super.onContainerClosed(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java index 82b6905d7..892ccc38d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerFilter.java @@ -59,7 +59,7 @@ public class ContainerFilter extends Container{ ItemStack stack = inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter){ - ItemDrill.loadSlotsFromNBT(this.filterInventory.slots, inventory.getCurrentItem()); + ItemDrill.loadSlotsFromNBT(this.filterInventory, inventory.getCurrentItem()); } } @@ -128,7 +128,7 @@ public class ContainerFilter extends Container{ public void onContainerClosed(EntityPlayer player){ ItemStack stack = this.inventory.getCurrentItem(); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter){ - ItemDrill.writeSlotsToNBT(this.filterInventory.slots, this.inventory.getCurrentItem()); + ItemDrill.writeSlotsToNBT(this.filterInventory, this.inventory.getCurrentItem()); } super.onContainerClosed(player); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java index 2a41e2291..06bbd4096 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerInputter.java @@ -39,7 +39,7 @@ public class ContainerInputter extends Container{ for(int i = 0; i < 2; i++){ for(int x = 0; x < 3; x++){ for(int y = 0; y < 4; y++){ - this.addSlotToContainer(new SlotFilter(this.tileInputter, 1+y+x*4+i*12, 20+i*84+x*18, 6+y*18)); + this.addSlotToContainer(new SlotFilter(i == 0 ? this.tileInputter.leftFilter : this.tileInputter.rightFilter, y+x*4, 20+i*84+x*18, 6+y*18)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java index a842f51d0..940acb1d5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerLaserRelayItemWhitelist.java @@ -32,7 +32,7 @@ public class ContainerLaserRelayItemWhitelist extends Container{ for(int i = 0; i < 2; i++){ for(int x = 0; x < 3; x++){ for(int y = 0; y < 4; y++){ - this.addSlotToContainer(new SlotFilter(this.tile.filterInventory, y+x*4+i*12, 20+i*84+x*18, 6+y*18)); + this.addSlotToContainer(new SlotFilter(i == 0 ? this.tile.leftFilter : this.tile.rightFilter, y+x*4, 20+i*84+x*18, 6+y*18)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java index 931fea385..b0108fc96 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerRangedCollector.java @@ -36,7 +36,7 @@ public class ContainerRangedCollector extends Container{ } for(int i = 0; i < 4; i++){ for(int j = 0; j < 3; j++){ - this.addSlotToContainer(new SlotFilter(this.collector, 6+j+i*3, 20+j*18, 6+i*18)); + this.addSlotToContainer(new SlotFilter(this.collector.filter, j+i*3, 20+j*18, 6+i*18)); } } @@ -52,7 +52,7 @@ public class ContainerRangedCollector extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - int inventoryStart = 18; + int inventoryStart = 6; int inventoryEnd = inventoryStart+26; int hotbarStart = inventoryEnd+1; int hotbarEnd = hotbarStart+8; @@ -66,7 +66,7 @@ public class ContainerRangedCollector extends Container{ //Other Slots in Inventory excluded if(slot >= inventoryStart){ //Shift from Inventory - if(!this.mergeItemStack(newStack, 0, TileEntityRangedCollector.WHITELIST_START, false)){ + if(!this.mergeItemStack(newStack, 0, 6, false)){ // if(slot >= inventoryStart && slot <= inventoryEnd){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java index 4bc3bcfd8..5adf000e0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/slot/SlotFilter.java @@ -10,6 +10,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.slot; +import de.ellpeck.actuallyadditions.mod.tile.FilterSettings; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -22,6 +23,10 @@ public class SlotFilter extends Slot{ super(inv, slot, x, y); } + public SlotFilter(FilterSettings inv, int slot, int x, int y){ + this(inv.filterInventory, slot, x, y); + } + /** * Gets called when the Filter Slot is clicked * Needs to be called in slotClick() in the Container! diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java index f2b2bcf25..adbf7ee99 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBag.java @@ -19,6 +19,8 @@ import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -51,14 +53,14 @@ public class ItemBag extends ItemBase{ @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced){ - NonNullList slots = StackUtil.createSlots(ContainerBag.getSlotAmount(this.isVoid)); - ItemDrill.loadSlotsFromNBT(slots, stack); + IInventory inv = new InventoryBasic("Bag", false, ContainerBag.getSlotAmount(this.isVoid)); + ItemDrill.loadSlotsFromNBT(inv, stack); - int slotsTotal = slots.size(); + int slotsTotal = inv.getSizeInventory(); int slotsFilled = 0; - for(ItemStack slotStack : slots){ - if(StackUtil.isValid(slotStack)){ + for(int i = 0; i < inv.getSizeInventory(); i++){ + if(StackUtil.isValid(inv.getStackInSlot(i))){ slotsFilled++; } } @@ -82,31 +84,31 @@ public class ItemBag extends ItemBase{ boolean changed = false; boolean isVoid = ((ItemBag)invStack.getItem()).isVoid; - NonNullList inventory = StackUtil.createSlots(ContainerBag.getSlotAmount(isVoid)); - ItemDrill.loadSlotsFromNBT(inventory, invStack); + IInventory inv = new InventoryBasic("Bag", false, ContainerBag.getSlotAmount(isVoid)); + ItemDrill.loadSlotsFromNBT(inv, invStack); - FilterSettings filter = new FilterSettings(0, 4, false, false, false, false, 0, 0); + FilterSettings filter = new FilterSettings(4, false, false, false, false, 0, 0); filter.readFromNBT(invStack.getTagCompound(), "Filter"); - if(filter.check(stack, inventory)){ + if(filter.check(stack)){ if(isVoid){ stack = StackUtil.setStackSize(stack, 0); changed = true; } else{ - for(int j = 4; j < inventory.size(); j++){ - ItemStack bagStack = inventory.get(j); + for(int j = 0; j < inv.getSizeInventory(); j++){ + ItemStack bagStack = inv.getStackInSlot(j); if(StackUtil.isValid(bagStack)){ if(ItemUtil.canBeStacked(bagStack, stack)){ int maxTransfer = Math.min(StackUtil.getStackSize(stack), stack.getMaxStackSize()-StackUtil.getStackSize(bagStack)); if(maxTransfer > 0){ - inventory.set(j, StackUtil.addStackSize(bagStack, maxTransfer)); + inv.setInventorySlotContents(j, StackUtil.addStackSize(bagStack, maxTransfer)); stack = StackUtil.addStackSize(stack, -maxTransfer); changed = true; } } } else{ - inventory.set(j, stack.copy()); + inv.setInventorySlotContents(j, stack.copy()); stack = StackUtil.setStackSize(stack, 0); changed = true; } @@ -120,7 +122,7 @@ public class ItemBag extends ItemBase{ if(changed){ if(!isVoid){ - ItemDrill.writeSlotsToNBT(inventory, invStack); + ItemDrill.writeSlotsToNBT(inv, invStack); } event.setResult(Event.Result.ALLOW); } @@ -149,16 +151,16 @@ public class ItemBag extends ItemBase{ if(handler != null){ boolean changed = false; - NonNullList inventory = StackUtil.createSlots(ContainerBag.getSlotAmount(this.isVoid)); - ItemDrill.loadSlotsFromNBT(inventory, stack); + IInventory inv = new InventoryBasic("Bag", false, ContainerBag.getSlotAmount(this.isVoid)); + ItemDrill.loadSlotsFromNBT(inv, stack); - for(int j = 4; j < inventory.size(); j++){ - ItemStack invStack = inventory.get(j); + for(int j = 4; j < inv.getSizeInventory(); j++){ + ItemStack invStack = inv.getStackInSlot(j); if(StackUtil.isValid(invStack)){ for(int i = 0; i < handler.getSlots(); i++){ ItemStack remain = handler.insertItem(i, invStack, false); if(!ItemStack.areItemStacksEqual(remain, invStack)){ - inventory.set(j, StackUtil.validateCopy(remain)); + inv.setInventorySlotContents(j, StackUtil.validateCopy(remain)); changed = true; if(!StackUtil.isValid(remain)){ @@ -170,7 +172,7 @@ public class ItemBag extends ItemBase{ } if(changed){ - ItemDrill.writeSlotsToNBT(inventory, stack); + ItemDrill.writeSlotsToNBT(inv, stack); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index 398dbf643..30f44665f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -34,6 +34,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Enchantments; import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -46,7 +48,6 @@ import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import javax.annotation.Nullable; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -76,7 +77,7 @@ public class ItemDrill extends ItemEnergy{ * * @param stack The Drill */ - public static void loadSlotsFromNBT(NonNullList slots, ItemStack stack){ + public static void loadSlotsFromNBT(IInventory slots, ItemStack stack){ NBTTagCompound compound = stack.getTagCompound(); if(compound != null){ TileEntityInventoryBase.loadSlots(slots, compound); @@ -89,7 +90,7 @@ public class ItemDrill extends ItemEnergy{ * @param slots The Slots * @param stack The Drill */ - public static void writeSlotsToNBT(NonNullList slots, ItemStack stack){ + public static void writeSlotsToNBT(IInventory slots, ItemStack stack){ NBTTagCompound compound = stack.getTagCompound(); if(compound == null){ compound = new NBTTagCompound(); @@ -149,14 +150,13 @@ public class ItemDrill extends ItemEnergy{ return StackUtil.getNull(); } - NonNullList slots = StackUtil.createSlots(ContainerDrill.SLOT_AMOUNT); - loadSlotsFromNBT(slots, stack); - if(slots != null && slots.size() > 0){ - for(ItemStack slotStack : slots){ - if(StackUtil.isValid(slotStack) && slotStack.getItem() instanceof ItemDrillUpgrade){ - if(((ItemDrillUpgrade)slotStack.getItem()).type == upgrade){ - return slotStack; - } + InventoryBasic inv = new InventoryBasic("Drill", false, ContainerDrill.SLOT_AMOUNT); + loadSlotsFromNBT(inv, stack); + for(int i = 0; i < inv.getSizeInventory(); i++){ + ItemStack slotStack = inv.getStackInSlot(i); + if(StackUtil.isValid(slotStack) && slotStack.getItem() instanceof ItemDrillUpgrade){ + if(((ItemDrillUpgrade)slotStack.getItem()).type == upgrade){ + return slotStack; } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java index 4a9ed6cc5..ddb86574c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFilter.java @@ -16,12 +16,13 @@ import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; import net.minecraft.world.World; import java.util.List; @@ -48,13 +49,12 @@ public class ItemFilter extends ItemBase{ @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced){ - NonNullList slots = StackUtil.createSlots(ContainerFilter.SLOT_AMOUNT); - ItemDrill.loadSlotsFromNBT(slots, stack); - if(slots != null && slots.size() > 0){ - for(ItemStack slot : slots){ - if(StackUtil.isValid(slot)){ - tooltip.add(slot.getItem().getItemStackDisplayName(slot)); - } + IInventory inv = new InventoryBasic("Filter", false, ContainerFilter.SLOT_AMOUNT); + ItemDrill.loadSlotsFromNBT(inv, stack); + for(int i = 0; i < inv.getSizeInventory(); i++){ + ItemStack slot = inv.getStackInSlot(i); + if(StackUtil.isValid(slot)){ + tooltip.add(slot.getItem().getItemStackDisplayName(slot)); } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java index 8d5724046..d8d0e2f0e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/FilterSettings.java @@ -14,10 +14,11 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter; import de.ellpeck.actuallyadditions.mod.items.ItemDrill; import de.ellpeck.actuallyadditions.mod.items.ItemFilter; import de.ellpeck.actuallyadditions.mod.util.StackUtil; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.ArrayUtils; @@ -30,9 +31,6 @@ public class FilterSettings{ public final int oredictButtonId; public final int modButtonId; - public final int startSlot; - public final int endSlot; - public boolean isWhitelist; public boolean respectMeta; public boolean respectNBT; @@ -45,9 +43,10 @@ public class FilterSettings{ private boolean lastRespectMod; private int lastRecpectOredict; - public FilterSettings(int startSlot, int endSlot, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, boolean defaultRespectMod, int defaultRespectOredict, int buttonIdStart){ - this.startSlot = startSlot; - this.endSlot = endSlot; + public final IInventory filterInventory; + + public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, boolean defaultRespectMod, int defaultRespectOredict, int buttonIdStart){ + this.filterInventory = new InventoryBasic("Filter", false, slots); this.isWhitelist = defaultWhitelist; this.respectMeta = defaultRespectMeta; @@ -62,21 +61,22 @@ public class FilterSettings{ this.modButtonId = buttonIdStart+4; } - public static boolean check(ItemStack stack, NonNullList slots, int startSlot, int endSlot, boolean whitelist, boolean meta, boolean nbt, boolean mod, int oredict){ + public static boolean check(ItemStack stack, IInventory filter, boolean whitelist, boolean meta, boolean nbt, boolean mod, int oredict){ if(StackUtil.isValid(stack)){ - for(int i = startSlot; i < endSlot; i++){ - if(StackUtil.isValid(slots.get(i))){ - if(areEqualEnough(slots.get(i), stack, meta, nbt, mod, oredict)){ + for(int i = 0; i < filter.getSizeInventory(); i++){ + ItemStack slot = filter.getStackInSlot(i); + + if(StackUtil.isValid(slot)){ + if(areEqualEnough(slot, stack, meta, nbt, mod, oredict)){ return whitelist; } - else if(slots.get(i).getItem() instanceof ItemFilter){ - NonNullList filterSlots = StackUtil.createSlots(ContainerFilter.SLOT_AMOUNT); - ItemDrill.loadSlotsFromNBT(filterSlots, slots.get(i)); - if(filterSlots != null && filterSlots.size() > 0){ - for(ItemStack filterSlot : filterSlots){ - if(StackUtil.isValid(filterSlot) && areEqualEnough(filterSlot, stack, meta, nbt, mod, oredict)){ - return whitelist; - } + else if(slot.getItem() instanceof ItemFilter){ + IInventory inv = new InventoryBasic("Filter", false, ContainerFilter.SLOT_AMOUNT); + ItemDrill.loadSlotsFromNBT(inv, slot); + for(int k = 0; k < inv.getSizeInventory(); k++){ + ItemStack filterSlot = inv.getStackInSlot(k); + if(StackUtil.isValid(filterSlot) && areEqualEnough(filterSlot, stack, meta, nbt, mod, oredict)){ + return whitelist; } } } @@ -158,6 +158,7 @@ public class FilterSettings{ compound.setBoolean("NBT", this.respectNBT); compound.setBoolean("Mod", this.respectMod); compound.setInteger("Oredict", this.respectOredict); + TileEntityInventoryBase.saveSlots(this.filterInventory, compound); tag.setTag(name, compound); } @@ -168,6 +169,7 @@ public class FilterSettings{ this.respectNBT = compound.getBoolean("NBT"); this.respectMod = compound.getBoolean("Mod"); this.respectOredict = compound.getInteger("Oredict"); + TileEntityInventoryBase.loadSlots(this.filterInventory, compound); } public boolean needsUpdateSend(){ @@ -205,7 +207,7 @@ public class FilterSettings{ } } - public boolean check(ItemStack stack, NonNullList slots){ - return check(stack, slots, this.startSlot, this.endSlot, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectMod, this.respectOredict); + public boolean check(ItemStack stack){ + return check(stack, this.filterInventory, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectMod, this.respectOredict); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java index 24e2cb3c7..5ddb356f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java @@ -21,13 +21,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor{ - public static final int PUT_FILTER_START = 13; - public static final int PULL_FILTER_START = 1; public static final int OKAY_BUTTON_ID = 133; public int sideToPut = -1; public int slotToPutStart; @@ -38,8 +37,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt public int slotToPullEnd; public TileEntity placeToPull; public boolean isAdvanced; - public FilterSettings leftFilter = new FilterSettings(PULL_FILTER_START, PULL_FILTER_START+12, true, true, false, false, 0, -1000); - public FilterSettings rightFilter = new FilterSettings(PUT_FILTER_START, PUT_FILTER_START+12, true, true, false, false, 0, -2000); + public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); + public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); private int lastPutSide; private int lastPutStart; private int lastPutEnd; @@ -127,7 +126,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt * @return If the Item is filtered correctly */ private boolean checkBothFilters(ItemStack stack, boolean output){ - return !this.isAdvanced || (output ? this.rightFilter : this.leftFilter).check(stack, this.slots); + return !this.isAdvanced || (output ? this.rightFilter : this.leftFilter).check(stack); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java index f6f441c7c..954906e58 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputterAdvanced.java @@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile; public class TileEntityInputterAdvanced extends TileEntityInputter{ public TileEntityInputterAdvanced(){ - super(25, "inputterAdvanced"); + super(1, "inputterAdvanced"); this.isAdvanced = true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index 373942dab..6d8286277 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -37,10 +38,11 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } } - public static void saveSlots(NonNullList slots, NBTTagCompound compound){ - if(slots != null && slots.size() > 0){ + public static void saveSlots(IInventory slots, NBTTagCompound compound){ + if(slots != null && slots.getSizeInventory() > 0){ NBTTagList tagList = new NBTTagList(); - for(ItemStack slot : slots){ + for(int i = 0; i < slots.getSizeInventory(); i++){ + ItemStack slot = slots.getStackInSlot(i); NBTTagCompound tagCompound = new NBTTagCompound(); if(StackUtil.isValid(slot)){ slot.writeToNBT(tagCompound); @@ -51,12 +53,12 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } } - public static void loadSlots(NonNullList slots, NBTTagCompound compound){ - if(slots != null && slots.size() > 0){ + public static void loadSlots(IInventory slots, NBTTagCompound compound){ + if(slots != null && slots.getSizeInventory() > 0){ NBTTagList tagList = compound.getTagList("Items", 10); - for(int i = 0; i < slots.size(); i++){ + for(int i = 0; i < slots.getSizeInventory(); i++){ NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - slots.set(i, tagCompound != null && tagCompound.hasKey("id") ? new ItemStack(tagCompound) : StackUtil.getNull()); + slots.setInventorySlotContents(i, tagCompound != null && tagCompound.hasKey("id") ? new ItemStack(tagCompound) : StackUtil.getNull()); } } } @@ -71,7 +73,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); if(type == NBTType.SAVE_TILE || (type == NBTType.SYNC && this.shouldSyncSlots())){ - saveSlots(this.slots, compound); + saveSlots(this, compound); } } @@ -83,7 +85,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); if(type == NBTType.SAVE_TILE || (type == NBTType.SYNC && this.shouldSyncSlots())){ - loadSlots(this.slots, compound); + loadSlots(this, compound); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index aecaca6c3..d6cbb1a4a 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -17,152 +17,18 @@ import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.InventoryBasic; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.items.IItemHandler; public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{ - public final IInventory filterInventory; - public FilterSettings leftFilter = new FilterSettings(0, 12, true, true, false, false, 0, -1000); - public FilterSettings rightFilter = new FilterSettings(12, 24, true, true, false, false, 0, -2000); - private NonNullList slots = StackUtil.createSlots(24); + public FilterSettings leftFilter = new FilterSettings(12, true, true, false, false, 0, -1000); + public FilterSettings rightFilter = new FilterSettings(12, true, true, false, false, 0, -2000); public TileEntityLaserRelayItemWhitelist(){ super("laserRelayItemWhitelist"); - - this.filterInventory = new IInventory(){ - - private TileEntityLaserRelayItemWhitelist tile; - - private IInventory setTile(TileEntityLaserRelayItemWhitelist tile){ - this.tile = tile; - return this; - } - - - @Override - public String getName(){ - return this.tile.name; - } - - @Override - public int getInventoryStackLimit(){ - return 64; - } - - @Override - public void markDirty(){ - - } - - @Override - public boolean isUsableByPlayer(EntityPlayer player){ - return this.tile.canPlayerUse(player); - } - - @Override - public void openInventory(EntityPlayer player){ - - } - - @Override - public void closeInventory(EntityPlayer player){ - - } - - @Override - public int getField(int id){ - return 0; - } - - @Override - public void setField(int id, int value){ - - } - - @Override - public int getFieldCount(){ - return 0; - } - - @Override - public void clear(){ - this.tile.slots.clear(); - } - - @Override - public void setInventorySlotContents(int i, ItemStack stack){ - this.tile.slots.set(i, stack); - this.markDirty(); - } - - @Override - public int getSizeInventory(){ - return this.tile.slots.size(); - } - - @Override - public boolean isEmpty(){ - return StackUtil.isIInvEmpty(this.tile.slots); - } - - @Override - public ItemStack getStackInSlot(int i){ - if(i < this.getSizeInventory()){ - return this.tile.slots.get(i); - } - return StackUtil.getNull(); - } - - @Override - public ItemStack decrStackSize(int i, int j){ - if(StackUtil.isValid(this.tile.slots.get(i))){ - ItemStack stackAt; - if(StackUtil.getStackSize(this.tile.slots.get(i)) <= j){ - stackAt = this.tile.slots.get(i); - this.tile.slots.set(i, StackUtil.getNull()); - this.markDirty(); - return stackAt; - } - else{ - stackAt = this.tile.slots.get(i).splitStack(j); - if(StackUtil.getStackSize(this.tile.slots.get(i)) <= 0){ - this.tile.slots.set(i, StackUtil.getNull()); - } - this.markDirty(); - return stackAt; - } - } - return StackUtil.getNull(); - } - - @Override - public ItemStack removeStackFromSlot(int index){ - ItemStack stack = this.tile.slots.get(index); - this.tile.slots.set(index, StackUtil.getNull()); - return stack; - } - - @Override - public boolean hasCustomName(){ - return false; - } - - - @Override - public ITextComponent getDisplayName(){ - return new TextComponentTranslation(this.getName()); - } - - @Override - public boolean isItemValidForSlot(int index, ItemStack stack){ - return false; - } - }.setTile(this); } @Override @@ -172,15 +38,12 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem @Override public boolean isWhitelisted(ItemStack stack, boolean output){ - return output ? this.rightFilter.check(stack, this.slots) : this.leftFilter.check(stack, this.slots); + return output ? this.rightFilter.check(stack) : this.leftFilter.check(stack); } @Override public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); - if(type == NBTType.SAVE_TILE){ - TileEntityInventoryBase.saveSlots(this.slots, compound); - } if(type != NBTType.SAVE_BLOCK){ this.leftFilter.writeToNBT(compound, "LeftFilter"); this.rightFilter.writeToNBT(compound, "RightFilter"); @@ -190,9 +53,6 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); - if(type == NBTType.SAVE_TILE){ - TileEntityInventoryBase.loadSlots(this.slots, compound); - } if(type != NBTType.SAVE_BLOCK){ this.leftFilter.readFromNBT(compound, "LeftFilter"); this.rightFilter.readFromNBT(compound, "RightFilter"); @@ -220,32 +80,31 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem ItemStack copy = stack.copy(); copy = StackUtil.setStackSize(copy, 1); - if(!FilterSettings.check(copy, this.slots, usedSettings.startSlot, usedSettings.endSlot, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){ - for(int k = usedSettings.startSlot; k < usedSettings.endSlot; k++){ - if(StackUtil.isValid(this.slots.get(k))){ - if(this.slots.get(k).getItem() instanceof ItemFilter){ - NonNullList filterSlots = StackUtil.createSlots(ContainerFilter.SLOT_AMOUNT); - ItemDrill.loadSlotsFromNBT(filterSlots, this.slots.get(k)); + if(!FilterSettings.check(copy, usedSettings.filterInventory, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectMod, usedSettings.respectOredict)){ + for(int k = 0; k < usedSettings.filterInventory.getSizeInventory(); k++){ + ItemStack slot = usedSettings.filterInventory.getStackInSlot(k); + if(StackUtil.isValid(slot)){ + if(slot.getItem() instanceof ItemFilter){ + IInventory inv = new InventoryBasic("Filter", false, ContainerFilter.SLOT_AMOUNT); + ItemDrill.loadSlotsFromNBT(inv, slot); boolean did = false; - if(filterSlots != null && filterSlots.size() > 0){ - for(int j = 0; j < filterSlots.size(); j++){ - if(!StackUtil.isValid(filterSlots.get(j))){ - filterSlots.set(j, copy); - did = true; - break; - } + for(int j = 0; j < inv.getSizeInventory(); j++){ + if(!StackUtil.isValid(inv.getStackInSlot(j))){ + inv.setInventorySlotContents(j, copy); + did = true; + break; } } if(did){ - ItemDrill.writeSlotsToNBT(filterSlots, this.slots.get(k)); + ItemDrill.writeSlotsToNBT(inv, slot); break; } } } else{ - this.slots.set(k, copy); + usedSettings.filterInventory.setInventorySlotContents(k, copy); break; } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index fb20fe319..ec41bc70c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -26,12 +26,11 @@ import java.util.ArrayList; public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor{ - public static final int WHITELIST_START = 6; public static final int RANGE = 6; - public FilterSettings filter = new FilterSettings(WHITELIST_START, WHITELIST_START+12, true, true, false, false, 0, -1000); + public FilterSettings filter = new FilterSettings(12, true, true, false, false, 0, -1000); public TileEntityRangedCollector(){ - super(18, "rangedCollector"); + super(6, "rangedCollector"); } @Override @@ -60,11 +59,11 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement for(EntityItem item : items){ if(!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getEntityItem())){ ItemStack toAdd = item.getEntityItem().copy(); - if(this.filter.check(toAdd, this.slots)){ + if(this.filter.check(toAdd)){ ArrayList checkList = new ArrayList(); checkList.add(toAdd); - if(WorldUtil.addToInventory(this, 0, WHITELIST_START, checkList, EnumFacing.UP, false, true)){ - WorldUtil.addToInventory(this, 0, WHITELIST_START, checkList, EnumFacing.UP, true, true); + if(WorldUtil.addToInventory(this, checkList, EnumFacing.UP, false, true)){ + WorldUtil.addToInventory(this, checkList, EnumFacing.UP, true, true); ((WorldServer)this.world).spawnParticle(EnumParticleTypes.CLOUD, false, item.posX, item.posY+0.45F, item.posZ, 5, 0, 0, 0, 0.03D); @@ -94,7 +93,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement @Override public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){ - return slot < WHITELIST_START; + return true; } @Override