From b0889fc2aa8d60e511480084417f62e2d5606177 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Sat, 10 Jan 2015 04:39:10 -0500 Subject: [PATCH] Add new variation compat. Mostly untested. --- .../java/com/cricketcraft/chisel/Chisel.java | 5 + .../chisel/compat/Compatibility.java | 2 +- .../chisel/compat/FMPIntegration.java | 2 +- .../chisel/compat/MarbleCompatibility.java | 147 ------------------ .../chisel/compat/VariationCompat.java | 53 +++++++ 5 files changed, 60 insertions(+), 149 deletions(-) delete mode 100644 src/main/java/com/cricketcraft/chisel/compat/MarbleCompatibility.java create mode 100644 src/main/java/com/cricketcraft/chisel/compat/VariationCompat.java diff --git a/src/main/java/com/cricketcraft/chisel/Chisel.java b/src/main/java/com/cricketcraft/chisel/Chisel.java index c1bd5dea..1150f741 100644 --- a/src/main/java/com/cricketcraft/chisel/Chisel.java +++ b/src/main/java/com/cricketcraft/chisel/Chisel.java @@ -51,6 +51,9 @@ import java.io.File; import java.util.ArrayList; import java.util.List; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + @Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:ForgeMultipart;after:Thaumcraft") public class Chisel { @@ -67,6 +70,8 @@ public class Chisel { public static int renderCarpetId; public static int renderAutoChiselId; public static int renderGlowId; + + public static final Logger logger = LogManager.getLogger(MOD_ID); @Instance(MOD_ID) public static Chisel instance; diff --git a/src/main/java/com/cricketcraft/chisel/compat/Compatibility.java b/src/main/java/com/cricketcraft/chisel/compat/Compatibility.java index bd52e7f5..ff5f038d 100644 --- a/src/main/java/com/cricketcraft/chisel/compat/Compatibility.java +++ b/src/main/java/com/cricketcraft/chisel/compat/Compatibility.java @@ -9,7 +9,7 @@ import cpw.mods.fml.common.registry.GameRegistry; public class Compatibility { public static void init(FMLPostInitializationEvent event) { - new MarbleCompatibility().postInit(event); + new VariationCompat().postInit(event); addSupport("ProjRed|Exploration", "projectred.exploration.stone", "marble", 0, 99); addSupport("bluepower", "marble", "marble", 0, 99); diff --git a/src/main/java/com/cricketcraft/chisel/compat/FMPIntegration.java b/src/main/java/com/cricketcraft/chisel/compat/FMPIntegration.java index b8805d80..179feb0d 100644 --- a/src/main/java/com/cricketcraft/chisel/compat/FMPIntegration.java +++ b/src/main/java/com/cricketcraft/chisel/compat/FMPIntegration.java @@ -9,7 +9,7 @@ import com.cricketcraft.chisel.init.ChiselBlocks; import cpw.mods.fml.common.event.FMLInterModComms; public class FMPIntegration implements IModIntegration { - + @Override public String getModId() { return "ForgeMicroblock"; diff --git a/src/main/java/com/cricketcraft/chisel/compat/MarbleCompatibility.java b/src/main/java/com/cricketcraft/chisel/compat/MarbleCompatibility.java deleted file mode 100644 index 0e30635f..00000000 --- a/src/main/java/com/cricketcraft/chisel/compat/MarbleCompatibility.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.cricketcraft.chisel.compat; - -import net.minecraft.block.Block; - -import com.cricketcraft.chisel.carving.Carving; - -import cpw.mods.fml.common.event.FMLPostInitializationEvent; - -public class MarbleCompatibility { - - abstract class ClassCompat { - - Class cl; - - public ClassCompat(String name) { - try { - if ((cl = Class.forName(name)) != null) - action(); - } catch (ClassNotFoundException e) { - // e.printStackTrace(); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (NoSuchFieldException e) { - e.printStackTrace(); - } catch (SecurityException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - abstract void action() throws Exception; - - abstract class BlockCompat { - - Block block; - - public BlockCompat(String variableName) throws Exception { - block = (Block) ClassCompat.this.cl.getField(variableName).get(null); - - if (block != null) - action(); - } - - abstract void action() throws Exception; - } - - ; - } - - ; - - abstract class ClassBlockCompat { - - Block block; - - ClassBlockCompat(final String className, final String blockName) { - new ClassCompat(className) { - - @Override - void action() throws Exception { - new BlockCompat(blockName) { - - @Override - void action() throws Exception { - ClassBlockCompat.this.doAction(block); - } - }; - } - }; - } - - void doAction(Block b) { - block = b; - - action(); - } - - abstract void action(); - } - - public void postInit(FMLPostInitializationEvent event) { - new ClassBlockCompat("shukaro.artifice.ArtificeBlocks", "marble") { - - @Override - void action() { - Carving.chisel.addVariation("marble", block, 0, 99); - } - }; - - new ClassCompat("shukaro.artifice.ArtificeBlocks") { - - @Override - void action() throws Exception { - Block[] blocks = (Block[]) cl.getField("blockLimestones").get(null); - - Carving.chisel.addVariation("limestone", blocks[0], 3, 99); - } - }; - - new ClassBlockCompat("com.bluepowermod.init.BPBlocks", "marble") { - - @Override - void action() { - Carving.chisel.addVariation("marble", block, 0, 99); - } - }; - - new ClassBlockCompat("num.numirp.block.ModBlocks", "blockDecor") { - - @Override - void action() { - Carving.chisel.addVariation("marble", block, 0, 99); - } - }; - - new ClassBlockCompat("mariculture.core.Core", "limestone") { - - @Override - void action() { - Carving.chisel.addVariation("limestone", block, 0, 99); - } - }; - new ClassBlockCompat("emasher.core.EmasherCore", "limestone") { - - @Override - void action() { - Carving.chisel.addVariation("limestone", block, 0, 99); - } - }; - - new ClassCompat("Reika.GeoStrata.GeoStrata") { - - @Override - void action() throws Exception { - Block[] blocks = (Block[]) cl.getField("blocks").get(null); - - Carving.chisel.addVariation("marble", blocks[0], 2, 99); - - Carving.chisel.addVariation("limestone", blocks[0], 3, 99); - } - }; - } - -} diff --git a/src/main/java/com/cricketcraft/chisel/compat/VariationCompat.java b/src/main/java/com/cricketcraft/chisel/compat/VariationCompat.java new file mode 100644 index 00000000..eefbb887 --- /dev/null +++ b/src/main/java/com/cricketcraft/chisel/compat/VariationCompat.java @@ -0,0 +1,53 @@ +package com.cricketcraft.chisel.compat; + +import java.util.List; + +import net.minecraft.block.Block; + +import org.apache.commons.lang3.tuple.Triple; + +import com.cricketcraft.chisel.carving.Carving; +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.registry.GameRegistry; + +public class VariationCompat { + + public static String[] rockColorNames = { "gray", "lightgray", "brown", "tan", "reddish", "bluish", "greenish" }; + + public void postInit(FMLPostInitializationEvent event) { + // block, metadata, category + List> blocks = Lists.newArrayList(); + + /* Artifice */ + blocks.add(Triple.of(find("Artifice", "artifice.marble"), 0, "marble")); + blocks.add(Triple.of(find("Artifice", "artifice.marble.slab"), 0, "marble_slab")); + for (String s : rockColorNames) { + blocks.add(Triple.of(find("Artifice", "artifice.limestone." + s), 0, "limestone")); + } + + /* BluePower */ + blocks.add(Triple.of(find("bluepower", "marble"), 0, "marble")); + + /* Mariculture */ + Block block = find("mariculture", "limestone"); + for (int i = 0; i < 16; i++) { + blocks.add(Triple.of(block, i, "limestone")); + } + + // TODO geostrata + + registerAll(blocks); + } + + private void registerAll(List> blocks) { + for (Triple t : blocks) { + Carving.chisel.addVariation(t.getRight(), t.getLeft(), t.getMiddle(), 99); + } + } + + private Block find(String modid, String block) { + return GameRegistry.findBlock(modid, block); + } +}