本文整理汇总了Java中net.minecraft.entity.ai.attributes.IAttributeInstance类的典型用法代码示例。如果您正苦于以下问题:Java IAttributeInstance类的具体用法?Java IAttributeInstance怎么用?Java IAttributeInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAttributeInstance类属于net.minecraft.entity.ai.attributes包,在下文中一共展示了IAttributeInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeAttributeInstanceToNBT
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
*/
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance instance)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
IAttribute iattribute = instance.getAttribute();
nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
nbttagcompound.setDouble("Base", instance.getBaseValue());
Collection<AttributeModifier> collection = instance.getModifiers();
if (collection != null && !collection.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
for (AttributeModifier attributemodifier : collection)
{
if (attributemodifier.isSaved())
{
nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
}
}
nbttagcompound.setTag("Modifiers", nbttaglist);
}
return nbttagcompound;
}
示例2: updateAITasks
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
protected void updateAITasks() {
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
if (this.isAngry()) {
--this.angerLevel;
}
if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) {
this.playSound(SoundEvents.ENTITY_ZOMBIE_PIG_ANGRY, this.getSoundVolume() * 2.0F,
((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
}
if (this.angerLevel > 0 && this.angerTargetUUID != null && this.getAITarget() == null) {
EntityPlayer entityplayer = this.world.getPlayerEntityByUUID(this.angerTargetUUID);
this.setRevengeTarget(entityplayer);
this.attackingPlayer = entityplayer;
this.recentlyHit = this.getRevengeTimer();
}
super.updateAITasks();
}
示例3: applyModifiersToAttributeInstance
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
private static void applyModifiersToAttributeInstance(IAttributeInstance instance, NBTTagCompound compound)
{
instance.setBaseValue(compound.getDouble("Base"));
if (compound.hasKey("Modifiers", 9))
{
NBTTagList nbttaglist = compound.getTagList("Modifiers", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));
if (attributemodifier != null)
{
AttributeModifier attributemodifier1 = instance.getModifier(attributemodifier.getID());
if (attributemodifier1 != null)
{
instance.removeModifier(attributemodifier1);
}
instance.applyModifier(attributemodifier);
}
}
}
}
示例4: sendMetadataToAllAssociatedPlayers
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity
* itself if a player.
*/
private void sendMetadataToAllAssociatedPlayers()
{
EntityDataManager entitydatamanager = this.trackedEntity.getDataManager();
if (entitydatamanager.isDirty())
{
this.sendToTrackingAndSelf(new SPacketEntityMetadata(this.trackedEntity.getEntityId(), entitydatamanager, false));
}
if (this.trackedEntity instanceof EntityLivingBase)
{
AttributeMap attributemap = (AttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
Set<IAttributeInstance> set = attributemap.getAttributeInstanceSet();
if (!set.isEmpty())
{
this.sendToTrackingAndSelf(new SPacketEntityProperties(this.trackedEntity.getEntityId(), set));
}
set.clear();
}
}
示例5: setChild
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Set whether this zombie is a child.
*/
public void setChild(boolean childZombie)
{
this.getDataWatcher().updateObject(12, Byte.valueOf((byte)(childZombie ? 1 : 0)));
if (this.worldObj != null && !this.worldObj.isRemote)
{
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
iattributeinstance.removeModifier(babySpeedBoostModifier);
if (childZombie)
{
iattributeinstance.applyModifier(babySpeedBoostModifier);
}
}
this.setChildSize(childZombie);
}
示例6: writeAttributeInstanceToNBT
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
*/
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance p_111261_0_)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
IAttribute iattribute = p_111261_0_.getAttribute();
nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
nbttagcompound.setDouble("Base", p_111261_0_.getBaseValue());
Collection<AttributeModifier> collection = p_111261_0_.func_111122_c();
if (collection != null && !collection.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
for (AttributeModifier attributemodifier : collection)
{
if (attributemodifier.isSaved())
{
nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
}
}
nbttagcompound.setTag("Modifiers", nbttaglist);
}
return nbttagcompound;
}
示例7: func_151475_a
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
public static void func_151475_a(BaseAttributeMap p_151475_0_, NBTTagList p_151475_1_)
{
for (int i = 0; i < p_151475_1_.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = p_151475_1_.getCompoundTagAt(i);
IAttributeInstance iattributeinstance = p_151475_0_.getAttributeInstanceByName(nbttagcompound.getString("Name"));
if (iattributeinstance != null)
{
applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
}
else
{
logger.warn("Ignoring unknown attribute \'" + nbttagcompound.getString("Name") + "\'");
}
}
}
示例8: applyModifiersToAttributeInstance
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
private static void applyModifiersToAttributeInstance(IAttributeInstance p_111258_0_, NBTTagCompound p_111258_1_)
{
p_111258_0_.setBaseValue(p_111258_1_.getDouble("Base"));
if (p_111258_1_.hasKey("Modifiers", 9))
{
NBTTagList nbttaglist = p_111258_1_.getTagList("Modifiers", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));
if (attributemodifier != null)
{
AttributeModifier attributemodifier1 = p_111258_0_.getModifier(attributemodifier.getID());
if (attributemodifier1 != null)
{
p_111258_0_.removeModifier(attributemodifier1);
}
p_111258_0_.applyModifier(attributemodifier);
}
}
}
}
示例9: sendMetadataToAllAssociatedPlayers
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity
* itself if a player.
*/
private void sendMetadataToAllAssociatedPlayers()
{
DataWatcher datawatcher = this.trackedEntity.getDataWatcher();
if (datawatcher.hasObjectChanged())
{
this.func_151261_b(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), datawatcher, false));
}
if (this.trackedEntity instanceof EntityLivingBase)
{
ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
Set<IAttributeInstance> set = serversideattributemap.getAttributeInstanceSet();
if (!set.isEmpty())
{
this.func_151261_b(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), set));
}
set.clear();
}
}
示例10: setAttributeModifiers
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list)
{
for (int i = 0; i < list.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));
if (iattributeinstance != null)
{
applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
}
else
{
LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")});
}
}
}
示例11: setAttributeModifiers
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list)
{
for (int i = 0; i < list.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));
if (iattributeinstance == null)
{
LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")});
}
else
{
applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
}
}
}
示例12: setAttackTarget
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Sets the active target the Task system uses for tracking
*/
public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn)
{
super.setAttackTarget(entitylivingbaseIn);
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
if (entitylivingbaseIn == null)
{
this.targetChangeTime = 0;
this.dataManager.set(SCREAMING, Boolean.valueOf(false));
iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST);
}
else
{
this.targetChangeTime = this.ticksExisted;
this.dataManager.set(SCREAMING, Boolean.valueOf(true));
if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST))
{
iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST);
}
}
}
示例13: setChild
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Set whether this zombie is a child.
*/
public void setChild(boolean childZombie)
{
this.getDataManager().set(IS_CHILD, Boolean.valueOf(childZombie));
if (this.world != null && !this.world.isRemote)
{
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
iattributeinstance.removeModifier(BABY_SPEED_BOOST);
if (childZombie)
{
iattributeinstance.applyModifier(BABY_SPEED_BOOST);
}
}
this.setChildSize(childZombie);
}
示例14: setSprintingGay
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
public void setSprintingGay(boolean sprinting)
{
SprintEvent event = new SprintEvent(sprinting);
event.call();
sprinting = event.sprint;
super.setSprinting(sprinting);
IAttributeInstance var2 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
if (var2.getModifier(sprintingSpeedBoostModifierUUID) != null)
{
var2.removeModifier(sprintingSpeedBoostModifier);
}
if (sprinting)
{
var2.applyModifier(sprintingSpeedBoostModifier);
}
}
示例15: setSprinting
import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入依赖的package包/类
/**
* Set sprinting switch for Entity.
*/
public void setSprinting(boolean sprinting)
{
super.setSprinting(sprinting);
IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
if (iattributeinstance.getModifier(sprintingSpeedBoostModifierUUID) != null)
{
iattributeinstance.removeModifier(sprintingSpeedBoostModifier);
}
if (sprinting)
{
iattributeinstance.applyModifier(sprintingSpeedBoostModifier);
}
}