use of org.spongepowered.api.ResourceKey in project SpongeCommon by SpongePowered.
the class SpongeChannelManager method handleLoginResponsePayload.
private void handleLoginResponsePayload(final EngineConnection connection, final int transactionId, @Nullable final ChannelBuf payload) {
// Sponge magic... Allows normal packets to be send during the login phase from the client to server
if (transactionId == Constants.Channels.LOGIN_PAYLOAD_IGNORED_TRANSACTION_ID) {
return;
}
if (transactionId == Constants.Channels.LOGIN_PAYLOAD_TRANSACTION_ID) {
if (payload != null) {
final ResourceKey channelKey = ResourceKey.resolve(payload.readString());
this.handlePlayPayload(connection, channelKey, payload);
}
return;
}
// Normal handling
final TransactionStore transactionStore = ConnectionUtil.getTransactionStore(connection);
final TransactionStore.Entry entry = transactionStore.remove(transactionId);
if (entry == null) {
return;
}
if (entry.getData() instanceof ClientTypeSyncFuture) {
if (payload != null) {
this.handleClientType(connection, payload);
}
((ClientTypeSyncFuture) entry.getData()).future.complete(null);
return;
}
if (entry.getData() instanceof ChannelRegistrySyncFuture) {
if (payload != null) {
this.handleChannelRegistry(connection, payload);
}
((ChannelRegistrySyncFuture) entry.getData()).future.complete(null);
return;
}
final TransactionResult result = payload == null ? TransactionResult.failure(new NoResponseException()) : TransactionResult.success(payload);
entry.getChannel().handleTransactionResponse(connection, entry.getData(), result);
}
use of org.spongepowered.api.ResourceKey in project SpongeCommon by SpongePowered.
the class SpongeFluidStack method toContainer.
@Override
@NonNull
public DataContainer toContainer() {
final ResourceKey resourceKey = Sponge.game().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType);
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, this.contentVersion()).set(Constants.Fluids.FLUID_TYPE, resourceKey).set(Constants.Fluids.FLUID_VOLUME, this.volume);
if (this.extraData != null) {
container.set(Constants.Sponge.UNSAFE_NBT, this.extraData);
}
return container;
}
use of org.spongepowered.api.ResourceKey in project SpongeCommon by SpongePowered.
the class SpongeFluidStackSnapshot method toContainer.
@Override
@NonNull
public DataContainer toContainer() {
final ResourceKey resourceKey = Sponge.game().registry(RegistryTypes.FLUID_TYPE).valueKey(this.fluidType);
final DataContainer container = DataContainer.createNew().set(Queries.CONTENT_VERSION, this.contentVersion()).set(Constants.Fluids.FLUID_TYPE, resourceKey).set(Constants.Fluids.FLUID_VOLUME, this.volume);
if (this.extraData != null) {
container.set(Constants.Sponge.UNSAFE_NBT, this.extraData);
}
return container;
}
use of org.spongepowered.api.ResourceKey in project SpongeCommon by SpongePowered.
the class EntitySelectorParserMixin_API method addNotEntityType.
@Override
public Selector.@NonNull Builder addNotEntityType(@NonNull final EntityType<@NonNull ?> type) {
final ResourceKey key = (ResourceKey) (Object) Registry.ENTITY_TYPE.getKey((net.minecraft.world.entity.EntityType<?>) type);
this.api$handle("type", "!" + key.asString());
return this;
}
use of org.spongepowered.api.ResourceKey in project SpongeCommon by SpongePowered.
the class EntitySelectorParserMixin_API method addNotGameMode.
@Override
public Selector.@NonNull Builder addNotGameMode(@NonNull final GameMode mode) {
final ResourceKey key = Sponge.game().registry(RegistryTypes.GAME_MODE).valueKey(mode);
this.api$handle("gamemode", key.value(), Tristate.TRUE);
return this;
}
Aggregations