Add new variation compat. Mostly untested.

This commit is contained in:
tterrag1098 committed 2015-01-10 04:39:10 -05:00
1 parent d5402082ab
commit b0889fc2aa
5 files changed
+60 -149

No files matched your search

@@ -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;
@@ -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);
@@ -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";
@@ -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);
}
};
}
}
@@ -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<Triple<Block, Integer, String>> 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<Triple<Block, Integer, String>> blocks) {
for (Triple<Block, Integer, String> t : blocks) {
Carving.chisel.addVariation(t.getRight(), t.getLeft(), t.getMiddle(), 99);
}
}
private Block find(String modid, String block) {
return GameRegistry.findBlock(modid, block);
}
}