Java Code Examples for net.minecraft.entity.player.EntityPlayer.getCapability()

The following are Jave code examples for showing how to use getCapability() of the net.minecraft.entity.player.EntityPlayer class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Loot-Slash-Conquer   File: EventLivingHurtAttack.java   View Source Code Vote up 7 votes
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onLivingAttack(LivingAttackEvent event)
{
	/*
	 * Player attacks a monster OR another player
	 */
	if (event.getSource().getTrueSource() instanceof EntityPlayer && !event.getSource().getTrueSource().getEntityWorld().isRemote)
	{
		EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
		EntityLivingBase enemy = event.getEntityLiving();
		ItemStack stack = player.inventory.getCurrentItem();
		PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (playerInfo != null && stack != null && stack.getItem() instanceof ItemSword && !(stack.getItem() instanceof ItemLEAdvancedMelee))
		{
			NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
			
			if (playerInfo.getPlayerLevel() >= nbt.getInteger("Level"))
			{
				useWeaponAttributes(event.getAmount(), player, enemy, stack, nbt);
			}
		}
	}
}
 
Example 2
Project: Loot-Slash-Conquer   File: GuiMana.java   View Source Code Vote up 6 votes
@SubscribeEvent
public void onRenderOverlayText(RenderGameOverlayEvent.Text event)
{
	ScaledResolution sr = event.getResolution();
	EntityPlayer player = Minecraft.getMinecraft().player;
	Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
	
	if (!player.capabilities.isCreativeMode && statsCap != null)
	{
		String mana = statsCap.getMana() + " / " + statsCap.getMaxMana();
		
		GL11.glPushMatrix();
		GL11.glScalef(0.5F, 0.5F, 0.5F);
		Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(mana, (sr.getScaledWidth() / 2 + 37) * 2, (sr.getScaledHeight() - 37) * 2, 0xFFFFFF);
		GL11.glPopMatrix();
	}
}
 
Example 3
Project: ArcaneMagic   File: ItemNotebook.java   View Source Code Vote up 6 votes
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
	INotebookInfo cap = player.getCapability(INotebookInfo.CAP, null);
	if (cap != null)
	{
		if (world.isRemote)
		{
			world.playSound(player.posX, player.posY, player.posZ, ArcaneMagicSoundHandler.randomPageSound(),
					SoundCategory.MASTER, 1f, 1f, false);
		} else
		{
			ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookOpened(cap), (EntityPlayerMP) player);
		}
		player.openGui(ArcaneMagic.instance, GUI_ID, world, (int) player.posX, (int) player.posY,
				(int) player.posZ);
	} else
	{
		System.out.println("NULL NOTEBOOK CAPABILITY FOUND FOR PLAYER WITH UUID " + player.getUniqueID().toString()
				+ "! THIS IS BAD!");
	}
	return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
 
Example 4
Project: Never-Enough-Currency   File: KeybindHandler.java   View Source Code Vote up 6 votes
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
public static void onEvent(KeyInputEvent event) {
	Minecraft mc = Minecraft.getMinecraft();
	EntityPlayer player = mc.player;

	CartCapability entityData = player.getCapability(Currency.CART_DATA, null);

	boolean isEmpty = true;

	if (entityData != null && entityData.getCart() != null) {
		for (ItemStack stack : entityData.getCart()) {
			if (!stack.isEmpty()) {
				isEmpty = false;
			}
		}
	}

	if (!isEmpty && openList.isPressed()) {
		Minecraft.getMinecraft().player.openGui(Currency.INSTANCE, 5, mc.world, (int) player.posX, (int) player.posY, (int) player.posZ);
	}
}
 
Example 5
Project: Loot-Slash-Conquer   File: ItemLEMagical.java   View Source Code Vote up 6 votes
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected)
{
	if (entity instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer) entity;
		PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (!world.isRemote && info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
		{
			if (selected && !isBonusActive)
			{
				EventPlayerTick.updateStats(player, info);
				isBonusActive = true;
			}
			
			if (!selected && isBonusActive)
			{
				EventPlayerTick.updateStats(player, info);
				isBonusActive = false;
			}
		}
	}
}
 
