Skip to content

Commit

Permalink
Fix ModMixin annotation for both Forge and Fabric due to incorrect cl…
Browse files Browse the repository at this point in the history
…ass load order
  • Loading branch information
hlysine committed Oct 31, 2024
1 parent f7b0587 commit 5e1948c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 2 additions & 11 deletions common/src/main/java/com/copycatsplus/copycats/compat/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public enum Mods {
SODIUM("sodium"),
ATHENA("athena"),
INDIUM("indium"),
STARLIGHT("starlight");
STARLIGHT("starlight"),
DOUBLE_SLABS("doubleslabs");

public final String id;
public final boolean isLoaded;
Expand All @@ -56,23 +57,13 @@ public ResourceLocation rl(String path) {
return new ResourceLocation(id, path);
}

public Item getItem(String id) {
return BuiltInRegistries.ITEM.get(rl(id));
}

public Item getItem(ResourceLocation id) {
return BuiltInRegistries.ITEM.get(id);
}

public boolean getLoaded() {
return isLoaded;
}

/**
* @return a boolean of whether the mod is loaded or not based on mod id
*/


@ExpectPlatform
public static boolean getLoaded(String id) {
throw new AssertionError();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.copycatsplus.copycats.compat.forge;

import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLLoader;

public class ModsImpl {


public static boolean getLoaded(String id) {
// If ModList is null, we are in the loading stage, so we need to check the loading mod list
if (ModList.get() == null)
return FMLLoader.getLoadingModList().getMods().stream().anyMatch(mod -> mod.getModId().equals(id));
return ModList.get().isLoaded(id);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.copycatsplus.copycats.forge.mixin.compat.doubleslabs;

import cjminecraft.doubleslabs.common.config.DSConfig;
import com.copycatsplus.copycats.compat.Mods;
import com.copycatsplus.copycats.foundation.annotation.ModMixin;
import com.copycatsplus.copycats.foundation.copycat.ICopycatBlock;
import net.minecraft.world.level.block.Block;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -12,6 +14,7 @@
/**
* Always blacklist copycat blocks from being considered by Double Slabs.
*/
@ModMixin(requiredMods = Mods.DOUBLE_SLABS)
@Mixin(DSConfig.Common.class)
@Pseudo
public class DSConfigCommonMixin {
Expand Down

0 comments on commit 5e1948c

Please sign in to comment.