Started by
SuperBully
on
Topic category: Advanced modding
Hello! I have a bit of custom code that can apply armor trims to armor. This isn't for custom armor trims, just attempting to replicate the vanilla feature of applying armor trims to armor.
My code, which was NOT written by me but by someone else on this forum who was helping me, was working for 2025.2. Here's the custom code snippet:
(patternGet & matGet are local itemstack variables. patternGet is the trim, matGet is the material like lapis or gold.)
Level level = entity.level();
Holder.Reference<TrimMaterial> trimMaterial = TrimMaterials.getFromIngredient(level.registryAccess(), matGet).get();
Holder.Reference<TrimPattern> trimPattern = TrimPatterns.getFromTemplate(level.registryAccess(), patternGet).get();
itemOutput.applyComponents(
DataComponentMap.builder()
.set(DataComponents.TRIM, new ArmorTrim(trimMaterial, trimPattern))
.build()
);
Now in 2025.3 it returns an error when compiling:
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler output below.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\Thanatos\MCreatorWorkspaces\mc_modern_progression\src\main\java\net\mcreator\mcmodernprogression\procedures\SmithingTableUpdateProcedure.java:462: error: incompatible types: Holder cannot be converted to Reference
Holder.Reference<TrimMaterial> trimMaterial = TrimMaterials.getFromIngredient(level.registryAccess(), matGet).get();
^
C:\Users\Thanatos\MCreatorWorkspaces\mc_modern_progression\src\main\java\net\mcreator\mcmodernprogression\procedures\SmithingTableUpdateProcedure.java:463: error: cannot find symbol
Holder.Reference<TrimPattern> trimPattern = TrimPatterns.getFromTemplate(level.registryAccess(), patternGet).get();
^
symbol: method getFromTemplate(RegistryAccess,ItemStack)
location: class TrimPatterns
2 errorsI'm at a loss for why this is happening as I'm super inexperienced with custom code. Is there an easy way to fix this? Any help is appreciated!
Every Minecraft version changes things, so you will need to adapt this code manually to work with new Minecraft versions
What versions did you use in either of those?
The working code was in Mcreator 2025.2 for Minecraft 1.21.4 and the error was in Mcreator 2025.3 for Minecraft 1.21.8
There were significant changes to Minecraft code between these two, so you will need to do some code adaptations.
You can use built-in decompiled code browser too see what was changed