use of crazypants.enderio.base.filter.filters.ExistingItemFilter in project EnderIO by SleepyTrousers.
the class ItemExistingItemFilter method onItemUse.
@Override
@Nonnull
public EnumActionResult onItemUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return EnumActionResult.SUCCESS;
}
if (player.isSneaking()) {
IItemHandler externalInventory = ItemTools.getExternalInventory(world, pos, side);
if (externalInventory != null) {
ItemStack heldItem = player.getHeldItem(hand);
ExistingItemFilter filter = (ExistingItemFilter) createFilterFromStack(heldItem);
player.sendStatusMessage(filter.mergeSnapshot(externalInventory) ? Lang.ITEM_FILTER_UPDATED.toChatServer() : Lang.ITEM_FILTER_NOTUPDATED.toChatServer(), true);
FilterRegistry.writeFilterToStack(filter, heldItem);
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
use of crazypants.enderio.base.filter.filters.ExistingItemFilter in project EnderIO by SleepyTrousers.
the class ItemExistingItemFilter method createFilterFromStack.
@Override
public IItemFilter createFilterFromStack(@Nonnull ItemStack stack) {
IItemFilter filter = new ExistingItemFilter();
NBTTagCompound tag = NbtValue.FILTER.getTag(stack);
filter.readFromNBT(tag);
return filter;
}
Aggregations