tweaked delay when picking up items, experimental hotbar is now disabled by default

This commit is contained in:
GameHerobrine 2024-11-23 03:10:26 +03:00
parent a4a5f1dfdf
commit 46efebaf67
8 changed files with 11 additions and 9 deletions

View file

@ -275,7 +275,7 @@ class EntityAPI{
}
}
public function drop(Position $pos, Item $item){
public function drop(Position $pos, Item $item, $pickupDelay = 10){
if($item->getID() === AIR or $item->count <= 0){
return;
}
@ -295,6 +295,7 @@ class EntityAPI{
$item->count = min($item->getMaxStackSize(), $count);
$count -= $item->count;
$e = $this->add($pos->level, ENTITY_ITEM, ENTITY_ITEM_TYPE, $data);
$e->delayBeforePickup = $pickupDelay;
$this->spawnToAll($e);
$this->server->api->handle("entity.motion", $e);
}

View file

@ -3,7 +3,7 @@
class Player{
public static $smallChunks = false, $experimentalHotbar = true;
public static $smallChunks = false, $experimentalHotbar = false;
/** @var Config */
public $data;
/** @var Entity */
@ -2545,6 +2545,7 @@ class Player{
}
$this->addItem($slot->getID(), $slot->getMetadata(), $slot->count, false);
}
$tile->setSlot(0, BlockAPI::getItem(0, 0, 1));
$tile->setSlot($packet->slot, $item);
}
break;

View file

@ -24,7 +24,7 @@ class ItemEntity extends Entity{
$this->hasGravity = true;
$this->setHealth(5, "generic");
$this->gravity = 0.04;
$this->delayBeforePickup = 20;
$this->delayBeforePickup = 40; //in vanilla it is 0 by default
$this->stepHeight = 0;
}

View file

@ -42,7 +42,7 @@ class BeetrootBlock extends FlowableBlock{
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(BEETROOT_SEEDS, 0, 1));
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(BEETROOT_SEEDS, 0, 1), 10);
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
}
}

View file

@ -44,7 +44,7 @@ class CarrotBlock extends FlowableBlock{
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CARROT, 0, 1));
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(CARROT, 0, 1), 10);
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
}
}

View file

@ -44,7 +44,7 @@ class PotatoBlock extends FlowableBlock{
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(POTATO, 0, 1));
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(POTATO, 0, 1), 10);
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
}
}

View file

@ -44,7 +44,7 @@ class WheatBlock extends FlowableBlock{
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if($level->level->getBlockID($x, $y - 1, $z) != FARMLAND){
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(WHEAT_SEEDS, 0, 1));
ServerAPI::request()->api->entity->drop(new Position($x + 0.5, $y, $z + 0.5, $level), BlockAPI::getItem(WHEAT_SEEDS, 0, 1), 10);
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
}
}

View file

@ -38,11 +38,11 @@ class GrassBlock extends SolidBlock{
public function seedsDrop(){
$chance = lcg_value() * 100;
if($chance <= 1){
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(458,0,1));
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS,0,1), 10);
return;
}
elseif($chance > 1 and $chance <= 16){
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(295,0,1));
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(SEEDS,0,1), 10);
return;
}
}