use of org.spongepowered.common.bridge.client.MinecraftBridge in project SpongeCommon by SpongePowered.
the class MinecraftMixin_API method server.
@Override
public Optional<LocalServer> server() {
final MinecraftBridge minecraftBridge = (MinecraftBridge) (this);
final IntegratedServer integratedServer = minecraftBridge.bridge$getTemporaryIntegratedServer();
if (integratedServer != null) {
return (Optional<LocalServer>) (Object) Optional.ofNullable(integratedServer);
}
return (Optional<LocalServer>) (Object) Optional.ofNullable(this.shadow$getSingleplayerServer());
}
use of org.spongepowered.common.bridge.client.MinecraftBridge in project SpongeCommon by SpongePowered.
the class IntegratedServerMixin_Vanilla method vanilla$runEngineStartLifecycle.
@SuppressWarnings("ConstantConditions")
@Inject(method = "initServer", at = @At("HEAD"))
private void vanilla$runEngineStartLifecycle(final CallbackInfoReturnable<Boolean> cir) {
if (!Sponge.isServerAvailable()) {
((MinecraftBridge) Minecraft.getInstance()).bridge$setTemporaryIntegratedServer((IntegratedServer) (Object) this);
}
final Lifecycle lifecycle = Launch.instance().lifecycle();
lifecycle.establishServerServices();
lifecycle.establishServerFeatures();
lifecycle.establishServerRegistries(this);
lifecycle.callStartingEngineEvent(this);
}
use of org.spongepowered.common.bridge.client.MinecraftBridge in project SpongeCommon by SpongePowered.
the class SpongeChannelManager method handleLoginRequestPayload.
private boolean handleLoginRequestPayload(final EngineConnection connection, final ResourceKey channelKey, final int transactionId, final ChannelBuf payload) {
if (channelKey.equals(Constants.Channels.SPONGE_CLIENT_TYPE)) {
final ClientType clientType = ((MinecraftBridge) Sponge.client()).bridge$getClientType();
final ChannelBuf responsePayload = this.bufferAllocator.buffer();
responsePayload.writeString(clientType.getName());
final Packet<?> mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId);
PacketSender.sendTo(connection, mcPacket);
return true;
}
if (channelKey.equals(Constants.Channels.SPONGE_CHANNEL_REGISTRY)) {
this.handleChannelRegistry(connection, payload);
// Respond with registered channels
final ChannelBuf responsePayload = this.encodeChannelRegistry();
final Packet<?> mcPacket = PacketUtil.createLoginPayloadResponse(responsePayload, transactionId);
PacketSender.sendTo(connection, mcPacket);
return true;
}
ResourceKey actualChannelKey = channelKey;
ChannelBuf actualPayload = payload;
if (channelKey.equals(Constants.Channels.FML_LOGIN_WRAPPER_CHANNEL)) {
actualChannelKey = ResourceKey.resolve(payload.readString());
final int length = payload.readVarInt();
actualPayload = payload.readSlice(length);
}
final SpongeChannel channel = this.channels.get(actualChannelKey);
if (channel != null) {
channel.handleLoginRequestPayload(connection, transactionId, actualPayload);
return true;
}
return false;
}
Aggregations