mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Split up events to individual interfaces. Make Chunk events use WorldChunk instead.
This commit is contained in:
parent
f708519af8
commit
3431c0d894
12 changed files with 117 additions and 88 deletions
fabric-lifecycle-events-v1/src/main/java/net/fabricmc/fabric
api
client/event/lifecycle/v1
event/lifecycle/v1
mixin/event/lifecycle
|
@ -18,7 +18,7 @@ package net.fabricmc.fabric.api.client.event.lifecycle.v1;
|
|||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -79,10 +79,10 @@ public final class ClientChunkEvents {
|
|||
});
|
||||
|
||||
public interface Load {
|
||||
void onChunkLoad(ClientWorld world, Chunk chunk);
|
||||
void onChunkLoad(ClientWorld world, WorldChunk chunk);
|
||||
}
|
||||
|
||||
public interface Unload {
|
||||
void onChunkUnload(ClientWorld world, Chunk chunk);
|
||||
void onChunkUnload(ClientWorld world, WorldChunk chunk);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ public final class ClientLifecycleEvents {
|
|||
*
|
||||
* <p>This occurs while the splash screen is displayed.
|
||||
*/
|
||||
public static final Event<ClientLifecycleCallback> CLIENT_STARTED = EventFactory.createArrayBacked(ClientLifecycleCallback.class, callbacks -> client -> {
|
||||
for (ClientLifecycleCallback callback : callbacks) {
|
||||
callback.onChangeLifecycle(client);
|
||||
public static final Event<ClientStarted> CLIENT_STARTED = EventFactory.createArrayBacked(ClientStarted.class, callbacks -> client -> {
|
||||
for (ClientStarted callback : callbacks) {
|
||||
callback.onClientStarted(client);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -45,13 +45,17 @@ public final class ClientLifecycleEvents {
|
|||
*
|
||||
* <p>This will be called before the integrated server is stopped if it is running.
|
||||
*/
|
||||
public static final Event<ClientLifecycleCallback> CLIENT_STOPPING = EventFactory.createArrayBacked(ClientLifecycleCallback.class, callbacks -> client -> {
|
||||
for (ClientLifecycleCallback callback : callbacks) {
|
||||
callback.onChangeLifecycle(client);
|
||||
public static final Event<ClientStopping> CLIENT_STOPPING = EventFactory.createArrayBacked(ClientStopping.class, callbacks -> client -> {
|
||||
for (ClientStopping callback : callbacks) {
|
||||
callback.onClientStopping(client);
|
||||
}
|
||||
});
|
||||
|
||||
public interface ClientLifecycleCallback {
|
||||
void onChangeLifecycle(MinecraftClient client);
|
||||
public interface ClientStarted {
|
||||
void onClientStarted(MinecraftClient client);
|
||||
}
|
||||
|
||||
public interface ClientStopping {
|
||||
void onClientStopping(MinecraftClient client);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,21 +33,21 @@ public final class ClientTickEvents {
|
|||
/**
|
||||
* Called at the start of the client tick.
|
||||
*/
|
||||
public static final Event<ClientTickEvents.Client> START_CLIENT_TICK = EventFactory.createArrayBacked(ClientTickEvents.Client.class, callbacks -> client -> {
|
||||
public static final Event<StartTick> START_CLIENT_TICK = EventFactory.createArrayBacked(StartTick.class, callbacks -> client -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = client.getProfiler();
|
||||
profiler.push("fabricStartClientTick");
|
||||
|
||||
for (ClientTickEvents.Client event : callbacks) {
|
||||
for (StartTick event : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(event));
|
||||
event.onTick(client);
|
||||
event.onStartTick(client);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ClientTickEvents.Client event : callbacks) {
|
||||
event.onTick(client);
|
||||
for (StartTick event : callbacks) {
|
||||
event.onStartTick(client);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -55,21 +55,21 @@ public final class ClientTickEvents {
|
|||
/**
|
||||
* Called at the end of the client tick.
|
||||
*/
|
||||
public static final Event<ClientTickEvents.Client> END_CLIENT_TICK = EventFactory.createArrayBacked(ClientTickEvents.Client.class, callbacks -> client -> {
|
||||
public static final Event<EndTick> END_CLIENT_TICK = EventFactory.createArrayBacked(EndTick.class, callbacks -> client -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = client.getProfiler();
|
||||
profiler.push("fabricEndClientTick");
|
||||
|
||||
for (ClientTickEvents.Client event : callbacks) {
|
||||
for (EndTick event : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(event));
|
||||
event.onTick(client);
|
||||
event.onEndTick(client);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ClientTickEvents.Client event : callbacks) {
|
||||
event.onTick(client);
|
||||
for (EndTick event : callbacks) {
|
||||
event.onEndTick(client);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -77,21 +77,21 @@ public final class ClientTickEvents {
|
|||
/**
|
||||
* Called at the start of a ClientWorld's tick.
|
||||
*/
|
||||
public static final Event<ClientTickEvents.World> START_WORLD_TICK = EventFactory.createArrayBacked(ClientTickEvents.World.class, callbacks -> world -> {
|
||||
public static final Event<StartWorldTick> START_WORLD_TICK = EventFactory.createArrayBacked(StartWorldTick.class, callbacks -> world -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = world.getProfiler();
|
||||
profiler.push("fabricStartClientWorldTick");
|
||||
|
||||
for (ClientTickEvents.World callback : callbacks) {
|
||||
for (StartWorldTick callback : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(callback));
|
||||
callback.onTick(world);
|
||||
callback.onStartTick(world);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ClientTickEvents.World callback : callbacks) {
|
||||
callback.onTick(world);
|
||||
for (StartWorldTick callback : callbacks) {
|
||||
callback.onStartTick(world);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -101,30 +101,38 @@ public final class ClientTickEvents {
|
|||
*
|
||||
* <p>End of world tick may be used to start async computations for the next tick.
|
||||
*/
|
||||
public static final Event<ClientTickEvents.World> END_WORLD_TICK = EventFactory.createArrayBacked(ClientTickEvents.World.class, callbacks -> world -> {
|
||||
public static final Event<EndWorldTick> END_WORLD_TICK = EventFactory.createArrayBacked(EndWorldTick.class, callbacks -> world -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = world.getProfiler();
|
||||
profiler.push("fabricEndClientWorldTick");
|
||||
|
||||
for (ClientTickEvents.World callback : callbacks) {
|
||||
for (EndWorldTick callback : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(callback));
|
||||
callback.onTick(world);
|
||||
callback.onEndTick(world);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ClientTickEvents.World callback : callbacks) {
|
||||
callback.onTick(world);
|
||||
for (EndWorldTick callback : callbacks) {
|
||||
callback.onEndTick(world);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public interface Client {
|
||||
void onTick(MinecraftClient client);
|
||||
public interface StartTick {
|
||||
void onStartTick(MinecraftClient client);
|
||||
}
|
||||
|
||||
public interface World {
|
||||
void onTick(ClientWorld world);
|
||||
public interface EndTick {
|
||||
void onEndTick(MinecraftClient client);
|
||||
}
|
||||
|
||||
public interface StartWorldTick {
|
||||
void onStartTick(ClientWorld world);
|
||||
}
|
||||
|
||||
public interface EndWorldTick {
|
||||
void onEndTick(ClientWorld world);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package net.fabricmc.fabric.api.event.lifecycle.v1;
|
|||
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
|
@ -76,10 +76,10 @@ public final class ServerChunkEvents {
|
|||
});
|
||||
|
||||
public interface Load {
|
||||
void onChunkLoad(ServerWorld world, Chunk chunk);
|
||||
void onChunkLoad(ServerWorld world, WorldChunk chunk);
|
||||
}
|
||||
|
||||
public interface Unload {
|
||||
void onChunkUnload(ServerWorld world, Chunk chunk);
|
||||
void onChunkUnload(ServerWorld world, WorldChunk chunk);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ public final class ServerLifecycleEvents {
|
|||
*
|
||||
* <p>At this stage, all worlds are live.
|
||||
*/
|
||||
public static final Event<ServerLifecycleEvents.LifecycleCallback> SERVER_STARTED = EventFactory.createArrayBacked(ServerLifecycleEvents.LifecycleCallback.class, (callbacks) -> (server) -> {
|
||||
for (ServerLifecycleEvents.LifecycleCallback callback : callbacks) {
|
||||
callback.onChangeLifecycle(server);
|
||||
public static final Event<ServerStarted> SERVER_STARTED = EventFactory.createArrayBacked(ServerStarted.class, (callbacks) -> (server) -> {
|
||||
for (ServerStarted callback : callbacks) {
|
||||
callback.onServerStarted(server);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -44,9 +44,9 @@ public final class ServerLifecycleEvents {
|
|||
*
|
||||
* <p>All worlds are still present and can be modified.
|
||||
*/
|
||||
public static final Event<ServerLifecycleEvents.LifecycleCallback> SERVER_STOPPING = EventFactory.createArrayBacked(ServerLifecycleEvents.LifecycleCallback.class, (callbacks) -> (server) -> {
|
||||
for (ServerLifecycleEvents.LifecycleCallback callback : callbacks) {
|
||||
callback.onChangeLifecycle(server);
|
||||
public static final Event<ServerStopping> SERVER_STOPPING = EventFactory.createArrayBacked(ServerStopping.class, (callbacks) -> (server) -> {
|
||||
for (ServerStopping callback : callbacks) {
|
||||
callback.onServerStopping(server);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -57,13 +57,21 @@ public final class ServerLifecycleEvents {
|
|||
* <p>For example, an {@link net.fabricmc.api.EnvType#CLIENT integrated server} will begin stopping, but it's client may continue to run.
|
||||
* Meanwhile for a {@link net.fabricmc.api.EnvType#SERVER dedicated server}, this will be the last event called.
|
||||
*/
|
||||
public static final Event<ServerLifecycleEvents.LifecycleCallback> SERVER_STOPPED = EventFactory.createArrayBacked(ServerLifecycleEvents.LifecycleCallback.class, callbacks -> server -> {
|
||||
for (ServerLifecycleEvents.LifecycleCallback callback : callbacks) {
|
||||
callback.onChangeLifecycle(server);
|
||||
public static final Event<ServerStopped> SERVER_STOPPED = EventFactory.createArrayBacked(ServerStopped.class, callbacks -> server -> {
|
||||
for (ServerStopped callback : callbacks) {
|
||||
callback.onServerStopped(server);
|
||||
}
|
||||
});
|
||||
|
||||
public interface LifecycleCallback {
|
||||
void onChangeLifecycle(MinecraftServer server);
|
||||
public interface ServerStarted {
|
||||
void onServerStarted(MinecraftServer server);
|
||||
}
|
||||
|
||||
public interface ServerStopping {
|
||||
void onServerStopping(MinecraftServer server);
|
||||
}
|
||||
|
||||
public interface ServerStopped {
|
||||
void onServerStopped(MinecraftServer server);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,21 +30,21 @@ public final class ServerTickEvents {
|
|||
/**
|
||||
* Called at the start of the server tick.
|
||||
*/
|
||||
public static final Event<ServerTickEvents.Server> START_SERVER_TICK = EventFactory.createArrayBacked(ServerTickEvents.Server.class, callbacks -> server -> {
|
||||
public static final Event<StartTick> START_SERVER_TICK = EventFactory.createArrayBacked(StartTick.class, callbacks -> server -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = server.getProfiler();
|
||||
profiler.push("fabricStartServerTick");
|
||||
|
||||
for (ServerTickEvents.Server event : callbacks) {
|
||||
for (StartTick event : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(event));
|
||||
event.onTick(server);
|
||||
event.onStartTick(server);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ServerTickEvents.Server event : callbacks) {
|
||||
event.onTick(server);
|
||||
for (StartTick event : callbacks) {
|
||||
event.onStartTick(server);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -52,21 +52,21 @@ public final class ServerTickEvents {
|
|||
/**
|
||||
* Called at the end of the server tick.
|
||||
*/
|
||||
public static final Event<ServerTickEvents.Server> END_SERVER_TICK = EventFactory.createArrayBacked(ServerTickEvents.Server.class, callbacks -> server -> {
|
||||
public static final Event<EndTick> END_SERVER_TICK = EventFactory.createArrayBacked(EndTick.class, callbacks -> server -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = server.getProfiler();
|
||||
profiler.push("fabricEndServerTick");
|
||||
|
||||
for (ServerTickEvents.Server event : callbacks) {
|
||||
for (EndTick event : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(event));
|
||||
event.onTick(server);
|
||||
event.onEndTick(server);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ServerTickEvents.Server event : callbacks) {
|
||||
event.onTick(server);
|
||||
for (EndTick event : callbacks) {
|
||||
event.onEndTick(server);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -74,21 +74,21 @@ public final class ServerTickEvents {
|
|||
/**
|
||||
* Called at the start of a ServerWorld's tick.
|
||||
*/
|
||||
public static final Event<ServerTickEvents.World> START_WORLD_TICK = EventFactory.createArrayBacked(ServerTickEvents.World.class, callbacks -> world -> {
|
||||
public static final Event<StartWorldTick> START_WORLD_TICK = EventFactory.createArrayBacked(StartWorldTick.class, callbacks -> world -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = world.getProfiler();
|
||||
profiler.push("fabricStartServerWorldTick_" + world.dimension.getType().toString());
|
||||
|
||||
for (ServerTickEvents.World callback : callbacks) {
|
||||
for (StartWorldTick callback : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(callback));
|
||||
callback.onTick(world);
|
||||
callback.onStartTick(world);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ServerTickEvents.World callback : callbacks) {
|
||||
callback.onTick(world);
|
||||
for (StartWorldTick callback : callbacks) {
|
||||
callback.onStartTick(world);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -98,30 +98,38 @@ public final class ServerTickEvents {
|
|||
*
|
||||
* <p>End of world tick may be used to start async computations for the next tick.
|
||||
*/
|
||||
public static final Event<ServerTickEvents.World> END_WORLD_TICK = EventFactory.createArrayBacked(ServerTickEvents.World.class, callbacks -> world -> {
|
||||
public static final Event<EndWorldTick> END_WORLD_TICK = EventFactory.createArrayBacked(EndWorldTick.class, callbacks -> world -> {
|
||||
if (EventFactory.isProfilingEnabled()) {
|
||||
final Profiler profiler = world.getProfiler();
|
||||
profiler.push("fabricEndServerWorldTick_" + world.dimension.getType().toString());
|
||||
|
||||
for (ServerTickEvents.World callback : callbacks) {
|
||||
for (EndWorldTick callback : callbacks) {
|
||||
profiler.push(EventFactory.getHandlerName(callback));
|
||||
callback.onTick(world);
|
||||
callback.onEndTick(world);
|
||||
profiler.pop();
|
||||
}
|
||||
|
||||
profiler.pop();
|
||||
} else {
|
||||
for (ServerTickEvents.World callback : callbacks) {
|
||||
callback.onTick(world);
|
||||
for (EndWorldTick callback : callbacks) {
|
||||
callback.onEndTick(world);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public interface Server {
|
||||
void onTick(MinecraftServer server);
|
||||
public interface StartTick {
|
||||
void onStartTick(MinecraftServer server);
|
||||
}
|
||||
|
||||
public interface World {
|
||||
void onTick(ServerWorld world);
|
||||
public interface EndTick {
|
||||
void onEndTick(MinecraftServer server);
|
||||
}
|
||||
|
||||
public interface StartWorldTick {
|
||||
void onStartTick(ServerWorld world);
|
||||
}
|
||||
|
||||
public interface EndWorldTick {
|
||||
void onEndTick(ServerWorld world);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,27 +39,27 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
|||
public abstract class MinecraftServerMixin {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V", ordinal = 0), method = "run")
|
||||
private void afterSetupServer(CallbackInfo info) {
|
||||
ServerLifecycleEvents.SERVER_STARTED.invoker().onChangeLifecycle((MinecraftServer) (Object) this);
|
||||
ServerLifecycleEvents.SERVER_STARTED.invoker().onServerStarted((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "shutdown")
|
||||
private void beforeShutdownServer(CallbackInfo info) {
|
||||
ServerLifecycleEvents.SERVER_STOPPING.invoker().onChangeLifecycle((MinecraftServer) (Object) this);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.invoker().onServerStopping((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "shutdown")
|
||||
private void afterShutdownServer(CallbackInfo info) {
|
||||
ServerLifecycleEvents.SERVER_STOPPED.invoker().onChangeLifecycle((MinecraftServer) (Object) this);
|
||||
ServerLifecycleEvents.SERVER_STOPPED.invoker().onServerStopped((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V"), method = "tick")
|
||||
private void onStartTick(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {
|
||||
ServerTickEvents.START_SERVER_TICK.invoker().onTick((MinecraftServer) (Object) this);
|
||||
ServerTickEvents.START_SERVER_TICK.invoker().onStartTick((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "tick")
|
||||
private void onEndTick(BooleanSupplier shouldKeepTicking, CallbackInfo info) {
|
||||
ServerTickEvents.END_SERVER_TICK.invoker().onTick((MinecraftServer) (Object) this);
|
||||
ServerTickEvents.END_SERVER_TICK.invoker().onEndTick((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,6 +47,6 @@ public abstract class ServerWorldMixin {
|
|||
// Make sure "insideTick" is true before we call the start tick, so inject after it is set
|
||||
@Inject(method = "tick", at = @At(value = "FIELD", target = "Lnet/minecraft/server/world/ServerWorld;insideTick:Z", opcode = Opcodes.PUTFIELD, ordinal = 0, shift = At.Shift.AFTER))
|
||||
private void startWorldTick(BooleanSupplier shouldKeepTicking, CallbackInfo ci) {
|
||||
ServerTickEvents.START_WORLD_TICK.invoker().onTick((ServerWorld) (Object) this);
|
||||
ServerTickEvents.START_WORLD_TICK.invoker().onStartTick((ServerWorld) (Object) this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.server.world.ChunkHolder;
|
|||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||
|
||||
|
@ -48,7 +49,7 @@ public abstract class ThreadedAnvilChunkStorageMixin {
|
|||
*/
|
||||
@Inject(method = "method_18843", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/chunk/WorldChunk;setLoadedToWorld(Z)V", shift = At.Shift.AFTER))
|
||||
private void onChunkUnload(ChunkHolder chunkHolder, CompletableFuture<Chunk> chunkFuture, long pos, Chunk chunk, CallbackInfo ci) {
|
||||
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload(this.world, chunk);
|
||||
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload(this.world, (WorldChunk) chunk);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,6 +63,6 @@ public abstract class ThreadedAnvilChunkStorageMixin {
|
|||
@Inject(method = "method_17227", at = @At("TAIL"))
|
||||
private void onChunkLoad(ChunkHolder chunkHolder, Chunk protoChunk, CallbackInfoReturnable<Chunk> callbackInfoReturnable) {
|
||||
// We fire the event at TAIL since the chunk is guaranteed to be a WorldChunk then.
|
||||
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad(this.world, callbackInfoReturnable.getReturnValue());
|
||||
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad(this.world, (WorldChunk) callbackInfoReturnable.getReturnValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public abstract class WorldMixin {
|
|||
@Inject(at = @At("RETURN"), method = "tickBlockEntities")
|
||||
protected void tickWorldAfterBlockEntities(CallbackInfo ci) {
|
||||
if (!this.isClient()) {
|
||||
ServerTickEvents.END_WORLD_TICK.invoker().onTick((ServerWorld) (Object) this);
|
||||
ServerTickEvents.END_WORLD_TICK.invoker().onEndTick((ServerWorld) (Object) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ public abstract class ClientWorldMixin extends WorldMixin {
|
|||
// We override our injection on the clientworld so only the client world's tick invocations will run
|
||||
@Override
|
||||
protected void tickWorldAfterBlockEntities(CallbackInfo ci) {
|
||||
ClientTickEvents.END_WORLD_TICK.invoker().onTick((ClientWorld) (Object) this);
|
||||
ClientTickEvents.END_WORLD_TICK.invoker().onEndTick((ClientWorld) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "tickEntities", at = @At("HEAD"))
|
||||
private void startWorldTick(CallbackInfo ci) {
|
||||
ClientTickEvents.START_WORLD_TICK.invoker().onTick((ClientWorld) (Object) this);
|
||||
ClientTickEvents.START_WORLD_TICK.invoker().onStartTick((ClientWorld) (Object) this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,22 +33,22 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
|||
public abstract class MinecraftClientMixin {
|
||||
@Inject(at = @At("HEAD"), method = "tick")
|
||||
private void onStartTick(CallbackInfo info) {
|
||||
ClientTickEvents.START_CLIENT_TICK.invoker().onTick((MinecraftClient) (Object) this);
|
||||
ClientTickEvents.START_CLIENT_TICK.invoker().onStartTick((MinecraftClient) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "tick")
|
||||
private void onEndTick(CallbackInfo info) {
|
||||
ClientTickEvents.END_CLIENT_TICK.invoker().onTick((MinecraftClient) (Object) this);
|
||||
ClientTickEvents.END_CLIENT_TICK.invoker().onEndTick((MinecraftClient) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER), method = "stop")
|
||||
private void onStopping(CallbackInfo ci) {
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.invoker().onChangeLifecycle((MinecraftClient) (Object) this);
|
||||
ClientLifecycleEvents.CLIENT_STOPPING.invoker().onClientStopping((MinecraftClient) (Object) this);
|
||||
}
|
||||
|
||||
// We inject after the thread field is set so `ThreadExecutor#getThread` will work
|
||||
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;thread:Ljava/lang/Thread;", shift = At.Shift.AFTER), method = "run")
|
||||
private void onStart(CallbackInfo ci) {
|
||||
ClientLifecycleEvents.CLIENT_STARTED.invoker().onChangeLifecycle((MinecraftClient) (Object) this);
|
||||
ClientLifecycleEvents.CLIENT_STARTED.invoker().onClientStarted((MinecraftClient) (Object) this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue