Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.6 #744

Merged
merged 26 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eb477d7
Port to 1.20.5
Mrbysco Apr 24, 2024
7ab23b5
Remove leftover commented out code from the port
Mrbysco Apr 24, 2024
d8097ec
Port to 1.20.6
Mrbysco Apr 29, 2024
8228d3c
Update tick events
Mrbysco Apr 29, 2024
51df1a3
Update NeoForge
Mrbysco May 2, 2024
e7af056
Remove custom book recipe
Mrbysco May 3, 2024
5094036
Remove Accessor
Mrbysco May 4, 2024
3748c19
Register DataComponent before items
Mrbysco May 6, 2024
0b43ba4
Fix test recipes
Mrbysco May 6, 2024
7c99926
Update neoforge
Mrbysco May 22, 2024
e458ff3
Change the stack serialization method (WIP)
Mrbysco May 23, 2024
52439fc
Feed registry access where possible
Mrbysco Jun 9, 2024
919ce3e
Fix typo in networking translation key
Mrbysco Jun 9, 2024
013d129
Update NeoForge and Fabric
Mrbysco Jun 11, 2024
50736e1
Fix a creative tab crash
Mrbysco Jun 11, 2024
111b13b
Disable NeoForge test since it conflicts
Mrbysco Jun 11, 2024
360067c
Update JEI and REI
Mrbysco Jun 17, 2024
ca081af
Fix Ingredient Variable serializer not using the HolderLookup
Mrbysco Jun 17, 2024
1dbfa89
Change the ItemStackVariableSerializer toJson to use "components"
Mrbysco Jun 17, 2024
b5af6d0
Revert change to ItemStackUtil#loadStackFromJson
Mrbysco Jun 17, 2024
f99ce59
Change the spotlight page to use ItemStack[] instead of Ingredient
Mrbysco Jun 22, 2024
ac94dda
Remove the isString check from TextComponentVariableSerializer
Mrbysco Jun 22, 2024
b4a1d8a
add HolderLookup.Provider context in VariableAssigner
Minecraftschurli Jul 1, 2024
a0c689f
Merge remote-tracking branch 'upstream/1.20.x' into 1.20.5
Minecraftschurli Jul 1, 2024
14fda7f
Update BookOpenTrigger codec
Minecraftschurli Jul 1, 2024
9071f41
Spotless apply
Minecraftschurli Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '21'
- name: Validate gradlew integrity
uses: gradle/wrapper-validation-action@v1
- name: Restore cache
Expand Down
10 changes: 5 additions & 5 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ dependencies {

minecraft "com.mojang:minecraft:${mc_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:0.15.3"
modImplementation "net.fabricmc:fabric-loader:0.15.11"

modImplementation "net.fabricmc.fabric-api:fabric-api:0.92.1+1.20.4"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.100.0+1.20.6"
compileOnly project(":Xplat")

modCompileOnly "mezz.jei:jei-1.20.4-common-api:17.0.0.30"
modCompileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62"

modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:14.0.688") { transitive = false }
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:13.0.121") { transitive = false }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:16.0.729") { transitive = false }
modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:14.0.126") { transitive = false }
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import vazkii.patchouli.common.item.PatchouliItems;
import vazkii.patchouli.fabric.network.FabricMessageOpenBookGui;
import vazkii.patchouli.fabric.network.FabricMessageReloadBookContents;
import vazkii.patchouli.network.MessageOpenBookGui;
import vazkii.patchouli.network.MessageReloadBookContents;

import org.jetbrains.annotations.Nullable;

