本文整理汇总了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.
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
示例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
}
示例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();
}
示例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);
* }
*/
}
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例12: getDataManager
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static EntityDataManager getDataManager(Entity ent) {
return ent.getCapability(TF2weapons.WEAPONS_CAP, null).dataManager;
}
示例13: get
import net.minecraft.entity.Entity; //导入方法依赖的package包/类
public static WeaponsCapability get(Entity ent) {
return ent.getCapability(TF2weapons.WEAPONS_CAP, null);
}
示例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();
}