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


Java EntityLivingBase.getCapability方法代码示例

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


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

示例1: onEntityJoinWorld

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
	{
		EntityLivingBase entity = (EntityLivingBase) event.getEntity();
		World world = entity.getEntityWorld();
		IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		
		if (enemyLevelCap != null && chunkLevelHolder != null)
		{
			if (enemyLevelCap.getEnemyLevel() == 0)
			{
				IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
				int level = chunkLevel.getChunkLevel();
				
				enemyLevelCap.setEnemyLevel(level);
				entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
				
				if (level > 1) setAttributeModifiers(entity, level);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:EventEntityJoinWorld.java

示例2: getFeignDeathWatch

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack getFeignDeathWatch(EntityLivingBase living) {
	ItemStack stack=living.getHeldItemMainhand();
	if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
		return stack;
	}
	else {
		stack=living.getHeldItemOffhand();
		if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
			return stack;
		}
		IItemHandler items=living.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
		for(int i=0; i<items.getSlots(); i++) {
			stack=items.getStackInSlot(i);
			if(stack.getItem() instanceof ItemCloak && ((ItemCloak)stack.getItem()).isFeignDeath(stack, living) && stack.getItemDamage() == 0) {
				return stack;
			}
		}
	}
	return ItemStack.EMPTY;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:21,代码来源:ItemCloak.java

示例3: 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;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:MessageSyncAdd.java

示例4: calculateCritPre

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static int calculateCritPre(ItemStack stack, EntityLivingBase living) {
	int thisCritical = 0;
	
	if (living.getActivePotionEffect(TF2weapons.crit) != null || living.getActivePotionEffect(TF2weapons.buffbanner) != null)
		thisCritical = 1;
	if ( thisCritical == 0 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).focusedShot(stack) || living.getCapability(TF2weapons.WEAPONS_CAP, null).focusShotRemaining>0))
		thisCritical = 1;
	if (TF2ConfigVars.randomCrits && !stack.isEmpty() && stack.getItem() instanceof ItemWeapon) {
		ItemWeapon item = (ItemWeapon) stack.getItem();
		if ((!item.rapidFireCrits(stack) && item.hasRandomCrits(stack, living) && living.getRNG().nextFloat() <= item.critChance(stack, living))
				|| living.getCapability(TF2weapons.WEAPONS_CAP, null).getCritTime() > 0)
			thisCritical = 2;
	}
	if (living.getActivePotionEffect(TF2weapons.critBoost) != null)
		thisCritical = 2;
	
	if (!stack.isEmpty() && (!(stack.getItem() instanceof ItemWeapon) || stack.getItem() instanceof ItemMeleeWeapon)
			&& (living.getActivePotionEffect(TF2weapons.charging) != null || living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0))
		if (thisCritical < 2 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0 && living.getCapability(TF2weapons.WEAPONS_CAP, null).bashCritical)
				|| (living.getActivePotionEffect(TF2weapons.charging) != null && living.getActivePotionEffect(TF2weapons.charging).getDuration() < 14))
			thisCritical = 2;
		else if (thisCritical == 0 && (living.getCapability(TF2weapons.WEAPONS_CAP, null).ticksBash > 0 || living.getActivePotionEffect(TF2weapons.charging).getDuration() < 35))
			thisCritical = 1;
	return thisCritical;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:26,代码来源:TF2Util.java