Expand All @@ -50,8 +52,8 @@ public void onInitializeClient() {
UseBlockCallback.EVENT.register(MultiblockVisualizationHandler::onPlayerInteract);
ClientTickEvents.END_CLIENT_TICK.register(MultiblockVisualizationHandler::onClientTick);
HudRenderCallback.EVENT.register(MultiblockVisualizationHandler::onRenderHUD);
ClientPlayNetworking.registerGlobalReceiver(FabricMessageOpenBookGui.ID, FabricMessageOpenBookGui::handle);
ClientPlayNetworking.registerGlobalReceiver(FabricMessageReloadBookContents.ID, FabricMessageReloadBookContents::handle);
ClientPlayNetworking.registerGlobalReceiver(MessageOpenBookGui.TYPE, FabricMessageOpenBookGui::handle);
ClientPlayNetworking.registerGlobalReceiver(MessageReloadBookContents.TYPE, FabricMessageReloadBookContents::handle);

ModelLoadingPlugin.register(pluginContext -> {
for (Book book : BookRegistry.INSTANCE.books.values()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
Expand All @@ -18,18 +19,24 @@
import vazkii.patchouli.common.handler.LecternEventHandler;
import vazkii.patchouli.common.handler.ReloadContentsHandler;
import vazkii.patchouli.common.item.ItemModBook;
import vazkii.patchouli.common.item.PatchouliDataComponents;
import vazkii.patchouli.common.item.PatchouliItems;
import vazkii.patchouli.network.MessageOpenBookGui;
import vazkii.patchouli.network.MessageReloadBookContents;

public class FabricModInitializer implements ModInitializer {
@Override
public void onInitialize() {
PatchouliSounds.submitRegistrations((id, e) -> Registry.register(BuiltInRegistries.SOUND_EVENT, id, e));
PatchouliDataComponents.submitDataComponentRegistrations((id, e) -> Registry.register(BuiltInRegistries.DATA_COMPONENT_TYPE, id, e));
PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(BuiltInRegistries.ITEM, id, e));
PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, e));
FiberPatchouliConfig.setup();
CommandRegistrationCallback.EVENT.register((disp, buildCtx, selection) -> OpenBookCommand.register(disp));
UseBlockCallback.EVENT.register(LecternEventHandler::rightClick);

PayloadTypeRegistry.playS2C().register(MessageOpenBookGui.TYPE, MessageOpenBookGui.CODEC);
PayloadTypeRegistry.playS2C().register(MessageReloadBookContents.TYPE, MessageReloadBookContents.CODEC);

BookRegistry.INSTANCE.init();

ServerLifecycleEvents.END_DATA_PACK_RELOAD.register((server, _r, success) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
package vazkii.patchouli.fabric.network;

import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.client.book.ClientBookRegistry;
import vazkii.patchouli.network.MessageOpenBookGui;

import org.jetbrains.annotations.Nullable;


import io.netty.buffer.Unpooled;

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

public static void send(ServerPlayer player, ResourceLocation book, @Nullable ResourceLocation entry, int page) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
buf.writeResourceLocation(book);
buf.writeUtf(entry == null ? "" : entry.toString());
buf.writeVarInt(page);
ServerPlayNetworking.send(player, ID, buf);
ServerPlayNetworking.send(player, new MessageOpenBookGui(book, entry, page));
}

public static void handle(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
ResourceLocation book = buf.readResourceLocation();
ResourceLocation entry;
String tmp = buf.readUtf();
if (tmp.isEmpty()) {
entry = null;
} else {
entry = ResourceLocation.tryParse(tmp);
}

int page = buf.readVarInt();
client.submit(() -> ClientBookRegistry.INSTANCE.displayBookGui(book, entry, page));
public static void handle(MessageOpenBookGui message, ClientPlayNetworking.Context handler) {
Minecraft client = handler.client();
client.submit(() -> ClientBookRegistry.INSTANCE.displayBookGui(message.book(), message.entry(), message.page()));
}

}
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
package vazkii.patchouli.fabric.network;

import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PlayerLookup;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;

import vazkii.patchouli.api.PatchouliAPI;
import vazkii.patchouli.client.book.ClientBookRegistry;


import io.netty.buffer.Unpooled;
import vazkii.patchouli.network.MessageReloadBookContents;

public class FabricMessageReloadBookContents {
public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "reload_books");

public static void sendToAll(MinecraftServer server) {
PlayerLookup.all(server).forEach(FabricMessageReloadBookContents::send);
}

public static void send(ServerPlayer player) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.EMPTY_BUFFER);
ServerPlayNetworking.send(player, ID, buf);
ServerPlayNetworking.send(player, new MessageReloadBookContents());
}

public static void handle(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
public static void handle(MessageReloadBookContents message, ClientPlayNetworking.Context handler) {
Minecraft client = handler.client();
client.submit(() -> ClientBookRegistry.INSTANCE.reload());
}
}
6 changes: 3 additions & 3 deletions Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
],

