From 2f744f1c6b8f341da91b52d251a291eedce28030 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Thu, 26 Feb 2015 19:07:29 +0100 Subject: [PATCH] remove dropBrokenBlocks option (was mostly dummy), add markerRange config (currently capped at 64) --- common/buildcraft/BuildCraftBuilders.java | 9 +++++ common/buildcraft/BuildCraftCore.java | 23 +++++-------- common/buildcraft/BuildCraftEnergy.java | 26 +++++++------- common/buildcraft/BuildCraftFactory.java | 4 +-- common/buildcraft/BuildCraftSilicon.java | 4 +-- common/buildcraft/BuildCraftTransport.java | 14 ++++---- common/buildcraft/builders/TileMarker.java | 17 +++++----- .../buildcraft/builders/TilePathMarker.java | 7 ++-- common/buildcraft/core/DefaultProps.java | 1 + .../core/blueprints/BptBuilderBase.java | 34 +++++++++++++++++++ .../core/blueprints/BptBuilderBlueprint.java | 30 +--------------- .../core/blueprints/BptBuilderTemplate.java | 6 ++-- common/buildcraft/core/utils/BlockUtils.java | 2 +- 13 files changed, 93 insertions(+), 84 deletions(-) diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 10177fd622..9d8c885dbc 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -167,6 +167,7 @@ public class BuildCraftBuilders extends BuildCraftMod { public static BlueprintDatabase clientDB; public static boolean debugPrintSchematicList = false; + public static boolean dropBrokenBlocks = false; @Mod.EventHandler public void loadConfiguration(FMLPreInitializationEvent evt) { @@ -197,6 +198,14 @@ public void loadConfiguration(FMLPreInitializationEvent evt) { for (int i = 0; i < blueprintLibraryInput.length; ++i) { blueprintLibraryInput[i] = JavaTools.stripSurroundingQuotes(replacePathVariables(blueprintLibraryInput[i])); } + + //Property dropBlock = BuildCraftCore.mainConfiguration.get("general", "builder.dropBrokenBlocks", false, "set to true to force the builder to drop broken blocks"); + //dropBrokenBlocks = dropBlock.getBoolean(false); + + Property markerRange = BuildCraftCore.mainConfiguration.get("general", "marker.range", 64, "Set the default marker range. Setting it too high might cause lag and general weirdness, so watch out!"); + markerRange.setMinValue(8); + markerRange.setMaxValue(64); + DefaultProps.MARKER_RANGE = markerRange.getInt(); Property printSchematicList = BuildCraftCore.mainConfiguration.get("debug", "blueprints.printSchematicList", false); debugPrintSchematicList = printSchematicList.getBoolean(); diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index dbbb2b29ae..822d50a2bc 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -201,7 +201,6 @@ public static enum RenderMode { 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. public static boolean hidePowerNumbers = false; public static boolean hideFluidNumbers = false; public static int itemLifespan = 1200; @@ -314,36 +313,32 @@ public void loadConfiguration(FMLPreInitializationEvent evt) { try { mainConfiguration.load(); - Property updateCheck = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "update.check", true); + Property updateCheck = BuildCraftCore.mainConfiguration.get("general", "update.check", true); updateCheck.comment = "set to true for version check on startup"; if (updateCheck.getBoolean(true)) { Version.check(); } - Property dropBlock = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "dropBrokenBlocks", true); - dropBlock.comment = "set to false to prevent fillers from dropping blocks."; - dropBrokenBlocks = dropBlock.getBoolean(true); - - Property hideRFNumbers = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "hidePowerNumbers", false); + Property hideRFNumbers = BuildCraftCore.mainConfiguration.get("general", "hidePowerNumbers", false); hideRFNumbers.comment = "set to true to not display any RF or RF/t numbers."; hidePowerNumbers = hideRFNumbers.getBoolean(false); - Property hideMBNumbers = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "hideFluidNumbers", false); + Property hideMBNumbers = BuildCraftCore.mainConfiguration.get("general", "hideFluidNumbers", false); hideMBNumbers.comment = "set to true to not display any mB or mB/t numbers."; hideFluidNumbers = hideMBNumbers.getBoolean(false); - Property lifespan = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "itemLifespan", itemLifespan); + Property lifespan = BuildCraftCore.mainConfiguration.get("general", "itemLifespan", itemLifespan); lifespan.comment = "the lifespan in ticks of items dropped on the ground by pipes and machines, vanilla = 6000, default = 1200"; itemLifespan = lifespan.getInt(itemLifespan); if (itemLifespan < 100) { itemLifespan = 100; } - Property factor = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "network.updateFactor", 10); + Property factor = BuildCraftCore.mainConfiguration.get("general", "network.updateFactor", 10); factor.comment = "increasing this number will decrease network update frequency, useful for overloaded servers"; updateFactor = factor.getInt(10); - Property longFactor = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "network.stateRefreshPeriod", 40); + Property longFactor = BuildCraftCore.mainConfiguration.get("general", "network.stateRefreshPeriod", 40); longFactor.comment = "delay between full client sync packets, increasing it saves bandwidth, decreasing makes for better client syncronization."; longUpdateFactor = longFactor.getInt(40); @@ -356,7 +351,7 @@ public void loadConfiguration(FMLPreInitializationEvent evt) { listItem = (new ItemList()).setUnlocalizedName("list"); CoreProxy.proxy.registerItem(listItem); - Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true); + Property modifyWorldProp = BuildCraftCore.mainConfiguration.get("general", "modifyWorld", true); modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)"; modifyWorld = modifyWorldProp.getBoolean(true); @@ -366,7 +361,7 @@ public void loadConfiguration(FMLPreInitializationEvent evt) { CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class); } - Property consumeWater = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "consumeWater", consumeWaterSources); + Property consumeWater = BuildCraftCore.mainConfiguration.get("general", "consumeWater", consumeWaterSources); consumeWaterSources = consumeWater.getBoolean(consumeWaterSources); consumeWater.comment = "set to true if the Pump should consume water"; @@ -481,7 +476,7 @@ public void init(FMLInitializationEvent evt) { MinecraftForge.EVENT_BUS.register(new SpringPopulate()); } - for (String l : BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, + for (String l : BuildCraftCore.mainConfiguration.get("general", "recipesBlacklist", new String[0]).getStringList()) { recipesBlacklist.add(JavaTools.stripSurroundingQuotes(l.trim())); } diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index f2b53831b3..26cd6d028d 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -120,39 +120,39 @@ public class BuildCraftEnergy extends BuildCraftMod { public void preInit(FMLPreInitializationEvent evt) { int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT); int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "biomeOilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); - canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); - isOilDense = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "denseOil", true, "Should it be hard to swim in oil?").getBoolean(true); - oilWellScalar = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); - canEnginesExplode = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "enginesExplode", false, "Do engines explode upon overheat?").getBoolean(false); + canOilBurn = BuildCraftCore.mainConfiguration.get("general", "burnOil", true, "Can oil burn?").getBoolean(true); + isOilDense = BuildCraftCore.mainConfiguration.get("general", "denseOil", true, "Should it be hard to swim in oil?").getBoolean(true); + oilWellScalar = BuildCraftCore.mainConfiguration.get("general", "oilWellGenerationRate", 1.0, "Probability of oil well generation").getDouble(1.0); + canEnginesExplode = BuildCraftCore.mainConfiguration.get("general", "enginesExplode", false, "Do engines explode upon overheat?").getBoolean(false); setBiomeList( OilPopulate.INSTANCE.surfaceDepositBiomes, BuildCraftCore.mainConfiguration - .get(Configuration.CATEGORY_GENERAL, "oil.increasedBiomeIDs", + .get("general", "oil.increasedBiomeIDs", new String[] {BiomeDictionary.Type.SANDY.toString(), BiomeGenBase.taiga.biomeName}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that should have increased oil generation rates.")); setBiomeList( OilPopulate.INSTANCE.excessiveBiomes, BuildCraftCore.mainConfiguration - .get(Configuration.CATEGORY_GENERAL, + .get("general", "oil.excessiveBiomeIDs", new String[] {}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that should have GREATLY increased oil generation rates.")); setBiomeList(OilPopulate.INSTANCE.excludedBiomes, BuildCraftCore.mainConfiguration - .get(Configuration.CATEGORY_GENERAL, "oil.excludeBiomeIDs", + .get("general", "oil.excludeBiomeIDs", new String[] {BiomeGenBase.sky.biomeName, BiomeGenBase.hell.biomeName}, "IDs or Biome Types (e.g. SANDY,OCEAN) of biomes that are excluded from generating oil.")); - double fuelLavaMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.lava.combustion", 1.0F, "adjust energy value of Lava in Combustion Engines").getDouble(1.0F); - double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F); - double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F); + double fuelLavaMultiplier = BuildCraftCore.mainConfiguration.get("general", "fuel.lava.combustion", 1.0F, "adjust energy value of Lava in Combustion Engines").getDouble(1.0F); + double fuelOilMultiplier = BuildCraftCore.mainConfiguration.get("general", "fuel.oil.combustion", 1.0F, "adjust energy value of Oil in Combustion Engines").getDouble(1.0F); + double fuelFuelMultiplier = BuildCraftCore.mainConfiguration.get("general", "fuel.fuel.combustion", 1.0F, "adjust energy value of Fuel in Combustion Engines").getDouble(1.0F); - int fuelLavaEnergyOutput = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.lava.combustion.energyOutput", 20, "adjust output energy by Lava in Combustion Engines").getInt(20); - int fuelOilEnergyOutput = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.oil.combustion.energyOutput", 30, "adjust output energy by Oil in Combustion Engines").getInt(30); - int fuelFuelEnergyOutput = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "fuel.fuel.combustion.energyOutput", 60, "adjust output energy by Fuel in Combustion Engines").getInt(60); + int fuelLavaEnergyOutput = BuildCraftCore.mainConfiguration.get("general", "fuel.lava.combustion.energyOutput", 20, "adjust output energy by Lava in Combustion Engines").getInt(20); + int fuelOilEnergyOutput = BuildCraftCore.mainConfiguration.get("general", "fuel.oil.combustion.energyOutput", 30, "adjust output energy by Oil in Combustion Engines").getInt(30); + int fuelFuelEnergyOutput = BuildCraftCore.mainConfiguration.get("general", "fuel.fuel.combustion.energyOutput", 60, "adjust output energy by Fuel in Combustion Engines").getInt(60); BuildCraftCore.mainConfiguration.save(); diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index e9aeb5e8d0..6c6d7babd5 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -176,7 +176,7 @@ public void initialize(FMLPreInitializationEvent evt) { channels = NetworkRegistry.INSTANCE.newChannel (DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new BuildCraftChannelHandler(), new PacketHandlerFactory()); - ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL); + ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, "general"); allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines"); quarryOneTimeUse = genCat.get("quarry.one.time.use", false, "Quarry cannot be picked back up after placement"); @@ -184,7 +184,7 @@ public void initialize(FMLPreInitializationEvent evt) { miningDepth = genCat.get("mining.depth", 2, 256, 256, "how far below the machine can mining machines dig, range (2 - 256), default 256"); quarryLoadsChunks = genCat.get("quarry.loads.chunks", true, "Quarry loads chunks required for mining"); - Property pumpList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST); + Property pumpList = BuildCraftCore.mainConfiguration.get("general", "pumping.controlList", DefaultProps.PUMP_DIMENSION_LIST); pumpList.comment = "Allows admins to whitelist or blacklist pumping of specific fluids in specific dimensions.\n" + "Eg. \"-/-1/Lava\" will disable lava in the nether. \"-/*/Lava\" will disable lava in any dimension. \"+/0/*\" will enable any fluid in the overworld.\n" + "Entries are comma seperated, banned fluids have precedence over allowed ones." diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 66674077dd..34b20345f5 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -138,10 +138,10 @@ public class BuildCraftSilicon extends BuildCraftMod { @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { - chipsetCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("chipset.costMultiplier", Configuration.CATEGORY_GENERAL, 1.0F, 0.001F, 1000.0F, "The multiplier for chipset recipe cost."); + chipsetCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("chipset.costMultiplier", "general", 1.0F, 0.001F, 1000.0F, "The multiplier for chipset recipe cost."); blacklistedRobots = new ArrayList(); - blacklistedRobots.addAll(Arrays.asList(BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "boards.blacklist", new String[]{}).getStringList())); + blacklistedRobots.addAll(Arrays.asList(BuildCraftCore.mainConfiguration.get("general", "boards.blacklist", new String[]{}).getStringList())); BuildCraftCore.mainConfiguration.save(); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 782da71cf2..ef4763a8cc 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -257,21 +257,21 @@ private static class PipeRecipe { @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { try { - Property durability = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.durability", DefaultProps.PIPES_DURABILITY); + Property durability = BuildCraftCore.mainConfiguration.get("general", "pipes.durability", DefaultProps.PIPES_DURABILITY); durability.comment = "How long a pipe will take to break"; pipeDurability = (float) durability.getDouble(DefaultProps.PIPES_DURABILITY); - Property baseFlowRate = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.fluids.baseFlowRate", DefaultProps.PIPES_FLUIDS_BASE_FLOW_RATE); + Property baseFlowRate = BuildCraftCore.mainConfiguration.get("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 enableAdditionalWaterproofingRecipe = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.fluids.enableAdditionalWaterproofingRecipe", true); + Property enableAdditionalWaterproofingRecipe = BuildCraftCore.mainConfiguration.get("general", "pipes.fluids.enableAdditionalWaterproofingRecipe", true); enableAdditionalWaterproofingRecipe.comment = "Enable the slimeball based pipe waterproofing recipe"; additionalWaterproofingRecipe = enableAdditionalWaterproofingRecipe.getBoolean(); - gateCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("gate.recipeCostMultiplier", Configuration.CATEGORY_GENERAL, 1.0F, 0.001F, 1000.0F, "The multiplier for gate recipe cost."); + gateCostMultiplier = BuildCraftCore.mainConfiguration.getFloat("gate.recipeCostMultiplier", "general", 1.0F, 0.001F, 1000.0F, "The multiplier for gate recipe cost."); filteredBufferBlock = new BlockFilteredBuffer(); CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock")); @@ -280,11 +280,11 @@ public void preInit(FMLPreInitializationEvent evt) { GateExpansions.registerExpansion(GateExpansionTimer.INSTANCE); GateExpansions.registerExpansion(GateExpansionRedstoneFader.INSTANCE); - Property groupItemsTriggerProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "pipes.groupItemsTrigger", 32); + Property groupItemsTriggerProp = BuildCraftCore.mainConfiguration.get("general", "pipes.groupItemsTrigger", 32); groupItemsTriggerProp.comment = "when reaching this amount of objects in a pipes, items will be automatically grouped"; groupItemsTrigger = groupItemsTriggerProp.getInt(); - Property facadeBlacklistProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "facade.blacklist", new String[] { + Property facadeBlacklistProp = BuildCraftCore.mainConfiguration.get("general", "facade.blacklist", new String[] { Block.blockRegistry.getNameForObject(Blocks.bedrock), Block.blockRegistry.getNameForObject(Blocks.command_block), Block.blockRegistry.getNameForObject(Blocks.end_portal_frame), @@ -314,7 +314,7 @@ public void preInit(FMLPreInitializationEvent evt) { facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes."; facadeBlacklist = facadeBlacklistProp.getStringList(); - Property facadeAsWhitelist = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "facade.treatBlacklistAsWhitelist", false); + Property facadeAsWhitelist = BuildCraftCore.mainConfiguration.get("general", "facade.treatBlacklistAsWhitelist", false); facadeTreatBlacklistAsWhitelist = facadeAsWhitelist.getBoolean(); pipeWaterproof = new ItemBuildCraft(); diff --git a/common/buildcraft/builders/TileMarker.java b/common/buildcraft/builders/TileMarker.java index cf6c2325d0..a59baad5a5 100644 --- a/common/buildcraft/builders/TileMarker.java +++ b/common/buildcraft/builders/TileMarker.java @@ -19,6 +19,7 @@ import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.ISerializable; import buildcraft.api.core.Position; +import buildcraft.core.DefaultProps; import buildcraft.core.EntityBlock; import buildcraft.core.LaserKind; import buildcraft.core.TileBuildCraft; @@ -26,8 +27,6 @@ import buildcraft.core.utils.Utils; public class TileMarker extends TileBuildCraft implements IAreaProvider { - private static int maxSize = 64; - public static class TileWrapper implements ISerializable { public int x, y, z; @@ -155,23 +154,23 @@ private void switchSignals() { if (showSignals) { signals = new EntityBlock[6]; if (!origin.isSet() || !origin.vect[0].isSet()) { - signals[0] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord + maxSize - 1, yCoord, zCoord), + signals[0] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord + DefaultProps.MARKER_RANGE - 1, yCoord, zCoord), LaserKind.Blue); - signals[1] = Utils.createLaser(worldObj, new Position(xCoord - maxSize + 1, yCoord, zCoord), new Position(xCoord, yCoord, zCoord), + signals[1] = Utils.createLaser(worldObj, new Position(xCoord - DefaultProps.MARKER_RANGE + 1, yCoord, zCoord), new Position(xCoord, yCoord, zCoord), LaserKind.Blue); } if (!origin.isSet() || !origin.vect[1].isSet()) { - signals[2] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord + maxSize - 1, zCoord), + signals[2] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord + DefaultProps.MARKER_RANGE - 1, zCoord), LaserKind.Blue); - signals[3] = Utils.createLaser(worldObj, new Position(xCoord, yCoord - maxSize + 1, zCoord), new Position(xCoord, yCoord, zCoord), + signals[3] = Utils.createLaser(worldObj, new Position(xCoord, yCoord - DefaultProps.MARKER_RANGE + 1, zCoord), new Position(xCoord, yCoord, zCoord), LaserKind.Blue); } if (!origin.isSet() || !origin.vect[2].isSet()) { - signals[4] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord + maxSize - 1), + signals[4] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord), new Position(xCoord, yCoord, zCoord + DefaultProps.MARKER_RANGE - 1), LaserKind.Blue); - signals[5] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord - maxSize + 1), new Position(xCoord, yCoord, zCoord), + signals[5] = Utils.createLaser(worldObj, new Position(xCoord, yCoord, zCoord - DefaultProps.MARKER_RANGE + 1), new Position(xCoord, yCoord, zCoord), LaserKind.Blue); } } @@ -218,7 +217,7 @@ void setVect(int n) { coords[2] = zCoord; if (!origin.isSet() || !origin.vect[n].isSet()) { - for (int j = 1; j < maxSize; ++j) { + for (int j = 1; j < DefaultProps.MARKER_RANGE; ++j) { coords[n] += j; Block block = worldObj.getBlock(coords[0], coords[1], coords[2]); diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index 59f97b7782..17d0f2baca 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -20,15 +20,12 @@ import buildcraft.api.core.BlockIndex; import buildcraft.api.core.Position; +import buildcraft.core.DefaultProps; import buildcraft.core.LaserData; public class TilePathMarker extends TileMarker { - - // TODO: this should be moved to default props // A list with the pathMarkers that aren't fully connected // It only contains markers within the loaded chunks - public static int searchSize = 64; - private static LinkedList availableMarkers = new LinkedList(); public int x0, y0, z0, x1, y1, z1; @@ -94,7 +91,7 @@ private TilePathMarker findNearestAvailablePathMarker() { distance = Math.sqrt(Math.pow(this.xCoord - t.xCoord, 2) + Math.pow(this.yCoord - t.yCoord, 2) + Math.pow(this.zCoord - t.zCoord, 2)); - if (distance > searchSize) { + if (distance > DefaultProps.MARKER_RANGE) { continue; } diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 17d140d9fb..ec3f44428f 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -17,6 +17,7 @@ public final class DefaultProps { public static final String NET_CHANNEL_NAME = "BC"; public static int NETWORK_UPDATE_RANGE = 64; + public static int MARKER_RANGE = 64; public static int PIPE_CONTENTS_RENDER_DIST = 24; public static String TEXTURE_PATH_GUI = "textures/gui"; diff --git a/common/buildcraft/core/blueprints/BptBuilderBase.java b/common/buildcraft/core/blueprints/BptBuilderBase.java index 40a32fd0fd..a89d8a037a 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBase.java +++ b/common/buildcraft/core/blueprints/BptBuilderBase.java @@ -14,19 +14,27 @@ import org.apache.logging.log4j.Level; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.Constants; +import net.minecraftforge.event.world.BlockEvent; import buildcraft.BuildCraftBuilders; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingNotFoundException; +import buildcraft.api.blueprints.SchematicBlock; +import buildcraft.api.blueprints.SchematicBlockBase; import buildcraft.api.core.BCLog; import buildcraft.api.core.BlockIndex; import buildcraft.api.core.IAreaProvider; @@ -37,6 +45,7 @@ import buildcraft.core.builders.BuildingSlotBlock; import buildcraft.core.builders.IBuildingItemsProvider; import buildcraft.core.builders.TileAbstractBuilder; +import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtils; public abstract class BptBuilderBase implements IAreaProvider { @@ -272,4 +281,29 @@ public void loadBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider build } } } + + protected boolean isBlockBreakCanceled(World world, int x, int y, int z) { + if (!world.isAirBlock(x, y, z)) { + BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(x, y, z, world, world.getBlock(x, y, z), + world.getBlockMetadata(x, y, z), + CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world).get()); + MinecraftForge.EVENT_BUS.post(breakEvent); + return breakEvent.isCanceled(); + } + return false; + } + + protected boolean isBlockPlaceCanceled(World world, int x, int y, int z, SchematicBlockBase schematic) { + Block block = schematic instanceof SchematicBlock ? ((SchematicBlock) schematic).block : Blocks.stone; + int meta = schematic instanceof SchematicBlock ? ((SchematicBlock) schematic).meta : 0; + + BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent( + new BlockSnapshot(world, x, y, z, block, meta), + Blocks.air, + CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world, x, y, z).get() + ); + + MinecraftForge.EVENT_BUS.post(placeEvent); + return placeEvent.isCanceled(); + } } diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index 1769b692d2..42376c56f7 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -205,9 +205,7 @@ public void deploy () { initialize(); for (BuildingSlotBlock b : buildList) { - if (b.mode == Mode.ClearIfInvalid) { - context.world.setBlockToAir(b.x, b.y, b.z); - } else if (!b.schematic.doNotBuild()) { + if (!b.schematic.doNotBuild()) { b.stackConsumed = new LinkedList(); try { @@ -430,32 +428,6 @@ private BuildingSlot internalGetNextBlock(World world, TileAbstractBuilder build return null; } - private boolean isBlockBreakCanceled(World world, int x, int y, int z) { - if (!world.isAirBlock(x, y, z)) { - BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(x, y, z, world, world.getBlock(x, y, z), - world.getBlockMetadata(x, y, z), - CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world).get()); - MinecraftForge.EVENT_BUS.post(breakEvent); - return breakEvent.isCanceled(); - } - return false; - } - - private boolean isBlockPlaceCanceled(World world, int x, int y, int z, SchematicBlockBase schematic) { - Block block = schematic instanceof SchematicBlock ? ((SchematicBlock) schematic).block : Blocks.stone; - int meta = schematic instanceof SchematicBlock ? ((SchematicBlock) schematic).meta : 0; - - BlockEvent.PlaceEvent placeEvent = new BlockEvent.PlaceEvent( - new BlockSnapshot(world, x, y, z, block, meta), - Blocks.air, - CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world, x, y, z).get() - ); - - MinecraftForge.EVENT_BUS.post(placeEvent); - return placeEvent.isCanceled(); - } - - private BuildingSlot internalGetNextEntity(World world, TileAbstractBuilder builder) { Iterator it = entityList.iterator(); diff --git a/common/buildcraft/core/blueprints/BptBuilderTemplate.java b/common/buildcraft/core/blueprints/BptBuilderTemplate.java index e0c84025df..81adbba355 100644 --- a/common/buildcraft/core/blueprints/BptBuilderTemplate.java +++ b/common/buildcraft/core/blueprints/BptBuilderTemplate.java @@ -162,7 +162,8 @@ private BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder return null; } - if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) { + if (BlockUtils.isUnbreakableBlock(world, slot.x, slot.y, slot.z) + || isBlockBreakCanceled(world, slot.x, slot.y, slot.z)) { iterator.remove(); if (slot.mode == Mode.ClearIfInvalid) { clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z)); @@ -186,7 +187,8 @@ private BuildingSlotBlock internalGetNextBlock(World world, TileAbstractBuilder } } } else if (slot.mode == Mode.Build) { - if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) { + if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z) + || isBlockPlaceCanceled(world, x, y, z, slot.schematic)) { iterator.remove(); builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z)); } else { diff --git a/common/buildcraft/core/utils/BlockUtils.java b/common/buildcraft/core/utils/BlockUtils.java index ce5da2c99f..9865bec88f 100644 --- a/common/buildcraft/core/utils/BlockUtils.java +++ b/common/buildcraft/core/utils/BlockUtils.java @@ -86,7 +86,7 @@ public static boolean breakBlock(WorldServer world, int x, int y, int z, int for return false; } - if (!world.isAirBlock(x, y, z) && BuildCraftCore.dropBrokenBlocks && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { + if (!world.isAirBlock(x, y, z) && !world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { List items = getItemStackFromBlock(world, x, y, z); for (ItemStack item : items) {