Fix FMP integration. All normal blocks are now auto registered.

Fixes #89
Fixes #93
This commit is contained in:
tterrag1098 committed 2015-01-12 23:52:53 -05:00
1 parent 9d63c73e99
commit 1920feeb1d
9 files changed
+59 -257

No files matched your search

@@ -1,8 +1,6 @@
package com.cricketcraft.chisel;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@@ -22,8 +20,6 @@ import com.cricketcraft.chisel.client.gui.GuiAutoChisel;
import com.cricketcraft.chisel.client.gui.GuiChisel;
import com.cricketcraft.chisel.client.gui.GuiPresent;
import com.cricketcraft.chisel.compat.Compatibility;
import com.cricketcraft.chisel.compat.FMPIntegration;
import com.cricketcraft.chisel.compat.ModIntegration;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.init.ChiselBlocks;
import com.cricketcraft.chisel.init.ChiselTabs;
@@ -56,13 +52,10 @@ import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.Type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Mod(modid = Chisel.MOD_ID, name = Chisel.MOD_NAME, version = Chisel.VERSION, guiFactory = "com.cricketcraft.chisel.client.gui.GuiFactory", dependencies = "after:ForgeMultipart;after:Thaumcraft;after:appliedenergistics2;after:Railcraft;after:AWWayofTime")
public class Chisel {
public static final List<String> modsSupported = new ArrayList<String>();
public static final String MOD_ID = "chisel";
public static final BlockCarvable.SoundType soundTempleFootstep = new BlockCarvable.SoundType("dig.stone", MOD_ID + ":step.templeblock", 1.0f, 1.0f);
public static final String MOD_NAME = "Chisel 2";
@@ -79,7 +72,7 @@ public class Chisel {
public static int renderLayeredId;
public static int roadLineId;
public static final Logger logger = LogManager.getLogger(MOD_ID);
public static final Logger logger = LogManager.getLogger(MOD_NAME);
@Instance(MOD_ID)
public static Chisel instance;
@@ -87,15 +80,6 @@ public class Chisel {
@SidedProxy(clientSide = "com.cricketcraft.chisel.proxy.ClientProxy", serverSide = "com.cricketcraft.chisel.proxy.CommonProxy")
public static CommonProxy proxy;
@SideOnly(Side.CLIENT)
private static void initModIntegration() {
if (Configurations.enableFMP) {
ModIntegration.addMod(FMPIntegration.class);
}
ModIntegration.init();
}
@EventHandler
public void missingMapping(FMLMissingMappingsEvent event) {
BlockNameConversion.init();
@@ -135,12 +119,7 @@ public class Chisel {
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
modsSupported.add("Thaumcraft");
modsSupported.add("AWWayOfTime");
modsSupported.add("Twilight Forest");
modsSupported.add("appliedenergistics2");
modsSupported.add("Railcraft");
File configFile = event.getSuggestedConfigurationFile();
Configurations.configExists = configFile.exists();
Configurations.config = new Configuration(configFile);
@@ -205,10 +184,6 @@ public class Chisel {
registerWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount);
registerWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount);
if (event.getSide() == Side.CLIENT) {
initModIntegration();
}
proxy.init();
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(instance);
@@ -225,7 +200,6 @@ public class Chisel {
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
ChiselTabs.postInit();
ModIntegration.postInit();
Compatibility.init(event);
}
@@ -39,6 +39,11 @@ public class BlockCarvableGlass extends BlockGlass implements ICarvable {
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isNormalCube() {
return true;
}
@Override
public int getRenderType() {
@@ -30,9 +30,4 @@ public class BlockCarvableLayered extends BlockCarvable {
public int getRenderType() {
return Chisel.renderLayeredId;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
}
@@ -19,6 +19,7 @@ import com.cricketcraft.chisel.block.BlockCarvableSlab;
import com.cricketcraft.chisel.carving.CarvableVariation.CarvableVariationCTM;
import com.cricketcraft.chisel.client.render.CTM;
import com.cricketcraft.chisel.client.render.TextureSubmap;
import com.cricketcraft.chisel.compat.FMPIntegration;
import com.cricketcraft.chisel.config.Configurations;
import com.cricketcraft.chisel.item.ItemCarvable;
import com.cricketcraft.chisel.utils.GeneralClient;
@@ -294,6 +295,11 @@ public class CarvableHelper {
}
public void registerVariation(String name, CarvableVariation variation, Block block, int blockMeta) {
if (block.renderAsNormalBlock() || block.isOpaqueCube() || block.isNormalCube()) {
FMPIntegration.registerFMP(block, blockMeta);
}
if (forbidChiseling)
return;
@@ -1,5 +1,7 @@
package com.cricketcraft.chisel.compat;
import net.minecraft.block.Block;
import com.cricketcraft.chisel.carving.Carving;
import cpw.mods.fml.common.Loader;
@@ -8,12 +10,30 @@ import cpw.mods.fml.common.registry.GameRegistry;
public class Compatibility {
public static void init(FMLPostInitializationEvent event) {
new VariationCompat().postInit(event);
public static String[] rockColorNames = { "gray", "lightgray", "brown", "tan", "reddish", "bluish", "greenish" };
public static void init(FMLPostInitializationEvent event) {
/* Proj Red */
addSupport("ProjRed|Exploration", "projectred.exploration.stone", "marble", 0, 99);
/* Bluepower */
addSupport("bluepower", "marble", "marble", 0, 99);
/* Artifice */
addSupport("Artifice", "artifice.marble", "marble", 0, 99);
addSupport("Artifice", "artifice.marble.slab", "marble_slab", 0, 99);
for (String s : rockColorNames) {
addSupport("Artifice", "artifice.limestone." + s, "limestone", 0, 99);
}
/* Mariculture */
Block block = GameRegistry.findBlock("mariculture", "limestone");
for (int i = 0; i < 16; i++) {
addSupport("limestone", block, i, 99);
}
/* Geologica */
addSupport("PFAAGeologica", "strongStone", "marble", 5, 99);
addSupport("PFAAGeologica", "strongStoneSlab", "marbleSlab", 5, 99);
addSupport("PFAAGeologica", "strongStoneBrickStairs.marble", "marbleStairs", 0, 99);
@@ -26,7 +46,11 @@ public class Compatibility {
public static void addSupport(String modname, String blockname, String name, int metadata, int order) {
if (Loader.isModLoaded(modname) && GameRegistry.findBlock(modname, blockname) != null) {
Carving.chisel.addVariation(name, GameRegistry.findBlock(modname, blockname), metadata, order);
addSupport(name, GameRegistry.findBlock(modname, blockname), metadata, order);
}
}
public static void addSupport(String name, Block block, int metadata, int order) {
Carving.chisel.addVariation(name, block, metadata, order);
}
}
@@ -2,102 +2,21 @@ package com.cricketcraft.chisel.compat;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import com.cricketcraft.chisel.compat.ModIntegration.IModIntegration;
import com.cricketcraft.chisel.init.ChiselBlocks;
import cpw.mods.fml.common.event.FMLInterModComms;
public class FMPIntegration implements IModIntegration {
@Override
public String getModId() {
return "ForgeMicroblock";
public class FMPIntegration {
public static void registerFMP(Block block) {
registerFMP(block, 0, 15);
}
@Override
public void onInit() {
registerMaterial(ChiselBlocks.marble);
registerMaterial(ChiselBlocks.limestone);
registerMaterial(ChiselBlocks.cobblestone, 1, 15);
registerMaterial(ChiselBlocks.glass, 1, 15);
registerMaterial(ChiselBlocks.sandstone, 3, 15);
registerMaterial(ChiselBlocks.sand_snakestone, 1, 1);
registerMaterial(ChiselBlocks.sand_snakestone, 13, 13);
registerMaterial(ChiselBlocks.sandstone_scribbles);
registerMaterial(ChiselBlocks.concrete, 0, 10);
registerMaterial(ChiselBlocks.iron_block, 1, 15);
registerMaterial(ChiselBlocks.gold_block, 1, 14);
registerMaterial(ChiselBlocks.diamond_block, 1, 12);
registerMaterial(ChiselBlocks.glowstone, 1, 15); // This is glowstone
registerMaterial(ChiselBlocks.lapis_block, 1, 8);
registerMaterial(ChiselBlocks.emerald_block, 1, 11);
registerMaterial(ChiselBlocks.nether_brick, 1, 5);
registerMaterial(ChiselBlocks.netherrack, 1, 14);
registerMaterial(ChiselBlocks.mossy_cobblestone, 1, 15);
registerMaterial(ChiselBlocks.stonebricksmooth, 4, 15);
registerMaterial(ChiselBlocks.stone_snakestone, 1, 1);
registerMaterial(ChiselBlocks.stone_snakestone, 13, 13);
registerMaterial(ChiselBlocks.dirt, 0, 3);
registerMaterial(ChiselBlocks.dirt, 6, 7);
registerMaterial(ChiselBlocks.dirt, 11, 11);
registerMaterial(ChiselBlocks.ice, 1, 15);
registerMaterial(ChiselBlocks.ice_pillar);
for (int x = 0; x < 4; x++) {
registerMaterial(ChiselBlocks.planks[x], 1, 15); // Oak, Spruce, Birch
// and Jungle
}
// Accacia
registerMaterial(ChiselBlocks.planks[4], 1, 1);
registerMaterial(ChiselBlocks.planks[4], 2, 2);
registerMaterial(ChiselBlocks.planks[4], 6, 6);
registerMaterial(ChiselBlocks.planks[4], 8, 11);
registerMaterial(ChiselBlocks.planks[4], 13, 13);
// Dark Oak
registerMaterial(ChiselBlocks.planks[5], 1, 1);
registerMaterial(ChiselBlocks.planks[5], 2, 2);
registerMaterial(ChiselBlocks.planks[5], 6, 6);
registerMaterial(ChiselBlocks.planks[5], 8, 11);
registerMaterial(ChiselBlocks.planks[5], 13, 13);
registerMaterial(ChiselBlocks.obsidian, 1, 15);
registerMaterial(ChiselBlocks.obsidian_snakestone, 1, 1);
registerMaterial(ChiselBlocks.obsidian_snakestone, 13, 13);
registerMaterial(ChiselBlocks.redstone_block, 1, 15);
registerMaterial(ChiselBlocks.holystone, 0, 13);
registerMaterial(ChiselBlocks.carpet_block);
registerMaterial(ChiselBlocks.lavastone, 0, 6);
registerMaterial(ChiselBlocks.fantasyblock, 0, 1);
registerMaterial(ChiselBlocks.fantasyblock, 3, 14);
registerMaterial(ChiselBlocks.tyrian);
registerMaterial(ChiselBlocks.templeblock, 1, 2);
registerMaterial(ChiselBlocks.templeblock, 4, 15);
registerMaterial(ChiselBlocks.mossy_templeblock, 1, 2);
registerMaterial(ChiselBlocks.mossy_templeblock, 4, 15);
registerMaterial(ChiselBlocks.factoryblock, 0, 12);
registerMaterial(ChiselBlocks.factoryblock, 14, 14);
registerMaterial(ChiselBlocks.stainedGlass[0]); // White
registerMaterial(ChiselBlocks.woolen_clay);
registerMaterial(ChiselBlocks.laboratoryblock, 2, 3);
registerMaterial(ChiselBlocks.laboratoryblock, 5, 12);
registerMaterial(ChiselBlocks.voidstone, 0, 3);
registerMaterial(ChiselBlocks.voidstone, 12, 15);
registerMaterial(ChiselBlocks.waterstone);
}
@Override
public void onPostInit() {
}
private void registerMaterial(Block block) {
registerMaterial(block, 0, 15);
}
private void registerMaterial(Block block, int minMeta, int maxMeta) {
public static void registerFMP(Block block, int minMeta, int maxMeta) {
for (int c = minMeta; c <= maxMeta; c++) {
FMLInterModComms.sendMessage(getModId(), "microMaterial", new ItemStack(block, 1, c));
registerFMP(block, c);
}
}
public static void registerFMP(Block block, int meta) {
FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(block, 1, meta));
}
}
@@ -1,52 +0,0 @@
package com.cricketcraft.chisel.compat;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.Loader;
public class ModIntegration {
private static List<IModIntegration> integratedMods = new ArrayList<IModIntegration>();
public static void addMod(Class<? extends IModIntegration> cls) {
try {
IModIntegration obj = cls.newInstance();
if (Loader.isModLoaded(obj.getModId())) {
integratedMods.add(obj);
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
public static void init() {
try {
for (IModIntegration integration : integratedMods) {
integration.onInit();
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
public static void postInit() {
try {
for (IModIntegration integration : integratedMods) {
integration.onPostInit();
}
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
static interface IModIntegration {
String getModId();
void onInit();
void onPostInit();
}
}
@@ -1,53 +0,0 @@
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"));
}
registerAll(blocks);
}
private void registerAll(List<Triple<Block, Integer, String>> blocks) {
for (Triple<Block, Integer, String> t : blocks) {
if (t.getRight() != null) {
Carving.chisel.addVariation(t.getRight(), t.getLeft(), t.getMiddle(), 99);
}
}
}
private Block find(String modid, String block) {
return GameRegistry.findBlock(modid, block);
}
}
@@ -1,14 +1,5 @@
package com.cricketcraft.chisel.init;
import static com.cricketcraft.chisel.init.ChiselBlocks.carpet_block;
import static com.cricketcraft.chisel.init.ChiselBlocks.jackolantern;
import static com.cricketcraft.chisel.init.ChiselBlocks.planks;
import static com.cricketcraft.chisel.init.ChiselBlocks.present;
import static com.cricketcraft.chisel.init.ChiselBlocks.pumpkin;
import static com.cricketcraft.chisel.init.ChiselBlocks.stainedGlass;
import static com.cricketcraft.chisel.init.ChiselBlocks.stainedGlassPane;
import static com.cricketcraft.chisel.init.ChiselBlocks.torch;
import static com.cricketcraft.chisel.utils.General.sGNames;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
@@ -82,6 +73,9 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import static com.cricketcraft.chisel.init.ChiselBlocks.*;
import static com.cricketcraft.chisel.utils.General.*;
public enum Features {
AE_CERTUS_QUARTZ("appliedenergistics2") {
@@ -141,17 +135,10 @@ public enum Features {
for (int i = 0; i < 16; i++) {
final String blockName = "antiBlock" + ItemDye.field_150921_b[i];
String oreName = "antiBlock" + ItemDye.field_150921_b[i];
String texName = "antiBlock/" + ItemDye.field_150921_b[i] + "-";
antiBlock.carverHelper
.addVariation(StatCollector.translateToLocal("tile.antiBlock." + ItemDye.field_150921_b[i] + ".desc"), i, "antiblock/" + ItemDye.field_150921_b[i] + "-antiBlock");
// OreDictionary.registerOre(oreName, antiBlock);
Carving.chisel.registerOre(blockName, oreName);
/*
* for (CarvableVariation cv : stainedGlass[glassId].carverHelper.variations) { if (cv.metadata < glassPrefix || cv.metadata >= glassPrefix + 4) continue;
* stainedGlass[glassId].carverHelper.registerVariation(blockName, cv, stainedGlass[glassId], cv.metadata); }
*/
}
antiBlock.carverHelper.register(antiBlock, "antiBlock");
@@ -160,14 +147,10 @@ public enum Features {
@Override
void addRecipes() {
// TODO: Add a recipe
/*
* GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(ChiselBlocks.woolen_clay, 2, meta), new Object[] { "blockWool" + sGNames[meta].replaceAll(" ", ""), "stainedClay" +
* sGNames[meta].replaceAll(" ", "") }));
*/
}
@Override
boolean needsMetaRecipes() { // TODO: Not sure if this is necessary
boolean needsMetaRecipes() {
return true;
}
},
@@ -1041,7 +1024,8 @@ public enum Features {
@Override
void addBlocks() {
BlockCarvableIcePillar ice_pillar = (BlockCarvableIcePillar) new BlockCarvableIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setLightOpacity(3).setStepSound(Block.soundTypeGlass);
BlockCarvableIcePillar ice_pillar = (BlockCarvableIcePillar) new BlockCarvableIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setLightOpacity(3)
.setStepSound(Block.soundTypeGlass);
ice_pillar.carverHelper.setChiselBlockName("Ice Pillar");
ice_pillar.carverHelper.addVariation(StatCollector.translateToLocal("tile.icePillar.0.desc"), 0, "icepillar/plainplain");
ice_pillar.carverHelper.addVariation(StatCollector.translateToLocal("tile.icePillar.1.desc"), 1, "icepillar/plaingreek");
@@ -1631,8 +1615,8 @@ public enum Features {
@Override
void addBlocks() {
BlockCarvablePackedIcePillar packedice_pillar = (BlockCarvablePackedIcePillar) new BlockCarvablePackedIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks).setHardness(0.5F).setLightOpacity(3)
.setStepSound(Block.soundTypeGlass);
BlockCarvablePackedIcePillar packedice_pillar = (BlockCarvablePackedIcePillar) new BlockCarvablePackedIcePillar(Material.ice).setCreativeTab(ChiselTabs.tabOtherChiselBlocks)
.setHardness(0.5F).setLightOpacity(3).setStepSound(Block.soundTypeGlass);
packedice_pillar.carverHelper.setChiselBlockName("Packed Ice Pillar");
packedice_pillar.carverHelper.addVariation(StatCollector.translateToLocal("tile.packedicePillar.0.desc"), 0, "icepillar/plainplain");
packedice_pillar.carverHelper.addVariation(StatCollector.translateToLocal("tile.packedicePillar.1.desc"), 1, "icepillar/plaingreek");
@@ -2412,7 +2396,7 @@ public enum Features {
void addBlocks() {
String[] plank_names = { "oak", "spruce", "birch", "jungle", "acacia", "dark-oak" };
String[] plank_ucnames = { "Oak", "Spruce", "Birch", "Jungle", "Acacia", "Dark Oak" };
for (int i = 0; i < 6; i++) {
for (int i = 0; i < plank_names.length; i++) {
String n = plank_names[i];
String u = plank_ucnames[i];
final String orename = n.replace('-', '_') + "_planks";