fix a lot of Builder bugginess
This commit is contained in:
parent
bf25fdfbf6
commit
d0506b8a49
14 changed files with 32 additions and 106 deletions
|
@ -1,53 +0,0 @@
|
||||||
package buildcraft.api.core;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
public class BlockMetaPair implements Comparable<BlockMetaPair> {
|
|
||||||
private int id, meta;
|
|
||||||
|
|
||||||
public BlockMetaPair(Block block, int meta) {
|
|
||||||
this.id = Block.getIdFromBlock(block);
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlock() {
|
|
||||||
return Block.getBlockById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int meta() {
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return 17 * meta + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object other) {
|
|
||||||
if (other == null || !(other instanceof BlockMetaPair)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((BlockMetaPair) other).id == id && ((BlockMetaPair) other).meta == meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(BlockMetaPair arg) {
|
|
||||||
if (arg.id != id) {
|
|
||||||
return (id - arg.id) * 16;
|
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,7 @@ apply plugin: 'forge' // adds the forge dependency
|
||||||
apply plugin: 'maven' // for uploading to a maven repo
|
apply plugin: 'maven' // for uploading to a maven repo
|
||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
|
|
||||||
version = "6.1.3"
|
version = "6.1.5"
|
||||||
group= "com.mod-buildcraft"
|
group= "com.mod-buildcraft"
|
||||||
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
|
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ import buildcraft.api.blueprints.SchematicEntity;
|
||||||
import buildcraft.api.blueprints.SchematicFactory;
|
import buildcraft.api.blueprints.SchematicFactory;
|
||||||
import buildcraft.api.blueprints.SchematicMask;
|
import buildcraft.api.blueprints.SchematicMask;
|
||||||
import buildcraft.api.core.BCLog;
|
import buildcraft.api.core.BCLog;
|
||||||
import buildcraft.api.core.BlockMetaPair;
|
|
||||||
import buildcraft.api.core.JavaTools;
|
import buildcraft.api.core.JavaTools;
|
||||||
import buildcraft.api.filler.FillerManager;
|
import buildcraft.api.filler.FillerManager;
|
||||||
import buildcraft.api.filler.IFillerPattern;
|
import buildcraft.api.filler.IFillerPattern;
|
||||||
|
@ -261,8 +260,8 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
||||||
PrintWriter writer = new PrintWriter("SchematicDebug.txt", "UTF-8");
|
PrintWriter writer = new PrintWriter("SchematicDebug.txt", "UTF-8");
|
||||||
writer.println("*** REGISTERED SCHEMATICS ***");
|
writer.println("*** REGISTERED SCHEMATICS ***");
|
||||||
SchematicRegistry reg = (SchematicRegistry) BuilderAPI.schematicRegistry;
|
SchematicRegistry reg = (SchematicRegistry) BuilderAPI.schematicRegistry;
|
||||||
for (BlockMetaPair p : reg.schematicBlocks.keySet()) {
|
for (String s : reg.schematicBlocks.keySet()) {
|
||||||
writer.println(p.toString() + " -> " + reg.schematicBlocks.get(p).clazz.getCanonicalName());
|
writer.println(s + " -> " + reg.schematicBlocks.get(s).clazz.getCanonicalName());
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -35,7 +35,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import net.minecraftforge.oredict.RecipeSorter;
|
import net.minecraftforge.oredict.RecipeSorter;
|
||||||
import buildcraft.api.blueprints.BuilderAPI;
|
import buildcraft.api.blueprints.BuilderAPI;
|
||||||
import buildcraft.api.core.BlockMetaPair;
|
|
||||||
import buildcraft.api.core.EnumColor;
|
import buildcraft.api.core.EnumColor;
|
||||||
import buildcraft.api.core.IIconProvider;
|
import buildcraft.api.core.IIconProvider;
|
||||||
import buildcraft.api.core.JavaTools;
|
import buildcraft.api.core.JavaTools;
|
||||||
|
@ -518,8 +517,7 @@ public class BuildCraftTransport extends BuildCraftMod {
|
||||||
writer.println("*** REGISTERED FACADES ***");
|
writer.println("*** REGISTERED FACADES ***");
|
||||||
for (ItemStack stack : facadeItem.allFacades) {
|
for (ItemStack stack : facadeItem.allFacades) {
|
||||||
if (facadeItem.getBlocksForFacade(stack).length > 0) {
|
if (facadeItem.getBlocksForFacade(stack).length > 0) {
|
||||||
BlockMetaPair bmp = new BlockMetaPair(facadeItem.getBlocksForFacade(stack)[0], facadeItem.getMetaValuesForFacade(stack)[0]);
|
writer.println(Block.blockRegistry.getNameForObject(facadeItem.getBlocksForFacade(stack)[0]) + ":" + facadeItem.getMetaValuesForFacade(stack)[0]);
|
||||||
writer.println(bmp.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package buildcraft.builders;
|
package buildcraft.builders;
|
||||||
|
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
@ -42,14 +44,13 @@ public final class HeuristicBlockDetection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register blocks
|
// Register blocks
|
||||||
for (Object o : Block.blockRegistry.getKeys()) {
|
Iterator i = Block.blockRegistry.iterator();
|
||||||
Block block = (Block) Block.blockRegistry.getObject(o);
|
while (i.hasNext()) {
|
||||||
if (block == null) {
|
Block block = (Block) i.next();
|
||||||
|
if (block == null || block == Blocks.air) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitSet regularBlockMeta = new BitSet(16);
|
|
||||||
|
|
||||||
for (int meta = 0; meta < 16; meta++) {
|
for (int meta = 0; meta < 16; meta++) {
|
||||||
if (!SchematicRegistry.INSTANCE.isSupported(block, meta)) {
|
if (!SchematicRegistry.INSTANCE.isSupported(block, meta)) {
|
||||||
if (block.hasTileEntity(meta)) {
|
if (block.hasTileEntity(meta)) {
|
||||||
|
@ -65,23 +66,13 @@ public final class HeuristicBlockDetection {
|
||||||
if (creativeOnly) {
|
if (creativeOnly) {
|
||||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
|
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlockCreative.class);
|
||||||
} else {
|
} else {
|
||||||
regularBlockMeta.set(meta);
|
SchematicRegistry.INSTANCE.registerSchematicBlock(block, meta, SchematicBlock.class);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regularBlockMeta.cardinality() == 16) {
|
|
||||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, SchematicBlock.class);
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
if (regularBlockMeta.get(i)) {
|
|
||||||
SchematicRegistry.INSTANCE.registerSchematicBlock(block, i, SchematicBlock.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,11 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressOut > 0 && progressOut < PROGRESS_TIME) {
|
if (progressOut > 0 && progressOut < PROGRESS_TIME) {
|
||||||
progressOut++;
|
if (selected == -1) {
|
||||||
|
progressOut++;
|
||||||
|
} else {
|
||||||
|
progressOut = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// On progress IN, we'll download the blueprint from the server to the
|
// On progress IN, we'll download the blueprint from the server to the
|
||||||
|
|
|
@ -226,9 +226,6 @@ public class Blueprint extends BlueprintBase {
|
||||||
case ALL:
|
case ALL:
|
||||||
break;
|
break;
|
||||||
case CREATIVE_ONLY:
|
case CREATIVE_ONLY:
|
||||||
//System.out.println("FOUND CREATIVE BUILDING PERMISSION");
|
|
||||||
//System.out.println("- block: " + Block.blockRegistry.getNameForObject(block));
|
|
||||||
//System.out.println("- meta: " + meta);
|
|
||||||
if (buildingPermission == BuildingPermission.ALL) {
|
if (buildingPermission == BuildingPermission.ALL) {
|
||||||
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
buildingPermission = BuildingPermission.CREATIVE_ONLY;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,21 +18,19 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
import net.minecraftforge.common.config.Property;
|
import net.minecraftforge.common.config.Property;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
|
||||||
import buildcraft.api.blueprints.ISchematicRegistry;
|
import buildcraft.api.blueprints.ISchematicRegistry;
|
||||||
import buildcraft.api.blueprints.Schematic;
|
import buildcraft.api.blueprints.Schematic;
|
||||||
import buildcraft.api.blueprints.SchematicBlock;
|
import buildcraft.api.blueprints.SchematicBlock;
|
||||||
import buildcraft.api.blueprints.SchematicEntity;
|
import buildcraft.api.blueprints.SchematicEntity;
|
||||||
import buildcraft.api.core.BCLog;
|
import buildcraft.api.core.BCLog;
|
||||||
import buildcraft.api.core.BlockMetaPair;
|
|
||||||
import buildcraft.api.core.JavaTools;
|
import buildcraft.api.core.JavaTools;
|
||||||
|
|
||||||
public final class SchematicRegistry implements ISchematicRegistry {
|
public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
|
|
||||||
public static SchematicRegistry INSTANCE = new SchematicRegistry();
|
public static SchematicRegistry INSTANCE = new SchematicRegistry();
|
||||||
|
|
||||||
public final HashMap<BlockMetaPair, SchematicConstructor> schematicBlocks =
|
public final HashMap<String, SchematicConstructor> schematicBlocks =
|
||||||
new HashMap<BlockMetaPair, SchematicConstructor>();
|
new HashMap<String, SchematicConstructor>();
|
||||||
|
|
||||||
public 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>();
|
||||||
|
|
||||||
|
@ -91,7 +89,9 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSchematicBlock(Block block, Class<? extends Schematic> clazz, Object... params) {
|
public void registerSchematicBlock(Block block, Class<? extends Schematic> clazz, Object... params) {
|
||||||
registerSchematicBlock(block, OreDictionary.WILDCARD_VALUE, clazz, params);
|
for (int i = 0; i < 16; i++) {
|
||||||
|
registerSchematicBlock(block, i, clazz, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSchematicBlock(Block block, int meta, Class<? extends Schematic> clazz, Object... params) {
|
public void registerSchematicBlock(Block block, int meta, Class<? extends Schematic> clazz, Object... params) {
|
||||||
|
@ -99,10 +99,11 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
BCLog.logger.warn("Mod tried to register block with null name! Ignoring.");
|
BCLog.logger.warn("Mod tried to register block with null name! Ignoring.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (schematicBlocks.containsKey(new BlockMetaPair(block, meta))) {
|
if (schematicBlocks.containsKey(toStringKey(block, meta))) {
|
||||||
throw new RuntimeException("Block " + Block.blockRegistry.getNameForObject(block) + " is already associated with a schematic.");
|
throw new RuntimeException("Block " + Block.blockRegistry.getNameForObject(block) + " is already associated with a schematic.");
|
||||||
}
|
}
|
||||||
schematicBlocks.put(new BlockMetaPair(block, meta), new SchematicConstructor(clazz, params));
|
|
||||||
|
schematicBlocks.put(toStringKey(block, meta), new SchematicConstructor(clazz, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerSchematicEntity(
|
public void registerSchematicEntity(
|
||||||
|
@ -115,20 +116,11 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SchematicBlock createSchematicBlock(Block block, int metadata) {
|
public SchematicBlock createSchematicBlock(Block block, int metadata) {
|
||||||
if (block == Blocks.air) {
|
if (block == null || block == Blocks.air || metadata < 0 || metadata >= 16) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockMetaPair pairWildcard = new BlockMetaPair(block, OreDictionary.WILDCARD_VALUE);
|
SchematicConstructor c = schematicBlocks.get(toStringKey(block, metadata));
|
||||||
BlockMetaPair pair = new BlockMetaPair(block, metadata);
|
|
||||||
|
|
||||||
SchematicConstructor c = null;
|
|
||||||
|
|
||||||
if (schematicBlocks.containsKey(pair)) {
|
|
||||||
c = schematicBlocks.get(pair);
|
|
||||||
} else if (schematicBlocks.containsKey(pairWildcard)) {
|
|
||||||
c = schematicBlocks.get(pairWildcard);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -175,8 +167,7 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSupported(Block block, int metadata) {
|
public boolean isSupported(Block block, int metadata) {
|
||||||
return schematicBlocks.containsKey(new BlockMetaPair(block, OreDictionary.WILDCARD_VALUE))
|
return schematicBlocks.containsKey(toStringKey(block, metadata));
|
||||||
|| schematicBlocks.containsKey(new BlockMetaPair(block, metadata));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAllowedForBuilding(Block block, int metadata) {
|
public boolean isAllowedForBuilding(Block block, int metadata) {
|
||||||
|
@ -206,4 +197,8 @@ public final class SchematicRegistry implements ISchematicRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String toStringKey(Block block, int meta) {
|
||||||
|
return Block.blockRegistry.getNameForObject(block) + ":" + meta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ import java.util.Locale;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import buildcraft.api.statements.IActionExternal;
|
import buildcraft.api.statements.IActionExternal;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
|
@ -13,7 +13,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
import buildcraft.api.core.NetworkData;
|
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import buildcraft.api.core.NetworkData;
|
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
|
@ -18,7 +18,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.ICrafting;
|
import net.minecraft.inventory.ICrafting;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import buildcraft.api.core.NetworkData;
|
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import buildcraft.api.core.NetworkData;
|
|
||||||
import buildcraft.api.statements.IStatement;
|
import buildcraft.api.statements.IStatement;
|
||||||
import buildcraft.api.statements.IStatementContainer;
|
import buildcraft.api.statements.IStatementContainer;
|
||||||
import buildcraft.api.statements.IStatementParameter;
|
import buildcraft.api.statements.IStatementParameter;
|
||||||
|
|
Loading…
Reference in a new issue