Skip to content

Commit cfa2e3f

Browse files
committed
Fixed world join event
1 parent 9b8a9a9 commit cfa2e3f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

common/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.InventoryEvent;
22+
import com.lambda.event.events.WorldEvent;
2223
import net.minecraft.client.network.ClientPlayNetworkHandler;
24+
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
2325
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
2426
import net.minecraft.network.packet.s2c.play.UpdateSelectedSlotS2CPacket;
2527
import org.spongepowered.asm.mixin.Mixin;
@@ -29,6 +31,11 @@
2931

3032
@Mixin(ClientPlayNetworkHandler.class)
3133
public class ClientPlayNetworkHandlerMixin {
34+
@Inject(method = "onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;)V", at = @At("TAIL"))
35+
void injectJoinPacket(GameJoinS2CPacket packet, CallbackInfo ci) {
36+
EventFlow.post(new WorldEvent.Join());
37+
}
38+
3239
@Inject(method = "onUpdateSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/NetworkThreadUtils;forceMainThread(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;Lnet/minecraft/util/thread/ThreadExecutor;)V", shift = At.Shift.AFTER), cancellable = true)
3340
private void onUpdateSelectedSlot(UpdateSelectedSlotS2CPacket packet, CallbackInfo ci) {
3441
if (EventFlow.post(new InventoryEvent.HotbarSlot.Sync(packet.getSlot())).isCanceled()) ci.cancel();

common/src/main/java/com/lambda/mixin/world/ClientWorldMixin.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141

4242
@Mixin(ClientWorld.class)
4343
public class ClientWorldMixin {
44-
@Inject(method = "<init>(Lnet/minecraft/client/network/ClientPlayNetworkHandler;Lnet/minecraft/client/world/ClientWorld$Properties;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/registry/entry/RegistryEntry;IILjava/util/function/Supplier;Lnet/minecraft/client/render/WorldRenderer;ZJ)V", at = @At("TAIL"))
45-
void constructorMixin(ClientPlayNetworkHandler networkHandler, ClientWorld.Properties properties, RegistryKey registryRef, RegistryEntry dimensionTypeEntry, int loadDistance, int simulationDistance, Supplier profiler, WorldRenderer worldRenderer, boolean debugWorld, long seed, CallbackInfo ci) {
46-
EventFlow.post(new WorldEvent.Join());
47-
}
48-
4944
@Inject(method = "addEntity", at = @At("HEAD"), cancellable = true)
5045
private void onAddEntity(Entity entity, CallbackInfo ci) {
5146
if (EventFlow.post(new EntityEvent.EntitySpawn(entity)).isCanceled()) ci.cancel();

common/src/main/kotlin/com/lambda/event/events/WorldEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import net.minecraft.world.chunk.WorldChunk
3636
* occurrences in the game world.
3737
*/
3838
sealed class WorldEvent {
39-
// ToDo: Add doc
40-
// Represents the player joining the client world
39+
// ToDo: Add doc and determine if there's a better place for this event
40+
// Represents the player joining the world
4141
class Join() : Event
4242

4343
/**

0 commit comments

Comments
 (0)