本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.hasCapability方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.hasCapability方法的具体用法?Java EntityLivingBase.hasCapability怎么用?Java EntityLivingBase.hasCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.hasCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleServerMessage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncAdd message, MessageContext ctx) {
if ((player != null) && (message != null) && (ctx != null)) {
EntityLivingBase en = (EntityLivingBase) 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 (ItemStack stack : CurrencyUtils.itemMoneyAmount(message.amount)) {
if (stack != null && stack != ItemStack.EMPTY && en instanceof EntityPlayer) {
EntityPlayer pl = (EntityPlayer) en;
pl.inventory.addItemStackToInventory(stack);
}
}
}
}
}
return null;
}
示例2: onHeal
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public static void onHeal(LivingHealEvent event) {
EntityLivingBase entity = event.getEntityLiving();
if (!entity.hasCapability(CapabilityExtendedHealthSystem.INSTANCE, null))
return;
event.setCanceled(true);
if (!FirstAid.activeHealingConfig.allowOtherHealingItems)
return;
float amount = event.getAmount();
//Hacky shit to reduce vanilla regen
if (FirstAid.activeHealingConfig.allowNaturalRegeneration && Arrays.stream(Thread.currentThread().getStackTrace()).anyMatch(stackTraceElement -> stackTraceElement.getClassName().equals(FoodStats.class.getName())))
amount = amount * (float) FirstAid.activeHealingConfig.naturalRegenMultiplier;
else
amount = amount * (float) FirstAid.activeHealingConfig.otherRegenMultiplier;
HealthDistribution.distributeHealth(amount, (EntityPlayer) entity, true);
}
示例3: stopHurt
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void stopHurt(LivingAttackEvent event) {
if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase &&
(event.getSource().damageType.equals("mob") || event.getSource().damageType.equals("player"))) {
EntityLivingBase damageSource = (EntityLivingBase) event.getSource().getTrueSource();
if (!TF2Util.canInteract(damageSource)) {
event.setCanceled(true);
}
if (damageSource.hasCapability(TF2weapons.WEAPONS_CAP, null) && WeaponsCapability.get(damageSource).isDisguised()) {
disguise(damageSource, false);
}
}
if (!event.isCanceled() && event.getAmount() > 0) {
/*
* if(event.getEntity().getEntityData().getByte("IsCloaked")!=0){
* event.getEntity().getEntityData().setInteger("VisTicks",
* Math.min(10,event.getEntity().getEntityData().getInteger(
* "VisTicks"))); event.getEntity().setInvisible(false);
* //System.out.println("notInvisible"); }
*/
event.getEntityLiving().getEntityData().setInteger("lasthit", event.getEntityLiving().ticksExisted);
}
}
示例4: getBrewMap
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public static Map<IBrew, BrewEffect> getBrewMap(EntityLivingBase entity) {
if (entity.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null)) {
IBrewStorage storage = entity.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null);
return storage.getBrewMap();
}
return Collections.emptyMap();
}
示例5: getBrewEffects
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
public static Collection<BrewEffect> getBrewEffects(EntityLivingBase entity) {
if (entity.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null)) {
IBrewStorage storage = entity.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null);
return storage.getBrewEffects();
}
return Collections.emptyList();
}
示例6: isBrewActive
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Checks if a Brew is active.
*
* @param entity The entity
* @param brew The brew
* @return If it is active
*/
@SuppressWarnings("ConstantConditions")
public static boolean isBrewActive(EntityLivingBase entity, IBrew brew) {
if (entity.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null)) {
IBrewStorage storage = entity.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null);
return storage.getBrews().contains(brew);
}
return false;
}
示例7: getBrewStorage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/**
* Returns the {@link IBrewStorage} interface of the brew storage.
*
* @param entity The entity
* @return An {@link Optional <IBrewStorage>} for correctness
*/
@SuppressWarnings("ConstantConditions")
public static Optional<IBrewStorage> getBrewStorage(EntityLivingBase entity) {
if (entity.hasCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null)) {
return Optional.of(entity.getCapability(BrewStorageProvider.BREW_STORAGE_CAPABILITY, null));
}
return Optional.empty();
}
示例8: handleClientMessage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncCart message, MessageContext ctx) {
if ((player != null) && (message != null) && (ctx != null)) {
EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
if (en != null) {
if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
entityData.setCart(message.cart, false);
}
}
}
return null;
}
示例9: handleClientMessage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncCartItem message, MessageContext ctx) {
if ((player != null) && (message != null) && (ctx != null)) {
EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
if (en != null) {
if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
entityData.setStackInSlot(message.slot, message.stack, false);
}
}
}
return null;
}
示例10: handleClientMessage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncPrices message, MessageContext ctx) {
if ((player != null) && (message != null) && (ctx != null)) {
EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
if (en != null) {
if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
entityData.setPrices(message.prices, false);
}
}
}
return null;
}
示例11: onEntityTick
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityTick(LivingUpdateEvent e) {
EntityLivingBase entity = e.getEntityLiving();
if (entity.hasCapability(CAPABILITY_WEAPONSKILL, null)) {
IWeaponSkillInfo skillInfo = entity.getCapability(CAPABILITY_WEAPONSKILL, null);
skillInfo.setCooldown(Math.max(skillInfo.getCooldown()-1,0));
}
}
示例12: livingUpdate
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void livingUpdate(LivingUpdateEvent event) {
EntityLivingBase living = event.getEntityLiving();
if(living.hasCapability(RIG.RIG_ITEM, null)) {
ItemStack rig = living.getCapability(RIG.RIG_ITEM, null).getStackInSlot(0);
if(rig.hasTagCompound() && living.isInWater()) {
int extraair = 100 + RIGUpgrade.upgradesMap.get("Air").getAttributeValue(rig) * 100;
if (living.getRNG().nextInt(300+extraair)>=300) {
living.setAir(living.getAir()+1);
}
}
}
}
示例13: setAttackTarget
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void setAttackTarget(EntityLivingBase ent){
if(this.getAttackTarget()!=null&&ent instanceof EntityBuilding)
return;
if(ent!=null&&ent.hasCapability(TF2weapons.WEAPONS_CAP, null)&&ent.getCapability(TF2weapons.WEAPONS_CAP, null).itProtection>0)
return;
if(ent!=this.getAttackTarget()&&this.getAttackTarget()!=null){
boolean hadeffect=this.getAttackTarget().getActivePotionEffect(TF2weapons.it)!=null;
this.getAttackTarget().removePotionEffect(TF2weapons.it);
if(ent==null&&hadeffect)
this.getAttackTarget().addPotionEffect(new PotionEffect(TF2weapons.it,12));
}
if(ent!=null){
/*if(ent.getActivePotionEffect(TF2weapons.it)==null&&this.scareTick<=0){
for(EntityLivingBase living:this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>(){
@Override
public boolean apply(EntityLivingBase input) {
// TODO Auto-generated method stub
return getDistanceSqToEntity(input)<100 && !TF2weapons.isOnSameTeam(EntityHHH.this, input) && !(input.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null
&& input.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem()==Item.getItemFromBlock(Blocks.PUMPKIN));
}
})){
TF2weapons.stun(living, 100, false);
}
this.scareTick=200;
}*/
this.targetTime=300;
ent.addPotionEffect(new PotionEffect(TF2weapons.it,600));
if(ent!=this.getAttackTarget()&&this.rand.nextBoolean()){
}
}
super.setAttackTarget(ent);
}
示例14: isDisguised
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static boolean isDisguised(EntityLivingBase living, EntityLivingBase view) {
if(!living.hasCapability(TF2weapons.WEAPONS_CAP, null) || !WeaponsCapability.get(living).isDisguised()
|| (living.getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks != 0 && !(view instanceof EntityBuilding)))
return false;
String disguisetype=WeaponsCapability.get(living).getDisguiseType();
if(disguisetype.startsWith("M:") || disguisetype.startsWith("T:"))
return true;
if(disguisetype.startsWith("P:")) {
return living.world.getScoreboard().getPlayersTeam(disguisetype.substring(2)) == view.getTeam();
}
return false;
}
示例15: onDealDamage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void onDealDamage(ItemStack stack, EntityLivingBase attacker, Entity target, DamageSource source, float amount) {
if (TF2Attribute.getModifier("Burn Hit", stack, 0, attacker) > 0)
TF2Util.igniteAndAchievement(target, attacker, (int) TF2Attribute.getModifier("Burn Time", stack,
TF2Attribute.getModifier("Burn Hit", stack, 0, attacker), attacker) + 1);
if (target instanceof EntityLivingBase && attacker.hasCapability(TF2weapons.WEAPONS_CAP, null)){
boolean enemy = TF2Util.isEnemy(attacker, (EntityLivingBase) target);
/*if (attacker instanceof EntityPlayerMP && !target.isEntityAlive() &&
if (attacker instanceof EntityPlayerMP && target instanceof EntitySniper && !target.isEntityAlive() &&
&& TF2weapons.isEnemy(attacker, (EntityLivingBase) target)){
*/
float metalhit = TF2Attribute.getModifier("Metal Hit", stack, 0, attacker);
if (metalhit != 0) {
int restore=(int) (amount*metalhit/TF2ConfigVars.damageMultiplier);
if(!enemy && restore > 30)
restore=30;
attacker.getCapability(TF2weapons.WEAPONS_CAP, null).setMetal((int) (attacker.getCapability(TF2weapons.WEAPONS_CAP, null).getMetal()+restore));
}
if (!target.isEntityAlive() && !(target instanceof EntityBuilding)
&& TF2Attribute.getModifier("Kill Count", stack, 0, attacker)!=0){
stack.getTagCompound().setInteger("Heads", stack.getTagCompound().getInteger("Heads")+1);
}
float healthHit=TF2Attribute.getModifier("Health Hit", stack, 0, attacker);
if (healthHit > 0)
attacker.heal(enemy ? healthHit : healthHit/2f);
float bleed=TF2Attribute.getModifier("Bleed", stack, 0, attacker);
if (bleed > 0) {
((EntityLivingBase) target).addPotionEffect(new PotionEffect(TF2weapons.bleeding,(int) (bleed*20f)+10,0));
}
int rage = (int) TF2Attribute.getModifier("Knockback Rage", stack, 0, attacker);
if (enemy && !WeaponsCapability.get(attacker).knockbackActive && rage > 0) {
WeaponsCapability.get(attacker).setKnockbackRage(Math.min(1, WeaponsCapability.get(attacker).getKnockbackRage()+amount*(0.025f+rage*0.017f)));
}
if (enemy && TF2Attribute.getModifier("Uber Hit", stack, 0, attacker) > 0)
if (attacker instanceof EntityPlayer)
for (ItemStack medigun : ((EntityPlayer) attacker).inventory.mainInventory)
if (medigun != null && medigun.getItem() instanceof ItemMedigun) {
medigun.getTagCompound().setFloat("ubercharge",
MathHelper.clamp(
medigun.getTagCompound().getFloat("ubercharge")
+ TF2Attribute.getModifier("Uber Hit", stack, 0, attacker) / 100,
0, 1));
if (stack.getTagCompound().getFloat("ubercharge") >= 1)
attacker.playSound(ItemFromData.getSound(stack, PropertyType.CHARGED_SOUND), 1.2f, 1);
break;
}
if (TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker) != 1) {
//System.out.println(this.getFiringSpeed(stack, attacker) * (1-(1/TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker))));
attacker.getCapability(TF2weapons.WEAPONS_CAP, null).fire1Cool-= this.getFiringSpeed(stack, attacker) * (1-(1/TF2Attribute.getModifier("Fire Rate Hit", stack, 1, attacker)));
if(attacker instanceof EntityPlayerMP)
TF2weapons.network.sendTo(new TF2Message.ActionMessage(27,attacker), (EntityPlayerMP) attacker);
}
}
}