quarries and mining wells emit blockbreakevents now (for #2162), quarry speed fixed
This commit is contained in:
parent
8e561241f5
commit
a3064c12cd
2 changed files with 22 additions and 4 deletions
|
@ -10,11 +10,14 @@ package buildcraft.factory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftFactory;
|
||||
import buildcraft.api.tiles.IHasWork;
|
||||
|
@ -64,6 +67,15 @@ public class TileMiningWell extends TileBuildCraft implements IHasWork, IPipeCon
|
|||
return;
|
||||
}
|
||||
|
||||
BreakEvent breakEvent = new BreakEvent(xCoord, depth, zCoord, worldObj, world.getBlock(xCoord, depth, zCoord),
|
||||
world.getBlockMetadata(xCoord, depth, zCoord), CoreProxy.proxy.getBuildCraftPlayer((WorldServer) world).get());
|
||||
MinecraftForge.EVENT_BUS.post(breakEvent);
|
||||
|
||||
if (breakEvent.isCanceled()) {
|
||||
isDigging = false;
|
||||
return;
|
||||
}
|
||||
|
||||
boolean wasAir = world.isAirBlock(xCoord, depth, zCoord);
|
||||
|
||||
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock((WorldServer) worldObj, xCoord, depth, zCoord);
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.world.WorldServer;
|
|||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Type;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftFactory;
|
||||
|
@ -50,6 +51,7 @@ import buildcraft.core.network.PacketUpdate;
|
|||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
||||
public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedInventory {
|
||||
|
||||
|
@ -172,10 +174,10 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
|
|||
} else if (stage == Stage.IDLE) {
|
||||
dig();
|
||||
} else if (stage == Stage.DIGGING) {
|
||||
int energyToUse = 20 + Math.round(getBattery().getEnergyStored() / 500);
|
||||
int energyToUse = 20 + (int) Math.ceil(getBattery().getEnergyStored() / 500);
|
||||
|
||||
if (this.consumeEnergy(energyToUse)) {
|
||||
speed = 0.1 + energyToUse / 200F;
|
||||
speed = 0.1 + energyToUse / 2000F;
|
||||
moveHead(speed);
|
||||
}
|
||||
}
|
||||
|
@ -406,8 +408,12 @@ public class TileQuarry extends TileAbstractBuilder implements IHasWork, ISidedI
|
|||
|
||||
Block block = worldObj.getBlock(i, j, k);
|
||||
int meta = worldObj.getBlockMetadata(i, j, k);
|
||||
|
||||
if (isQuarriableBlock(i, j, k)) {
|
||||
|
||||
BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(i, j, k, worldObj, block, meta,
|
||||
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj).get());
|
||||
MinecraftForge.EVENT_BUS.post(breakEvent);
|
||||
|
||||
if (!breakEvent.isCanceled() && isQuarriableBlock(i, j, k)) {
|
||||
// Share this with mining well!
|
||||
|
||||
List<ItemStack> stacks = BlockUtil.getItemStackFromBlock((WorldServer) worldObj, i, j, k);
|
||||
|
|
Loading…
Reference in a new issue