Do not send packet to player not logged in
This commit is contained in:
parent
1ef69325a4
commit
7cd2907ac1
|
@ -0,0 +1,24 @@
|
|||
package io.izzel.arclight.common.mixin.forge;
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Mixin(PacketDistributor.class)
|
||||
public class PacketDistributorMixin {
|
||||
|
||||
@Overwrite
|
||||
private Consumer<IPacket<?>> playerConsumer(Supplier<ServerPlayerEntity> entityPlayerMPSupplier) {
|
||||
return p -> {
|
||||
ServerPlayerEntity entity = entityPlayerMPSupplier.get();
|
||||
if (entity.connection != null && entity.connection.netManager != null) {
|
||||
entity.connection.netManager.sendPacket(p);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
"ForgeEventFactoryMixin",
|
||||
"ForgeHooksMixin",
|
||||
"ForgeInternalHandlerMixin",
|
||||
"NetworkHooksMixin"
|
||||
"NetworkHooksMixin",
|
||||
"PacketDistributorMixin"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user