import client.event.events.EventPacket;
import client.event.events.EventUpdate;
import client.module.Category;
import client.module.Module;
import client.module.player.NoFall;
import client.value.Value;
import net.minecraft.init.Blocks;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.CPacketPlayer;
public class NoFall extends Module {
public boolean wasOnGround;
public Value<String> mode = new Value("nofall_mode", "Mode", "Normal", new String[] { "Normal", "Damage", "Packet" });
public NoFall() {
super("NoFall", Category.PLAYER);
add(this.mode);
}
public void onUpdate(EventUpdate event) {
setTag((String)this.mode.getValue());
if (event.isPRE() && (
(String)this.mode.getValue()).equalsIgnoreCase("Packet") &&
mc.player.fallDistance >= 2.0F)
mc.player.connection.sendPacket((Packet)new CPacketPlayer(true));
}
public void onPacket(EventPacket event) {
if (event.isSend() &&
event.getPacket() instanceof CPacketPlayer) {
CPacketPlayer packet = (CPacketPlayer)event.getPacket();
String mode = (String)this.mode.getValue();
if (mode.equalsIgnoreCase("Normal")) {
if (mc.player.fallDistance > 3.0F)
packet.setOnGround(true);
} else if (mode.equalsIgnoreCase("Damage")) {
if (mc.player.fallDistance > 3.0F) {
double offset = -1.0D;
for (double d = 0.0D; d < 6.0D; d += 0.5D) {
if (mc.world.getBlockState(mc.player.getPosition().add(0.0D, mc.player.motionY - d, 0.0D)).getBlock() != Blocks.AIR) {
offset = d;
break;
}
}
if (offset < 0.0D) {
this.wasOnGround = true;
packet.setOnGround(true);
return;
}
if (offset > 3.5D) {
this.wasOnGround = true;
packet.setOnGround(true);
}
} else {
this.wasOnGround = false;
}
}
}
}
}