mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 19:28:55 +00:00
Added Single Explosions [ignite TNT using fling & steel]
This commit is contained in:
parent
41b1a0f991
commit
94f8cfb59b
@ -101,6 +101,9 @@ class PlayerAPI{
|
||||
case "fall":
|
||||
$message = " hit the ground too hard";
|
||||
break;
|
||||
case "explosion":
|
||||
$message = " blew up";
|
||||
break;
|
||||
default:
|
||||
$message = " died";
|
||||
break;
|
||||
|
@ -131,6 +131,7 @@ abstract class Block extends Position{
|
||||
protected $meta;
|
||||
protected $name;
|
||||
protected $breakTime;
|
||||
protected $hardness;
|
||||
public $isActivable = false;
|
||||
public $breakable = true;
|
||||
public $isFlowable = false;
|
||||
@ -151,6 +152,11 @@ abstract class Block extends Position{
|
||||
$this->meta = (int) $meta;
|
||||
$this->name = $name;
|
||||
$this->breakTime = 0.20;
|
||||
$this->hardness = 10;
|
||||
}
|
||||
|
||||
final public function getHardness(){
|
||||
return ($this->hardness);
|
||||
}
|
||||
|
||||
final public function getName(){
|
||||
|
@ -27,6 +27,7 @@ class StairBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -24,6 +24,7 @@ class LadderBlock extends TransparentBlock{
|
||||
parent::__construct(LADDER, $meta, "Ladder");
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($target->isTransparent === false){
|
||||
|
@ -24,6 +24,7 @@ class SignPostBlock extends TransparentBlock{
|
||||
parent::__construct(SIGN_POST, $meta, "Sign Post");
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 5;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class TorchBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(TORCH, $meta, "Torch");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -28,6 +28,7 @@ class TrapdoorBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = true;
|
||||
}
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class LavaBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(LAVA, $meta, "Lava");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class StillLavaBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(STILL_LAVA, $meta, "Still Lava");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ require_once("Water.php");
|
||||
class StillWaterBlock extends WaterBlock{
|
||||
public function __construct($meta = 0){
|
||||
LiquidBlock::__construct(STILL_WATER, $meta, "Still Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class WaterBlock extends LiquidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WATER, $meta, "Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -31,6 +31,7 @@ class AirBlock extends TransparentBlock{
|
||||
$this->hasPhysics = false;
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ class BedBlock extends TransparentBlock{
|
||||
parent::__construct(BED_BLOCK, $type, "Bed Block");
|
||||
$this->isActivable = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
@ -25,6 +25,7 @@ class FireBlock extends FlowableBlock{
|
||||
$this->isReplaceable = true;
|
||||
$this->breakable = false;
|
||||
$this->isFullBlock = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,5 +22,19 @@
|
||||
class TNTBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(TNT, 0, "TNT");
|
||||
$this->hardness = 0;
|
||||
$this->isActivable = true;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
if($item->getID() === FLINT_STEEL){
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$item->useOn($this);
|
||||
}
|
||||
$explosion = new Explosion($this->level, $this, 4);
|
||||
$explosion->explode();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ class CakeBlock extends TransparentBlock{
|
||||
$this->isFullBlock = false;
|
||||
$this->isActivable = true;
|
||||
$this->meta = $meta & 0x07;
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -24,6 +24,7 @@ class CobwebBlock extends FlowableBlock{
|
||||
parent::__construct(COBWEB, 0, "Cobweb");
|
||||
$this->isSolid = true;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 25;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array();
|
||||
|
@ -23,6 +23,7 @@ class FenceBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(FENCE, 0, "Fence");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,7 @@ class FenceGateBlock extends TransparentBlock{
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$faces = array(
|
||||
|
@ -23,6 +23,7 @@ class IronDoorBlock extends DoorBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block");
|
||||
//$this->isActivable = true;
|
||||
$this->hardness = 25;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -29,7 +29,6 @@ class SlabBlock extends TransparentBlock{
|
||||
3 => "Cobblestone",
|
||||
4 => "Brick",
|
||||
5 => "Stone Brick",
|
||||
//6 => "Nether Brick",
|
||||
6 => "Quartz",
|
||||
);
|
||||
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
|
||||
@ -37,7 +36,8 @@ class SlabBlock extends TransparentBlock{
|
||||
$this->isFullBlock = true;
|
||||
}else{
|
||||
$this->isFullBlock = false;
|
||||
}
|
||||
}
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -25,6 +25,7 @@ class SnowLayerBlock extends FlowableBlock{
|
||||
$this->isReplaceable = true;
|
||||
$this->isSolid = false;
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 0.5;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class WoodDoorBlock extends DoorBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class CoalOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(COAL_ORE, 0, "Coal Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DiamondOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIAMOND_ORE, 0, "Diamond Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlowingRedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GoldOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GOLD_ORE, 0, "Gold Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IronOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(IRON_ORE, 0, "Iron Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class LapisOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(LAPIS_ORE, 0, "Lapis Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class RedstoneOreBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(REDSTONE_ORE, 0, "Redstone Ore");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class BrownMushroomBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class CactusBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(CACTUS, $meta, "Cactus");
|
||||
$this->isFullBlock = false;
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class CyanFlowerBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(CYAN_FLOWER, 0, "Cyan Flower");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DandelionBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DANDELION, 0, "Dandelion");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class DeadBushBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DEAD_BUSH, 0, "Dead Bush");
|
||||
$this->isReplaceable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class MelonStemBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(MELON_STEM, $meta, "Melon Stem");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$down = $this->getSide(0);
|
||||
|
@ -22,6 +22,7 @@
|
||||
class RedMushroomBlock extends FlowableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(RED_MUSHROOM, 0, "Red Mushroom");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -34,6 +34,7 @@ class SaplingBlock extends FlowableBlock{
|
||||
2 => "Birch Sapling",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class SugarcaneBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane");
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -29,6 +29,7 @@ class TallGrassBlock extends FlowableBlock{
|
||||
2 => "Fern",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -23,6 +23,7 @@ class WheatBlock extends FlowableBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class BedrockBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BEDROCK, 0, "Bedrock");
|
||||
$this->breakable = false;
|
||||
$this->hardness = 18000000;
|
||||
}
|
||||
|
||||
public function isBreakable(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class BookshelfBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BOOKSHELF, 0, "Bookshelf");
|
||||
$this->hardness = 7.5;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class BricksBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(BRICKS_BLOCK, 0, "Bricks");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class BurningFurnaceBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 17.5;
|
||||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
|
@ -23,6 +23,7 @@ class ChestBlock extends TransparentBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(CHEST, $meta, "Chest");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
$server = ServerAPI::request();
|
||||
|
@ -22,6 +22,7 @@
|
||||
class ClayBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(CLAY_BLOCK, 0, "Clay Block");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class CobblestoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(COBBLESTONE, 0, "Cobblestone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class DiamondBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class DirtBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(DIRT, 0, "Dirt");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
@ -29,10 +29,10 @@ class DoubleSlabBlock extends SolidBlock{
|
||||
3 => "Cobblestone",
|
||||
4 => "Brick",
|
||||
5 => "Stone Brick",
|
||||
6 => "Nether Brick",
|
||||
7 => "Quartz",
|
||||
6 => "Quartz",
|
||||
);
|
||||
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class FarmlandBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(FARMLAND, $meta, "Farmland");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlassBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLASS, 0, "Glass");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GlowstoneBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone");
|
||||
$this->hardness = 1.5;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GoldBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GOLD_BLOCK, 0, "Gold Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -23,6 +23,7 @@ class GrassBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GRASS, 0, "Grass");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 3;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class GravelBlock extends FallableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(GRAVEL, 0, "Gravel");
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IceBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(ICE, 0, "Ice");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class IronBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(IRON_BLOCK, 0, "Iron Block");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class LapisBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(LAPIS_BLOCK, 0, "Lapis Block");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -32,6 +32,7 @@ class LeavesBlock extends TransparentBlock{
|
||||
3 => "",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class MelonBlock extends TransparentBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(MELON_BLOCK, 0, "Melon Block");
|
||||
$this->hardness = 5;
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
|
@ -22,6 +22,7 @@
|
||||
class MossStoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(MOSS_STONE, 0, "Moss Stone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class NetherBricksBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(NETHER_BRICKS, 0, "Nether Bricks");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class NetherrackBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(NETHERRACK, 0, "Netherrack");
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,7 +22,7 @@
|
||||
class ObsidianBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(OBSIDIAN, 0, "Obsidian");
|
||||
|
||||
$this->hardness = 6000;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class PlanksBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(PLANKS, $meta, "Wooden Planks");
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class SandBlock extends FallableBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SAND, 0, "Sand");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,8 @@ class SandstoneBlock extends SolidBlock{
|
||||
1 => "Chiseled Sandstone",
|
||||
2 => "Smooth Sandstone",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 4;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -22,6 +22,7 @@
|
||||
class SnowBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SNOW_BLOCK, 0, "Snow Block");
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class SoulSandBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(SOUL_SAND, 0, "Soul Sand");
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
}
|
@ -22,6 +22,7 @@
|
||||
class StoneBlock extends SolidBlock{
|
||||
public function __construct(){
|
||||
parent::__construct(STONE, 0, "Stone");
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -29,6 +29,7 @@ class StoneBricksBlock extends SolidBlock{
|
||||
3 => "Chiseled Stone Bricks",
|
||||
);
|
||||
$this->name = $names[$this->meta & 0x03];
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBreakTime(Item $item, Player $player){
|
||||
|
@ -33,6 +33,7 @@ class WoodBlock extends SolidBlock{
|
||||
);
|
||||
$this->meta &= 0x03;
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 10;
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ class WoolBlock extends SolidBlock{
|
||||
15 => "Black Wool",
|
||||
);
|
||||
$this->name = $names[$this->meta];
|
||||
$this->hardness = 4;
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ class WorkbenchBlock extends SolidBlock{
|
||||
public function __construct($meta = 0){
|
||||
parent::__construct(WORKBENCH, $meta, "Crafting Table");
|
||||
$this->isActivable = true;
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player){
|
||||
|
@ -20,27 +20,29 @@
|
||||
*/
|
||||
|
||||
class Explosion{
|
||||
private $i = 16; //Rays
|
||||
private $i = 8; //Rays
|
||||
public $level;
|
||||
public $source;
|
||||
public $size;
|
||||
public $affectedBlocks = array();
|
||||
|
||||
public function __construct($level, Vector3 $center, $size){
|
||||
public function __construct(Level $level, Vector3 $center, $size){
|
||||
$this->level = $level;
|
||||
$this->source = $center;
|
||||
$this->size = max($size, 0);
|
||||
}
|
||||
|
||||
public function explode(){
|
||||
if($this->size < 0.1 or ServerAPI::request()->api->dhandle("entity.explosion", array(
|
||||
"level" => $level,
|
||||
$server = ServerAPI::request();
|
||||
if($this->size < 0.1 or $server->api->dhandle("entity.explosion", array(
|
||||
"level" => $this->level,
|
||||
"source" => $this->source,
|
||||
"size" => $this->size
|
||||
))){
|
||||
return false;
|
||||
}
|
||||
|
||||
$airblock = new AirBlock();
|
||||
$drops = array();
|
||||
for($i = 0; $i < $this->i; ++$i){
|
||||
for($j = 0; $j < $this->i; ++$j){
|
||||
for($k = 0; $k < $this->i; ++$k){
|
||||
@ -53,24 +55,25 @@ class Explosion{
|
||||
$d4 /= $d6;
|
||||
$d5 /= $d6;
|
||||
|
||||
$f1 = $this->size * (0.7 + lcg_value() * 0.6);
|
||||
$f1 = $this->size * (0.7 + (mt_rand(0, 1000000) / 1000000) * 0.6);
|
||||
$d0 = $this->source->x;
|
||||
$d1 = $this->source->y;
|
||||
$d2 = $this->source->z;
|
||||
|
||||
for($f2 = 0.3; $f1 > 0; $f1 -= $f2 * 0.75){
|
||||
$l = floor($d0);
|
||||
$i1 = floor($d1);
|
||||
$j1 = floor($d2);
|
||||
$k1 = $this->level->getBlock(new Vector3($l, $i1, $j1))->getID();
|
||||
if($k1 > AIR){
|
||||
$f3 = 0.5; //Placeholder
|
||||
$f1 -= ($f3 + 0.4) * $f2;
|
||||
}
|
||||
$l = (int) $d0;
|
||||
$i1 = (int) $d1;
|
||||
$j1 = (int) $d2;
|
||||
$k1 = $this->level->getBlock(new Vector3($l, $i1, $j1));
|
||||
|
||||
if($f1 > 0 and $i1 < 128 and $i1 >= 0){
|
||||
$this->level->setBlock(new Vector3($l, $i1, $j1), AIR, 0, false);
|
||||
$this->affectedBlocks[$l.$i1.$j1] = new Vector3($l, $i1, $j1);
|
||||
$f1 -= ($k1->getHardness() / 5 + 0.3) * $f2;
|
||||
|
||||
if(!($k1 instanceof AirBlock) and $f1 > 0 and $i1 < 128 and $i1 >= 0){
|
||||
$this->level->setBlockRaw(new Vector3($l, $i1, $j1), $airblock, false, false); //Do not send record
|
||||
$this->affectedBlocks[$l.$i1.$j1] = new Vector3($l - $this->source->x, $i1 - $this->source->y, $j1 - $this->source->z);
|
||||
if(mt_rand(0, 100) < 30){
|
||||
$drops[] = array(new Position($l, $i1, $j1, $this->level), BlockAPI::getItem($k1->getID(), $k1->getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
$d0 += $d3 * $f2;
|
||||
@ -81,15 +84,21 @@ class Explosion{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(ServerAPI::request()->api->player->getAll() as $player){
|
||||
$player->dataPacket(MC_EXPLOSION, array(
|
||||
"x" => $this->source->x,
|
||||
"y" => $this->source->y,
|
||||
"z" => $this->source->z,
|
||||
"radius" => $this->size,
|
||||
"records" => array(), //Blocks are already sent
|
||||
));
|
||||
|
||||
$server->api->player->broadcastPacket($server->api->player->getAll($this->level), MC_EXPLOSION, array(
|
||||
"x" => $this->source->x,
|
||||
"y" => $this->source->y,
|
||||
"z" => $this->source->z,
|
||||
"radius" => $this->size,
|
||||
"records" => $this->affectedBlocks,
|
||||
));
|
||||
foreach($server->api->entity->getRadius($this->source, 10) as $entity){
|
||||
$impact = (1 - $this->source->distance($entity) / 10);
|
||||
$damage = (int) (($impact * $impact + $impact) * 4 * $this->size + 1);
|
||||
$entity->harm($damage, "explosion");
|
||||
}
|
||||
foreach($drops as $drop){
|
||||
$server->api->entity->drop($drop[0], $drop[1]);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user