Improved item drop spawning

This commit is contained in:
Shoghi Cervantes 2014-10-13 22:45:04 +02:00
parent b26ee09f76
commit 883f93cc8c
8 changed files with 11 additions and 22 deletions

View File

@ -33,9 +33,8 @@ class BrownMushroom extends Flowable{
public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->getLevel()->dropItem($this, Item::get($this->id));
$this->getLevel()->setBlock($this, new Air(), false, false, true);
if($this->getSide(0)->isTransparent === true){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}

View File

@ -48,7 +48,7 @@ abstract class Fallable extends Solid{
$fall = new FallingBlock($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
"Pos" => new Enum("Pos", [
new Double("", $this->x + 0.5),
new Double("", $this->y + 0.5),
new Double("", $this->y),
new Double("", $this->z + 0.5)
]),
"Motion" => new Enum("Motion", [

View File

@ -129,13 +129,7 @@ class Leaves extends Transparent{
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
$this->getLevel()->setBlock($this, $this, false, false);
}else{
$this->getLevel()->setBlock($this, new Air(), false, false);
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));
}
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}

View File

@ -121,10 +121,7 @@ class Leaves2 extends Leaves{
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
$this->getLevel()->setBlock($this, $this, false, false);
}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));
}
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}

View File

@ -47,7 +47,7 @@ class TNT extends Solid{
$tnt = new PrimedTNT($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [
"Pos" => new Enum("Pos", [
new Double("", $this->x + 0.5),
new Double("", $this->y + 0.5),
new Double("", $this->y),
new Double("", $this->z + 0.5)
]),
"Motion" => new Enum("Motion", [

View File

@ -49,9 +49,8 @@ class Torch extends Flowable{
0 => 0,
];
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === self::FENCE)){ //Replace with common break method
$this->getLevel()->setBlock($this, new Air(), true);
$this->getLevel()->dropItem($this->add(0.5, 0.5, 0.5), Item::get(Item::TORCH));
if($this->getSide($faces[$side])->isTransparent === true and !($side === 0 and $this->getSide(0)->getID() === self::FENCE)){
$this->getLevel()->useBreakOn($this);
return Level::BLOCK_UPDATE_NORMAL;
}

View File

@ -51,9 +51,9 @@ class SpawnEgg extends Item{
$nbt = new Compound("", [
"Pos" => new Enum("Pos", [
new Double("", $block->getX()),
new Double("", $block->getX() + 0.5),
new Double("", $block->getY()),
new Double("", $block->getZ())
new Double("", $block->getZ() + 0.5)
]),
"Motion" => new Enum("Motion", [
new Double("", 0),

View File

@ -188,7 +188,7 @@ class Explosion{
$tnt = new PrimedTNT($this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", [
"Pos" => new Enum("Pos", [
new Double("", $block->x + 0.5),
new Double("", $block->y + 0.5),
new Double("", $block->y),
new Double("", $block->z + 0.5)
]),
"Motion" => new Enum("Motion", [