mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 20:49:43 +00:00
force send inv after crafting, fixed crafting with full inv
This commit is contained in:
parent
ce695ba052
commit
cd61a9e648
1 changed files with 26 additions and 6 deletions
|
|
@ -696,7 +696,6 @@ class Player{
|
||||||
while($count > 0){
|
while($count > 0){
|
||||||
$add = 0;
|
$add = 0;
|
||||||
foreach($inv as $s => $item){
|
foreach($inv as $s => $item){
|
||||||
console("{$item->getID()} {$item->getMetadata()} $type, $damage");
|
|
||||||
if($item->getID() === AIR){
|
if($item->getID() === AIR){
|
||||||
$add = min($item->getMaxStackSize(), $count);
|
$add = min($item->getMaxStackSize(), $count);
|
||||||
$inv[$s] = BlockAPI::getItem($type, $damage, $add);
|
$inv[$s] = BlockAPI::getItem($type, $damage, $add);
|
||||||
|
|
@ -1479,6 +1478,8 @@ class Player{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch($packet->pid()){
|
switch($packet->pid()){
|
||||||
case 0x01:
|
case 0x01:
|
||||||
break;
|
break;
|
||||||
|
|
@ -2206,19 +2207,21 @@ class Player{
|
||||||
$packet->item = $this->getSlot($this->slot);
|
$packet->item = $this->getSlot($this->slot);
|
||||||
$sendOnDrop = false;
|
$sendOnDrop = false;
|
||||||
|
|
||||||
/*if($prevItem != $packet->item){
|
if($prevItem->getID() != $packet->item->getID() || $prevItem->getMetadata() != $packet->item->getMetadata()){
|
||||||
if(count($this->inventory) >= 36){
|
if(count($this->inventory) >= 36){
|
||||||
foreach($this->inventory as $slot => $item){
|
foreach($this->inventory as $slot => $item){
|
||||||
if($item->getID() == 0) goto inv_desync_on_drop;
|
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;
|
$this->toCraft[] = $prevItem; //vanilla drops only result?
|
||||||
|
$this->lastCraft = microtime(true);
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
inv_desync_on_drop:
|
inv_desync_on_drop:
|
||||||
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
ConsoleAPI::debug("Inventory desync on drop({$this->iusername})");
|
||||||
$sendOnDrop = true;
|
$sendOnDrop = true;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
$this->craftingItems = [];
|
$this->craftingItems = [];
|
||||||
$this->toCraft = [];
|
$this->toCraft = [];
|
||||||
|
|
@ -2239,6 +2242,8 @@ class Player{
|
||||||
$sZ += sin($f3) * $f1;
|
$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->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), $sendOnDrop);
|
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), $sendOnDrop);
|
||||||
|
}else{
|
||||||
|
$this->sendInventory(); //send if blocked
|
||||||
}
|
}
|
||||||
if($this->entity->inAction === true){
|
if($this->entity->inAction === true){
|
||||||
$this->entity->inAction = false;
|
$this->entity->inAction = false;
|
||||||
|
|
@ -2647,9 +2652,24 @@ class Player{
|
||||||
$s = $this->getSlot($slot);
|
$s = $this->getSlot($slot);
|
||||||
if($s->count <= 0 or $s->getID() === AIR){
|
if($s->count <= 0 or $s->getID() === AIR){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
||||||
}else{
|
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->maxStackSize){
|
||||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
||||||
|
}else{
|
||||||
|
$f1 = 0.3;
|
||||||
|
$sX = -sin(($this->entity->yaw / 180) * M_PI) * cos(($this->entity->pitch / 180) * M_PI) * $f1;
|
||||||
|
$sZ = cos(($this->entity->yaw / 180) * M_PI) * cos(($this->entity->pitch / 180) * M_PI) * $f1;
|
||||||
|
$sY = -sin(($this->entity->pitch / 180) * M_PI) * $f1 + 0.1;
|
||||||
|
$f1 = 0.02;
|
||||||
|
$f3 = $this->entity->random->nextFloat() * M_PI * 2.0;
|
||||||
|
$f1 *= $this->entity->random->nextFloat();
|
||||||
|
$sX += cos($f3) * $f1;
|
||||||
|
$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, $item, $sX, $sY, $sZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->sendInventory(); //force send on crafting
|
||||||
|
|
||||||
switch($item->getID()){
|
switch($item->getID()){
|
||||||
case WORKBENCH:
|
case WORKBENCH:
|
||||||
AchievementAPI::grantAchievement($this, "buildWorkBench");
|
AchievementAPI::grantAchievement($this, "buildWorkBench");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue