Skip to content

Commit

Permalink
Remove custom book recipe
Browse files Browse the repository at this point in the history
You can specify components in vanilla results now
  • Loading branch information
Mrbysco committed May 3, 2024
1 parent 51df1a3 commit e7af056
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class FabricModInitializer implements ModInitializer {
public void onInitialize() {
PatchouliSounds.submitRegistrations((id, e) -> Registry.register(BuiltInRegistries.SOUND_EVENT, id, e));
PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(BuiltInRegistries.ITEM, id, e));
PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, e));
PatchouliDataComponents.submitDataComponentRegistrations((id, e) -> Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, id, e));
FiberPatchouliConfig.setup();
CommandRegistrationCallback.EVENT.register((disp, buildCtx, selection) -> OpenBookCommand.register(disp));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public static void register(RegisterEvent evt) {
evt.register(Registries.ITEM, rh -> {
PatchouliItems.submitItemRegistrations(rh::register);
});
evt.register(Registries.RECIPE_SERIALIZER, rh -> {
PatchouliItems.submitRecipeSerializerRegistrations(rh::register);
});
evt.register(Registries.DATA_COMPONENT_TYPE, rh -> {
PatchouliDataComponents.submitDataComponentRegistrations(rh::register);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package vazkii.patchouli.client.book.template.variable;

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.mojang.serialization.JsonOps;

import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Component.Serializer;
import net.minecraft.network.chat.ComponentSerialization;

import vazkii.patchouli.api.IVariableSerializer;
import vazkii.patchouli.mixin.AccessorComponentSerializer;

public class TextComponentVariableSerializer implements IVariableSerializer<Component> {
@Override
Expand All @@ -23,6 +25,6 @@ public Component fromJson(JsonElement json) {

@Override
public JsonElement toJson(Component stack) {
return AccessorComponentSerializer.invokeSerialize(stack, RegistryAccess.EMPTY);
return ComponentSerialization.CODEC.encodeStart(RegistryAccess.EMPTY.createSerializationContext(JsonOps.INSTANCE), stack).getOrThrow(JsonParseException::new);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.RecipeSerializer;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.common.recipe.ShapedBookRecipe;
import vazkii.patchouli.common.recipe.ShapelessBookRecipe;

import java.util.function.BiConsumer;

Expand All @@ -18,9 +15,4 @@ public class PatchouliItems {
public static void submitItemRegistrations(BiConsumer<ResourceLocation, Item> consumer) {
consumer.accept(BOOK_ID, BOOK);
}

public static void submitRecipeSerializerRegistrations(BiConsumer<ResourceLocation, RecipeSerializer<?>> consumer) {
consumer.accept(new ResourceLocation(PatchouliAPI.MOD_ID, "shaped_book_recipe"), ShapedBookRecipe.SERIALIZER);
consumer.accept(new ResourceLocation(PatchouliAPI.MOD_ID, "shapeless_book_recipe"), ShapelessBookRecipe.SERIALIZER);
}
}

This file was deleted.

This file was deleted.

0 comments on commit e7af056

Please sign in to comment.