diff --git a/src/main/java/cr0s/warpdrive/EntityJump.java b/src/main/java/cr0s/warpdrive/EntityJump.java index 87439d66..09567257 100644 --- a/src/main/java/cr0s/warpdrive/EntityJump.java +++ b/src/main/java/cr0s/warpdrive/EntityJump.java @@ -615,7 +615,7 @@ public class EntityJump extends Entity { Block block = worldObj.getBlock(x, y, z); // Skipping vanilla air & ignored blocks - if (block == Blocks.air || WarpDriveConfig.TAGGED_BLOCKS_LEFTBEHIND.contains(block)) { + if (block == Blocks.air || WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)) { continue; } @@ -820,7 +820,7 @@ public class EntityJump extends Entity { Block block = worldObj.getBlock(x, y, z); // Skipping vanilla air & ignored blocks - if (block == Blocks.air || WarpDriveConfig.TAGGED_BLOCKS_LEFTBEHIND.contains(block)) { + if (block == Blocks.air || WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)) { continue; } @@ -831,7 +831,7 @@ public class EntityJump extends Entity { } // Stop on non-movable blocks - if (WarpDriveConfig.TAGGED_BLOCKS_ANCHOR.contains(block)) { + if (WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) { reason.append(block.getUnlocalizedName() + " detected onboard at " + x + ", " + y + ", " + z + ". Aborting."); LocalProfiler.stop(); return -1; @@ -857,12 +857,12 @@ public class EntityJump extends Entity { Block block = worldObj.getBlock(x, y, z); // Skipping any air block & ignored blocks - if (worldObj.isAirBlock(x, y, z) || WarpDriveConfig.TAGGED_BLOCKS_LEFTBEHIND.contains(block)) { + if (worldObj.isAirBlock(x, y, z) || WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)) { continue; } // Skipping non-movable blocks - if (WarpDriveConfig.TAGGED_BLOCKS_ANCHOR.contains(block)) { + if (WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) { continue; } @@ -1070,7 +1070,7 @@ public class EntityJump extends Entity { blockSource = worldObj.getBlock(x, y, z); blockTarget = worldObj.getBlock(newX, newY, newZ); - if (WarpDriveConfig.TAGGED_BLOCKS_ANCHOR.contains(blockTarget)) { + if (WarpDriveConfig.BLOCKS_ANCHOR.contains(blockTarget)) { result.add(x, y, z, newX + 0.5D - movementVector[0] * 1.0D, newY + 0.5D - movementVector[1] * 1.0D, @@ -1082,9 +1082,9 @@ public class EntityJump extends Entity { } if ( blockSource != Blocks.air - && !WarpDriveConfig.TAGGED_BLOCKS_EXPANDABLE.contains(blockSource) + && !WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockSource) && blockTarget != Blocks.air - && !WarpDriveConfig.TAGGED_BLOCKS_EXPANDABLE.contains(blockTarget)) { + && !WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockTarget)) { result.add(x, y, z, newX + 0.5D + movementVector[0] * 0.1D, newY + 0.5D + movementVector[1] * 0.1D, diff --git a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java index caa43203..f0310d92 100644 --- a/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java +++ b/src/main/java/cr0s/warpdrive/block/building/TileEntityShipScanner.java @@ -152,22 +152,24 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy { setActive(false); // disable scanner break; } - + // Deploy single block JumpBlock jb = blocksToDeploy[currentDeployIndex]; + + if (jb != null && !WarpDriveConfig.BLOCKS_ANCHOR.contains(jb.block)) { + Block blockAtTarget = worldObj.getBlock(targetX + jb.x, targetY + jb.y, targetZ + jb.z); + if (blockAtTarget == Blocks.air || WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockAtTarget)) { + jb.deploy(worldObj, targetX, targetY, targetZ); - if (jb != null && !jb.block.isAssociatedBlock(Blocks.bedrock) && !WarpDriveConfig.scannerIgnoreBlocks.contains(jb.block) - && worldObj.isAirBlock(targetX + jb.x, targetY + jb.y, targetZ + jb.z)) { - jb.deploy(worldObj, targetX, targetY, targetZ); + if (worldObj.rand.nextInt(100) <= 10) { + worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); - if (worldObj.rand.nextInt(100) <= 10) { - worldObj.playSoundEffect(xCoord + 0.5f, yCoord, zCoord + 0.5f, "warpdrive:lowlaser", 4F, 1F); - - PacketHandler.sendBeamPacket(worldObj, new Vector3(this).translate(0.5D), - new Vector3(targetX + jb.x, targetY + jb.y, targetZ + jb.z).translate(0.5D), 0f, 1f, 0f, 15, 0, 100); + PacketHandler.sendBeamPacket(worldObj, new Vector3(this).translate(0.5D), + new Vector3(targetX + jb.x, targetY + jb.y, targetZ + jb.z).translate(0.5D), 0f, 1f, 0f, 15, 0, 100); + } } } - + currentDeployIndex++; } } @@ -254,10 +256,9 @@ public class TileEntityShipScanner extends TileEntityAbstractEnergy { for (int z = 0; z < length; z++) { Block block = worldObj.getBlock(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z); - // Do not scan air, bedrock and specified forbidden blocks - // (like ore or Warp-Cores) - if (worldObj.isAirBlock(shipCore.minX + x, shipCore.minY + y, shipCore.minZ + z) || block.isAssociatedBlock(Blocks.bedrock) - || WarpDriveConfig.scannerIgnoreBlocks.contains(block)) { + // Skip leftBehind and anchor blocks + if ( WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block) + || WarpDriveConfig.BLOCKS_ANCHOR.contains(block)) { block = Blocks.air; } diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java index ed2b4f20..d563f773 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityLaserTreeFarm.java @@ -102,7 +102,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner { int cost = calculateBlockCost(block); if (consumeEnergyFromBooster(cost, true)) { if (isRoomForHarvest()) { - if (block.isAssociatedBlock(Block.getBlockFromItem(WarpDriveConfig.IC2_rubberWood.getItem()))) { + if (block.isAssociatedBlock(WarpDriveConfig.IC2_rubberWood)) { int metadata = worldObj.getBlockMetadata(pos.x, pos.y, pos.z); if (metadata >= 2 && metadata <= 5) { if (WarpDriveConfig.LOGGING_COLLECTION) { @@ -150,11 +150,11 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner { } private static boolean isLog(Block block) { - return WarpDriveConfig.minerLogs.contains(block); + return WarpDriveConfig.BLOCKS_LOGS.contains(block); } private static boolean isLeaf(Block block) { - return WarpDriveConfig.minerLeaves.contains(block); + return WarpDriveConfig.BLOCKS_LEAVES.contains(block); } private static void addTree(LinkedList list, VectorI newTree) { diff --git a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java index 608aae26..7bc8848d 100644 --- a/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java +++ b/src/main/java/cr0s/warpdrive/block/collection/TileEntityMiningLaser.java @@ -219,12 +219,12 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { return false; } // check blacklist - if (WarpDriveConfig.TAGGED_BLOCKS_NOMINING.contains(block)) { + if (WarpDriveConfig.BLOCKS_NOMINING.contains(block)) { stop(); return false; } // check whitelist - if (WarpDriveConfig.TAGGED_BLOCKS_MINING.contains(block) || WarpDriveConfig.minerOres.contains(block)) { + if (WarpDriveConfig.BLOCKS_MINING.contains(block) || WarpDriveConfig.BLOCKS_ORES.contains(block)) { return true; } // check default (explosion resistance is used to test for force fields and reinforced blocks, basically preventing mining a base or ship) @@ -412,7 +412,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { z = zCoord; block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } @@ -426,7 +426,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (; x <= xmax; x++) { block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } @@ -436,7 +436,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (; z <= zmax; z++) { block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } @@ -446,7 +446,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (; x >= xmin; x--) { block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } @@ -456,7 +456,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (; z > zmin; z--) { block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } @@ -466,7 +466,7 @@ public class TileEntityMiningLaser extends TileEntityAbstractInterfaced { for (; x < xCoord; x++) { block = worldObj.getBlock(x, currentLayer, z); if (canDig(block, x, currentLayer, z)) { - if (isQuarry || WarpDriveConfig.minerOres.contains(block)) {// Quarry collects all blocks or only collect valuables blocks + if (isQuarry || WarpDriveConfig.BLOCKS_ORES.contains(block)) {// Quarry collects all blocks or only collect valuables blocks valuablesInLayer.add(new VectorI(x, currentLayer, z)); } } diff --git a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java index 35a3826d..f0bf9863 100644 --- a/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java +++ b/src/main/java/cr0s/warpdrive/block/movement/TileEntityShipCore.java @@ -637,10 +637,10 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { Block block = worldObj.getBlock(x, y, z); // Skipping vanilla air & ignored blocks - if (block == Blocks.air || WarpDriveConfig.TAGGED_BLOCKS_LEFTBEHIND.contains(block)) { + if (block == Blocks.air || WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)) { continue; } - if (WarpDriveConfig.TAGGED_BLOCKS_NOMASS.contains(block)) { + if (WarpDriveConfig.BLOCKS_NOMASS.contains(block)) { continue; } @@ -696,9 +696,9 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { // not vanilla air nor ignored blocks at source // not vanilla air nor expandable blocks are target location if ( blockSource != Blocks.air - && !WarpDriveConfig.TAGGED_BLOCKS_EXPANDABLE.contains(blockSource) + && !WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockSource) && blockTarget != Blocks.air - && !WarpDriveConfig.TAGGED_BLOCKS_EXPANDABLE.contains(blockTarget)) { + && !WarpDriveConfig.BLOCKS_EXPANDABLE.contains(blockTarget)) { return false; } } @@ -1028,12 +1028,12 @@ public class TileEntityShipCore extends TileEntityAbstractEnergy { Block block = worldObj.getBlock(x, y, z); // Skipping vanilla air & ignored blocks - if (block == Blocks.air || WarpDriveConfig.TAGGED_BLOCKS_LEFTBEHIND.contains(block)) { + if (block == Blocks.air || WarpDriveConfig.BLOCKS_LEFTBEHIND.contains(block)) { continue; } newVolume++; - if (WarpDriveConfig.TAGGED_BLOCKS_NOMASS.contains(block)) { + if (WarpDriveConfig.BLOCKS_NOMASS.contains(block)) { continue; } newMass++; diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index 60972634..d4d6b71f 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -22,7 +22,6 @@ import cr0s.warpdrive.config.filler.FillerManager; import cr0s.warpdrive.config.structures.StructureManager; import cr0s.warpdrive.data.Planet; import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -62,18 +61,15 @@ public class WarpDriveConfig { public static ItemStack IC2_air; public static ItemStack IC2_empty; - public static ItemStack IC2_rubberWood; + public static Block IC2_rubberWood; public static ItemStack IC2_Resin; public static Block CC_Computer, CC_peripheral, CCT_Turtle, CCT_Expanded, CCT_Advanced; public static ItemStack GT_Ores, GT_Granite, GT_Machine; public static int AS_Turbine, AS_deuteriumCell; public static int ICBM_Machine, ICBM_Missile, ICBM_Explosive; - public static Item GS_ultimateLappack; - public static ArrayList minerOres, minerLogs, minerLeaves, scannerIgnoreBlocks; public static ArrayList spaceHelmets, jetpacks; - public static ArrayList commonWorldGenOres; // Mod configuration (see loadWarpDriveConfig() for comments/definitions) // General @@ -145,13 +141,18 @@ public class WarpDriveConfig { // Tagged blocks private static HashMap taggedBlocks = null; // loaded from configuration file at PreInit, parsed at PostInit - public static HashSet TAGGED_BLOCKS_ANCHOR = null; - public static HashSet TAGGED_BLOCKS_NOMASS = null; - public static HashSet TAGGED_BLOCKS_LEFTBEHIND = null; - public static HashSet TAGGED_BLOCKS_EXPANDABLE = null; - public static HashSet TAGGED_BLOCKS_MINING = null; - public static HashSet TAGGED_BLOCKS_NOMINING = null; - public static HashMap TAGGED_BLOCKS_PLACE = null; + + // Blocks dictionary + public static HashSet BLOCKS_ORES; + public static HashSet BLOCKS_LOGS; + public static HashSet BLOCKS_LEAVES; + public static HashSet BLOCKS_ANCHOR = null; + public static HashSet BLOCKS_NOMASS = null; + public static HashSet BLOCKS_LEFTBEHIND = null; + public static HashSet BLOCKS_EXPANDABLE = null; + public static HashSet BLOCKS_MINING = null; + public static HashSet BLOCKS_NOMINING = null; + public static HashMap BLOCKS_PLACE = null; // Radar public static int RADAR_MAX_ENERGY_STORED = 100000000; // 100kk eU @@ -464,9 +465,9 @@ public class WarpDriveConfig { + "Invalid tags will be ignored silently. Tags and block names are case sensitive.\n" + "In case of conflicts, the latest tag overwrite the previous ones.\n" + "- Anchor: ship can't move with this block aboard (default: bedrock and assimilated).\n" - + "- NoMass: this block doesn't count when calculating ship volume/mass (default: all 'air' blocks).\n" + + "- NoMass: this block doesn't count when calculating ship volume/mass (default: leaves, all 'air' blocks).\n" + "- LeftBehind: this block won't move with your ship (default: RailCraft heat, WarpDrive gases).\n" - + "- Expandable: this block will be squished/ignored in case of collision (default: leaves). All 'LeftBehind' are assumed as Expandable.\n" + + "- Expandable: this block will be squished/ignored in case of collision.\n" + "- Mining: this block is mineable (default: all 'ore' blocks from the ore dictionnary).\n" + "- NoMining: this block is non-mineable (default: forcefields).\n" + "- PlaceEarliest: this block will be removed last and placed first (default: ship hull and projectors).\n" @@ -478,27 +479,38 @@ public class WarpDriveConfig { ConfigCategory categoryBlockTags = config.getCategory("block_tags"); String[] taggedBlocksName = categoryBlockTags.getValues().keySet().toArray(new String[0]); if (taggedBlocksName.length == 0) { - config.get("block_tags", "minecraft:bedrock" , "Anchor NoMining" ).getString(); - config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor" ).getString(); - config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor" ).getString(); - config.get("block_tags", "Artifacts:anti_anti_builder_stone", "Anchor" ).getString(); - config.get("block_tags", "Artifacts:anti_builder" , "Anchor" ).getString(); + // anchors + config.get("block_tags", "minecraft:bedrock" , "Anchor NoMining" ).getString(); + config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor NoMining" ).getString(); + config.get("block_tags", "Artifacts:invisible_bedrock" , "Anchor NoMining" ).getString(); + config.get("block_tags", "Artifacts:anti_anti_builder_stone", "Anchor NoMining" ).getString(); + config.get("block_tags", "Artifacts:anti_builder" , "Anchor NoMining" ).getString(); - config.get("block_tags", "IC2:blockReinforcedFoam" , "PlaceEarliest NoMining" ).getString(); - config.get("block_tags", "IC2:blockAlloy" , "PlaceEarliest NoMining" ).getString(); - config.get("block_tags", "IC2:blockAlloyGlass" , "PlaceEarliest NoMining" ).getString(); - config.get("block_tags", "minecraft:obsidian" , "PlaceEarliest" ).getString(); - config.get("block_tags", "AdvancedRepulsionSystems:field" , "PlaceEarlier NoMining" ).getString(); + // placement priorities + config.get("block_tags", "IC2:blockReinforcedFoam" , "PlaceEarliest NoMining" ).getString(); + config.get("block_tags", "IC2:blockAlloy" , "PlaceEarliest NoMining" ).getString(); + config.get("block_tags", "IC2:blockAlloyGlass" , "PlaceEarliest NoMining" ).getString(); + config.get("block_tags", "minecraft:obsidian" , "PlaceEarliest Mining" ).getString(); + config.get("block_tags", "AdvancedRepulsionSystems:field" , "PlaceEarlier NoMining" ).getString(); // FIXME config.get("block_tags", "MFFS:field" , "PlaceEarlier NoMining" ).getString(); - config.get("block_tags", "IC2:blockGenerator" , "PlaceLater" ).getString(); - config.get("block_tags", "IC2:blockReactorChamber" , "PlaceLatest" ).getString(); + config.get("block_tags", "IC2:blockGenerator" , "PlaceLater" ).getString(); + config.get("block_tags", "IC2:blockReactorChamber" , "PlaceLatest" ).getString(); - config.get("block_tags", "WarpDrive:blockGas" , "LeftBehind" ).getString(); - config.get("block_tags", "Railcraft:residual.heat" , "LeftBehind" ).getString(); - config.get("block_tags", "InvisibLights:blockLightSource" , "NoMass" ).getString(); - config.get("block_tags", "WarpDrive:blockAir" , "NoMass PlaceLatest" ).getString(); + // expandables, a.k.a. "don't blow my ship with this..." + config.get("block_tags", "WarpDrive:blockGas" , "LeftBehind Expandable" ).getString(); + config.get("block_tags", "Railcraft:residual.heat" , "LeftBehind Expandable" ).getString(); + config.get("block_tags", "InvisibLights:blockLightSource" , "NoMass Expandable" ).getString(); + config.get("block_tags", "WarpDrive:blockAir" , "NoMass Expandable PlaceLatest" ).getString(); - config.get("block_tags", "WarpDrive:blockIridium" , "Mining" ).getString(); // stronger than obsidian but can still be mined (see ender moon) + // mining a mineshaft... + config.get("block_tags", "minecraft:web" , "Mining" ).getString(); + config.get("block_tags", "minecraft:fence" , "Mining" ).getString(); + config.get("block_tags", "minecraft:torch" , "Mining" ).getString(); + config.get("block_tags", "minecraft:glowstone" , "Mining" ).getString(); + config.get("block_tags", "minecraft:redstone_block" , "Mining" ).getString(); + + // mining an 'end' moon + config.get("block_tags", "WarpDrive:blockIridium" , "Mining" ).getString(); // stronger than obsidian but can still be mined (see ender moon) taggedBlocksName = categoryBlockTags.getValues().keySet().toArray(new String[0]); } taggedBlocks = new HashMap(taggedBlocksName.length); @@ -705,20 +717,8 @@ public class WarpDriveConfig { } public static void onFMLInitialization() { - commonWorldGenOres = new ArrayList(); - commonWorldGenOres.add(Blocks.iron_ore); - commonWorldGenOres.add(Blocks.gold_ore); - commonWorldGenOres.add(Blocks.coal_ore); - commonWorldGenOres.add(Blocks.emerald_ore); - commonWorldGenOres.add(Blocks.lapis_ore); - commonWorldGenOres.add(Blocks.redstone_ore); - spaceHelmets = new ArrayList(); jetpacks = new ArrayList(); - minerOres = new ArrayList(); - minerLogs = new ArrayList(); - minerLeaves = new ArrayList(); - scannerIgnoreBlocks = new ArrayList(); isForgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart"); if (isForgeMultipartLoaded) { @@ -748,116 +748,9 @@ public class WarpDriveConfig { isThermalExpansionLoaded = Loader.isModLoaded("ThermalExpansion"); isAppliedEnergistics2Loaded = Loader.isModLoaded("appliedenergistics2"); isOpenComputersLoaded = Loader.isModLoaded("OpenComputers"); - - // - minerOres.add(WarpDrive.blockIridium); - minerOres.add(Blocks.coal_ore); - minerOres.add(Blocks.quartz_ore); - minerOres.add(Blocks.obsidian); - minerOres.add(Blocks.web); - minerOres.add(Blocks.fence); - minerOres.add(Blocks.torch); - minerOres.add(Blocks.glowstone); - minerOres.add(Blocks.redstone_block); - - // Ignore WarpDrive blocks (which potentially will be duplicated by - // cheaters using ship scan/deploy) - scannerIgnoreBlocks.add(WarpDrive.blockShipCore); - scannerIgnoreBlocks.add(WarpDrive.blockShipController); - scannerIgnoreBlocks.add(WarpDrive.blockIridium); - - if (isIndustrialCraft2loaded) { - // Metadata: 0 Batbox, 1 MFE, 2 MFSU, 3 LV transformer, 4 MV transformer, 5 HV transformer, 6 EV transformer, 7 CESU - scannerIgnoreBlocks.add(Block.getBlockFromName("IC2:blockElectric")); - - // Metadata: 0 Batbox, 1 CESU, 2 MFE, 3 MFSU - scannerIgnoreBlocks.add(Block.getBlockFromName("IC2:blockChargepad")); - } - if (isICBMLoaded) { - scannerIgnoreBlocks.add(Block.getBlockFromName("ICBM:explosive")); - } - if (isComputerCraftLoaded) { - scannerIgnoreBlocks.add(CC_Computer); - scannerIgnoreBlocks.add(CCT_Turtle); - scannerIgnoreBlocks.add(CCT_Expanded); - scannerIgnoreBlocks.add(CCT_Advanced); - } - // Do not deploy ores and valuables - for (Block t : commonWorldGenOres) { - scannerIgnoreBlocks.add(t); - } } public static void onFMLPostInitialization() { - // translate tagged blocks - TAGGED_BLOCKS_ANCHOR = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_NOMASS = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_LEFTBEHIND = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_EXPANDABLE = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_MINING = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_NOMINING = new HashSet(taggedBlocks.size()); - TAGGED_BLOCKS_PLACE = new HashMap(taggedBlocks.size()); - for (Entry taggedBlock : taggedBlocks.entrySet()) { - Block block = Block.getBlockFromName(taggedBlock.getKey()); - if (block == null) { - WarpDrive.logger.info("Ignoring missing block " + taggedBlock.getKey()); - continue; - } - for (String tag : taggedBlock.getValue().replace("\t", " ").replace(",", " ").replace(" ", " ").split(" ")) { - switch (tag) { - case "Anchor": - TAGGED_BLOCKS_ANCHOR.add(block); - break; - - case "NoMass": - TAGGED_BLOCKS_NOMASS.add(block); - break; - - case "LeftBehind": - TAGGED_BLOCKS_LEFTBEHIND.add(block); - TAGGED_BLOCKS_EXPANDABLE.add(block); - break; - - case "Expandable": - TAGGED_BLOCKS_EXPANDABLE.add(block); - break; - - case "Mining": - TAGGED_BLOCKS_MINING.add(block); - break; - - case "NoMining": - TAGGED_BLOCKS_NOMINING.add(block); - break; - - case "PlaceEarliest": - TAGGED_BLOCKS_PLACE.put(block, 0); - break; - - case "PlaceEarlier": - TAGGED_BLOCKS_PLACE.put(block, 1); - break; - - case "PlaceNormal": - TAGGED_BLOCKS_PLACE.put(block, 2); - break; - - case "PlaceLater": - TAGGED_BLOCKS_PLACE.put(block, 3); - break; - - case "PlaceLatest": - TAGGED_BLOCKS_PLACE.put(block, 4); - break; - } - } - } - WarpDrive.logger.info("Tagged blocks identified:"); - WarpDrive.logger.info("- " + TAGGED_BLOCKS_ANCHOR.size() + " with Anchor tag: " + TAGGED_BLOCKS_ANCHOR); - WarpDrive.logger.info("- " + TAGGED_BLOCKS_NOMASS.size() + " with NoMass blocks defined: " + TAGGED_BLOCKS_NOMASS); - WarpDrive.logger.info("- " + TAGGED_BLOCKS_LEFTBEHIND.size() + " with LeftBehind blocks defined: " + TAGGED_BLOCKS_LEFTBEHIND); - WarpDrive.logger.info("- " + TAGGED_BLOCKS_PLACE.size() + " with Placement priority blocks defined: " + TAGGED_BLOCKS_PLACE); - // read XML files File[] files = configDirectory.listFiles(new FilenameFilter() { @Override @@ -874,37 +767,107 @@ public class WarpDriveConfig { FillerManager.loadOres(configDirectory); StructureManager.loadStructures(configDirectory); - LoadOreDict(); + loadBlockDictionnary(); FillerManager.finishLoading(); } - private static void LoadOreDict() { + private static void loadBlockDictionnary() { + // get default settings from parsing ore dictionary + BLOCKS_ORES = new HashSet(); + BLOCKS_LOGS = new HashSet(); + BLOCKS_LEAVES = new HashSet(); String[] oreNames = OreDictionary.getOreNames(); for (String oreName : oreNames) { String lowerOreName = oreName.toLowerCase(); if (oreName.length() > 4 && oreName.substring(0, 3).equals("ore")) { ArrayList itemStacks = OreDictionary.getOres(oreName); for (ItemStack itemStack : itemStacks) { - minerOres.add(Block.getBlockFromItem(itemStack.getItem())); - WarpDrive.logger.info("- added " + oreName + " to MinerOres as " + itemStack); + BLOCKS_ORES.add(Block.getBlockFromItem(itemStack.getItem())); + // WarpDrive.logger.info("- added " + oreName + " to ores as " + itemStack); } } if (lowerOreName.contains("log")) { ArrayList itemStacks = OreDictionary.getOres(oreName); for (ItemStack itemStack : itemStacks) { - minerLogs.add(Block.getBlockFromItem(itemStack.getItem())); - WarpDrive.logger.info("- added " + oreName + " to MinerLogs as " + itemStack); + BLOCKS_LOGS.add(Block.getBlockFromItem(itemStack.getItem())); + // WarpDrive.logger.info("- added " + oreName + " to logs as " + itemStack); } } if (lowerOreName.contains("leave") || lowerOreName.contains("leaf")) { ArrayList itemStacks = OreDictionary.getOres(oreName); for (ItemStack itemStack : itemStacks) { - minerLeaves.add(Block.getBlockFromItem(itemStack.getItem())); - WarpDrive.logger.info("- added " + oreName + " to MinerLeaves as " + itemStack); + BLOCKS_LEAVES.add(Block.getBlockFromItem(itemStack.getItem())); + // WarpDrive.logger.info("- added " + oreName + " to leaves as " + itemStack); } } } + + // translate tagged blocks + BLOCKS_ANCHOR = new HashSet(taggedBlocks.size()); + BLOCKS_NOMASS = new HashSet(taggedBlocks.size() + BLOCKS_LEAVES.size()); + BLOCKS_NOMASS.addAll(BLOCKS_LEAVES); + BLOCKS_LEFTBEHIND = new HashSet(taggedBlocks.size()); + BLOCKS_EXPANDABLE = new HashSet(taggedBlocks.size() + BLOCKS_LEAVES.size()); + BLOCKS_EXPANDABLE.addAll(BLOCKS_LEAVES); + BLOCKS_MINING = new HashSet(taggedBlocks.size()); + BLOCKS_NOMINING = new HashSet(taggedBlocks.size()); + BLOCKS_PLACE = new HashMap(taggedBlocks.size()); + for (Entry taggedBlock : taggedBlocks.entrySet()) { + Block block = Block.getBlockFromName(taggedBlock.getKey()); + if (block == null) { + WarpDrive.logger.info("Ignoring missing block " + taggedBlock.getKey()); + continue; + } + for (String tag : taggedBlock.getValue().replace("\t", " ").replace(",", " ").replace(" ", " ").split(" ")) { + switch (tag) { + case "Anchor" : BLOCKS_ANCHOR.add(block); break; + case "NoMass" : BLOCKS_NOMASS.add(block); break; + case "LeftBehind" : BLOCKS_LEFTBEHIND.add(block); break; + case "Expandable" : BLOCKS_EXPANDABLE.add(block); break; + case "Mining" : BLOCKS_MINING.add(block); break; + case "NoMining" : BLOCKS_NOMINING.add(block); break; + case "PlaceEarliest": BLOCKS_PLACE.put(block, 0); break; + case "PlaceEarlier" : BLOCKS_PLACE.put(block, 1); break; + case "PlaceNormal" : BLOCKS_PLACE.put(block, 2); break; + case "PlaceLater" : BLOCKS_PLACE.put(block, 3); break; + case "PlaceLatest" : BLOCKS_PLACE.put(block, 4); break; + } + } + } + WarpDrive.logger.info("Active blocks dictionnary:"); + WarpDrive.logger.info("- " + BLOCKS_ORES.size() + " ores: " + getHashMessage(BLOCKS_ORES)); + WarpDrive.logger.info("- " + BLOCKS_LOGS.size() + " logs: " + getHashMessage(BLOCKS_LOGS)); + WarpDrive.logger.info("- " + BLOCKS_LEAVES.size() + " laves: " + getHashMessage(BLOCKS_LEAVES)); + WarpDrive.logger.info("- " + BLOCKS_ANCHOR.size() + " anchors: " + getHashMessage(BLOCKS_ANCHOR)); + WarpDrive.logger.info("- " + BLOCKS_NOMASS.size() + " with NoMass tag: " + getHashMessage(BLOCKS_NOMASS)); + WarpDrive.logger.info("- " + BLOCKS_LEFTBEHIND.size() + " with LeftBehind tag: " + getHashMessage(BLOCKS_LEFTBEHIND)); + WarpDrive.logger.info("- " + BLOCKS_EXPANDABLE.size() + " expandable: " + getHashMessage(BLOCKS_EXPANDABLE)); + WarpDrive.logger.info("- " + BLOCKS_MINING.size() + " with Mining tag: " + getHashMessage(BLOCKS_MINING)); + WarpDrive.logger.info("- " + BLOCKS_NOMINING.size() + " with NoMining tag: " + getHashMessage(BLOCKS_NOMINING)); + WarpDrive.logger.info("- " + BLOCKS_PLACE.size() + " with Placement priority: " + getHashMessage(BLOCKS_PLACE)); + } + + private static String getHashMessage(HashSet hashSet) { + String message = ""; + for (Block block : hashSet) { + if (!message.isEmpty()) { + message += ", "; + } + message += GameRegistry.findUniqueIdentifierFor(block); + } + return message; + } + + private static String getHashMessage(HashMap hashMap) { + String message = ""; + for (Entry entry : hashMap.entrySet()) { + if (!message.isEmpty()) { + message += ", "; + } + message += GameRegistry.findUniqueIdentifierFor(entry.getKey()) + "=" + entry.getValue(); + } + return message; } private static void loadForgeMultipart() { @@ -934,28 +897,8 @@ public class WarpDriveConfig { IC2_empty = getModItemStack("IC2", "itemCellEmpty", -1); IC2_air = getModItemStack("IC2", "itemCellEmpty", 5); - ItemStack rubberWood = getModItemStack("IC2", "blockRubWood", -1); + IC2_rubberWood = getModBlock("IC2", "blockRubWood"); IC2_Resin = getModItemStack("IC2", "itemHarz", -1); - if (rubberWood != null) { - IC2_rubberWood = rubberWood; - minerOres.add(Block.getBlockFromItem(getModItemStack("IC2", "rubberWood", -1).getItem())); - } - ItemStack ore = getModItemStack("IC2", "blockOreUran", -1); - if (ore != null) { - commonWorldGenOres.add(Block.getBlockFromItem(ore.getItem())); - } - ore = getModItemStack("IC2", "blockOreCopper", -1); - if (ore != null) { - commonWorldGenOres.add(Block.getBlockFromItem(ore.getItem())); - } - ore = getModItemStack("IC2", "blockOreTin", -1); - if (ore != null) { - commonWorldGenOres.add(Block.getBlockFromItem(ore.getItem())); - } - ore = getModItemStack("IC2", "blockOreLead", -1); - if (ore != null) { - commonWorldGenOres.add(Block.getBlockFromItem(ore.getItem())); - } } catch (Exception exception) { WarpDrive.logger.error("Error loading IndustrialCraft2 classes"); exception.printStackTrace(); @@ -989,10 +932,9 @@ public class WarpDriveConfig { private static void loadGraviSuite() { try { - spaceHelmets.add((Item) Item.itemRegistry.getObject("GraviSuite.ultimateSolarHelmet")); // FIXME - jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite.advJetpack")); // FIXME - jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite.graviChestPlate")); // FIXME - GS_ultimateLappack = (Item) Item.itemRegistry.getObject("GraviSuite.ultimateLappack"); // FIXME + jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:advJetpack")); + jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:advNanoChestPlate")); + jetpacks.add((Item) Item.itemRegistry.getObject("GraviSuite:graviChestPlate")); } catch (Exception exception) { WarpDrive.logger.error("Error loading GS classes"); exception.printStackTrace();