Allow custom step height for StepMod
@@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import com.matt.forgehax.asm.events.PacketEvent;
import com.matt.forgehax.events.LocalPlayerUpdateEvent;
import com.matt.forgehax.util.PacketHelper;
+import com.matt.forgehax.util.command.Setting;
import com.matt.forgehax.util.mod.Category;
import com.matt.forgehax.util.mod.ToggleMod;
import com.matt.forgehax.util.mod.loader.RegisterMod;
@@ -20,6 +21,16 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class StepMod extends ToggleMod {
public static final float DEFAULT_STEP_HEIGHT = 0.6f;
+ public final Setting<Float> stepHeight =
+ getCommandStub()
+ .builders()
+ .<Float>newSettingBuilder()
+ .name("height")
+ .description("how high you can step")
+ .defaultTo(1.2f)
+ .min(0f)
+ .build();
+
public StepMod() {
super(Category.PLAYER, "Step", false, "Step up blocks");
}
@@ -35,7 +46,7 @@ public class StepMod extends ToggleMod {
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
EntityPlayer localPlayer = (EntityPlayer) event.getEntityLiving();
if (localPlayer.onGround) {
- localPlayer.stepHeight = 1.f;
+ localPlayer.stepHeight = stepHeight.getAsFloat();
} else {
localPlayer.stepHeight = DEFAULT_STEP_HEIGHT;
}
@@ -77,4 +88,9 @@ public class StepMod extends ToggleMod {
previousPositionPacket = (CPacketPlayer) event.getPacket();
}
}
+
+ @Override
+ public String getDisplayText() {
+ return String.format("%s[%s]", super.getDisplayText(), stepHeight.get().toString());
+ }
}
