fixed: dead lock redstone

This commit is contained in:
Reider745
2025-07-07 11:09:37 +03:00
parent f56246e21f
commit f715d9843c
2 changed files with 12 additions and 5 deletions
@@ -11,6 +11,7 @@ import cn.nukkit.level.Level;
import cn.nukkit.math.BlockFace;
import com.reider745.api.CustomManager;
import com.reider745.api.ReflectHelper;
import com.reider745.hooks.ServerHooks;
import com.reider745.hooks.block.BlockPalette;
import com.zhekasmirnov.innercore.api.NativeCallback;
import com.zhekasmirnov.innercore.api.NativeItem;
@@ -344,10 +345,7 @@ public class CustomBlock extends BlockSolidMeta implements RandomTick {
this.level);
return type;
} else if (type == Level.BLOCK_UPDATE_REDSTONE || type == Level.BLOCK_UPDATE_NORMAL) {
RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
getLevel().getServer().getPluginManager().callEvent(ev);
if (ev.isCancelled())
return type;
ServerHooks.postApply.add(new RedstoneUpdateEvent(this));
return type;
}
return type;
@@ -3,6 +3,7 @@ package com.reider745.hooks;
import cn.nukkit.Server;
import cn.nukkit.command.CommandSender;
import cn.nukkit.command.defaults.VersionCommand;
import cn.nukkit.event.Event;
import cn.nukkit.network.protocol.ProtocolInfo;
import cn.nukkit.plugin.JavaPluginLoader;
import cn.nukkit.plugin.PluginClassLoader;
@@ -20,10 +21,14 @@ import com.zhekasmirnov.horizon.runtime.logger.Logger;
import com.zhekasmirnov.innercore.api.NativeCallback;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@Hooks(className = "cn.nukkit.Server")
public class ServerHooks {
public static InnerCoreServer innerCoreServer = new InnerCoreServer();
public static final List<Event> postApply = new CopyOnWriteArrayList<>();
@Inject
public static void start(Server self) throws Exception {
@@ -103,11 +108,15 @@ public class ServerHooks {
EntityMotion.tick();
NativeCallback.onTick();
for(Event event : postApply) {
Server.getInstance().getPluginManager().callEvent(event);
}
TpsCommand.innerCoreTimes[indexTime] = System.currentTimeMillis() - start;
EventListener.isFirstTickEnd = true;
} catch (Exception e) {
Logger.warning("IC-TICK", e.getCause());
Logger.warning("IC-TICK", e);
}
}catch (Throwable e){
Logger.warning("IC-TICK", e);