示例5: doChargeTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void doChargeTick(EntityLivingBase player) {
	if (player == Minecraft.getMinecraft().player) {
		if (player.getActivePotionEffect(TF2weapons.charging) != null
				&& !(Minecraft.getMinecraft().player.movementInput instanceof MovementInputCharging)) {
			player.getCapability(TF2weapons.PLAYER_CAP,
					null).lastMovementInput = Minecraft.getMinecraft().player.movementInput;
			Minecraft.getMinecraft().player.movementInput = new MovementInputCharging();
			KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSprint.getKeyCode(), true);
			Minecraft.getMinecraft().gameSettings.mouseSensitivity *= 0.1f;
		} else if (player.getActivePotionEffect(TF2weapons.charging) == null
				&& player.getCapability(TF2weapons.PLAYER_CAP, null).lastMovementInput != null) {

			Minecraft.getMinecraft().player.movementInput = player.getCapability(TF2weapons.PLAYER_CAP,
					null).lastMovementInput;
			player.getCapability(TF2weapons.PLAYER_CAP, null).lastMovementInput = null;
			Minecraft.getMinecraft().gameSettings.mouseSensitivity *= 10f;
		}
		//Minecraft.getMinecraft().player.movementInput.moveForward = 1f;
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:21,代码来源:ClientProxy.java

示例6: altFireTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean altFireTick(ItemStack stack, EntityLivingBase living, World world) {
	EntitySentry sentry = living.getCapability(TF2weapons.WEAPONS_CAP, null).controlledSentry;
	if (sentry != null && sentry.isEntityAlive())
		sentry.shootRocket(living);
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:8,代码来源:ItemWrangler.java

示例7: shoot

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void shoot(ItemStack stack, EntityLivingBase living, World world, int thisCritical, EnumHand hand) {
	if (!world.isRemote) {
		EntityStickybomb bomb = new EntityStickybomb(world, living, hand);
		bomb.setCritical(thisCritical);
		world.spawnEntity(bomb);
		ArrayList<EntityStickybomb> list = living.getCapability(TF2weapons.WEAPONS_CAP, null).activeBomb;
		list.add(bomb);
		if (list.size() > TF2Attribute.getModifier("Stickybomb Count", stack, 8, living)) {
			EntityStickybomb firstBomb = list.get(0);
			firstBomb.explode(firstBomb.posX, firstBomb.posY, firstBomb.posZ, null, 1);
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:15,代码来源:ItemStickyLauncher.java

示例8: onDealDamage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void onDealDamage(ItemStack stack, EntityLivingBase attacker, Entity target, DamageSource source, float amount) {
	super.onDealDamage(stack, attacker, target, source, amount);
	if(attacker instanceof EntityPlayer && !target.isEntityAlive() && target instanceof EntityLivingBase && TF2Util.isEnemy(attacker, (EntityLivingBase) target)){
		attacker.getCapability(TF2weapons.WEAPONS_CAP, null).killsSpinning++;
		/*if(attacker.getCapability(TF2weapons.WEAPONS_CAP, null).killsSpinning>=8)
			((EntityPlayer)attacker).addStat(TF2Achievements.REVOLUTION);*/
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:9,代码来源:ItemMinigun.java

示例9: doFireSound

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doFireSound(ItemStack stack, EntityLivingBase living, World world, int critical) {
	if (ItemFromData.getData(stack).hasProperty(PropertyType.CHARGED_FIRE_SOUND) 
			&& living.getCapability(TF2weapons.WEAPONS_CAP, null).chargeTicks >= getChargeTime(stack, living)) {
		SoundEvent soundToPlay = SoundEvent.REGISTRY
				.getObject(new ResourceLocation(ItemFromData.getData(stack).getString(PropertyType.CHARGED_FIRE_SOUND)
						+ (critical == 2 ? ".crit" : "")));
		living.playSound(soundToPlay, 4f, 1f);
		if (world.isRemote)
			ClientProxy.removeReloadSound(living);
	}
	else {
		super.doFireSound(stack, living, world, critical);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:15,代码来源:ItemSniperRifle.java

示例10: 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;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncCart.java

示例11: 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;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncCartItem.java

示例12: 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));
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:9,代码来源:Thermionics.java

示例13: altFireTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean altFireTick(ItemStack stack, EntityLivingBase living, World world) {
	if (!world.isRemote) {
		ArrayList<EntityStickybomb> list = living.getCapability(TF2weapons.WEAPONS_CAP, null).activeBomb;
		if (list == null || list.isEmpty())
			return false;
		boolean exploded = false;
		
		TF2PlayerCapability cap=living.getCapability(TF2weapons.PLAYER_CAP, null);
		if(cap != null){
			cap.engineerKilled=false;
			cap.dispenserKilled=false;
			cap.sentryKilled=false;
			cap.stickybombKilled=0;
		}
		for (int i = 0; i < list.size(); i++) {
			EntityStickybomb bomb = list.get(i);
			if (bomb.ticksExisted > bomb.getArmTime() && (bomb.getType()!=1 || living.getEntityBoundingBox().grow(1.5, 0.25, 1.5).offset(0, -1.25, 0).contains(bomb.getPositionVector()) || TF2Util.lookingAt(living, 30, bomb.posX, bomb.posY, bomb.posZ))) {
				bomb.explode(bomb.posX, bomb.posY + bomb.height / 2, bomb.posZ, null, 1);
				i--;
				exploded = true;
			}
		}
		if (exploded) {
			living.playSound(ItemFromData.getSound(stack, PropertyType.DETONATE_SOUND), 1f, 1);
			/*if(living instanceof EntityPlayer && cap.stickybombKilled>=3)
				((EntityPlayer)living).addStat(TF2Achievements.PIPEBAGGER);
			if(living instanceof EntityPlayer && cap.engineerKilled && cap.dispenserKilled && cap.sentryKilled)
				((EntityPlayer)living).addStat(TF2Achievements.ARGYLE_SAP);*/
		}
	}
	return false;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:34,代码来源:ItemStickyLauncher.java

示例14: 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);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:37,代码来源:EntityHHH.java

示例15: disableZoom

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void disableZoom(ItemStack stack, EntityLivingBase living) {
	WeaponsCapability cap = living.getCapability(TF2weapons.WEAPONS_CAP, null);
	
	cap.setCharging(false);
	living.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(slowdown);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:7,代码来源:ItemSniperRifle.java


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