Fix rocket elytra in curio slot.
KostromDan opened this issue ยท 1 comments
#3935
You closed this issue as completed, but it not fixed in the lastest verson.
Since my modpack needs this feature and a year later the fix didn't happen, I implemented this feature myself using kubejs.
Now all what you need to do to finally fix this issue is implement in Java function is_curious_contains_working_elytra
and add check (is_curious_contains_working_elytra(event) || event.player.getItemBySlot($EquipmentSlot.CHEST).canElytraFly(event.player))
Instead of just event.player.getItemBySlot($EquipmentSlot.CHEST).canElytraFly(event.player)
https://github.com/VazkiiMods/Quark/blob/master/src/main/java/vazkii/quark/content/tweaks/module/BetterElytraRocketModule.java
const $EquipmentSlot = Java.loadClass('net.minecraft.world.entity.EquipmentSlot')
const $FireworkRocketItem = Java.loadClass('net.minecraft.world.item.FireworkRocketItem')
const $FireworkRocketEntity = Java.loadClass('net.minecraft.world.entity.projectile.FireworkRocketEntity')
const $Vec3 = Java.loadClass('net.minecraft.world.phys.Vec3')
function setDeltaMovement(player, x, y, z) {
player.setDeltaMovement(new $Vec3(x, y, z))
player.hurtMarked = true
}
function addDeltaMovement(player, x, y, z) {
player.setDeltaMovement(player.getDeltaMovement().add(new $Vec3(x, y, z)))
player.hurtMarked = true
}
function is_curious_contains_working_elytra(event) {
const api = new CuriosApi();
const curios = api.getCuriosHelper().getEquippedCurios(event.player).resolve().get();
for (let slot = 0; slot < curios.getSlots(); slot++) {
if (curios.getStackInSlot(slot).canElytraFly(event.player)) {
return true
}
}
return false
}
function process_elytra(event) {
if (event.item.getItem() instanceof $FireworkRocketItem &&
!event.player.isFallFlying() &&
(is_curious_contains_working_elytra(event) ||
event.player.getItemBySlot($EquipmentSlot.CHEST).canElytraFly(event.player))) {
event.cancel()
addDeltaMovement(event.player, 0, 0.5, 0)
event.server.scheduleInTicks(2, callback => {
event.player.startFallFlying()
event.level.addFreshEntity(new $FireworkRocketEntity(event.level, event.item, event.player))
})
if (!event.player.getAbilities().instabuild) event.item.shrink(1);
}
}
ItemEvents.rightClicked(event => {
process_elytra(event)
})
BlockEvents.rightClicked(event => {
process_elytra(event)
})