From 5f1da59666671f6edd017a7b54b2e30d0ebf6e09 Mon Sep 17 00:00:00 2001 From: BrokenK3yboard <63761658+BrokenK3yboard@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:16:37 -0600 Subject: [PATCH] Remove crafting extension registry Temporarily disable FlagIngredient + misc. cleanup --- src/main/java/org/violetmoon/zeta/Zeta.java | 7 +- .../client/config/widget/CategoryButton.java | 2 +- .../zeta/config/ConfigFlagManager.java | 31 +++-- .../violetmoon/zeta/config/FlagCondition.java | 20 ++-- .../violetmoon/zeta/event/load/ZRegister.java | 5 - .../zeta/recipe/FlagIngredient.java | 78 +++++++------ .../zeta/recipe/IZetaCondition.java | 15 +-- .../zeta/recipe/IZetaConditionSerializer.java | 22 ---- .../zeta/recipe/IZetaCustomIngredient.java | 21 ++++ .../zeta/recipe/IZetaIngredient.java | 6 +- .../recipe/IZetaIngredientSerializer.java | 26 ----- .../zeta/registry/BrewingRegistry.java | 42 +++---- .../registry/CraftingExtensionsRegistry.java | 15 --- .../zeta/util/SimpleInventoryBlockEntity.java | 12 +- .../violetmoon/zetaimplforge/ForgeZeta.java | 11 +- .../client/ForgeClientRegistryExtension.java | 2 +- .../mixin/mixins/IngredientMixin.java | 32 ----- .../registry/ForgeBrewingRegistry.java | 11 +- .../ForgeCraftingExtensionsRegistry.java | 110 ------------------ src/main/resources/pack.mcmeta | 5 +- src/main/resources/zeta_forge.mixins.json | 1 - 21 files changed, 130 insertions(+), 344 deletions(-) delete mode 100644 src/main/java/org/violetmoon/zeta/recipe/IZetaConditionSerializer.java create mode 100644 src/main/java/org/violetmoon/zeta/recipe/IZetaCustomIngredient.java delete mode 100644 src/main/java/org/violetmoon/zeta/recipe/IZetaIngredientSerializer.java delete mode 100644 src/main/java/org/violetmoon/zeta/registry/CraftingExtensionsRegistry.java delete mode 100644 src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/IngredientMixin.java delete mode 100644 src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java diff --git a/src/main/java/org/violetmoon/zeta/Zeta.java b/src/main/java/org/violetmoon/zeta/Zeta.java index 967c8fb..ddce0c2 100644 --- a/src/main/java/org/violetmoon/zeta/Zeta.java +++ b/src/main/java/org/violetmoon/zeta/Zeta.java @@ -52,7 +52,6 @@ public Zeta(String modid, Logger log, ZetaSide side) { this.registry = createRegistry(); this.renderLayerRegistry = createRenderLayerRegistry(); this.dyeables = createDyeablesRegistry(); - this.craftingExtensions = createCraftingExtensionsRegistry(); this.brewingRegistry = createBrewingRegistry(); this.advancementModifierRegistry = createAdvancementModifierRegistry(); this.pottedPlantRegistry = createPottedPlantRegistry(); @@ -67,8 +66,7 @@ public Zeta(String modid, Logger log, ZetaSide side) { this.entitySpawn = createEntitySpawnHandler(); - loadBus.subscribe(craftingExtensions) - .subscribe(dyeables) + loadBus.subscribe(dyeables) .subscribe(brewingRegistry) .subscribe(advancementModifierRegistry) .subscribe(fuel) @@ -92,7 +90,6 @@ public Zeta(String modid, Logger log, ZetaSide side) { public final RegistryUtil registryUtil = new RegistryUtil(this); //TODO: Delete this, only needed cause there's no way to get early registry names. public final RenderLayerRegistry renderLayerRegistry; public final DyeablesRegistry dyeables; - public final CraftingExtensionsRegistry craftingExtensions; public final BrewingRegistry brewingRegistry; public final AdvancementModifierRegistry advancementModifierRegistry; public final PottedPlantRegistry pottedPlantRegistry; @@ -159,7 +156,7 @@ public ZetaModuleManager createModuleManager() { public RenderLayerRegistry createRenderLayerRegistry() { return new RenderLayerRegistry(); } - public abstract CraftingExtensionsRegistry createCraftingExtensionsRegistry(); + public DyeablesRegistry createDyeablesRegistry() { return new DyeablesRegistry(); } diff --git a/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java b/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java index 9c0f8a4..fe820d8 100644 --- a/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java +++ b/src/main/java/org/violetmoon/zeta/client/config/widget/CategoryButton.java @@ -21,7 +21,7 @@ public CategoryButton(int x, int y, int w, int h, Component text, ItemStack icon @Override public void renderWidget(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { - super.render(guiGraphics, mouseX, mouseY, partialTicks); + super.renderWidget(guiGraphics, mouseX, mouseY, partialTicks); if(!active) setTooltip(Tooltip.create(Component.translatable("quark.gui.config.missingaddon"))); // todo: QUARK REFERENCE diff --git a/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java b/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java index 7c98de2..ca8c1de 100644 --- a/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java +++ b/src/main/java/org/violetmoon/zeta/config/ConfigFlagManager.java @@ -1,21 +1,18 @@ package org.violetmoon.zeta.config; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.storage.loot.predicates.LootItemConditionType; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.event.bus.LoadEvent; import org.violetmoon.zeta.event.load.ZRegister; import org.violetmoon.zeta.module.ZetaModule; -import org.violetmoon.zeta.recipe.FlagIngredient; -import org.violetmoon.zeta.registry.CraftingExtensionsRegistry; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.resources.ResourceLocation; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; public final class ConfigFlagManager { @@ -24,8 +21,8 @@ public final class ConfigFlagManager { private final Set allFlags = new HashSet<>(); private final Map flags = new HashMap<>(); - //TODO augh; needed for BrewingRegistry - public final FlagIngredient.Serializer flagIngredientSerializer = new FlagIngredient.Serializer(this); + // TODO augh; needed for BrewingRegistry + // public final FlagIngredient.Serializer flagIngredientSerializer = new FlagIngredient.Serializer(this); public static final LootItemConditionType FLAG_CONDITION_TYPE = new LootItemConditionType(FlagLootCondition.CODEC); @@ -37,15 +34,15 @@ public ConfigFlagManager(Zeta zeta) { @LoadEvent public void onRegister(ZRegister event) { + /* CraftingExtensionsRegistry ext = event.getCraftingExtensionsRegistry(); - //Note: These SHOULD be Quark-independent already, but hell if I know. Todo: Double check it. ext.registerConditionSerializer(new FlagCondition.Serializer(this, ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"))); ext.registerConditionSerializer(new FlagCondition.Serializer(this, ResourceLocation.fromNamespaceAndPath(zeta.modid, "advancement_flag"), () -> ZetaGeneralConfig.enableModdedAdvancements)); - + */ Registry.register(BuiltInRegistries.LOOT_CONDITION_TYPE, ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), FLAG_CONDITION_TYPE); - ext.registerIngredientSerializer(ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), flagIngredientSerializer); + // ext.registerIngredientSerializer(ResourceLocation.fromNamespaceAndPath(zeta.modid, "flag"), flagIngredientSerializer); SyncedFlagHandler.setupFlagManager(this); } @@ -55,9 +52,7 @@ public void clear() { public void putFlag(ZetaModule module, String flag, boolean value) { flags.put(flag, value && module.enabled); - if(!allFlags.contains(flag)) { - allFlags.add(flag); - } + allFlags.add(flag); } public void putModuleFlag(ZetaModule module) { diff --git a/src/main/java/org/violetmoon/zeta/config/FlagCondition.java b/src/main/java/org/violetmoon/zeta/config/FlagCondition.java index 19367c7..178b25e 100644 --- a/src/main/java/org/violetmoon/zeta/config/FlagCondition.java +++ b/src/main/java/org/violetmoon/zeta/config/FlagCondition.java @@ -1,14 +1,10 @@ package org.violetmoon.zeta.config; -import java.util.function.BooleanSupplier; - +import com.mojang.serialization.MapCodec; +import net.minecraft.resources.ResourceLocation; import org.violetmoon.zeta.recipe.IZetaCondition; -import org.violetmoon.zeta.recipe.IZetaConditionSerializer; -import org.violetmoon.zeta.util.BooleanSuppliers; -import com.google.gson.JsonObject; - -import net.minecraft.resources.ResourceLocation; +import java.util.function.BooleanSupplier; /** * @author WireSegal @@ -17,8 +13,8 @@ public record FlagCondition(ConfigFlagManager cfm, String flag, ResourceLocation loc, BooleanSupplier extraCondition) implements IZetaCondition { @Override - public ResourceLocation getID() { - return loc; + public MapCodec codec() { + return null; } @Override @@ -27,11 +23,12 @@ public boolean test(IContext context) { throw new RuntimeException("Illegal flag: " + flag); if(!cfm.isValidFlag(flag)) - cfm.zeta.log.warn("Non-existent flag " + flag + " being used"); + cfm.zeta.log.warn("Non-existent flag {} being used", flag); return extraCondition.getAsBoolean() && cfm.getFlag(flag); } + /* public static class Serializer implements IZetaConditionSerializer { private final ConfigFlagManager cfm; private final ResourceLocation location; @@ -62,4 +59,5 @@ public ResourceLocation getID() { return location; } } -} + */ +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/event/load/ZRegister.java b/src/main/java/org/violetmoon/zeta/event/load/ZRegister.java index b49697c..f821dd1 100644 --- a/src/main/java/org/violetmoon/zeta/event/load/ZRegister.java +++ b/src/main/java/org/violetmoon/zeta/event/load/ZRegister.java @@ -4,7 +4,6 @@ import org.violetmoon.zeta.advancement.AdvancementModifierRegistry; import org.violetmoon.zeta.event.bus.IZetaLoadEvent; import org.violetmoon.zeta.registry.BrewingRegistry; -import org.violetmoon.zeta.registry.CraftingExtensionsRegistry; import org.violetmoon.zeta.registry.RenderLayerRegistry; import org.violetmoon.zeta.registry.VariantRegistry; import org.violetmoon.zeta.registry.ZetaRegistry; @@ -21,10 +20,6 @@ public ZetaRegistry getRegistry() { return zeta.registry; } - public CraftingExtensionsRegistry getCraftingExtensionsRegistry() { - return zeta.craftingExtensions; - } - public BrewingRegistry getBrewingRegistry() { return zeta.brewingRegistry; } diff --git a/src/main/java/org/violetmoon/zeta/recipe/FlagIngredient.java b/src/main/java/org/violetmoon/zeta/recipe/FlagIngredient.java index 5723cbc..ee079ba 100644 --- a/src/main/java/org/violetmoon/zeta/recipe/FlagIngredient.java +++ b/src/main/java/org/violetmoon/zeta/recipe/FlagIngredient.java @@ -1,52 +1,39 @@ package org.violetmoon.zeta.recipe; -import java.util.Arrays; -import java.util.stream.Stream; - -import net.neoforged.neoforge.common.crafting.ICustomIngredient; -import org.jetbrains.annotations.NotNull; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.neoforged.neoforge.common.crafting.IngredientType; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.Zeta; import org.violetmoon.zeta.config.ConfigFlagManager; -import com.google.gson.JsonObject; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.crafting.Ingredient; +import java.util.Arrays; +import java.util.stream.Stream; /** * @author WireSegal * Created at 3:44 PM on 10/20/19. */ -public class FlagIngredient implements ICustomIngredient, IZetaIngredient { //AccessWidener? Idk I think this is cooked. +public class FlagIngredient implements IZetaCustomIngredient { // TODO: Abstract later, use NF-provided CustomIngredient for now private final Ingredient parent; - private final ConfigFlagManager cfm; private final String flag; - private final IZetaIngredientSerializer serializer; - public FlagIngredient(Ingredient parent, String flag, ConfigFlagManager cfm, IZetaIngredientSerializer serializer) { + public FlagIngredient(Ingredient parent, String flag, ConfigFlagManager cfm) { this.parent = parent; this.cfm = cfm; this.flag = flag; - this.serializer = serializer; } @Override public Stream getItems() { - if (!cfm.getFlag(flag)) - return Stream.empty(); - return Arrays.stream(parent.getItems()); + return (!cfm.getFlag(flag)) ? Stream.empty() : Arrays.stream(parent.getItems()); } @Override public boolean test(@Nullable ItemStack target) { - if (target == null || !cfm.getFlag(flag)) - return false; - - return parent.test(target); + return cfm.getFlag(flag) && parent.test(target); } @Override @@ -55,19 +42,47 @@ public boolean isSimple() { } @Override - public IZetaIngredientSerializer zetaGetSerializer() { - return serializer; + public IngredientType getType() { + return null; + } + + @Override + public Zeta getZeta() { + return cfm.zeta; } - public record Serializer(ConfigFlagManager cfm) implements IZetaIngredientSerializer { + /* + public record Serializer(ConfigFlagManager cfm) implements IZetaCustomIngredient { + + @Override + public boolean test(ItemStack stack) { + return false; + } + + @Override + public Stream getItems() { + return Stream.empty(); + } - @Deprecated(forRemoval = true) - public static Serializer INSTANCE; + @Override + public boolean isSimple() { + return false; + } + + @Override + public IngredientType getType() { + return null; + } + + @Override + public Zeta getZeta() { + return cfm.zeta; + } @NotNull @Override public FlagIngredient parse(@NotNull FriendlyByteBuf buffer) { - return new FlagIngredient(Ingredient.fromNetwork(buffer), buffer.readUtf(), cfm, this); + return new FlagIngredient(Ingredient.CONTENTS_STREAM_CODEC.decode(buffer), buffer.readUtf(), cfm, this); } @NotNull @@ -83,10 +98,5 @@ public void write(@NotNull FriendlyByteBuf buffer, @NotNull FlagIngredient ingre ingredient.parent.toNetwork(buffer); buffer.writeUtf(ingredient.flag); } - - @Override - public Zeta getZeta() { - return cfm.zeta; - } - } + */ } diff --git a/src/main/java/org/violetmoon/zeta/recipe/IZetaCondition.java b/src/main/java/org/violetmoon/zeta/recipe/IZetaCondition.java index 49f0217..3e7efde 100644 --- a/src/main/java/org/violetmoon/zeta/recipe/IZetaCondition.java +++ b/src/main/java/org/violetmoon/zeta/recipe/IZetaCondition.java @@ -1,25 +1,26 @@ package org.violetmoon.zeta.recipe; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - +import com.mojang.serialization.MapCodec; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + // Copy of Forge ICondition public interface IZetaCondition { - ResourceLocation getID(); boolean test(IContext context); + MapCodec codec(); - //TODO: do we need this interface IContext { + default Collection> getTag(TagKey key) { - return getAllTags(key.registry()).getOrDefault(key.location(), Set.of()); + return this.getAllTags(key.registry()).getOrDefault(key.location(), Set.of()); } Map>> getAllTags(ResourceKey> registry); diff --git a/src/main/java/org/violetmoon/zeta/recipe/IZetaConditionSerializer.java b/src/main/java/org/violetmoon/zeta/recipe/IZetaConditionSerializer.java deleted file mode 100644 index 868fe38..0000000 --- a/src/main/java/org/violetmoon/zeta/recipe/IZetaConditionSerializer.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.violetmoon.zeta.recipe; - -import com.google.gson.JsonObject; - -import net.minecraft.resources.ResourceLocation; - -// Copy of Forge IConditionSerializer -public interface IZetaConditionSerializer { - void write(JsonObject json, T value); - - T read(JsonObject json); - - ResourceLocation getID(); - - default JsonObject getJson(T value) - { - JsonObject json = new JsonObject(); - this.write(json, value); - json.addProperty("type", value.getID().toString()); - return json; - } -} diff --git a/src/main/java/org/violetmoon/zeta/recipe/IZetaCustomIngredient.java b/src/main/java/org/violetmoon/zeta/recipe/IZetaCustomIngredient.java new file mode 100644 index 0000000..526105a --- /dev/null +++ b/src/main/java/org/violetmoon/zeta/recipe/IZetaCustomIngredient.java @@ -0,0 +1,21 @@ +package org.violetmoon.zeta.recipe; + +import net.minecraft.world.item.ItemStack; +import net.neoforged.neoforge.common.crafting.ICustomIngredient; +import net.neoforged.neoforge.common.crafting.IngredientType; +import org.violetmoon.zeta.Zeta; + +import java.util.stream.Stream; + +// Copy of Neoforge ICustomIngredient +public interface IZetaCustomIngredient extends ICustomIngredient { // TODO: Abstract later, use NF-provided CustomIngredient for now + boolean test(ItemStack var1); + + Stream getItems(); + + boolean isSimple(); + + IngredientType getType(); + + Zeta getZeta(); +} diff --git a/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredient.java b/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredient.java index da0d42d..3fdb393 100644 --- a/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredient.java +++ b/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredient.java @@ -1,10 +1,8 @@ package org.violetmoon.zeta.recipe; -import net.neoforged.neoforge.common.crafting.ICustomIngredient; - /** * Forge hacks some custom IIngredientSerializer stuff onto Ingredient */ -public interface IZetaIngredient { - IZetaIngredientSerializer zetaGetSerializer(); +public interface IZetaIngredient { + IZetaCustomIngredient zetaGetSerializer(); } diff --git a/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredientSerializer.java b/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredientSerializer.java deleted file mode 100644 index fc29d9f..0000000 --- a/src/main/java/org/violetmoon/zeta/recipe/IZetaIngredientSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.violetmoon.zeta.recipe; - -import net.neoforged.neoforge.common.crafting.ICustomIngredient; -import org.violetmoon.zeta.Zeta; - -import com.google.gson.JsonObject; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; - -// Copy of Forge IIngredientSerializer -public interface IZetaIngredientSerializer { - T parse(FriendlyByteBuf buffer); - - T parse(JsonObject json); - - void write(FriendlyByteBuf buffer, T ingredient); - - //Aaaaaaaa - Zeta getZeta(); - - //TODO: Is getId needed? - default ResourceLocation getID() { - return getZeta().craftingExtensions.getID(this); - } -} diff --git a/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java b/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java index a0c4562..8f5c060 100644 --- a/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java +++ b/src/main/java/org/violetmoon/zeta/registry/BrewingRegistry.java @@ -1,22 +1,20 @@ package org.violetmoon.zeta.registry; -import java.util.Map; - -import net.minecraft.core.Holder; -import net.minecraft.world.item.Item; -import org.jetbrains.annotations.Nullable; -import org.violetmoon.zeta.Zeta; - import com.google.common.collect.Maps; - +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffect; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.item.alchemy.Potion; import net.minecraft.world.item.alchemy.Potions; +import org.jetbrains.annotations.Nullable; +import org.violetmoon.zeta.Zeta; + +import java.util.Map; /** * @author WireSegal @@ -36,19 +34,15 @@ public void addPotionMix(String flag, Item reagent, MobEffect effect) { addPotionMix(flag, reagent, effect, null); } - public void addPotionMix(String flag, Item reagent, MobEffect effect, - int normalTime, int longTime, int strongTime) { + public void addPotionMix(String flag, Item reagent, MobEffect effect, int normalTime, int longTime, int strongTime) { addPotionMix(flag, reagent, effect, null, normalTime, longTime, strongTime); } - public void addPotionMix(String flag, Item reagent, MobEffect effect, - @Nullable MobEffect negation) { + public void addPotionMix(String flag, Item reagent, MobEffect effect, @Nullable MobEffect negation) { addPotionMix(flag, reagent, effect, negation, 3600, 9600, 1800); } - - public void addPotionMix(String flag, Item reagent, MobEffect effect, - @Nullable MobEffect negation, int normalTime, int longTime, int strongTime) { + public void addPotionMix(String flag, Item reagent, MobEffect effect, @Nullable MobEffect negation, int normalTime, int longTime, int strongTime) { ResourceLocation loc = zeta.registry.getRegistryName(effect, BuiltInRegistries.MOB_EFFECT); if (loc != null) { @@ -109,30 +103,20 @@ public void addNegation(String flag, Potion normalType, Potion longType, @Nullab protected void addFlaggedRecipe(String flag, Potion potion, Item reagent, Potion to) { flaggedPotions.put(to, flag); - /*Supplier flagIngredientSupplier = () -> new FlagIngredient( - reagent, - flag, - zeta.configManager.getConfigFlagManager(), - zeta.configManager.getConfigFlagManager().flagIngredientSerializer - );*/ - //todo: Chat checkup on this + // Supplier flagIngredientSupplier = () -> new FlagIngredient(reagent, flag, zeta.configManager.getConfigFlagManager(), zeta.configManager.getConfigFlagManager().flagIngredientSerializer); if (zeta.configManager.getConfigFlagManager().getFlag(flag)) { addBrewingRecipe(potion, reagent, to); - }; - - } + } + } protected Potion registerPotion(MobEffectInstance eff, String baseName, String name) { Potion effect = new Potion(zeta.modid + "." + baseName, eff); zeta.registry.register(effect, name, Registries.POTION); - return effect; } public boolean isEnabled(Potion potion) { - if (!flaggedPotions.containsKey(potion)) - return true; - return zeta.configManager.getConfigFlagManager().getFlag(flaggedPotions.get(potion)); + return !flaggedPotions.containsKey(potion) || zeta.configManager.getConfigFlagManager().getFlag(flaggedPotions.get(potion)); } protected abstract void addBrewingRecipe(Potion input, Item reagentSupplier, Potion output); diff --git a/src/main/java/org/violetmoon/zeta/registry/CraftingExtensionsRegistry.java b/src/main/java/org/violetmoon/zeta/registry/CraftingExtensionsRegistry.java deleted file mode 100644 index f9955e2..0000000 --- a/src/main/java/org/violetmoon/zeta/registry/CraftingExtensionsRegistry.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.violetmoon.zeta.registry; - -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Ingredient; -import org.violetmoon.zeta.recipe.IZetaCondition; -import org.violetmoon.zeta.recipe.IZetaConditionSerializer; -import org.violetmoon.zeta.recipe.IZetaIngredientSerializer; - -public interface CraftingExtensionsRegistry { - IZetaConditionSerializer registerConditionSerializer(IZetaConditionSerializer serializer); - IZetaIngredientSerializer registerIngredientSerializer(ResourceLocation id, IZetaIngredientSerializer serializer); - - //TODO: Is getId needed? - ResourceLocation getID(IZetaIngredientSerializer serializer); -} diff --git a/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java b/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java index 686699d..d1ebc60 100644 --- a/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java +++ b/src/main/java/org/violetmoon/zeta/util/SimpleInventoryBlockEntity.java @@ -132,23 +132,17 @@ public boolean canPlaceItem(int i, @NotNull ItemStack itemstack) { } @Override - public void startOpen(@NotNull Player player) { - // NO-OP - } + public abstract void startOpen(@NotNull Player player); @Override - public void stopOpen(@NotNull Player player) { - // NO-OP - } + public abstract void stopOpen(@NotNull Player player); @Override public void clearContent() { inventorySlots = NonNullList.withSize(getContainerSize(), ItemStack.EMPTY); } - public void inventoryChanged(int i) { - // NO-OP - } + abstract void inventoryChanged(int i); public boolean isAutomationEnabled() { return true; diff --git a/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java b/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java index 119a7df..7ae3c94 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java +++ b/src/main/java/org/violetmoon/zetaimplforge/ForgeZeta.java @@ -45,7 +45,10 @@ import org.violetmoon.zeta.event.play.loading.ZVillagerTrades; import org.violetmoon.zeta.event.play.loading.ZWandererTrades; import org.violetmoon.zeta.item.ext.ItemExtensionFactory; -import org.violetmoon.zeta.registry.*; +import org.violetmoon.zeta.registry.BrewingRegistry; +import org.violetmoon.zeta.registry.CreativeTabManager; +import org.violetmoon.zeta.registry.PottedPlantRegistry; +import org.violetmoon.zeta.registry.ZetaRegistry; import org.violetmoon.zeta.util.RaytracingUtil; import org.violetmoon.zeta.util.ZetaSide; import org.violetmoon.zetaimplforge.api.GatherAdvancementModifiersEvent; @@ -66,7 +69,6 @@ import org.violetmoon.zetaimplforge.event.play.loading.ForgeZWandererTrades; import org.violetmoon.zetaimplforge.item.IForgeItemItemExtensions; import org.violetmoon.zetaimplforge.registry.ForgeBrewingRegistry; -import org.violetmoon.zetaimplforge.registry.ForgeCraftingExtensionsRegistry; import org.violetmoon.zetaimplforge.registry.ForgeZetaRegistry; import org.violetmoon.zetaimplforge.util.ForgeRaytracingUtil; @@ -110,11 +112,6 @@ public ZetaRegistry createRegistry() { return new ForgeZetaRegistry(this, bus); } - @Override - public CraftingExtensionsRegistry createCraftingExtensionsRegistry() { - return new ForgeCraftingExtensionsRegistry(); - } - @Override public BrewingRegistry createBrewingRegistry() { return new ForgeBrewingRegistry(this); diff --git a/src/main/java/org/violetmoon/zetaimplforge/client/ForgeClientRegistryExtension.java b/src/main/java/org/violetmoon/zetaimplforge/client/ForgeClientRegistryExtension.java index c083d7d..7c9bc4a 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/client/ForgeClientRegistryExtension.java +++ b/src/main/java/org/violetmoon/zetaimplforge/client/ForgeClientRegistryExtension.java @@ -15,7 +15,7 @@ public ForgeClientRegistryExtension(Zeta z) { //Forge has some weirdo extension, they want you to use json or something. //Doing it from java is easier and more akin to how it happens on Fabric. @Override - @SuppressWarnings("removal") + @SuppressWarnings("deprecation") protected void doSetRenderLayer(Block block, RenderLayerRegistry.Layer layer) { ItemBlockRenderTypes.setRenderLayer(block, resolvedTypes.get(layer)); } diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/IngredientMixin.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/IngredientMixin.java deleted file mode 100644 index c0043c4..0000000 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/IngredientMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.violetmoon.zetaimplforge.mixin.mixins; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.violetmoon.zeta.recipe.IZetaIngredient; -import org.violetmoon.zeta.recipe.IZetaIngredientSerializer; -import org.violetmoon.zetaimplforge.registry.ForgeCraftingExtensionsRegistry; - -import net.minecraft.world.item.crafting.Ingredient; - -/** - * Forge hacks an "IIngredientSerializer getSerializer()" method onto Ingredient, which Zeta's ingredients - * can't directly implement since IIngredientSerializer is a Forge-only class. - */ -@Mixin(Ingredient.class) -public class IngredientMixin { - @Inject(method = "getSerializer", remap = false, at = @At("HEAD"), cancellable = true) - public void blah(CallbackInfoReturnable> cir) { - Ingredient self = (Ingredient) (Object) this; - - if(self instanceof IZetaIngredient zIng) { - IZetaIngredientSerializer ser = zIng.zetaGetSerializer(); - - IIngredientSerializer forge = ((ForgeCraftingExtensionsRegistry) ser.getZeta().craftingExtensions) - .toForgeIngredientSerializers.get(ser); - - if(forge != null) - cir.setReturnValue(forge); - } - } -} diff --git a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeBrewingRegistry.java b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeBrewingRegistry.java index 6a0cd08..b1515bc 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeBrewingRegistry.java +++ b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeBrewingRegistry.java @@ -14,6 +14,10 @@ import java.util.List; public class ForgeBrewingRegistry extends BrewingRegistry { + + private List delayedPotions = new ArrayList<>(); + private boolean okToRegisterImmediately = false; + public ForgeBrewingRegistry(ForgeZeta zeta) { super(zeta); } @@ -23,17 +27,16 @@ void register() { new PotionBrewing.Builder(FeatureFlagSet.of()).addMix(input, reagentSupplier, output); } } - private List delayedPotions = new ArrayList<>(); - private boolean okToRegisterImmediately = false; @Override public void addBrewingRecipe(Potion input, Item reagentSupplier, Potion output) { DelayedPotion d = new DelayedPotion(Holder.direct(input), reagentSupplier, Holder.direct(output)); - if(okToRegisterImmediately) + if(okToRegisterImmediately) { d.register(); - else + } else { delayedPotions.add(d); + } } @LoadEvent diff --git a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java deleted file mode 100644 index 95e2654..0000000 --- a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java +++ /dev/null @@ -1,110 +0,0 @@ -package org.violetmoon.zetaimplforge.registry; - -import com.google.gson.JsonObject; -import com.mojang.serialization.MapCodec; -import net.minecraft.core.Holder; -import net.minecraft.core.Registry; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.crafting.Ingredient; -import net.neoforged.neoforge.common.conditions.ICondition; -import net.neoforged.neoforge.common.crafting.CraftingHelper; -import org.violetmoon.zeta.recipe.IZetaCondition; -import org.violetmoon.zeta.recipe.IZetaConditionSerializer; -import org.violetmoon.zeta.recipe.IZetaIngredientSerializer; -import org.violetmoon.zeta.registry.CraftingExtensionsRegistry; - -import java.util.Collection; -import java.util.IdentityHashMap; -import java.util.Map; - -public class ForgeCraftingExtensionsRegistry implements CraftingExtensionsRegistry { - - /// Ingredient serializers /// - - //Used in IngredientMixin on Forge - public final Map, IIngredientSerializer> toForgeIngredientSerializers = new IdentityHashMap<>(); - - @Override - public IZetaIngredientSerializer registerIngredientSerializer(ResourceLocation id, IZetaIngredientSerializer serializer) { - //Register a Forge ingredient serializer that delegates to our ingredient serializer. - IIngredientSerializer forge = new IIngredientSerializer<>() { - @Override - public T parse(FriendlyByteBuf buffer) { - return serializer.parse(buffer); - } - - @Override - public T parse(JsonObject json) { - return serializer.parse(json); - } - - @Override - public void write(FriendlyByteBuf buffer, T ingredient) { - serializer.write(buffer, ingredient); - } - }; - - CraftingHelper.register(id, forge); - toForgeIngredientSerializers.put(serializer, forge); - - return serializer; - } - - //TODO: Is getId needed? - @Override - public ResourceLocation getID(IZetaIngredientSerializer serializer) { - return CraftingHelper.getID(toForgeIngredientSerializers.get(serializer)); - } - - /// Condition serializers /// - //These are far more annoying, since there's two layers of forge-specific classes to wrap - - //FORGE icontext to ZETA icontext - public record Forge2ZetaContext(ICondition.IContext forge) implements IZetaCondition.IContext { - @Override - public Map>> getAllTags(ResourceKey> registry) { - return forge.getAllTags(registry); - } - } - - //ZETA icondition to FORGE icondition - public record Zeta2ForgeCondition(T zeta) implements ICondition { - - @Override - public boolean test(ICondition.IContext context) { - //Wrap the IContext in a class Zeta can refer to, before passing it to Zeta - return zeta.test(new Forge2ZetaContext(context)); - } - - @Override - public MapCodec codec() { - return null; - } - } - - @Override - public IZetaConditionSerializer registerConditionSerializer(IZetaConditionSerializer serializer) { - CraftingHelper.register(new IConditionSerializer>() { - @Override - public Zeta2ForgeCondition read(JsonObject json) { - //Wrap the condition in Forge-specific wrapping before passing it to Forge. - return new Zeta2ForgeCondition<>(serializer.read(json)); - } - - @Override - public void write(JsonObject json, Zeta2ForgeCondition value) { - //Unwrap the condition from its Forge-specific wrapping before passing it to `serializer`. - serializer.write(json, value.zeta); - } - - @Override - public ResourceLocation getID() { - return serializer.getID(); - } - }); - - return serializer; - } -} diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index c88ae35..0dc66c1 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,7 +1,6 @@ { "pack": { "description": "Zeta's resources", - "pack_format": 15, - "forge:server_data_pack_format": 12 + "pack_format": 48 } -} +} \ No newline at end of file diff --git a/src/main/resources/zeta_forge.mixins.json b/src/main/resources/zeta_forge.mixins.json index e0c6d29..33338d4 100644 --- a/src/main/resources/zeta_forge.mixins.json +++ b/src/main/resources/zeta_forge.mixins.json @@ -9,7 +9,6 @@ "AccessorEvent", "AccessorModConfig", "AccessorPotionBrewing", - "IngredientMixin", "WeatheringCopperMixin", "self.IZetaBlockMixin_FAKE", "self.IZetaItemMixin_FAKE"