mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
right clicking while sneaking with an existing item filter on an inventory will add the content to the snapshot
This commit is contained in:
1 parent
173821524d
commit
2fccdaa683
3 files changed
+51
-1
No files matched your search
@@ -62,6 +62,12 @@ item.itemExistingItemFilter.name=Existing Item Filter
|
||||
item.itemExistingItemFilter.tooltip.basic.line1=Upgrade for item conduits
|
||||
item.itemExistingItemFilter.tooltip.detailed.line1=Selects only items already
|
||||
item.itemExistingItemFilter.tooltip.detailed.line2=in the inventory
|
||||
item.itemExistingItemFilter.tooltip.detailed.line3=Right click while sneaking
|
||||
item.itemExistingItemFilter.tooltip.detailed.line4=on an inventory to add the
|
||||
item.itemExistingItemFilter.tooltip.detailed.line5=content to the snapshot
|
||||
|
||||
enderio.item.itemExistingItemFilter.filterUpdated=New items have been added to the snapshot
|
||||
enderio.item.itemExistingItemFilter.filterNotUpdated=The snapshot already covers all items in the inventory
|
||||
|
||||
item.itemModItemFilter.name=Mod Item Filter
|
||||
item.itemModItemFilter.tooltip.basic.line1=Upgrade for item conduits
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import crazypants.enderio.conduit.item.NetworkedInventory;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class ExistingItemFilter implements IItemFilter {
|
||||
|
||||
@@ -114,6 +115,22 @@ public class ExistingItemFilter implements IItemFilter {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean mergeSnapshot(IInventory inventory) {
|
||||
if(snapshot == null) {
|
||||
snapshot = new ArrayList<ItemStack>();
|
||||
}
|
||||
int size = inventory.getSizeInventory();
|
||||
boolean added = false;
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if(stack != null && !isStackInSnapshot(stack)) {
|
||||
snapshot.add(stack);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
return added;
|
||||
}
|
||||
|
||||
public List<ItemStack> getSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ import crazypants.enderio.conduit.item.FilterRegister;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.util.Lang;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade, IResourceTooltipProvider {
|
||||
|
||||
@@ -46,6 +50,29 @@ public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade,
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) {
|
||||
if(world.isRemote) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(player.isSneaking()) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof IInventory) {
|
||||
ExistingItemFilter filter = (ExistingItemFilter)createFilterFromStack(item);
|
||||
if(filter.mergeSnapshot((IInventory)te)) {
|
||||
player.addChatComponentMessage(new ChatComponentText(Lang.localize("item.itemExistingItemFilter.filterUpdated")));
|
||||
} else {
|
||||
player.addChatComponentMessage(new ChatComponentText(Lang.localize("item.itemExistingItemFilter.filterNotUpdated")));
|
||||
}
|
||||
FilterRegister.writeFilterToStack(filter, item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister IIconRegister) {
|
||||
itemIcon = IIconRegister.registerIcon("enderio:existingItemFilter");
|
||||
@@ -58,7 +85,7 @@ public class ItemExistingItemFilter extends Item implements IItemFilterUpgrade,
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
if(FilterRegister.isFilterSet(par1ItemStack)) {
|
||||
if(TooltipAddera.showAdvancedTooltips()) {
|
||||
par3List.add(EnumChatFormatting.ITALIC + Lang.localize("itemConduitFilterUpgrade.configured"));
|
||||
|
||||
Reference in new issue
Block a user