2016-06-07 23:17:06 +02:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-06-07 23:17:06 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
2018-06-23 01:39:30 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
2016-11-16 20:31:16 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2017-06-17 00:48:49 +02:00
|
|
|
import net.minecraft.client.util.ITooltipFlag;
|
2016-06-07 23:17:06 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
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.world.World;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class ItemFilter extends ItemBase {
|
2016-06-07 23:17:06 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public ItemFilter(String name) {
|
2016-06-07 23:17:06 +02:00
|
|
|
super(name);
|
|
|
|
this.setMaxStackSize(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public EnumRarity getRarity(ItemStack stack) {
|
2016-06-07 23:17:06 +02:00
|
|
|
return EnumRarity.UNCOMMON;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
|
|
|
if (!world.isRemote && hand == EnumHand.MAIN_HAND) {
|
|
|
|
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.FILTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ);
|
2016-06-07 23:17:06 +02:00
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
2016-06-07 23:17:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
2017-06-17 00:48:49 +02:00
|
|
|
super.addInformation(stack, playerIn, tooltip, advanced);
|
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT);
|
2016-11-27 11:37:55 +01:00
|
|
|
ItemDrill.loadSlotsFromNBT(inv, stack);
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int i = 0; i < inv.getSlots(); i++) {
|
2016-11-27 11:37:55 +01:00
|
|
|
ItemStack slot = inv.getStackInSlot(i);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(slot)) {
|
2016-11-27 11:37:55 +01:00
|
|
|
tooltip.add(slot.getItem().getItemStackDisplayName(slot));
|
2016-06-07 23:17:06 +02:00
|
|
|
}
|
2017-06-29 18:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-07 23:17:06 +02:00
|
|
|
}
|