package com.matt.forgehax.mods;

import com.matt.forgehax.asm.reflection.FastReflection;
import com.matt.forgehax.util.command.Setting;
import com.matt.forgehax.util.mod.ToggleMod;
import com.matt.forgehax.util.mod.loader.RegisterMod;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.entity.passive.AbstractHorse;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import static com.matt.forgehax.Helper.*;

/**
 * Created by Babbaj on 9/1/2017.
 */
@RegisterMod
public class HorseStats extends ToggleMod {
    public HorseStats() { super("HorseStats", false, "Change the stats of your horse"); }

    public final Setting<Double> jumpHeight = getCommandStub().builders().<Double>newSettingBuilder()
            .name("jumpHeight").description("Modified horse jump height attribute. Default: 1")
            .defaultTo(1.0D).build();
    public final Setting<Double> speed = getCommandStub().builders().<Double>newSettingBuilder()
            .name("Speed").description("Modiified horse speed attribute. Default: 0.3375")
            .defaultTo(0.3375D).build();

    @SubscribeEvent
    public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
        if (!(getRidingEntity() instanceof AbstractHorse)) return;

        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());

    }

}

@@ -1310,10 +1310,59 @@
 if (
-!(
+EntityUtils.isDrivenByPlayer(event.getEntity()) && 
 getR
@@ -1404,19 +1404,16 @@
 rse)
-) return;%0A%0A
+ %7B%0A%0A    
     
@@ -1517,32 +1517,36 @@
 ity());%0A        
+   
+ 
 IAttribute MOVEM
@@ -1639,24 +1639,29 @@
 Entity());%0A%0A
+     
        ((Ent
@@ -1666,32 +1666,33 @@
 ntityLivingBase)
+ 
 getRidingEntity(
@@ -1771,24 +1771,29 @@
 ());%0A       
+    
+ 
 ((EntityLivi
@@ -1799,16 +1799,17 @@
 ingBase)
+ 
 getRidin
@@ -1885,22 +1885,31 @@
 sDouble());%0A
+        %7D
 %0A    %7D%0A%0A%7D%0A

Check if the entity is being ridden by the player