本文整理匯總了Java中net.minecraft.entity.ai.attributes.IAttribute類的典型用法代碼示例。如果您正苦於以下問題:Java IAttribute類的具體用法?Java IAttribute怎麽用?Java IAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IAttribute類屬於net.minecraft.entity.ai.attributes包,在下文中一共展示了IAttribute類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeAttributeInstanceToNBT
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的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;
}
示例2: writeAttributeInstanceToNBT
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的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;
}
示例3: applyAttributesModifiersToEntity
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void applyAttributesModifiersToEntity(EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_)
{
Iterator iterator = this.field_111188_I.entrySet().iterator();
while (iterator.hasNext())
{
Entry entry = (Entry)iterator.next();
IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());
if (iattributeinstance != null)
{
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
iattributeinstance.removeModifier(attributemodifier);
iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + p_111185_3_, this.func_111183_a(p_111185_3_, attributemodifier), attributemodifier.getOperation()));
}
}
}
示例4: register
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public static void register() {
for (Field f : AbstractHorse.class.getDeclaredFields()) {
try {
if (f.getName().equals("JUMP_STRENGTH") || f.getName().equals("field_110270_bw") || "interface net.minecraft.entity.ai.attributes.IAttribute".equals(f.getType() + "")) {
f.setAccessible(true);
// save pointer to the obj so we can reference it later
horseJumpStrength = (IAttribute) f.get(null);
break;
}
}
catch (Exception e) {
ModCyclic.logger.error("Severe error, please report this to the mod author [ JUMP_STRENGTH ]:");
ModCyclic.logger.error(e.getStackTrace().toString());
}
}
if (horseJumpStrength == null) {
ModCyclic.logger.error(Const.MODID + ": JUMP_STRENGTH : Error - field not found using reflection");
}
}
示例5: applyAttributesModifiersToEntity
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3)
{
Iterator var4 = this.field_111188_I.entrySet().iterator();
while (var4.hasNext())
{
Entry var5 = (Entry)var4.next();
IAttributeInstance var6 = par2BaseAttributeMap.getAttributeInstance((IAttribute)var5.getKey());
if (var6 != null)
{
AttributeModifier var7 = (AttributeModifier)var5.getValue();
var6.removeModifier(var7);
var6.applyModifier(new AttributeModifier(var7.getID(), this.getName() + " " + par3, this.func_111183_a(par3, var7), var7.getOperation()));
}
}
}
示例6: writeAttributeModifierToNBT
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
/**
* Helper method for writing new attribute modifiers.
* @param attribute
* @param modifier
* @param slot
* @return
*/
public static NBTTagCompound writeAttributeModifierToNBT(IAttribute attribute, AttributeModifier modifier, EntityEquipmentSlot slot)
{
NBTTagCompound nbt = new NBTTagCompound();
nbt.setString("AttributeName", attribute.getName());
nbt.setString("Name", modifier.getName());
nbt.setString("Slot", slot.getName());
nbt.setDouble("Amount", modifier.getAmount());
nbt.setInteger("Operation", modifier.getOperation());
nbt.setLong("UUIDMost", modifier.getID().getMostSignificantBits());
nbt.setLong("UUIDLeast", modifier.getID().getLeastSignificantBits());
return nbt;
}
示例7: replaceModifier
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
/**
* Replace a modifier in the {@link Multimap} with a copy that's had {@code multiplier} applied to its value.
*
* @param modifierMultimap The MultiMap
* @param attribute The attribute being modified
* @param id The ID of the modifier
* @param multiplier The multiplier to apply
*/
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier)
{
// Get the modifiers for the specified attribute
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
// Find the modifier with the specified ID, if any
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) // If it exists,
{
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier); // Remove it
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation())); // Add the new modifier
}
}
示例8: applyAttributeModifiers
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void applyAttributeModifiers(AbstractAttributeMap attributeMap, int amplifier) {
for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
IAttributeInstance attribute = attributeMap.getAttributeInstance(entry.getKey());
if (attribute == null) continue;
AttributeModifier modifier = entry.getValue();
attribute.removeModifier(modifier);
attribute.applyModifier(new AttributeModifier(modifier.getID(), this.getName() + " " + amplifier, modifier.getAmount() * (double) (amplifier + 1), modifier.getOperation()));
}
}
示例9: removeAttributeModifiers
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void removeAttributeModifiers(AbstractAttributeMap attributeMapIn, int amplifier) {
for (Map.Entry<IAttribute, AttributeModifier> entry : modifierMap.entrySet()) {
IAttributeInstance attribute = attributeMapIn.getAttributeInstance(entry.getKey());
if (attribute == null) continue;
attribute.removeModifier(entry.getValue());
}
}
示例10: replaceModifier
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) {
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) {
final AttributeModifier modifier = modifierOptional.get();
modifiers.remove(modifier);
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation()));
}
}
示例11: onLivingUpdate
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
if (EntityUtils.isDrivenByPlayer(event.getEntity()) && getRidingEntity() instanceof AbstractHorse) {
IAttribute JUMP_STRENGTH = FastReflection.Fields.AbstractHorse_JUMP_STRENGTH.get(getRidingEntity());
IAttribute MOVEMENT_SPEED = FastReflection.Fields.SharedMonsterAttributes_MOVEMENT_SPEED.get(getRidingEntity());
((EntityLivingBase) getRidingEntity()).getEntityAttribute(JUMP_STRENGTH).setBaseValue(jumpHeight.getAsDouble());
((EntityLivingBase) getRidingEntity()).getEntityAttribute(MOVEMENT_SPEED).setBaseValue(speed.getAsDouble());
}
}
示例12: registerPotionAttributeModifier
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
/**
* Used by potions to register the attribute they modify.
*/
public Potion registerPotionAttributeModifier(IAttribute p_111184_1_, String p_111184_2_, double p_111184_3_, int p_111184_5_)
{
AttributeModifier attributemodifier = new AttributeModifier(UUID.fromString(p_111184_2_), this.getName(), p_111184_3_, p_111184_5_);
this.attributeModifierMap.put(p_111184_1_, attributemodifier);
return this;
}
示例13: removeAttributesModifiersFromEntity
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111187_2_, int amplifier)
{
for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
{
IAttributeInstance iattributeinstance = p_111187_2_.getAttributeInstance((IAttribute)entry.getKey());
if (iattributeinstance != null)
{
iattributeinstance.removeModifier((AttributeModifier)entry.getValue());
}
}
}
示例14: applyAttributesModifiersToEntity
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
{
IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());
if (iattributeinstance != null)
{
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
iattributeinstance.removeModifier(attributemodifier);
iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
}
}
}
示例15: handleEntityProperties
import net.minecraft.entity.ai.attributes.IAttribute; //導入依賴的package包/類
/**
* Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
* sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
* maxHealth and knockback resistance as well as reinforcement spawning chance.
*/
public void handleEntityProperties(S20PacketEntityProperties packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());
if (entity != null)
{
if (!(entity instanceof EntityLivingBase))
{
throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
}
else
{
BaseAttributeMap baseattributemap = ((EntityLivingBase)entity).getAttributeMap();
for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d())
{
IAttributeInstance iattributeinstance = baseattributemap.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());
if (iattributeinstance == null)
{
iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute((IAttribute)null, s20packetentityproperties$snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
}
iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
iattributeinstance.removeAllModifiers();
for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c())
{
iattributeinstance.applyModifier(attributemodifier);
}
}
}
}
}