Example 6
Project: PurificatiMagicae   File: ItemPapyrus.java   View Source Code Vote up 6 votes
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer p, EnumHand handIn)
{
    ItemStack stack = p.getHeldItem(handIn);
    if (!worldIn.isRemote)
    {
        IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
        for (Pair<IfEntry, IRSReadPapyrus> pair : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSReadPapyrus.class, p, store))
        {
            if (pair.getRight().isSuitable(stack))
            {
                store.unlockStepAndSync(pair.getLeft().getId(), (EntityPlayerMP)p);
            }
        }
    }
    if (stack.hasTagCompound())
    {
        if (stack.getTagCompound().hasKey("papyrus_id"))
        {
            PurMag.proxy.openPapyrus(stack.getTagCompound().getString("papyrus_id"));
        }
    }
    return new ActionResult<>(EnumActionResult.PASS, stack);
}
 
Example 7
Project: Loot-Slash-Conquer   File: ItemLEBauble.java   View Source Code Vote up 6 votes
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity) 
{
	if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
	else
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
			{
				EventPlayerTick.updateStats(player, info);
			}
			else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
		}
	}
}
 
Example 8
Project: Loot-Slash-Conquer   File: ItemLEBauble.java   View Source Code Vote up 6 votes
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase entity) 
{
	if (!entity.getEntityWorld().isRemote)
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null)
			{
				EventPlayerTick.updateStats(player, info);
			}
		}
	}
}
 
