mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Made filter slots be ignored by comparators and stuff
This commit is contained in:
parent
0b1cb80931
commit
142a07f783
47 changed files with 150 additions and 456 deletions
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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){
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)){
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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<String> tooltip, boolean advanced){
|
||||
NonNullList<ItemStack> 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<ItemStack> 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<ItemStack> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ItemStack> 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<ItemStack> 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<ItemStack> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String> tooltip, boolean advanced){
|
||||
NonNullList<ItemStack> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ItemStack> 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<ItemStack> 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<ItemStack> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ItemStack> 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<ItemStack> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ItemStack> 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<ItemStack> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ItemStack> checkList = new ArrayList<ItemStack>();
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue