Created
January 21, 2018 14:58
-
-
Save kindlich/02c1f1387b34ebbabb4670f800225c46 to your computer and use it in GitHub Desktop.
Sky PartType
This file contains hidden or 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
| #loader contenttweaker | |
| #debug | |
| import mods.contenttweaker.VanillaFactory; | |
| import mods.contenttweaker.Item; | |
| import mods.contenttweaker.MaterialSystem; | |
| import mods.contenttweaker.PartDataPiece; | |
| import mods.contenttweaker.MaterialPart; | |
| import mods.contenttweaker.Color; | |
| import mods.contenttweaker.ResourceLocation; | |
| var craftingToolPartType = MaterialSystem.createPartType("crafting_tool", function(materialPart) { | |
| var materialName as string = materialPart.getMaterial().getUnlocalizedName(); | |
| var partName as string = materialPart.getPart().getUnlocalizedName(); | |
| var tool = VanillaFactory.createItem(materialName ~ "_" ~ partName); | |
| tool.maxStackSize = 1; | |
| tool.maxDamage = materialPart.getData().getIntValue("maxDamage", 256); | |
| tool.itemGetContainerItem = function(item) { | |
| return (item.damage + 1 < item.maxDamage) ? item.withDamage(item.damage + 1) : null; | |
| }; | |
| tool.itemColorSupplier = function(identifier) { | |
| return materialPart.getCTColor(); | |
| }; | |
| tool.itemTextureLocationSupplier = function(identifier) { | |
| print("itemTextureLocationSupplier for " ~ identifier); | |
| return ResourceLocation.create("contenttweaker:" + identifier); | |
| }; | |
| tool.register(); | |
| }); | |
| var maxDamageDataPiece = MaterialSystem.createPartDataPiece("maxDamage", false); | |
| craftingToolPartType.setData([maxDamageDataPiece] as PartDataPiece[]); | |
| var saw = MaterialSystem.getPartBuilder().setName("saw").setPartType(craftingToolPartType).build(); | |
| var cobalt = MaterialSystem.getMaterialBuilder().setName("Pyure Cobalt").setColor(18347).build(); | |
| var tin = MaterialSystem.getMaterialBuilder().setName("Pyure Tin").setColor(10275286).build(); | |
| cobalt.registerPart(saw); | |
| tin.registerPart(saw); |
This file contains hidden or 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
| public class SkyTest implements Runnable { | |
| public static void __script__() { | |
| IPartType var1 = CTMaterialSystem.createPartType("crafting_tool", new ZenClass0()); | |
| IPartDataPiece var3 = CTMaterialSystem.createPartDataPiece("maxDamage", false); | |
| var1.setData(new IPartDataPiece[]{var3}); | |
| IPart var5 = CTMaterialSystem.getPartBuilder().setName("saw").setPartType(var1).build(); | |
| IMaterial var7 = CTMaterialSystem.getMaterialBuilder().setName("Pyure Cobalt").setColor(18347).build(); | |
| IMaterial var9 = CTMaterialSystem.getMaterialBuilder().setName("Pyure Tin").setColor(10275286).build(); | |
| var7.registerPart(var5); | |
| var9.registerPart(var5); | |
| } | |
| } |
This file contains hidden or 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
| public class ZenClass0 implements IRegisterMaterialPart { | |
| public ZenClass0() { | |
| } | |
| public void register(IMaterialPart var1) { | |
| String var3 = var1.getMaterial().getUnlocalizedName(); | |
| String var5 = var1.getPart().getUnlocalizedName(); | |
| ItemRepresentation var7 = VanillaFactory.createItem(var3 + "_" + var5); | |
| var7.setMaxStackSize(1); | |
| var7.setMaxDamage(var1.getData().getIntValue("maxDamage", 256)); | |
| var7.setItemGetContainerItem(new ZenClass1()); | |
| var7.setItemColorSupplier(new ZenClass2()); | |
| var7.setItemTextureLocationSupplier(new ZenClass3()); | |
| var7.register(); | |
| } | |
| } |
This file contains hidden or 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
| public class ZenClass1 implements IItemGetContainerItem { | |
| public ZenClass1() { | |
| } | |
| public IItemStack getContainerItem(IItemStack var1) { | |
| return var1.getDamage() + 1 < var1.getMaxDamage() ? var1.withDamage(var1.getDamage() + 1) : null; | |
| } | |
| } |
This file contains hidden or 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
| public class ZenClass2 implements IColorSupplier { | |
| public ZenClass2() { | |
| } | |
| public CTColor getColor(String var1) { | |
| return var1.getCTColor(); | |
| } | |
| } |
This file contains hidden or 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
| public class ZenClass3 implements IResourceLocationSupplier { | |
| public ZenClass3() { | |
| } | |
| public CTResourceLocation getResourceLocation(String var1) { | |
| GlobalFunctions.print("itemTextureLocationSupplier for " + var1); | |
| return CTResourceLocation.create("contenttweaker:" + var1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment