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


Java Entity.getCapability方法代码示例

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


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

示例1: worldTick

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@SubscribeEvent
public void worldTick(TickEvent.WorldTickEvent event) {
    if (event.phase == TickEvent.Phase.END) {
        try {
            for (Entity entity : event.world.loadedEntityList) {
                if (entity.hasCapability(CapabilityHackingProvider.HACKING_CAPABILITY, null)) {
                    IHacking hack = entity.getCapability(CapabilityHackingProvider.HACKING_CAPABILITY, null);
                    if (!hack.getCurrentHacks().isEmpty()) {
                        hack.update(entity);
                    }
                }
            }
        } catch (Throwable e) {
            // Catching a CME which I have no clue on what might cause it.
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:HackTickHandler.java

示例2: onUpdate

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
	WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);

	
	if (cap.reloadCool > 0 && par5 && cap.isCharging())
		this.disableZoom(par1ItemStack, (EntityLivingBase) par3Entity);
		
	if (cap.isCharging() && par5 && !(TF2Attribute.getModifier("Weapon Mode", par1ItemStack, 0, (EntityLivingBase) par3Entity) == 2 && cap.fire1Cool <= 0 ))
		if (cap.chargeTicks < getChargeTime(par1ItemStack, (EntityLivingBase) par3Entity))
			cap.chargeTicks += 1;
	// System.out.println("Charging: "+cap.chargeTicks);

	if (par3Entity instanceof EntitySniper && ((EntitySniper) par3Entity).getAttackTarget() != null
			&& par1ItemStack.getTagCompound().getBoolean("WaitProper"))
		if (((EntitySniper) par3Entity).getHealth() < 8 && cap.fire1Cool > 250)
			par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null).fire1Cool = 250;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:20,代码来源:ItemSniperRifle.java

示例3: canHack

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public boolean canHack(Entity entity, EntityPlayer player) {
    if (entity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
        IItemHandler handler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        for (int i = 0; i < handler.getSlots(); i++) {
            if (!handler.getStackInSlot(i).isEmpty()) return true;
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:HackableLivingDisarm.java

示例4: onHackFinished

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onHackFinished(Entity entity, EntityPlayer player) {
    if (!entity.world.isRemote && entity instanceof EntityLiving) {
        Random rand = new Random();
        EntityLiving entityLiving = (EntityLiving) entity;

        // access from vertical gets hands, horizontal gets armor - see EntityLivingBase#getCapability
        IItemHandler handsHandler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
        IItemHandler armorHandler = entity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH);

        doDisarm(entityLiving, rand, handsHandler, entityLiving.inventoryHandsDropChances);
        doDisarm(entityLiving, rand, armorHandler, entityLiving.inventoryArmorDropChances);
        entityLiving.setCanPickUpLoot(false);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:HackableLivingDisarm.java

示例5: getCurrentEntityHacks

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public List<IHackableEntity> getCurrentEntityHacks(Entity entity) {
    IHacking hacking = entity.getCapability(CapabilityHackingProvider.HACKING_CAPABILITY, null);
    if (hacking != null) {
        return hacking.getCurrentHacks();
    } else {
        Log.warning("Hacking capability couldn't be found in the entity " + entity.getName());
    }
    return Collections.emptyList();

}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:PneumaticHelmetRegistry.java

示例6: onEntityAttack

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onEntityAttack(LivingAttackEvent e) {
	if (e.getEntity().getEntityWorld().isRemote) return;
	
	Entity attacker = e.getSource().getTrueSource();
	
	if (attacker==null) return; //It's probably just some bat dying in lava
	if (attacker.hasCapability(CAPABILITY_WEAPONSKILL, EnumFacing.UP)) {
		IWeaponSkillInfo skillInfo = attacker.getCapability(CAPABILITY_WEAPONSKILL, EnumFacing.UP);
		if (skillInfo.getCooldown()<=0) {
			//Search for activations
			if (attacker instanceof EntityLivingBase) {
				
				//Tool activations
				if (e.getSource().damageType.equals("player")) {
					ItemStack weapon = ((EntityLivingBase)attacker).getHeldItem(((EntityLivingBase) attacker).getActiveHand());
					if (weapon.getItem() instanceof ISkillActivating) {
						int activated = ((ISkillActivating) weapon.getItem()).activateSkill(skillInfo, (EntityLivingBase)attacker, weapon, e.getSource(), (EntityLiving) e.getEntityLiving());
						if (activated>0) {
							// TODO: Stats? Advancements?
							skillInfo.setCooldown(activated);
						}
					}
				}
			}
		}
	}
	
	//TODO: Check the defender for armor WeaponSkills
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:31,代码来源:Thermionics.java

示例7: CapabilityMessage

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public CapabilityMessage(Entity entity,boolean sendAll) {
	WeaponsCapability cap = entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	this.entityID = entity.getEntityId();
	this.healTarget = cap.getHealTarget();
	//this.critTime = cap.critTime;
	//this.heads = cap.collectedHeads;
	if(sendAll) {
		this.entries=cap.dataManager.getAll();
	}
	else {
		this.entries=cap.dataManager.getDirty();
	}
	// new Exception().printStackTrace();
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:15,代码来源:TF2Message.java

示例8: onUpdate

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
	if (par5 && ((EntityLivingBase)par3Entity).getHeldItemMainhand() == par1ItemStack) {
		WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);
		if (TF2ConfigVars.randomCrits && !par2World.isRemote && cap.critTimeCool <= 0) {
			cap.critTimeCool = 20;
			if (this.rapidFireCrits(par1ItemStack) && this.hasRandomCrits(par1ItemStack, par3Entity)
					&& ((EntityLivingBase) par3Entity).getRNG().nextFloat() <= this.critChance(par1ItemStack,
							par3Entity)) {
				cap.setCritTime(40);
				// System.out.println("Apply crits rapid");
			}
		}
		if (TF2Attribute.getModifier("Kill Count", par1ItemStack, 0, null)!=0){
			par1ItemStack.getTagCompound().setInteger("Heads", cap.getHeads());
		}
		if (cap.getCritTime() > 0)
			cap.setCritTime(cap.getCritTime()-1);
		cap.critTimeCool -= 1;
		/*
		 * if(par3Entity instanceof
		 * EntityTF2Character&&((EntityTF2Character)
		 * par3Entity).getAttackTarget()!=null){
		 * System.out.println(this.getWeaponSpreadBase(par1ItemStack,
		 * (EntityLivingBase) par3Entity));
		 * if(par1ItemStack.getTagCompound().getInteger("reload")<=100&&!((
		 * EntityTF2Character)par3Entity).attack.lookingAt(this.
		 * getWeaponSpreadBase(par1ItemStack, (EntityLivingBase)
		 * par3Entity)*100+1)){
		 * par1ItemStack.getTagCompound().setInteger("reload", 100); }
		 * //par1ItemStack.getTagCompound().setBoolean("WaitProper", true);
		 * }
		 */
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:37,代码来源:ItemWeapon.java

示例9: onUpdate

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(stack, par2World, par3Entity, par4, par5);
	if(stack.isEmpty())
		return;
	/*
	 * if(itemProperties.get(par2World.isRemote).get(par3Entity)==null){
	 * itemProperties.get(par2World.isRemote).put((EntityLivingBase)
	 * par3Entity, new NBTTagCompound()); }
	 */
	WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	WeaponData.WeaponDataCapability stackcap = stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null);
	EntityLivingBase living=(EntityLivingBase) par3Entity;
	if (stackcap.active == 0 && par5) {
		stackcap.active = 1;
		// itemProperties.get(par2World.isRemote).get(par3Entity).setShort("reloadd",
		// (short) 800);

		if(!par2World.isRemote && living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER)!=null){
			float addHealth=(float) living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER).getAmount();
			living.setHealth((living.getMaxHealth())/(living.getMaxHealth()-addHealth)*living.getHealth());
		}
		cap.fire1Cool = this.getDeployTime(stack, living);
		cap.fire2Cool = this.getDeployTime(stack, living);
	} else if (stackcap.active > 0
			&& stack != living.getHeldItemOffhand() && !par5) {
		if (stackcap.active == 2 && (cap.state & 3) > 0)
			this.endUse(stack, living, par2World, cap.state, 0);
		
		stackcap.active = 0;
		this.holster(cap, stack, living, par2World);

	}
	if (par3Entity.ticksExisted % 5 == 0 && stackcap.active == 2
			&& TF2Attribute.getModifier("Mark Death", stack, 0, living) > 0)
		living.addPotionEffect(new PotionEffect(TF2weapons.markDeath,
				(int) TF2Attribute.getModifier("Mark Death", stack, 0,living) * 20));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:39,代码来源:ItemUsable.java

示例10: onUpdate

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
	WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	if (par5 && par1ItemStack.getTagCompound() != null)
		// System.out.println("EntityTicked" + cap.state+ par3Entity);
		if ((cap.state == 0 || cap.state == 4) && cap.chargeTicks > 0) {
		// System.out.println("Draining" + cap.chargeTicks);
			cap.killsSpinning=0;
			cap.chargeTicks -= 2;
			((EntityLivingBase) par3Entity).getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(slowdown);
		}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:14,代码来源:ItemMinigun.java

示例11: trackEntity

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public void trackEntity(Entity entity, IHackableEntity iHackable) {
    if (iHackable.getId() != null && entity.hasCapability(CapabilityHackingProvider.HACKING_CAPABILITY, null)) {
        IHacking hack = entity.getCapability(CapabilityHackingProvider.HACKING_CAPABILITY, null);
        hack.addHackable(iHackable);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:7,代码来源:HackTickHandler.java

示例12: getDataManager

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static EntityDataManager getDataManager(Entity ent) {
	return ent.getCapability(TF2weapons.WEAPONS_CAP, null).dataManager;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:4,代码来源:WeaponsCapability.java

示例13: get

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static WeaponsCapability get(Entity ent) {
	return ent.getCapability(TF2weapons.WEAPONS_CAP, null);
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:4,代码来源:WeaponsCapability.java

示例14: initGui

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
public void initGui() {
	player = new EntityOtherPlayerMP(this.mc.world, new GameProfile(mc.player.getUniqueID(), "name"));
	for(ResourceLocation entry:ForgeRegistries.ENTITIES.getKeys()) {
		Entity entity=EntityList.createEntityByIDFromName(entry, this.mc.world);
		if(entity instanceof EntityLivingBase && ((entity.width + entity.height < 6 && entity.isNonBoss())||this.mc.player.capabilities.isCreativeMode)) {
			mobList.add((EntityLivingBase) entity);
			if(entity instanceof EntitySpy) {
				entity.getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks=0;
			}
		}
	}
	Collections.sort(mobList, new Comparator<EntityLivingBase>() {

		@Override
		public int compare(EntityLivingBase o1, EntityLivingBase o2) {
			// TODO Auto-generated method stub
			return EntityList.getKey(o2).toString().compareTo(EntityList.getKey(o1).toString());
		}
		
	});
	Keyboard.enableRepeatEvents(true);
	this.playerNameField = new GuiTextField(6, this.fontRenderer, this.width / 2 + 26, this.height / 2 + 60, 108,
			19);
	this.playerNameField.setMaxStringLength(64);
	this.playerNameField.setFocused(true);
	this.buttonList.clear();
	for(int i=0;i<16;i++) {
		this.buttonList.add(new GuiButton(i, this.width / 2 - 135 + (i%2) * 70, this.height / 2 - 60+i/2*20, 70, 20,
				I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityZombie.class)), new Object[0])));
	}
	/*this.buttonList.add(new GuiButton(0, this.width / 2 - 135, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityZombie.class)), new Object[0])));
	this.buttonList.add(new GuiButton(1, this.width / 2 - 65, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityCreeper.class)), new Object[0])));
	this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityEnderman.class)), new Object[0])));
	this.buttonList.add(new GuiButton(7, this.width / 2 + 75, this.height / 2 - 20, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntitySpider.class)), new Object[0])));
	this.buttonList.add(new GuiButton(3, this.width / 2 - 135, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityCow.class)), new Object[0])));
	this.buttonList.add(new GuiButton(4, this.width / 2 - 65, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityPig.class)), new Object[0])));
	this.buttonList.add(new GuiButton(8, this.width / 2 + 5, this.height / 2 + 90, 60, 20,
			I18n.format(EntityList.getTranslationName(EntityList.getKey(EntityChicken.class)), new Object[0])));*/
	this.buttonList
			.add(playerDisguise = new GuiButton(30, this.width / 2 + 25, this.height / 2 + 80, 110, 20, "Player"));
	this.setButtons();

}
 
开发者ID:rafradek,项目名称:Mods,代码行数:51,代码来源:GuiDisguiseKit.java


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