Skip to content

Commit

Permalink
Ensured some starter values for before game start on server
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed Dec 24, 2023
1 parent 2b28fe7 commit 10a702d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/turniplabs/halplibe/HalpLibe.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package turniplabs.halplibe;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import net.minecraft.core.Global;
Expand All @@ -9,6 +10,7 @@
import turniplabs.halplibe.helper.AchievementHelper;
import turniplabs.halplibe.helper.ModVersionHelper;
import turniplabs.halplibe.helper.NetworkHelper;
import turniplabs.halplibe.helper.SoundHelper;
import turniplabs.halplibe.util.TomlConfigHandler;
import turniplabs.halplibe.util.achievements.AchievementPage;
import turniplabs.halplibe.util.achievements.VanillaAchievementsPage;
Expand All @@ -19,7 +21,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

public class HalpLibe implements ModInitializer, PreLaunchEntrypoint {
public class HalpLibe implements ModInitializer, PreLaunchEntrypoint{
public static final String MOD_ID = "halplibe";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static boolean sendModlist;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/turniplabs/halplibe/helper/SoundHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


public class SoundHelper {
private static Hashtable<String, String> fileCache = new Hashtable<String, String>();
private static final Hashtable<String, String> fileCache = new Hashtable<String, String>();
public static final File appDirectory = Minecraft.getAppDir("minecraft-bta");
public static final File soundDirectory = new File(appDirectory.getAbsolutePath() + "/resources/mod/sound");
public static final File musicDirectory = new File(appDirectory.getAbsolutePath() + "/resources/mod/music");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package turniplabs.halplibe.mixin.mixins;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.Global;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
Expand All @@ -11,12 +13,16 @@

@Mixin(value = MinecraftServer.class, remap = false)
public class MinecraftServerMixin {
@Shadow private static MinecraftServer instance;

@Inject(method = "startServer", at = @At(value = "INVOKE",target = "Lnet/minecraft/core/data/DataLoader;loadRecipes(Ljava/lang/String;)V", ordinal = 3, shift = At.Shift.AFTER))
public void recipeEntrypoint(CallbackInfoReturnable<Boolean> cir){
FabricLoader.getInstance().getEntrypoints("recipesReady", RecipeEntrypoint.class).forEach(RecipeEntrypoint::onRecipesReady);
}
@Inject(method = "startServer", at = @At("HEAD"))
public void beforeGameStartEntrypoint(CallbackInfoReturnable<Boolean> cir){
instance = (MinecraftServer)(Object)this;
Global.isServer = true;
FabricLoader.getInstance().getEntrypoints("beforeGameStart", GameStartEntrypoint.class).forEach(GameStartEntrypoint::beforeGameStart);
}

Expand Down

0 comments on commit 10a702d

Please sign in to comment.