"depends": {
"fabricloader": ">=0.14.21",
"fabric": ">=0.87.0",
"minecraft": ">=1.20.1 <1.21"
"fabricloader": ">=0.15.10",
"fabric": ">=0.97.6",
"minecraft": ">=1.20.6 <1.21"
}
}
2 changes: 1 addition & 1 deletion Fabric/src/main/resources/patchouli_fabric.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "vazkii.patchouli.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
],
"client": [
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pipeline {
}
agent any
tools {
jdk "jdk-17.0.1"
jdk "jdk-21.0.2"
}
stages {
stage('Clean') {
Expand Down
11 changes: 8 additions & 3 deletions NeoForge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,16 @@ runs {
}

dependencies {
implementation "net.neoforged:neoforge:20.4.173"
implementation "net.neoforged:neoforge:20.6.115"
implementation project(":Xplat")

compileOnly "mezz.jei:jei-1.20.4-common-api:17.0.0.30"
testCompileOnly "mezz.jei:jei-1.20.4-common-api:17.0.0.30"
compileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62"
testCompileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62"
}

tasks.named('test').configure {
//Disable builtin test as we have JUnit enabled in Xplat
enabled(false)
}

TaskCollection.metaClass.excludingNeoTasks = { ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@
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.common.EventBusSubscriber;
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.client.event.ClientPlayerNetworkEvent;
import net.neoforged.neoforge.client.event.ClientTickEvent;
import net.neoforged.neoforge.client.event.ModelEvent;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.client.event.RegisterGuiLayersEvent;
import net.neoforged.neoforge.client.event.RenderFrameEvent;
import net.neoforged.neoforge.client.event.RenderTooltipEvent;
import net.neoforged.neoforge.client.gui.VanillaGuiLayers;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.TickEvent;
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;

import vazkii.patchouli.api.PatchouliAPI;
Expand All @@ -36,7 +41,7 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Mod.EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class NeoForgeClientInitializer {
/**
* Why are these necessary?
Expand Down Expand Up @@ -99,23 +104,21 @@ public static void registerReloadListeners(RegisterClientReloadListenersEvent e)
}

@SubscribeEvent
public static void registerOverlays(RegisterGuiOverlaysEvent evt) {
evt.registerAbove(VanillaGuiOverlay.CROSSHAIR.id(), new ResourceLocation(PatchouliAPI.MOD_ID, "book_overlay"),
(gui, poseStack, partialTick, width, height) -> BookRightClickHandler.onRenderHUD(poseStack, partialTick)
public static void registerOverlays(RegisterGuiLayersEvent evt) {
evt.registerAbove(VanillaGuiLayers.CROSSHAIR, new ResourceLocation(PatchouliAPI.MOD_ID, "book_overlay"),
BookRightClickHandler::onRenderHUD
);
evt.registerBelow(VanillaGuiOverlay.BOSS_EVENT_PROGRESS.id(), new ResourceLocation(PatchouliAPI.MOD_ID, "multiblock_progress"),
(gui, poseStack, partialTick, width, height) -> MultiblockVisualizationHandler.onRenderHUD(poseStack, partialTick)
evt.registerBelow(VanillaGuiLayers.BOSS_OVERLAY, new ResourceLocation(PatchouliAPI.MOD_ID, "multiblock_progress"),
MultiblockVisualizationHandler::onRenderHUD
);
}

@SubscribeEvent
public static void onInitializeClient(FMLClientSetupEvent evt) {
ClientBookRegistry.INSTANCE.init();
PersistentData.setup();
NeoForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> {
if (e.phase == TickEvent.Phase.END) {
ClientTicker.endClientTick(Minecraft.getInstance());
}
NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post e) -> {
ClientTicker.endClientTick(Minecraft.getInstance());
});
NeoForge.EVENT_BUS.addListener((PlayerInteractEvent.RightClickBlock e) -> BookRightClickHandler.onRightClick(e.getEntity(), e.getLevel(), e.getHand(), e.getHitVec()));
NeoForge.EVENT_BUS.addListener((PlayerInteractEvent.RightClickBlock e) -> {
Expand All @@ -125,18 +128,15 @@ public static void onInitializeClient(FMLClientSetupEvent evt) {
e.setCancellationResult(result);
}
});
NeoForge.EVENT_BUS.addListener((TickEvent.ClientTickEvent e) -> {
if (e.phase == TickEvent.Phase.END) {
MultiblockVisualizationHandler.onClientTick(Minecraft.getInstance());
}
NeoForge.EVENT_BUS.addListener((ClientTickEvent.Post e) -> {
MultiblockVisualizationHandler.onClientTick(Minecraft.getInstance());
});

NeoForge.EVENT_BUS.addListener((TickEvent.RenderTickEvent e) -> {
if (e.phase == TickEvent.Phase.START) {
ClientTicker.renderTickStart(e.renderTickTime);
} else {
ClientTicker.renderTickEnd();
}
NeoForge.EVENT_BUS.addListener((RenderFrameEvent.Pre e) -> {
ClientTicker.renderTickStart(e.getPartialTick());
});
NeoForge.EVENT_BUS.addListener((RenderFrameEvent.Post e) -> {
ClientTicker.renderTickEnd();
});

NeoForge.EVENT_BUS.addListener((ClientPlayerNetworkEvent.LoggingOut e) -> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package vazkii.patchouli.neoforge.common;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.ItemStack;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
Expand All @@ -22,14 +26,15 @@
import vazkii.patchouli.common.handler.LecternEventHandler;
import vazkii.patchouli.common.handler.ReloadContentsHandler;
import vazkii.patchouli.common.item.ItemModBook;
import vazkii.patchouli.common.item.PatchouliDataComponents;
import vazkii.patchouli.common.item.PatchouliItems;
import vazkii.patchouli.neoforge.network.NeoForgeNetworkHandler;

@Mod.EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
@EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
@Mod(PatchouliAPI.MOD_ID)
public class NeoForgeModInitializer {
public NeoForgeModInitializer(IEventBus eventBus) {
NeoForgePatchouliConfig.setup();
public NeoForgeModInitializer(IEventBus eventBus, Dist dist, ModContainer container) {
NeoForgePatchouliConfig.setup(container);

eventBus.addListener(NeoForgeNetworkHandler::setupPackets);
}
Expand All @@ -39,12 +44,12 @@ public static void register(RegisterEvent evt) {
evt.register(Registries.SOUND_EVENT, rh -> {
PatchouliSounds.submitRegistrations(rh::register);
});
evt.register(Registries.DATA_COMPONENT_TYPE, rh -> {
PatchouliDataComponents.submitDataComponentRegistrations(rh::register);
});
evt.register(Registries.ITEM, rh -> {
PatchouliItems.submitItemRegistrations(rh::register);
});
evt.register(Registries.RECIPE_SERIALIZER, rh -> {
PatchouliItems.submitRecipeSerializerRegistrations(rh::register);
});
}

@SubscribeEvent
Expand All @@ -53,7 +58,7 @@ public static void processCreativeTabs(BuildCreativeModeTabContentsEvent evt) {
if (!b.noBook) {
ItemStack book = ItemModBook.forBook(b);
if (evt.getTab() == CreativeModeTabs.searchTab()) {
evt.accept(book);
evt.accept(book, CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY);
} else if (b.creativeTab != null) {
if (evt.getTab() == CreativeModeTabRegistry.getTab(b.creativeTab)) {
evt.accept(book);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package vazkii.patchouli.neoforge.common;

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

Expand Down Expand Up @@ -55,8 +55,8 @@ public class NeoForgePatchouliConfig {
SPEC = builder.build();
}

public static void setup() {
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, SPEC);
public static void setup(ModContainer container) {
container.registerConfig(ModConfig.Type.CLIENT, SPEC);
PatchouliConfig.set(new PatchouliConfigAccess() {
@Override
public boolean disableAdvancementLocking() {
Expand Down
Loading