mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Plant fix
This commit is contained in:
parent
133f398a42
commit
a8d4797cf2
8 changed files with 31 additions and 15 deletions
|
|
@ -38,17 +38,16 @@ class FarmlandBlock extends TransparentBlock{
|
|||
}
|
||||
return false;
|
||||
}
|
||||
$this->level->scheduleBlockUpdate(new Position($this, 0, 0, $this->level), Utils::getRandomUpdateTicks(), BLOCK_UPDATE_RANDOM);
|
||||
if($type === BLOCK_UPDATE_RANDOM){
|
||||
if($this->checkWater()){
|
||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 1), true, false, true);
|
||||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
else{
|
||||
if($this->getSide(1)->isFlowable) return BLOCK_UPDATE_RANDOM;
|
||||
$this->level->setBlock($this, BlockAPI::get(DIRT, 0), true, false, true);
|
||||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class BeetrootBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS, 0, 1));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class CarrotBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(CARROT, 0, 1));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class MelonStemBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(MELON_SEEDS, 0, mt_rand(0, 2)));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
|
|
@ -83,8 +83,16 @@ class MelonStemBlock extends FlowableBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(MELON_SEEDS, 0, mt_rand(0, 2)),
|
||||
);
|
||||
$drops = array();
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(MELON_SEEDS, 0, mt_rand(1, 2));
|
||||
}
|
||||
elseif($this->meta >= 0x01 and $this->meta <= 0x07){
|
||||
$drops[] = array(MELON_SEEDS, 0, 1);
|
||||
}
|
||||
else{
|
||||
$drops[] = array(MELON_SEEDS, 0, 0);
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ class PotatoBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(POTATO, 0, 1));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(PUMPKIN_SEEDS, 0, mt_rand(0, 2)));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
|
|
@ -83,8 +83,16 @@ class PumpkinStemBlock extends FlowableBlock{
|
|||
}
|
||||
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array(PUMPKIN_SEEDS, 0, mt_rand(0, 2)),
|
||||
);
|
||||
$drops = array();
|
||||
if($this->meta >= 0x07){
|
||||
$drops[] = array(PUMPKIN_SEEDS, 0, mt_rand(1, 2));
|
||||
}
|
||||
elseif($this->meta >= 0x01 and $this->meta <= 0x07){
|
||||
$drops[] = array(PUMPKIN_SEEDS, 0, 1);
|
||||
}
|
||||
else{
|
||||
$drops[] = array(PUMPKIN_SEEDS, 0, 0);
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
}
|
||||
|
|
@ -53,12 +53,13 @@ class WheatBlock extends FlowableBlock{
|
|||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
||||
if($this->getSide(0)->getID() != 60){
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}elseif($type === BLOCK_UPDATE_RANDOM){
|
||||
}
|
||||
elseif($type === BLOCK_UPDATE_RANDOM){
|
||||
if(mt_rand(0, 2) == 1){
|
||||
if($this->meta < 0x07){
|
||||
++$this->meta;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue