diff --git a/build.gradle b/build.gradle index 69e227068..14deb1880 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ dependencies { // https://central.sonatype.com/artifact/com.google.code.gson/gson/versions implementation group: 'com.google.code.gson', name: 'gson', version: '2.7' // https://central.sonatype.com/artifact/org.mozilla/rhino/versions - implementation group: 'org.mozilla', name: 'rhino', version: '1.7.14' + implementation group: 'org.mozilla', name: 'rhino', version: '1.7.15' // https://central.sonatype.com/artifact/org.json/json/versions implementation group: 'org.json', name: 'json', version: '20231013' diff --git a/src/main/java/com/reider745/event/EventListener.java b/src/main/java/com/reider745/event/EventListener.java index 31b877fd2..9fd137b61 100644 --- a/src/main/java/com/reider745/event/EventListener.java +++ b/src/main/java/com/reider745/event/EventListener.java @@ -339,9 +339,8 @@ public void onBlockExplosion(BlockExplosionPrimeEvent event) {// TODO: deprecate } final Location pos = event.getBlock().getLocation(); - - - + consumeEvent(event, () -> NativeCallback.onExplode((float) pos.x, (float) pos.y, (float) pos.z, + (float) event.getForce(), -1, false, event.isBlockBreaking(), Float.MAX_VALUE)); } @EventHandler(priority = EventPriority.HIGHEST) @@ -411,9 +410,9 @@ public void onBlockUpdate(BlockGrowEvent event) { @EventHandler(priority = EventPriority.HIGHEST) public void onEntityTeleport(EntityTeleportEvent event) { final int from = FakeDimensions.getFakeIdForLevel(event.getFrom().level); - final int to = FakeDimensions.getFakeIdForLevel(event.getFrom().level); + final int to = FakeDimensions.getFakeIdForLevel(event.getTo().level); - if (CustomDimension.getDimensionById(to) != null || CustomDimension.getDimensionById(from) != null) + if(to != from) NativeCallback.onCustomDimensionTransfer(EntityMethod.getIdForEntity(event.getEntity()), from, to); } @@ -535,7 +534,4 @@ public void onPlayerFormResponded(PlayerFormRespondedEvent event) { // TODO: onItemUsedNoTarget (not only custom items) - // TODO: onItemUseReleased (not only custom items) - - // TODO: onItemUseComplete (not only custom items) } diff --git a/src/main/java/com/reider745/hooks/NetworkHooks.java b/src/main/java/com/reider745/hooks/NetworkHooks.java index 35d02a96a..fa3bd7c88 100644 --- a/src/main/java/com/reider745/hooks/NetworkHooks.java +++ b/src/main/java/com/reider745/hooks/NetworkHooks.java @@ -32,7 +32,7 @@ @Hooks(className = "cn.nukkit.network.Network") public class NetworkHooks implements HookClass { - private static LinkedList canSendInfo = new LinkedList<>(); + private static final LinkedList canSendInfo = new LinkedList<>(); public static void close(Player player){ canSendInfo.remove(NativeNetworking.getId(player)); @@ -94,8 +94,19 @@ public static void processBatch(Network network, byte[] payload, Collection listsToRefresh = new ArrayList<>(); + synchronized (allClientLists) { + Java8BackComp.removeIf(allClientLists, ref -> { + ConnectedClientList list = ref.get(); + if (list != null) { + listsToRefresh.add(list); + return false; + } + return true; + }); + } + + for (ConnectedClientList list : listsToRefresh) { + list.refresh(); + } + } + private static void clearOnShutdown() { synchronized (allClientLists) { allClientLists.clear(); diff --git a/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java b/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java index 181a55c37..a2bf301cb 100644 --- a/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java +++ b/src/main/java/com/zhekasmirnov/innercore/api/NativeCallback.java @@ -27,6 +27,7 @@ import com.zhekasmirnov.apparatus.multiplayer.ThreadTypeMarker; import com.zhekasmirnov.apparatus.multiplayer.server.ConnectedClient; import com.zhekasmirnov.apparatus.ecs.core.EntitySystem; +import com.zhekasmirnov.apparatus.multiplayer.util.list.ConnectedClientList; import com.zhekasmirnov.horizon.runtime.logger.Logger; import com.zhekasmirnov.innercore.api.commontypes.Coords; import com.zhekasmirnov.innercore.api.commontypes.FullBlock; @@ -369,6 +370,7 @@ public static void onTick() { Updatable.getForServer().onTick(); executor.blockUntilExecuted(); Updatable.getForServer().onPostTick(); + ConnectedClientList.onTick(); // run ecs serverTickingSystem.run(ECS.getEntityManager()); diff --git a/src/main/resources/innercore/coreengine/core-engine.dev.js b/src/main/resources/innercore/coreengine/core-engine.dev.js index 44f13f50c..f9cb800ae 100755 --- a/src/main/resources/innercore/coreengine/core-engine.dev.js +++ b/src/main/resources/innercore/coreengine/core-engine.dev.js @@ -780,13 +780,8 @@ var TileEntityBasePrototype = { return true; } } - } else { - var screen = this.getGuiScreen(); - if (screen) { - this.container.openAs(screen); - return true; - } } + return false; }, selfDestroy: function() { @@ -829,7 +824,7 @@ var TileEntity = { Prototype.saverId = Saver.registerObjectSaver(saverName, { read: function(obj) { if (!obj || !obj.coords) { - print("Corrupted data "+JSON.stringify(obj)); + print("Corrupted save "+JSON.stringify(obj)); return; } @@ -842,7 +837,14 @@ var TileEntity = { for (var property in Prototype) { instance[property] = Prototype[property]; } - instance.data = obj.data || {}; + instance.data = obj.data; + if(!instance.data){ + instance.data = {}; + for (let property in Prototype.defaultValues) { + instance.data[property] = Prototype.defaultValues[property]; + } + print("Corrupted save data "+JSON.stringify(obj)); + } instance.x = obj.coords.x || 0; instance.y = obj.coords.y || 0; instance.z = obj.coords.z || 0; @@ -1149,9 +1151,6 @@ var TileEntity = { tileEntity.noupdate = false; // tile entity must update at least once to initialize } tileEntity.onCheckerTick(tileEntity.__initialized, tileEntity.isLoaded, wasLoaded); - if (tileEntity.networkEntity) { - tileEntity.networkEntity.refreshClients(); - } if (tileEntity.isLoaded && tileEntity.blockSource) { var isPlaced = tileEntity.blockSource.getBlockId(tileEntity.x, tileEntity.y, tileEntity.z) === tileEntity.blockID; if (!isPlaced) { @@ -1198,9 +1197,7 @@ Callback.addCallback("tick", function() { }); Callback.addCallback("RedstoneSignal", function(coords, params, onLoad, region) { var tileEntity = TileEntity.getTileEntity(coords.x, coords.y, coords.z, region); - if (tileEntity) { - tileEntity.redstone(params); - } + tileEntity && tileEntity.__initialized && tileEntity.redstone(params); }); Callback.addCallback("BreakBlock", function(blockSource, coords, fullTile, isDropAllowed, player, item) { if (GameAPI.isActionPrevented()) {