Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Июн 2025
- Сообщения
- 12
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
Перенёс с Monoton 2.1
Java:
package im.expensive.functions.impl.movement;
import com.google.common.eventbus.Subscribe;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MoveUtils;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.util.math.vector.Vector3d;
@FunctionRegister(name = "ElytraFly", type = Category.Movement)
public class ElytraJump extends Function {
private final BooleanSetting auto = new BooleanSetting("Умный свап", false);
private boolean hasFiredOnStart = false;
public ElytraJump() {
this.addSettings(auto);
}
private int getItemSlot(Item item) {
int finalSlot = -1;
for (int i = 0; i < 36; ++i) {
if (mc.player.inventory.getStackInSlot(i).getItem() == item) {
finalSlot = i;
break;
}
}
if (finalSlot < 9 && finalSlot != -1) {
finalSlot += 36;
}
return finalSlot;
}
private int getChestPlateSlot() {
Item[] items = {
Items.NETHERITE_CHESTPLATE, Items.DIAMOND_CHESTPLATE, Items.GOLDEN_CHESTPLATE,
Items.IRON_CHESTPLATE, Items.LEATHER_CHESTPLATE, Items.CHAINMAIL_CHESTPLATE
};
for (Item item : items) {
for (int i = 0; i < 36; ++i) {
Item stack = mc.player.inventory.getStackInSlot(i).getItem();
if (stack == item) {
if (i < 9) {
i += 36;
}
return i;
}
}
}
return -1;
}
@Subscribe
public void onEvent(EventUpdate event) {
if (!mc.player.abilities.isFlying
&& mc.player.isOnGround()
&& !mc.player.isInWater()
&& !mc.player.isInLava()
&& mc.player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == Items.ELYTRA
&& !mc.gameSettings.keyBindJump.isKeyDown()) {
mc.player.jump();
}
if (!mc.player.abilities.isFlying
&& !mc.player.isOnGround()
&& !mc.player.isInWater()
&& !mc.player.isElytraFlying()
&& mc.player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == Items.ELYTRA) {
mc.player.startFallFlying();
mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_FALL_FLYING));
}
if (mc.player.isOnGround() || mc.player.isInWater() || mc.player.isInLava()) {
hasFiredOnStart = false;
}
if (mc.player.hurtTime > 0 && auto.get()
&& mc.player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == Items.ELYTRA) {
swapToChestplate();
return;
}
if (mc.player.movementInput != null
&& getItemSlot(Items.ELYTRA) == 38
&& mc.player.movementInput.jump
&& !mc.player.isElytraFlying()) {
mc.player.movementInput.jump = false;
}
if (mc.player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == Items.ELYTRA) {
MoveUtils.setMotion(0);
mc.gameSettings.keyBindJump.setPressed(true);
if (mc.player.isElytraFlying()) {
mc.player.setMotion(mc.player.getMotion().x, mc.player.getMotion().y + MathUtil.random(0.06f, 0.061f), mc.player.getMotion().z);
}
} else if (auto.get()) {
swapToElytra();
}
}
@Subscribe
public void onEvent(EventMotion event) {
if (mc.player.isElytraFlying()) {
im.expensive.functions.impl.combat.KillAura killAura = im.expensive.Expensive.getInstance().getFunctionRegistry().getKillAura();
float targetYaw = killAura != null && killAura.isState() && killAura.getTarget() != null ?
killAura.getTarget().rotationYaw : mc.player.rotationYaw;
float targetPitch = 0.0f;
event.setYaw(targetYaw);
event.setPitch(targetPitch);
mc.player.rotationYaw = targetYaw;
mc.player.rotationPitch = targetPitch;
mc.player.rotationYawHead = targetYaw;
mc.player.renderYawOffset = targetYaw;
}
}
@override
public void onEnable() {
hasFiredOnStart = false;
if (auto.get()) {
swapToElytra();
}
super.onEnable();
}
@override
public void onDisable() {
if (auto.get() && mc.player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == Items.ELYTRA) {
swapToChestplate();
}
super.onDisable();
}
private void swapToElytra() {
int elytraSlot = getItemSlot(Items.ELYTRA);
if (elytraSlot != -1) {
InventoryUtil.moveItem(elytraSlot, 6);
}
}
private void swapToChestplate() {
int chestplateSlot = getChestPlateSlot();
if (chestplateSlot != -1) {
InventoryUtil.moveItem(chestplateSlot, 6);
}
}
}
