mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
Added Vines and Mycelium blocks
This commit is contained in:
parent
62e47bab13
commit
9118406d7d
6 changed files with 59 additions and 27 deletions
|
|
@ -182,7 +182,7 @@ define("GLASS_PANEL", 102);
|
||||||
define("MELON_BLOCK", 103);
|
define("MELON_BLOCK", 103);
|
||||||
define("PUMPKIN_STEM", 104);
|
define("PUMPKIN_STEM", 104);
|
||||||
define("MELON_STEM", 105);
|
define("MELON_STEM", 105);
|
||||||
|
define("VINES", 106);
|
||||||
define("FENCE_GATE", 107);
|
define("FENCE_GATE", 107);
|
||||||
define("BRICK_STAIRS", 108);
|
define("BRICK_STAIRS", 108);
|
||||||
define("STONE_BRICK_STAIRS", 109);
|
define("STONE_BRICK_STAIRS", 109);
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ abstract class Block extends Position{
|
||||||
RED_MUSHROOM_BLOCK => "RedMushroomSolidBlock",
|
RED_MUSHROOM_BLOCK => "RedMushroomSolidBlock",
|
||||||
BROWN_MUSHROOM_BLOCK => "BrownMushroomSolidBlock",
|
BROWN_MUSHROOM_BLOCK => "BrownMushroomSolidBlock",
|
||||||
MONSTER_SPAWNER => "MonsterSpawnerBlock",
|
MONSTER_SPAWNER => "MonsterSpawnerBlock",
|
||||||
|
VINES => "VinesBlock",
|
||||||
|
MYCELIUM => "MyceliumBlock",
|
||||||
);
|
);
|
||||||
protected $id;
|
protected $id;
|
||||||
protected $meta;
|
protected $meta;
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,23 @@ class CocoaBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
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->getID() === WOOD and ($target->getMetadata() & 0x03) === 0x03){
|
if($face === 0 || $face === 1){
|
||||||
//$this->meta = $face;
|
return false; //fix of placing invalid ids without array
|
||||||
$this->level->setBlock($block, $this, true, false, true);
|
}
|
||||||
|
if($target->isTransparent === false){
|
||||||
|
$faces = array(
|
||||||
|
2 => 0x00,
|
||||||
|
3 => 0x00,
|
||||||
|
4 => 0x00,
|
||||||
|
5 => 0x00,
|
||||||
|
);
|
||||||
|
$this->level->setBlock($this, BlockAPI::get($this->id, $faces[$face]), true, false, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player){
|
/*public function onActivate(Item $item, Player $player){
|
||||||
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
|
||||||
$this->meta++;
|
$this->meta++;
|
||||||
if($this->meta > 0x02){
|
if($this->meta > 0x02){
|
||||||
|
|
@ -32,20 +40,7 @@ class CocoaBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === BLOCK_UPDATE_NORMAL){
|
if($type === BLOCK_UPDATE_RANDOM){
|
||||||
/*$side = $this->getMetadata();
|
|
||||||
$faces = array( //magical tranformation
|
|
||||||
3 => 2,
|
|
||||||
2 => 3,
|
|
||||||
5 => 4,
|
|
||||||
4 => 5,
|
|
||||||
);
|
|
||||||
if($this->getSide($faces[$side]) instanceof AirBlock){ //Replace with common break method
|
|
||||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1));
|
|
||||||
$this->level->setBlock($this, new AirBlock(), true, false, true);
|
|
||||||
return BLOCK_UPDATE_NORMAL;
|
|
||||||
}*/
|
|
||||||
}elseif($type === BLOCK_UPDATE_RANDOM){
|
|
||||||
if(mt_rand(0, 2) == 1){
|
if(mt_rand(0, 2) == 1){
|
||||||
if($this->meta < 0x03){
|
if($this->meta < 0x03){
|
||||||
++$this->meta;
|
++$this->meta;
|
||||||
|
|
@ -57,11 +52,11 @@ class CocoaBlock extends FlowableBlock{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
$drops = [];
|
$drops = [];
|
||||||
if($this->meta >= 0x02){
|
if($this->meta >= 0x02){ //hum?
|
||||||
$drops[] = [DYE, 3, mt_rand(1, 4)];
|
$drops[] = [DYE, 3, mt_rand(1, 4)];
|
||||||
}else{
|
}else{
|
||||||
$drops[] = [DYE, 3, 1];
|
$drops[] = [DYE, 3, 1];
|
||||||
|
|
|
||||||
0
src/material/block/plant/LilypadBlock.php
Normal file
0
src/material/block/plant/LilypadBlock.php
Normal file
35
src/material/block/plant/VinesBlock.php
Normal file
35
src/material/block/plant/VinesBlock.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class VinesBlock extends FlowableBlock{
|
||||||
|
public function __construct($meta = 0){
|
||||||
|
parent::__construct(VINES, $meta, "Vines");
|
||||||
|
$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($face === 0 || $face === 1){
|
||||||
|
return false; //fix of placing invalid ids without array
|
||||||
|
}
|
||||||
|
if($target->isTransparent === false){
|
||||||
|
$faces = array(
|
||||||
|
2 => 0x01,
|
||||||
|
3 => 0x04,
|
||||||
|
4 => 0x08,
|
||||||
|
5 => 0x02,
|
||||||
|
);
|
||||||
|
$this->level->setBlock($this, BlockAPI::get($this->id, $faces[$face]), true, false, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item, Player $player){
|
||||||
|
$drops = array();
|
||||||
|
if($item->isShears()){
|
||||||
|
$drops[] = array($this->id, 0, 1);
|
||||||
|
}
|
||||||
|
return $drops;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,16 +7,16 @@ class MyceliumBlock extends SolidBlock{
|
||||||
$this->hardness = 3;
|
$this->hardness = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
|
||||||
return array(
|
|
||||||
array(DIRT, 0, 1),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === BLOCK_UPDATE_RANDOM && !$this->getSide(1)->isTransparent && mt_rand(0, 2) == 1){
|
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);
|
$this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
|
||||||
}
|
}
|
||||||
return BLOCK_UPDATE_RANDOM;
|
return BLOCK_UPDATE_RANDOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDrops(Item $item, Player $player){
|
||||||
|
return array(
|
||||||
|
array(DIRT, 0, 1),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue