當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。