Example 9
Project: BetterBeginningsReborn   File: ContainerSmelter.java   View Source Code Vote up 6 votes
public ContainerSmelter(EntityPlayer player, TileEntitySmelter tileEntitySmelter)
{
	super(tileEntitySmelter);
	PlayerInvWrapper playerInv = (PlayerInvWrapper) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	addSlotToContainer(new SlotItemHandler(itemHandler, TileEntitySmelter.INPUT, 46, 17));
	addSlotToContainer(new SlotItemHandler(itemHandler, TileEntitySmelter.FUEL, 56, 53));
	addSlotToContainer(new SlotOutput(itemHandler, TileEntitySmelterBase.OUTPUT, 116, 35));
	addSlotToContainer(new SlotItemHandler(itemHandler, TileEntitySmelter.BOOSTER, 66, 17));

	int i;
	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			addSlotToContainer(new SlotItemHandler(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	for (i = 0; i < 9; ++i)
	{
		addSlotToContainer(new SlotItemHandler(playerInv, i, 8 + i * 18, 142));
	}
}
 
Example 10
Project: PurificatiMagicae   File: IfEntry.java   View Source Code Vote up 5 votes
public boolean isAvailableToSee(EntityPlayer p, int tier)
{
    IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
    //if tier is < needed.
    if (tier < getTier())
        return false;

    if (!isAllParentsUnlocked(p))
        return false;

    return true;
}
 
Example 11
Project: Loot-Slash-Conquer   File: GuiMana.java   View Source Code Vote up 5 votes
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Post event)
{
	if (event.getType() != ElementType.EXPERIENCE) return;
	else
	{
		ScaledResolution sr = event.getResolution();
		EntityPlayer player = mc.player;
		
		if (!player.capabilities.isCreativeMode)
		{
			Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
			
			if (statsCap != null)
			{
				if (statsCap.getMaxMana() != 0)
				{
					double manaBarWidth = (double) statsCap.getMana() / statsCap.getMaxMana() * 81.0;
					int xPos = sr.getScaledWidth() / 2 + 10;
					int yPos = sr.getScaledHeight() - 38;
					
					mc.renderEngine.bindTexture(location);

					//if (capMana.getMana() != capMana.getMaxMana())
					//{
						this.drawTexturedModalRect(xPos, yPos, 0, 18, 81, 6);
						this.drawTexturedModalRect(xPos, yPos, 0, 24, (int) manaBarWidth, 5);
					//}
				}
			}
		}
	}
}
 
Example 12
Project: BetterBeginningsReborn   File: ContainerObsidianKiln.java   View Source Code Vote up 5 votes
public ContainerObsidianKiln(EntityPlayer player, TileEntityObsidianKiln obsKiln)
{
	super(obsKiln);
	PlayerInvWrapper playerInv = (PlayerInvWrapper) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	addSlotToContainer(new SlotItemHandler(itemHandler, TileEntityKilnBase.SLOT_INPUT, 56, 17));
	addSlotToContainer(new SlotConfigurableAccess((IItemHandlerModifiable) itemHandler, TileEntityKilnBase.SLOT_FUEL, 56, 53)
			{
				@Override
				public boolean isItemValid(ItemStack stack) 
				{
					return FuelRegistry.getBurnTime(FuelConsumerType.OBSIDIAN_KILN, stack) > 0;
				}
			});
	addSlotToContainer(new SlotOutput(itemHandler, TileEntityObsidianKiln.SLOT_OUTPUT, 116, 35));

	int i;
	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			addSlotToContainer(new SlotItemHandler(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	for (i = 0; i < 9; ++i)
	{
		addSlotToContainer(new SlotItemHandler(playerInv, i, 8 + i * 18, 142));
	}
}
 
Example 13
Project: BetterBeginningsReborn   File: ContainerNetherBrickOven.java   View Source Code Vote up 5 votes
public ContainerNetherBrickOven(EntityPlayer player, TileEntityNetherBrickOven tileEntityBrickOven)
{
	super(tileEntityBrickOven);
	PlayerInvWrapper playerInv = (PlayerInvWrapper) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	tileEntityNetherBrickOven = tileEntityBrickOven;
	addSlotToContainer(new SlotConfigurableAccess((IItemHandlerModifiable) itemHandler, TileEntityNetherBrickOven.FUEL, 17, 63));
	addSlotToContainer(new SlotOutput(itemHandler, TileEntityOvenBase.OUTPUT, 138, 35));

	int i;

	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; j++)
		{
			addSlotToContainer(new SlotItemHandler(itemHandler, j + i * 3 + TileEntityNetherBrickOven.INPUTSTART,
			                            44 + j * 18, 17 + i * 18));
		}
	}

	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			addSlotToContainer(new SlotItemHandler(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	for (i = 0; i < 9; ++i)
	{
		addSlotToContainer(new SlotItemHandler(playerInv, i, 8 + i * 18, 142));
	}
}
 
Example 14
Project: BetterBeginningsReborn   File: ContainerBrickOven.java   View Source Code Vote up 5 votes
public ContainerBrickOven(EntityPlayer player, TileEntityBrickOven tileEntityBrickOven)
{
	super(tileEntityBrickOven);
	PlayerInvWrapper playerInv = (PlayerInvWrapper) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	addSlotToContainer(new SlotConfigurableAccess(itemHandler, TileEntityBrickOven.FUEL, 92, 58));
	addSlotToContainer(new SlotOutput(itemHandler, TileEntityBrickOven.OUTPUT, 124, 21));

	int i;

	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; j++)
		{
			addSlotToContainer(new SlotItemHandler(itemHandler, j + i * 3 + TileEntityBrickOven.INPUTSTART, 30 + j * 18, 17 + i * 18));
		}
	}

	for (i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 9; ++j)
		{
			addSlotToContainer(new SlotItemHandler(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
		}
	}

	for (i = 0; i < 9; ++i)
	{
		addSlotToContainer(new SlotItemHandler(playerInv, i, 8 + i * 18, 142));
	}
}
 
Example 15
Project: BetterBeginningsReborn   File: ContainerWickerBasket.java   View Source Code Vote up 5 votes
public ContainerWickerBasket(EntityPlayer player, TileEntityWickerBasket tileEntityIn)
   {
super(tileEntityIn);
PlayerInvWrapper playerInv = (PlayerInvWrapper) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

//Wicker Basket Inventory
for (int x = 0; x < 9; ++x)
{
    addSlotToContainer(new SlotConfigurableAccess(itemHandler, x, x * 18 + 8, 18).setCanExtract(true).setCanInsert(true));
}

//Player Inventory
//TODO Replace with function
int i;
for (i = 0; i < 3; ++i)
{
    for (int j = 0; j < 9; ++j)
    {
	addSlotToContainer(new SlotConfigurableAccess(playerInv, j + i * 9 + 9, 8 + j * 18, 50 + i * 18).setCanExtract(true).setCanInsert(true));
    }
}
//Player Hotbar
for (i = 0; i < 9; ++i)
{
    addSlotToContainer(new SlotConfigurableAccess(playerInv, i, 8 + i * 18, 108).setCanExtract(true).setCanInsert(true));
}
   }
 
Example 16
Project: ArcaneMagic   File: TileEntityAnalyzer.java   View Source Code Vote up 5 votes
public void evaulateStack()
{
	hasValidStack = false;

	if (stackOwner != null)
	{
		EntityPlayer player = world.getPlayerEntityByUUID(stackOwner);
		if (player != null)
		{
			List<NotebookCategory> unlockable = ArcaneMagicAPI.getAnalyzer().getAnalysisResults(getStack(0));
			if (getStack(0) != null && !getStack(0).isEmpty() && unlockable.size() > 0)
			{
				INotebookInfo info = player.getCapability(INotebookInfo.CAP, null);
				if (info != null)
				{
					for (NotebookCategory c : unlockable)
					{
						if (info.isUnlocked(c.getPrerequisiteTag()) && !info.isUnlocked(c.getRequiredTag()))
						{
							hasValidStack = true;
							break;
						}
					}
				}

			}
		}
	}
}
 
Example 17
Project: ArcaneMagic   File: GuiNotebook.java   View Source Code Vote up 5 votes
public GuiNotebook(EntityPlayer player)
{
	this.player = player;
	INotebookInfo cap = player.getCapability(INotebookInfo.CAP, null);

	// player opened it for the first time!
	if (cap != null && !cap.getUsed())
	{
		cap.setUsed(true);
		ArcaneMagicPacketHandler.INSTANCE.sendToServer(new PacketNotebookChanged(cap));
	}
}
 
Example 18
Project: Loot-Slash-Conquer   File: GuiPlayerInformation.java   View Source Code Vote up 4 votes
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
	this.drawDefaultBackground(); // draws background tint
	super.drawScreen(mouseX, mouseY, partialTicks);
	
	DecimalFormat format = new DecimalFormat("#.##");
	EntityPlayer player = mc.player;
	PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
	Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
	
	if (player != null && playerInfo != null && statsCap != null)
	{
		// main info
		this.drawCenteredString(this.fontRenderer, I18n.format("gui.playerinfo.title"), this.width / 2, 20, 0xFFFFFF); // title
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.class") + ": " + I18n.format("gui.playerinfo.class." + playerInfo.getPlayerClass()), this.width / 2 - 50, 40, 0xFFFFFF); // level
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.level") + ": " + playerInfo.getPlayerLevel(), this.width / 2 - 50, 50, 0xFFFFFF); // level
		
		String experience = I18n.format("gui.playerinfo.experience") + ": " + playerInfo.getPlayerExperience() + " / " + playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel());
		double percent = (((double) playerInfo.getPlayerExperience() * 100) / (double) (playerInfo.getLevelUpExperience(playerInfo.getPlayerLevel())));
		String percentString = "  (" + String.format("%.0f%%", percent) + ")";
		this.drawString(this.fontRenderer, experience + percentString, this.width / 2 - 50, 60, 0xFFFFFF); // experience
		
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.skillpoints") + ": " + playerInfo.getSkillPoints(), this.width / 2 - 50, 70, 0xFFFFFF); // skill points

		// stats
		this.drawCenteredString(this.fontRenderer, I18n.format("gui.playerinfo.stats"), this.width / 2 + 150, 120, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.strength") + ":", this.width / 2 + 110, 140, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.agility") + ":", this.width / 2 + 110, 150, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.dexterity") + ":", this.width / 2 + 110, 160, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.intelligence") + ":", this.width / 2 + 110, 170, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.wisdom") + ":", this.width / 2 + 110, 180, 0xFFFFFF);
		this.drawString(this.fontRenderer, I18n.format("gui.playerinfo.stats.fortitude") + ":", this.width / 2 + 110, 190, 0xFFFFFF);
		
		this.drawString(this.fontRenderer, "" + playerInfo.getStrengthStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusStrengthStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 140, 0xFFFFFF);
		this.drawString(this.fontRenderer, "" + playerInfo.getAgilityStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusAgilityStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 150, 0xFFFFFF);
		this.drawString(this.fontRenderer, "" + playerInfo.getDexterityStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusDexterityStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 160, 0xFFFFFF);
		this.drawString(this.fontRenderer, "" + playerInfo.getIntelligenceStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusIntelligenceStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 170, 0xFFFFFF);
		this.drawString(this.fontRenderer, "" + playerInfo.getWisdomStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusWisdomStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 180, 0xFFFFFF);
		this.drawString(this.fontRenderer, "" + playerInfo.getFortitudeStat() + " (" + TextFormatting.GREEN + "+" + playerInfo.getBonusFortitudeStat() + TextFormatting.WHITE + ")", this.width / 2 + 180, 190, 0xFFFFFF);
		
		// bonuses
		this.drawCenteredString(this.fontRenderer, I18n.format("gui.playerinfo.bonuses"), this.width / 2 - 150, 120, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.playerdamage") + ": " + TextFormatting.WHITE + "+" + (int) (PlayerStatHelper.ATTACK_DAMAGE_MULTIPLIER * (playerInfo.getTotalStrength())), this.width / 2 - 190, 140, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.magicalpower") + ": " + TextFormatting.WHITE + "+" + (int) (PlayerStatHelper.MAGICAL_POWER_MULTIPLIER * (playerInfo.getTotalIntelligence())), this.width / 2 - 190, 150, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.attackspeed") + ": " + TextFormatting.WHITE + "+" + format.format((PlayerStatHelper.ATTACK_SPEED_MULTIPLIER * (playerInfo.getTotalAgility()))), this.width / 2 - 190, 160, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.armor") + ": " + TextFormatting.WHITE + "+" + format.format(player.getEntityAttribute(SharedMonsterAttributes.ARMOR).getAttributeValue()), this.width / 2 - 190, 170, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.toughness") + ": " + TextFormatting.WHITE + "+" + format.format(player.getEntityAttribute(SharedMonsterAttributes.ARMOR_TOUGHNESS).getAttributeValue()), this.width / 2 - 190, 180, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.health") + ": " + TextFormatting.WHITE + "+" + (int) (PlayerStatHelper.MAX_HEALTH_MULTIPLIER * (playerInfo.getTotalFortitude())), this.width / 2 - 190, 190, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.hp5") + ": " + TextFormatting.WHITE + statsCap.getHealthPerSecond(), this.width / 2 - 190, 200, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.mana") + ": " + TextFormatting.WHITE + "+" + (int) (PlayerStatHelper.MAX_MANA_MULTIPLIER * (playerInfo.getTotalWisdom())), this.width / 2 - 190, 210, 0xFFFFFF);
		this.drawString(this.fontRenderer, TextFormatting.GRAY + I18n.format("gui.playerinfo.bonuses.mp5") + ": " + TextFormatting.WHITE + statsCap.getManaPerSecond(), this.width / 2 - 190, 220, 0xFFFFFF);
	}
}
 
