Added new Wood slabs, stairs, crafing recipes

This commit is contained in:
Shoghi Cervantes 2014-06-16 15:46:45 +02:00
parent b3820bedbc
commit 28926832df
9 changed files with 250 additions and 4 deletions

View File

@ -0,0 +1,36 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
class AcaciaWoodStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(self::ACACIA_WOOD_STAIRS, $meta, "Acacia Wood Stairs");
}
public function getDrops(Item $item){
return array(
array($this->id, 0, 1),
);
}
}

View File

@ -199,9 +199,13 @@ abstract class Block extends Position implements Metadatable{
const WOOD_SLABS = 158;
const WOODEN_SLABS = 158;
const LEAVES2 = 161;
const LEAVE2 = 161;
const WOOD2 = 162;
const TRUNK2 = 162;
const LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 163;
const HAY_BALE = 170;
const CARPET = 171;
@ -551,6 +555,8 @@ abstract class Block extends Position implements Metadatable{
self::WOOD_SLAB => new WoodSlab(),
self::WOOD2 => new Wood2(),
self::ACACIA_WOOD_STAIRS => new AcaciaWoodStairs(),
self::DARK_OAK_WOOD_STAIRS => new DarkOakWoodStairs(),
self::HAY_BALE => new HayBale(),
self::CARPET => new Carpet(),

View File

@ -0,0 +1,36 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
class DarkOakWoodStairs extends Stair{
public function __construct($meta = 0){
parent::__construct(self::DARK_OAK_WOOD_STAIRS, $meta, "Dark Oak Wood Stairs");
}
public function getDrops(Item $item){
return array(
array($this->id, 0, 1),
);
}
}

View File

@ -31,6 +31,8 @@ class DoubleWoodSlab extends Solid{
1 => "Spruce",
2 => "Birch",
3 => "Jungle",
4 => "Acacia",
5 => "Dark Oak",
);
$this->name = "Double " . $names[$this->meta & 0x07] . " Wooden Slab";
$this->hardness = 15;

View File

@ -30,6 +30,8 @@ class Leaves extends Transparent{
const SPRUCE = 1;
const BIRCH = 2;
const JUNGLE = 3;
const ACACIA = 0;
const DARK_OAK = 1;
public function __construct($meta = 0){
parent::__construct(self::LEAVES, $meta, "Leaves");

View File

@ -0,0 +1,149 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
namespace pocketmine\block;
use pocketmine\item\Item;
use pocketmine\level\Level;
use pocketmine\Player;
class Leaves2 extends Leaves{
public function __construct($meta = 0){
Transparent::__construct(self::LEAVES, $meta, "Leaves");
$names = array(
self::ACACIA => "Acacia Leaves",
self::DARK_OAK => "Dark Oak Leaves",
);
$this->name = $names[$this->meta & 0x03];
$this->hardness = 1;
}
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){
++$check;
$index = $pos->x . "." . $pos->y . "." . $pos->z;
if(isset($visited[$index])){
return false;
}
if($pos->getID() === self::WOOD2){
return true;
}elseif($pos->getID() === self::LEAVES2 and $distance < 3){
$visited[$index] = true;
$down = $pos->getSide(0)->getID();
if($down === Item::WOOD2){
return true;
}
if($fromSide === null){
for($side = 2; $side <= 5; ++$side){
if($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side) === true){
return true;
}
}
}else{ //No more loops
switch($fromSide){
case 2:
if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}
break;
case 3:
if($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}
break;
case 4:
if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}
break;
case 5:
if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){
return true;
}
break;
}
}
}
return false;
}
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if(($this->meta & 0b00001100) === 0){
$this->meta |= 0x08;
$this->getLevel()->setBlock($this, $this, false, false, true);
}
}elseif($type === Level::BLOCK_UPDATE_RANDOM){
if(($this->meta & 0b00001100) === 0x08){
$this->meta &= 0x03;
$visited = [];
$check = 0;
if($this->findLog($this, $visited, 0, $check) === true){
$this->getLevel()->setBlock($this, $this, false, false, true);
}else{
$this->getLevel()->setBlock($this, new Air(), false, false, true);
if(mt_rand(1, 20) === 1){ //Saplings
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta & 0x03, 1));
}
return Level::BLOCK_UPDATE_NORMAL;
}
}
}
return false;
}
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->meta |= 0x04;
$this->getLevel()->setBlock($this, $this, true, false, true);
}
public function getDrops(Item $item){
$drops = [];
if($item->isShears()){
$drops[] = array(Item::LEAVES2, $this->meta & 0x03, 1);
}else{
if(mt_rand(1, 20) === 1){ //Saplings
$drops[] = array(Item::SAPLING, $this->meta & 0x03, 1);
}
}
return $drops;
}
}

View File

@ -32,6 +32,8 @@ class WoodSlab extends Transparent{
1 => "Spruce",
2 => "Birch",
3 => "Jungle",
4 => "Acacia",
5 => "Dark Oak",
);
$this->name = (($this->meta & 0x08) === 0x08 ? "Upper " : "") . $names[$this->meta & 0x07] . " Wooden Slab";
if(($this->meta & 0x08) === 0x08){
@ -66,7 +68,7 @@ class WoodSlab extends Transparent{
return true;
}
}elseif(!($player instanceof Player) or !$player->inBlock($block)){
}elseif(!($player instanceof Player)){ //TODO: collision
if($block->getID() === self::WOOD_SLAB){
if(($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);

View File

@ -23,6 +23,7 @@ namespace pocketmine\inventory;
use pocketmine\block\Planks;
use pocketmine\block\Wood;
use pocketmine\block\Wood2;
use pocketmine\item\Item;
class CraftingManager{
@ -60,8 +61,8 @@ class CraftingManager{
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4)))->addIngredient(Item::get(Item::WOOD, Wood::SPRUCE, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4)))->addIngredient(Item::get(Item::WOOD, Wood::BIRCH, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4)))->addIngredient(Item::get(Item::WOOD, Wood::JUNGLE, 1)));
//$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4)))->addIngredient(Item::get(Item::WOOD2, Wood2::ACACIA, 1)));
//$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4)))->addIngredient(Item::get(Item::WOOD2, Wood2::DARK_OAK, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4)))->addIngredient(Item::get(Item::WOOD2, Wood2::ACACIA, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4)))->addIngredient(Item::get(Item::WOOD2, Wood2::DARK_OAK, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOOL, 0, 1)))->addIngredient(Item::get(Item::STRING, 0, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::TORCH, 0, 4)))->addIngredient(Item::get(Item::COAL, null, 1))->addIngredient(Item::get(Item::STICK, 0, 1)));
$this->registerRecipe((new ShapelessRecipe(Item::get(Item::SUGAR, 0, 1)))->addIngredient(Item::get(Item::SUGARCANE, 0, 1)));
@ -85,7 +86,10 @@ class CraftingManager{
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::BIRCH, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 3)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::JUNGLE_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::JUNGLE, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 3)));
//TODO: add new wood stairs, slabs
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::ACACIA_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::ACACIA, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 3)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::DARK_OAK_WOOD_STAIRS, 0, 4)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::WOOD_SLAB, Planks::DARK_OAK, 6)))->addIngredient(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 3)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BUCKET, 0, 1)))->addIngredient(Item::get(Item::IRON_INGOT, 0, 3)));
$this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CLOCK, 0, 1)))->addIngredient(Item::get(Item::GOLD_INGOT, 0, 4))->addIngredient(Item::get(Item::REDSTONE_DUST, 0, 1)));

View File

@ -55,6 +55,7 @@ class Item{
const GOLD_ORE = 14;
const IRON_ORE = 15;
const COAL_ORE = 16;
const LOG = 17;
const WOOD = 17;
const TRUNK = 17;
const LEAVES = 18;
@ -196,6 +197,14 @@ class Item{
const WOOD_SLABS = 158;
const WOODEN_SLABS = 158;
const LEAVES2 = 161;
const LEAVE2 = 161;
const WOOD2 = 162;
const TRUNK2 = 162;
const LOG2 = 162;
const ACACIA_WOOD_STAIRS = 163;
const DARK_OAK_WOOD_STAIRS = 163;
const HAY_BALE = 170;
const CARPET = 171;