mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +00:00
Improved item drop spawning
This commit is contained in:
parent
b26ee09f76
commit
883f93cc8c
@ -33,9 +33,8 @@ class BrownMushroom extends Flowable{
|
|||||||
|
|
||||||
public function onUpdate($type){
|
public function onUpdate($type){
|
||||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||||
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
|
if($this->getSide(0)->isTransparent === true){
|
||||||
$this->getLevel()->dropItem($this, Item::get($this->id));
|
$this->getLevel()->useBreakOn($this);
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ abstract class Fallable extends Solid{
|
|||||||
$fall = new FallingBlock($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
$fall = new FallingBlock($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
||||||
"Pos" => new Enum("Pos", [
|
"Pos" => new Enum("Pos", [
|
||||||
new Double("", $this->x + 0.5),
|
new Double("", $this->x + 0.5),
|
||||||
new Double("", $this->y + 0.5),
|
new Double("", $this->y),
|
||||||
new Double("", $this->z + 0.5)
|
new Double("", $this->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new Enum("Motion", [
|
||||||
|
@ -129,13 +129,7 @@ class Leaves extends Transparent{
|
|||||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||||
$this->getLevel()->setBlock($this, $this, false, false);
|
$this->getLevel()->setBlock($this, $this, false, false);
|
||||||
}else{
|
}else{
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false);
|
$this->getLevel()->useBreakOn($this);
|
||||||
if(mt_rand(1, 20) === 1){ //Saplings
|
|
||||||
$this->getLevel()->dropItem($this, Item::get($this->id, $this->meta & 0x03, 1));
|
|
||||||
}
|
|
||||||
if(($this->meta & 0x03) === self::OAK and mt_rand(1, 200) === 1){ //Apples
|
|
||||||
$this->getLevel()->dropItem($this, Item::get(Item::APPLE, 0, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -121,10 +121,7 @@ class Leaves2 extends Leaves{
|
|||||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||||
$this->getLevel()->setBlock($this, $this, false, false);
|
$this->getLevel()->setBlock($this, $this, false, false);
|
||||||
}else{
|
}else{
|
||||||
$this->getLevel()->setBlock($this, new Air(), false, false, true);
|
$this->getLevel()->useBreakOn($this);
|
||||||
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 Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class TNT extends Solid{
|
|||||||
$tnt = new PrimedTNT($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
$tnt = new PrimedTNT($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
|
||||||
"Pos" => new Enum("Pos", [
|
"Pos" => new Enum("Pos", [
|
||||||
new Double("", $this->x + 0.5),
|
new Double("", $this->x + 0.5),
|
||||||
new Double("", $this->y + 0.5),
|
new Double("", $this->y),
|
||||||
new Double("", $this->z + 0.5)
|
new Double("", $this->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new Enum("Motion", [
|
||||||
|
@ -49,9 +49,8 @@ class Torch extends Flowable{
|
|||||||
0 => 0,
|
0 => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === self::FENCE)){ //Replace with common break method
|
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === self::FENCE)){
|
||||||
$this->getLevel()->setBlock($this, new Air(), true);
|
$this->getLevel()->useBreakOn($this);
|
||||||
$this->getLevel()->dropItem($this->add(0.5, 0.5, 0.5), Item::get(Item::TORCH));
|
|
||||||
|
|
||||||
return Level::BLOCK_UPDATE_NORMAL;
|
return Level::BLOCK_UPDATE_NORMAL;
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,9 @@ class SpawnEgg extends Item{
|
|||||||
|
|
||||||
$nbt = new Compound("", [
|
$nbt = new Compound("", [
|
||||||
"Pos" => new Enum("Pos", [
|
"Pos" => new Enum("Pos", [
|
||||||
new Double("", $block->getX()),
|
new Double("", $block->getX() + 0.5),
|
||||||
new Double("", $block->getY()),
|
new Double("", $block->getY()),
|
||||||
new Double("", $block->getZ())
|
new Double("", $block->getZ() + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new Enum("Motion", [
|
||||||
new Double("", 0),
|
new Double("", 0),
|
||||||
|
@ -188,7 +188,7 @@ class Explosion{
|
|||||||
$tnt = new PrimedTNT($this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", [
|
$tnt = new PrimedTNT($this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", [
|
||||||
"Pos" => new Enum("Pos", [
|
"Pos" => new Enum("Pos", [
|
||||||
new Double("", $block->x + 0.5),
|
new Double("", $block->x + 0.5),
|
||||||
new Double("", $block->y + 0.5),
|
new Double("", $block->y),
|
||||||
new Double("", $block->z + 0.5)
|
new Double("", $block->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new Enum("Motion", [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user