Merge pull request #63 from bush-did-711/master

Added ElytraDisable option to NoFall
This commit is contained in:
noil 2021-04-19 23:24:22 -04:00 committed by GitHub
commit 6a34ad04d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -3,6 +3,7 @@ package me.rigamortis.seppuku.impl.module.movement;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.client.CPacketPlayer;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -13,18 +14,32 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
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() {
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
public void sendPacket(EventSendPacket event) {
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();
packet.onGround = true;
}
}
}
}
}