本文整理汇总了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;
}
示例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;
}
示例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());
}
}
示例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();
}
示例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;
}