本文整理汇总了Java中net.minecraft.entity.ai.attributes.AttributeInstance.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeInstance.getAttributeValue方法的具体用法?Java AttributeInstance.getAttributeValue怎么用?Java AttributeInstance.getAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.ai.attributes.AttributeInstance
的用法示例。
在下文中一共展示了AttributeInstance.getAttributeValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMoveSpeed
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
private void updateMoveSpeed(EntityLivingBase entity, EntityStats stats) {
AttributeInstance moveSpeedAttribute = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
double newMoveSpeed = stats.getMovementSpeed();
double oldMoveSpeed = moveSpeedAttribute.getAttributeValue();
if (newMoveSpeed != oldMoveSpeed) {
double baseMoveSpeed = moveSpeedAttribute.getBaseValue();
// Get the modifier:
AttributeModifier speedModifier = moveSpeedAttribute.getModifier(uuid);
if (speedModifier != null) {
// Remove the old modifier
moveSpeedAttribute.removeModifier(speedModifier);
}
// I think the argument "2" stands for operation "add percentage":
speedModifier = new AttributeModifier(uuid, "Speed bonus from Dota 2 Items", newMoveSpeed / baseMoveSpeed - 1.0, 2)
.setSaved(false); // I think this makes it non-persistent
moveSpeedAttribute.applyModifier(speedModifier);
}
}
示例2: getFOVMultiplier
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Gets the player's field of view multiplier. (ex. when flying)
*/
public float getFOVMultiplier()
{
float f = 1.0F;
if (this.capabilities.isFlying)
{
f *= 1.1F;
}
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
f = (float)((double)f * ((attributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));
if (this.isUsingItem() && this.getItemInUse().itemID == Item.bow.itemID)
{
int i = this.getItemInUseDuration();
float f1 = (float)i / 20.0F;
if (f1 > 1.0F)
{
f1 = 1.0F;
}
else
{
f1 *= f1;
}
f *= 1.0F - f1 * 0.15F;
}
return ForgeHooksClient.getOffsetFOV(this, f);
}
示例3: getTargetDistance
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
protected double getTargetDistance()
{
AttributeInstance attributeinstance = this.taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange);
return attributeinstance == null ? 16.0D : attributeinstance.getAttributeValue();
}
示例4: onRenderHotBar
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
@ForgeSubscribe
public void onRenderHotBar(RenderGameOverlayEvent event) {
// Only interested in Post-HotBar events ((almost) the end of overlay rendering)
if (event.isCancelable() || event.type != ElementType.HOTBAR || mc.thePlayer.capabilities.isCreativeMode) {
return;
}
EntityStats stats = Dota2Items.stats.getOrCreateEntityStats(mc.thePlayer);
if (stats.getMaxMana() == 0) {
return;
}
float halfDrop = (float)stats.getMaxMana() / (float)HALF_DROPS_COUNT;
int mana = MathHelper.floor_float((float)stats.getMana() / halfDrop);
long ticksSinceLastChange = mc.thePlayer.ticksExisted - lastChange;
boolean highlight = ticksSinceLastChange <= HIGHLIGHT_TIME && ticksSinceLastChange / 3 % 2 == 1;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
mc.renderEngine.bindTexture(texture);
int width = event.resolution.getScaledWidth();
int height = event.resolution.getScaledHeight();
int left = width / 2 - 91;
int top = height - 39;
// Account for health bars:
AttributeInstance attrMaxHealth = this.mc.thePlayer.getEntityAttribute(SharedMonsterAttributes.maxHealth);
float healthMax = (float)attrMaxHealth.getAttributeValue();
float absorb = this.mc.thePlayer.getAbsorptionAmount();
int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F);
int rowHeight = Math.max(10 - (healthRows - 2), 3);
top -= healthRows * rowHeight;
// Account for armor:
if (ForgeHooks.getTotalArmorValue(mc.thePlayer) > 0) {
top -= 10;
}
yPos = top;
int regen = -1;
for (int i = 0; i < 10; ++i) {
int idx = i * 2 + 1;
int x = left + i * 8;
int y = top;
if (i == regen) {
y -= 2;
}
drawTexturedModalRect(x, y, (highlight ? 9 : 0), 0, 9, 9);
if (highlight) {
if (idx < prevMana) {
drawTexturedModalRect(x, y, 54, 0, 9, 9);
} else if (idx == prevMana) {
drawTexturedModalRect(x, y, 63, 0, 9, 9);
}
}
if (idx < mana) {
drawTexturedModalRect(x, y, 36, 0, 9, 9);
} else if (idx == mana) {
drawTexturedModalRect(x, y, 45, 0, 9, 9);
}
}
if (prevMana != mana) {
lastChange = mc.thePlayer.ticksExisted;
}
prevMana = mana;
}