Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Jun 9, 2024
1 parent d0caae2 commit c40e769
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
import top.theillusivec4.curios.api.CuriosApi;
import top.theillusivec4.curios.api.SlotResult;

import java.util.Optional;

import static com.leclowndu93150.flightutils.common.AngelRingModules.getInertiaModifier;
import static com.leclowndu93150.flightutils.common.AngelRingModules.getMiningSpeedModifier;
Expand All @@ -20,10 +23,10 @@
public class AngelRingEvents {

@SubscribeEvent(priority = EventPriority.LOW)
public void setRingBreakSpeed(PlayerEvent.BreakSpeed event) {
public static void setRingBreakSpeed(PlayerEvent.BreakSpeed event) {
ItemStack angelRingStack = CuriosApi.getCuriosHelper().getCuriosHandler(event.getEntity()).get().findFirstCurio(ItemRegistry.ANGEL_RING.get()).get().stack();
float newDigSpeed = event.getOriginalSpeed();
if (getMiningSpeedModifier(angelRingStack) && !event.getEntity().onGround()){
if (getMiningSpeedModifier(angelRingStack) && !event.getEntity().onGround()) {
newDigSpeed *= 5f;
}
if (newDigSpeed != event.getOriginalSpeed()) {
Expand All @@ -32,14 +35,17 @@ public void setRingBreakSpeed(PlayerEvent.BreakSpeed event) {
}

@SubscribeEvent(priority = EventPriority.LOW)
public void stopDrift(PlayerTickEvent event) {
ItemStack angelRingStack = CuriosApi.getCuriosHelper().getCuriosHandler(event.getEntity()).get().findFirstCurio(ItemRegistry.ANGEL_RING.get()).get().stack();
Vec3 motion = event.getEntity().getDeltaMovement();
if(event.getEntity().getAbilities().flying && getInertiaModifier(angelRingStack)){
Options opt = Minecraft.getInstance().options;
if (!opt.keyUp.isDown() && !opt.keyDown.isDown() && !opt.keyLeft.isDown() && !opt.keyRight.isDown()) {
if (motion.x != 0 || motion.z != 0) {
event.getEntity().setDeltaMovement(0, motion.y, 0);
public static void stopDrift(PlayerTickEvent.Pre event) {
Optional<SlotResult> slotResult = CuriosApi.getCuriosHelper().getCuriosHandler(event.getEntity()).flatMap(curiosHandler -> curiosHandler.findFirstCurio(ItemRegistry.ANGEL_RING.get()));
if (slotResult.isPresent()) {
ItemStack angelRingStack = slotResult.get().stack();
Vec3 motion = event.getEntity().getDeltaMovement();
if (event.getEntity().getAbilities().flying && getInertiaModifier(angelRingStack)) {
Options opt = Minecraft.getInstance().options;
if (!opt.keyUp.isDown() && !opt.keyDown.isDown() && !opt.keyLeft.isDown() && !opt.keyRight.isDown()) {
if (motion.x != 0 || motion.z != 0) {
event.getEntity().setDeltaMovement(0, motion.y, 0);
}
}
}
}
Expand Down

0 comments on commit c40e769

Please sign in to comment.