fixed up the registry nonsense and got forge actually able to get into the world!!!!!!
This commit is contained in:
parent
31ff708d80
commit
8501c4ce34
|
@ -12,6 +12,7 @@ import at.petrak.hexcasting.common.items.pigment.ItemPridePigment;
|
|||
import at.petrak.hexcasting.common.items.pigment.ItemUUIDPigment;
|
||||
import at.petrak.hexcasting.common.items.storage.*;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import com.google.common.base.Suppliers;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
|
@ -21,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
|
@ -86,24 +88,24 @@ public class HexItems {
|
|||
public static final ItemMediaBattery BATTERY = make("battery",
|
||||
new ItemMediaBattery(unstackable()), null);
|
||||
|
||||
public static final ItemStack BATTERY_DUST_STACK = addToTab(ItemMediaBattery.withMedia(
|
||||
public static final Supplier<ItemStack> BATTERY_DUST_STACK = addToTab(() -> ItemMediaBattery.withMedia(
|
||||
new ItemStack(HexItems.BATTERY),
|
||||
MediaConstants.DUST_UNIT * 64,
|
||||
MediaConstants.DUST_UNIT * 64), HexCreativeTabs.HEX);
|
||||
public static final ItemStack BATTERY_SHARD_STACK = addToTab(ItemMediaBattery.withMedia(
|
||||
public static final Supplier<ItemStack> BATTERY_SHARD_STACK = addToTab(() -> ItemMediaBattery.withMedia(
|
||||
new ItemStack(HexItems.BATTERY),
|
||||
MediaConstants.SHARD_UNIT * 64,
|
||||
MediaConstants.SHARD_UNIT * 64), HexCreativeTabs.HEX);
|
||||
public static final ItemStack BATTERY_CRYSTAL_STACK = addToTab(ItemMediaBattery.withMedia(
|
||||
public static final Supplier<ItemStack> BATTERY_CRYSTAL_STACK = addToTab(() -> ItemMediaBattery.withMedia(
|
||||
new ItemStack(HexItems.BATTERY),
|
||||
MediaConstants.CRYSTAL_UNIT * 64,
|
||||
MediaConstants.CRYSTAL_UNIT * 64), HexCreativeTabs.HEX);
|
||||
public static final ItemStack BATTERY_QUENCHED_SHARD_STACK = addToTab(ItemMediaBattery.withMedia(
|
||||
public static final Supplier<ItemStack> BATTERY_QUENCHED_SHARD_STACK = addToTab(() -> ItemMediaBattery.withMedia(
|
||||
new ItemStack(HexItems.BATTERY),
|
||||
MediaConstants.QUENCHED_SHARD_UNIT * 64,
|
||||
MediaConstants.QUENCHED_SHARD_UNIT * 64), HexCreativeTabs.HEX);
|
||||
|
||||
public static final ItemStack BATTERY_QUENCHED_BLOCK_STACK = addToTab(ItemMediaBattery.withMedia(
|
||||
public static final Supplier<ItemStack> BATTERY_QUENCHED_BLOCK_STACK = addToTab(() -> ItemMediaBattery.withMedia(
|
||||
new ItemStack(HexItems.BATTERY),
|
||||
MediaConstants.QUENCHED_BLOCK_UNIT * 64,
|
||||
MediaConstants.QUENCHED_BLOCK_UNIT * 64), HexCreativeTabs.HEX);
|
||||
|
@ -170,9 +172,10 @@ public class HexItems {
|
|||
return make(modLoc(id), item, HexCreativeTabs.HEX);
|
||||
}
|
||||
|
||||
private static ItemStack addToTab(ItemStack stack, CreativeModeTab tab) {
|
||||
ITEM_TABS.computeIfAbsent(tab, t -> new ArrayList<>()).add(new TabEntry.StackEntry(stack));
|
||||
return stack;
|
||||
private static Supplier<ItemStack> addToTab(Supplier<ItemStack> stack, CreativeModeTab tab) {
|
||||
var memoised = Suppliers.memoize(stack::get);
|
||||
ITEM_TABS.computeIfAbsent(tab, t -> new ArrayList<>()).add(new TabEntry.StackEntry(memoised));
|
||||
return memoised;
|
||||
}
|
||||
|
||||
private static abstract class TabEntry {
|
||||
|
@ -192,15 +195,15 @@ public class HexItems {
|
|||
}
|
||||
|
||||
static class StackEntry extends TabEntry {
|
||||
private final ItemStack stack;
|
||||
private final Supplier<ItemStack> stack;
|
||||
|
||||
StackEntry(ItemStack stack) {
|
||||
StackEntry(Supplier<ItemStack> stack) {
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
void register(CreativeModeTab.Output r) {
|
||||
r.accept(stack);
|
||||
r.accept(stack.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ dependencies {
|
|||
compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:$curiosVersion+$minecraftVersion:api")
|
||||
runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:$curiosVersion+$minecraftVersion")
|
||||
|
||||
api fg.deobf("com.github.Virtuoel:Pehkui:${pehkuiVersion}-1.19.4-forge")
|
||||
api fg.deobf("com.github.Virtuoel:Pehkui:${pehkuiVersion}-$minecraftVersion-forge")
|
||||
}
|
||||
|
||||
minecraft {
|
||||
|
|
|
@ -21,7 +21,6 @@ import at.petrak.hexcasting.common.recipe.HexRecipeStuffRegistry;
|
|||
import at.petrak.hexcasting.forge.cap.CapSyncers;
|
||||
import at.petrak.hexcasting.forge.cap.ForgeCapabilityHandler;
|
||||
import at.petrak.hexcasting.forge.datagen.ForgeHexDataGenerators;
|
||||
import at.petrak.hexcasting.forge.event.NewRegistryEventHandler;
|
||||
import at.petrak.hexcasting.forge.interop.curios.CuriosApiInterop;
|
||||
import at.petrak.hexcasting.forge.interop.curios.CuriosRenderers;
|
||||
import at.petrak.hexcasting.forge.lib.ForgeHexArgumentTypeRegistry;
|
||||
|
@ -32,6 +31,7 @@ import at.petrak.hexcasting.forge.recipe.ForgeModConditionalIngredient;
|
|||
import at.petrak.hexcasting.forge.recipe.ForgeUnsealedIngredient;
|
||||
import at.petrak.hexcasting.interop.HexInterop;
|
||||
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
|
@ -79,6 +79,7 @@ import java.util.function.Consumer;
|
|||
public class ForgeHexInitializer {
|
||||
public ForgeHexInitializer() {
|
||||
initConfig();
|
||||
initRegistries();
|
||||
initRegistry();
|
||||
initListeners();
|
||||
}
|
||||
|
@ -96,6 +97,19 @@ public class ForgeHexInitializer {
|
|||
mlc.registerConfig(ModConfig.Type.SERVER, serverConfig.getRight());
|
||||
}
|
||||
|
||||
public static void initRegistries() {
|
||||
if (!(BuiltInRegistries.REGISTRY instanceof MappedRegistry<?> rootRegistry)) return;
|
||||
rootRegistry.unfreeze();
|
||||
|
||||
IXplatAbstractions.INSTANCE.getActionRegistry();
|
||||
IXplatAbstractions.INSTANCE.getSpecialHandlerRegistry();
|
||||
IXplatAbstractions.INSTANCE.getIotaTypeRegistry();
|
||||
IXplatAbstractions.INSTANCE.getArithmeticRegistry();
|
||||
IXplatAbstractions.INSTANCE.getEvalSoundRegistry();
|
||||
|
||||
rootRegistry.freeze();
|
||||
}
|
||||
|
||||
private static void initRegistry() {
|
||||
bind(Registries.SOUND_EVENT, HexSounds::registerSounds);
|
||||
|
||||
|
@ -119,13 +133,11 @@ public class ForgeHexInitializer {
|
|||
|
||||
bind(Registries.PARTICLE_TYPE, HexParticles::registerParticles);
|
||||
|
||||
getModEventBus().addListener(NewRegistryEventHandler::newRegistry);
|
||||
|
||||
bind(IXplatAbstractions.INSTANCE.getIotaTypeRegistry().key(), HexIotaTypes::registerTypes);
|
||||
bind(IXplatAbstractions.INSTANCE.getActionRegistry().key(), HexActions::register);
|
||||
bind(IXplatAbstractions.INSTANCE.getSpecialHandlerRegistry().key(), HexSpecialHandlers::register);
|
||||
bind(IXplatAbstractions.INSTANCE.getArithmeticRegistry().key(), HexArithmetics::register);
|
||||
bind(IXplatAbstractions.INSTANCE.getEvalSoundRegistry().key(), HexEvalSounds::register);
|
||||
bind(HexRegistries.IOTA_TYPE, HexIotaTypes::registerTypes);
|
||||
bind(HexRegistries.ACTION, HexActions::register);
|
||||
bind(HexRegistries.SPECIAL_HANDLER, HexSpecialHandlers::register);
|
||||
bind(HexRegistries.ARITHMETIC, HexArithmetics::register);
|
||||
bind(HexRegistries.EVAL_SOUND, HexEvalSounds::register);
|
||||
|
||||
ForgeHexArgumentTypeRegistry.ARGUMENT_TYPES.register(getModEventBus());
|
||||
ForgeHexLootMods.REGISTRY.register(getModEventBus());
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package at.petrak.hexcasting.forge.event;
|
||||
|
||||
import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
|
||||
import at.petrak.hexcasting.api.casting.arithmetic.Arithmetic;
|
||||
import at.petrak.hexcasting.api.casting.castables.SpecialHandler;
|
||||
import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
|
||||
import at.petrak.hexcasting.api.casting.iota.IotaType;
|
||||
import at.petrak.hexcasting.common.lib.HexRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.NewRegistryEvent;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
|
||||
public class NewRegistryEventHandler {
|
||||
public static Supplier<IForgeRegistry<ActionRegistryEntry>> ACTION;
|
||||
public static Supplier<IForgeRegistry<SpecialHandler.Factory<?>>> SPECIAL_HANDLER;
|
||||
public static Supplier<IForgeRegistry<IotaType<?>>> IOTA_TYPE;
|
||||
public static Supplier<IForgeRegistry<Arithmetic>> ARITHMETIC;
|
||||
public static Supplier<IForgeRegistry<EvalSound>> EVAL_SOUND;
|
||||
|
||||
public static void newRegistry(NewRegistryEvent event) {
|
||||
ACTION = event.create(
|
||||
new RegistryBuilder<ActionRegistryEntry>()
|
||||
.setName(HexRegistries.ACTION.location())
|
||||
);
|
||||
SPECIAL_HANDLER = event.create(
|
||||
new RegistryBuilder<SpecialHandler.Factory<?>>()
|
||||
.setName(HexRegistries.SPECIAL_HANDLER.location())
|
||||
);
|
||||
IOTA_TYPE = event.create(
|
||||
new RegistryBuilder<IotaType<?>>()
|
||||
.setName(HexRegistries.IOTA_TYPE.location())
|
||||
.setDefaultKey(modLoc("null"))
|
||||
);
|
||||
ARITHMETIC = event.create(
|
||||
new RegistryBuilder<Arithmetic>()
|
||||
.setName(HexRegistries.ARITHMETIC.location())
|
||||
.disableSync()
|
||||
);
|
||||
EVAL_SOUND = event.create(
|
||||
new RegistryBuilder<EvalSound>()
|
||||
.setName(HexRegistries.EVAL_SOUND.location())
|
||||
.setDefaultKey(modLoc("nothing"))
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package at.petrak.hexcasting.forge.mixin;
|
||||
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(BuiltInRegistries.class)
|
||||
public interface ForgeAccessorBuiltInRegistries {
|
||||
@Invoker("registerDefaulted")
|
||||
static <T> DefaultedRegistry<T> hex$registerDefaulted(ResourceKey<? extends Registry<T>> registryName,
|
||||
String defaultId,
|
||||
BuiltInRegistries.RegistryBootstrap<T> bootstrap) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@Invoker("registerSimple")
|
||||
static <T> Registry<T> hex$registerSimple(ResourceKey<? extends Registry<T>> registryName,
|
||||
BuiltInRegistries.RegistryBootstrap<T> bootstrap) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
|
@ -21,10 +21,13 @@ import at.petrak.hexcasting.api.player.FlightAbility;
|
|||
import at.petrak.hexcasting.api.player.Sentinel;
|
||||
import at.petrak.hexcasting.api.utils.HexUtils;
|
||||
import at.petrak.hexcasting.common.lib.HexRegistries;
|
||||
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
|
||||
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
|
||||
import at.petrak.hexcasting.common.msgs.IMessage;
|
||||
import at.petrak.hexcasting.forge.cap.CapSyncers;
|
||||
import at.petrak.hexcasting.forge.cap.HexCapabilities;
|
||||
import at.petrak.hexcasting.forge.interop.curios.CuriosApiInterop;
|
||||
import at.petrak.hexcasting.forge.mixin.ForgeAccessorBuiltInRegistries;
|
||||
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
|
||||
import at.petrak.hexcasting.forge.network.MsgBrainsweepAck;
|
||||
import at.petrak.hexcasting.forge.recipe.ForgeUnsealedIngredient;
|
||||
|
@ -37,7 +40,6 @@ import com.google.common.base.Suppliers;
|
|||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
|
@ -92,6 +94,7 @@ import java.util.UUID;
|
|||
import java.util.function.BiFunction;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
||||
import static net.minecraftforge.fluids.capability.IFluidHandler.FluidAction.EXECUTE;
|
||||
|
||||
public class ForgeXplatImpl implements IXplatAbstractions {
|
||||
|
@ -452,25 +455,28 @@ public class ForgeXplatImpl implements IXplatAbstractions {
|
|||
return namespace;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Supplier<Registry<ActionRegistryEntry>> ACTION_REGISTRY = Suppliers.memoize(() ->
|
||||
(Registry<ActionRegistryEntry>) BuiltInRegistries.REGISTRY.get(HexRegistries.ACTION.location())
|
||||
ForgeAccessorBuiltInRegistries.hex$registerSimple(
|
||||
HexRegistries.ACTION, null)
|
||||
);
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Supplier<Registry<SpecialHandler.Factory<?>>> SPECIAL_HANDLER_REGISTRY = Suppliers.memoize(() ->
|
||||
(Registry<SpecialHandler.Factory<?>>) BuiltInRegistries.REGISTRY.get(HexRegistries.SPECIAL_HANDLER.location())
|
||||
);
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Supplier<Registry<SpecialHandler.Factory<?>>> SPECIAL_HANDLER_REGISTRY =
|
||||
Suppliers.memoize(() ->
|
||||
ForgeAccessorBuiltInRegistries.hex$registerSimple(
|
||||
HexRegistries.SPECIAL_HANDLER, null)
|
||||
);
|
||||
private static final Supplier<Registry<IotaType<?>>> IOTA_TYPE_REGISTRY = Suppliers.memoize(() ->
|
||||
(Registry<IotaType<?>>) BuiltInRegistries.REGISTRY.get(HexRegistries.IOTA_TYPE.location())
|
||||
ForgeAccessorBuiltInRegistries.hex$registerDefaulted(
|
||||
HexRegistries.IOTA_TYPE,
|
||||
modLoc("null").toString(), registry -> HexIotaTypes.NULL)
|
||||
);
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Supplier<Registry<Arithmetic>> ARITHMETIC_REGISTRY = Suppliers.memoize(() ->
|
||||
(Registry<Arithmetic>) BuiltInRegistries.REGISTRY.get(HexRegistries.ARITHMETIC.location())
|
||||
ForgeAccessorBuiltInRegistries.hex$registerSimple(
|
||||
HexRegistries.ARITHMETIC, null)
|
||||
);
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Supplier<Registry<EvalSound>> EVAL_SOUND_REGISTRY = Suppliers.memoize(() ->
|
||||
(Registry<EvalSound>) BuiltInRegistries.REGISTRY.get(HexRegistries.EVAL_SOUND.location())
|
||||
ForgeAccessorBuiltInRegistries.hex$registerDefaulted(
|
||||
HexRegistries.EVAL_SOUND,
|
||||
modLoc("nothing").toString(), registry -> HexEvalSounds.NOTHING)
|
||||
);
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,6 @@ public net.minecraft.client.renderer.RenderType$CompositeRenderType
|
|||
public net.minecraft.client.renderer.RenderType$CompositeState f_110576_ # textureState
|
||||
public net.minecraft.world.item.crafting.Ingredient <init>(Ljava/util/stream/Stream;)V
|
||||
public net.minecraft.world.item.crafting.Ingredient f_43902_ # values
|
||||
public net.minecraft.core.Registry$RegistryBootstrap
|
||||
public net.minecraft.world.damagesource.DamageSources m_269079_(Lnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/damagesource/DamageSource; # source
|
||||
public net.minecraft.world.damagesource.DamageSources m_269298_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; # source
|
||||
public net.minecraft.world.damagesource.DamageSources m_269298_(Lnet/minecraft/resources/ResourceKey;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/damagesource/DamageSource; # source
|
||||
public net.minecraft.core.registries.BuiltInRegistries$RegistryBootstrap
|
|
@ -5,6 +5,7 @@
|
|||
"refmap": "hexcasting.mixins.refmap.json",
|
||||
"package": "at.petrak.hexcasting.forge.mixin",
|
||||
"mixins": [
|
||||
"ForgeAccessorBuiltInRegistries",
|
||||
"ForgeMixinCursedRecipeSerializerBase"
|
||||
],
|
||||
"client": [
|
||||
|
|
|
@ -16,4 +16,4 @@ paucalVersion=0.6.0
|
|||
patchouliVersion=80
|
||||
|
||||
jeiVersion=15.0.0.12
|
||||
pehkuiVersion=3.7.5
|
||||
pehkuiVersion=3.7.6
|
||||
|
|
Loading…
Reference in a new issue