Merge pull request #28 from FreeHij/0.9.5

adding new blocks
This commit is contained in:
ArkQuark 2023-02-21 21:15:31 +03:00 • committed by GitHub
commit d6cf7d2d52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 395 additions and 9 deletions

View file

@ -95,6 +95,7 @@ class Item{
QUARTZ => "QuartzItem",
CAMERA => "CameraItem",
BEETROOT_SEEDS => "BeetrootSeedsItem",
EMERALD => "EmeraldItem",
//tool
IRON_SHOVEL => "IronShovelItem",

View file

@ -0,0 +1,33 @@
<?php
class AcaciaWoodStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs");
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isAxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 3;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
}

View file

@ -5,6 +5,26 @@ class BirchWoodStairsBlock extends StairBlock{
parent::__construct(BIRCH_WOOD_STAIRS, $meta, "Birch Wood Stairs");
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isAxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 3;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),

View file

@ -0,0 +1,33 @@
<?php
class DarkOakWoodStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs");
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isAxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 3;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
}

View file

@ -5,6 +5,26 @@ class JungleWoodStairsBlock extends StairBlock{
parent::__construct(JUNGLE_WOOD_STAIRS, $meta, "Jungle Wood Stairs");
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isAxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 3;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),

View file

@ -5,6 +5,26 @@ class SpruceWoodStairsBlock extends StairBlock{
parent::__construct(SPRUCE_WOOD_STAIRS, $meta, "Spruce Wood Stairs");
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->isAxe()){
case 5:
return 0.4;
case 4:
return 0.5;
case 3:
return 0.75;
case 2:
return 0.25;
case 1:
return 1.5;
default:
return 3;
}
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),

View file

@ -0,0 +1,32 @@
<?php
class EmeraldOreBlock extends SolidBlock{
public function __construct(){
parent::__construct(EMERALD_ORE, 0, "Emerald Ore");
$this->hardness = 15;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->getPickaxeLevel()){
case 5:
return 0.6;
case 4:
return 0.75;
default:
return 15;
}
}
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(EMERALD, 0, 1),
);
}else{
return array();
}
}
}

View file

@ -1,9 +1,30 @@
<?php
class CyanFlowerBlock extends FlowableBlock{
const POPPY = 0;
const BLUE_ORCHID = 1;
const ALLIUM = 2;
const AZURE_BLUET = 3;
const RED_TULIP = 4;
const ORANGE_TULIP = 5;
const WHITE_TULIP = 6;
const PINK_TULIP = 7;
const OXEYE_DAISY = 8;
public function __construct(){
parent::__construct(CYAN_FLOWER, 0, "Cyan Flower");
parent::__construct(CYAN_FLOWER, 0, "Poppy");
$this->hardness = 0;
$names = array(
0 => "Poppy",
1 => "Blue Orchid",
2 => "Allium",
3 => "Azure Bluet",
4 => "Red Tulip",
5 => "Orange Tulip",
6 => "White Tulip",
7 => "Pink Tulip",
8 => "Oxeye Daisy",
);
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -5,6 +5,8 @@ class SaplingBlock extends FlowableBlock{
const SPRUCE = 1;
const BIRCH = 2;
const JUNGLE = 3;
const ACACIA = 4;
const DARK_OAK = 5;
const BURN_TIME = 5;
public function __construct($meta = SaplingBlock::OAK){
@ -15,6 +17,8 @@ class SaplingBlock extends FlowableBlock{
1 => "Spruce Sapling",
2 => "Birch Sapling",
3 => "Jungle Sapling",
4 => "Acacia Sapling",
5 => "Dark Oak Sapling",
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 0;

View file

@ -0,0 +1,32 @@
<?php
class EmeraldBlock extends SolidBlock{
public function __construct(){
parent::__construct(EMERALD_BLOCK, 0, "Emerald Block");
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->getPickaxeLevel()){
case 5:
return 0.95;
case 4:
return 1.25;
default:
return 25;
}
}
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 4){
return array(
array(EMERALD_BLOCK, 0, 1),
);
}else{
return array();
}
}
}

View file

@ -0,0 +1,38 @@
<?php
class EndStoneBlock extends SolidBlock {
public function __construct(){
parent::__construct(END_STONE, 0, "End Stone");
$this->hardness = 45;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->getPickaxeLevel()){ //from pm 1.4
case 5:
return 0.6;
case 4:
return 0.75;
case 3:
return 1.15;
case 2:
return 0.4;
case 1:
return 2.25;
default:
return 15;
}
}
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array(END_STONE, 0, 1),
);
}else{
return array();
}
}
}

View file

