当前位置: 首页>>代码示例>>Java>>正文


Java EntityPlayer.getCapability方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getCapability方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getCapability方法的具体用法?Java EntityPlayer.getCapability怎么用?Java EntityPlayer.getCapability使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.getCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLivingAttack

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:25,代码来源:EventLivingHurtAttack.java

示例2: onRenderOverlayText

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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();
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:18,代码来源:GuiMana.java

示例3: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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));
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:24,代码来源:ItemNotebook.java

示例4: onEvent

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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);
	}
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:23,代码来源:KeybindHandler.java

示例5: onUpdate

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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;
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:25,代码来源:ItemLEMagical.java

示例6: onItemRightClick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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);
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:25,代码来源:ItemPapyrus.java

示例7: onEquipped

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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."));
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:20,代码来源:ItemLEBauble.java

示例8: onUnequipped

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:18,代码来源:ItemLEBauble.java

示例9: ContainerSmelter

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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));
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:24,代码来源:ContainerSmelter.java

示例10: isAvailableToSee

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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;
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:13,代码来源:IfEntry.java

示例11: onRenderOverlay

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@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);
					//}
				}
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:34,代码来源:GuiMana.java

示例12: ContainerObsidianKiln

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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));
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:30,代码来源:ContainerObsidianKiln.java

示例13: ContainerNetherBrickOven

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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));
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:33,代码来源:ContainerNetherBrickOven.java

示例14: ContainerBrickOven

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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));
	}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:31,代码来源:ContainerBrickOven.java

示例15: ContainerWickerBasket

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
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));
}
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:28,代码来源:ContainerWickerBasket.java


注:本文中的net.minecraft.entity.player.EntityPlayer.getCapability方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。