Add postea transformer for microblock items (#48)

This commit is contained in:
FourIsTheNumber authored and GitHub committed 2026-07-04 20:02:17 -04:00
1 parent 09e2b847fc
commit d2ce5b7362
4 files changed
+45

No files matched your search

+1
View File
@@ -3,6 +3,7 @@
dependencies {
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.12:dev")
compileOnly("com.github.GTNewHorizons:Angelica:2.1.19:dev")
compileOnly("com.github.GTNewHorizons:Postea:1.2.5:dev") {transitive = false}
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.93-GTNH:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'CodeChickenCore'
}
@@ -0,0 +1,29 @@
package codechicken.microblock.compat;
import net.minecraft.nbt.NBTTagCompound;
import com.gtnewhorizons.postea.api.IItemStackTransformationHandler;
import codechicken.microblock.MicroMaterialRegistry;
public class ItemMicroPartTransformer implements IItemStackTransformationHandler {
@Override
public boolean apply(String originalItemId, NBTTagCompound stackTag) {
if (!stackTag.hasKey("tag")) return false;
NBTTagCompound tag = stackTag.getCompoundTag("tag");
if (!tag.hasKey("mat")) return false;
String matName = tag.getString("mat");
// Goes through the remap layer, which is private
int remappedId = MicroMaterialRegistry.materialID(matName);
String remappedName = MicroMaterialRegistry.materialName(remappedId);
if (remappedName.equals(matName)) return false;
tag.setString("mat", remappedName);
stackTag.setTag("tag", tag);
return true;
}
}
@@ -0,0 +1,11 @@
package codechicken.microblock.compat;
import com.gtnewhorizons.postea.api.ItemStackReplacementManager;
public class PosteaCompat {
public static void registerTransformers() {
ItemStackReplacementManager
.addTransformationHandler("ForgeMicroblock:microblock", new ItemMicroPartTransformer());
}
}
@@ -16,6 +16,7 @@ import net.minecraftforge.oredict.OreDictionary
import net.minecraft.item.ItemStack
import net.minecraftforge.oredict.ShapedOreRecipe
import codechicken.lib.packet.PacketCustom
import codechicken.microblock.compat.PosteaCompat
import cpw.mods.fml.common.Loader
import cpw.mods.fml.common.registry.GameRegistry
import net.minecraft.client.renderer.RenderBlocks
@@ -110,6 +111,9 @@ class MicroblockProxy_serverImpl {
MicroblockSPH.registryChannel,
MicroblockSPH
)
if (Loader.isModLoaded("postea")) {
PosteaCompat.registerTransformers()
}
}
}