Search in sources :

Example 1 with AttributeMapBase

use of net.minecraft.server.AttributeMapBase in project Arcade2 by ShootGame.

the class GamePlayer method getAttribute.

@Override
public Attribute getAttribute(AttributeKey key) {
    EntityPlayer mojang = this.getMojang();
    if (this.attributeMap == null) {
        try {
            Field mojangMap = EntityLiving.class.getDeclaredField("attributeMap");
            mojangMap.setAccessible(true);
            this.attributeMap = new TrackingAttributeMap((AttributeMapBase) mojangMap.get(mojang));
        } catch (ReflectiveOperationException ex) {
            this.game.getPlugin().getLogger().log(Level.SEVERE, "Could not inject attribute map", ex);
            return null;
        }
    }
    return this.attributeMap.getAttribute(key);
}
Also used : Field(java.lang.reflect.Field) AttributeMapBase(net.minecraft.server.AttributeMapBase) TrackingAttributeMap(pl.themolka.arcade.attribute.TrackingAttributeMap) EntityPlayer(net.minecraft.server.EntityPlayer)

Aggregations

Field (java.lang.reflect.Field)1 AttributeMapBase (net.minecraft.server.AttributeMapBase)1 EntityPlayer (net.minecraft.server.EntityPlayer)1 TrackingAttributeMap (pl.themolka.arcade.attribute.TrackingAttributeMap)1