-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/legobmw99/allomancy/modules/extras/mixin/BannerDFUMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.legobmw99.allomancy.modules.extras.mixin; | ||
|
||
import com.legobmw99.allomancy.Allomancy; | ||
import com.legobmw99.allomancy.api.enums.Metal; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.util.datafix.fixes.BannerPatternFormatFix; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Mutable; | ||
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.CallbackInfo; | ||
|
||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
|
||
/** | ||
* TEMPORARY: Used to port 1.20 banners to 1.21 | ||
* TODO: Remove in future version once worlds have updated | ||
*/ | ||
@Mixin(BannerPatternFormatFix.class) | ||
public class BannerDFUMixin { | ||
@Mutable | ||
@Final | ||
@Shadow | ||
private static Map<String, String> PATTERN_ID_MAP; | ||
|
||
@Inject(at = @At("RETURN"), method = "<clinit>") | ||
private static void onConstruct(CallbackInfo info) { | ||
|
||
Allomancy.LOGGER.info("Injecting to banner DFU"); | ||
var patternMap = new HashMap<>(PATTERN_ID_MAP); | ||
|
||
for (Metal mt : Metal.values()) { | ||
String name = mt.getName(); | ||
Allomancy.LOGGER.info("Redirecting banner pattern for {}", name); | ||
patternMap.put("ALLOMANCY" + name.toUpperCase(Locale.ROOT), | ||
ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, name).toString()); | ||
} | ||
|
||
PATTERN_ID_MAP = patternMap; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"required": true, | ||
"minVersion": "0.8", | ||
"package": "com.legobmw99.allomancy.modules.extras.mixin", | ||
"compatibilityLevel": "JAVA_21", | ||
"mixins": ["BannerDFUMixin"], | ||
"client": [], | ||
"server": [], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |