mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
fee80da366
8 changed files with 78 additions and 9 deletions
|
|
@ -1523,6 +1523,7 @@ class Player{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function sendPing() {
|
||||
$pk = new PingPacket;
|
||||
$pk->time = intdiv(hrtime(true), 1_000_000);
|
||||
|
|
@ -3236,6 +3237,7 @@ class Player{
|
|||
}
|
||||
|
||||
|
||||
|
||||
if ($this->blocked === true or ($this->entity->position instanceof Vector3 and $blockVector->distance($this->entity->position) > 10)) {
|
||||
|
||||
} elseif ($this->getSlot($this->slot)->getID() !== $packet->item or ($this->getSlot($this->slot)->isTool() === false and $this->getSlot($this->slot)->getMetadata() !== $packet->meta)) {
|
||||
|
|
@ -6089,7 +6091,7 @@ class Player{
|
|||
$s = $this->getSlot($slot);
|
||||
if($s->count <= 0 or $s->getID() === AIR){
|
||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $item->count), false);
|
||||
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->maxStackSize){
|
||||
}else if($s->getID() == $item->getID() && $s->getMetadata() == $item->getMetadata() && ($s->count + $item->count) <= $s->getMaxStackSize()){
|
||||
$this->setSlot($slot, BlockAPI::getItem($item->getID(), $item->getMetadata(), $s->count + $item->count), false);
|
||||
}else{
|
||||
$f1 = 0.3;
|
||||
|
|
|
|||
|
|
@ -227,6 +227,7 @@ class PocketMinecraftServer{
|
|||
}, $this->asyncThread);
|
||||
}
|
||||
}
|
||||
release_lock();
|
||||
}
|
||||
|
||||
public function send2Discord($msg){
|
||||
|
|
|
|||
|
|
@ -71,6 +71,30 @@ if($errors > 0){
|
|||
exit(1); //Exit with error
|
||||
}
|
||||
|
||||
$lockFile = fopen(DATA_PATH . "server.lock", "a+b");
|
||||
if ($lockFile === false) {
|
||||
console("[ERROR] Unable to open server.lock file. Please check that the current user has read/write permissions to it.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
define("LOCK_FILE", $lockFile);
|
||||
|
||||
if (!flock(LOCK_FILE, LOCK_EX | LOCK_NB)) {
|
||||
//wait for a shared lock to avoid race conditions if two servers started at the same time - this makes sure the
|
||||
//other server wrote its PID and released exclusive lock before we get our lock
|
||||
flock(LOCK_FILE, LOCK_SH);
|
||||
$pid = stream_get_contents(LOCK_FILE);
|
||||
|
||||
echo "[CRITICAL] Another NostalgiaCore instance (PID $pid) is already using this folder (" . DATA_PATH . ")." . PHP_EOL;
|
||||
echo "[CRITICAL] Please stop the other server first before running a new one." . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ftruncate(LOCK_FILE, 0);
|
||||
fwrite(LOCK_FILE, (string) getmypid());
|
||||
fflush(LOCK_FILE);
|
||||
flock(LOCK_FILE, LOCK_SH); //prevent acquiring an exclusive lock from another process, but allow reading
|
||||
|
||||
$sha1sum = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
/***REM_START***/
|
||||
require_once(FILE_PATH . "/src/math/Vector3.php");
|
||||
|
|
|
|||
|
|
@ -254,3 +254,16 @@ function logg($message, $name, $EOL = true, $level = 2, $close = false){
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function release_lock(){
|
||||
if(LOCK_FILE !== null){
|
||||
if(!flock(LOCK_FILE, LOCK_UN)){
|
||||
console("[CRITICAL] Failed to release the server.lock file.");
|
||||
}
|
||||
if(!fclose(LOCK_FILE)){
|
||||
console("[CRITICAL] Could not close server.lock resource.");
|
||||
}
|
||||
} else {
|
||||
console("[CRITICAL] Failed to find the server.lock file.");
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ name_your_server=命名您的服务器:
|
|||
port_warning=尽量不要改变端口如果这是您第一次设置服务器.
|
||||
server_port=服务器端口:
|
||||
invalid_port=不正确的服务器端口.
|
||||
ram_warning=RAM是NostalgiaCore可用的最大内存. 推荐范围: 128-256 MB
|
||||
ram_warning=您需要设置NostalgiaCore的最大可用内存. 推荐范围: 128-256 MB
|
||||
server_ram=分配给服务器的内存(MB):
|
||||
gamemode_info=选择模式: (1)生存模式 或 (2)创造模式
|
||||
default_gamemode=默认游戏模式
|
||||
|
|
@ -23,7 +23,7 @@ spawn_protection=启用出生点保护?
|
|||
|
||||
op_info=OP是一个服务器的管理员, 可以执行比普通玩家更多的命令.
|
||||
op_who=OP的用户名是什么?
|
||||
op_warning=你可以执行\"/op <用户名>\"来添加OP.
|
||||
op_warning=你可以执行"/op <用户名>"来添加OP.
|
||||
whitelist_info=白名单可以只允许在其列表内的玩家加入.
|
||||
whitelist_enable=您想启用白名单吗?
|
||||
whitelist_warning=你可以用"/whitelist add <用户名>"把别人加入白名单.
|
||||
|
|
@ -39,8 +39,8 @@ usage_info=匿名数据让我们可以获得全球的NostalgiaCore和它的插
|
|||
usage_disable=您希望禁用匿名数据吗?
|
||||
ip_get=获得你的外部IP和内部IP
|
||||
ip_warning=您的外部IP是 {{EXTERNAL_IP}} . 您可能需要端口转发到您的内网IP {{INTERNAL_IP}} .
|
||||
ip_confirm=请确认您检查了它, 如果您直接进入下一步并跳过这一步, 没有外部的玩家可以加入. [按\"回车\"键]
|
||||
ip_confirm=请确认您检查了它, 如果您直接进入下一步并跳过这一步, 没有外部的玩家可以加入. [按"回车"键]
|
||||
|
||||
you_have_finished=您已经成功完成了服务器设置向导.
|
||||
pocketmine_will_start=NostalgiaCore现在开始运行. 输入 \"/help\" 来看所有可用的命令.
|
||||
pocketmine_will_start=NostalgiaCore现在开始运行. 输入 "/help" 来看所有可用的命令.
|
||||
pocketmine_plugins=请查看插件源来添加新的功能, 迷你游戏或者对服务器的高级保护.
|
||||
|
|
|
|||
|
|
@ -133,6 +133,10 @@ class Item{
|
|||
public $id;
|
||||
public $meta;
|
||||
public $count;
|
||||
/**
|
||||
* @var int
|
||||
* Max stack size of the item. Use Item::getMaxStackSize to get stack size for specific item.
|
||||
*/
|
||||
public $maxStackSize = 64;
|
||||
public $durability = 0;
|
||||
public $name;
|
||||
|
|
|
|||
|
|
@ -10,20 +10,31 @@ class BucketItem extends Item{
|
|||
public function __construct($meta = 0, $count = 1){
|
||||
parent::__construct(BUCKET, $meta, $count, "Bucket");
|
||||
$this->isActivable = true;
|
||||
$this->maxStackSize = 1;
|
||||
$this->maxStackSize = 16;
|
||||
$this->name = BucketItem::$possiblenames[$this->meta];
|
||||
}
|
||||
|
||||
public function getMaxStackSize(){
|
||||
if($this->getMetadata() == 0) return 16;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if($this->meta === AIR){
|
||||
if($target instanceof LiquidBlock && $target->getMetadata() == 0){
|
||||
$level->setBlock($target, new AirBlock(), true, false, true);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = match($target->getID()){
|
||||
$meta = match($target->getID()){
|
||||
WATER, STILL_WATER => WATER,
|
||||
LAVA, STILL_LAVA => LAVA,
|
||||
default => 0
|
||||
};
|
||||
if($this->count <= 1){
|
||||
$this->meta = $meta;
|
||||
}else{
|
||||
--$this->count;
|
||||
$player->addItem(BUCKET, $meta, 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -33,7 +44,12 @@ class BucketItem extends Item{
|
|||
$level->setBlock($block, $water, true, false, true);
|
||||
//$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
if($this->count <= 1){
|
||||
$this->meta = 0;
|
||||
}else{
|
||||
--$this->count;
|
||||
$player->addItem(BUCKET, $meta, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -43,7 +59,12 @@ class BucketItem extends Item{
|
|||
$level->setBlock($block, $lava, true, false, true);
|
||||
//$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
if(($player->gamemode & 0x01) === 0){
|
||||
$this->meta = 0;
|
||||
if($this->count <= 1){
|
||||
$this->meta = 0;
|
||||
}else{
|
||||
--$this->count;
|
||||
$player->addItem(BUCKET, $meta, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue