2019-02-18 12:15:18 +01:00
|
|
|
package de.ellpeck.naturesaura.items;
|
|
|
|
|
2019-02-18 19:30:35 +01:00
|
|
|
import com.google.common.base.Strings;
|
2019-02-18 12:15:18 +01:00
|
|
|
import de.ellpeck.naturesaura.NaturesAura;
|
2019-02-18 13:00:54 +01:00
|
|
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
2019-02-18 19:30:35 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.BlockEnderCrate;
|
|
|
|
import net.minecraft.client.util.ITooltipFlag;
|
2019-02-18 12:15:18 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
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-02-18 19:30:35 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
import java.util.List;
|
2019-02-18 12:15:18 +01:00
|
|
|
|
|
|
|
public class ItemEnderAccess extends ItemImpl {
|
|
|
|
public ItemEnderAccess() {
|
|
|
|
super("ender_access");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
|
|
|
|
if (handIn != EnumHand.MAIN_HAND)
|
|
|
|
return new ActionResult<>(EnumActionResult.PASS, playerIn.getHeldItem(handIn));
|
|
|
|
ItemStack stack = playerIn.getHeldItemMainhand();
|
2019-02-18 19:30:35 +01:00
|
|
|
if (!Strings.isNullOrEmpty(BlockEnderCrate.getEnderName(stack))) {
|
|
|
|
if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 10000, false))
|
2019-02-18 12:15:18 +01:00
|
|
|
playerIn.openGui(NaturesAura.MOD_ID, 1, worldIn, (int) playerIn.posX, (int) playerIn.posY, (int) playerIn.posZ);
|
|
|
|
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
|
|
|
}
|
|
|
|
return new ActionResult<>(EnumActionResult.FAIL, stack);
|
|
|
|
}
|
2019-02-18 19:30:35 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
|
|
|
BlockEnderCrate.addEnderNameInfo(stack, tooltip);
|
|
|
|
}
|
2019-02-18 12:15:18 +01:00
|
|
|
}
|