Added ElytraDisable option to NoFall
This commit is contained in:
parent
400f791e7a
commit
818a3d7c2b
|
@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.module.movement;
|
||||||
import me.rigamortis.seppuku.api.event.EventStageable;
|
import me.rigamortis.seppuku.api.event.EventStageable;
|
||||||
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
|
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
|
||||||
import me.rigamortis.seppuku.api.module.Module;
|
import me.rigamortis.seppuku.api.module.Module;
|
||||||
|
import me.rigamortis.seppuku.api.value.Value;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.play.client.CPacketPlayer;
|
import net.minecraft.network.play.client.CPacketPlayer;
|
||||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||||
|
@ -13,14 +14,28 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||||
*/
|
*/
|
||||||
public final class NoFallModule extends Module {
|
public final class NoFallModule extends Module {
|
||||||
|
|
||||||
|
public final Value<Boolean> elytraDisable = new Value<Boolean>("ElytraDisable", new String[]{"noelytra", "elytra", "disableonelytrafly"}, "Disables NoFall when the player is flying.", true);
|
||||||
|
|
||||||
public NoFallModule() {
|
public NoFallModule() {
|
||||||
super("NoFall", new String[]{"NoFallDamage"}, "Prevents fall damage", "NONE", -1, ModuleType.MOVEMENT);
|
super("NoFall", new String[]{"NoFallDamage"}, "Prevents fall damage", "NONE", -1, ModuleType.MOVEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isFlying() {
|
||||||
|
if (this.elytraDisable.getValue()) {
|
||||||
|
if (Minecraft.getMinecraft().player.isElytraFlying()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void sendPacket(EventSendPacket event) {
|
public void sendPacket(EventSendPacket event) {
|
||||||
if (event.getStage() == EventStageable.EventStage.PRE) {
|
if (event.getStage() == EventStageable.EventStage.PRE) {
|
||||||
if (event.getPacket() instanceof CPacketPlayer && Minecraft.getMinecraft().player.fallDistance >= 3.0f) {
|
if (event.getPacket() instanceof CPacketPlayer && Minecraft.getMinecraft().player.fallDistance >= 3.0f && !this.isFlying()) {
|
||||||
final CPacketPlayer packet = (CPacketPlayer) event.getPacket();
|
final CPacketPlayer packet = (CPacketPlayer) event.getPacket();
|
||||||
packet.onGround = true;
|
packet.onGround = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue