Skip to content

Commit

Permalink
simplify elytra events
Browse files Browse the repository at this point in the history
  • Loading branch information
UpcraftLP committed Apr 23, 2024
1 parent 772e04d commit fdf4e9f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,7 @@ public void onInitialize() {
return false;
};

EntityElytraEvents.CUSTOM.register((entity, tickElytra) -> {
var component = TrinketsApi.getTrinketComponent(entity);
if (component.isPresent()) {
var items = component.orElseThrow().getEquipped(stack -> stack.getItem() instanceof WingItem);
if (!items.isEmpty()) {
var slot = items.get(0);
var stack = slot.getB();
var copy = stack.copy();
if (!stack.isEmpty() && IcarusHelper.onFallFlyingTick(entity, stack, tickElytra)) {
if(!ItemStack.matches(stack, copy)) {
slot.getA().inventory().markUpdate();
}
return true;
}
}
}

return false;
});
EntityElytraEvents.CUSTOM.register((entity, tickElytra) -> IcarusHelper.onFallFlyingTick(entity, IcarusHelper.getEquippedWings(entity), tickElytra));

ServerLifecycleEvents.SERVER_STARTING.register(Icarus::onServerStart);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,7 @@ public void onInitialize(ModContainer mod) {
return false;
};

EntityElytraEvents.CUSTOM.register((entity, tickElytra) -> {
var component = TrinketsApi.getTrinketComponent(entity);
if (component.isPresent()) {
var items = component.orElseThrow().getEquipped(stack -> stack.getItem() instanceof WingItem);
if (!items.isEmpty()) {
var slot = items.get(0);
var stack = slot.getB();
var copy = stack.copy();
if (!stack.isEmpty() && IcarusHelper.onFallFlyingTick(entity, stack, tickElytra)) {
if (!ItemStack.matches(stack, copy)) {
slot.getA().inventory().markUpdate();
}
return true;
}
}
}

return false;
});
EntityElytraEvents.CUSTOM.register((entity, tickElytra) -> IcarusHelper.onFallFlyingTick(entity, IcarusHelper.getEquippedWings(entity), tickElytra));

ServerEntityTickCallback.EVENT.register((entity, isPassengerTick) -> {
if (!isPassengerTick && entity instanceof Player player) {
Expand Down

0 comments on commit fdf4e9f

Please sign in to comment.