@ -34,7 +34,7 @@ class GrassBlock extends SolidBlock{
return false;
}
public function seedsDrop(){
/*public function seedsDrop(){
$chance = Utils::randomFloat() * 100;
if($chance <= 1){
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(458,0,1));
@ -45,7 +45,7 @@ class GrassBlock extends SolidBlock{
return;
}
return;
}
}*/
public function onUpdate($type){
if($type === BLOCK_UPDATE_RANDOM && !$this->getSide(1)->isTransparent && mt_rand(0, 2) == 1){
@ -53,5 +53,4 @@ class GrassBlock extends SolidBlock{
}
return BLOCK_UPDATE_RANDOM;
}
}

View file

@ -0,0 +1,39 @@
<?php
class HardenedClayBlock extends SolidBlock {
public function __construct(){
parent::__construct(HARDENED_CLAY, 0, "Hardened Clay");
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->getPickaxeLevel()){
case 5:
return 0.25;
case 4:
return 0.35;
case 3:
return 0.5;
case 2:
return 0.2;
case 1:
return 0.95;
default:
return 6.25;
}
}
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array(HARDENED_CLAY, 0, 1),
);
}else{
return array();
}
}
}

View file

@ -0,0 +1,22 @@
<?php
class MyceliumBlock extends SolidBlock{
public function __construct(){
parent::__construct(MYCELIUM, 0, "Mycelium");
$this->isActivable = true;
$this->hardness = 3;
}
public function getDrops(Item $item, Player $player){
return array(
array(DIRT, 0, 1),
);
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_RANDOM && !$this->getSide(1)->isTransparent && mt_rand(0, 2) == 1){
$this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
}
return BLOCK_UPDATE_RANDOM;
}
}

View file

@ -8,6 +8,8 @@ class PlanksBlock extends SolidBlock{
WoodBlock::SPRUCE => "Spruce Wooden Planks",
WoodBlock::BIRCH => "Birch Wooden Planks",
WoodBlock::JUNGLE => "Jungle Wooden Planks",
WoodBlock::ACACIA => "Acacia Wooden Planks",
WoodBlock::DARK_OAK => "Dark Oak Wooden Planks",
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 15;

View file

@ -0,0 +1,58 @@
<?php
class StainedClayBlock extends SolidBlock{
public function __construct($meta = 0){
parent::__construct(STAINED_CLAY, $meta, "Stained Clay");
$names = array(
0 => "White Stained Clay",
1 => "Orange Stained Clay",
2 => "Magenta Stained Clay",
3 => "Light Blue Stained Clay",
4 => "Yellow Stained Clay",
5 => "Lime Stained Clay",
6 => "Pink Stained Clay",
7 => "Gray Stained Clay",
8 => "Light Gray Stained Clay",
9 => "Cyan Stained Clay",
10 => "Purple Stained Clay",
11 => "Blue Stained Clay",
12 => "Brown Stained Clay",
13 => "Green Stained Clay",
14 => "Red Stained Clay",
15 => "Black Stained Clay",
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 30;
}
public function getBreakTime(Item $item, Player $player){
if(($player->gamemode & 0x01) === 0x01){
return 0.20;
}
switch($item->getPickaxeLevel()){
case 5:
return 0.25;
case 4:
return 0.35;
case 3:
return 0.5;
case 2:
return 0.2;
case 1:
return 0.95;
default:
return 6.25;
}
}
public function getDrops(Item $item, Player $player){
if($item->getPickaxeLevel() >= 1){
return array(
array(STAINED_CLAY, $this->meta & 0x03, 1),
);
}else{
return array();
}
}
}

View file

@ -5,14 +5,18 @@ class WoodBlock extends SolidBlock{
const SPRUCE = 1;
const BIRCH = 2;
const JUNGLE = 3;
const ACACIA = 4;
const DARK_OAK = 5;
public function __construct($meta = 0){
parent::__construct(WOOD, $meta, "Wood");
parent::__construct(WOOD, $meta, "Log");
$names = array(
WoodBlock::OAK => "Oak Wood",
WoodBlock::SPRUCE => "Spruce Wood",
WoodBlock::BIRCH => "Birch Wood",
WoodBlock::JUNGLE => "Jungle Wood",
WoodBlock::OAK => "Oak Log",
WoodBlock::SPRUCE => "Spruce Log",
WoodBlock::BIRCH => "Birch Log",
WoodBlock::JUNGLE => "Jungle Log",
WoodBlock::ACACIA => "Acacia Log",
WoodBlock::DARK_OAK => "Dark Oak Log"
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 10;

View file

@ -0,0 +1,8 @@
<?php
class EmeraldItem extends Item{
public function __construct($meta = 0, $count = 1){
parent::__construct(EMERALD, 0, $count, "Emerald");
}
}