add /buildcraft [op|deop], fix #2998
This commit is contained in:
parent
b2ebbcb99b
commit
15c008b1d4
9 changed files with 93 additions and 22 deletions
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
20
common/buildcraft/core/command/SubCommandDeop.java
Normal file
20
common/buildcraft/core/command/SubCommandDeop.java
Normal file
|
@ -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]");
|
||||
}
|
||||
}
|
21
common/buildcraft/core/command/SubCommandOp.java
Normal file
21
common/buildcraft/core/command/SubCommandOp.java
Normal file
|
@ -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]");
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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() || miner.hasMined()) {
|
||||
miner = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue