fix: расинхрон data

- Добавлена настройка порта сокет сервера
- Добавлена возможность отключать сокет сервер
- Исправлено открытие верстака
- Исправлено id ведра воды
- Изменена дефолтная версия inner core с 152 на 153
This commit is contained in:
Reider745
2023-12-29 10:14:51 +03:00
parent 951b953f4c
commit 025e5803f5
12 changed files with 74 additions and 25 deletions
@@ -4,6 +4,19 @@ Callback.addCallback("CoreConfigured", function(config) {
isLegacyWorkbenchEnabled = config.getBool("gameplay.use_legacy_workbench_override");
});
function open(player, x, y, z){
var position = Entity.getPosition(player);
var distanceSqr = Math.pow(position[0] - (x + .5), 2) + Math.pow(position[1] - (y + .5), 2) + Math.pow(position[2] - (z + .5), 2);
if (distanceSqr < 15 * 15) {
var blockSource = BlockSource.getDefaultForActor(player);
if (blockSource != null && blockSource.getBlockId(x || 0, y || 0, z || 0) === 58) {
var client = Network.getClientForPlayer(player);
WorkbenchHandler.openFor(client);
WorkbenchHandler.handleRebuildRecipeRequest(client);
}
}
}
/**
* Network workbench implementation
*/
@@ -15,15 +28,7 @@ var WorkbenchHandler = {
setupPacketListeners: function() {
Network.addServerPacket("sys.workbench.open", function(client, coords) {
var position = Entity.getPosition(client.getPlayerUid());
var distanceSqr = Math.pow(position[0] - (coords.x + .5), 2) + Math.pow(position[1] - (coords.y + .5), 2) + Math.pow(position[2] - (coords.z + .5), 2);
if (distanceSqr < 15 * 15) {
var blockSource = BlockSource.getDefaultForActor(client.getPlayerUid());
if (blockSource != null && blockSource.getBlockId(coords.x || 0, coords.y || 0, coords.z || 0) === 58) {
WorkbenchHandler.openFor(client);
WorkbenchHandler.handleRebuildRecipeRequest(client);
}
}
});
},
@@ -140,18 +145,21 @@ var WorkbenchHandler = {
WorkbenchHandler.setupContainerClientSide();
WorkbenchHandler.setupPacketListeners();
Callback.addCallback("ItemUseLocalServer", function (coords, item, block, isExternal, player) {
/*Callback.addCallback("ItemUseLocalServer", function (coords, item, block, isExternal, player) {
if (isLegacyWorkbenchEnabled && block.id === 58) {
if (!Entity.isSneaking(player)) {
preventDefault();
Network.sendToServer("sys.workbench.open", {x: coords.x, y: coords.y, z: coords.z});
}
}
});
});*/
Callback.addCallback("ItemUse", function (coords, item, block, isExternal, player) {
if (isLegacyWorkbenchEnabled && block.id === 58 && !Entity.isSneaking(player)) {
if (isLegacyWorkbenchEnabled && block.id === 58) {
preventDefault();
if(!Entity.isSneaking(player)){
open(Number(player), coords.x, coords.y, coords.z)
}
}
});
+15 -1
View File
@@ -10,7 +10,7 @@ pack-version-code: 152
# Use vanilla crafting table interface, instead of custom one.
# Attention: currently not supported and custom recipes will not be dislayed.
# use-legacy-workbench-override: off
# use-legacy-workbench-override: on
# Disabling inventory fix for connected clients, outdated versions do not
# work properly with it, not allowing moving items around inventory.
@@ -28,3 +28,17 @@ pack-version-code: 152
# Developer mode allows you to receive additional information
# about engine operation, as well as profiling of methods.
# developer-mode: on
# Период сохранения данных inner core
# auto-save-period: 60
# Обновлять вместе с сохранениями inner core сохранения мира
# auto-save-world: on
# Состояние сокет сервера
# Для сокета сервера требуется дополнительный порт, подключение через сокет серверы более стабильное
# socket-server-enable: on
# Порт сокет сервера
# socket-port: 2304