still doesn't compile, but now feat. registries
This commit is contained in:
parent
61926ca299
commit
a9c8be1212
22 changed files with 249 additions and 96 deletions
|
@ -1,35 +1,35 @@
|
|||
package at.petrak.hexcasting.api.spell
|
||||
|
||||
import at.petrak.hexcasting.api.spell.datum.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.datum.Iota
|
||||
|
||||
/**
|
||||
* Restricted interface for functional lists.
|
||||
*
|
||||
* ...Surely this won't have any performance implications.
|
||||
*/
|
||||
sealed class SpellList : Iterable<SpellDatum> {
|
||||
sealed class SpellList : Iterable<Iota> {
|
||||
|
||||
abstract val nonEmpty: Boolean
|
||||
abstract val car: SpellDatum
|
||||
abstract val car: Iota
|
||||
abstract val cdr: SpellList
|
||||
|
||||
class LPair(override val car: SpellDatum, override val cdr: SpellList) : SpellList() {
|
||||
class LPair(override val car: Iota, override val cdr: SpellList) : SpellList() {
|
||||
override val nonEmpty = true
|
||||
}
|
||||
|
||||
class LList(val idx: Int, val list: List<SpellDatum>) : SpellList() {
|
||||
class LList(val idx: Int, val list: List<Iota>) : SpellList() {
|
||||
override val nonEmpty: Boolean
|
||||
get() = idx < list.size
|
||||
override val car: SpellDatum
|
||||
override val car: Iota
|
||||
get() = list[idx]
|
||||
override val cdr: SpellList
|
||||
get() = LList(idx + 1, list)
|
||||
|
||||
constructor(list: List<SpellDatum>) : this(0, list)
|
||||
constructor(list: List<Iota>) : this(0, list)
|
||||
}
|
||||
|
||||
fun modifyAt(startIdx: Int, modify: (SpellList) -> SpellList): SpellList {
|
||||
val stack = mutableListOf<SpellDatum>()
|
||||
val stack = mutableListOf<Iota>()
|
||||
val ptr = iterator()
|
||||
var idx = startIdx
|
||||
if (idx < 0) {
|
||||
|
@ -49,7 +49,7 @@ sealed class SpellList : Iterable<SpellDatum> {
|
|||
return value
|
||||
}
|
||||
|
||||
fun getAt(startIdx: Int): SpellDatum {
|
||||
fun getAt(startIdx: Int): Iota {
|
||||
var ptr = this
|
||||
var idx = startIdx
|
||||
if (idx < 0) {
|
||||
|
@ -69,9 +69,9 @@ sealed class SpellList : Iterable<SpellDatum> {
|
|||
|
||||
override fun iterator() = SpellListIterator(this)
|
||||
|
||||
class SpellListIterator(var list: SpellList) : Iterator<SpellDatum> {
|
||||
class SpellListIterator(var list: SpellList) : Iterator<Iota> {
|
||||
override fun hasNext() = list.nonEmpty
|
||||
override operator fun next(): SpellDatum {
|
||||
override operator fun next(): Iota {
|
||||
val car = list.car
|
||||
list = list.cdr
|
||||
return car
|
||||
|
|
|
@ -9,7 +9,7 @@ import at.petrak.hexcasting.api.mod.HexConfig
|
|||
import at.petrak.hexcasting.api.mod.HexItemTags
|
||||
import at.petrak.hexcasting.api.mod.HexStatistics
|
||||
import at.petrak.hexcasting.api.spell.*
|
||||
import at.petrak.hexcasting.api.spell.datum.SpellDatum
|
||||
import at.petrak.hexcasting.api.spell.datum.Iota
|
||||
import at.petrak.hexcasting.api.spell.math.HexDir
|
||||
import at.petrak.hexcasting.api.spell.math.HexPattern
|
||||
import at.petrak.hexcasting.api.spell.mishaps.*
|
||||
|
@ -238,7 +238,7 @@ class CastingHarness private constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun generateDescs() = stack.map(SpellDatum::display)
|
||||
fun generateDescs() = stack.map(Iota::display)
|
||||
|
||||
/**
|
||||
* Return the functional update represented by the current state (for use with `copy`)
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DatumDouble extends SpellDatum {
|
||||
public class DatumDouble extends Iota {
|
||||
public static final double TOLERANCE = 0.0001;
|
||||
|
||||
public DatumDouble(double d) {
|
||||
|
@ -15,11 +15,11 @@ public class DatumDouble extends SpellDatum {
|
|||
}
|
||||
|
||||
public double getDouble() {
|
||||
return (Double) this.datum;
|
||||
return (Double) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsOther(SpellDatum that) {
|
||||
public boolean toleratesOther(Iota that) {
|
||||
return that instanceof DatumDouble dd && Math.abs(this.getDouble() - dd.getDouble()) < TOLERANCE;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class DatumDouble extends SpellDatum {
|
|||
return DoubleTag.valueOf(this.getDouble());
|
||||
}
|
||||
|
||||
public static SpellDatum.Type<DatumDouble> TYPE = new Type<>() {
|
||||
public static IotaType<DatumDouble> TYPE = new IotaType<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public DatumDouble deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException {
|
||||
|
|
|
@ -8,17 +8,17 @@ import net.minecraft.world.entity.Entity;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DatumEntity extends SpellDatum {
|
||||
public class DatumEntity extends Iota {
|
||||
protected DatumEntity(@NotNull Entity e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return (Entity) this.datum;
|
||||
return (Entity) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsOther(SpellDatum that) {
|
||||
public boolean toleratesOther(Iota that) {
|
||||
return that instanceof DatumEntity dent && this.getEntity() == dent.getEntity();
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ public class DatumEntity extends SpellDatum {
|
|||
return out;
|
||||
}
|
||||
|
||||
public static SpellDatum.Type<DatumEntity> TYPE = new Type<>() {
|
||||
public static IotaType<DatumEntity> TYPE = new IotaType<>() {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
|
|
|
@ -8,17 +8,17 @@ import org.jetbrains.annotations.NotNull;
|
|||
/**
|
||||
* Similar to {@link DatumWidget}, this is a <i>wrapper</i> for {@link SpellList}.
|
||||
*/
|
||||
public class DatumList extends SpellDatum {
|
||||
public class DatumList extends Iota {
|
||||
public DatumList(@NotNull SpellList list) {
|
||||
super(list);
|
||||
}
|
||||
|
||||
public SpellList getList() {
|
||||
return (SpellList) this.datum;
|
||||
return (SpellList) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsOther(SpellDatum that) {
|
||||
public boolean toleratesOther(Iota that) {
|
||||
var a = this.getList();
|
||||
if (!(that instanceof DatumList list)) {
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ public class DatumList extends SpellDatum {
|
|||
// one remains full before the other
|
||||
return false;
|
||||
}
|
||||
SpellDatum x = aIter.next(), y = bIter.next();
|
||||
Iota x = aIter.next(), y = bIter.next();
|
||||
if (!SpellDatums.equalsWithTolerance(x, y)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package at.petrak.hexcasting.api.spell.datum;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DatumNull extends Iota {
|
||||
private static final Object NULL_SUBSTITUTE = new Object();
|
||||
|
||||
public DatumNull() {
|
||||
super(NULL_SUBSTITUTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toleratesOther(Iota that) {
|
||||
return that instanceof DatumNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Tag serialize() {
|
||||
return new CompoundTag();
|
||||
}
|
||||
|
||||
public static IotaType<DatumNull> TYPE = new IotaType<>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public DatumNull deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException {
|
||||
return new DatumNull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component display(Tag tag) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int color() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
|
@ -4,13 +4,13 @@ import at.petrak.hexcasting.api.spell.math.HexPattern;
|
|||
import net.minecraft.nbt.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DatumPattern extends SpellDatum {
|
||||
public class DatumPattern extends Iota {
|
||||
public DatumPattern(@NotNull HexPattern pattern) {
|
||||
super(pattern);
|
||||
}
|
||||
|
||||
public HexPattern getPattern() {
|
||||
return (HexPattern) this.datum;
|
||||
return (HexPattern) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,13 +4,13 @@ import net.minecraft.nbt.Tag;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DatumVec3 extends SpellDatum {
|
||||
public class DatumVec3 extends Iota {
|
||||
public DatumVec3(@NotNull Vec3 datum) {
|
||||
super(datum);
|
||||
}
|
||||
|
||||
public Vec3 getVec3() {
|
||||
return (Vec3) this.datum;
|
||||
return (Vec3) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,13 +7,13 @@ import org.jetbrains.annotations.NotNull;
|
|||
/**
|
||||
* Note this is different than the widget itself; this is a widget wrapper.
|
||||
*/
|
||||
public class DatumWidget extends SpellDatum {
|
||||
public class DatumWidget extends Iota {
|
||||
public DatumWidget(@NotNull Widget widget) {
|
||||
super(widget);
|
||||
}
|
||||
|
||||
public Widget getWidget() {
|
||||
return (Widget) this.datum;
|
||||
return (Widget) this.payload;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package at.petrak.hexcasting.api.spell.datum;
|
||||
|
||||
import net.minecraft.nbt.Tag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class Iota {
|
||||
@NotNull
|
||||
protected final Object payload;
|
||||
|
||||
protected Iota(@NotNull Object payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public @NotNull Object getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare this to another object, within a tolerance.
|
||||
* <p>
|
||||
* Don't call this directly; use {@link SpellDatums#equalsWithTolerance}.
|
||||
*/
|
||||
abstract public boolean toleratesOther(Iota that);
|
||||
|
||||
|
||||
abstract public @NotNull Tag serialize();
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package at.petrak.hexcasting.api.spell.datum;
|
||||
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
// Take notes from ForgeRegistryEntry
|
||||
public abstract class IotaType<T extends Iota> {
|
||||
/**
|
||||
* Spell datums are stored as such: {@code { "type": "modid:type", "datum": a_tag }}.
|
||||
* <p>
|
||||
* The {@code type} key is given when registering the spell datum type; this method
|
||||
* deserializes the tag associated with {@code "datum"}.
|
||||
* <p>
|
||||
* Returning {@code null} makes the resulting datum be {@link at.petrak.hexcasting.api.spell.Widget Widget.NULL}.
|
||||
* Throwing an exception raises a mishap.
|
||||
*/
|
||||
@Nullable
|
||||
abstract T deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get a display of this datum from the tag, <i>without</i> the world.
|
||||
* This is for use on the client.
|
||||
*/
|
||||
abstract Component display(Tag tag);
|
||||
|
||||
/**
|
||||
* Get the color associated with this datum type.
|
||||
*/
|
||||
abstract int color();
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package at.petrak.hexcasting.api.spell.datum;
|
||||
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class SpellDatum {
|
||||
@NotNull
|
||||
protected final Object datum;
|
||||
|
||||
protected SpellDatum(@NotNull Object datum) {
|
||||
this.datum = datum;
|
||||
}
|
||||
|
||||
public @NotNull Object getDatum() {
|
||||
return datum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare this to another object, within a tolerance.
|
||||
* <p>
|
||||
* Don't call this directly; use {@link SpellDatums#equalsWithTolerance}.
|
||||
*/
|
||||
abstract public boolean equalsOther(SpellDatum that);
|
||||
|
||||
|
||||
abstract public @NotNull Tag serialize();
|
||||
|
||||
public interface Type<T extends SpellDatum> {
|
||||
/**
|
||||
* Spell datums are stored as such: {@code { "type": "modid:type", "datum": a_tag }}.
|
||||
* <p>
|
||||
* The {@code type} key is given when registering the spell datum type; this method
|
||||
* deserializes the tag associated with {@code "datum"}.
|
||||
* <p>
|
||||
* Returning {@code null} makes the resulting datum be {@link at.petrak.hexcasting.api.spell.Widget Widget.NULL}.
|
||||
* Throwing an exception raises a mishap.
|
||||
*/
|
||||
@Nullable
|
||||
T deserialize(Tag tag, ServerLevel world) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Get a display of this datum from the tag, <i>without</i> the world.
|
||||
* This is for use on the client.
|
||||
*/
|
||||
Component display(Tag tag);
|
||||
|
||||
/**
|
||||
* Get the color associated with this datum type.
|
||||
*/
|
||||
int color();
|
||||
}
|
||||
}
|
|
@ -15,13 +15,13 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SpellDatums {
|
||||
private static final Map<ResourceLocation, SpellDatum.Type<?>> controllers = new ConcurrentHashMap<>();
|
||||
private static final Map<ResourceLocation, IotaType<?>> controllers = new ConcurrentHashMap<>();
|
||||
|
||||
public static final String
|
||||
TAG_TYPE = HexAPI.MOD_ID + ":type",
|
||||
TAG_DATA = HexAPI.MOD_ID + ":data";
|
||||
|
||||
public static SpellDatum deserializeFromRootTag(CompoundTag tag,
|
||||
public static Iota deserializeFromRootTag(CompoundTag tag,
|
||||
ServerLevel world) throws IllegalArgumentException {
|
||||
if (tag.contains(TAG_TYPE, Tag.TAG_STRING) && tag.contains(TAG_DATA)) {
|
||||
var typeKey = new ResourceLocation(tag.getString(TAG_TYPE));
|
||||
|
@ -47,11 +47,11 @@ public class SpellDatums {
|
|||
throw new IllegalArgumentException("could not deserialize this tag: " + tag);
|
||||
}
|
||||
|
||||
public static boolean equalsWithTolerance(SpellDatum a, SpellDatum b) {
|
||||
return a == b || a.equalsOther(b) || b.equalsOther(a);
|
||||
public static boolean equalsWithTolerance(Iota a, Iota b) {
|
||||
return a == b || a.toleratesOther(b) || b.toleratesOther(a);
|
||||
}
|
||||
|
||||
private static SpellDatum legacyDeserialize(String key, Tag inner,
|
||||
private static Iota legacyDeserialize(String key, Tag inner,
|
||||
ServerLevel world) throws IllegalArgumentException {
|
||||
return switch (key) {
|
||||
case "entity" -> {
|
||||
|
@ -66,7 +66,7 @@ public class SpellDatums {
|
|||
case "vec3" -> new DatumVec3(HexUtils.vecFromNBT(((LongArrayTag) inner).getAsLongArray()));
|
||||
case "list" -> {
|
||||
var listTag = (ListTag) inner;
|
||||
var out = new ArrayList<SpellDatum>();
|
||||
var out = new ArrayList<Iota>();
|
||||
for (var subtag : listTag) {
|
||||
var subdatum = deserializeFromRootTag((CompoundTag) subtag, world);
|
||||
out.add(subdatum);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package at.petrak.hexcasting.common.lib;
|
||||
|
||||
import at.petrak.hexcasting.api.spell.datum.*;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class HexIotaTypes {
|
||||
public static final Registry<IotaType<?>> REGISTRY = IXplatAbstractions.INSTANCE.getIotaTypeRegistry();
|
||||
|
||||
public static void registerTypes() {
|
||||
BiConsumer<IotaType<?>, ResourceLocation> r = (type, id) -> Registry.register(REGISTRY, id, type);
|
||||
for (var e : TYPES.entrySet()) {
|
||||
r.accept(e.getValue(), e.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<ResourceLocation, IotaType<?>> TYPES = new LinkedHashMap<>();
|
||||
|
||||
public static final IotaType<DatumNull> NULL = type("null", DatumNull.TYPE);
|
||||
public static final IotaType<DatumDouble> DOUBLE = type("double", DatumDouble.TYPE);
|
||||
public static final IotaType<DatumEntity> ENTITY = type("entity", DatumEntity.TYPE);
|
||||
|
||||
private static <U extends Iota, T extends IotaType<U>> T type(String name, T type) {
|
||||
var old = TYPES.put(modLoc(name), type);
|
||||
if (old != null) {
|
||||
throw new IllegalArgumentException("Typo? Duplicate id " + name);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -9,9 +9,11 @@ import at.petrak.hexcasting.api.player.FlightAbility;
|
|||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.api.spell.datum.IotaType;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.interop.pehkui.PehkuiInterop;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
@ -143,6 +145,8 @@ public interface IXplatAbstractions {
|
|||
|
||||
String getModName(String namespace);
|
||||
|
||||
Registry<IotaType<?>> getIotaTypeRegistry();
|
||||
|
||||
// interop
|
||||
|
||||
PehkuiInterop.ApiAbstraction getPehkuiApi();
|
||||
|
|
|
@ -88,7 +88,11 @@ object FabricHexInitializer : ModInitializer {
|
|||
HexBlocks.registerBlockItems(bind(Registry.ITEM))
|
||||
HexBlockEntities.registerTiles(bind(Registry.BLOCK_ENTITY_TYPE))
|
||||
HexItems.registerItems(bind(Registry.ITEM))
|
||||
Registry.register(IngredientDeserializer.REGISTRY, modLoc("unsealed"), FabricUnsealedIngredient.Deserializer.INSTANCE)
|
||||
Registry.register(
|
||||
IngredientDeserializer.REGISTRY,
|
||||
modLoc("unsealed"),
|
||||
FabricUnsealedIngredient.Deserializer.INSTANCE
|
||||
)
|
||||
|
||||
HexEntities.registerEntities(bind(Registry.ENTITY_TYPE))
|
||||
|
||||
|
@ -97,6 +101,9 @@ object FabricHexInitializer : ModInitializer {
|
|||
|
||||
HexLootFunctions.registerSerializers(bind(Registry.LOOT_FUNCTION_TYPE))
|
||||
|
||||
HexIotaTypes.registerTypes()
|
||||
|
||||
|
||||
// Done with soft implements in forge
|
||||
val flameOn = FlammableBlockRegistry.getDefaultInstance()
|
||||
for (log in listOf(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package at.petrak.hexcasting.fabric.xplat;
|
||||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.api.addldata.DataHolder;
|
||||
import at.petrak.hexcasting.api.addldata.HexHolder;
|
||||
import at.petrak.hexcasting.api.addldata.ManaHolder;
|
||||
|
@ -10,6 +11,7 @@ import at.petrak.hexcasting.api.player.FlightAbility;
|
|||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.api.spell.datum.IotaType;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.fabric.cc.HexCardinalComponents;
|
||||
|
@ -22,8 +24,10 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
|||
import at.petrak.hexcasting.xplat.IXplatTags;
|
||||
import at.petrak.hexcasting.xplat.Platform;
|
||||
import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder;
|
||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
|
@ -38,9 +42,11 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -357,6 +363,19 @@ public class FabricXplatImpl implements IXplatAbstractions {
|
|||
return namespace;
|
||||
}
|
||||
|
||||
private static Registry<IotaType<?>> IOTA_TYPE_REGISTRY = null;
|
||||
|
||||
@Override
|
||||
public Registry<IotaType<?>> getIotaTypeRegistry() {
|
||||
if (IOTA_TYPE_REGISTRY == null) {
|
||||
IOTA_TYPE_REGISTRY = FabricRegistryBuilder.from(new DefaultedRegistry<IotaType<?>>(
|
||||
HexAPI.MOD_ID + ":null", ResourceKey.createRegistryKey(modLoc("iota_type")),
|
||||
Lifecycle.stable(), null))
|
||||
.buildAndRegister();
|
||||
}
|
||||
return IOTA_TYPE_REGISTRY;
|
||||
}
|
||||
|
||||
private static PehkuiInterop.ApiAbstraction PEHKUI_API = null;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,6 +101,8 @@ public class ForgeHexInitializer {
|
|||
|
||||
bind(ForgeRegistries.PARTICLE_TYPES, HexParticles::registerParticles);
|
||||
|
||||
HexIotaTypes.registerTypes();
|
||||
|
||||
ArgumentTypes.register(HexAPI.MOD_ID + ":pattern", PatternResLocArgument.class,
|
||||
new EmptyArgumentSerializer<>(PatternResLocArgument::id));
|
||||
HexAdvancementTriggers.registerTriggers();
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package at.petrak.hexcasting.forge.mixin;
|
||||
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Registry.class)
|
||||
public interface ForgeAccessorRegistry {
|
||||
@Invoker("registerDefaulted")
|
||||
static <T> DefaultedRegistry<T> hex$registerDefaulted(ResourceKey<? extends Registry<T>> registryName,
|
||||
String defaultId,
|
||||
Registry.RegistryBootstrap<T> bootstrap) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
|
@ -12,11 +12,14 @@ import at.petrak.hexcasting.api.player.Sentinel;
|
|||
import at.petrak.hexcasting.api.spell.casting.CastingContext;
|
||||
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
|
||||
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
|
||||
import at.petrak.hexcasting.api.spell.datum.IotaType;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.common.lib.HexIotaTypes;
|
||||
import at.petrak.hexcasting.common.lib.HexItems;
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.forge.cap.CapSyncers;
|
||||
import at.petrak.hexcasting.forge.cap.HexCapabilities;
|
||||
import at.petrak.hexcasting.forge.mixin.ForgeAccessorRegistry;
|
||||
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
||||
import at.petrak.hexcasting.forge.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.forge.recipe.ForgeUnsealedIngredient;
|
||||
|
@ -67,8 +70,8 @@ import net.minecraftforge.common.loot.CanToolPerformAction;
|
|||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.loading.FMLLoader;
|
||||
import net.minecraftforge.network.NetworkDirection;
|
||||
|
@ -81,6 +84,8 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class ForgeXplatImpl implements IXplatAbstractions {
|
||||
@Override
|
||||
public Platform platform() {
|
||||
|
@ -402,6 +407,18 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return namespace;
|
||||
}
|
||||
|
||||
private static Registry<IotaType<?>> IOTA_TYPE_REGISTRY = null;
|
||||
|
||||
@Override
|
||||
public Registry<IotaType<?>> getIotaTypeRegistry() {
|
||||
if (IOTA_TYPE_REGISTRY == null) {
|
||||
IOTA_TYPE_REGISTRY = ForgeAccessorRegistry.hex$registerDefaulted(
|
||||
ResourceKey.createRegistryKey(modLoc("iota_type")),
|
||||
HexAPI.MOD_ID + ":null", registry -> HexIotaTypes.NULL);
|
||||
}
|
||||
return IOTA_TYPE_REGISTRY;
|
||||
}
|
||||
|
||||
// it's literally the EXACT SAME on fabric aaa
|
||||
private static PehkuiInterop.ApiAbstraction PEHKUI_API = null;
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
public net.minecraft.client.renderer.RenderType$CompositeRenderType
|
||||
public net.minecraft.client.renderer.RenderType$CompositeState f_110576_ # textureState
|
||||
public net.minecraft.core.Registry$RegistryBootstrap
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"refmap": "hexcasting.mixins.refmap.json",
|
||||
"package": "at.petrak.hexcasting.forge.mixin",
|
||||
"mixins": ["ForgeMixinCursedRecipeSerializerBase"]
|
||||
"mixins": ["ForgeAccessorRegistry", "ForgeMixinCursedRecipeSerializerBase"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue