fixed: call event for tick
This commit is contained in:
@@ -345,7 +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) {
|
||||
ServerHooks.postApply.add(new RedstoneUpdateEvent(this));
|
||||
ServerHooks.postApply.add(this);
|
||||
return type;
|
||||
}
|
||||
return type;
|
||||
|
||||
@@ -160,15 +160,19 @@ public class EventListener implements Listener {
|
||||
EntityMethod.getIdForEntity(event.getPlayer())));
|
||||
}
|
||||
|
||||
public static void onRedston(Block event) {
|
||||
Block block = event.getBlock();
|
||||
Level level = event.getBlock().getLevel();
|
||||
int signal = level.isBlockIndirectlyGettingPowered(block);
|
||||
|
||||
NativeCallback.onRedstoneSignalChange((int) block.x, (int) block.y, (int) block.z,
|
||||
signal, !event.getBlock().isPowerSource(), level);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onRedstoneUpdate(RedstoneUpdateEvent event) {
|
||||
if(isFirstTickEnd){
|
||||
Block block = event.getBlock();
|
||||
Level level = event.getBlock().getLevel();
|
||||
int signal = level.isBlockIndirectlyGettingPowered(block);
|
||||
|
||||
consumeEvent(event, () -> NativeCallback.onRedstoneSignalChange((int) block.x, (int) block.y, (int) block.z,
|
||||
signal, !event.getBlock().isPowerSource(), level));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.reider745.hooks;
|
||||
|
||||
import cn.nukkit.Server;
|
||||
import cn.nukkit.block.Block;
|
||||
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;
|
||||
@@ -28,7 +28,7 @@ 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<>();
|
||||
public static final List<Block> postApply = new CopyOnWriteArrayList<>();
|
||||
|
||||
@Inject
|
||||
public static void start(Server self) throws Exception {
|
||||
@@ -108,8 +108,8 @@ public class ServerHooks {
|
||||
EntityMotion.tick();
|
||||
NativeCallback.onTick();
|
||||
|
||||
for(Event event : postApply) {
|
||||
Server.getInstance().getPluginManager().callEvent(event);
|
||||
for(Block block : postApply) {
|
||||
EventListener.onRedston(block);
|
||||
}
|
||||
|
||||
TpsCommand.innerCoreTimes[indexTime] = System.currentTimeMillis() - start;
|
||||
|
||||
Reference in New Issue
Block a user