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


Java EntityPlayer.hasCapability方法代码示例

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


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

示例1: handleServerMessage

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncRemove message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
					if (player.inventory.getStackInSlot(i) != ItemStack.EMPTY && player.inventory.getStackInSlot(i).getItem() instanceof ItemMoneyBase) {
						player.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:18,代码来源:MessageSyncRemove.java

示例2: handleServerMessage

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncClearList message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);

				entityData.setCart(NonNullList.withSize(entityData.getSizeInventory(), ItemStack.EMPTY), true);
				List<Float> prices = Arrays.asList(new Float[25]);
				for (int i = 0; i < prices.size(); i++) {
					prices.set(i, (float) 0);
				}
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:MessageSyncClearList.java

示例3: onPlayerClone

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@SubscribeEvent
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
	final EntityPlayer oldPlayer = event.getOriginal();
	final EntityPlayer newPlayer = event.getEntityPlayer();

	if (event.isWasDeath() && oldPlayer.hasCapability(EnergyProvider.ENERGY_CAPABILITY, null) && newPlayer.hasCapability(EnergyProvider.ENERGY_CAPABILITY, null)) {
		final IEnergy oldCap = oldPlayer.getCapability(EnergyProvider.ENERGY_CAPABILITY, null);
		final IEnergy newCap = oldPlayer.getCapability(EnergyProvider.ENERGY_CAPABILITY, null);
		newCap.set(oldCap.get());
		newCap.setMax(oldCap.getMax());
		newCap.setRegen(oldCap.getRegenTime(), oldCap.getRegenBurst());
		newCap.setUses(oldCap.getUses());
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:16,代码来源:EnergyEvents.java

示例4: getEnergy

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
 * Returns the {@link IEnergy} interface of the player.
 *
 * @param player The player
 * @return An {@link Optional<IEnergy>} for correctness
 */
@SuppressWarnings("ConstantConditions")
public static Optional<IEnergy> getEnergy(EntityPlayer player) {
	if (player.hasCapability(EnergyProvider.ENERGY_CAPABILITY, null)) {
		return Optional.of(player.getCapability(EnergyProvider.ENERGY_CAPABILITY, null));
	}
	return Optional.empty();
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:14,代码来源:EnergyHandler.java

示例5: getStageData

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


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