Skip to content

Commit

Permalink
Run spotlessJavaApply
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrbysco committed Jan 27, 2024
1 parent 44b4700 commit c4e2516
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
import net.minecraft.world.InteractionResult;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.event.*;
import net.neoforged.neoforge.client.gui.overlay.VanillaGuiOverlay;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.client.base.BookModel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package vazkii.patchouli.neoforge.common;

import net.minecraft.resources.ResourceLocation;
import net.neoforged.neoforge.common.ModConfigSpec;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.common.ModConfigSpec;

import vazkii.patchouli.api.PatchouliConfigAccess;
import vazkii.patchouli.common.base.PatchouliConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;

import vazkii.patchouli.api.PatchouliAPI;

import org.jetbrains.annotations.Nullable;

public record NeoForgeMessageOpenBookGui(ResourceLocation book, @Nullable ResourceLocation entry, int page) implements CustomPacketPayload {

public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "open_book");

public NeoForgeMessageOpenBookGui(FriendlyByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.neoforged.neoforge.network.PacketDistributor;

import vazkii.patchouli.api.PatchouliAPI;

public record NeoForgeMessageReloadBookContents() implements CustomPacketPayload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.neoforge.network.handler.NeoForgeClientPayloadHandler;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.network.handling.PlayPayloadContext;

import vazkii.patchouli.client.book.ClientBookRegistry;
import vazkii.patchouli.neoforge.network.NeoForgeMessageOpenBookGui;
import vazkii.patchouli.neoforge.network.NeoForgeMessageReloadBookContents;
Expand All @@ -15,8 +16,8 @@ public static NeoForgeClientPayloadHandler getInstance() {

public void handleData(final NeoForgeMessageOpenBookGui data, final PlayPayloadContext context) {
context.workHandler().submitAsync(() -> {
ClientBookRegistry.INSTANCE.displayBookGui(data.book(), data.entry(), data.page());
})
ClientBookRegistry.INSTANCE.displayBookGui(data.book(), data.entry(), data.page());
})
.exceptionally(e -> {
// Handle exception
context.packetHandler().disconnect(Component.translatable("patchouli.networking.failed", e.getMessage()));
Expand All @@ -26,8 +27,8 @@ public void handleData(final NeoForgeMessageOpenBookGui data, final PlayPayloadC

public void handleData(final NeoForgeMessageReloadBookContents data, final PlayPayloadContext context) {
context.workHandler().submitAsync(() -> {
ClientBookRegistry.INSTANCE.reload();
})
ClientBookRegistry.INSTANCE.reload();
})
.exceptionally(e -> {
// Handle exception
context.packetHandler().disconnect(Component.translatable("patchouli.networking.failed", e.getMessage()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.fml.ModList;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;

import vazkii.patchouli.api.BookContentsReloadEvent;
import vazkii.patchouli.api.BookDrawScreenEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementHolder;
import net.minecraft.advancements.AdvancementProgress;
import net.minecraft.client.Minecraft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;

import net.minecraft.network.chat.contents.PlainTextContents;

import vazkii.patchouli.client.book.text.BookTextParser;
import vazkii.patchouli.client.book.text.TextLayouter;
import vazkii.patchouli.client.book.text.Word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package vazkii.patchouli.client.book.template.variable;

import com.google.gson.JsonElement;

import com.mojang.serialization.JsonOps;

import net.minecraft.world.item.crafting.Ingredient;

import vazkii.patchouli.api.IVariableSerializer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.ExtraCodecs;
Expand Down Expand Up @@ -51,11 +52,11 @@ public RecipeSerializer<?> getSerializer() {
public static class Serializer implements RecipeSerializer<ShapedBookRecipe> {
public static final Codec<ShapedBookRecipe> CODEC = RecordCodecBuilder.create(
instance -> instance.group(
ExtraCodecs.strictOptionalField(Codec.STRING, "group", "").forGetter(bookRecipe -> bookRecipe.group),
ShapedRecipePattern.MAP_CODEC.forGetter(bookRecipe -> bookRecipe.pattern),
ExtraCodecs.strictOptionalField(ItemStack.ITEM_WITH_COUNT_CODEC, "result", ItemStack.EMPTY).forGetter(bookRecipe -> bookRecipe.result),
ExtraCodecs.strictOptionalField(ResourceLocation.CODEC, "book", null).forGetter(bookRecipe -> bookRecipe.outputBook)
)
ExtraCodecs.strictOptionalField(Codec.STRING, "group", "").forGetter(bookRecipe -> bookRecipe.group),
ShapedRecipePattern.MAP_CODEC.forGetter(bookRecipe -> bookRecipe.pattern),
ExtraCodecs.strictOptionalField(ItemStack.ITEM_WITH_COUNT_CODEC, "result", ItemStack.EMPTY).forGetter(bookRecipe -> bookRecipe.result),
ExtraCodecs.strictOptionalField(ResourceLocation.CODEC, "book", null).forGetter(bookRecipe -> bookRecipe.outputBook)
)
.apply(instance, ShapedBookRecipe::new)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import net.minecraft.core.NonNullList;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -55,28 +56,28 @@ public static class Serializer implements RecipeSerializer<ShapelessBookRecipe>
static int maxHeight = 3;
private static final Codec<ShapelessBookRecipe> CODEC = RecordCodecBuilder.create(
instance -> instance.group(
ExtraCodecs.strictOptionalField(Codec.STRING, "group", "").forGetter(bookRecipe -> bookRecipe.group),
ExtraCodecs.strictOptionalField(ItemStack.ITEM_WITH_COUNT_CODEC, "result", ItemStack.EMPTY).forGetter(bookRecipe -> bookRecipe.result),
Ingredient.CODEC_NONEMPTY
.listOf()
.fieldOf("ingredients")
.flatXmap(
ingredientList -> {
Ingredient[] aingredient = ingredientList
.toArray(Ingredient[]::new);
if (aingredient.length == 0) {
return DataResult.error(() -> "No ingredients for shapeless book recipe");
} else {
return aingredient.length > maxHeight * maxWidth
? DataResult.error(() -> "Too many ingredients for shapeless book recipe. The maximum is: %s".formatted(maxHeight * maxWidth))
: DataResult.success(NonNullList.of(Ingredient.EMPTY, aingredient));
}
},
DataResult::success
)
.forGetter(bookRecipe -> bookRecipe.ingredients),
ExtraCodecs.strictOptionalField(ResourceLocation.CODEC, "book", null).forGetter(bookRecipe -> bookRecipe.outputBook)
)
ExtraCodecs.strictOptionalField(Codec.STRING, "group", "").forGetter(bookRecipe -> bookRecipe.group),
ExtraCodecs.strictOptionalField(ItemStack.ITEM_WITH_COUNT_CODEC, "result", ItemStack.EMPTY).forGetter(bookRecipe -> bookRecipe.result),
Ingredient.CODEC_NONEMPTY
.listOf()
.fieldOf("ingredients")
.flatXmap(
ingredientList -> {
Ingredient[] aingredient = ingredientList
.toArray(Ingredient[]::new);
if (aingredient.length == 0) {
return DataResult.error(() -> "No ingredients for shapeless book recipe");
} else {
return aingredient.length > maxHeight * maxWidth
? DataResult.error(() -> "Too many ingredients for shapeless book recipe. The maximum is: %s".formatted(maxHeight * maxWidth))
: DataResult.success(NonNullList.of(Ingredient.EMPTY, aingredient));
}
},
DataResult::success
)
.forGetter(bookRecipe -> bookRecipe.ingredients),
ExtraCodecs.strictOptionalField(ResourceLocation.CODEC, "book", null).forGetter(bookRecipe -> bookRecipe.outputBook)
)
.apply(instance, ShapelessBookRecipe::new)
);

Expand Down

0 comments on commit c4e2516

Please sign in to comment.