mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
farm -> dirt on player fall, how works better
This commit is contained in:
parent
1baafb8b26
commit
8e5d2bb1c7
8 changed files with 34 additions and 22 deletions
|
|
@ -156,7 +156,7 @@ abstract class Block extends Position{
|
|||
public $slipperiness;
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){}
|
||||
|
||||
public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){}
|
||||
public function __construct($id, $meta = 0, $name = "Unknown"){
|
||||
$this->id = (int) $id;
|
||||
$this->meta = (int) $meta;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ class StaticBlock
|
|||
}
|
||||
}
|
||||
|
||||
public static function getBlock($id){
|
||||
return nullsafe(Block::$class[$id], Block::$class[0]);
|
||||
}
|
||||
|
||||
public static function getBoundingBoxForBlockCoords($id, $x, $y, $z){
|
||||
/**@var AxisAlignedBB $bb*/
|
||||
$bb = nullsafe(self::$boundingBoxes[$id], false);
|
||||
|
|
|
|||
|
|
@ -16,6 +16,14 @@ class FarmlandBlock extends TransparentBlock{
|
|||
return $b->isTransparent && $b->id != 0;
|
||||
}
|
||||
|
||||
public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){
|
||||
$rv = lcg_value();
|
||||
console("rv: $rv, fd: ".($fallDistance - 0.5));
|
||||
if($rv < ($fallDistance - 0.5)){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
$meta = $level->level->getBlockDamage($x, $y, $z);
|
||||
$b = $level->level->getBlockID($x, $y + 1, $z);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class DirtBlock extends SolidBlock{
|
|||
if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
|
||||
else $player->setSlot($player->slot, $item, true);
|
||||
}
|
||||
$this->level->setBlock($this, BlockAPI::get(FARMLAND, 0), true, false, true);
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, FARMLAND, 0, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class GrassBlock extends SolidBlock{
|
|||
if($item->getMetadata() >= $item->getMaxDurability()) $player->setSlot($player->slot, new Item(AIR, 0, 0), false);
|
||||
else $player->setSlot($player->slot, $item, true);
|
||||
}
|
||||
$this->level->setBlock($this, new FarmlandBlock());
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, FARMLAND, 0, true);
|
||||
$this->seedsDrop();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue