Buildcraft should now be mostly MFFS safe.
Depreciated the unbreakableBlock() thing in the API and added a new function to BlockUtils that does a better job of the same thing. The Quarry and Mining Well should be completely incapable of penetrating a Force Field. The Filler will terminate its current job if it detects an unbreackable block during an operation, but its still theoretically possible to affect blocks inside a Force Field. Some patterns are worse than others. Preventing this completely is pretty difficult without some way to know whether a block is inside a Force Field.
This commit is contained in:
parent
675f4e6df9
commit
85fee2aef7
13 changed files with 107 additions and 71 deletions
|
@ -17,6 +17,7 @@ import cpw.mods.fml.common.Mod;
|
|||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.ServerStarting;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -61,7 +62,11 @@ import buildcraft.core.triggers.ActionMachineControl.Mode;
|
|||
import buildcraft.core.utils.Localization;
|
||||
import buildcraft.transport.triggers.TriggerRedstoneInput;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BlockFlower;
|
||||
import net.minecraft.src.BlockFluid;
|
||||
import net.minecraft.src.BlockGrass;
|
||||
import net.minecraft.src.CommandHandler;
|
||||
import net.minecraft.src.EntityList;
|
||||
import net.minecraft.src.Item;
|
||||
|
@ -232,11 +237,6 @@ public class BuildCraftCore {
|
|||
LiquidManager.liquids.add(new LiquidData(new LiquidStack(Block.waterStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.waterMoving, LiquidManager.BUCKET_VOLUME), new ItemStack(Item.potion), new ItemStack(Item.glassBottle)));
|
||||
LiquidManager.liquids.add(new LiquidData(new LiquidStack(Block.lavaStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(Block.lavaMoving, LiquidManager.BUCKET_VOLUME), new ItemStack(Item.bucketLava), new ItemStack(Item.bucketEmpty)));
|
||||
|
||||
BuildCraftAPI.softBlocks[Block.tallGrass.blockID] = true;
|
||||
BuildCraftAPI.softBlocks[Block.snow.blockID] = true;
|
||||
BuildCraftAPI.softBlocks[Block.waterMoving.blockID] = true;
|
||||
BuildCraftAPI.softBlocks[Block.waterStill.blockID] = true;
|
||||
|
||||
ActionManager.registerTriggerProvider(new DefaultTriggerProvider());
|
||||
ActionManager.registerActionProvider(new DefaultActionProvider());
|
||||
|
||||
|
@ -261,6 +261,17 @@ public class BuildCraftCore {
|
|||
|
||||
}
|
||||
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event){
|
||||
for(Block block : Block.blocksList) {
|
||||
if(block instanceof BlockFluid || block instanceof BlockGrass){
|
||||
BuildCraftAPI.softBlocks[block.blockID] = true;
|
||||
}
|
||||
}
|
||||
|
||||
BuildCraftAPI.softBlocks[Block.snow.blockID] = true;
|
||||
}
|
||||
|
||||
@ServerStarting
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager();
|
||||
|
|
|
@ -157,9 +157,6 @@ public class BuildCraftEnergy {
|
|||
|
||||
LiquidManager.liquids.add(new LiquidData(new LiquidStack(oilStill, LiquidManager.BUCKET_VOLUME), new LiquidStack(oilMoving, LiquidManager.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty)));
|
||||
LiquidManager.liquids.add(new LiquidData(new LiquidStack(fuel, LiquidManager.BUCKET_VOLUME), new LiquidStack(fuel, LiquidManager.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty)));
|
||||
|
||||
BuildCraftAPI.softBlocks[oilMoving.blockID] = true;
|
||||
BuildCraftAPI.softBlocks[oilStill.blockID] = true;
|
||||
}
|
||||
|
||||
public static void loadRecipes() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -13,14 +13,14 @@ import net.minecraft.src.Block;
|
|||
import net.minecraft.src.World;
|
||||
|
||||
public class BuildCraftAPI {
|
||||
|
||||
|
||||
@Deprecated
|
||||
// To be removed, see LiquidManager
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static final int LAST_ORIGINAL_BLOCK = 122;
|
||||
public static final int LAST_ORIGINAL_ITEM = 126;
|
||||
|
||||
public static boolean[] softBlocks = new boolean[Block.blocksList.length];
|
||||
public static final boolean[] softBlocks = new boolean[Block.blocksList.length];
|
||||
/**
|
||||
* Return true if the block given in parameter is pass through (e.g. air,
|
||||
* water...)
|
||||
|
@ -29,9 +29,8 @@ public class BuildCraftAPI {
|
|||
return blockId == 0 || softBlocks[blockId] || Block.blocksList[blockId] == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the block cannot be broken, typically bedrock and lava
|
||||
*/
|
||||
@Deprecated
|
||||
// To be removed
|
||||
public static boolean unbreakableBlock(int blockId) {
|
||||
return blockId == Block.bedrock.blockID || blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID;
|
||||
}
|
||||
|
@ -47,10 +46,4 @@ public class BuildCraftAPI {
|
|||
|
||||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < softBlocks.length; ++i) {
|
||||
softBlocks[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ public class FillerFillAll extends FillerPattern {
|
|||
int yMax = (int) box.pMax().y;
|
||||
int zMax = (int) box.pMax().z;
|
||||
|
||||
return fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj);
|
||||
return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ public class FillerFillPyramid extends FillerPattern {
|
|||
}
|
||||
|
||||
while (step <= xSize / 2 && step <= zSize / 2 && height >= yMin && height <= yMax) {
|
||||
if (!fill(xMin + step, height, zMin + step, xMax - step, height, zMax - step, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin + step, height, zMin + step, xMax - step, height, zMax - step, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -120,7 +120,7 @@ public class FillerFillStairs extends FillerPattern {
|
|||
if (kind == 0) {
|
||||
while (x2 - x1 + 1 > 0 && z2 - z1 + 1 > 0 && x2 - x1 < sizeX && z2 - z1 < sizeZ && height >= yMin && height <= yMax) {
|
||||
|
||||
if (!fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) {
|
||||
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class FillerFillStairs extends FillerPattern {
|
|||
|
||||
}
|
||||
|
||||
if (!fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) {
|
||||
if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -26,27 +26,27 @@ public class FillerFillWalls extends FillerPattern {
|
|||
int yMax = (int) box.pMax().y;
|
||||
int zMax = (int) box.pMax().z;
|
||||
|
||||
if (!fill(xMin, yMin, zMin, xMax, yMin, zMax, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin, yMin, zMin, xMax, yMin, zMax, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fill(xMin, yMin, zMin, xMin, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin, yMin, zMin, xMin, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fill(xMin, yMin, zMin, xMax, yMax, zMin, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin, yMin, zMin, xMax, yMax, zMin, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fill(xMax, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMax, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fill(xMin, yMin, zMax, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin, yMin, zMax, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!fill(xMin, yMax, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
if (fill(xMin, yMax, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import buildcraft.api.core.BuildCraftAPI;
|
|||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
|
@ -45,6 +46,9 @@ public class FillerFlattener extends FillerPattern {
|
|||
found = false;
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
if(!BlockUtil.canChangeBlock(tile.worldObj, x, y, z)){
|
||||
return true;
|
||||
}
|
||||
if (!blockedColumns[x - xMin][z - zMin]) {
|
||||
if (!BuildCraftAPI.softBlock(tile.worldObj.getBlockId(x, y, z))) {
|
||||
blockedColumns[x - xMin][z - zMin] = true;
|
||||
|
@ -72,7 +76,7 @@ public class FillerFlattener extends FillerPattern {
|
|||
return false;
|
||||
}
|
||||
|
||||
return empty(xMin, yMin, zMin, xMax, 64 * 2, zMax, tile.worldObj);
|
||||
return !empty(xMin, yMin, zMin, xMax, 64 * 2, zMax, tile.worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,6 +47,12 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to fill blocks in the area.
|
||||
*
|
||||
* Return false if the process failed.
|
||||
*
|
||||
*/
|
||||
public boolean fill(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, ItemStack stackToPlace, World world) {
|
||||
boolean found = false;
|
||||
int xSlot = 0, ySlot = 0, zSlot = 0;
|
||||
|
@ -54,6 +60,9 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int y = yMin; y <= yMax && !found; ++y) {
|
||||
for (int x = xMin; x <= xMax && !found; ++x) {
|
||||
for (int z = zMin; z <= zMax && !found; ++z) {
|
||||
if(!BlockUtil.canChangeBlock(world, x, y, z)){
|
||||
return false;
|
||||
}
|
||||
if (BuildCraftAPI.softBlock(world.getBlockId(x, y, z))) {
|
||||
xSlot = x;
|
||||
ySlot = y;
|
||||
|
@ -70,9 +79,15 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
zSlot, 1, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
return !found;
|
||||
return found;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to remove the blocks in the area.
|
||||
*
|
||||
* Return false if is the process failed.
|
||||
*
|
||||
*/
|
||||
public boolean empty(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, World world) {
|
||||
boolean found = false;
|
||||
int lastX = Integer.MAX_VALUE, lastY = Integer.MAX_VALUE, lastZ = Integer.MAX_VALUE;
|
||||
|
@ -81,8 +96,10 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
found = false;
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
if (!BuildCraftAPI.softBlock(world.getBlockId(x, y, z))
|
||||
&& !BuildCraftAPI.unbreakableBlock(world.getBlockId(x, y, z))) {
|
||||
if(!BlockUtil.canChangeBlock(world, x, y, z)){
|
||||
return false;
|
||||
}
|
||||
if (!BuildCraftAPI.softBlock(world.getBlockId(x, y, z))) {
|
||||
found = true;
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
|
@ -102,9 +119,10 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
} else {
|
||||
BlockUtil.breakBlock(world, lastX, lastY, lastZ);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return lastX == Integer.MAX_VALUE;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/**
|
||||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ public class FillerRemover extends FillerPattern {
|
|||
int yMax = (int) box.pMax().y;
|
||||
int zMax = (int) box.pMax().z;
|
||||
|
||||
return empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
|
||||
return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.ArrayList;
|
|||
|
||||
import buildcraft.BuildCraftCore;
|
||||
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.BuildCraftFactory;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
@ -38,4 +40,29 @@ public class BlockUtil {
|
|||
world.setBlockWithNotify(x, y, z, 0);
|
||||
}
|
||||
|
||||
public static boolean canChangeBlock(World world, int x, int y, int z) {
|
||||
if(world.isAirBlock(x, y, z)){
|
||||
return true;
|
||||
}
|
||||
|
||||
int blockID = world.getBlockId(x, y, z);
|
||||
if(Block.blocksList[blockID] == null) {
|
||||
return true;
|
||||
}
|
||||
Block block = Block.blocksList[blockID];
|
||||
|
||||
if(block.getBlockHardness(world, x, y, z) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(blockID == BuildCraftEnergy.oilMoving.blockID || blockID == BuildCraftEnergy.oilStill.blockID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(blockID == Block.lavaStill.blockID || blockID == Block.lavaMoving.blockID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ import buildcraft.core.IMachine;
|
|||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.World;
|
||||
|
@ -55,12 +54,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
|
|||
depth = depth - 1;
|
||||
}
|
||||
|
||||
if (depth < 0
|
||||
|| (Block.blocksList[world.getBlockId(xCoord, depth, zCoord)] != null && Block.blocksList[world.getBlockId(
|
||||
xCoord, depth, zCoord)].getBlockHardness(world, xCoord, yCoord, zCoord) == -1.0f)
|
||||
|| world.getBlockId(xCoord, depth, zCoord) == Block.lavaMoving.blockID
|
||||
|| world.getBlockId(xCoord, depth, zCoord) == Block.lavaStill.blockID) {
|
||||
|
||||
if (depth < 0 || !BlockUtil.canChangeBlock(world, xCoord, depth, zCoord)) {
|
||||
isDigging = false;
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +69,7 @@ public class TileMiningWell extends TileMachine implements IMachine, IPowerRecep
|
|||
return;
|
||||
}
|
||||
|
||||
if (stacks == null || stacks.size() == 0) {
|
||||
if (stacks == null || stacks.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
|
||||
int blockId = worldObj.getBlockId(bx, by, bz);
|
||||
|
||||
if (isUnquarriableBlock(blockId, bx, by, bz)) {
|
||||
if (!BlockUtil.canChangeBlock(worldObj, bx, by, bz)) {
|
||||
blockedColumns[searchX][searchZ] = true;
|
||||
} else if (isQuarriableBlock(blockId, bx, by + 1, bz)) {
|
||||
if (doSet) {
|
||||
|
@ -436,16 +436,8 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor,
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isUnquarriableBlock(int blockID, int bx, int by, int bz) {
|
||||
|
||||
if (Block.blocksList[blockID] != null && Block.blocksList[blockID].getBlockHardness(worldObj, bx, by, bz) == -1.0f)
|
||||
return true;
|
||||
|
||||
return blockID == Block.lavaStill.blockID || blockID == Block.lavaMoving.blockID;
|
||||
}
|
||||
|
||||
private boolean isQuarriableBlock(int blockID, int bx, int by, int bz) {
|
||||
return !isUnquarriableBlock(blockID, bx, by, bz) && !BuildCraftAPI.softBlock(blockID);
|
||||
return BlockUtil.canChangeBlock(worldObj, bx, by, bz) && !BuildCraftAPI.softBlock(blockID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue