Added Single Explosions [ignite TNT using fling & steel]

This commit is contained in:
Shoghi Cervantes 2013-09-06 13:46:52 +02:00
parent 41b1a0f991
commit 94f8cfb59b
77 changed files with 134 additions and 32 deletions

View File

@ -101,6 +101,9 @@ class PlayerAPI{
case "fall": case "fall":
$message = " hit the ground too hard"; $message = " hit the ground too hard";
break; break;
case "explosion":
$message = " blew up";
break;
default: default:
$message = " died"; $message = " died";
break; break;

View File

@ -131,6 +131,7 @@ abstract class Block extends Position{
protected $meta; protected $meta;
protected $name; protected $name;
protected $breakTime; protected $breakTime;
protected $hardness;
public $isActivable = false; public $isActivable = false;
public $breakable = true; public $breakable = true;
public $isFlowable = false; public $isFlowable = false;
@ -151,6 +152,11 @@ abstract class Block extends Position{
$this->meta = (int) $meta; $this->meta = (int) $meta;
$this->name = $name; $this->name = $name;
$this->breakTime = 0.20; $this->breakTime = 0.20;
$this->hardness = 10;
}
final public function getHardness(){
return ($this->hardness);
} }
final public function getName(){ final public function getName(){

View File

@ -27,6 +27,7 @@ class StairBlock extends TransparentBlock{
}else{ }else{
$this->isFullBlock = false; $this->isFullBlock = false;
} }
$this->hardness = 30;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -24,6 +24,7 @@ class LadderBlock extends TransparentBlock{
parent::__construct(LADDER, $meta, "Ladder"); parent::__construct(LADDER, $meta, "Ladder");
$this->isSolid = false; $this->isSolid = false;
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 2;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($target->isTransparent === false){ if($target->isTransparent === false){

View File

@ -24,6 +24,7 @@ class SignPostBlock extends TransparentBlock{
parent::__construct(SIGN_POST, $meta, "Sign Post"); parent::__construct(SIGN_POST, $meta, "Sign Post");
$this->isSolid = false; $this->isSolid = false;
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 5;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -22,6 +22,7 @@
class TorchBlock extends FlowableBlock{ class TorchBlock extends FlowableBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(TORCH, $meta, "Torch"); parent::__construct(TORCH, $meta, "Torch");
$this->hardness = 0;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -28,6 +28,7 @@ class TrapdoorBlock extends TransparentBlock{
}else{ }else{
$this->isFullBlock = true; $this->isFullBlock = true;
} }
$this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ 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){ if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){

View File

@ -22,6 +22,7 @@
class LavaBlock extends LiquidBlock{ class LavaBlock extends LiquidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(LAVA, $meta, "Lava"); parent::__construct(LAVA, $meta, "Lava");
$this->hardness = 0;
} }
} }

View File

@ -22,6 +22,7 @@
class StillLavaBlock extends LiquidBlock{ class StillLavaBlock extends LiquidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(STILL_LAVA, $meta, "Still Lava"); parent::__construct(STILL_LAVA, $meta, "Still Lava");
$this->hardness = 500;
} }
} }

View File

@ -27,6 +27,7 @@ require_once("Water.php");
class StillWaterBlock extends WaterBlock{ class StillWaterBlock extends WaterBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
LiquidBlock::__construct(STILL_WATER, $meta, "Still Water"); LiquidBlock::__construct(STILL_WATER, $meta, "Still Water");
$this->hardness = 500;
} }
} }

View File

@ -22,6 +22,7 @@
class WaterBlock extends LiquidBlock{ class WaterBlock extends LiquidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(WATER, $meta, "Water"); parent::__construct(WATER, $meta, "Water");
$this->hardness = 500;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -31,6 +31,7 @@ class AirBlock extends TransparentBlock{
$this->hasPhysics = false; $this->hasPhysics = false;
$this->isSolid = false; $this->isSolid = false;
$this->isFullBlock = true; $this->isFullBlock = true;
$this->hardness = 0;
} }

View File

@ -24,6 +24,7 @@ class BedBlock extends TransparentBlock{
parent::__construct(BED_BLOCK, $type, "Bed Block"); parent::__construct(BED_BLOCK, $type, "Bed Block");
$this->isActivable = true; $this->isActivable = true;
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 1;
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){

View File

@ -25,6 +25,7 @@ class FireBlock extends FlowableBlock{
$this->isReplaceable = true; $this->isReplaceable = true;
$this->breakable = false; $this->breakable = false;
$this->isFullBlock = true; $this->isFullBlock = true;
$this->hardness = 0;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,5 +22,19 @@
class TNTBlock extends SolidBlock{ class TNTBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(TNT, 0, "TNT"); 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;
} }
} }

View File

@ -25,6 +25,7 @@ class CakeBlock extends TransparentBlock{
$this->isFullBlock = false; $this->isFullBlock = false;
$this->isActivable = true; $this->isActivable = true;
$this->meta = $meta & 0x07; $this->meta = $meta & 0x07;
$this->hardness = 2.5;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -24,6 +24,7 @@ class CobwebBlock extends FlowableBlock{
parent::__construct(COBWEB, 0, "Cobweb"); parent::__construct(COBWEB, 0, "Cobweb");
$this->isSolid = true; $this->isSolid = true;
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 25;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array(); return array();

View File

@ -23,6 +23,7 @@ class FenceBlock extends TransparentBlock{
public function __construct(){ public function __construct(){
parent::__construct(FENCE, 0, "Fence"); parent::__construct(FENCE, 0, "Fence");
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 15;
} }
} }

View File

@ -28,6 +28,7 @@ class FenceGateBlock extends TransparentBlock{
}else{ }else{
$this->isFullBlock = false; $this->isFullBlock = false;
} }
$this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$faces = array( $faces = array(

View File

@ -23,6 +23,7 @@ class IronDoorBlock extends DoorBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block"); parent::__construct(IRON_DOOR_BLOCK, $meta, "Iron Door Block");
//$this->isActivable = true; //$this->isActivable = true;
$this->hardness = 25;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -29,7 +29,6 @@ class SlabBlock extends TransparentBlock{
3 => "Cobblestone", 3 => "Cobblestone",
4 => "Brick", 4 => "Brick",
5 => "Stone Brick", 5 => "Stone Brick",
//6 => "Nether Brick",
6 => "Quartz", 6 => "Quartz",
); );
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab"; $this->name = (($this->meta & 0x08) === 0x08 ? "Upper ":"") . $names[$this->meta & 0x07] . " Slab";
@ -37,7 +36,8 @@ class SlabBlock extends TransparentBlock{
$this->isFullBlock = true; $this->isFullBlock = true;
}else{ }else{
$this->isFullBlock = false; $this->isFullBlock = false;
} }
$this->hardness = 30;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -25,6 +25,7 @@ class SnowLayerBlock extends FlowableBlock{
$this->isReplaceable = true; $this->isReplaceable = true;
$this->isSolid = false; $this->isSolid = false;
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 0.5;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -23,6 +23,7 @@ class WoodDoorBlock extends DoorBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block"); parent::__construct(WOOD_DOOR_BLOCK, $meta, "Wood Door Block");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 15;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class CoalOreBlock extends SolidBlock{ class CoalOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(COAL_ORE, 0, "Coal Ore"); parent::__construct(COAL_ORE, 0, "Coal Ore");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class DiamondOreBlock extends SolidBlock{ class DiamondOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(DIAMOND_ORE, 0, "Diamond Ore"); parent::__construct(DIAMOND_ORE, 0, "Diamond Ore");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class GlowingRedstoneOreBlock extends SolidBlock{ class GlowingRedstoneOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore"); parent::__construct(GLOWING_REDSTONE_ORE, 0, "Glowing Redstone Ore");
$this->hardness = 15;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -22,6 +22,7 @@
class GoldOreBlock extends SolidBlock{ class GoldOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(GOLD_ORE, 0, "Gold Ore"); parent::__construct(GOLD_ORE, 0, "Gold Ore");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class IronOreBlock extends SolidBlock{ class IronOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(IRON_ORE, 0, "Iron Ore"); parent::__construct(IRON_ORE, 0, "Iron Ore");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class LapisOreBlock extends SolidBlock{ class LapisOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(LAPIS_ORE, 0, "Lapis Ore"); parent::__construct(LAPIS_ORE, 0, "Lapis Ore");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class RedstoneOreBlock extends SolidBlock{ class RedstoneOreBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(REDSTONE_ORE, 0, "Redstone Ore"); parent::__construct(REDSTONE_ORE, 0, "Redstone Ore");
$this->hardness = 15;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -22,6 +22,7 @@
class BrownMushroomBlock extends FlowableBlock{ class BrownMushroomBlock extends FlowableBlock{
public function __construct(){ public function __construct(){
parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom"); parent::__construct(BROWN_MUSHROOM, 0, "Brown Mushroom");
$this->hardness = 0;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -23,6 +23,7 @@ class CactusBlock extends TransparentBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(CACTUS, $meta, "Cactus"); parent::__construct(CACTUS, $meta, "Cactus");
$this->isFullBlock = false; $this->isFullBlock = false;
$this->hardness = 2;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -22,6 +22,7 @@
class CyanFlowerBlock extends FlowableBlock{ class CyanFlowerBlock extends FlowableBlock{
public function __construct(){ public function __construct(){
parent::__construct(CYAN_FLOWER, 0, "Cyan Flower"); 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){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -22,6 +22,7 @@
class DandelionBlock extends FlowableBlock{ class DandelionBlock extends FlowableBlock{
public function __construct(){ public function __construct(){
parent::__construct(DANDELION, 0, "Dandelion"); parent::__construct(DANDELION, 0, "Dandelion");
$this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -23,6 +23,7 @@ class DeadBushBlock extends FlowableBlock{
public function __construct(){ public function __construct(){
parent::__construct(DEAD_BUSH, 0, "Dead Bush"); parent::__construct(DEAD_BUSH, 0, "Dead Bush");
$this->isReplaceable = true; $this->isReplaceable = true;
$this->hardness = 0;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -23,6 +23,7 @@ class MelonStemBlock extends FlowableBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(MELON_STEM, $meta, "Melon Stem"); parent::__construct(MELON_STEM, $meta, "Melon Stem");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0); $down = $this->getSide(0);

View File

@ -22,6 +22,7 @@
class RedMushroomBlock extends FlowableBlock{ class RedMushroomBlock extends FlowableBlock{
public function __construct(){ public function __construct(){
parent::__construct(RED_MUSHROOM, 0, "Red Mushroom"); parent::__construct(RED_MUSHROOM, 0, "Red Mushroom");
$this->hardness = 0;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -34,6 +34,7 @@ class SaplingBlock extends FlowableBlock{
2 => "Birch Sapling", 2 => "Birch Sapling",
); );
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -22,6 +22,7 @@
class SugarcaneBlock extends FlowableBlock{ class SugarcaneBlock extends FlowableBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane"); parent::__construct(SUGARCANE_BLOCK, $meta, "Sugarcane");
$this->hardness = 0;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -29,6 +29,7 @@ class TallGrassBlock extends FlowableBlock{
2 => "Fern", 2 => "Fern",
); );
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 0;
} }
public function onUpdate($type){ public function onUpdate($type){

View File

@ -23,6 +23,7 @@ class WheatBlock extends FlowableBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block"); parent::__construct(WHEAT_BLOCK, $meta, "Wheat Block");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 0;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -23,6 +23,7 @@ class BedrockBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(BEDROCK, 0, "Bedrock"); parent::__construct(BEDROCK, 0, "Bedrock");
$this->breakable = false; $this->breakable = false;
$this->hardness = 18000000;
} }
public function isBreakable(Item $item, Player $player){ public function isBreakable(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class BookshelfBlock extends SolidBlock{ class BookshelfBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(BOOKSHELF, 0, "Bookshelf"); parent::__construct(BOOKSHELF, 0, "Bookshelf");
$this->hardness = 7.5;
} }
} }

View File

@ -22,6 +22,7 @@
class BricksBlock extends SolidBlock{ class BricksBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(BRICKS_BLOCK, 0, "Bricks"); parent::__construct(BRICKS_BLOCK, 0, "Bricks");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -23,6 +23,7 @@ class BurningFurnaceBlock extends SolidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace"); parent::__construct(BURNING_FURNACE, $meta, "Burning Furnace");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 17.5;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View File

@ -23,6 +23,7 @@ class ChestBlock extends TransparentBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(CHEST, $meta, "Chest"); parent::__construct(CHEST, $meta, "Chest");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 15;
} }
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$server = ServerAPI::request(); $server = ServerAPI::request();

View File

@ -22,6 +22,7 @@
class ClayBlock extends SolidBlock{ class ClayBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(CLAY_BLOCK, 0, "Clay Block"); parent::__construct(CLAY_BLOCK, 0, "Clay Block");
$this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class CobblestoneBlock extends SolidBlock{ class CobblestoneBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(COBBLESTONE, 0, "Cobblestone"); parent::__construct(COBBLESTONE, 0, "Cobblestone");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class DiamondBlock extends SolidBlock{ class DiamondBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block"); parent::__construct(DIAMOND_BLOCK, 0, "Diamond Block");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -23,6 +23,7 @@ class DirtBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(DIRT, 0, "Dirt"); parent::__construct(DIRT, 0, "Dirt");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 2.5;
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){

View File

@ -29,10 +29,10 @@ class DoubleSlabBlock extends SolidBlock{
3 => "Cobblestone", 3 => "Cobblestone",
4 => "Brick", 4 => "Brick",
5 => "Stone Brick", 5 => "Stone Brick",
6 => "Nether Brick", 6 => "Quartz",
7 => "Quartz",
); );
$this->name = "Double " . $names[$this->meta & 0x07] . " Slab"; $this->name = "Double " . $names[$this->meta & 0x07] . " Slab";
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class FarmlandBlock extends SolidBlock{ class FarmlandBlock extends SolidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(FARMLAND, $meta, "Farmland"); parent::__construct(FARMLAND, $meta, "Farmland");
$this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(

View File

@ -22,6 +22,7 @@
class GlassBlock extends TransparentBlock{ class GlassBlock extends TransparentBlock{
public function __construct(){ public function __construct(){
parent::__construct(GLASS, 0, "Glass"); parent::__construct(GLASS, 0, "Glass");
$this->hardness = 1.5;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class GlowstoneBlock extends TransparentBlock{ class GlowstoneBlock extends TransparentBlock{
public function __construct(){ public function __construct(){
parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone"); parent::__construct(GLOWSTONE_BLOCK, 0, "Glowstone");
$this->hardness = 1.5;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class GoldBlock extends SolidBlock{ class GoldBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(GOLD_BLOCK, 0, "Gold Block"); parent::__construct(GOLD_BLOCK, 0, "Gold Block");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -23,6 +23,7 @@ class GrassBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(GRASS, 0, "Grass"); parent::__construct(GRASS, 0, "Grass");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(

View File

@ -22,6 +22,7 @@
class GravelBlock extends FallableBlock{ class GravelBlock extends FallableBlock{
public function __construct(){ public function __construct(){
parent::__construct(GRAVEL, 0, "Gravel"); parent::__construct(GRAVEL, 0, "Gravel");
$this->hardness = 3;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class IceBlock extends TransparentBlock{ class IceBlock extends TransparentBlock{
public function __construct(){ public function __construct(){
parent::__construct(ICE, 0, "Ice"); parent::__construct(ICE, 0, "Ice");
$this->hardness = 2.5;
} }
public function onBreak(Item $item, Player $player){ public function onBreak(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class IronBlock extends SolidBlock{ class IronBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(IRON_BLOCK, 0, "Iron Block"); parent::__construct(IRON_BLOCK, 0, "Iron Block");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class LapisBlock extends SolidBlock{ class LapisBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(LAPIS_BLOCK, 0, "Lapis Block"); parent::__construct(LAPIS_BLOCK, 0, "Lapis Block");
$this->hardness = 15;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -32,6 +32,7 @@ class LeavesBlock extends TransparentBlock{
3 => "", 3 => "",
); );
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 1;
} }
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){

View File

@ -22,6 +22,7 @@
class MelonBlock extends TransparentBlock{ class MelonBlock extends TransparentBlock{
public function __construct(){ public function __construct(){
parent::__construct(MELON_BLOCK, 0, "Melon Block"); parent::__construct(MELON_BLOCK, 0, "Melon Block");
$this->hardness = 5;
} }
public function getDrops(Item $item, Player $player){ public function getDrops(Item $item, Player $player){
return array( return array(

View File

@ -22,6 +22,7 @@
class MossStoneBlock extends SolidBlock{ class MossStoneBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(MOSS_STONE, 0, "Moss Stone"); parent::__construct(MOSS_STONE, 0, "Moss Stone");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class NetherBricksBlock extends SolidBlock{ class NetherBricksBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(NETHER_BRICKS, 0, "Nether Bricks"); parent::__construct(NETHER_BRICKS, 0, "Nether Bricks");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class NetherrackBlock extends SolidBlock{ class NetherrackBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(NETHERRACK, 0, "Netherrack"); parent::__construct(NETHERRACK, 0, "Netherrack");
$this->hardness = 2;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,7 +22,7 @@
class ObsidianBlock extends SolidBlock{ class ObsidianBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(OBSIDIAN, 0, "Obsidian"); parent::__construct(OBSIDIAN, 0, "Obsidian");
$this->hardness = 6000;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class PlanksBlock extends SolidBlock{ class PlanksBlock extends SolidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(PLANKS, $meta, "Wooden Planks"); parent::__construct(PLANKS, $meta, "Wooden Planks");
$this->hardness = 15;
} }
} }

View File

@ -22,6 +22,7 @@
class SandBlock extends FallableBlock{ class SandBlock extends FallableBlock{
public function __construct(){ public function __construct(){
parent::__construct(SAND, 0, "Sand"); parent::__construct(SAND, 0, "Sand");
$this->hardness = 2.5;
} }
} }

View File

@ -27,7 +27,8 @@ class SandstoneBlock extends SolidBlock{
1 => "Chiseled Sandstone", 1 => "Chiseled Sandstone",
2 => "Smooth 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){ public function getBreakTime(Item $item, Player $player){

View File

@ -22,6 +22,7 @@
class SnowBlock extends SolidBlock{ class SnowBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(SNOW_BLOCK, 0, "Snow Block"); parent::__construct(SNOW_BLOCK, 0, "Snow Block");
$this->hardness = 1;
} }
} }

View File

@ -22,6 +22,7 @@
class SoulSandBlock extends SolidBlock{ class SoulSandBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(SOUL_SAND, 0, "Soul Sand"); parent::__construct(SOUL_SAND, 0, "Soul Sand");
$this->hardness = 2.5;
} }
} }

View File

@ -22,6 +22,7 @@
class StoneBlock extends SolidBlock{ class StoneBlock extends SolidBlock{
public function __construct(){ public function __construct(){
parent::__construct(STONE, 0, "Stone"); parent::__construct(STONE, 0, "Stone");
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -29,6 +29,7 @@ class StoneBricksBlock extends SolidBlock{
3 => "Chiseled Stone Bricks", 3 => "Chiseled Stone Bricks",
); );
$this->name = $names[$this->meta & 0x03]; $this->name = $names[$this->meta & 0x03];
$this->hardness = 30;
} }
public function getBreakTime(Item $item, Player $player){ public function getBreakTime(Item $item, Player $player){

View File

@ -33,6 +33,7 @@ class WoodBlock extends SolidBlock{
); );
$this->meta &= 0x03; $this->meta &= 0x03;
$this->name = $names[$this->meta]; $this->name = $names[$this->meta];
$this->hardness = 10;
} }
} }

View File

@ -41,6 +41,7 @@ class WoolBlock extends SolidBlock{
15 => "Black Wool", 15 => "Black Wool",
); );
$this->name = $names[$this->meta]; $this->name = $names[$this->meta];
$this->hardness = 4;
} }
} }

View File

@ -23,6 +23,7 @@ class WorkbenchBlock extends SolidBlock{
public function __construct($meta = 0){ public function __construct($meta = 0){
parent::__construct(WORKBENCH, $meta, "Crafting Table"); parent::__construct(WORKBENCH, $meta, "Crafting Table");
$this->isActivable = true; $this->isActivable = true;
$this->hardness = 15;
} }
public function onActivate(Item $item, Player $player){ public function onActivate(Item $item, Player $player){

View File

@ -20,27 +20,29 @@
*/ */
class Explosion{ class Explosion{
private $i = 16; //Rays private $i = 8; //Rays
public $level; public $level;
public $source; public $source;
public $size; public $size;
public $affectedBlocks = array(); public $affectedBlocks = array();
public function __construct($level, Vector3 $center, $size){ public function __construct(Level $level, Vector3 $center, $size){
$this->level = $level; $this->level = $level;
$this->source = $center; $this->source = $center;
$this->size = max($size, 0); $this->size = max($size, 0);
} }
public function explode(){ public function explode(){
if($this->size < 0.1 or ServerAPI::request()->api->dhandle("entity.explosion", array( $server = ServerAPI::request();
"level" => $level, if($this->size < 0.1 or $server->api->dhandle("entity.explosion", array(
"level" => $this->level,
"source" => $this->source, "source" => $this->source,
"size" => $this->size "size" => $this->size
))){ ))){
return false; return false;
} }
$airblock = new AirBlock();
$drops = array();
for($i = 0; $i < $this->i; ++$i){ for($i = 0; $i < $this->i; ++$i){
for($j = 0; $j < $this->i; ++$j){ for($j = 0; $j < $this->i; ++$j){
for($k = 0; $k < $this->i; ++$k){ for($k = 0; $k < $this->i; ++$k){
@ -53,24 +55,25 @@ class Explosion{
$d4 /= $d6; $d4 /= $d6;
$d5 /= $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; $d0 = $this->source->x;
$d1 = $this->source->y; $d1 = $this->source->y;
$d2 = $this->source->z; $d2 = $this->source->z;
for($f2 = 0.3; $f1 > 0; $f1 -= $f2 * 0.75){ for($f2 = 0.3; $f1 > 0; $f1 -= $f2 * 0.75){
$l = floor($d0); $l = (int) $d0;
$i1 = floor($d1); $i1 = (int) $d1;
$j1 = floor($d2); $j1 = (int) $d2;
$k1 = $this->level->getBlock(new Vector3($l, $i1, $j1))->getID(); $k1 = $this->level->getBlock(new Vector3($l, $i1, $j1));
if($k1 > AIR){
$f3 = 0.5; //Placeholder
$f1 -= ($f3 + 0.4) * $f2;
}
if($f1 > 0 and $i1 < 128 and $i1 >= 0){ $f1 -= ($k1->getHardness() / 5 + 0.3) * $f2;
$this->level->setBlock(new Vector3($l, $i1, $j1), AIR, 0, false);
$this->affectedBlocks[$l.$i1.$j1] = new Vector3($l, $i1, $j1); 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; $d0 += $d3 * $f2;
@ -81,15 +84,21 @@ class Explosion{
} }
} }
} }
foreach(ServerAPI::request()->api->player->getAll() as $player){ $server->api->player->broadcastPacket($server->api->player->getAll($this->level), MC_EXPLOSION, array(
$player->dataPacket(MC_EXPLOSION, array( "x" => $this->source->x,
"x" => $this->source->x, "y" => $this->source->y,
"y" => $this->source->y, "z" => $this->source->z,
"z" => $this->source->z, "radius" => $this->size,
"radius" => $this->size, "records" => $this->affectedBlocks,
"records" => array(), //Blocks are already sent ));
)); 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]);
} }
} }
} }