fabric-1.18: rename BlockEvents.EVENT -> BlockEvents.BLOCK_EVENT

This commit is contained in:
Kosma Moczek 2021-12-02 20:55:43 +01:00
parent ebdab5e706
commit ef31e6daa8
3 changed files with 4 additions and 3 deletions

View File

@ -753,7 +753,7 @@ public class DynmapPlugin {
ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> worldTracker.handleChunkLoad(world, chunk));
ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> worldTracker.handleChunkUnload(world, chunk));
ChunkDataEvents.SAVE.register((world, chunk) -> worldTracker.handleChunkDataSave(world, chunk));
BlockEvents.EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
BlockEvents.BLOCK_EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
}
// Prime the known full chunks
if (onchunkgenerate && (server.getWorlds() != null)) {

View File

@ -9,7 +9,7 @@ public class BlockEvents {
private BlockEvents() {
}
public static Event<BlockCallback> EVENT = EventFactory.createArrayBacked(BlockCallback.class,
public static Event<BlockCallback> BLOCK_EVENT = EventFactory.createArrayBacked(BlockCallback.class,
(listeners) -> (world, pos) -> {
for (BlockCallback callback : listeners) {
callback.onBlockEvent(world, pos);
@ -17,6 +17,7 @@ public class BlockEvents {
}
);
@FunctionalInterface
public interface BlockCallback {
void onBlockEvent(World world, BlockPos pos);
}

View File

@ -19,7 +19,7 @@ public abstract class WorldChunkMixin {
@Inject(method = "setBlockState", at = @At("RETURN"))
public void setBlockState(BlockPos pos, BlockState state, boolean moved, CallbackInfoReturnable<BlockState> info) {
if (info.getReturnValue() != null) {
BlockEvents.EVENT.invoker().onBlockEvent(this.getWorld(), pos);
BlockEvents.BLOCK_EVENT.invoker().onBlockEvent(this.getWorld(), pos);
}
}
}