Example 19
Project: ArcaneMagic   File: ItemParchment.java   View Source Code Vote up 4 votes
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
	ItemStack stack = player.getHeldItem(hand);
	if (stack.getItem().equals(ModRegistry.WRITTEN_PARCHMENT))
	{
		Pair<NotebookCategory, Boolean> catInfo = getToUnlock(stack);
		if (catInfo != null)
		{
			if (!world.isRemote)
			{
				INotebookInfo cap = player.getCapability(INotebookInfo.CAP, null);
				if (cap != null)
				{
					NotebookCategory cat = catInfo.first();
					if (cat != null)
					{
						if (!cat.equals(NotebookCategories.UNKNOWN_REALMS)
								&& cap.isUnlocked(cat.getPrerequisiteTag())
								&& !cap.isUnlocked(cat.getRequiredTag()))
						{
							cap.setUnlocked(cat.getRequiredTag());
						}
						if (catInfo.second())
						{
							for (NotebookCategory mightBeParent : NotebookCategory.REGISTRY.getValues())
							{
								if (mightBeParent != null && mightBeParent.getRequiredTag() != null)
								{
									if (mightBeParent.getRequiredTag().equals(cat.getPrerequisiteTag()))
									{
										ArcaneMagicPacketHandler.INSTANCE
												.sendTo(new PacketNotebookToastExpanded(mightBeParent,
														cat.getRequiredTag(), true), (EntityPlayerMP) player);
									}
								}
							}
						} else
						{
							ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
									(EntityPlayerMP) player);
						}

					} else
					{
						ArcaneMagicPacketHandler.INSTANCE.sendTo(new PacketNotebookToastOrFail(cat, true),
								(EntityPlayerMP) player);
					}
				}
			}
		}

		world.playSound(player, player.getPosition(), ArcaneMagicSoundHandler.randomWriteSound(),
				SoundCategory.PLAYERS, 1, 1);
		player.setHeldItem(hand, ItemStack.EMPTY);
		player.swingArm(hand);
		if (!world.isRemote)
		{
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
		}
	}
	return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
 
Example 20
Project: Game-Stages   File: PlayerDataHandler.java   View Source Code Vote up 2 votes
/**
 * Gets the stage data for a player.
 *
 * @param player The player to get stage data from.
 * @return The stage data for the player.
 */
public static IStageData getStageData (@Nonnull EntityPlayer player) {

    return player != null && player.hasCapability(CAPABILITY, EnumFacing.DOWN) ? player.getCapability(CAPABILITY, EnumFacing.DOWN) : null;
}