Skip to content

Commit

Permalink
Fixed bug where recipe namespaces and groups weren't recreated on ser…
Browse files Browse the repository at this point in the history
…ver-client recipe sync.
  • Loading branch information
MartinSVK12 committed Mar 29, 2024
1 parent a6191e0 commit 36089b2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bta_version=7.1-pre2a
loader_version=0.15.6-babric.4-bta

# Mod
mod_version=3.5.0
mod_version=3.5.1
mod_group=turniplabs
mod_name=halplibe

16 changes: 15 additions & 1 deletion src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
import net.minecraft.core.block.BlockLanternFirefly;
import net.minecraft.core.data.gamerule.GameRuleBoolean;
import net.minecraft.core.data.gamerule.GameRules;
import net.minecraft.core.data.registry.Registries;
import net.minecraft.core.data.registry.recipe.RecipeNamespace;
import net.minecraft.core.item.Item;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.DyeColor;
import net.minecraft.core.world.biome.Biome;
import net.minecraft.core.world.biome.Biomes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import turniplabs.halplibe.helper.*;
import turniplabs.halplibe.util.RecipeEntrypoint;
import turniplabs.halplibe.util.TomlConfigHandler;
import turniplabs.halplibe.util.achievements.AchievementPage;
import turniplabs.halplibe.util.achievements.VanillaAchievementsPage;
Expand All @@ -24,7 +28,7 @@

import java.util.HashMap;

public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {
public class HalpLibe implements ModInitializer, PreLaunchEntrypoint, RecipeEntrypoint {
public static final String MOD_ID = "halplibe";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static boolean isClient = FabricLoader.getInstance().getEnvironmentType().equals(EnvType.CLIENT);
Expand Down Expand Up @@ -104,4 +108,14 @@ public void onPreLaunch() {
// Initializes halp statics first
NetworkHelper.register(PacketModList.class, false, true); // Register Halplibe packets first
}

@Override
public void onRecipesReady() {

}

@Override
public void initNamespaces() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class MinecraftMixin {

@Inject(method = "startGame", at = @At(value = "INVOKE",target = "Lnet/minecraft/core/data/DataLoader;loadRecipesFromFile(Ljava/lang/String;)V", ordinal = 3, shift = At.Shift.AFTER))
public void recipeEntrypoint(CallbackInfo ci){
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::initNamespaces);
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::onRecipesReady);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class MinecraftServerMixin {

@Inject(method = "startServer", at = @At(value = "INVOKE",target = "Lnet/minecraft/core/data/DataLoader;loadRecipesFromFile(Ljava/lang/String;)V", ordinal = 3, shift = At.Shift.AFTER))
public void recipeEntrypoint(CallbackInfoReturnable<Boolean> cir){
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::initNamespaces);
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::onRecipesReady);
}
@Inject(method = "startServer", at = @At("HEAD"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package turniplabs.halplibe.mixin.mixins;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.net.handler.NetClientHandler;
import net.minecraft.core.net.handler.NetHandler;
import net.minecraft.core.net.packet.Packet1Login;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import turniplabs.halplibe.util.RecipeEntrypoint;

@Mixin(value = NetClientHandler.class,remap = false)
public abstract class NetClientHandlerMixin extends NetHandler {

@Inject(method = "handleLogin", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/crafting/legacy/CraftingManager;reset()V", shift = At.Shift.BEFORE))
public void handleLogin(Packet1Login packet1login, CallbackInfo ci) {
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::initNamespaces);
}
}

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
],
"preLaunch": [
"turniplabs.halplibe.HalpLibe"
],
"recipesReady": [
"turniplabs.halplibe.HalpLibe"
]
},
"mixins": [
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/halplibe.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"package": "turniplabs.halplibe.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"mixins.RecipeRegistryMixin",
"accessors.BlockFireAccessor",
"accessors.EntityFireflyFXAccessor",
"accessors.EntityFXAccessor",
Expand All @@ -18,6 +17,7 @@
"mixins.ContainerPlayerCreativeMixin",
"mixins.I18nMixin",
"mixins.ItemStackJsonAdapterMixin",
"mixins.NetClientHandlerMixin",
"mixins.PacketMobSpawnMixin",
"mixins.commands.CommandsCoreMixin",
"mixins.network.PacketMixin",
Expand Down

0 comments on commit 36089b2

Please sign in to comment.