mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
fixed cheking for space on item take
This commit is contained in:
parent
01b3e01db5
commit
ce695ba052
3 changed files with 24 additions and 5 deletions
|
|
@ -201,7 +201,7 @@ class BanAPI{
|
|||
$reason = $reason == "" ? "No reason" : $reason;
|
||||
|
||||
$this->server->schedule(60, [$player, "close"], "You have been kicked: " . $reason); //Forces a kick
|
||||
$player->lastCorrect = new Vector3($player->entity->x, $player->entity->y, $player->entity->z); //TODO better fix
|
||||
$player->lastCorrect = new Vector3($player->entity->x, $player->entity->y, $player->entity->z);
|
||||
$player->blocked = true;
|
||||
if($issuer instanceof Player){
|
||||
$this->server->api->chat->broadcast($player->username . " has been kicked by " . $issuer->username . ": $reason");
|
||||
|
|
|
|||
|
|
@ -696,12 +696,14 @@ class Player{
|
|||
while($count > 0){
|
||||
$add = 0;
|
||||
foreach($inv as $s => $item){
|
||||
console("{$item->getID()} {$item->getMetadata()} $type, $damage");
|
||||
if($item->getID() === AIR){
|
||||
$add = min($item->getMaxStackSize(), $count);
|
||||
$inv[$s] = BlockAPI::getItem($type, $damage, $add);
|
||||
break;
|
||||
}elseif($item->getID() === $type and $item->getMetadata() === $damage){
|
||||
$add = min($item->getMaxStackSize() - $item->count, $count);
|
||||
|
||||
if($add <= 0){
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1476,7 +1478,7 @@ class Player{
|
|||
if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch($packet->pid()){
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -2200,7 +2202,24 @@ class Player{
|
|||
break;
|
||||
}
|
||||
$packet->eid = $this->eid;
|
||||
$prevItem = $packet->item;
|
||||
$packet->item = $this->getSlot($this->slot);
|
||||
$sendOnDrop = false;
|
||||
|
||||
/*if($prevItem != $packet->item){
|
||||
if(count($this->inventory) >= 36){
|
||||
foreach($this->inventory as $slot => $item){
|
||||
if($item->getID() == 0) goto inv_desync_on_drop;
|
||||
}
|
||||
//crafting sends drop packet if inv is full, TODO: add it into craffting array
|
||||
goto inv_desync_on_drop;
|
||||
}else{
|
||||
inv_desync_on_drop:
|
||||
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
||||
$sendOnDrop = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
$this->craftingItems = [];
|
||||
$this->toCraft = [];
|
||||
$data["eid"] = $packet->eid;
|
||||
|
|
@ -2219,7 +2238,7 @@ class Player{
|
|||
$sY += ($this->entity->random->nextFloat() - $this->entity->random->nextFloat()) * 0.1;
|
||||
$sZ += sin($f3) * $f1;
|
||||
$this->server->api->entity->dropRawPos($this->level, $this->entity->x, $this->entity->y - 0.3 + $this->entity->height - 0.12, $this->entity->z, $packet->item, $sX, $sY, $sZ);
|
||||
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
|
||||
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), $sendOnDrop);
|
||||
}
|
||||
if($this->entity->inAction === true){
|
||||
$this->entity->inAction = false;
|
||||
|
|
|
|||
|
|
@ -416,11 +416,11 @@ class Entity extends Position
|
|||
foreach($this->server->api->entity->getRadius($this, 2, false) as $item){
|
||||
if($item->class === ENTITY_ITEM && !$item->closed && $item->spawntime > 0 && $item->delayBeforePickup <= 0){
|
||||
if($item->boundingBox->intersectsWith($myBB)){
|
||||
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->type, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", array(
|
||||
if((($this->player->gamemode & 0x01) === 1 || $this->player->hasSpace($item->itemID, $item->meta, $item->stack) === true) && $this->server->api->dhandle("player.pickup", array(
|
||||
"eid" => $this->player->eid,
|
||||
"player" => $this->player,
|
||||
"entity" => $item,
|
||||
"block" => $item->type,
|
||||
"block" => $item->itemID,
|
||||
"meta" => $item->meta,
|
||||
"target" => $item->eid
|
||||
)) !== false){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue