Skip to content

Commit

Permalink
fix default magic data attachment having null server player
Browse files Browse the repository at this point in the history
  • Loading branch information
iron431 committed Aug 10, 2024
1 parent 38816db commit ed5f147
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.redspace.ironsspellbooks.IronsSpellbooks;
import io.redspace.ironsspellbooks.api.magic.MagicData;
import io.redspace.ironsspellbooks.capabilities.magic.PlayerMagicProvider;
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.attachment.AttachmentType;
import net.neoforged.neoforge.registries.DeferredHolder;
Expand All @@ -18,5 +19,6 @@ public static void register(IEventBus eventBus) {
ATTACHMENT_TYPES.register(eventBus);
}

public static final DeferredHolder<AttachmentType<?>, AttachmentType<MagicData>> MAGIC_DATA = ATTACHMENT_TYPES.register("magic_data", () -> AttachmentType.builder(() -> new MagicData()).serialize(new PlayerMagicProvider()).build());
public static final DeferredHolder<AttachmentType<?>, AttachmentType<MagicData>> MAGIC_DATA = ATTACHMENT_TYPES.register("magic_data",
() -> AttachmentType.builder((holder) -> holder instanceof ServerPlayer serverPlayer ? new MagicData(serverPlayer) : new MagicData()).serialize(new PlayerMagicProvider()).build());
}

0 comments on commit ed5f147

Please sign in to comment.