From 46efebaf6758aac4c31bc57b99dd18372a0d80a2 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 23 Nov 2024 03:10:26 +0300 Subject: [PATCH] tweaked delay when picking up items, experimental hotbar is now disabled by default --- src/API/EntityAPI.php | 3 ++- src/Player.php | 3 ++- src/entity/object/ItemEntity.php | 2 +- src/material/block/plant/BeetrootBlock.php | 2 +- src/material/block/plant/CarrotBlock.php | 2 +- src/material/block/plant/PotatoBlock.php | 2 +- src/material/block/plant/WheatBlock.php | 2 +- src/material/block/solid/GrassBlock.php | 4 ++-- 8 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/API/EntityAPI.php b/src/API/EntityAPI.php index 7fc6a7df..26c09e96 100644 --- a/src/API/EntityAPI.php +++ b/src/API/EntityAPI.php @@ -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); } diff --git a/src/Player.php b/src/Player.php index d78b3567..0a860129 100755 --- a/src/Player.php +++ b/src/Player.php @@ -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; diff --git a/src/entity/object/ItemEntity.php b/src/entity/object/ItemEntity.php index 6e67ad9a..9af57bee 100644 --- a/src/entity/object/ItemEntity.php +++ b/src/entity/object/ItemEntity.php @@ -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; } diff --git a/src/material/block/plant/BeetrootBlock.php b/src/material/block/plant/BeetrootBlock.php index 7b820259..c1b51d73 100644 --- a/src/material/block/plant/BeetrootBlock.php +++ b/src/material/block/plant/BeetrootBlock.php @@ -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); } } diff --git a/src/material/block/plant/CarrotBlock.php b/src/material/block/plant/CarrotBlock.php index 4c2df687..498399f4 100644 --- a/src/material/block/plant/CarrotBlock.php +++ b/src/material/block/plant/CarrotBlock.php @@ -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); } } diff --git a/src/material/block/plant/PotatoBlock.php b/src/material/block/plant/PotatoBlock.php index ccb4542a..3ab969fe 100644 --- a/src/material/block/plant/PotatoBlock.php +++ b/src/material/block/plant/PotatoBlock.php @@ -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); } } diff --git a/src/material/block/plant/WheatBlock.php b/src/material/block/plant/WheatBlock.php index a78bdade..53bf67f4 100644 --- a/src/material/block/plant/WheatBlock.php +++ b/src/material/block/plant/WheatBlock.php @@ -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); } } diff --git a/src/material/block/solid/GrassBlock.php b/src/material/block/solid/GrassBlock.php index c258af29..f2850eba 100644 --- a/src/material/block/solid/GrassBlock.php +++ b/src/material/block/solid/GrassBlock.php @@ -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; } }