Added rare drop from reactor
Tall grass now drop only wheat seeds
Fix utils::chance()
Zombie now can drop carrot or potato
This commit is contained in:
ArkQuark 2022-06-02 23:56:38 +03:00
parent ccc51c8fe7
commit ac60efb7ca
4 changed files with 27 additions and 39 deletions

View file

@ -34,10 +34,9 @@ class TallGrassBlock 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)->isTransparent === true){//Replace with common break method
$this->level->setBlock($this, new AirBlock(), false, false, true);
$random = mt_rand(0,3);
if($random == 3) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
return BLOCK_UPDATE_NORMAL;
}
}
@ -46,34 +45,16 @@ class TallGrassBlock extends FlowableBlock{
public function getDrops(Item $item, Player $player){
$drops = array();
$possibleDrops = array(
array(WHEAT_SEEDS, 0, 1),
array(CARROT, 0, 1),
array(POTATO, 0, 1),
array(BEETROOT_SEEDS, 0, 1),
array(MELON_SEEDS, 0, 1),
array(PUMPKIN_SEEDS, 0, 1),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
);
if ($item->isShears()){
$drops[] = array($this->id, $this->meta & 0x03, 1);
}
elseif(($item = $possibleDrops[mt_rand(0, count($possibleDrops) - 1)]) !== 0){
$drops[] = $item;
elseif(Utils::chance(15)){
$drops[] = array(WHEAT_SEEDS, 0, 1)
}
return $drops;
}
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);
if($down->getID() == 2 or $down->getID() == 3){
$this->level->setBlock($block, $this, true, false, true);