add debug messages for schematics and facades (close #2124), improve schematic autodetection
This commit is contained in:
parent
bf9bfc5c50
commit
85e588780f
8 changed files with 112 additions and 23 deletions
|
@ -1,6 +1,7 @@
|
|||
package buildcraft.api.core;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class BlockMetaPair implements Comparable<BlockMetaPair> {
|
||||
private int id, meta;
|
||||
|
@ -40,4 +41,13 @@ public class BlockMetaPair implements Comparable<BlockMetaPair> {
|
|||
return meta - arg.meta;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.getBlock() == null) {
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
return Block.blockRegistry.getNameForObject(this.getBlock()) + ":" + (this.meta == OreDictionary.WILDCARD_VALUE ? "*" : this.meta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ package buildcraft;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityMinecartChest;
|
||||
|
@ -39,6 +40,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
import buildcraft.api.blueprints.BlueprintDeployer;
|
||||
import buildcraft.api.blueprints.BuilderAPI;
|
||||
import buildcraft.api.blueprints.ISchematicRegistry;
|
||||
|
@ -47,6 +49,7 @@ import buildcraft.api.blueprints.SchematicEntity;
|
|||
import buildcraft.api.blueprints.SchematicFactory;
|
||||
import buildcraft.api.blueprints.SchematicMask;
|
||||
import buildcraft.api.core.BCLog;
|
||||
import buildcraft.api.core.BlockMetaPair;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
|
@ -158,6 +161,8 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
public static BlueprintDatabase serverDB;
|
||||
public static BlueprintDatabase clientDB;
|
||||
|
||||
public static boolean debugPrintSchematicList = false;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void loadConfiguration(FMLPreInitializationEvent evt) {
|
||||
String blueprintServerDir = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL,
|
||||
|
@ -188,6 +193,9 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
blueprintLibraryInput[i] = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintLibraryInput[i]));
|
||||
}
|
||||
|
||||
Property printSchematicList = BuildCraftCore.mainConfiguration.get("debug", "blueprints.printSchematicList", false);
|
||||
debugPrintSchematicList = printSchematicList.getBoolean();
|
||||
|
||||
if (BuildCraftCore.mainConfiguration.hasChanged()) {
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
}
|
||||
|
@ -247,6 +255,20 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
|||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
HeuristicBlockDetection.start();
|
||||
|
||||
if (debugPrintSchematicList) {
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter("SchematicDebug.txt", "UTF-8");
|
||||
writer.println("*** REGISTERED SCHEMATICS ***");
|
||||
SchematicRegistry reg = ((SchematicRegistry) BuilderAPI.schematicRegistry);
|
||||
for (BlockMetaPair p : reg.schematicBlocks.keySet()) {
|
||||
writer.println(p.toString() + " -> " + reg.schematicBlocks.get(p).clazz.getCanonicalName());
|
||||
}
|
||||
writer.close();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
|
|
@ -139,7 +139,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
Full, NoDynamic
|
||||
}
|
||||
public static RenderMode render = RenderMode.Full;
|
||||
public static boolean debugMode = false;
|
||||
public static boolean debugWorldgen = false;
|
||||
public static boolean modifyWorld = false;
|
||||
public static boolean colorBlindMode = false;
|
||||
public static boolean dropBrokenBlocks = true; // Set to false to prevent the filler from dropping broken blocks.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -34,6 +35,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import buildcraft.api.blueprints.BuilderAPI;
|
||||
import buildcraft.api.core.BlockMetaPair;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
|
@ -51,6 +53,7 @@ import buildcraft.core.InterModComms;
|
|||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.PowerMode;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.blueprints.SchematicRegistry;
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.silicon.ItemRedstoneChipset.Chipset;
|
||||
|
@ -217,6 +220,8 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
public static IActionInternal actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW);
|
||||
public static IActionInternal[] actionValve = new IActionInternal[4];
|
||||
|
||||
public static boolean debugPrintFacadeList = false;
|
||||
|
||||
private static LinkedList<PipeRecipe> pipeRecipes = new LinkedList<PipeRecipe>();
|
||||
|
||||
public IIconProvider pipeIconProvider = new PipeIconProvider();
|
||||
|
@ -281,6 +286,8 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
Property baseFlowRate = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.fluids.baseFlowRate", DefaultProps.PIPES_FLUIDS_BASE_FLOW_RATE);
|
||||
pipeFluidsBaseFlowRate = baseFlowRate.getInt();
|
||||
|
||||
Property printFacadeList = BuildCraftCore.mainConfiguration.get("debug", "facades.printFacadeList", false);
|
||||
debugPrintFacadeList = printFacadeList.getBoolean();
|
||||
|
||||
Property exclusionItemList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "woodenPipe.item.exclusion", new String[0]);
|
||||
|
||||
|
@ -505,6 +512,22 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
facadeItem.initialize();
|
||||
|
||||
if (debugPrintFacadeList) {
|
||||
try {
|
||||
PrintWriter writer = new PrintWriter("FacadeDebug.txt", "UTF-8");
|
||||
writer.println("*** REGISTERED FACADES ***");
|
||||
for (ItemStack stack : facadeItem.allFacades) {
|
||||
if (facadeItem.getBlocksForFacade(stack).length > 0) {
|
||||
BlockMetaPair bmp = new BlockMetaPair(facadeItem.getBlocksForFacade(stack)[0], facadeItem.getMetaValuesForFacade(stack)[0]);
|
||||
writer.println(bmp.toString());
|
||||
}
|
||||
}
|
||||
writer.close();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRecipes() {
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
package buildcraft.builders;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
import buildcraft.api.blueprints.SchematicFluid;
|
||||
import buildcraft.builders.schematics.SchematicBlockCreative;
|
||||
import buildcraft.builders.schematics.SchematicTileCreative;
|
||||
import buildcraft.core.blueprints.SchematicRegistry;
|
||||
|
||||
public final class HeuristicBlockDetection {
|
||||
|
@ -18,7 +23,24 @@ public final class HeuristicBlockDetection {
|
|||
|
||||
}
|
||||
|
||||
private static BitSet craftableBlockList = new BitSet(65536);
|
||||
|
||||
public static void start() {
|
||||
// Initialize craftableBlockList
|
||||
for (Object or : CraftingManager.getInstance().getRecipeList()) {
|
||||
if (or instanceof IRecipe) {
|
||||
IRecipe recipe = ((IRecipe) or);
|
||||
if (recipe.getRecipeOutput() != null && recipe.getRecipeOutput().getItem() != null &&
|
||||
recipe.getRecipeOutput().getItem() instanceof ItemBlock) {
|
||||
int pos = recipe.getRecipeOutput().getItemDamage() & 15;
|
||||
pos |= Block.getIdFromBlock(Block.getBlockFromItem(recipe.getRecipeOutput().getItem())) << 4;
|
||||
if (pos >= 0 && pos < 65536) {
|
||||
craftableBlockList.set(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register fluids
|
||||
for (Fluid f : FluidRegistry.getRegisteredFluids().values()) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(f.getBlock(), SchematicFluid.class, new FluidStack(f, 1000));
|
||||
|
@ -33,9 +55,18 @@ public final class HeuristicBlockDetection {
|
|||
|
||||
for (int meta = 0; meta < 16; meta++) {
|
||||
if (!SchematicRegistry.INSTANCE.isSupported(block, meta)) {
|
||||
if (block.hasTileEntity(meta)) {
|
||||
// All tiles are registered as creative only.
|
||||
// This is helpful for example for server admins.
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicTileCreative.class);
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean creativeOnly = false;
|
||||
|
||||
// Stops dupes with (for instance) ore blocks
|
||||
if (!canCraft(block, meta)) {
|
||||
|
||||
// Does it drop a different block type?
|
||||
try {
|
||||
if (block.getItemDropped(meta, null, 0) != Item.getItemFromBlock(block)) {
|
||||
creativeOnly = true;
|
||||
|
@ -45,15 +76,13 @@ public final class HeuristicBlockDetection {
|
|||
// depending on an RNG for deciding the dropped item
|
||||
// from being autodetected.
|
||||
}
|
||||
if (block.hasTileEntity(meta)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (creativeOnly) {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
|
||||
} else {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
|
||||
} else {
|
||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -62,4 +91,9 @@ public final class HeuristicBlockDetection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canCraft(Block block, int meta) {
|
||||
int pos = Block.getIdFromBlock(block) << 4 | meta;
|
||||
return craftableBlockList.get(pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
|||
|
||||
public static SchematicRegistry INSTANCE = new SchematicRegistry();
|
||||
|
||||
private final HashMap<BlockMetaPair, SchematicConstructor> schematicBlocks =
|
||||
public final HashMap<BlockMetaPair, SchematicConstructor> schematicBlocks =
|
||||
new HashMap<BlockMetaPair, SchematicConstructor>();
|
||||
|
||||
private final HashMap<Class<? extends Entity>, SchematicConstructor> schematicEntities = new HashMap<Class<? extends Entity>, SchematicConstructor>();
|
||||
public final HashMap<Class<? extends Entity>, SchematicConstructor> schematicEntities = new HashMap<Class<? extends Entity>, SchematicConstructor>();
|
||||
|
||||
private final HashSet<String> modsForbidden = new HashSet<String>();
|
||||
private final HashSet<String> blocksForbidden = new HashSet<String>();
|
||||
|
@ -42,7 +42,7 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
|||
private SchematicRegistry() {
|
||||
}
|
||||
|
||||
private class SchematicConstructor {
|
||||
public class SchematicConstructor {
|
||||
public final Class<? extends Schematic> clazz;
|
||||
public final Object[] params;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public final class OilPopulate {
|
|||
bonus *= BuildCraftEnergy.oilWellScalar;
|
||||
if (BuildCraftEnergy.excessiveOilBiomeIDs.contains(biome.biomeID)) {
|
||||
bonus *= 30.0;
|
||||
} else if (BuildCraftCore.debugMode) {
|
||||
} else if (BuildCraftCore.debugWorldgen) {
|
||||
bonus *= 20.0;
|
||||
}
|
||||
GenType type = GenType.NONE;
|
||||
|
@ -171,7 +171,7 @@ public final class OilPopulate {
|
|||
}
|
||||
generateSurfaceDeposit(world, rand, biome, wellX, groundLevel, wellZ, lakeRadius);
|
||||
|
||||
boolean makeSpring = type == GenType.LARGE && BuildCraftEnergy.spawnOilSprings && BuildCraftCore.springBlock != null && (BuildCraftCore.debugMode || rand.nextDouble() <= 0.25);
|
||||
boolean makeSpring = type == GenType.LARGE && BuildCraftEnergy.spawnOilSprings && BuildCraftCore.springBlock != null && (BuildCraftCore.debugWorldgen || rand.nextDouble() <= 0.25);
|
||||
|
||||
// Generate Spout
|
||||
int baseY;
|
||||
|
|
|
@ -108,7 +108,7 @@ public class BlockTank extends BlockBuildCraft {
|
|||
if (liquid != null) {
|
||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
|
||||
if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (qty != 0 && !BuildCraftCore.debugWorldgen && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class BlockTank extends BlockBuildCraft {
|
|||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
if (liquid != null) {
|
||||
if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (!BuildCraftCore.debugWorldgen && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled)) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue