diff --git a/buildcraft_resources/changelog/7.1.6 b/buildcraft_resources/changelog/7.1.6 index e7778ee3..9acf5a52 100644 --- a/buildcraft_resources/changelog/7.1.6 +++ b/buildcraft_resources/changelog/7.1.6 @@ -1,4 +1,14 @@ +Additions: + +* "/buildcraft op" and "/buildcraft deop", used to op/deop the BuildCraft "fake player" (asie) + +Improvements: + +* New quarry frame model! (asie) +* Quarry now rebuilds its own frame if it is removed (asie) + Bugs fixed: +* [#2998] Quarries not respecting a certain form of player-specific protection (asie) * Creative Engines only outputting 1/5th the advertised RF/t (asie) * Frame icon not rendering on Quarry Frame building (asie) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 2d057d89..fc7edc7a 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -110,6 +110,8 @@ import buildcraft.core.builders.patterns.PatternPyramid; import buildcraft.core.builders.patterns.PatternStairs; import buildcraft.core.builders.schematics.SchematicIgnore; import buildcraft.core.command.SubCommandChangelog; +import buildcraft.core.command.SubCommandDeop; +import buildcraft.core.command.SubCommandOp; import buildcraft.core.command.SubCommandVersion; import buildcraft.core.config.BuildCraftConfiguration; import buildcraft.core.config.ConfigManager; @@ -250,6 +252,7 @@ public class BuildCraftCore extends BuildCraftMod { public static boolean loadDefaultRecipes = true; public static boolean consumeWaterSources = false; + public static boolean miningAllowPlayerProtectedBlocks = false; public static float miningMultiplier; public static AchievementManager achievementManager; @@ -275,6 +278,8 @@ public class BuildCraftCore extends BuildCraftMod { commandBuildcraft.addAlias("bc"); commandBuildcraft.addChildCommand(new SubCommandVersion()); commandBuildcraft.addChildCommand(new SubCommandChangelog()); + commandBuildcraft.addChildCommand(new SubCommandDeop()); + commandBuildcraft.addChildCommand(new SubCommandOp()); BuildcraftRecipeRegistry.assemblyTable = AssemblyRecipeManager.INSTANCE; BuildcraftRecipeRegistry.integrationTable = IntegrationRecipeManager.INSTANCE; @@ -292,6 +297,7 @@ public class BuildCraftCore extends BuildCraftMod { mainConfigManager.getCat("debug").setShowInGui(false); mainConfigManager.getCat("vars").setShowInGui(false); + mainConfigManager.register("general.miningBreaksPlayerProtectedBlocks", false, "Should BuildCraft miners be allowed to break blocks using player-specific protection?", ConfigManager.RestartRequirement.NONE); mainConfigManager.register("general.updateCheck", true, "Should I check the BuildCraft version on startup?", ConfigManager.RestartRequirement.NONE); mainConfigManager.register("display.hidePowerValues", false, "Should all power values (RF, RF/t) be hidden?", ConfigManager.RestartRequirement.NONE); mainConfigManager.register("display.hideFluidValues", false, "Should all fluid values (mB, mB/t) be hidden?", ConfigManager.RestartRequirement.NONE); @@ -615,6 +621,7 @@ public class BuildCraftCore extends BuildCraftMod { canEnginesExplode = mainConfigManager.get("general.canEnginesExplode").getBoolean(); consumeWaterSources = mainConfigManager.get("general.pumpsConsumeWater").getBoolean(); miningMultiplier = (float) mainConfigManager.get("power.miningUsageMultiplier").getDouble(); + miningAllowPlayerProtectedBlocks = mainConfigManager.get("general.miningBreaksPlayerProtectedBlocks").getBoolean(); if (mainConfigManager.get("general.updateCheck").getBoolean(true)) { Version.check(); diff --git a/common/buildcraft/builders/TileQuarry.java b/common/buildcraft/builders/TileQuarry.java index e0514c11..3f76b29c 100644 --- a/common/buildcraft/builders/TileQuarry.java +++ b/common/buildcraft/builders/TileQuarry.java @@ -268,7 +268,9 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI CoreProxy.proxy.removeEntity(entity); miner.mineStack(mineable); } + } + if (miner.hasMined() || miner.hasFailed()) { miner = null; if (!findFrame()) { @@ -281,7 +283,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI } protected boolean findFrame() { - int dir = getBlockMetadata(); + int dir = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); ForgeDirection o = ForgeDirection.getOrientation(dir > 6 ? 6 : dir).getOpposite(); if (o == ForgeDirection.UNKNOWN) { return true; @@ -545,7 +547,6 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI chunkTicket.getModData().setInteger("quarryX", xCoord); chunkTicket.getModData().setInteger("quarryY", yCoord); chunkTicket.getModData().setInteger("quarryZ", zCoord); - ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); } IAreaProvider a = null; @@ -588,7 +589,7 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI if (useDefault) { int xMin, zMin; - int dir = getBlockMetadata(); + int dir = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); ForgeDirection o = ForgeDirection.getOrientation(dir > 6 ? 6 : dir).getOpposite(); switch (o) { diff --git a/common/buildcraft/core/command/SubCommandDeop.java b/common/buildcraft/core/command/SubCommandDeop.java new file mode 100644 index 00000000..208a67fe --- /dev/null +++ b/common/buildcraft/core/command/SubCommandDeop.java @@ -0,0 +1,20 @@ +package buildcraft.core.command; + +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; + +import buildcraft.BuildCraftCore; +import buildcraft.core.lib.commands.CommandHelpers; +import buildcraft.core.lib.commands.SubCommand; + +public class SubCommandDeop extends SubCommand { + public SubCommandDeop() { + super("deop"); + } + + @Override + public void processSubCommand(ICommandSender sender, String[] args) { + MinecraftServer.getServer().getConfigurationManager().func_152610_b(BuildCraftCore.gameProfile); + CommandHelpers.sendLocalizedChatMessage(sender, "commands.deop.success", "[BuildCraft]"); + } +} diff --git a/common/buildcraft/core/command/SubCommandOp.java b/common/buildcraft/core/command/SubCommandOp.java new file mode 100644 index 00000000..aafc58d0 --- /dev/null +++ b/common/buildcraft/core/command/SubCommandOp.java @@ -0,0 +1,21 @@ +package buildcraft.core.command; + +import net.minecraft.command.ICommandSender; +import net.minecraft.server.MinecraftServer; + +import buildcraft.BuildCraftCore; +import buildcraft.core.Version; +import buildcraft.core.lib.commands.CommandHelpers; +import buildcraft.core.lib.commands.SubCommand; + +public class SubCommandOp extends SubCommand { + public SubCommandOp() { + super("op"); + } + + @Override + public void processSubCommand(ICommandSender sender, String[] args) { + MinecraftServer.getServer().getConfigurationManager().func_152605_a(BuildCraftCore.gameProfile); + CommandHelpers.sendLocalizedChatMessage(sender, "commands.op.success", "[BuildCraft]"); + } +} diff --git a/common/buildcraft/core/lib/utils/BlockMiner.java b/common/buildcraft/core/lib/utils/BlockMiner.java index 3dbeaf32..e5aa7f5b 100644 --- a/common/buildcraft/core/lib/utils/BlockMiner.java +++ b/common/buildcraft/core/lib/utils/BlockMiner.java @@ -74,6 +74,11 @@ public class BlockMiner { } public int acceptEnergy(int offeredAmount) { + if (BlockUtils.isUnbreakableBlock(world, x, y, z)) { + hasFailed = true; + return 0; + } + energyRequired = BlockUtils.computeBlockBreakEnergy(world, x, y, z); int usedAmount = MathUtils.clamp(offeredAmount, 0, Math.max(0, energyRequired - energyAccepted)); diff --git a/common/buildcraft/core/lib/utils/BlockUtils.java b/common/buildcraft/core/lib/utils/BlockUtils.java index a6037861..f24f2583 100644 --- a/common/buildcraft/core/lib/utils/BlockUtils.java +++ b/common/buildcraft/core/lib/utils/BlockUtils.java @@ -119,14 +119,6 @@ public final class BlockUtils { world.spawnEntityInWorld(entityitem); } - @Deprecated - public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) { - if (block == null || block.isAir(world, x, y, z)) { - return false; - } - return true; - } - public static boolean canChangeBlock(World world, int x, int y, int z) { return canChangeBlock(world.getBlock(x, y, z), world, x, y, z); } @@ -136,7 +128,7 @@ public final class BlockUtils { return true; } - if (block.getBlockHardness(world, x, y, z) < 0) { + if (isUnbreakableBlock(world, x, y, z, block)) { return false; } @@ -152,10 +144,24 @@ public final class BlockUtils { return true; } - public static boolean isUnbreakableBlock(World world, int x, int y, int z) { - Block b = world.getBlock(x, y, z); + public static float getBlockHardnessMining(World world, int x, int y, int z, Block b) { + if (world instanceof WorldServer && !BuildCraftCore.miningAllowPlayerProtectedBlocks) { + return b.getPlayerRelativeBlockHardness(CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world).get(), world, x, y, z); + } else { + return b.getBlockHardness(world, x, y, z); + } + } - return b != null && b.getBlockHardness(world, x, y, z) < 0; + public static boolean isUnbreakableBlock(World world, int x, int y, int z, Block b) { + if (b == null) { + return false; + } + + return getBlockHardnessMining(world, x, y, z, b) < 0; + } + + public static boolean isUnbreakableBlock(World world, int x, int y, int z) { + return isUnbreakableBlock(world, x, y, z, world.getBlock(x, y, z)); } /** diff --git a/common/buildcraft/factory/TileMiningWell.java b/common/buildcraft/factory/TileMiningWell.java index 4d779070..0b170afe 100644 --- a/common/buildcraft/factory/TileMiningWell.java +++ b/common/buildcraft/factory/TileMiningWell.java @@ -103,10 +103,11 @@ public class TileMiningWell extends TileBuildCraft implements IHasWork, IPipeCon int usedEnergy = miner.acceptEnergy(getBattery().getEnergyStored()); getBattery().useEnergy(usedEnergy, usedEnergy, false); - if (miner.hasMined()) { - if (miner.hasFailed()) { - isDigging = false; - } + if (miner.hasFailed()) { + isDigging = false; + } + + if (miner.hasFailed() || miner.hasMined()) { miner = null; } } diff --git a/common/buildcraft/robotics/ai/AIRobotBreak.java b/common/buildcraft/robotics/ai/AIRobotBreak.java index 20e30c63..058a0ad6 100644 --- a/common/buildcraft/robotics/ai/AIRobotBreak.java +++ b/common/buildcraft/robotics/ai/AIRobotBreak.java @@ -49,7 +49,7 @@ public class AIRobotBreak extends AIRobot { robot.setItemActive(true); block = robot.worldObj.getBlock(blockToBreak.x, blockToBreak.y, blockToBreak.z); meta = robot.worldObj.getBlockMetadata(blockToBreak.x, blockToBreak.y, blockToBreak.z); - hardness = block.getBlockHardness(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z); + hardness = BlockUtils.getBlockHardnessMining(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z, block); speed = getBreakSpeed(robot, robot.getHeldItem(), block, meta); } @@ -63,11 +63,11 @@ public class AIRobotBreak extends AIRobot { return; } meta = robot.worldObj.getBlockMetadata(blockToBreak.x, blockToBreak.y, blockToBreak.z); - hardness = block.getBlockHardness(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z); + hardness = BlockUtils.getBlockHardnessMining(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z, block); speed = getBreakSpeed(robot, robot.getHeldItem(), block, meta); } - if (block.isAir(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z)) { + if (block.isAir(robot.worldObj, blockToBreak.x, blockToBreak.y, blockToBreak.z) || hardness < 0) { setSuccess(false); terminate(); return;