From e563a84b3e45c9eb58d6eb8f3de28f75d0514bd6 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Thu, 29 Feb 2024 22:12:25 +0100 Subject: [PATCH 01/53] fix ArmorMaterials are now in a registry --- .../java/org/spongepowered/api/registry/RegistryTypes.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 0988ad0d9f..58a9b52c9b 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -196,6 +196,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType ART_TYPE = RegistryTypes.minecraftKeyInGame("painting_variant"); + public static final DefaultedRegistryType ARMOR_MATERIAL = RegistryTypes.minecraftKeyInGame("armor_material"); + public static final DefaultedRegistryType ATTRIBUTE_TYPE = RegistryTypes.minecraftKeyInGame("attribute"); public static final DefaultedRegistryType BIOME = RegistryTypes.minecraftKeyInServer("worldgen/biome"); @@ -278,7 +280,6 @@ public final class RegistryTypes { public static final DefaultedRegistryType ADVANCEMENT_TYPE = RegistryTypes.spongeKeyInGame("advancement_type"); - public static final DefaultedRegistryType ARMOR_MATERIAL = RegistryTypes.spongeKeyInGame("armor_material"); public static final DefaultedRegistryType ATTACHMENT_SURFACE = RegistryTypes.spongeKeyInGame("attachment_surface"); From 5565cde1d2d40fc5cb6ae2ddee63431255bcf51e Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 23 Mar 2024 20:17:41 +0100 Subject: [PATCH 02/53] fix MapDecorationType --- .../decoration/MapDecorationBannerType.java | 43 ------------------- .../api/map/decoration/MapDecorationType.java | 12 +++++- .../api/registry/RegistryTypes.java | 4 +- 3 files changed, 12 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/org/spongepowered/api/map/decoration/MapDecorationBannerType.java diff --git a/src/main/java/org/spongepowered/api/map/decoration/MapDecorationBannerType.java b/src/main/java/org/spongepowered/api/map/decoration/MapDecorationBannerType.java deleted file mode 100644 index 019c6e50bc..0000000000 --- a/src/main/java/org/spongepowered/api/map/decoration/MapDecorationBannerType.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.map.decoration; - -import org.spongepowered.api.data.type.DyeColor; - -/** - * An extension of {@link MapDecorationType} that represents a banner, and provides - * the {@link org.spongepowered.api.data.type.DyeColor} of the banner it - * represents. - *

- * Not all {@link MapDecorationType MapDecorationTypes} are {@link MapDecorationBannerType}. - */ -public interface MapDecorationBannerType extends MapDecorationType { - /** - * Gets the corresponding {@link DyeColor} that this banner decoration type is. - * - * @return The {@link DyeColor} that this banner decoration type is. - */ - DyeColor bannerColor(); -} diff --git a/src/main/java/org/spongepowered/api/map/decoration/MapDecorationType.java b/src/main/java/org/spongepowered/api/map/decoration/MapDecorationType.java index 9dd07eff60..72549a60d4 100644 --- a/src/main/java/org/spongepowered/api/map/decoration/MapDecorationType.java +++ b/src/main/java/org/spongepowered/api/map/decoration/MapDecorationType.java @@ -24,15 +24,23 @@ */ package org.spongepowered.api.map.decoration; +import org.spongepowered.api.data.type.DyeColor; import org.spongepowered.api.map.MapCanvas; import org.spongepowered.api.registry.DefaultedRegistryValue; import org.spongepowered.api.util.annotation.CatalogedBy; +import java.util.Optional; + /** - * Represents a symbol that may be used on a {@link MapCanvas} as part of a - * {@link MapDecoration}. + * Represents a symbol that may be used on a {@link MapCanvas} as part of a {@link MapDecoration}. */ @CatalogedBy(MapDecorationTypes.class) public interface MapDecorationType extends DefaultedRegistryValue { + /** + * Gets the corresponding {@link DyeColor} that this banner decoration type is. + * + * @return The {@link DyeColor} that this banner decoration type is. + */ + Optional bannerColor(); } diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 58a9b52c9b..c313490b92 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -234,6 +234,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType JIGSAW_POOL = RegistryTypes.minecraftKeyInServer("worldgen/template_pool"); + public static final DefaultedRegistryType MAP_DECORATION_TYPE = RegistryTypes.minecraftKeyInGame("map_decoration_type"); + public static final DefaultedRegistryType NOISE_GENERATOR_CONFIG = RegistryTypes.minecraftKeyInServer("worldgen/noise_settings"); public static final DefaultedRegistryType NOISE = RegistryTypes.minecraftKeyInServer("worldgen/noise"); @@ -401,8 +403,6 @@ public final class RegistryTypes { public static final DefaultedRegistryType MAP_DECORATION_ORIENTATION = RegistryTypes.spongeKeyInGame("map_decoration_orientation"); - public static final DefaultedRegistryType MAP_DECORATION_TYPE = RegistryTypes.spongeKeyInGame("map_decoration_type"); - public static final DefaultedRegistryType MAP_SHADE = RegistryTypes.spongeKeyInGame("map_shade"); public static final DefaultedRegistryType MATTER_TYPE = RegistryTypes.spongeKeyInGame("matter_type"); From 0e9b339194aeb13055110855e2865363015b4892 Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 4 May 2024 23:14:34 +0200 Subject: [PATCH 03/53] Bump java to 21 --- .github/workflows/check-spotless.yaml | 2 +- .github/workflows/check-style.yaml | 2 +- .github/workflows/ci.yaml | 2 +- README.md | 4 ++-- gradle.properties | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-spotless.yaml b/.github/workflows/check-spotless.yaml index b4742e6e56..8ff8b992f9 100644 --- a/.github/workflows/check-spotless.yaml +++ b/.github/workflows/check-spotless.yaml @@ -10,5 +10,5 @@ jobs: call-check: uses: SpongePowered/.github/.github/workflows/shared-check-spotless.yaml@master with: - runtime_version: 17 + runtime_version: 21 secrets: inherit diff --git a/.github/workflows/check-style.yaml b/.github/workflows/check-style.yaml index c991e800c4..286cd11250 100644 --- a/.github/workflows/check-style.yaml +++ b/.github/workflows/check-style.yaml @@ -10,5 +10,5 @@ jobs: call-check: uses: SpongePowered/.github/.github/workflows/shared-check-style.yaml@master with: - runtime_version: 17 + runtime_version: 21 secrets: inherit diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bccff70bb5..b1d5d767ff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: call-build: uses: SpongePowered/.github/.github/workflows/shared-ci.yaml@master with: - runtime_version: 17 + runtime_version: 21 publish_snapshot_javadoc: true publishing_branch_regex: 'api-\d+' secrets: inherit diff --git a/README.md b/README.md index b761727a81..9b447617d7 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ A mature Minecraft plugin API (not including an implementation), licensed under * [Discord] `#plugins` ## Prerequisites -* [Java] 17 +* [Java] 21 ## Clone The following steps will ensure your project is cloned properly. @@ -24,7 +24,7 @@ __Note:__ If you do not have [Gradle] installed then use ./gradlew for Unix syst In order to build SpongeAPI you simply need to run the `gradle` command. You can find the compiled JAR file in `./build/libs` labeled similarly to 'spongeapi-x.x.x-SNAPSHOT.jar'. -Sponge will use a javac version of *at least* 17. If an older JDK is used to launch Gradle, JDK 17 will be downloaded automatically. +Sponge will use a javac version of *at least* 21. If an older JDK is used to launch Gradle, JDK 21 will be downloaded automatically. ## Contributing Are you a talented programmer looking to contribute some code? We'd love the help! diff --git a/gradle.properties b/gradle.properties index ce5b09031e..bbd9a55f2f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ version=11.0.0-SNAPSHOT organization=SpongePowered projectUrl=https://www.spongepowered.org projectDescription=A plugin API for Minecraft: Java Edition -javaTarget=17 +javaTarget=21 javadocPublishRoot=https://jd.spongepowered.org/ From c60ba1e9a06e3c5c3e43b8b04c5d4c18fd72212b Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 4 May 2024 23:17:33 +0200 Subject: [PATCH 04/53] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b447617d7..8704b56139 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -SpongeAPI ![Build Status](https://github.com/SpongePowered/SpongeAPI/actions/workflows/ci.yaml/badge.svg?branch=api-10) +SpongeAPI ![Build Status](https://github.com/SpongePowered/SpongeAPI/actions/workflows/ci.yaml/badge.svg?branch=api-11) ============= A mature Minecraft plugin API (not including an implementation), licensed under the [MIT License]. From baf50592d0b485f63e315ff1843b7b31e789f960 Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 4 May 2024 23:31:47 +0200 Subject: [PATCH 05/53] Update supported source version to release 21 --- .../org/spongepowered/plugin/processor/ListenerProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java b/src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java index 20d86b29ed..9f65589fbe 100644 --- a/src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java +++ b/src/ap/java/org/spongepowered/plugin/processor/ListenerProcessor.java @@ -58,7 +58,7 @@ import javax.tools.Diagnostic; @SupportedAnnotationTypes(ListenerProcessor.LISTENER_ANNOTATION_CLASS) -@SupportedSourceVersion(SourceVersion.RELEASE_17) +@SupportedSourceVersion(SourceVersion.RELEASE_21) public class ListenerProcessor extends AbstractProcessor { static final String LISTENER_ANNOTATION_CLASS = "org.spongepowered.api.event.Listener"; From 41b0b0ce6e4e65f2d5f725b6654c0d46db38fcb7 Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 4 May 2024 23:42:00 +0200 Subject: [PATCH 06/53] Set genEventImpl compatibility to java 17 for now --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9409899b2f..95dda334e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -132,7 +132,7 @@ dependencies { tasks { genEventImpl { - sourceCompatibility = javaTarget + sourceCompatibility = "17" // TODO use javaTarget here destinationDirectory = project.layout.buildDirectory.dir("generated/event-factory") outputFactory = "org.spongepowered.api.event.SpongeEventFactory" From a459a98f0955c84398f0824175ccafec2c84c2b7 Mon Sep 17 00:00:00 2001 From: aromaa Date: Mon, 6 May 2024 17:22:56 +0300 Subject: [PATCH 07/53] WIP work EngineConnection --- .../living/player/server/ServerPlayer.java | 6 +- .../network/ServerSideConnectionEvent.java | 15 ++-- .../ClientConnectionConfigurationState.java | 28 ++++++++ ...on.java => ClientConnectionGameState.java} | 8 +-- .../network/ClientConnectionIntentState.java | 28 ++++++++ .../network/ClientConnectionLoginState.java | 28 ++++++++ .../api/network/ClientConnectionState.java | 28 ++++++++ .../api/network/EngineConnection.java | 7 ++ .../EngineConnectionConfigurationState.java | 28 ++++++++ ...on.java => EngineConnectionGameState.java} | 8 +-- .../network/EngineConnectionIntentState.java | 28 ++++++++ .../network/EngineConnectionLoginState.java | 28 ++++++++ ...nTypes.java => EngineConnectionState.java} | 42 ++--------- .../api/network/EngineConnectionStates.java | 70 +++++++++++++++++++ .../ServerConnectionConfigurationState.java | 28 ++++++++ ...on.java => ServerConnectionGameState.java} | 8 +-- .../network/ServerConnectionIntentState.java | 28 ++++++++ .../network/ServerConnectionLoginState.java | 28 ++++++++ .../api/network/ServerConnectionState.java | 28 ++++++++ .../api/network/ServerSideConnection.java | 8 --- .../channel/packet/RequestPacketHandler.java | 10 +-- .../packet/TransactionalPacketBinding.java | 22 ++---- 22 files changed, 421 insertions(+), 91 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java rename src/main/java/org/spongepowered/api/network/{LocalPlayerConnection.java => ClientConnectionGameState.java} (86%) create mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java create mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java create mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionState.java create mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java rename src/main/java/org/spongepowered/api/network/{PlayerConnection.java => EngineConnectionGameState.java} (89%) create mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java create mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java rename src/main/java/org/spongepowered/api/network/{EngineConnectionTypes.java => EngineConnectionState.java} (52%) create mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionStates.java create mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java rename src/main/java/org/spongepowered/api/network/{ServerPlayerConnection.java => ServerConnectionGameState.java} (88%) create mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java create mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java create mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionState.java diff --git a/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java b/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java index f408b4f274..48faf20679 100644 --- a/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java +++ b/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java @@ -47,7 +47,7 @@ import org.spongepowered.api.event.Cause; import org.spongepowered.api.item.inventory.Container; import org.spongepowered.api.item.inventory.Inventory; -import org.spongepowered.api.network.ServerPlayerConnection; +import org.spongepowered.api.network.ServerSideConnection; import org.spongepowered.api.resourcepack.ResourcePack; import org.spongepowered.api.scoreboard.Scoreboard; import org.spongepowered.api.service.permission.Subject; @@ -179,12 +179,12 @@ default SetValue.Mutable displayedSkinParts() { } /** - * Gets the appropriate {@link ServerPlayerConnection} linking this player to a + * Gets the appropriate {@link ServerSideConnection} linking this player to a * client. * * @return The connection */ - ServerPlayerConnection connection(); + ServerSideConnection connection(); /** * Sends a given {@link ResourcePack} to this player. diff --git a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java index 7049af3b31..ee9d739ea2 100644 --- a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java +++ b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java @@ -69,12 +69,17 @@ public interface ServerSideConnectionEvent extends Event { ServerSideConnection connection(); /** - * Gets the {@link GameProfile} of the client attempting to connect. - * - * @return The client's profile + * Called asynchronously when the client attempts to connect to + * the server. */ - default GameProfile profile() { - return this.connection().profile(); + interface Intent extends ServerSideConnectionEvent, MessageEvent, Cancellable { + + /** + * Gets if the user is intending to connect due to being transferred. + * + * @return If the user is transferring. + */ + boolean isTransfer(); } /** diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java new file mode 100644 index 0000000000..92835bfd4d --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ClientConnectionConfigurationState extends EngineConnectionConfigurationState, ClientConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/LocalPlayerConnection.java b/src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java similarity index 86% rename from src/main/java/org/spongepowered/api/network/LocalPlayerConnection.java rename to src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java index bdfec46e21..bdbf6912a3 100644 --- a/src/main/java/org/spongepowered/api/network/LocalPlayerConnection.java +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java @@ -26,14 +26,10 @@ import org.spongepowered.api.entity.living.player.client.LocalPlayer; -/** - * Represents a connection of a client to the server where - * the client {@link LocalPlayer player} has successfully joined. - */ -public interface LocalPlayerConnection extends PlayerConnection, ClientSideConnection { +public interface ClientConnectionGameState extends EngineConnectionGameState, ClientConnectionState { /** - * Gets the associated {@link LocalPlayer player} for this connection. + * Gets the associated {@link LocalPlayer player} for this connection state. * * @return The associated player */ diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java new file mode 100644 index 0000000000..5391f802c4 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ClientConnectionIntentState extends EngineConnectionIntentState, ClientSideConnection { +} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java new file mode 100644 index 0000000000..d913f3c45e --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ClientConnectionLoginState extends EngineConnectionLoginState, ClientConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionState.java new file mode 100644 index 0000000000..246df4b277 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ClientConnectionState extends EngineConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnection.java b/src/main/java/org/spongepowered/api/network/EngineConnection.java index 909ab840dc..24b0aaf1f1 100644 --- a/src/main/java/org/spongepowered/api/network/EngineConnection.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnection.java @@ -38,6 +38,13 @@ public interface EngineConnection extends RemoteConnection { */ EngineConnectionSide side(); + /** + * Gets the state this connection is on. + * + * @return The state + */ + EngineConnectionState state(); + /** * Closes the connection, showing the default disconnect reason. * (the translation key {@code disconnect.disconnected}) diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java new file mode 100644 index 0000000000..303f0e8be3 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface EngineConnectionConfigurationState extends EngineConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/PlayerConnection.java b/src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java similarity index 89% rename from src/main/java/org/spongepowered/api/network/PlayerConnection.java rename to src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java index 54e4c8c15d..5b3738a39a 100644 --- a/src/main/java/org/spongepowered/api/network/PlayerConnection.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java @@ -26,14 +26,10 @@ import org.spongepowered.api.entity.living.player.Player; -/** - * Represents a connection of a client to the server where - * the {@link Player} has successfully joined. - */ -public interface PlayerConnection extends EngineConnection { +public interface EngineConnectionGameState extends EngineConnectionState { /** - * Gets the associated {@link Player player} for this connection. + * Gets the associated {@link Player player} for this connection state. * * @return The associated player */ diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java new file mode 100644 index 0000000000..5d83b2ac68 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface EngineConnectionIntentState extends EngineConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java new file mode 100644 index 0000000000..fdca9a2b6c --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface EngineConnectionLoginState extends EngineConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionTypes.java b/src/main/java/org/spongepowered/api/network/EngineConnectionState.java similarity index 52% rename from src/main/java/org/spongepowered/api/network/EngineConnectionTypes.java rename to src/main/java/org/spongepowered/api/network/EngineConnectionState.java index 1530854cd3..384343fcf8 100644 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionTypes.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionState.java @@ -25,43 +25,15 @@ package org.spongepowered.api.network; /** - * An enumeration of all the possible engine connection types. + * Represents the current state of the connection. */ -public final class EngineConnectionTypes { +public interface EngineConnectionState { /** - * The supertype of all the known connection types. + * Gets whatever the connection was established because + * the client was transferred. + * + * @return Whatever the client was transferred. */ - public static final Class ALL = EngineConnection.class; - - /** - * The client side connection type. - */ - public static final Class CLIENT_SIDE = ClientSideConnection.class; - - /** - * The client side connection type where the player - * has successfully joined a server. - */ - public static final Class LOCAL_PLAYER = LocalPlayerConnection.class; - - /** - * The server or client connection type where the player - * has successfully joined a server. - */ - public static final Class PLAYER = PlayerConnection.class; - - /** - * The server side connection type. - */ - public static final Class SERVER_SIDE = ServerSideConnection.class; - - /** - * The server side connection type where the player - * has successfully joined a server. - */ - public static final Class SERVER_PLAYER = ServerPlayerConnection.class; - - private EngineConnectionTypes() { - } + boolean transferred(); } diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java b/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java new file mode 100644 index 0000000000..38db53e2d2 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java @@ -0,0 +1,70 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +/** + * An enumeration of all the possible engine connection states. + */ +public final class EngineConnectionStates { + + /** + * The supertype of all the known connection states. + */ + public static final Class ALL = EngineConnectionStates.class; + + public static final Class INTENT = EngineConnectionIntentState.class; + + public static final Class LOGIN = EngineConnectionLoginState.class; + + public static final Class CONFIGURATION = EngineConnectionConfigurationState.class; + + public static final Class GAME = EngineConnectionGameState.class; + + /** + * The supertype of all the known client connection states. + */ + public static final Class CLIENT_SIDE = ClientConnectionState.class; + + public static final Class CLIENT_INTENT = ClientConnectionIntentState.class; + + public static final Class CLIENT_LOGIN = ClientConnectionLoginState.class; + + public static final Class CLIENT_CONFIGURATION = ClientConnectionConfigurationState.class; + + public static final Class CLIENT_GAME = ClientConnectionGameState.class; + + /** + * The supertype of all the known server connection states. + */ + public static final Class SERVER_SIDE = ServerConnectionState.class; + + public static final Class SERVER_INTENT = ServerConnectionIntentState.class; + + public static final Class SERVER_LOGIN = ServerConnectionLoginState.class; + + public static final Class SERVER_CONFIGURATION = ServerConnectionConfigurationState.class; + + public static final Class SERVER_GAME = ServerConnectionGameState.class; +} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java new file mode 100644 index 0000000000..17bf2ce30a --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ServerConnectionConfigurationState extends EngineConnectionConfigurationState, ServerConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/ServerPlayerConnection.java b/src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java similarity index 88% rename from src/main/java/org/spongepowered/api/network/ServerPlayerConnection.java rename to src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java index e7582d187f..dc2b938381 100644 --- a/src/main/java/org/spongepowered/api/network/ServerPlayerConnection.java +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java @@ -26,14 +26,10 @@ import org.spongepowered.api.entity.living.player.server.ServerPlayer; -/** - * Represents a connection of a client to the server where - * the {@link ServerPlayer} has successfully joined. - */ -public interface ServerPlayerConnection extends PlayerConnection, ServerSideConnection { +public interface ServerConnectionGameState extends EngineConnectionGameState, ServerConnectionState { /** - * Gets the associated {@link ServerPlayer player} for this connection. + * Gets the associated {@link ServerPlayer player} for this connection state. * * @return The associated player */ diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java new file mode 100644 index 0000000000..fafd555ad0 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ServerConnectionIntentState extends EngineConnectionIntentState, ServerConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java new file mode 100644 index 0000000000..44b615ee22 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ServerConnectionLoginState extends EngineConnectionLoginState, ServerConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java new file mode 100644 index 0000000000..a2f07b2470 --- /dev/null +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.network; + +public interface ServerConnectionState extends EngineConnectionState { +} diff --git a/src/main/java/org/spongepowered/api/network/ServerSideConnection.java b/src/main/java/org/spongepowered/api/network/ServerSideConnection.java index 77a7d22e60..902c209f07 100644 --- a/src/main/java/org/spongepowered/api/network/ServerSideConnection.java +++ b/src/main/java/org/spongepowered/api/network/ServerSideConnection.java @@ -24,8 +24,6 @@ */ package org.spongepowered.api.network; -import org.spongepowered.api.profile.GameProfile; - /** * Represents a connection between a minecraft client and server. */ @@ -36,10 +34,4 @@ default EngineConnectionSide side() { return EngineConnectionSide.SERVER; } - /** - * Gets the profile of the client. - * - * @return The client's profile - */ - GameProfile profile(); } diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/RequestPacketHandler.java b/src/main/java/org/spongepowered/api/network/channel/packet/RequestPacketHandler.java index be72a6275e..18addcbd6d 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/RequestPacketHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/RequestPacketHandler.java @@ -24,7 +24,7 @@ */ package org.spongepowered.api.network.channel.packet; -import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.RemoteConnection; import org.spongepowered.api.network.channel.ChannelException; @@ -33,10 +33,10 @@ * * @param

The request packet type * @param The response packet type - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface RequestPacketHandler

{ +public interface RequestPacketHandler

{ /** * Handles the {@link RequestPacket} which was send by a specific @@ -53,8 +53,8 @@ public interface RequestPacketHandler

* * @param requestPacket The received request packet - * @param connection The connection that sent the packet + * @param state The state that sent the packet * @param response The response which should be completed */ - void handleRequest(P requestPacket, C connection, RequestPacketResponse response); + void handleRequest(P requestPacket, S state, RequestPacketResponse response); } diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/TransactionalPacketBinding.java b/src/main/java/org/spongepowered/api/network/channel/packet/TransactionalPacketBinding.java index 48359d17b2..e17d5ffa31 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/TransactionalPacketBinding.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/TransactionalPacketBinding.java @@ -26,6 +26,7 @@ import org.spongepowered.api.network.EngineConnection; import org.spongepowered.api.network.EngineConnectionSide; +import org.spongepowered.api.network.EngineConnectionState; import java.util.concurrent.CompletableFuture; @@ -59,19 +60,6 @@ public interface TransactionalPacketBinding

, R extend @Override Class

packetType(); - /** - * Sets the {@link RequestPacketHandler} to handle a {@link RequestPacket} - * on a specific connection side. The difference with a normal {@link PacketHandler} - * is that it requires a response {@link Packet} as return value. - * - * @param side The side the request packet should be handled on - * @param handler The handler of the request packet - * @param The connection type - * @return This packet binding, for chaining - */ - TransactionalPacketBinding setRequestHandler( - EngineConnectionSide side, RequestPacketHandler handler); - /** * Sets the {@link RequestPacketHandler} to handle a {@link RequestPacket} * for a specific connection type. The difference with a normal {@link PacketHandler} @@ -79,11 +67,11 @@ TransactionalPacketBinding setRequestHandler( * * @param connectionType The connection type the request packet should be handled by * @param handler The handler of the request packet - * @param The connection type + * @param The connection state * @return This packet binding, for chaining */ - TransactionalPacketBinding setRequestHandler( - Class connectionType, RequestPacketHandler handler); + TransactionalPacketBinding setRequestHandler( + Class connectionType, RequestPacketHandler handler); /** * Sets the {@link RequestPacketHandler} to handle a {@link RequestPacket} @@ -93,7 +81,7 @@ TransactionalPacketBinding setRequestHandler( * @param handler The handler of the request packet * @return This packet binding, for chaining */ - TransactionalPacketBinding setRequestHandler(RequestPacketHandler handler); + TransactionalPacketBinding setRequestHandler(RequestPacketHandler handler); /** * Adds a {@link PacketHandler} to handle a response {@link Packet} From c4161ecfe1e40f85fa548f977a0b80597f91efec Mon Sep 17 00:00:00 2001 From: Chris Sanders Date: Sun, 31 Mar 2024 17:56:53 -0500 Subject: [PATCH 08/53] Changes for WorldTypeTemplate. - Expose and unify the data properties between WorldType and WorldTypeTemplate - Remove the type getter from template. This prompts a much larger discussion about data packs but templates should never reference their actual built type. It is an implementation detail and the API should declare these as temporary, lifecycle-like objects. Signed-off-by: Chris Sanders --- .../spongepowered/api/world/WorldType.java | 229 +--------------- .../api/world/WorldTypeDataFetcher.java | 254 ++++++++++++++++++ .../api/world/WorldTypeTemplate.java | 25 +- 3 files changed, 272 insertions(+), 236 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/world/WorldTypeDataFetcher.java diff --git a/src/main/java/org/spongepowered/api/world/WorldType.java b/src/main/java/org/spongepowered/api/world/WorldType.java index 3830d60447..f30e912d7c 100644 --- a/src/main/java/org/spongepowered/api/world/WorldType.java +++ b/src/main/java/org/spongepowered/api/world/WorldType.java @@ -24,238 +24,11 @@ */ package org.spongepowered.api.world; -import org.spongepowered.api.block.BlockType; -import org.spongepowered.api.block.BlockTypes; -import org.spongepowered.api.data.DataHolder; -import org.spongepowered.api.data.Keys; -import org.spongepowered.api.effect.potion.PotionEffectTypes; -import org.spongepowered.api.entity.Entity; -import org.spongepowered.api.entity.living.monster.boss.dragon.EnderDragon; -import org.spongepowered.api.entity.living.monster.piglin.Piglin; -import org.spongepowered.api.entity.living.monster.zombie.ZombifiedPiglin; -import org.spongepowered.api.entity.living.player.server.ServerPlayer; -import org.spongepowered.api.fluid.FluidTypes; -import org.spongepowered.api.item.ItemTypes; -import org.spongepowered.api.raid.Raid; import org.spongepowered.api.registry.DefaultedRegistryValue; import org.spongepowered.api.service.context.ContextSource; -import org.spongepowered.api.tag.Tag; -import org.spongepowered.api.util.MinecraftDayTime; -import org.spongepowered.api.util.Range; import org.spongepowered.api.util.annotation.CatalogedBy; -import org.spongepowered.api.world.portal.PortalType; -import org.spongepowered.api.world.portal.PortalTypes; -import org.spongepowered.api.world.server.ServerLocation; -import org.spongepowered.api.world.server.ServerWorld; - -import java.util.Optional; @CatalogedBy(WorldTypes.class) -public interface WorldType extends DefaultedRegistryValue, ContextSource, DataHolder { - - /** - * Gets the {@link WorldTypeEffect effect} that will play for a {@link ServerPlayer player} - * traveling in a {@link ServerWorld world} of this type. - * - * @return The effect - */ - default WorldTypeEffect effect() { - return this.require(Keys.WORLD_TYPE_EFFECT); - } - - /** - * Gets if {@link BlockTypes#WATER} will evaporate or {@link BlockTypes#WET_SPONGE} will - * become a {@link BlockTypes#SPONGE}. Additionally {@link FluidTypes#FLOWING_LAVA} will - * spread faster and thinner. - * - * @return True if scorching, false if not - */ - default boolean scorching() { - return this.require(Keys.SCORCHING); - } - - /** - * Gets if the world type is considered natural. - *

Natural worlds allow - * sleeping in beds and setting the respawn point, - * {@link PortalTypes#NETHER} portals to spawn {@link ZombifiedPiglin} and - * {@link ItemTypes#COMPASS} to work

- * - * @return True if natural, false if not - */ - default boolean natural() { - return this.require(Keys.NATURAL_WORLD_TYPE); - } - - /** - * Gets the coordinate scale applied to the coordinates of a {@link ServerPlayer player} - * traveling in a {@link ServerWorld world} of this type. - *

- * Best seen when transferring that player from one world to another (as the player's - * coordinates will adjust to the scale of the destination world's). - * - * @return The scale - */ - default double coordinateMultiplier() { - return this.require(Keys.COORDINATE_MULTIPLIER); - } - - /** - * Gets if a {@link ServerWorld world} of this type will have global lighting, used - * in game mechanics such as {@link Entity} spawning. - *

In Vanilla, used in weather, lighting engine, and respawning mechanics

- * - * @return True if skylight, false if not - */ - default boolean hasSkylight() { - return this.require(Keys.HAS_SKYLIGHT); - } - - /** - * Gets if a {@link ServerWorld world} of this type is generated with a ceiling at some - * pre-determined y value composed of {@link BlockTypes#BEDROCK}. Most notable usage of - * this is for the {@link WorldTypes#THE_NETHER type}. - * - *

In Vanilla, used in weather, map items, and respawning mechanics

- * - * @return True if a ceiling is present, false if not - */ - default boolean hasCeiling() { - return this.require(Keys.HAS_CEILING); - } - - /** - * Gets the amount of lighting a client will play as an effect while traversing a - * {@link ServerWorld world} of this type. - * - *

In Vanilla, the value will be between {@code 0.0} and {@code 1.0}

- * - * @return The lighting value - */ - default float ambientLighting() { - return this.require(Keys.AMBIENT_LIGHTING); - } - - /** - * Gets if a {@link ServerWorld world} of this type will be fixed at a particular - * {@link MinecraftDayTime time} or flow naturally - * - * @return If present, a fixed day time. Otherwise, free flowing time - */ - default Optional fixedTime() { - return this.get(Keys.FIXED_TIME); - } - - /** - * Gets if, when {@code False}, a {@link Piglin} will transform into a {@link ZombifiedPiglin}, - * over time, while existing in a {@link ServerWorld world} of this type. - * - * @return True if piglin are safe, false if they will zombify - */ - default boolean piglinSafe() { - return this.require(Keys.PIGLIN_SAFE); - } - - /** - * Gets if {@link ServerPlayer players} can sleep in a bed while existing in a - * {@link ServerWorld world} of this type. - *

When bed usage is not allowed beds will instead explode.

- * - * @return True if beds are usable, false if not - */ - default boolean bedsUsable() { - return this.require(Keys.BEDS_USABLE); - } - - /** - * Gets if {@link ServerPlayer players} can charge and use {@link BlockTypes#RESPAWN_ANCHOR} - * while existing in a {@link ServerWorld world} of this type. - * - * @return True if respawn anchors are usable, false if not - */ - default boolean respawnAnchorsUsable() { - return this.require(Keys.RESPAWN_ANCHOR_USABLE); - } - - /** - * Gets if {@link ServerPlayer players} who have the {@link PotionEffectTypes#BAD_OMEN} effect - * could cause a {@link Raid} while existing in a {@link ServerWorld world} of this type. - * - * @return True if bad omens could case a raid, false if not - */ - default boolean hasRaids() { - return this.require(Keys.HAS_RAIDS); - } - - /** - * Gets the minimum {@code Y} value that blocks can exist within a world of this type. - *

In vanilla this is a multiple of 16 between -2032 and 2016

- * - * @return The minimum height - */ - default int floor() { - return this.require(Keys.WORLD_FLOOR); - } - - /** - * Gets the total height in which blocks can exist within a world of this type. - *

In vanilla this is a multiple of 16 between 16 and 4064. {@link #floor()} + {@link #height()} may not be more than 2032

- * - * @return The maximum height - */ - default int height() { - return this.require(Keys.WORLD_HEIGHT); - } - - /** - * Gets the maximum height that teleportation logic performed via - * {@link ItemTypes#CHORUS_FRUIT} or {@link PortalType portal types} may use to determine - * the exit {@link ServerLocation location} of the teleport or the generation of a portal - * itself. - * - * @return The logical height - */ - default int logicalHeight() { - return this.require(Keys.WORLD_LOGICAL_HEIGHT); - } - - /** - * Gets the tag for blocks that burn indefinitely in a world of this type. - * - * @return The infiniburn tag - */ - default Tag infiniburn() { - return this.require(Keys.INFINIBURN); - } - - /** - * Gets if {@link ServerWorld worlds} of this type will spawn the {@link EnderDragon dragon} - * fight mechanics. - * - * @return True if dragon fight spawns, false if not - */ - default boolean createDragonFight() { - return this.require(Keys.CREATE_DRAGON_FIGHT); - } - - /** - * Returns the light level needed to block monster spawning. - * - * @return spawn light limit - */ - default int spawnLightLimit() { - return this.require(Keys.SPAWN_LIGHT_LIMIT); - } - - /** - * Returns the light level range needed to block monster spawning. - * - * @return the spawn light range - */ - default Range spawnLightRange() { - return this.require(Keys.SPAWN_LIGHT_RANGE); - } - - +public interface WorldType extends DefaultedRegistryValue, ContextSource, WorldTypeDataFetcher { } diff --git a/src/main/java/org/spongepowered/api/world/WorldTypeDataFetcher.java b/src/main/java/org/spongepowered/api/world/WorldTypeDataFetcher.java new file mode 100644 index 0000000000..ce02cec717 --- /dev/null +++ b/src/main/java/org/spongepowered/api/world/WorldTypeDataFetcher.java @@ -0,0 +1,254 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.world; + +import org.spongepowered.api.block.BlockType; +import org.spongepowered.api.block.BlockTypes; +import org.spongepowered.api.data.DataHolder; +import org.spongepowered.api.data.Keys; +import org.spongepowered.api.effect.potion.PotionEffectTypes; +import org.spongepowered.api.entity.Entity; +import org.spongepowered.api.entity.living.monster.boss.dragon.EnderDragon; +import org.spongepowered.api.entity.living.monster.piglin.Piglin; +import org.spongepowered.api.entity.living.monster.zombie.ZombifiedPiglin; +import org.spongepowered.api.entity.living.player.server.ServerPlayer; +import org.spongepowered.api.fluid.FluidTypes; +import org.spongepowered.api.item.ItemTypes; +import org.spongepowered.api.raid.Raid; +import org.spongepowered.api.tag.Tag; +import org.spongepowered.api.util.MinecraftDayTime; +import org.spongepowered.api.util.Range; +import org.spongepowered.api.world.portal.PortalType; +import org.spongepowered.api.world.portal.PortalTypes; +import org.spongepowered.api.world.server.ServerLocation; +import org.spongepowered.api.world.server.ServerWorld; + +import java.util.Optional; + +public interface WorldTypeDataFetcher extends DataHolder { + + /** + * Gets the {@link WorldTypeEffect effect} that will play for a {@link ServerPlayer player} + * traveling in a {@link ServerWorld world} of this type. + * + * @return The effect + */ + default WorldTypeEffect effect() { + return this.require(Keys.WORLD_TYPE_EFFECT); + } + + /** + * Gets if {@link BlockTypes#WATER} will evaporate or {@link BlockTypes#WET_SPONGE} will + * become a {@link BlockTypes#SPONGE}. Additionally {@link FluidTypes#FLOWING_LAVA} will + * spread faster and thinner. + * + * @return True if scorching, false if not + */ + default boolean scorching() { + return this.require(Keys.SCORCHING); + } + + /** + * Gets if the world type is considered natural. + *

Natural worlds allow + * sleeping in beds and setting the respawn point, + * {@link PortalTypes#NETHER} portals to spawn {@link ZombifiedPiglin} and + * {@link ItemTypes#COMPASS} to work

+ * + * @return True if natural, false if not + */ + default boolean natural() { + return this.require(Keys.NATURAL_WORLD_TYPE); + } + + /** + * Gets the coordinate scale applied to the coordinates of a {@link ServerPlayer player} + * traveling in a {@link ServerWorld world} of this type. + *

+ * Best seen when transferring that player from one world to another (as the player's + * coordinates will adjust to the scale of the destination world's). + * + * @return The scale + */ + default double coordinateMultiplier() { + return this.require(Keys.COORDINATE_MULTIPLIER); + } + + /** + * Gets if a {@link ServerWorld world} of this type will have global lighting, used + * in game mechanics such as {@link Entity} spawning. + *

In Vanilla, used in weather, lighting engine, and respawning mechanics

+ * + * @return True if skylight, false if not + */ + default boolean hasSkylight() { + return this.require(Keys.HAS_SKYLIGHT); + } + + /** + * Gets if a {@link ServerWorld world} of this type is generated with a ceiling at some + * pre-determined y value composed of {@link BlockTypes#BEDROCK}. Most notable usage of + * this is for the {@link WorldTypes#THE_NETHER type}. + * + *

In Vanilla, used in weather, map items, and respawning mechanics

+ * + * @return True if a ceiling is present, false if not + */ + default boolean hasCeiling() { + return this.require(Keys.HAS_CEILING); + } + + /** + * Gets the amount of lighting a client will play as an effect while traversing a + * {@link ServerWorld world} of this type. + * + *

In Vanilla, the value will be between {@code 0.0} and {@code 1.0}

+ * + * @return The lighting value + */ + default float ambientLighting() { + return this.require(Keys.AMBIENT_LIGHTING); + } + + /** + * Gets if a {@link ServerWorld world} of this type will be fixed at a particular + * {@link MinecraftDayTime time} or flow naturally + * + * @return If present, a fixed day time. Otherwise, free flowing time + */ + default Optional fixedTime() { + return this.get(Keys.FIXED_TIME); + } + + /** + * Gets if, when {@code False}, a {@link Piglin} will transform into a {@link ZombifiedPiglin}, + * over time, while existing in a {@link ServerWorld world} of this type. + * + * @return True if piglin are safe, false if they will zombify + */ + default boolean piglinSafe() { + return this.require(Keys.PIGLIN_SAFE); + } + + /** + * Gets if {@link ServerPlayer players} can sleep in a bed while existing in a + * {@link ServerWorld world} of this type. + *

When bed usage is not allowed beds will instead explode.

+ * + * @return True if beds are usable, false if not + */ + default boolean bedsUsable() { + return this.require(Keys.BEDS_USABLE); + } + + /** + * Gets if {@link ServerPlayer players} can charge and use {@link BlockTypes#RESPAWN_ANCHOR} + * while existing in a {@link ServerWorld world} of this type. + * + * @return True if respawn anchors are usable, false if not + */ + default boolean respawnAnchorsUsable() { + return this.require(Keys.RESPAWN_ANCHOR_USABLE); + } + + /** + * Gets if {@link ServerPlayer players} who have the {@link PotionEffectTypes#BAD_OMEN} effect + * could cause a {@link Raid} while existing in a {@link ServerWorld world} of this type. + * + * @return True if bad omens could case a raid, false if not + */ + default boolean hasRaids() { + return this.require(Keys.HAS_RAIDS); + } + + /** + * Gets the minimum {@code Y} value that blocks can exist within a world of this type. + *

In vanilla this is a multiple of 16 between -2032 and 2016

+ * + * @return The minimum height + */ + default int floor() { + return this.require(Keys.WORLD_FLOOR); + } + + /** + * Gets the total height in which blocks can exist within a world of this type. + *

In vanilla this is a multiple of 16 between 16 and 4064. {@link #floor()} + {@link #height()} may not be more than 2032

+ * + * @return The maximum height + */ + default int height() { + return this.require(Keys.WORLD_HEIGHT); + } + + /** + * Gets the maximum height that teleportation logic performed via + * {@link ItemTypes#CHORUS_FRUIT} or {@link PortalType portal types} may use to determine + * the exit {@link ServerLocation location} of the teleport or the generation of a portal + * itself. + * + * @return The logical height + */ + default int logicalHeight() { + return this.require(Keys.WORLD_LOGICAL_HEIGHT); + } + + /** + * Gets the tag for blocks that burn indefinitely in a world of this type. + * + * @return The infiniburn tag + */ + default Tag infiniburn() { + return this.require(Keys.INFINIBURN); + } + + /** + * Gets if {@link ServerWorld worlds} of this type will spawn the {@link EnderDragon dragon} + * fight mechanics. + * + * @return True if dragon fight spawns, false if not + */ + default boolean createDragonFight() { + return this.require(Keys.CREATE_DRAGON_FIGHT); + } + + /** + * Returns the light level needed to block monster spawning. + * + * @return spawn light limit + */ + default int spawnLightLimit() { + return this.require(Keys.SPAWN_LIGHT_LIMIT); + } + + /** + * Returns the light level range needed to block monster spawning. + * + * @return the spawn light range + */ + default Range spawnLightRange() { + return this.require(Keys.SPAWN_LIGHT_RANGE); + } +} diff --git a/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java b/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java index 5bce074b8b..dbf335ea1b 100644 --- a/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java +++ b/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java @@ -26,14 +26,18 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.data.Key; +import org.spongepowered.api.data.persistence.DataView; import org.spongepowered.api.data.value.Value; +import org.spongepowered.api.datapack.DataPack; import org.spongepowered.api.datapack.DataPackEntry; import org.spongepowered.api.util.DataPackEntryBuilder; +import java.io.IOException; + /** * A template for a {@link WorldType}. */ -public interface WorldTypeTemplate extends DataPackEntry { +public interface WorldTypeTemplate extends DataPackEntry, WorldTypeDataFetcher { static WorldTypeTemplate.Builder overworld() { return WorldTypeTemplate.builder().fromValue(WorldTypes.OVERWORLD.get()); @@ -55,17 +59,22 @@ static Builder builder() { return Sponge.game().builderProvider().provide(Builder.class).reset(); } - /** - * Returns the world type. - * - * @return The world type - */ - WorldType worldType(); - interface Builder extends DataPackEntryBuilder { Builder add(Key> key, V value); + /** + * Creates a world template based on the given data view. + *

The given data must be equivalent to a data-pack for world-templates (dimension)

+ * + * @param pack The data + * @return This builder, for chaining + */ + Builder fromDataPack(DataView pack) throws IOException; + + Builder from(WorldType type); + + Builder pack(DataPack pack); } } From 56a41b969e159a3626858144f220f4db617abc51 Mon Sep 17 00:00:00 2001 From: Chris Sanders Date: Sun, 31 Mar 2024 18:35:37 -0500 Subject: [PATCH 09/53] We'll allow api-10 to not be broke. This needs a far better fix in 11 but that comes with looking over DataPack objects as a whole. Signed-off-by: Chris Sanders --- .../org/spongepowered/api/world/WorldTypeTemplate.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java b/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java index dbf335ea1b..5636a00b74 100644 --- a/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java +++ b/src/main/java/org/spongepowered/api/world/WorldTypeTemplate.java @@ -59,6 +59,13 @@ static Builder builder() { return Sponge.game().builderProvider().provide(Builder.class).reset(); } + /** + * Returns the world type. + * + * @return The world type + */ + WorldType worldType(); + interface Builder extends DataPackEntryBuilder { Builder add(Key> key, V value); From 3a01dbfd7c2a262fcc3eb5f07c6de317c46ea870 Mon Sep 17 00:00:00 2001 From: aromaa Date: Mon, 13 May 2024 17:18:36 +0300 Subject: [PATCH 10/53] Finish up the changes to EngineConnection and ServerSideConnectionEvent --- .../network/ServerSideConnectionEvent.java | 113 +++++++++++++++--- .../ClientConnectionConfigurationState.java | 28 ----- .../network/ClientConnectionGameState.java | 38 ------ .../network/ClientConnectionIntentState.java | 28 ----- .../network/ClientConnectionLoginState.java | 28 ----- .../api/network/ClientConnectionState.java | 49 ++++++++ .../api/network/EngineConnection.java | 7 +- .../EngineConnectionConfigurationState.java | 28 ----- .../network/EngineConnectionGameState.java | 37 ------ .../network/EngineConnectionIntentState.java | 28 ----- .../network/EngineConnectionLoginState.java | 28 ----- .../api/network/EngineConnectionState.java | 57 ++++++++- .../api/network/EngineConnectionStates.java | 41 +++++-- .../api/network/RemoteConnection.java | 7 ++ .../ServerConnectionConfigurationState.java | 28 ----- .../network/ServerConnectionGameState.java | 45 ------- .../network/ServerConnectionIntentState.java | 28 ----- .../network/ServerConnectionLoginState.java | 28 ----- .../api/network/ServerConnectionState.java | 50 ++++++++ .../network/channel/packet/PacketChannel.java | 2 +- .../packet/basic/BasicPacketChannel.java | 1 + 21 files changed, 291 insertions(+), 408 deletions(-) delete mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java delete mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java delete mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java delete mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java delete mode 100644 src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java delete mode 100644 src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java diff --git a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java index ee9d739ea2..67cd0d7f1c 100644 --- a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java +++ b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java @@ -38,21 +38,30 @@ import org.spongepowered.api.profile.GameProfile; import org.spongepowered.api.service.ban.BanService; import org.spongepowered.api.service.whitelist.WhitelistService; +import org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod; import org.spongepowered.api.world.server.ServerLocation; import org.spongepowered.api.world.server.ServerWorld; import org.spongepowered.math.vector.Vector3d; import java.net.InetAddress; +import java.util.Optional; /** - * Represents an event fired during the login process. + * Represents an event fired during the login and configuration phase. * *

These events represent the progression of a {@link ServerPlayer player} * from first authenticating, to being fully loaded in the world.

* *

The events are fired in the following order:

* - *

#Auth -> #Handshake -> #Login -> #Join

+ *

#Intent -> #Auth -> #Handshake -> #Configuration -> #Login -> #Join

+ * + *

Vanilla also allows the client to go back to the configuration phase + * where the {@link ServerPlayer player} is removed from the world before + * being put back after the configuration phase ends. The order of the events + * is the following:

+ * + *

#Leave -> #Configuration -> #Login -> #Join

* *

Traditionally one could consider a {@link SpawnEntityEvent} to be thrown, * but due to the nature of cancellations, a {@link ServerPlayer player} joining @@ -69,37 +78,72 @@ public interface ServerSideConnectionEvent extends Event { ServerSideConnection connection(); /** - * Called asynchronously when the client attempts to connect to - * the server. + *

Called asynchronously when the client attempts to connect to + * the server.

+ * + *

After observing this event for particular {@link ServerSideConnection connection} + * you are guaranteed to get #Disconnect for the same connection without + * ordering issues.

*/ interface Intent extends ServerSideConnectionEvent, MessageEvent, Cancellable { /** * Gets if the user is intending to connect due to being transferred. * - * @return If the user is transferring. + * @return {@code true} if the user is transferring. */ boolean isTransfer(); } + /** + * Represents an event that has knowledge about the {@link GameProfile} that + * is linked to the connection. + */ + @NoFactoryMethod + interface ProfileScoped extends ServerSideConnectionEvent { + + /** + * Gets the {@link GameProfile} of the client. + * + * @return The client's profile + */ + GameProfile profile(); + } + /** * Called asynchronously when the client attempts to authenticate against * the server. * + *

After observing this event for particular {@link ServerSideConnection connection} + * you are guaranteed to get #Disconnect for the same connection without + * ordering issues.

+ * + *

If the registered {@link BanService} or {@link WhitelistService} + * indicates that a player should not be allowed to join ( + * {@link GameProfile} or {@link InetAddress} has an ban, or is not on the + * whitelist), then this event will automatically cancelled by the + * implementation, with the proper message set through + * {@link MessageEvent#setMessage(Component)}. No action on the part + * of the registered {@link BanService} or {@link WhitelistService} is + * required for this to occur. + * + *

Plugins may uncancel the event to allow a client to join, regardless of + * its ban/whitelist status.

+ * *

Note: This event is fired before #Login.

*/ - interface Auth extends ServerSideConnectionEvent, MessageEvent, Cancellable { + interface Auth extends ProfileScoped, MessageEvent, Cancellable { } /** - * Called after the client authenticates and attempts to login to the - * server. This is the phase where plugins can perform a handshake with - * the client by sending login related packets and requests. + * Called after the client authenticates and attempts to switch to the + * configuration phase. This is the phase where plugins can perform + * a handshake with the client by sending login related packets and requests. * *

During this event, it's possible to use the {@link Channel}s to send * requests to the client. As long as there's requests going to the client, * the connection will stay in the handshake phase and will not continue - * to the {@link Login} event.

+ * to the {@link Configuration} event.

* *

For example, a plugin sends a packet to the client to request its * client side plugin version. The client responds and the plugin handles @@ -110,13 +154,28 @@ interface Auth extends ServerSideConnectionEvent, MessageEvent, Cancellable { *

During the lifetime of the handshake phase, a {@link ServerSideConnection} * can be terminated by calling {@link ServerSideConnection#close(Component)}.

*/ - interface Handshake extends ServerSideConnectionEvent { + interface Handshake extends ProfileScoped { + } + + /** + * Called when the configuration phase starts. This can happen multiple + * times per session. + * + *

During this event, it's possible to use the {@link Channel}s to send + * requests to the client. As long as there's requests going to the client, + * the connection will stay in the configuration phase and will not continue + * to the {@link Login} event.

+ * + *

During the lifetime of the handshake phase, a {@link ServerSideConnection} + * can be terminated by calling {@link ServerSideConnection#close(Component)}.

+ */ + interface Configuration extends ProfileScoped { } /** - * Called after the server finished its handshake with the client. + * Called after the server finished its configuration with the client. * - *

Note: This event is fired after #Auth and is NOT async. Any changes + *

Note: This event is fired after #Configuration and is NOT async. Any changes * required for the {@link ServerPlayer players} {@link ServerLocation location} * or {@link Vector3d rotation} should be done during this event and NOT * during #Join.

@@ -133,7 +192,7 @@ interface Handshake extends ServerSideConnectionEvent { * Plugins may uncancel the event to allow a client to join, regardless of * its ban/whitelist status.

*/ - interface Login extends ServerSideConnectionEvent, MessageEvent, Event, Cancellable { + interface Login extends ProfileScoped, MessageEvent, Cancellable { /** * Gets the {@link User}. @@ -187,14 +246,14 @@ interface Login extends ServerSideConnectionEvent, MessageEvent, Event, Cancella /** * Called when a {@link ServerPlayer player} joins the game within a - * {@link ServerWorld world} for the first time after initial connection. + * {@link ServerWorld world} for the first time after the configuration phase. * Fired after {@link Login} once the {@link ServerPlayer player} has been * properly added to the {@link ServerWorld}. If data is wanted to be * modified that could affect a player's representation (such as vanishing), * it's recommended to modify such data in the logging in * {@link Login#user() User} instead. */ - interface Join extends ServerSideConnectionEvent, AudienceMessageEvent, MessageCancellable { + interface Join extends ProfileScoped, AudienceMessageEvent, MessageCancellable { /** * Gets the {@link ServerPlayer player}. @@ -205,9 +264,11 @@ interface Join extends ServerSideConnectionEvent, AudienceMessageEvent, MessageC } /** - * Called when a {@link ServerPlayer player} disconnects from the game. + * Called when a {@link ServerPlayer player} leaves from the world. The + * {@link ServerSideConnection connection} might not be closed yet as the + * client could have transitioned back to the configuration state. */ - interface Disconnect extends ServerSideConnectionEvent, AudienceMessageEvent { + interface Leave extends ProfileScoped, AudienceMessageEvent, MessageCancellable { /** * Gets the {@link ServerPlayer player}. @@ -217,4 +278,20 @@ interface Disconnect extends ServerSideConnectionEvent, AudienceMessageEvent { ServerPlayer player(); } + /** + * Called when a {@link ServerSideConnection connection} disconnects from the game. + * + *

Note: This event might be called asynchronously. Additionally, the connection + * might have not got past #Auth. + */ + interface Disconnect extends ServerSideConnectionEvent { + + /** + * Gets the {@link GameProfile} of the client if it got + * past authentication. + * + * @return The client's profile + */ + Optional profile(); + } } diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java deleted file mode 100644 index 92835bfd4d..0000000000 --- a/src/main/java/org/spongepowered/api/network/ClientConnectionConfigurationState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ClientConnectionConfigurationState extends EngineConnectionConfigurationState, ClientConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java deleted file mode 100644 index bdbf6912a3..0000000000 --- a/src/main/java/org/spongepowered/api/network/ClientConnectionGameState.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -import org.spongepowered.api.entity.living.player.client.LocalPlayer; - -public interface ClientConnectionGameState extends EngineConnectionGameState, ClientConnectionState { - - /** - * Gets the associated {@link LocalPlayer player} for this connection state. - * - * @return The associated player - */ - @Override - LocalPlayer player(); -} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java deleted file mode 100644 index 5391f802c4..0000000000 --- a/src/main/java/org/spongepowered/api/network/ClientConnectionIntentState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ClientConnectionIntentState extends EngineConnectionIntentState, ClientSideConnection { -} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java deleted file mode 100644 index d913f3c45e..0000000000 --- a/src/main/java/org/spongepowered/api/network/ClientConnectionLoginState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ClientConnectionLoginState extends EngineConnectionLoginState, ClientConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/ClientConnectionState.java b/src/main/java/org/spongepowered/api/network/ClientConnectionState.java index 246df4b277..bb533b06a9 100644 --- a/src/main/java/org/spongepowered/api/network/ClientConnectionState.java +++ b/src/main/java/org/spongepowered/api/network/ClientConnectionState.java @@ -24,5 +24,54 @@ */ package org.spongepowered.api.network; +import org.spongepowered.api.entity.living.player.client.LocalPlayer; + +/** + * Represents the state of the connection + * from the client to the server on the client side. + */ public interface ClientConnectionState extends EngineConnectionState { + + /** + * Represents the intent state of the connection + * from the client to the server on the client side. + */ + interface Intent extends EngineConnectionState.Intent, ClientConnectionState { + } + + /** + * Represents the authenticated state of the connection + * from the client to the server on the client side. + */ + interface Authenticated extends EngineConnectionState.Authenticated, ClientConnectionState { + } + + /** + * Represents the login state of the connection + * from the client to the server on the client side. + */ + interface Login extends EngineConnectionState.Login, Authenticated { + } + + /** + * Represents the configuration state of the connection + * from the client to the server on the client side. + */ + interface Configuration extends EngineConnectionState.Configuration, Authenticated { + } + + /** + * Represents the game state of the connection + * from the client to the server on the client side. + */ + interface Game extends EngineConnectionState.Game, Authenticated { + + /** + * Gets the associated {@link LocalPlayer player} for this connection state. + * + * @return The associated player + */ + @Override + LocalPlayer player(); + } } diff --git a/src/main/java/org/spongepowered/api/network/EngineConnection.java b/src/main/java/org/spongepowered/api/network/EngineConnection.java index 24b0aaf1f1..b87153e624 100644 --- a/src/main/java/org/spongepowered/api/network/EngineConnection.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnection.java @@ -26,6 +26,8 @@ import net.kyori.adventure.text.Component; +import java.util.Optional; + /** * Represents a connection on the server or client engine. */ @@ -41,9 +43,10 @@ public interface EngineConnection extends RemoteConnection { /** * Gets the state this connection is on. * - * @return The state + * @return The state, or {@link Optional#empty()} if the connection + * has been closed. */ - EngineConnectionState state(); + Optional state(); /** * Closes the connection, showing the default disconnect reason. diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java deleted file mode 100644 index 303f0e8be3..0000000000 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionConfigurationState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface EngineConnectionConfigurationState extends EngineConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java deleted file mode 100644 index 5b3738a39a..0000000000 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionGameState.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -import org.spongepowered.api.entity.living.player.Player; - -public interface EngineConnectionGameState extends EngineConnectionState { - - /** - * Gets the associated {@link Player player} for this connection state. - * - * @return The associated player - */ - Player player(); -} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java deleted file mode 100644 index 5d83b2ac68..0000000000 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionIntentState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface EngineConnectionIntentState extends EngineConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java deleted file mode 100644 index fdca9a2b6c..0000000000 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionLoginState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface EngineConnectionLoginState extends EngineConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionState.java b/src/main/java/org/spongepowered/api/network/EngineConnectionState.java index 384343fcf8..d8453fcce4 100644 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionState.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionState.java @@ -24,8 +24,12 @@ */ package org.spongepowered.api.network; +import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.profile.GameProfile; + /** - * Represents the current state of the connection. + * Represents the current state of the connection + * on the server or client engine. */ public interface EngineConnectionState { @@ -33,7 +37,56 @@ public interface EngineConnectionState { * Gets whatever the connection was established because * the client was transferred. * - * @return Whatever the client was transferred. + * @return {@code true} if the client was transferred. */ boolean transferred(); + + /** + * Represents the intent state of the connection + * on the server or client engine. + */ + interface Intent extends EngineConnectionState { + } + + /** + * Represents the authenticated state of the connection + * on the server or client engine. + */ + interface Authenticated extends EngineConnectionState { + + /** + * Gets the associated {@link GameProfile profile} for this connection state. + * + * @return The associated profile + */ + GameProfile profile(); + } + + /** + * Represents the login state of the connection + * on the server or client engine. + */ + interface Login extends Authenticated { + } + + /** + * Represents the connection state of the connection + * on the server or client engine. + */ + interface Configuration extends Authenticated { + } + + /** + * Represents the game state of the connection + * on the server or client engine. + */ + interface Game extends Authenticated { + + /** + * Gets the associated {@link Player player} for this connection state. + * + * @return The associated player + */ + Player player(); + } } diff --git a/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java b/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java index 38db53e2d2..f09e9bf10e 100644 --- a/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java +++ b/src/main/java/org/spongepowered/api/network/EngineConnectionStates.java @@ -32,39 +32,54 @@ public final class EngineConnectionStates { /** * The supertype of all the known connection states. */ - public static final Class ALL = EngineConnectionStates.class; + public static final Class ALL = EngineConnectionState.class; - public static final Class INTENT = EngineConnectionIntentState.class; + public static final Class INTENT = EngineConnectionState.Intent.class; - public static final Class LOGIN = EngineConnectionLoginState.class; + /** + * The supertype of all the connection states where the connection is authenticated. + */ + public static final Class AUTHENTICATED = EngineConnectionState.Authenticated.class; + + public static final Class LOGIN = EngineConnectionState.Login.class; - public static final Class CONFIGURATION = EngineConnectionConfigurationState.class; + public static final Class CONFIGURATION = EngineConnectionState.Configuration.class; - public static final Class GAME = EngineConnectionGameState.class; + public static final Class GAME = EngineConnectionState.Game.class; /** * The supertype of all the known client connection states. */ public static final Class CLIENT_SIDE = ClientConnectionState.class; - public static final Class CLIENT_INTENT = ClientConnectionIntentState.class; + public static final Class CLIENT_INTENT = ClientConnectionState.Intent.class; - public static final Class CLIENT_LOGIN = ClientConnectionLoginState.class; + /** + * The supertype of all the connection states where the client is authenticated. + */ + public static final Class CLIENT_AUTHENTICATED = ClientConnectionState.Authenticated.class; - public static final Class CLIENT_CONFIGURATION = ClientConnectionConfigurationState.class; + public static final Class CLIENT_LOGIN = ClientConnectionState.Login.class; - public static final Class CLIENT_GAME = ClientConnectionGameState.class; + public static final Class CLIENT_CONFIGURATION = ClientConnectionState.Configuration.class; + + public static final Class CLIENT_GAME = ClientConnectionState.Game.class; /** * The supertype of all the known server connection states. */ public static final Class SERVER_SIDE = ServerConnectionState.class; - public static final Class SERVER_INTENT = ServerConnectionIntentState.class; + public static final Class SERVER_INTENT = ServerConnectionState.Intent.class; + + /** + * The supertype of all the connection states where the client is authenticated. + */ + public static final Class SERVER_AUTHENTICATED = ServerConnectionState.Authenticated.class; - public static final Class SERVER_LOGIN = ServerConnectionLoginState.class; + public static final Class SERVER_LOGIN = ServerConnectionState.Login.class; - public static final Class SERVER_CONFIGURATION = ServerConnectionConfigurationState.class; + public static final Class SERVER_CONFIGURATION = ServerConnectionState.Configuration.class; - public static final Class SERVER_GAME = ServerConnectionGameState.class; + public static final Class SERVER_GAME = ServerConnectionState.Game.class; } diff --git a/src/main/java/org/spongepowered/api/network/RemoteConnection.java b/src/main/java/org/spongepowered/api/network/RemoteConnection.java index ba4aef19e9..05220251b4 100644 --- a/src/main/java/org/spongepowered/api/network/RemoteConnection.java +++ b/src/main/java/org/spongepowered/api/network/RemoteConnection.java @@ -28,6 +28,13 @@ public interface RemoteConnection { + /*** + * Gets whatever the connection is open. + * + * @return {@code true} if the connection is open. + */ + boolean active(); + /** * Gets the {@link InetSocketAddress} of this connection. * diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java deleted file mode 100644 index 17bf2ce30a..0000000000 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionConfigurationState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ServerConnectionConfigurationState extends EngineConnectionConfigurationState, ServerConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java deleted file mode 100644 index dc2b938381..0000000000 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionGameState.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -import org.spongepowered.api.entity.living.player.server.ServerPlayer; - -public interface ServerConnectionGameState extends EngineConnectionGameState, ServerConnectionState { - - /** - * Gets the associated {@link ServerPlayer player} for this connection state. - * - * @return The associated player - */ - @Override - ServerPlayer player(); - - /** - * Gets the connection latency. This is constantly calculated by the server. - * - * @return The latency - */ - int latency(); -} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java deleted file mode 100644 index fafd555ad0..0000000000 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionIntentState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ServerConnectionIntentState extends EngineConnectionIntentState, ServerConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java deleted file mode 100644 index 44b615ee22..0000000000 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionLoginState.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.network; - -public interface ServerConnectionLoginState extends EngineConnectionLoginState, ServerConnectionState { -} diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java index a2f07b2470..11d299e855 100644 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionState.java +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java @@ -24,5 +24,55 @@ */ package org.spongepowered.api.network; +import org.spongepowered.api.entity.living.player.server.ServerPlayer; + +/** + * Represents a connection state between a minecraft client and server. + */ public interface ServerConnectionState extends EngineConnectionState { + + /** + * Represents a intent state between a minecraft client and server. + */ + interface Intent extends EngineConnectionState.Intent, ServerConnectionState { + } + + /** + * Represents a authenicated state between a minecraft client and server. + */ + interface Authenticated extends EngineConnectionState.Authenticated, ServerConnectionState { + } + + /** + * Represents a login state between a minecraft client and server. + */ + interface Login extends EngineConnectionState.Login, Authenticated { + } + + /** + * Represents a configuration state between a minecraft client and server. + */ + interface Configuration extends EngineConnectionState.Configuration, Authenticated { + } + + /** + * Represents a game state between a minecraft client and server. + */ + interface Game extends EngineConnectionState.Game, Authenticated { + + /** + * Gets the associated {@link ServerPlayer player} for this connection state. + * + * @return The associated player + */ + @Override + ServerPlayer player(); + + /** + * Gets the connection latency. This is constantly calculated by the server. + * + * @return The latency + */ + int latency(); + } } diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/PacketChannel.java b/src/main/java/org/spongepowered/api/network/channel/packet/PacketChannel.java index c326269eaf..6ad9aa3d01 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/PacketChannel.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/PacketChannel.java @@ -31,7 +31,7 @@ /** * Represents an advanced channel binding that sends and receives packets. An * advantage over using a {@link BasicPacketChannel} is that it also supports - * request/response packets. + * request/response packets and the configuration phase. * *

However this channel is NOT compatible with the forge opcode based packet * channels. If you want to remain compatible, use {@link BasicPacketChannel} diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/basic/BasicPacketChannel.java b/src/main/java/org/spongepowered/api/network/channel/packet/basic/BasicPacketChannel.java index c8d64d5fda..d8546db1fa 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/basic/BasicPacketChannel.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/basic/BasicPacketChannel.java @@ -36,6 +36,7 @@ * *

There are a few limitations with using this channel. Request/response * packets may only be used during the handshake phase using {@link #handshake}. + * Packets can't be send during the configuration phase. * Normal packets may only be send during the play phase.

*/ public interface BasicPacketChannel extends Channel, TransactionalPacketRegistry { From ff8cbeb0ce389a54ca4091710f1b7ea61cd38ffa Mon Sep 17 00:00:00 2001 From: aromaa Date: Tue, 14 May 2024 02:30:39 +0300 Subject: [PATCH 11/53] Fix channels --- .../api/network/ServerConnectionState.java | 2 +- .../api/network/channel/Channel.java | 4 +- .../channel/ChannelExceptionHandler.java | 25 ++++---- .../channel/packet/HandlerPacketBinding.java | 39 +++---------- .../network/channel/packet/PacketHandler.java | 10 ++-- .../channel/packet/ResponsePacketHandler.java | 14 ++--- .../packet/TransactionalPacketBinding.java | 57 ++++--------------- .../handshake/RawHandshakeDataChannel.java | 19 ++----- .../RawHandshakeDataRequestHandler.java | 9 +-- .../channel/raw/play/RawPlayDataChannel.java | 35 +++--------- .../channel/raw/play/RawPlayDataHandler.java | 10 ++-- 11 files changed, 71 insertions(+), 153 deletions(-) diff --git a/src/main/java/org/spongepowered/api/network/ServerConnectionState.java b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java index 11d299e855..499c023cde 100644 --- a/src/main/java/org/spongepowered/api/network/ServerConnectionState.java +++ b/src/main/java/org/spongepowered/api/network/ServerConnectionState.java @@ -38,7 +38,7 @@ interface Intent extends EngineConnectionState.Intent, ServerConnectionState { } /** - * Represents a authenicated state between a minecraft client and server. + * Represents an authenicated state between a minecraft client and server. */ interface Authenticated extends EngineConnectionState.Authenticated, ServerConnectionState { } diff --git a/src/main/java/org/spongepowered/api/network/channel/Channel.java b/src/main/java/org/spongepowered/api/network/channel/Channel.java index c2fd17ae23..968cae837d 100644 --- a/src/main/java/org/spongepowered/api/network/channel/Channel.java +++ b/src/main/java/org/spongepowered/api/network/channel/Channel.java @@ -25,7 +25,7 @@ package org.spongepowered.api.network.channel; import org.spongepowered.api.ResourceKey; -import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; /** * Represents a network channel bound to a {@link ChannelManager}. The channel @@ -55,5 +55,5 @@ public interface Channel { * * @param handler The channel exception handler */ - void setExceptionHandler(ChannelExceptionHandler handler); + void setExceptionHandler(ChannelExceptionHandler handler); } diff --git a/src/main/java/org/spongepowered/api/network/channel/ChannelExceptionHandler.java b/src/main/java/org/spongepowered/api/network/channel/ChannelExceptionHandler.java index f952ade14e..b557c7604f 100644 --- a/src/main/java/org/spongepowered/api/network/channel/ChannelExceptionHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/ChannelExceptionHandler.java @@ -27,6 +27,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.spongepowered.api.Sponge; import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; import java.util.Objects; import java.util.concurrent.CompletableFuture; @@ -35,10 +36,10 @@ * Represents a handler for exceptions of {@link Channel}s. This handler * can be implemented by plugin developers. * - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface ChannelExceptionHandler { +public interface ChannelExceptionHandler { /** * Gets the {@link ChannelExceptionHandler} that will always log when a @@ -51,7 +52,7 @@ public interface ChannelExceptionHandler { * * @return The channel exception handler */ - static ChannelExceptionHandler logEverything() { + static ChannelExceptionHandler logEverything() { return Sponge.game().factoryProvider().provide(Factory.class).logEverything(); } @@ -64,12 +65,12 @@ static ChannelExceptionHandler logEverything() { * this one must be completed when an exception occurs. The future is always * null when a request packet is being handled on the other side.

* - * @param connection The connection that the exception occurred for + * @param state The state that the exception occurred for * @param channel The channel the exception occurred on * @param exception The exception the occurred * @param future The future of the send operation or receive operation */ - void handle(C connection, Channel channel, ChannelException exception, @Nullable CompletableFuture future); + void handle(S state, Channel channel, ChannelException exception, @Nullable CompletableFuture future); /** * Returns a new {@link ChannelExceptionHandler} that suppresses every {@link ChannelException} @@ -80,8 +81,8 @@ static ChannelExceptionHandler logEverything() { * * @return The new channel exception handler */ - default ChannelExceptionHandler suppressAllIfFutureIsPresent() { - final ChannelExceptionHandler original = this; + default ChannelExceptionHandler suppressAllIfFutureIsPresent() { + final ChannelExceptionHandler original = this; return (connection, channel, exception, future) -> { if (future != null) { future.completeExceptionally(exception); @@ -102,9 +103,9 @@ default ChannelExceptionHandler suppressAllIfFutureIsPresent() { * @param exceptionType The exception type to suppress * @return The new channel exception handler */ - default ChannelExceptionHandler suppressIfFutureIsPresent(final Class exceptionType) { + default ChannelExceptionHandler suppressIfFutureIsPresent(final Class exceptionType) { Objects.requireNonNull(exceptionType, "exceptionType"); - final ChannelExceptionHandler original = this; + final ChannelExceptionHandler original = this; return (connection, channel, exception, future) -> { if (future != null && exceptionType.isInstance(exception)) { future.completeExceptionally(exception); @@ -127,9 +128,9 @@ default ChannelExceptionHandler suppressIfFutureIsPresent(final Class suppress(final Class exceptionType) { + default ChannelExceptionHandler suppress(final Class exceptionType) { Objects.requireNonNull(exceptionType, "exceptionType"); - final ChannelExceptionHandler original = this; + final ChannelExceptionHandler original = this; return (connection, channel, exception, future) -> { if (exceptionType.isInstance(exception)) { if (future != null) { @@ -143,6 +144,6 @@ default ChannelExceptionHandler suppress(final Class logEverything(); + ChannelExceptionHandler logEverything(); } } diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/HandlerPacketBinding.java b/src/main/java/org/spongepowered/api/network/channel/packet/HandlerPacketBinding.java index a8fd014ed7..15c17b4746 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/HandlerPacketBinding.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/HandlerPacketBinding.java @@ -24,8 +24,7 @@ */ package org.spongepowered.api.network.channel.packet; -import org.spongepowered.api.network.EngineConnection; -import org.spongepowered.api.network.EngineConnectionSide; +import org.spongepowered.api.network.EngineConnectionState; /** * A packet binding that allows the registration of {@link PacketHandler}s. @@ -34,29 +33,17 @@ */ public interface HandlerPacketBinding

extends PacketBinding

{ - /** - * Adds a {@link PacketHandler} to handle the packets of type - * {@link P}. The handler is invoked every time the packet is - * sent to the given side. - * - * @param side The side the handler should be used on - * @param handler The handler to add - * @param The connection type - * @return This binding, for chaining - */ - PacketBinding

addHandler(EngineConnectionSide side, PacketHandler handler); - /** * Adds a {@link PacketHandler} to handle the packets of type * {@link P}. The handler is invoked every time the packet is * received by the given connection type. * - * @param connectionType The connection type the handler should be used by + * @param connectionState The connection type the handler should be used by * @param handler The handler to add - * @param The connection type + * @param The connection state * @return This binding, for chaining */ - PacketBinding

addHandler(Class connectionType, PacketHandler handler); + PacketBinding

addHandler(Class connectionState, PacketHandler handler); /** * Adds a {@link PacketHandler} to handle the packets of type @@ -66,27 +53,17 @@ public interface HandlerPacketBinding

extends PacketBinding

* @param handler The handler to add * @return This binding, for chaining */ - PacketBinding

addHandler(PacketHandler handler); - - /** - * Removes the {@link PacketHandler} for the given side. - * - * @param side The side the handler should be removes from - * @param handler The handler to remove - * @param The connection type - * @return This binding, for chaining - */ - PacketBinding

removeHandler(EngineConnectionSide side, PacketHandler handler); + PacketBinding

addHandler(PacketHandler handler); /** * Removes the {@link PacketHandler} for the given connection type. * - * @param connectionType The connection type the handler should be removes from + * @param connectionState The connection state the handler should be removes from * @param handler The handler to remove - * @param The connection type + * @param The connection state * @return This binding, for chaining */ - PacketBinding

removeHandler(Class connectionType, PacketHandler handler); + PacketBinding

removeHandler(Class connectionState, PacketHandler handler); /** * Removes the {@link PacketHandler}. diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/PacketHandler.java b/src/main/java/org/spongepowered/api/network/channel/packet/PacketHandler.java index 153f5bb479..78b0c15855 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/PacketHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/PacketHandler.java @@ -24,21 +24,21 @@ */ package org.spongepowered.api.network.channel.packet; -import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; /** * Represents a handler for a packet that was received over the network. * - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface PacketHandler

{ +public interface PacketHandler

{ /** * Handles the {@link Packet} sent by a remote connection. * * @param packet The packet received - * @param connection The connection that sent the packet + * @param state The state that sent the packet */ - void handle(P packet, C connection); + void handle(P packet, S state); } diff --git a/src/main/java/org/spongepowered/api/network/channel/packet/ResponsePacketHandler.java b/src/main/java/org/spongepowered/api/network/channel/packet/ResponsePacketHandler.java index 4365aa775a..9afc7a64bc 100644 --- a/src/main/java/org/spongepowered/api/network/channel/packet/ResponsePacketHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/packet/ResponsePacketHandler.java @@ -24,7 +24,7 @@ */ package org.spongepowered.api.network.channel.packet; -import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.channel.ChannelException; import org.spongepowered.api.network.channel.NoResponseException; @@ -33,19 +33,19 @@ * * @param

The type of the request packet * @param The type of the response packet - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface ResponsePacketHandler

{ +public interface ResponsePacketHandler

{ /** * Handles the response {@link Packet} sent by a client connection. * * @param responsePacket The response packet that was received * @param requestPacket The packet that was send to request the response - * @param connection The connection that sent the packet + * @param state The state that sent the packet */ - void handleResponse(R responsePacket, P requestPacket, C connection); + void handleResponse(R responsePacket, P requestPacket, S state); /** * Handles the failure of a response {@link Packet}. The {@link ChannelException} which @@ -54,8 +54,8 @@ public interface ResponsePacketHandler

, R extend * for a specific connection type. The difference with a normal {@link PacketHandler} * is that it requires a response {@link Packet} as return value. * - * @param connectionType The connection type the request packet should be handled by + * @param connectionState The connection state the request packet should be handled by * @param handler The handler of the request packet * @param The connection state * @return This packet binding, for chaining */ TransactionalPacketBinding setRequestHandler( - Class connectionType, RequestPacketHandler handler); + Class connectionState, RequestPacketHandler handler); /** * Sets the {@link RequestPacketHandler} to handle a {@link RequestPacket} @@ -83,22 +82,6 @@ TransactionalPacketBinding setRequestHan */ TransactionalPacketBinding setRequestHandler(RequestPacketHandler handler); - /** - * Adds a {@link PacketHandler} to handle a response {@link Packet} - * on a specific connection side. - * - *

Binding a response {@link PacketHandler} is completely optional. It is also - * possible to append a handler to the {@link CompletableFuture} returned by - * {@link PacketChannel#sendTo(EngineConnection, RequestPacket)}.

- * - * @param side The side the response packet should be handled on - * @param handler The handler of the response packet - * @param The connection type - * @return This packet binding, for chaining - */ - TransactionalPacketBinding addResponseHandler( - EngineConnectionSide side, PacketHandler handler); - /** * Adds a {@link PacketHandler} to handle a response {@link Packet} * on for a specific connection type. @@ -107,29 +90,13 @@ TransactionalPacketBinding addResponseHandler * possible to append a handler to the {@link CompletableFuture} returned by * {@link PacketChannel#sendTo(EngineConnection, RequestPacket)}.

* - * @param connectionType The connection type the response packet should be handled by + * @param connectionState The connection state the response packet should be handled by * @param responseHandler The handler of the response packet - * @param The connection type - * @return This packet binding, for chaining - */ - TransactionalPacketBinding addResponseHandler( - Class connectionType, PacketHandler responseHandler); - - /** - * Adds a {@link ResponsePacketHandler} to handle a response {@link Packet} - * on a specific connection side. - * - *

Binding a response {@link PacketHandler} is completely optional. It is also - * possible to append a handler to the {@link CompletableFuture} returned by - * {@link PacketChannel#sendTo(EngineConnection, RequestPacket)}.

- * - * @param side The side the response packet should be handled on - * @param handler The handler of the response packet - * @param The connection type + * @param The connection state * @return This packet binding, for chaining */ - TransactionalPacketBinding addResponseHandler( - EngineConnectionSide side, ResponsePacketHandler handler); + TransactionalPacketBinding addResponseHandler( + Class connectionState, PacketHandler responseHandler); /** * Adds a {@link ResponsePacketHandler} to handle a response {@link Packet} @@ -139,13 +106,13 @@ TransactionalPacketBinding addResponseHandler * possible to append a handler to the {@link CompletableFuture} returned by * {@link PacketChannel#sendTo(EngineConnection, RequestPacket)}.

* - * @param connectionType The connection type the response packet should be handled by + * @param connectionState The connection state the response packet should be handled by * @param handler The handler of the response packet - * @param The connection type + * @param The connection state * @return This packet binding, for chaining */ - TransactionalPacketBinding addResponseHandler( - Class connectionType, ResponsePacketHandler handler); + TransactionalPacketBinding addResponseHandler( + Class connectionState, ResponsePacketHandler handler); /** * Adds a {@link PacketHandler} to handle a response {@link Packet} on both platform sides. @@ -157,7 +124,7 @@ TransactionalPacketBinding addResponseHandler * @param handler The handler of the response packet * @return This packet binding, for chaining */ - TransactionalPacketBinding addResponseHandler(PacketHandler handler); + TransactionalPacketBinding addResponseHandler(PacketHandler handler); /** * Adds a {@link ResponsePacketHandler} to handle a response {@link Packet} @@ -170,5 +137,5 @@ TransactionalPacketBinding addResponseHandler * @param handler The handler of the response packet * @return This packet binding, for chaining */ - TransactionalPacketBinding addResponseHandler(ResponsePacketHandler handler); + TransactionalPacketBinding addResponseHandler(ResponsePacketHandler handler); } diff --git a/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataChannel.java b/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataChannel.java index f14d1ace87..914d8138e3 100644 --- a/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataChannel.java +++ b/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataChannel.java @@ -25,7 +25,7 @@ package org.spongepowered.api.network.channel.raw.handshake; import org.spongepowered.api.network.EngineConnection; -import org.spongepowered.api.network.EngineConnectionSide; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.channel.ChannelBuf; import org.spongepowered.api.network.channel.NoResponseException; import org.spongepowered.api.network.channel.raw.RawDataChannel; @@ -46,23 +46,14 @@ public interface RawHandshakeDataChannel { */ RawDataChannel parent(); - /** - * Sets the {@link RawHandshakeDataRequestHandler} on the given connection side. - * - * @param side The connection side the handler should be set on - * @param handler The handler to set - * @param The connection type - */ - void setRequestHandler(EngineConnectionSide side, RawHandshakeDataRequestHandler handler); - /** * Sets the {@link RawHandshakeDataRequestHandler} for the given connection type. * - * @param connectionType The connection type the handler should be used by + * @param connectionState The connection state the handler should be used by * @param handler The handler to set - * @param The connection type + * @param The connection state */ - void setRequestHandler(Class connectionType, RawHandshakeDataRequestHandler handler); + void setRequestHandler(Class connectionState, RawHandshakeDataRequestHandler handler); /** * Sets the {@link RawHandshakeDataRequestHandler} on the @@ -70,7 +61,7 @@ public interface RawHandshakeDataChannel { * * @param handler The handler to set */ - void setRequestHandler(RawHandshakeDataRequestHandler handler); + void setRequestHandler(RawHandshakeDataRequestHandler handler); /** * Sends a request message {@link ChannelBuf} to diff --git a/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataRequestHandler.java b/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataRequestHandler.java index 898ecb7a6f..d200dae08a 100644 --- a/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataRequestHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/raw/handshake/RawHandshakeDataRequestHandler.java @@ -25,16 +25,17 @@ package org.spongepowered.api.network.channel.raw.handshake; import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.channel.ChannelBuf; import org.spongepowered.api.network.channel.NoResponseException; /** * Handles a raw handshake data request. * - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface RawHandshakeDataRequestHandler { +public interface RawHandshakeDataRequestHandler { /** * Handles the request data {@link ChannelBuf} for the given @@ -50,8 +51,8 @@ public interface RawHandshakeDataRequestHandler { * take minutes.

* * @param request The request channel buf - * @param connection The connection that received the request data + * @param state The state that received the request data * @param response The response which should be completed */ - void handleRequest(ChannelBuf request, C connection, RawHandshakeDataRequestResponse response); + void handleRequest(ChannelBuf request, S state, RawHandshakeDataRequestResponse response); } diff --git a/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataChannel.java b/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataChannel.java index b34fa2da43..4f0a52be09 100644 --- a/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataChannel.java +++ b/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataChannel.java @@ -27,7 +27,7 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.api.network.EngineConnection; -import org.spongepowered.api.network.EngineConnectionSide; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.channel.ChannelBuf; import org.spongepowered.api.network.channel.packet.Packet; import org.spongepowered.api.network.channel.packet.PacketChannel; @@ -71,45 +71,26 @@ public interface RawPlayDataChannel { * * @param handler The handler */ - void addHandler(RawPlayDataHandler handler); + void addHandler(RawPlayDataHandler handler); /** * Adds a listener to this channel that is invoked every time data is * sent to it on the given connection side. * - * @param side The connection side the data will be handled for + * @param connectionState The connection state the data will be handled for * @param handler The handler - * @param The connection type + * @param The connection state */ - void addHandler(EngineConnectionSide side, RawPlayDataHandler handler); - - /** - * Adds a listener to this channel that is invoked every time data is - * sent to it on the given connection side. - * - * @param connectionType The connection type the data will be handled for - * @param handler The handler - * @param The connection type - */ - void addHandler(Class connectionType, RawPlayDataHandler handler); - - /** - * Removes the handler from handling data. - * - * @param side The side to remove the handler from - * @param handler The handler - * @param The connection type - */ - void removeHandler(EngineConnectionSide side, RawPlayDataHandler handler); + void addHandler(Class connectionState, RawPlayDataHandler handler); /** * Removes the handler from handling data. * - * @param connectionType The connection type to remove the handler from + * @param connectionState The connection state to remove the handler from * @param handler The handler - * @param The connection type + * @param The connection state */ - void removeHandler(Class connectionType, RawPlayDataHandler handler); + void removeHandler(Class connectionState, RawPlayDataHandler handler); /** * Removes the handler from handling data. diff --git a/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataHandler.java b/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataHandler.java index f2cc50f38f..81bbe219f1 100644 --- a/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataHandler.java +++ b/src/main/java/org/spongepowered/api/network/channel/raw/play/RawPlayDataHandler.java @@ -24,22 +24,22 @@ */ package org.spongepowered.api.network.channel.raw.play; -import org.spongepowered.api.network.EngineConnection; +import org.spongepowered.api.network.EngineConnectionState; import org.spongepowered.api.network.channel.ChannelBuf; /** * Represents a listener for data being sent to a raw channel. * - * @param The connection type + * @param The connection state */ @FunctionalInterface -public interface RawPlayDataHandler { +public interface RawPlayDataHandler { /** * Handles the given {@link ChannelBuf} data sent by a remote connection. * * @param data The raw data - * @param connection The remote connection + * @param state The remote state */ - void handlePayload(ChannelBuf data, C connection); + void handlePayload(ChannelBuf data, S state); } From 21f97a218f0a14f7ce8fa7b9dd8f160701aa255b Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Tue, 14 May 2024 22:17:19 +0200 Subject: [PATCH 12/53] Fix BannerPatternLater builder methods --- .../org/spongepowered/api/data/meta/BannerPatternLayer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java b/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java index 912e4e52ba..8e07713f08 100644 --- a/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java +++ b/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java @@ -31,6 +31,7 @@ import org.spongepowered.api.data.type.BannerPatternShape; import org.spongepowered.api.data.type.DyeColor; import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.RegistryReference; import org.spongepowered.api.util.CopyableBuilder; import java.util.function.Supplier; @@ -48,7 +49,7 @@ public interface BannerPatternLayer extends DataSerializable { * @param color The color * @return The new pattern layer */ - static BannerPatternLayer of(Supplier shape, DefaultedRegistryReference color) { + static BannerPatternLayer of(RegistryReference shape, DefaultedRegistryReference color) { return BannerPatternLayer.of(shape.get(), color.get()); } @@ -60,7 +61,7 @@ static BannerPatternLayer of(Supplier shape, Defau * @param color The color * @return The new pattern layer */ - static BannerPatternLayer of(Supplier shape, DyeColor color) { + static BannerPatternLayer of(RegistryReference shape, DyeColor color) { return BannerPatternLayer.of(shape.get(), color); } From e46968716d90be76a49dd5662d641e2458585ffa Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Tue, 14 May 2024 22:17:57 +0200 Subject: [PATCH 13/53] Generate API data --- .../criteria/trigger/Triggers.java | 8 + .../spongepowered/api/block/BlockTypes.java | 4 + .../api/block/entity/BlockEntityTypes.java | 2 + .../api/data/type/ArmorMaterials.java | 16 +- .../api/data/type/BannerPatternShapes.java | 96 ++++++------ .../api/effect/particle/ParticleOptions.java | 1 - .../api/effect/particle/ParticleTypes.java | 24 ++- .../api/effect/potion/PotionEffectTypes.java | 12 ++ .../api/effect/sound/SoundTypes.java | 140 +++++++++++++++++- .../entity/attribute/type/AttributeTypes.java | 18 ++- .../cause/entity/damage/DamageTypes.java | 2 + .../org/spongepowered/api/item/ItemTypes.java | 40 ++++- .../item/enchantment/EnchantmentTypes.java | 13 +- .../api/item/potion/PotionTypes.java | 10 +- .../api/state/BooleanStateProperties.java | 4 + .../api/state/EnumStateProperties.java | 4 + .../spongepowered/api/tag/BlockTypeTags.java | 18 +++ .../spongepowered/api/tag/DamageTypeTags.java | 4 + .../spongepowered/api/tag/EntityTypeTags.java | 24 +++ .../spongepowered/api/tag/ItemTypeTags.java | 102 ++++++++++++- .../api/world/gamerule/GameRules.java | 2 + 21 files changed, 468 insertions(+), 76 deletions(-) diff --git a/src/main/java/org/spongepowered/api/advancement/criteria/trigger/Triggers.java b/src/main/java/org/spongepowered/api/advancement/criteria/trigger/Triggers.java index 5060b9e963..e24f0e4e32 100644 --- a/src/main/java/org/spongepowered/api/advancement/criteria/trigger/Triggers.java +++ b/src/main/java/org/spongepowered/api/advancement/criteria/trigger/Triggers.java @@ -42,6 +42,8 @@ public final class Triggers { public static final DefaultedRegistryReference> ALLAY_DROP_ITEM_ON_BLOCK = Triggers.key(ResourceKey.minecraft("allay_drop_item_on_block")); + public static final DefaultedRegistryReference> ANY_BLOCK_USE = Triggers.key(ResourceKey.minecraft("any_block_use")); + public static final DefaultedRegistryReference> AVOID_VIBRATION = Triggers.key(ResourceKey.minecraft("avoid_vibration")); public static final DefaultedRegistryReference> BEE_NEST_DESTROYED = Triggers.key(ResourceKey.minecraft("bee_nest_destroyed")); @@ -58,8 +60,12 @@ public final class Triggers { public static final DefaultedRegistryReference> CONSUME_ITEM = Triggers.key(ResourceKey.minecraft("consume_item")); + public static final DefaultedRegistryReference> CRAFTER_RECIPE_CRAFTED = Triggers.key(ResourceKey.minecraft("crafter_recipe_crafted")); + public static final DefaultedRegistryReference> CURED_ZOMBIE_VILLAGER = Triggers.key(ResourceKey.minecraft("cured_zombie_villager")); + public static final DefaultedRegistryReference> DEFAULT_BLOCK_USE = Triggers.key(ResourceKey.minecraft("default_block_use")); + public static final DefaultedRegistryReference> EFFECTS_CHANGED = Triggers.key(ResourceKey.minecraft("effects_changed")); public static final DefaultedRegistryReference> ENCHANTED_ITEM = Triggers.key(ResourceKey.minecraft("enchanted_item")); @@ -70,6 +76,8 @@ public final class Triggers { public static final DefaultedRegistryReference> ENTITY_KILLED_PLAYER = Triggers.key(ResourceKey.minecraft("entity_killed_player")); + public static final DefaultedRegistryReference> FALL_AFTER_EXPLOSION = Triggers.key(ResourceKey.minecraft("fall_after_explosion")); + public static final DefaultedRegistryReference> FALL_FROM_HEIGHT = Triggers.key(ResourceKey.minecraft("fall_from_height")); public static final DefaultedRegistryReference> FILLED_BUCKET = Triggers.key(ResourceKey.minecraft("filled_bucket")); diff --git a/src/main/java/org/spongepowered/api/block/BlockTypes.java b/src/main/java/org/spongepowered/api/block/BlockTypes.java index 4be86c22e8..cde1c5aabf 100644 --- a/src/main/java/org/spongepowered/api/block/BlockTypes.java +++ b/src/main/java/org/spongepowered/api/block/BlockTypes.java @@ -896,6 +896,8 @@ public final class BlockTypes { public static final DefaultedRegistryReference HAY_BLOCK = BlockTypes.key(ResourceKey.minecraft("hay_block")); + public static final DefaultedRegistryReference HEAVY_CORE = BlockTypes.key(ResourceKey.minecraft("heavy_core")); + public static final DefaultedRegistryReference HEAVY_WEIGHTED_PRESSURE_PLATE = BlockTypes.key(ResourceKey.minecraft("heavy_weighted_pressure_plate")); public static final DefaultedRegistryReference HONEY_BLOCK = BlockTypes.key(ResourceKey.minecraft("honey_block")); @@ -1940,6 +1942,8 @@ public final class BlockTypes { public static final DefaultedRegistryReference TWISTING_VINES_PLANT = BlockTypes.key(ResourceKey.minecraft("twisting_vines_plant")); + public static final DefaultedRegistryReference VAULT = BlockTypes.key(ResourceKey.minecraft("vault")); + public static final DefaultedRegistryReference VERDANT_FROGLIGHT = BlockTypes.key(ResourceKey.minecraft("verdant_froglight")); public static final DefaultedRegistryReference VINE = BlockTypes.key(ResourceKey.minecraft("vine")); diff --git a/src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java b/src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java index a768ed3d17..9d1cf49f8a 100644 --- a/src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java +++ b/src/main/java/org/spongepowered/api/block/entity/BlockEntityTypes.java @@ -126,6 +126,8 @@ public final class BlockEntityTypes { public static final DefaultedRegistryReference TRIAL_SPAWNER = BlockEntityTypes.key(ResourceKey.minecraft("trial_spawner")); + public static final DefaultedRegistryReference VAULT = BlockEntityTypes.key(ResourceKey.minecraft("vault")); + private BlockEntityTypes() { } diff --git a/src/main/java/org/spongepowered/api/data/type/ArmorMaterials.java b/src/main/java/org/spongepowered/api/data/type/ArmorMaterials.java index 1a0d0f0dd6..64170a17a4 100644 --- a/src/main/java/org/spongepowered/api/data/type/ArmorMaterials.java +++ b/src/main/java/org/spongepowered/api/data/type/ArmorMaterials.java @@ -40,19 +40,21 @@ @RegistryScopes(scopes = RegistryScope.GAME) public final class ArmorMaterials { - public static final DefaultedRegistryReference CHAINMAIL = ArmorMaterials.key(ResourceKey.sponge("chainmail")); + public static final DefaultedRegistryReference ARMADILLO = ArmorMaterials.key(ResourceKey.minecraft("armadillo")); - public static final DefaultedRegistryReference DIAMOND = ArmorMaterials.key(ResourceKey.sponge("diamond")); + public static final DefaultedRegistryReference CHAINMAIL = ArmorMaterials.key(ResourceKey.minecraft("chainmail")); - public static final DefaultedRegistryReference GOLD = ArmorMaterials.key(ResourceKey.sponge("gold")); + public static final DefaultedRegistryReference DIAMOND = ArmorMaterials.key(ResourceKey.minecraft("diamond")); - public static final DefaultedRegistryReference IRON = ArmorMaterials.key(ResourceKey.sponge("iron")); + public static final DefaultedRegistryReference GOLD = ArmorMaterials.key(ResourceKey.minecraft("gold")); - public static final DefaultedRegistryReference LEATHER = ArmorMaterials.key(ResourceKey.sponge("leather")); + public static final DefaultedRegistryReference IRON = ArmorMaterials.key(ResourceKey.minecraft("iron")); - public static final DefaultedRegistryReference NETHERITE = ArmorMaterials.key(ResourceKey.sponge("netherite")); + public static final DefaultedRegistryReference LEATHER = ArmorMaterials.key(ResourceKey.minecraft("leather")); - public static final DefaultedRegistryReference TURTLE = ArmorMaterials.key(ResourceKey.sponge("turtle")); + public static final DefaultedRegistryReference NETHERITE = ArmorMaterials.key(ResourceKey.minecraft("netherite")); + + public static final DefaultedRegistryReference TURTLE = ArmorMaterials.key(ResourceKey.minecraft("turtle")); private ArmorMaterials() { } diff --git a/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java b/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java index b85746c74f..741b48f5e6 100644 --- a/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java +++ b/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java @@ -25,111 +25,111 @@ package org.spongepowered.api.data.type; import org.spongepowered.api.ResourceKey; -import org.spongepowered.api.Sponge; -import org.spongepowered.api.registry.DefaultedRegistryReference; import org.spongepowered.api.registry.Registry; import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryReference; import org.spongepowered.api.registry.RegistryScope; import org.spongepowered.api.registry.RegistryScopes; import org.spongepowered.api.registry.RegistryTypes; +import org.spongepowered.api.world.server.ServerWorld; /** * */ @SuppressWarnings("unused") -@RegistryScopes(scopes = RegistryScope.GAME) +@RegistryScopes(scopes = RegistryScope.WORLD) public final class BannerPatternShapes { - public static final DefaultedRegistryReference BASE = BannerPatternShapes.key(ResourceKey.minecraft("base")); + public static final RegistryReference BASE = BannerPatternShapes.key(ResourceKey.minecraft("base")); - public static final DefaultedRegistryReference BORDER = BannerPatternShapes.key(ResourceKey.minecraft("border")); + public static final RegistryReference BORDER = BannerPatternShapes.key(ResourceKey.minecraft("border")); - public static final DefaultedRegistryReference BRICKS = BannerPatternShapes.key(ResourceKey.minecraft("bricks")); + public static final RegistryReference BRICKS = BannerPatternShapes.key(ResourceKey.minecraft("bricks")); - public static final DefaultedRegistryReference CIRCLE = BannerPatternShapes.key(ResourceKey.minecraft("circle")); + public static final RegistryReference CIRCLE = BannerPatternShapes.key(ResourceKey.minecraft("circle")); - public static final DefaultedRegistryReference CREEPER = BannerPatternShapes.key(ResourceKey.minecraft("creeper")); + public static final RegistryReference CREEPER = BannerPatternShapes.key(ResourceKey.minecraft("creeper")); - public static final DefaultedRegistryReference CROSS = BannerPatternShapes.key(ResourceKey.minecraft("cross")); + public static final RegistryReference CROSS = BannerPatternShapes.key(ResourceKey.minecraft("cross")); - public static final DefaultedRegistryReference CURLY_BORDER = BannerPatternShapes.key(ResourceKey.minecraft("curly_border")); + public static final RegistryReference CURLY_BORDER = BannerPatternShapes.key(ResourceKey.minecraft("curly_border")); - public static final DefaultedRegistryReference DIAGONAL_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_left")); + public static final RegistryReference DIAGONAL_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_left")); - public static final DefaultedRegistryReference DIAGONAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_right")); + public static final RegistryReference DIAGONAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_right")); - public static final DefaultedRegistryReference DIAGONAL_UP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_left")); + public static final RegistryReference DIAGONAL_UP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_left")); - public static final DefaultedRegistryReference DIAGONAL_UP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_right")); + public static final RegistryReference DIAGONAL_UP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_right")); - public static final DefaultedRegistryReference FLOWER = BannerPatternShapes.key(ResourceKey.minecraft("flower")); + public static final RegistryReference FLOWER = BannerPatternShapes.key(ResourceKey.minecraft("flower")); - public static final DefaultedRegistryReference GLOBE = BannerPatternShapes.key(ResourceKey.minecraft("globe")); + public static final RegistryReference GLOBE = BannerPatternShapes.key(ResourceKey.minecraft("globe")); - public static final DefaultedRegistryReference GRADIENT = BannerPatternShapes.key(ResourceKey.minecraft("gradient")); + public static final RegistryReference GRADIENT = BannerPatternShapes.key(ResourceKey.minecraft("gradient")); - public static final DefaultedRegistryReference GRADIENT_UP = BannerPatternShapes.key(ResourceKey.minecraft("gradient_up")); + public static final RegistryReference GRADIENT_UP = BannerPatternShapes.key(ResourceKey.minecraft("gradient_up")); - public static final DefaultedRegistryReference HALF_HORIZONTAL = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal")); + public static final RegistryReference HALF_HORIZONTAL = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal")); - public static final DefaultedRegistryReference HALF_HORIZONTAL_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal_bottom")); + public static final RegistryReference HALF_HORIZONTAL_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal_bottom")); - public static final DefaultedRegistryReference HALF_VERTICAL = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical")); + public static final RegistryReference HALF_VERTICAL = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical")); - public static final DefaultedRegistryReference HALF_VERTICAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical_right")); + public static final RegistryReference HALF_VERTICAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical_right")); - public static final DefaultedRegistryReference MOJANG = BannerPatternShapes.key(ResourceKey.minecraft("mojang")); + public static final RegistryReference MOJANG = BannerPatternShapes.key(ResourceKey.minecraft("mojang")); - public static final DefaultedRegistryReference PIGLIN = BannerPatternShapes.key(ResourceKey.minecraft("piglin")); + public static final RegistryReference PIGLIN = BannerPatternShapes.key(ResourceKey.minecraft("piglin")); - public static final DefaultedRegistryReference RHOMBUS = BannerPatternShapes.key(ResourceKey.minecraft("rhombus")); + public static final RegistryReference RHOMBUS = BannerPatternShapes.key(ResourceKey.minecraft("rhombus")); - public static final DefaultedRegistryReference SKULL = BannerPatternShapes.key(ResourceKey.minecraft("skull")); + public static final RegistryReference SKULL = BannerPatternShapes.key(ResourceKey.minecraft("skull")); - public static final DefaultedRegistryReference SMALL_STRIPES = BannerPatternShapes.key(ResourceKey.minecraft("small_stripes")); + public static final RegistryReference SMALL_STRIPES = BannerPatternShapes.key(ResourceKey.minecraft("small_stripes")); - public static final DefaultedRegistryReference SQUARE_BOTTOM_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_left")); + public static final RegistryReference SQUARE_BOTTOM_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_left")); - public static final DefaultedRegistryReference SQUARE_BOTTOM_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_right")); + public static final RegistryReference SQUARE_BOTTOM_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_right")); - public static final DefaultedRegistryReference SQUARE_TOP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_left")); + public static final RegistryReference SQUARE_TOP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_left")); - public static final DefaultedRegistryReference SQUARE_TOP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_right")); + public static final RegistryReference SQUARE_TOP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_right")); - public static final DefaultedRegistryReference STRAIGHT_CROSS = BannerPatternShapes.key(ResourceKey.minecraft("straight_cross")); + public static final RegistryReference STRAIGHT_CROSS = BannerPatternShapes.key(ResourceKey.minecraft("straight_cross")); - public static final DefaultedRegistryReference STRIPE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("stripe_bottom")); + public static final RegistryReference STRIPE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("stripe_bottom")); - public static final DefaultedRegistryReference STRIPE_CENTER = BannerPatternShapes.key(ResourceKey.minecraft("stripe_center")); + public static final RegistryReference STRIPE_CENTER = BannerPatternShapes.key(ResourceKey.minecraft("stripe_center")); - public static final DefaultedRegistryReference STRIPE_DOWNLEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downleft")); + public static final RegistryReference STRIPE_DOWNLEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downleft")); - public static final DefaultedRegistryReference STRIPE_DOWNRIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downright")); + public static final RegistryReference STRIPE_DOWNRIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downright")); - public static final DefaultedRegistryReference STRIPE_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_left")); + public static final RegistryReference STRIPE_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_left")); - public static final DefaultedRegistryReference STRIPE_MIDDLE = BannerPatternShapes.key(ResourceKey.minecraft("stripe_middle")); + public static final RegistryReference STRIPE_MIDDLE = BannerPatternShapes.key(ResourceKey.minecraft("stripe_middle")); - public static final DefaultedRegistryReference STRIPE_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_right")); + public static final RegistryReference STRIPE_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_right")); - public static final DefaultedRegistryReference STRIPE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("stripe_top")); + public static final RegistryReference STRIPE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("stripe_top")); - public static final DefaultedRegistryReference TRIANGLE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangle_bottom")); + public static final RegistryReference TRIANGLE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangle_bottom")); - public static final DefaultedRegistryReference TRIANGLE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangle_top")); + public static final RegistryReference TRIANGLE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangle_top")); - public static final DefaultedRegistryReference TRIANGLES_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangles_bottom")); + public static final RegistryReference TRIANGLES_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangles_bottom")); - public static final DefaultedRegistryReference TRIANGLES_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangles_top")); + public static final RegistryReference TRIANGLES_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangles_top")); private BannerPatternShapes() { } - public static Registry registry() { - return Sponge.game().registry(RegistryTypes.BANNER_PATTERN_SHAPE); + public static Registry registry(final ServerWorld world) { + return world.registry(RegistryTypes.BANNER_PATTERN_SHAPE); } - private static DefaultedRegistryReference key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asDefaultedReference(Sponge::game); + private static RegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asReference(); } } diff --git a/src/main/java/org/spongepowered/api/effect/particle/ParticleOptions.java b/src/main/java/org/spongepowered/api/effect/particle/ParticleOptions.java index f7debab78e..36f8859c20 100644 --- a/src/main/java/org/spongepowered/api/effect/particle/ParticleOptions.java +++ b/src/main/java/org/spongepowered/api/effect/particle/ParticleOptions.java @@ -68,7 +68,6 @@ public final class ParticleOptions { * {@link ParticleType}s this option is applicable to are: * *
    - *
  • {@link ParticleTypes#AMBIENT_ENTITY_EFFECT}
  • *
  • {@link ParticleTypes#ENTITY_EFFECT}
  • *
  • {@link ParticleTypes#DUST}
  • *
diff --git a/src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java b/src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java index 369074ea39..06fa3d1930 100644 --- a/src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java +++ b/src/main/java/org/spongepowered/api/effect/particle/ParticleTypes.java @@ -40,8 +40,6 @@ @RegistryScopes(scopes = RegistryScope.GAME) public final class ParticleTypes { - public static final DefaultedRegistryReference AMBIENT_ENTITY_EFFECT = ParticleTypes.key(ResourceKey.minecraft("ambient_entity_effect")); - public static final DefaultedRegistryReference ANGRY_VILLAGER = ParticleTypes.key(ResourceKey.minecraft("angry_villager")); public static final DefaultedRegistryReference ASH = ParticleTypes.key(ResourceKey.minecraft("ash")); @@ -94,6 +92,8 @@ public final class ParticleTypes { public static final DefaultedRegistryReference DUST_COLOR_TRANSITION = ParticleTypes.key(ResourceKey.minecraft("dust_color_transition")); + public static final DefaultedRegistryReference DUST_PILLAR = ParticleTypes.key(ResourceKey.minecraft("dust_pillar")); + public static final DefaultedRegistryReference DUST_PLUME = ParticleTypes.key(ResourceKey.minecraft("dust_plume")); public static final DefaultedRegistryReference EFFECT = ParticleTypes.key(ResourceKey.minecraft("effect")); @@ -148,18 +148,22 @@ public final class ParticleTypes { public static final DefaultedRegistryReference GUST = ParticleTypes.key(ResourceKey.minecraft("gust")); - public static final DefaultedRegistryReference GUST_DUST = ParticleTypes.key(ResourceKey.minecraft("gust_dust")); + public static final DefaultedRegistryReference GUST_EMITTER_LARGE = ParticleTypes.key(ResourceKey.minecraft("gust_emitter_large")); - public static final DefaultedRegistryReference GUST_EMITTER = ParticleTypes.key(ResourceKey.minecraft("gust_emitter")); + public static final DefaultedRegistryReference GUST_EMITTER_SMALL = ParticleTypes.key(ResourceKey.minecraft("gust_emitter_small")); public static final DefaultedRegistryReference HAPPY_VILLAGER = ParticleTypes.key(ResourceKey.minecraft("happy_villager")); public static final DefaultedRegistryReference HEART = ParticleTypes.key(ResourceKey.minecraft("heart")); + public static final DefaultedRegistryReference INFESTED = ParticleTypes.key(ResourceKey.minecraft("infested")); + public static final DefaultedRegistryReference INSTANT_EFFECT = ParticleTypes.key(ResourceKey.minecraft("instant_effect")); public static final DefaultedRegistryReference ITEM = ParticleTypes.key(ResourceKey.minecraft("item")); + public static final DefaultedRegistryReference ITEM_COBWEB = ParticleTypes.key(ResourceKey.minecraft("item_cobweb")); + public static final DefaultedRegistryReference ITEM_SLIME = ParticleTypes.key(ResourceKey.minecraft("item_slime")); public static final DefaultedRegistryReference ITEM_SNOWBALL = ParticleTypes.key(ResourceKey.minecraft("item_snowball")); @@ -180,10 +184,14 @@ public final class ParticleTypes { public static final DefaultedRegistryReference NOTE = ParticleTypes.key(ResourceKey.minecraft("note")); + public static final DefaultedRegistryReference OMINOUS_SPAWNING = ParticleTypes.key(ResourceKey.minecraft("ominous_spawning")); + public static final DefaultedRegistryReference POOF = ParticleTypes.key(ResourceKey.minecraft("poof")); public static final DefaultedRegistryReference PORTAL = ParticleTypes.key(ResourceKey.minecraft("portal")); + public static final DefaultedRegistryReference RAID_OMEN = ParticleTypes.key(ResourceKey.minecraft("raid_omen")); + public static final DefaultedRegistryReference RAIN = ParticleTypes.key(ResourceKey.minecraft("rain")); public static final DefaultedRegistryReference REVERSE_PORTAL = ParticleTypes.key(ResourceKey.minecraft("reverse_portal")); @@ -200,6 +208,8 @@ public final class ParticleTypes { public static final DefaultedRegistryReference SMALL_FLAME = ParticleTypes.key(ResourceKey.minecraft("small_flame")); + public static final DefaultedRegistryReference SMALL_GUST = ParticleTypes.key(ResourceKey.minecraft("small_gust")); + public static final DefaultedRegistryReference SMOKE = ParticleTypes.key(ResourceKey.minecraft("smoke")); public static final DefaultedRegistryReference SNEEZE = ParticleTypes.key(ResourceKey.minecraft("sneeze")); @@ -224,10 +234,16 @@ public final class ParticleTypes { public static final DefaultedRegistryReference TOTEM_OF_UNDYING = ParticleTypes.key(ResourceKey.minecraft("totem_of_undying")); + public static final DefaultedRegistryReference TRIAL_OMEN = ParticleTypes.key(ResourceKey.minecraft("trial_omen")); + public static final DefaultedRegistryReference TRIAL_SPAWNER_DETECTION = ParticleTypes.key(ResourceKey.minecraft("trial_spawner_detection")); + public static final DefaultedRegistryReference TRIAL_SPAWNER_DETECTION_OMINOUS = ParticleTypes.key(ResourceKey.minecraft("trial_spawner_detection_ominous")); + public static final DefaultedRegistryReference UNDERWATER = ParticleTypes.key(ResourceKey.minecraft("underwater")); + public static final DefaultedRegistryReference VAULT_CONNECTION = ParticleTypes.key(ResourceKey.minecraft("vault_connection")); + public static final DefaultedRegistryReference VIBRATION = ParticleTypes.key(ResourceKey.minecraft("vibration")); public static final DefaultedRegistryReference WARPED_SPORE = ParticleTypes.key(ResourceKey.minecraft("warped_spore")); diff --git a/src/main/java/org/spongepowered/api/effect/potion/PotionEffectTypes.java b/src/main/java/org/spongepowered/api/effect/potion/PotionEffectTypes.java index d21bc70ae0..a882041b5e 100644 --- a/src/main/java/org/spongepowered/api/effect/potion/PotionEffectTypes.java +++ b/src/main/java/org/spongepowered/api/effect/potion/PotionEffectTypes.java @@ -64,6 +64,8 @@ public final class PotionEffectTypes { public static final DefaultedRegistryReference HUNGER = PotionEffectTypes.key(ResourceKey.minecraft("hunger")); + public static final DefaultedRegistryReference INFESTED = PotionEffectTypes.key(ResourceKey.minecraft("infested")); + public static final DefaultedRegistryReference INSTANT_DAMAGE = PotionEffectTypes.key(ResourceKey.minecraft("instant_damage")); public static final DefaultedRegistryReference INSTANT_HEALTH = PotionEffectTypes.key(ResourceKey.minecraft("instant_health")); @@ -82,8 +84,12 @@ public final class PotionEffectTypes { public static final DefaultedRegistryReference NIGHT_VISION = PotionEffectTypes.key(ResourceKey.minecraft("night_vision")); + public static final DefaultedRegistryReference OOZING = PotionEffectTypes.key(ResourceKey.minecraft("oozing")); + public static final DefaultedRegistryReference POISON = PotionEffectTypes.key(ResourceKey.minecraft("poison")); + public static final DefaultedRegistryReference RAID_OMEN = PotionEffectTypes.key(ResourceKey.minecraft("raid_omen")); + public static final DefaultedRegistryReference REGENERATION = PotionEffectTypes.key(ResourceKey.minecraft("regeneration")); public static final DefaultedRegistryReference RESISTANCE = PotionEffectTypes.key(ResourceKey.minecraft("resistance")); @@ -98,12 +104,18 @@ public final class PotionEffectTypes { public static final DefaultedRegistryReference STRENGTH = PotionEffectTypes.key(ResourceKey.minecraft("strength")); + public static final DefaultedRegistryReference TRIAL_OMEN = PotionEffectTypes.key(ResourceKey.minecraft("trial_omen")); + public static final DefaultedRegistryReference UNLUCK = PotionEffectTypes.key(ResourceKey.minecraft("unluck")); public static final DefaultedRegistryReference WATER_BREATHING = PotionEffectTypes.key(ResourceKey.minecraft("water_breathing")); public static final DefaultedRegistryReference WEAKNESS = PotionEffectTypes.key(ResourceKey.minecraft("weakness")); + public static final DefaultedRegistryReference WEAVING = PotionEffectTypes.key(ResourceKey.minecraft("weaving")); + + public static final DefaultedRegistryReference WIND_CHARGED = PotionEffectTypes.key(ResourceKey.minecraft("wind_charged")); + public static final DefaultedRegistryReference WITHER = PotionEffectTypes.key(ResourceKey.minecraft("wither")); private PotionEffectTypes() { diff --git a/src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java b/src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java index 70a373aec4..7c21e16ec2 100644 --- a/src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java +++ b/src/main/java/org/spongepowered/api/effect/sound/SoundTypes.java @@ -422,6 +422,16 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_CHORUS_FLOWER_GROW = SoundTypes.key(ResourceKey.minecraft("block.chorus_flower.grow")); + public static final DefaultedRegistryReference BLOCK_COBWEB_BREAK = SoundTypes.key(ResourceKey.minecraft("block.cobweb.break")); + + public static final DefaultedRegistryReference BLOCK_COBWEB_FALL = SoundTypes.key(ResourceKey.minecraft("block.cobweb.fall")); + + public static final DefaultedRegistryReference BLOCK_COBWEB_HIT = SoundTypes.key(ResourceKey.minecraft("block.cobweb.hit")); + + public static final DefaultedRegistryReference BLOCK_COBWEB_PLACE = SoundTypes.key(ResourceKey.minecraft("block.cobweb.place")); + + public static final DefaultedRegistryReference BLOCK_COBWEB_STEP = SoundTypes.key(ResourceKey.minecraft("block.cobweb.step")); + public static final DefaultedRegistryReference BLOCK_COMPARATOR_CLICK = SoundTypes.key(ResourceKey.minecraft("block.comparator.click")); public static final DefaultedRegistryReference BLOCK_COMPOSTER_EMPTY = SoundTypes.key(ResourceKey.minecraft("block.composter.empty")); @@ -692,6 +702,16 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_HANGING_SIGN_WAXED_INTERACT_FAIL = SoundTypes.key(ResourceKey.minecraft("block.hanging_sign.waxed_interact_fail")); + public static final DefaultedRegistryReference BLOCK_HEAVY_CORE_BREAK = SoundTypes.key(ResourceKey.minecraft("block.heavy_core.break")); + + public static final DefaultedRegistryReference BLOCK_HEAVY_CORE_FALL = SoundTypes.key(ResourceKey.minecraft("block.heavy_core.fall")); + + public static final DefaultedRegistryReference BLOCK_HEAVY_CORE_HIT = SoundTypes.key(ResourceKey.minecraft("block.heavy_core.hit")); + + public static final DefaultedRegistryReference BLOCK_HEAVY_CORE_PLACE = SoundTypes.key(ResourceKey.minecraft("block.heavy_core.place")); + + public static final DefaultedRegistryReference BLOCK_HEAVY_CORE_STEP = SoundTypes.key(ResourceKey.minecraft("block.heavy_core.step")); + public static final DefaultedRegistryReference BLOCK_HONEY_BLOCK_BREAK = SoundTypes.key(ResourceKey.minecraft("block.honey_block.break")); public static final DefaultedRegistryReference BLOCK_HONEY_BLOCK_FALL = SoundTypes.key(ResourceKey.minecraft("block.honey_block.fall")); @@ -1340,10 +1360,16 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_SWEET_BERRY_BUSH_PLACE = SoundTypes.key(ResourceKey.minecraft("block.sweet_berry_bush.place")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_ABOUT_TO_SPAWN_ITEM = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.about_to_spawn_item")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_AMBIENT = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.ambient")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_AMBIENT_CHARGED = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.ambient_charged")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_BREAK = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.break")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_CHARGE_ACTIVATE = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.charge_activate")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_CLOSE_SHUTTER = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.close_shutter")); public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_DETECT_PLAYER = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.detect_player")); @@ -1358,6 +1384,10 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_PLACE = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.place")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_SPAWN_ITEM = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.spawn_item")); + + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_SPAWN_ITEM_BEGIN = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.spawn_item_begin")); + public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_SPAWN_MOB = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.spawn_mob")); public static final DefaultedRegistryReference BLOCK_TRIAL_SPAWNER_STEP = SoundTypes.key(ResourceKey.minecraft("block.trial_spawner.step")); @@ -1390,6 +1420,32 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_TUFF_BRICKS_STEP = SoundTypes.key(ResourceKey.minecraft("block.tuff_bricks.step")); + public static final DefaultedRegistryReference BLOCK_VAULT_ACTIVATE = SoundTypes.key(ResourceKey.minecraft("block.vault.activate")); + + public static final DefaultedRegistryReference BLOCK_VAULT_AMBIENT = SoundTypes.key(ResourceKey.minecraft("block.vault.ambient")); + + public static final DefaultedRegistryReference BLOCK_VAULT_BREAK = SoundTypes.key(ResourceKey.minecraft("block.vault.break")); + + public static final DefaultedRegistryReference BLOCK_VAULT_CLOSE_SHUTTER = SoundTypes.key(ResourceKey.minecraft("block.vault.close_shutter")); + + public static final DefaultedRegistryReference BLOCK_VAULT_DEACTIVATE = SoundTypes.key(ResourceKey.minecraft("block.vault.deactivate")); + + public static final DefaultedRegistryReference BLOCK_VAULT_EJECT_ITEM = SoundTypes.key(ResourceKey.minecraft("block.vault.eject_item")); + + public static final DefaultedRegistryReference BLOCK_VAULT_FALL = SoundTypes.key(ResourceKey.minecraft("block.vault.fall")); + + public static final DefaultedRegistryReference BLOCK_VAULT_HIT = SoundTypes.key(ResourceKey.minecraft("block.vault.hit")); + + public static final DefaultedRegistryReference BLOCK_VAULT_INSERT_ITEM = SoundTypes.key(ResourceKey.minecraft("block.vault.insert_item")); + + public static final DefaultedRegistryReference BLOCK_VAULT_INSERT_ITEM_FAIL = SoundTypes.key(ResourceKey.minecraft("block.vault.insert_item_fail")); + + public static final DefaultedRegistryReference BLOCK_VAULT_OPEN_SHUTTER = SoundTypes.key(ResourceKey.minecraft("block.vault.open_shutter")); + + public static final DefaultedRegistryReference BLOCK_VAULT_PLACE = SoundTypes.key(ResourceKey.minecraft("block.vault.place")); + + public static final DefaultedRegistryReference BLOCK_VAULT_STEP = SoundTypes.key(ResourceKey.minecraft("block.vault.step")); + public static final DefaultedRegistryReference BLOCK_VINE_BREAK = SoundTypes.key(ResourceKey.minecraft("block.vine.break")); public static final DefaultedRegistryReference BLOCK_VINE_FALL = SoundTypes.key(ResourceKey.minecraft("block.vine.fall")); @@ -1434,6 +1490,8 @@ public final class SoundTypes { public static final DefaultedRegistryReference BLOCK_WET_SPONGE_BREAK = SoundTypes.key(ResourceKey.minecraft("block.wet_sponge.break")); + public static final DefaultedRegistryReference BLOCK_WET_SPONGE_DRIES = SoundTypes.key(ResourceKey.minecraft("block.wet_sponge.dries")); + public static final DefaultedRegistryReference BLOCK_WET_SPONGE_FALL = SoundTypes.key(ResourceKey.minecraft("block.wet_sponge.fall")); public static final DefaultedRegistryReference BLOCK_WET_SPONGE_HIT = SoundTypes.key(ResourceKey.minecraft("block.wet_sponge.hit")); @@ -1494,6 +1552,32 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_ALLAY_ITEM_THROWN = SoundTypes.key(ResourceKey.minecraft("entity.allay.item_thrown")); + public static final DefaultedRegistryReference ENTITY_ARMADILLO_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.ambient")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_BRUSH = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.brush")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_DEATH = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.death")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_EAT = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.eat")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_HURT = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.hurt")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_HURT_REDUCED = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.hurt_reduced")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_LAND = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.land")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_PEEK = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.peek")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_ROLL = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.roll")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_SCUTE_DROP = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.scute_drop")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_STEP = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.step")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_UNROLL_FINISH = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.unroll_finish")); + + public static final DefaultedRegistryReference ENTITY_ARMADILLO_UNROLL_START = SoundTypes.key(ResourceKey.minecraft("entity.armadillo.unroll_start")); + public static final DefaultedRegistryReference ENTITY_ARMOR_STAND_BREAK = SoundTypes.key(ResourceKey.minecraft("entity.armor_stand.break")); public static final DefaultedRegistryReference ENTITY_ARMOR_STAND_FALL = SoundTypes.key(ResourceKey.minecraft("entity.armor_stand.fall")); @@ -1558,8 +1642,22 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_BOAT_PADDLE_WATER = SoundTypes.key(ResourceKey.minecraft("entity.boat.paddle_water")); + public static final DefaultedRegistryReference ENTITY_BOGGED_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.bogged.ambient")); + + public static final DefaultedRegistryReference ENTITY_BOGGED_DEATH = SoundTypes.key(ResourceKey.minecraft("entity.bogged.death")); + + public static final DefaultedRegistryReference ENTITY_BOGGED_HURT = SoundTypes.key(ResourceKey.minecraft("entity.bogged.hurt")); + + public static final DefaultedRegistryReference ENTITY_BOGGED_SHEAR = SoundTypes.key(ResourceKey.minecraft("entity.bogged.shear")); + + public static final DefaultedRegistryReference ENTITY_BOGGED_STEP = SoundTypes.key(ResourceKey.minecraft("entity.bogged.step")); + + public static final DefaultedRegistryReference ENTITY_BREEZE_CHARGE = SoundTypes.key(ResourceKey.minecraft("entity.breeze.charge")); + public static final DefaultedRegistryReference ENTITY_BREEZE_DEATH = SoundTypes.key(ResourceKey.minecraft("entity.breeze.death")); + public static final DefaultedRegistryReference ENTITY_BREEZE_DEFLECT = SoundTypes.key(ResourceKey.minecraft("entity.breeze.deflect")); + public static final DefaultedRegistryReference ENTITY_BREEZE_HURT = SoundTypes.key(ResourceKey.minecraft("entity.breeze.hurt")); public static final DefaultedRegistryReference ENTITY_BREEZE_IDLE_AIR = SoundTypes.key(ResourceKey.minecraft("entity.breeze.idle_air")); @@ -1576,6 +1674,10 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_BREEZE_SLIDE = SoundTypes.key(ResourceKey.minecraft("entity.breeze.slide")); + public static final DefaultedRegistryReference ENTITY_BREEZE_WHIRL = SoundTypes.key(ResourceKey.minecraft("entity.breeze.whirl")); + + public static final DefaultedRegistryReference ENTITY_BREEZE_WIND_BURST = SoundTypes.key(ResourceKey.minecraft("entity.breeze.wind_burst")); + public static final DefaultedRegistryReference ENTITY_CAMEL_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.camel.ambient")); public static final DefaultedRegistryReference ENTITY_CAMEL_DASH = SoundTypes.key(ResourceKey.minecraft("entity.camel.dash")); @@ -1682,6 +1784,8 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_DONKEY_HURT = SoundTypes.key(ResourceKey.minecraft("entity.donkey.hurt")); + public static final DefaultedRegistryReference ENTITY_DONKEY_JUMP = SoundTypes.key(ResourceKey.minecraft("entity.donkey.jump")); + public static final DefaultedRegistryReference ENTITY_DRAGON_FIREBALL_EXPLODE = SoundTypes.key(ResourceKey.minecraft("entity.dragon_fireball.explode")); public static final DefaultedRegistryReference ENTITY_DROWNED_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.drowned.ambient")); @@ -1864,8 +1968,6 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_GENERIC_SWIM = SoundTypes.key(ResourceKey.minecraft("entity.generic.swim")); - public static final DefaultedRegistryReference ENTITY_GENERIC_WIND_BURST = SoundTypes.key(ResourceKey.minecraft("entity.generic.wind_burst")); - public static final DefaultedRegistryReference ENTITY_GHAST_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.ghast.ambient")); public static final DefaultedRegistryReference ENTITY_GHAST_DEATH = SoundTypes.key(ResourceKey.minecraft("entity.ghast.death")); @@ -2124,6 +2226,8 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_MULE_HURT = SoundTypes.key(ResourceKey.minecraft("entity.mule.hurt")); + public static final DefaultedRegistryReference ENTITY_MULE_JUMP = SoundTypes.key(ResourceKey.minecraft("entity.mule.jump")); + public static final DefaultedRegistryReference ENTITY_OCELOT_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.ocelot.ambient")); public static final DefaultedRegistryReference ENTITY_OCELOT_DEATH = SoundTypes.key(ResourceKey.minecraft("entity.ocelot.death")); @@ -2168,6 +2272,8 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_PARROT_IMITATE_BLAZE = SoundTypes.key(ResourceKey.minecraft("entity.parrot.imitate.blaze")); + public static final DefaultedRegistryReference ENTITY_PARROT_IMITATE_BOGGED = SoundTypes.key(ResourceKey.minecraft("entity.parrot.imitate.bogged")); + public static final DefaultedRegistryReference ENTITY_PARROT_IMITATE_BREEZE = SoundTypes.key(ResourceKey.minecraft("entity.parrot.imitate.breeze")); public static final DefaultedRegistryReference ENTITY_PARROT_IMITATE_CREEPER = SoundTypes.key(ResourceKey.minecraft("entity.parrot.imitate.creeper")); @@ -2724,6 +2830,10 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_WARDEN_TENDRIL_CLICKS = SoundTypes.key(ResourceKey.minecraft("entity.warden.tendril_clicks")); + public static final DefaultedRegistryReference ENTITY_WIND_CHARGE_THROW = SoundTypes.key(ResourceKey.minecraft("entity.wind_charge.throw")); + + public static final DefaultedRegistryReference ENTITY_WIND_CHARGE_WIND_BURST = SoundTypes.key(ResourceKey.minecraft("entity.wind_charge.wind_burst")); + public static final DefaultedRegistryReference ENTITY_WITCH_AMBIENT = SoundTypes.key(ResourceKey.minecraft("entity.witch.ambient")); public static final DefaultedRegistryReference ENTITY_WITCH_CELEBRATE = SoundTypes.key(ResourceKey.minecraft("entity.witch.celebrate")); @@ -2832,6 +2942,12 @@ public final class SoundTypes { public static final DefaultedRegistryReference ENTITY_ZOMBIFIED_PIGLIN_HURT = SoundTypes.key(ResourceKey.minecraft("entity.zombified_piglin.hurt")); + public static final DefaultedRegistryReference EVENT_MOB_EFFECT_BAD_OMEN = SoundTypes.key(ResourceKey.minecraft("event.mob_effect.bad_omen")); + + public static final DefaultedRegistryReference EVENT_MOB_EFFECT_RAID_OMEN = SoundTypes.key(ResourceKey.minecraft("event.mob_effect.raid_omen")); + + public static final DefaultedRegistryReference EVENT_MOB_EFFECT_TRIAL_OMEN = SoundTypes.key(ResourceKey.minecraft("event.mob_effect.trial_omen")); + public static final DefaultedRegistryReference EVENT_RAID_HORN = SoundTypes.key(ResourceKey.minecraft("event.raid.horn")); public static final DefaultedRegistryReference INTENTIONALLY_EMPTY = SoundTypes.key(ResourceKey.minecraft("intentionally_empty")); @@ -2854,6 +2970,10 @@ public final class SoundTypes { public static final DefaultedRegistryReference ITEM_ARMOR_EQUIP_TURTLE = SoundTypes.key(ResourceKey.minecraft("item.armor.equip_turtle")); + public static final DefaultedRegistryReference ITEM_ARMOR_EQUIP_WOLF = SoundTypes.key(ResourceKey.minecraft("item.armor.equip_wolf")); + + public static final DefaultedRegistryReference ITEM_ARMOR_UNEQUIP_WOLF = SoundTypes.key(ResourceKey.minecraft("item.armor.unequip_wolf")); + public static final DefaultedRegistryReference ITEM_AXE_SCRAPE = SoundTypes.key(ResourceKey.minecraft("item.axe.scrape")); public static final DefaultedRegistryReference ITEM_AXE_STRIP = SoundTypes.key(ResourceKey.minecraft("item.axe.strip")); @@ -2970,8 +3090,16 @@ public final class SoundTypes { public static final DefaultedRegistryReference ITEM_LODESTONE_COMPASS_LOCK = SoundTypes.key(ResourceKey.minecraft("item.lodestone_compass.lock")); + public static final DefaultedRegistryReference ITEM_MACE_SMASH_AIR = SoundTypes.key(ResourceKey.minecraft("item.mace.smash_air")); + + public static final DefaultedRegistryReference ITEM_MACE_SMASH_GROUND = SoundTypes.key(ResourceKey.minecraft("item.mace.smash_ground")); + + public static final DefaultedRegistryReference ITEM_MACE_SMASH_GROUND_HEAVY = SoundTypes.key(ResourceKey.minecraft("item.mace.smash_ground_heavy")); + public static final DefaultedRegistryReference ITEM_NETHER_WART_PLANT = SoundTypes.key(ResourceKey.minecraft("item.nether_wart.plant")); + public static final DefaultedRegistryReference ITEM_OMINOUS_BOTTLE_DISPOSE = SoundTypes.key(ResourceKey.minecraft("item.ominous_bottle.dispose")); + public static final DefaultedRegistryReference ITEM_SHIELD_BLOCK = SoundTypes.key(ResourceKey.minecraft("item.shield.block")); public static final DefaultedRegistryReference ITEM_SHIELD_BREAK = SoundTypes.key(ResourceKey.minecraft("item.shield.break")); @@ -3000,6 +3128,14 @@ public final class SoundTypes { public static final DefaultedRegistryReference ITEM_TRIDENT_THUNDER = SoundTypes.key(ResourceKey.minecraft("item.trident.thunder")); + public static final DefaultedRegistryReference ITEM_WOLF_ARMOR_BREAK = SoundTypes.key(ResourceKey.minecraft("item.wolf_armor.break")); + + public static final DefaultedRegistryReference ITEM_WOLF_ARMOR_CRACK = SoundTypes.key(ResourceKey.minecraft("item.wolf_armor.crack")); + + public static final DefaultedRegistryReference ITEM_WOLF_ARMOR_DAMAGE = SoundTypes.key(ResourceKey.minecraft("item.wolf_armor.damage")); + + public static final DefaultedRegistryReference ITEM_WOLF_ARMOR_REPAIR = SoundTypes.key(ResourceKey.minecraft("item.wolf_armor.repair")); + public static final DefaultedRegistryReference MUSIC_CREATIVE = SoundTypes.key(ResourceKey.minecraft("music.creative")); public static final DefaultedRegistryReference MUSIC_CREDITS = SoundTypes.key(ResourceKey.minecraft("music.credits")); diff --git a/src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java b/src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java index 098b0a7c0f..e8454b5917 100644 --- a/src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java +++ b/src/main/java/org/spongepowered/api/entity/attribute/type/AttributeTypes.java @@ -50,10 +50,16 @@ public final class AttributeTypes { public static final DefaultedRegistryReference GENERIC_ATTACK_SPEED = AttributeTypes.key(ResourceKey.minecraft("generic.attack_speed")); + public static final DefaultedRegistryReference GENERIC_FALL_DAMAGE_MULTIPLIER = AttributeTypes.key(ResourceKey.minecraft("generic.fall_damage_multiplier")); + public static final DefaultedRegistryReference GENERIC_FLYING_SPEED = AttributeTypes.key(ResourceKey.minecraft("generic.flying_speed")); public static final DefaultedRegistryReference GENERIC_FOLLOW_RANGE = AttributeTypes.key(ResourceKey.minecraft("generic.follow_range")); + public static final DefaultedRegistryReference GENERIC_GRAVITY = AttributeTypes.key(ResourceKey.minecraft("generic.gravity")); + + public static final DefaultedRegistryReference GENERIC_JUMP_STRENGTH = AttributeTypes.key(ResourceKey.minecraft("generic.jump_strength")); + public static final DefaultedRegistryReference GENERIC_KNOCKBACK_RESISTANCE = AttributeTypes.key(ResourceKey.minecraft("generic.knockback_resistance")); public static final DefaultedRegistryReference GENERIC_LUCK = AttributeTypes.key(ResourceKey.minecraft("generic.luck")); @@ -64,7 +70,17 @@ public final class AttributeTypes { public static final DefaultedRegistryReference GENERIC_MOVEMENT_SPEED = AttributeTypes.key(ResourceKey.minecraft("generic.movement_speed")); - public static final DefaultedRegistryReference HORSE_JUMP_STRENGTH = AttributeTypes.key(ResourceKey.minecraft("horse.jump_strength")); + public static final DefaultedRegistryReference GENERIC_SAFE_FALL_DISTANCE = AttributeTypes.key(ResourceKey.minecraft("generic.safe_fall_distance")); + + public static final DefaultedRegistryReference GENERIC_SCALE = AttributeTypes.key(ResourceKey.minecraft("generic.scale")); + + public static final DefaultedRegistryReference GENERIC_STEP_HEIGHT = AttributeTypes.key(ResourceKey.minecraft("generic.step_height")); + + public static final DefaultedRegistryReference PLAYER_BLOCK_BREAK_SPEED = AttributeTypes.key(ResourceKey.minecraft("player.block_break_speed")); + + public static final DefaultedRegistryReference PLAYER_BLOCK_INTERACTION_RANGE = AttributeTypes.key(ResourceKey.minecraft("player.block_interaction_range")); + + public static final DefaultedRegistryReference PLAYER_ENTITY_INTERACTION_RANGE = AttributeTypes.key(ResourceKey.minecraft("player.entity_interaction_range")); public static final DefaultedRegistryReference ZOMBIE_SPAWN_REINFORCEMENTS = AttributeTypes.key(ResourceKey.minecraft("zombie.spawn_reinforcements")); diff --git a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java index f7898effcb..548bfc3f83 100644 --- a/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java +++ b/src/main/java/org/spongepowered/api/event/cause/entity/damage/DamageTypes.java @@ -108,6 +108,8 @@ public final class DamageTypes { public static final DefaultedRegistryReference SONIC_BOOM = DamageTypes.key(ResourceKey.minecraft("sonic_boom")); + public static final DefaultedRegistryReference SPIT = DamageTypes.key(ResourceKey.minecraft("spit")); + public static final DefaultedRegistryReference STALAGMITE = DamageTypes.key(ResourceKey.minecraft("stalagmite")); public static final DefaultedRegistryReference STARVE = DamageTypes.key(ResourceKey.minecraft("starve")); diff --git a/src/main/java/org/spongepowered/api/item/ItemTypes.java b/src/main/java/org/spongepowered/api/item/ItemTypes.java index 45fae9436d..2b4ef0f8a2 100644 --- a/src/main/java/org/spongepowered/api/item/ItemTypes.java +++ b/src/main/java/org/spongepowered/api/item/ItemTypes.java @@ -106,6 +106,10 @@ public final class ItemTypes { public static final DefaultedRegistryReference ARCHER_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("archer_pottery_sherd")); + public static final DefaultedRegistryReference ARMADILLO_SCUTE = ItemTypes.key(ResourceKey.minecraft("armadillo_scute")); + + public static final DefaultedRegistryReference ARMADILLO_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("armadillo_spawn_egg")); + public static final DefaultedRegistryReference ARMOR_STAND = ItemTypes.key(ResourceKey.minecraft("armor_stand")); public static final DefaultedRegistryReference ARMS_UP_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("arms_up_pottery_sherd")); @@ -298,6 +302,10 @@ public final class ItemTypes { public static final DefaultedRegistryReference BLUE_WOOL = ItemTypes.key(ResourceKey.minecraft("blue_wool")); + public static final DefaultedRegistryReference BOGGED_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("bogged_spawn_egg")); + + public static final DefaultedRegistryReference BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = ItemTypes.key(ResourceKey.minecraft("bolt_armor_trim_smithing_template")); + public static final DefaultedRegistryReference BONE = ItemTypes.key(ResourceKey.minecraft("bone")); public static final DefaultedRegistryReference BONE_BLOCK = ItemTypes.key(ResourceKey.minecraft("bone_block")); @@ -320,6 +328,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference BREAD = ItemTypes.key(ResourceKey.minecraft("bread")); + public static final DefaultedRegistryReference BREEZE_ROD = ItemTypes.key(ResourceKey.minecraft("breeze_rod")); + public static final DefaultedRegistryReference BREEZE_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("breeze_spawn_egg")); public static final DefaultedRegistryReference BREWER_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("brewer_pottery_sherd")); @@ -968,6 +978,12 @@ public final class ItemTypes { public static final DefaultedRegistryReference FLINT_AND_STEEL = ItemTypes.key(ResourceKey.minecraft("flint_and_steel")); + public static final DefaultedRegistryReference FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = ItemTypes.key(ResourceKey.minecraft("flow_armor_trim_smithing_template")); + + public static final DefaultedRegistryReference FLOW_BANNER_PATTERN = ItemTypes.key(ResourceKey.minecraft("flow_banner_pattern")); + + public static final DefaultedRegistryReference FLOW_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("flow_pottery_sherd")); + public static final DefaultedRegistryReference FLOWER_BANNER_PATTERN = ItemTypes.key(ResourceKey.minecraft("flower_banner_pattern")); public static final DefaultedRegistryReference FLOWER_POT = ItemTypes.key(ResourceKey.minecraft("flower_pot")); @@ -1124,6 +1140,10 @@ public final class ItemTypes { public static final DefaultedRegistryReference GUNPOWDER = ItemTypes.key(ResourceKey.minecraft("gunpowder")); + public static final DefaultedRegistryReference GUSTER_BANNER_PATTERN = ItemTypes.key(ResourceKey.minecraft("guster_banner_pattern")); + + public static final DefaultedRegistryReference GUSTER_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("guster_pottery_sherd")); + public static final DefaultedRegistryReference HANGING_ROOTS = ItemTypes.key(ResourceKey.minecraft("hanging_roots")); public static final DefaultedRegistryReference HAY_BLOCK = ItemTypes.key(ResourceKey.minecraft("hay_block")); @@ -1134,6 +1154,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference HEARTBREAK_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("heartbreak_pottery_sherd")); + public static final DefaultedRegistryReference HEAVY_CORE = ItemTypes.key(ResourceKey.minecraft("heavy_core")); + public static final DefaultedRegistryReference HEAVY_WEIGHTED_PRESSURE_PLATE = ItemTypes.key(ResourceKey.minecraft("heavy_weighted_pressure_plate")); public static final DefaultedRegistryReference HOGLIN_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("hoglin_spawn_egg")); @@ -1396,6 +1418,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference LOOM = ItemTypes.key(ResourceKey.minecraft("loom")); + public static final DefaultedRegistryReference MACE = ItemTypes.key(ResourceKey.minecraft("mace")); + public static final DefaultedRegistryReference MAGENTA_BANNER = ItemTypes.key(ResourceKey.minecraft("magenta_banner")); public static final DefaultedRegistryReference MAGENTA_BED = ItemTypes.key(ResourceKey.minecraft("magenta_bed")); @@ -1660,6 +1684,10 @@ public final class ItemTypes { public static final DefaultedRegistryReference OCHRE_FROGLIGHT = ItemTypes.key(ResourceKey.minecraft("ochre_froglight")); + public static final DefaultedRegistryReference OMINOUS_BOTTLE = ItemTypes.key(ResourceKey.minecraft("ominous_bottle")); + + public static final DefaultedRegistryReference OMINOUS_TRIAL_KEY = ItemTypes.key(ResourceKey.minecraft("ominous_trial_key")); + public static final DefaultedRegistryReference ORANGE_BANNER = ItemTypes.key(ResourceKey.minecraft("orange_banner")); public static final DefaultedRegistryReference ORANGE_BED = ItemTypes.key(ResourceKey.minecraft("orange_bed")); @@ -2064,6 +2092,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference SCAFFOLDING = ItemTypes.key(ResourceKey.minecraft("scaffolding")); + public static final DefaultedRegistryReference SCRAPE_POTTERY_SHERD = ItemTypes.key(ResourceKey.minecraft("scrape_pottery_sherd")); + public static final DefaultedRegistryReference SCULK = ItemTypes.key(ResourceKey.minecraft("sculk")); public static final DefaultedRegistryReference SCULK_CATALYST = ItemTypes.key(ResourceKey.minecraft("sculk_catalyst")); @@ -2074,8 +2104,6 @@ public final class ItemTypes { public static final DefaultedRegistryReference SCULK_VEIN = ItemTypes.key(ResourceKey.minecraft("sculk_vein")); - public static final DefaultedRegistryReference SCUTE = ItemTypes.key(ResourceKey.minecraft("scute")); - public static final DefaultedRegistryReference SEA_LANTERN = ItemTypes.key(ResourceKey.minecraft("sea_lantern")); public static final DefaultedRegistryReference SEA_PICKLE = ItemTypes.key(ResourceKey.minecraft("sea_pickle")); @@ -2410,10 +2438,14 @@ public final class ItemTypes { public static final DefaultedRegistryReference TURTLE_HELMET = ItemTypes.key(ResourceKey.minecraft("turtle_helmet")); + public static final DefaultedRegistryReference TURTLE_SCUTE = ItemTypes.key(ResourceKey.minecraft("turtle_scute")); + public static final DefaultedRegistryReference TURTLE_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("turtle_spawn_egg")); public static final DefaultedRegistryReference TWISTING_VINES = ItemTypes.key(ResourceKey.minecraft("twisting_vines")); + public static final DefaultedRegistryReference VAULT = ItemTypes.key(ResourceKey.minecraft("vault")); + public static final DefaultedRegistryReference VERDANT_FROGLIGHT = ItemTypes.key(ResourceKey.minecraft("verdant_froglight")); public static final DefaultedRegistryReference VEX_ARMOR_TRIM_SMITHING_TEMPLATE = ItemTypes.key(ResourceKey.minecraft("vex_armor_trim_smithing_template")); @@ -2600,6 +2632,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference WILD_ARMOR_TRIM_SMITHING_TEMPLATE = ItemTypes.key(ResourceKey.minecraft("wild_armor_trim_smithing_template")); + public static final DefaultedRegistryReference WIND_CHARGE = ItemTypes.key(ResourceKey.minecraft("wind_charge")); + public static final DefaultedRegistryReference WITCH_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("witch_spawn_egg")); public static final DefaultedRegistryReference WITHER_ROSE = ItemTypes.key(ResourceKey.minecraft("wither_rose")); @@ -2610,6 +2644,8 @@ public final class ItemTypes { public static final DefaultedRegistryReference WITHER_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("wither_spawn_egg")); + public static final DefaultedRegistryReference WOLF_ARMOR = ItemTypes.key(ResourceKey.minecraft("wolf_armor")); + public static final DefaultedRegistryReference WOLF_SPAWN_EGG = ItemTypes.key(ResourceKey.minecraft("wolf_spawn_egg")); public static final DefaultedRegistryReference WOODEN_AXE = ItemTypes.key(ResourceKey.minecraft("wooden_axe")); diff --git a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentTypes.java b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentTypes.java index f9aa0c3a0d..94a3745ba4 100644 --- a/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentTypes.java +++ b/src/main/java/org/spongepowered/api/item/enchantment/EnchantmentTypes.java @@ -70,8 +70,12 @@ public final class EnchantmentTypes { */ public static final DefaultedRegistryReference BLAST_PROTECTION = EnchantmentTypes.key(ResourceKey.minecraft("blast_protection")); + public static final DefaultedRegistryReference BREACH = EnchantmentTypes.key(ResourceKey.minecraft("breach")); + public static final DefaultedRegistryReference CHANNELING = EnchantmentTypes.key(ResourceKey.minecraft("channeling")); + public static final DefaultedRegistryReference DENSITY = EnchantmentTypes.key(ResourceKey.minecraft("density")); + /** * Increases underwater movement speed. * @@ -245,12 +249,7 @@ public final class EnchantmentTypes { public static final DefaultedRegistryReference SOUL_SPEED = EnchantmentTypes.key(ResourceKey.minecraft("soul_speed")); - /** - * Increases the damage of the sweeping attack. - * - *

In vanilla the maximum level is 3.

- */ - public static final DefaultedRegistryReference SWEEPING = EnchantmentTypes.key(ResourceKey.minecraft("sweeping")); + public static final DefaultedRegistryReference SWEEPING_EDGE = EnchantmentTypes.key(ResourceKey.minecraft("sweeping_edge")); public static final DefaultedRegistryReference SWIFT_SNEAK = EnchantmentTypes.key(ResourceKey.minecraft("swift_sneak")); @@ -275,6 +274,8 @@ public final class EnchantmentTypes { */ public static final DefaultedRegistryReference VANISHING_CURSE = EnchantmentTypes.key(ResourceKey.minecraft("vanishing_curse")); + public static final DefaultedRegistryReference WIND_BURST = EnchantmentTypes.key(ResourceKey.minecraft("wind_burst")); + private EnchantmentTypes() { } diff --git a/src/main/java/org/spongepowered/api/item/potion/PotionTypes.java b/src/main/java/org/spongepowered/api/item/potion/PotionTypes.java index 286fe0606e..8278db6ab8 100644 --- a/src/main/java/org/spongepowered/api/item/potion/PotionTypes.java +++ b/src/main/java/org/spongepowered/api/item/potion/PotionTypes.java @@ -42,14 +42,14 @@ public final class PotionTypes { public static final DefaultedRegistryReference AWKWARD = PotionTypes.key(ResourceKey.minecraft("awkward")); - public static final DefaultedRegistryReference EMPTY = PotionTypes.key(ResourceKey.minecraft("empty")); - public static final DefaultedRegistryReference FIRE_RESISTANCE = PotionTypes.key(ResourceKey.minecraft("fire_resistance")); public static final DefaultedRegistryReference HARMING = PotionTypes.key(ResourceKey.minecraft("harming")); public static final DefaultedRegistryReference HEALING = PotionTypes.key(ResourceKey.minecraft("healing")); + public static final DefaultedRegistryReference INFESTED = PotionTypes.key(ResourceKey.minecraft("infested")); + public static final DefaultedRegistryReference INVISIBILITY = PotionTypes.key(ResourceKey.minecraft("invisibility")); public static final DefaultedRegistryReference LEAPING = PotionTypes.key(ResourceKey.minecraft("leaping")); @@ -86,6 +86,8 @@ public final class PotionTypes { public static final DefaultedRegistryReference NIGHT_VISION = PotionTypes.key(ResourceKey.minecraft("night_vision")); + public static final DefaultedRegistryReference OOZING = PotionTypes.key(ResourceKey.minecraft("oozing")); + public static final DefaultedRegistryReference POISON = PotionTypes.key(ResourceKey.minecraft("poison")); public static final DefaultedRegistryReference REGENERATION = PotionTypes.key(ResourceKey.minecraft("regeneration")); @@ -126,6 +128,10 @@ public final class PotionTypes { public static final DefaultedRegistryReference WEAKNESS = PotionTypes.key(ResourceKey.minecraft("weakness")); + public static final DefaultedRegistryReference WEAVING = PotionTypes.key(ResourceKey.minecraft("weaving")); + + public static final DefaultedRegistryReference WIND_CHARGED = PotionTypes.key(ResourceKey.minecraft("wind_charged")); + private PotionTypes() { } diff --git a/src/main/java/org/spongepowered/api/state/BooleanStateProperties.java b/src/main/java/org/spongepowered/api/state/BooleanStateProperties.java index b4a2ac6d29..266edcd50f 100644 --- a/src/main/java/org/spongepowered/api/state/BooleanStateProperties.java +++ b/src/main/java/org/spongepowered/api/state/BooleanStateProperties.java @@ -165,6 +165,10 @@ public static BooleanStateProperty property_OCCUPIED() { return BooleanStateProperty.of("OCCUPIED"); } + public static BooleanStateProperty property_OMINOUS() { + return BooleanStateProperty.of("OMINOUS"); + } + public static BooleanStateProperty property_OPEN() { return BooleanStateProperty.of("OPEN"); } diff --git a/src/main/java/org/spongepowered/api/state/EnumStateProperties.java b/src/main/java/org/spongepowered/api/state/EnumStateProperties.java index 7abe48745b..3300563ee1 100644 --- a/src/main/java/org/spongepowered/api/state/EnumStateProperties.java +++ b/src/main/java/org/spongepowered/api/state/EnumStateProperties.java @@ -183,6 +183,10 @@ public static EnumStateProperty property_TRIAL_SPAWNER_STATE() { return EnumStateProperty.of("TRIAL_SPAWNER_STATE"); } + public static EnumStateProperty property_VAULT_STATE() { + return EnumStateProperty.of("VAULT_STATE"); + } + public static EnumStateProperty property_VERTICAL_DIRECTION() { return EnumStateProperty.of("VERTICAL_DIRECTION"); } diff --git a/src/main/java/org/spongepowered/api/tag/BlockTypeTags.java b/src/main/java/org/spongepowered/api/tag/BlockTypeTags.java index 28fcab9299..7bf2a75ece 100644 --- a/src/main/java/org/spongepowered/api/tag/BlockTypeTags.java +++ b/src/main/java/org/spongepowered/api/tag/BlockTypeTags.java @@ -49,12 +49,16 @@ public final class BlockTypeTags { public static final Tag ANVIL = BlockTypeTags.key(ResourceKey.minecraft("anvil")); + public static final Tag ARMADILLO_SPAWNABLE_ON = BlockTypeTags.key(ResourceKey.minecraft("armadillo_spawnable_on")); + public static final Tag AXOLOTLS_SPAWNABLE_ON = BlockTypeTags.key(ResourceKey.minecraft("axolotls_spawnable_on")); public static final Tag AZALEA_GROWS_ON = BlockTypeTags.key(ResourceKey.minecraft("azalea_grows_on")); public static final Tag AZALEA_ROOT_REPLACEABLE = BlockTypeTags.key(ResourceKey.minecraft("azalea_root_replaceable")); + public static final Tag BADLANDS_TERRACOTTA = BlockTypeTags.key(ResourceKey.minecraft("badlands_terracotta")); + public static final Tag BAMBOO_BLOCKS = BlockTypeTags.key(ResourceKey.minecraft("bamboo_blocks")); public static final Tag BAMBOO_PLANTABLE_ON = BlockTypeTags.key(ResourceKey.minecraft("bamboo_plantable_on")); @@ -133,6 +137,8 @@ public final class BlockTypeTags { public static final Tag DIRT = BlockTypeTags.key(ResourceKey.minecraft("dirt")); + public static final Tag DOES_NOT_BLOCK_HOPPERS = BlockTypeTags.key(ResourceKey.minecraft("does_not_block_hoppers")); + public static final Tag DOORS = BlockTypeTags.key(ResourceKey.minecraft("doors")); public static final Tag DRAGON_IMMUNE = BlockTypeTags.key(ResourceKey.minecraft("dragon_immune")); @@ -183,6 +189,18 @@ public final class BlockTypeTags { public static final Tag IMPERMEABLE = BlockTypeTags.key(ResourceKey.minecraft("impermeable")); + public static final Tag INCORRECT_FOR_DIAMOND_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_diamond_tool")); + + public static final Tag INCORRECT_FOR_GOLD_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_gold_tool")); + + public static final Tag INCORRECT_FOR_IRON_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_iron_tool")); + + public static final Tag INCORRECT_FOR_NETHERITE_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_netherite_tool")); + + public static final Tag INCORRECT_FOR_STONE_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_stone_tool")); + + public static final Tag INCORRECT_FOR_WOODEN_TOOL = BlockTypeTags.key(ResourceKey.minecraft("incorrect_for_wooden_tool")); + public static final Tag INFINIBURN_END = BlockTypeTags.key(ResourceKey.minecraft("infiniburn_end")); public static final Tag INFINIBURN_NETHER = BlockTypeTags.key(ResourceKey.minecraft("infiniburn_nether")); diff --git a/src/main/java/org/spongepowered/api/tag/DamageTypeTags.java b/src/main/java/org/spongepowered/api/tag/DamageTypeTags.java index e402deac3f..40c191a4c7 100644 --- a/src/main/java/org/spongepowered/api/tag/DamageTypeTags.java +++ b/src/main/java/org/spongepowered/api/tag/DamageTypeTags.java @@ -61,6 +61,8 @@ public final class DamageTypeTags { public static final Tag BYPASSES_SHIELD = DamageTypeTags.key(ResourceKey.minecraft("bypasses_shield")); + public static final Tag BYPASSES_WOLF_ARMOR = DamageTypeTags.key(ResourceKey.minecraft("bypasses_wolf_armor")); + public static final Tag CAN_BREAK_ARMOR_STAND = DamageTypeTags.key(ResourceKey.minecraft("can_break_armor_stand")); public static final Tag DAMAGES_HELMET = DamageTypeTags.key(ResourceKey.minecraft("damages_helmet")); @@ -79,6 +81,8 @@ public final class DamageTypeTags { public static final Tag IS_LIGHTNING = DamageTypeTags.key(ResourceKey.minecraft("is_lightning")); + public static final Tag IS_PLAYER_ATTACK = DamageTypeTags.key(ResourceKey.minecraft("is_player_attack")); + public static final Tag IS_PROJECTILE = DamageTypeTags.key(ResourceKey.minecraft("is_projectile")); public static final Tag NO_ANGER = DamageTypeTags.key(ResourceKey.minecraft("no_anger")); diff --git a/src/main/java/org/spongepowered/api/tag/EntityTypeTags.java b/src/main/java/org/spongepowered/api/tag/EntityTypeTags.java index 8d218f13c7..74b7fc4804 100644 --- a/src/main/java/org/spongepowered/api/tag/EntityTypeTags.java +++ b/src/main/java/org/spongepowered/api/tag/EntityTypeTags.java @@ -37,8 +37,12 @@ @RegistryScopes(scopes = RegistryScope.GAME) public final class EntityTypeTags { + public static final Tag> AQUATIC = EntityTypeTags.key(ResourceKey.minecraft("aquatic")); + public static final Tag> ARROWS = EntityTypeTags.key(ResourceKey.minecraft("arrows")); + public static final Tag> ARTHROPOD = EntityTypeTags.key(ResourceKey.minecraft("arthropod")); + public static final Tag> AXOLOTL_ALWAYS_HOSTILES = EntityTypeTags.key(ResourceKey.minecraft("axolotl_always_hostiles")); public static final Tag> AXOLOTL_HUNT_TARGETS = EntityTypeTags.key(ResourceKey.minecraft("axolotl_hunt_targets")); @@ -57,18 +61,38 @@ public final class EntityTypeTags { public static final Tag> FROG_FOOD = EntityTypeTags.key(ResourceKey.minecraft("frog_food")); + public static final Tag> IGNORES_POISON_AND_REGEN = EntityTypeTags.key(ResourceKey.minecraft("ignores_poison_and_regen")); + + public static final Tag> ILLAGER = EntityTypeTags.key(ResourceKey.minecraft("illager")); + + public static final Tag> ILLAGER_FRIENDS = EntityTypeTags.key(ResourceKey.minecraft("illager_friends")); + public static final Tag> IMPACT_PROJECTILES = EntityTypeTags.key(ResourceKey.minecraft("impact_projectiles")); + public static final Tag> INVERTED_HEALING_AND_HARM = EntityTypeTags.key(ResourceKey.minecraft("inverted_healing_and_harm")); + public static final Tag> NON_CONTROLLING_RIDER = EntityTypeTags.key(ResourceKey.minecraft("non_controlling_rider")); + public static final Tag> NOT_SCARY_FOR_PUFFERFISH = EntityTypeTags.key(ResourceKey.minecraft("not_scary_for_pufferfish")); + public static final Tag> POWDER_SNOW_WALKABLE_MOBS = EntityTypeTags.key(ResourceKey.minecraft("powder_snow_walkable_mobs")); public static final Tag> RAIDERS = EntityTypeTags.key(ResourceKey.minecraft("raiders")); + public static final Tag> REDIRECTABLE_PROJECTILE = EntityTypeTags.key(ResourceKey.minecraft("redirectable_projectile")); + + public static final Tag> SENSITIVE_TO_BANE_OF_ARTHROPODS = EntityTypeTags.key(ResourceKey.minecraft("sensitive_to_bane_of_arthropods")); + + public static final Tag> SENSITIVE_TO_IMPALING = EntityTypeTags.key(ResourceKey.minecraft("sensitive_to_impaling")); + + public static final Tag> SENSITIVE_TO_SMITE = EntityTypeTags.key(ResourceKey.minecraft("sensitive_to_smite")); + public static final Tag> SKELETONS = EntityTypeTags.key(ResourceKey.minecraft("skeletons")); public static final Tag> UNDEAD = EntityTypeTags.key(ResourceKey.minecraft("undead")); + public static final Tag> WITHER_FRIENDS = EntityTypeTags.key(ResourceKey.minecraft("wither_friends")); + public static final Tag> ZOMBIES = EntityTypeTags.key(ResourceKey.minecraft("zombies")); private EntityTypeTags() { diff --git a/src/main/java/org/spongepowered/api/tag/ItemTypeTags.java b/src/main/java/org/spongepowered/api/tag/ItemTypeTags.java index 45a5290347..8d9478114b 100644 --- a/src/main/java/org/spongepowered/api/tag/ItemTypeTags.java +++ b/src/main/java/org/spongepowered/api/tag/ItemTypeTags.java @@ -41,11 +41,13 @@ public final class ItemTypeTags { public static final Tag ANVIL = ItemTypeTags.key(ResourceKey.minecraft("anvil")); + public static final Tag ARMADILLO_FOOD = ItemTypeTags.key(ResourceKey.minecraft("armadillo_food")); + public static final Tag ARROWS = ItemTypeTags.key(ResourceKey.minecraft("arrows")); public static final Tag AXES = ItemTypeTags.key(ResourceKey.minecraft("axes")); - public static final Tag AXOLOTL_TEMPT_ITEMS = ItemTypeTags.key(ResourceKey.minecraft("axolotl_tempt_items")); + public static final Tag AXOLOTL_FOOD = ItemTypeTags.key(ResourceKey.minecraft("axolotl_food")); public static final Tag BAMBOO_BLOCKS = ItemTypeTags.key(ResourceKey.minecraft("bamboo_blocks")); @@ -55,6 +57,8 @@ public final class ItemTypeTags { public static final Tag BEDS = ItemTypeTags.key(ResourceKey.minecraft("beds")); + public static final Tag BEE_FOOD = ItemTypeTags.key(ResourceKey.minecraft("bee_food")); + public static final Tag BIRCH_LOGS = ItemTypeTags.key(ResourceKey.minecraft("birch_logs")); public static final Tag BOATS = ItemTypeTags.key(ResourceKey.minecraft("boats")); @@ -65,12 +69,20 @@ public final class ItemTypeTags { public static final Tag BUTTONS = ItemTypeTags.key(ResourceKey.minecraft("buttons")); + public static final Tag CAMEL_FOOD = ItemTypeTags.key(ResourceKey.minecraft("camel_food")); + public static final Tag CANDLES = ItemTypeTags.key(ResourceKey.minecraft("candles")); + public static final Tag CAT_FOOD = ItemTypeTags.key(ResourceKey.minecraft("cat_food")); + public static final Tag CHERRY_LOGS = ItemTypeTags.key(ResourceKey.minecraft("cherry_logs")); + public static final Tag CHEST_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("chest_armor")); + public static final Tag CHEST_BOATS = ItemTypeTags.key(ResourceKey.minecraft("chest_boats")); + public static final Tag CHICKEN_FOOD = ItemTypeTags.key(ResourceKey.minecraft("chicken_food")); + public static final Tag CLUSTER_MAX_HARVESTABLES = ItemTypeTags.key(ResourceKey.minecraft("cluster_max_harvestables")); public static final Tag COAL_ORES = ItemTypeTags.key(ResourceKey.minecraft("coal_ores")); @@ -83,6 +95,8 @@ public final class ItemTypeTags { public static final Tag COPPER_ORES = ItemTypeTags.key(ResourceKey.minecraft("copper_ores")); + public static final Tag COW_FOOD = ItemTypeTags.key(ResourceKey.minecraft("cow_food")); + public static final Tag CREEPER_DROP_MUSIC_DISCS = ItemTypeTags.key(ResourceKey.minecraft("creeper_drop_music_discs")); public static final Tag CREEPER_IGNITERS = ItemTypeTags.key(ResourceKey.minecraft("creeper_igniters")); @@ -103,8 +117,46 @@ public final class ItemTypeTags { public static final Tag DOORS = ItemTypeTags.key(ResourceKey.minecraft("doors")); + public static final Tag DYEABLE = ItemTypeTags.key(ResourceKey.minecraft("dyeable")); + public static final Tag EMERALD_ORES = ItemTypeTags.key(ResourceKey.minecraft("emerald_ores")); + public static final Tag ENCHANTABLE_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("enchantable/armor")); + + public static final Tag ENCHANTABLE_BOW = ItemTypeTags.key(ResourceKey.minecraft("enchantable/bow")); + + public static final Tag ENCHANTABLE_CHEST_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("enchantable/chest_armor")); + + public static final Tag ENCHANTABLE_CROSSBOW = ItemTypeTags.key(ResourceKey.minecraft("enchantable/crossbow")); + + public static final Tag ENCHANTABLE_DURABILITY = ItemTypeTags.key(ResourceKey.minecraft("enchantable/durability")); + + public static final Tag ENCHANTABLE_EQUIPPABLE = ItemTypeTags.key(ResourceKey.minecraft("enchantable/equippable")); + + public static final Tag ENCHANTABLE_FIRE_ASPECT = ItemTypeTags.key(ResourceKey.minecraft("enchantable/fire_aspect")); + + public static final Tag ENCHANTABLE_FISHING = ItemTypeTags.key(ResourceKey.minecraft("enchantable/fishing")); + + public static final Tag ENCHANTABLE_FOOT_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("enchantable/foot_armor")); + + public static final Tag ENCHANTABLE_HEAD_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("enchantable/head_armor")); + + public static final Tag ENCHANTABLE_LEG_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("enchantable/leg_armor")); + + public static final Tag ENCHANTABLE_MINING = ItemTypeTags.key(ResourceKey.minecraft("enchantable/mining")); + + public static final Tag ENCHANTABLE_MINING_LOOT = ItemTypeTags.key(ResourceKey.minecraft("enchantable/mining_loot")); + + public static final Tag ENCHANTABLE_SHARP_WEAPON = ItemTypeTags.key(ResourceKey.minecraft("enchantable/sharp_weapon")); + + public static final Tag ENCHANTABLE_SWORD = ItemTypeTags.key(ResourceKey.minecraft("enchantable/sword")); + + public static final Tag ENCHANTABLE_TRIDENT = ItemTypeTags.key(ResourceKey.minecraft("enchantable/trident")); + + public static final Tag ENCHANTABLE_VANISHING = ItemTypeTags.key(ResourceKey.minecraft("enchantable/vanishing")); + + public static final Tag ENCHANTABLE_WEAPON = ItemTypeTags.key(ResourceKey.minecraft("enchantable/weapon")); + public static final Tag FENCE_GATES = ItemTypeTags.key(ResourceKey.minecraft("fence_gates")); public static final Tag FENCES = ItemTypeTags.key(ResourceKey.minecraft("fences")); @@ -113,16 +165,30 @@ public final class ItemTypeTags { public static final Tag FLOWERS = ItemTypeTags.key(ResourceKey.minecraft("flowers")); + public static final Tag FOOT_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("foot_armor")); + public static final Tag FOX_FOOD = ItemTypeTags.key(ResourceKey.minecraft("fox_food")); public static final Tag FREEZE_IMMUNE_WEARABLES = ItemTypeTags.key(ResourceKey.minecraft("freeze_immune_wearables")); + public static final Tag FROG_FOOD = ItemTypeTags.key(ResourceKey.minecraft("frog_food")); + + public static final Tag GOAT_FOOD = ItemTypeTags.key(ResourceKey.minecraft("goat_food")); + public static final Tag GOLD_ORES = ItemTypeTags.key(ResourceKey.minecraft("gold_ores")); public static final Tag HANGING_SIGNS = ItemTypeTags.key(ResourceKey.minecraft("hanging_signs")); + public static final Tag HEAD_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("head_armor")); + public static final Tag HOES = ItemTypeTags.key(ResourceKey.minecraft("hoes")); + public static final Tag HOGLIN_FOOD = ItemTypeTags.key(ResourceKey.minecraft("hoglin_food")); + + public static final Tag HORSE_FOOD = ItemTypeTags.key(ResourceKey.minecraft("horse_food")); + + public static final Tag HORSE_TEMPT_ITEMS = ItemTypeTags.key(ResourceKey.minecraft("horse_tempt_items")); + public static final Tag IGNORED_BY_PIGLIN_BABIES = ItemTypeTags.key(ResourceKey.minecraft("ignored_by_piglin_babies")); public static final Tag IRON_ORES = ItemTypeTags.key(ResourceKey.minecraft("iron_ores")); @@ -135,12 +201,20 @@ public final class ItemTypeTags { public static final Tag LECTERN_BOOKS = ItemTypeTags.key(ResourceKey.minecraft("lectern_books")); + public static final Tag LEG_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("leg_armor")); + + public static final Tag LLAMA_FOOD = ItemTypeTags.key(ResourceKey.minecraft("llama_food")); + + public static final Tag LLAMA_TEMPT_ITEMS = ItemTypeTags.key(ResourceKey.minecraft("llama_tempt_items")); + public static final Tag LOGS = ItemTypeTags.key(ResourceKey.minecraft("logs")); public static final Tag LOGS_THAT_BURN = ItemTypeTags.key(ResourceKey.minecraft("logs_that_burn")); public static final Tag MANGROVE_LOGS = ItemTypeTags.key(ResourceKey.minecraft("mangrove_logs")); + public static final Tag MEAT = ItemTypeTags.key(ResourceKey.minecraft("meat")); + public static final Tag MUSIC_DISCS = ItemTypeTags.key(ResourceKey.minecraft("music_discs")); public static final Tag NON_FLAMMABLE_WOOD = ItemTypeTags.key(ResourceKey.minecraft("non_flammable_wood")); @@ -149,8 +223,18 @@ public final class ItemTypeTags { public static final Tag OAK_LOGS = ItemTypeTags.key(ResourceKey.minecraft("oak_logs")); + public static final Tag OCELOT_FOOD = ItemTypeTags.key(ResourceKey.minecraft("ocelot_food")); + + public static final Tag PANDA_FOOD = ItemTypeTags.key(ResourceKey.minecraft("panda_food")); + + public static final Tag PARROT_FOOD = ItemTypeTags.key(ResourceKey.minecraft("parrot_food")); + + public static final Tag PARROT_POISONOUS_FOOD = ItemTypeTags.key(ResourceKey.minecraft("parrot_poisonous_food")); + public static final Tag PICKAXES = ItemTypeTags.key(ResourceKey.minecraft("pickaxes")); + public static final Tag PIG_FOOD = ItemTypeTags.key(ResourceKey.minecraft("pig_food")); + public static final Tag PIGLIN_FOOD = ItemTypeTags.key(ResourceKey.minecraft("piglin_food")); public static final Tag PIGLIN_LOVED = ItemTypeTags.key(ResourceKey.minecraft("piglin_loved")); @@ -159,6 +243,8 @@ public final class ItemTypeTags { public static final Tag PLANKS = ItemTypeTags.key(ResourceKey.minecraft("planks")); + public static final Tag RABBIT_FOOD = ItemTypeTags.key(ResourceKey.minecraft("rabbit_food")); + public static final Tag RAILS = ItemTypeTags.key(ResourceKey.minecraft("rails")); public static final Tag REDSTONE_ORES = ItemTypeTags.key(ResourceKey.minecraft("redstone_ores")); @@ -167,10 +253,14 @@ public final class ItemTypeTags { public static final Tag SAPLINGS = ItemTypeTags.key(ResourceKey.minecraft("saplings")); + public static final Tag SHEEP_FOOD = ItemTypeTags.key(ResourceKey.minecraft("sheep_food")); + public static final Tag SHOVELS = ItemTypeTags.key(ResourceKey.minecraft("shovels")); public static final Tag SIGNS = ItemTypeTags.key(ResourceKey.minecraft("signs")); + public static final Tag SKULLS = ItemTypeTags.key(ResourceKey.minecraft("skulls")); + public static final Tag SLABS = ItemTypeTags.key(ResourceKey.minecraft("slabs")); public static final Tag SMALL_FLOWERS = ItemTypeTags.key(ResourceKey.minecraft("small_flowers")); @@ -193,14 +283,16 @@ public final class ItemTypeTags { public static final Tag STONE_TOOL_MATERIALS = ItemTypeTags.key(ResourceKey.minecraft("stone_tool_materials")); + public static final Tag STRIDER_FOOD = ItemTypeTags.key(ResourceKey.minecraft("strider_food")); + + public static final Tag STRIDER_TEMPT_ITEMS = ItemTypeTags.key(ResourceKey.minecraft("strider_tempt_items")); + public static final Tag SWORDS = ItemTypeTags.key(ResourceKey.minecraft("swords")); public static final Tag TALL_FLOWERS = ItemTypeTags.key(ResourceKey.minecraft("tall_flowers")); public static final Tag TERRACOTTA = ItemTypeTags.key(ResourceKey.minecraft("terracotta")); - public static final Tag TOOLS = ItemTypeTags.key(ResourceKey.minecraft("tools")); - public static final Tag TRAPDOORS = ItemTypeTags.key(ResourceKey.minecraft("trapdoors")); public static final Tag TRIM_MATERIALS = ItemTypeTags.key(ResourceKey.minecraft("trim_materials")); @@ -209,6 +301,8 @@ public final class ItemTypeTags { public static final Tag TRIMMABLE_ARMOR = ItemTypeTags.key(ResourceKey.minecraft("trimmable_armor")); + public static final Tag TURTLE_FOOD = ItemTypeTags.key(ResourceKey.minecraft("turtle_food")); + public static final Tag VILLAGER_PLANTABLE_SEEDS = ItemTypeTags.key(ResourceKey.minecraft("villager_plantable_seeds")); public static final Tag WALLS = ItemTypeTags.key(ResourceKey.minecraft("walls")); @@ -217,6 +311,8 @@ public final class ItemTypeTags { public static final Tag WART_BLOCKS = ItemTypeTags.key(ResourceKey.minecraft("wart_blocks")); + public static final Tag WOLF_FOOD = ItemTypeTags.key(ResourceKey.minecraft("wolf_food")); + public static final Tag WOODEN_BUTTONS = ItemTypeTags.key(ResourceKey.minecraft("wooden_buttons")); public static final Tag WOODEN_DOORS = ItemTypeTags.key(ResourceKey.minecraft("wooden_doors")); diff --git a/src/main/java/org/spongepowered/api/world/gamerule/GameRules.java b/src/main/java/org/spongepowered/api/world/gamerule/GameRules.java index 1772e238d6..d3cfe5cb42 100644 --- a/src/main/java/org/spongepowered/api/world/gamerule/GameRules.java +++ b/src/main/java/org/spongepowered/api/world/gamerule/GameRules.java @@ -130,6 +130,8 @@ public final class GameRules { public static final DefaultedRegistryReference> SNOW_ACCUMULATION_HEIGHT = GameRules.key(ResourceKey.sponge("snow_accumulation_height")); + public static final DefaultedRegistryReference> SPAWN_CHUNK_RADIUS = GameRules.key(ResourceKey.sponge("spawn_chunk_radius")); + public static final DefaultedRegistryReference> SPAWN_RADIUS = GameRules.key(ResourceKey.sponge("spawn_radius")); public static final DefaultedRegistryReference> SPECTATORS_GENERATE_CHUNKS = GameRules.key(ResourceKey.sponge("spectators_generate_chunks")); From e21e6cc94a4179f2c99cf3cf01a1d7e134c088e2 Mon Sep 17 00:00:00 2001 From: Morpheus Date: Thu, 16 May 2024 12:48:09 +0000 Subject: [PATCH 14/53] Bump log4j to 2.22.1 (#2505) * Bump log4j to 2.22.1 * Update verification metadata --- gradle/libs.versions.toml | 2 +- gradle/verification-metadata.xml | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0aa6e15d28..ca9f42cf71 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ guice = "5.0.1" ideaExt = "1.1.8" indra = "3.1.3" junit = "5.10.2" -log4j = "2.19.0" +log4j = "2.22.1" math = "2.0.1" mockito = "5.11.0" pluginSpi = "0.3.0" diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 886a4ab376..bf35d259c6 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -74,6 +74,11 @@ + + + + + @@ -84,11 +89,21 @@ + + + + + + + + + + @@ -632,6 +647,11 @@ + + + + + @@ -687,6 +707,21 @@ + + + + + + + + + + + + + + + @@ -997,6 +1032,11 @@ + + + + + @@ -1154,6 +1194,11 @@ + + + + + @@ -1164,6 +1209,11 @@ + + + + + @@ -1175,11 +1225,24 @@ + + + + + + + + + + + + + @@ -1355,6 +1418,11 @@ + + + + + @@ -1423,6 +1491,11 @@ + + + + + @@ -1439,6 +1512,11 @@ + + + + + @@ -1582,6 +1660,9 @@ + + + @@ -1711,6 +1792,11 @@ + + + + + From d5ac150e39682b0c7a82ae2fa5a8d3f28cd46869 Mon Sep 17 00:00:00 2001 From: Morpheus Date: Thu, 16 May 2024 15:42:47 +0000 Subject: [PATCH 15/53] Replace deprecated locale methods (#2507) --- .../api/util/locale/Locales.java | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/main/java/org/spongepowered/api/util/locale/Locales.java b/src/main/java/org/spongepowered/api/util/locale/Locales.java index 67e49cb4c8..d6ac4b3a34 100644 --- a/src/main/java/org/spongepowered/api/util/locale/Locales.java +++ b/src/main/java/org/spongepowered/api/util/locale/Locales.java @@ -43,79 +43,79 @@ public static Locale of(String locale) { return Sponge.game().locale(locale); } - public static final Locale AF_ZA = new Locale("af", "ZA"); - public static final Locale AR_SA = new Locale("ar", "SA"); - public static final Locale AST_ES = new Locale("ast", "ES"); - public static final Locale AZ_AZ = new Locale("az", "AZ"); - public static final Locale BG_BG = new Locale("bg", "BG"); - public static final Locale CA_ES = new Locale("ca", "ES"); - public static final Locale CS_CZ = new Locale("cs", "CZ"); - public static final Locale CY_GB = new Locale("cy", "GB"); - public static final Locale DA_DK = new Locale("da", "DK"); + public static final Locale AF_ZA = Locale.of("af", "ZA"); + public static final Locale AR_SA = Locale.of("ar", "SA"); + public static final Locale AST_ES = Locale.of("ast", "ES"); + public static final Locale AZ_AZ = Locale.of("az", "AZ"); + public static final Locale BG_BG = Locale.of("bg", "BG"); + public static final Locale CA_ES = Locale.of("ca", "ES"); + public static final Locale CS_CZ = Locale.of("cs", "CZ"); + public static final Locale CY_GB = Locale.of("cy", "GB"); + public static final Locale DA_DK = Locale.of("da", "DK"); public static final Locale DE_DE = Locale.GERMANY; - public static final Locale EL_GR = new Locale("el", "GR"); - public static final Locale EN_AU = new Locale("en", "AU"); - public static final Locale EN_CA = new Locale("en", "CA"); + public static final Locale EL_GR = Locale.of("el", "GR"); + public static final Locale EN_AU = Locale.of("en", "AU"); + public static final Locale EN_CA = Locale.of("en", "CA"); public static final Locale EN_GB = Locale.UK; - public static final Locale EN_PT = new Locale("en", "PT"); + public static final Locale EN_PT = Locale.of("en", "PT"); public static final Locale EN_US = Locale.US; - public static final Locale EO_UY = new Locale("eo", "UY"); - public static final Locale ES_AR = new Locale("es", "AR"); - public static final Locale ES_ES = new Locale("es", "ES"); - public static final Locale ES_MX = new Locale("es", "MX"); - public static final Locale ES_UY = new Locale("es", "UY"); - public static final Locale ES_VE = new Locale("es", "VE"); - public static final Locale ET_EE = new Locale("et", "EE"); - public static final Locale EU_ES = new Locale("eu", "ES"); - public static final Locale FA_IR = new Locale("fa", "IR"); - public static final Locale FI_FI = new Locale("fi", "FI"); - public static final Locale FIL_PH = new Locale("fil", "PH"); + public static final Locale EO_UY = Locale.of("eo", "UY"); + public static final Locale ES_AR = Locale.of("es", "AR"); + public static final Locale ES_ES = Locale.of("es", "ES"); + public static final Locale ES_MX = Locale.of("es", "MX"); + public static final Locale ES_UY = Locale.of("es", "UY"); + public static final Locale ES_VE = Locale.of("es", "VE"); + public static final Locale ET_EE = Locale.of("et", "EE"); + public static final Locale EU_ES = Locale.of("eu", "ES"); + public static final Locale FA_IR = Locale.of("fa", "IR"); + public static final Locale FI_FI = Locale.of("fi", "FI"); + public static final Locale FIL_PH = Locale.of("fil", "PH"); public static final Locale FR_CA = Locale.CANADA_FRENCH; public static final Locale FR_FR = Locale.FRANCE; - public static final Locale GA_IE = new Locale("ga", "IE"); - public static final Locale GL_ES = new Locale("gl", "ES"); - public static final Locale GV_IM = new Locale("gv", "IM"); - public static final Locale HE_IL = new Locale("he", "IL"); - public static final Locale HI_IN = new Locale("hi", "IN"); - public static final Locale HR_HR = new Locale("hr", "HR"); - public static final Locale HU_HU = new Locale("hu", "HU"); - public static final Locale HY_AM = new Locale("hy", "AM"); - public static final Locale ID_ID = new Locale("id", "ID"); - public static final Locale IS_IS = new Locale("is", "IS"); + public static final Locale GA_IE = Locale.of("ga", "IE"); + public static final Locale GL_ES = Locale.of("gl", "ES"); + public static final Locale GV_IM = Locale.of("gv", "IM"); + public static final Locale HE_IL = Locale.of("he", "IL"); + public static final Locale HI_IN = Locale.of("hi", "IN"); + public static final Locale HR_HR = Locale.of("hr", "HR"); + public static final Locale HU_HU = Locale.of("hu", "HU"); + public static final Locale HY_AM = Locale.of("hy", "AM"); + public static final Locale ID_ID = Locale.of("id", "ID"); + public static final Locale IS_IS = Locale.of("is", "IS"); public static final Locale IT_IT = Locale.ITALY; public static final Locale JA_JP = Locale.JAPAN; - public static final Locale KA_GE = new Locale("ka", "GE"); + public static final Locale KA_GE = Locale.of("ka", "GE"); public static final Locale KO_KR = Locale.KOREA; - public static final Locale KW_GB = new Locale("kw", "GB"); - public static final Locale LA_LA = new Locale("la", "LA"); - public static final Locale LB_LU = new Locale("lb", "LU"); - public static final Locale LT_LT = new Locale("lt", "LT"); - public static final Locale LV_LV = new Locale("lv", "LV"); - public static final Locale MI_NZ = new Locale("mi", "NZ"); - public static final Locale MS_MY = new Locale("ms", "MY"); - public static final Locale MT_MT = new Locale("mt", "MT"); - public static final Locale NDS_DE = new Locale("nds", "DE"); - public static final Locale NL_NL = new Locale("nl", "NL"); - public static final Locale NN_NO = new Locale("nn", "NO"); - public static final Locale NO_NO = new Locale("no", "NO"); - public static final Locale OC_FR = new Locale("oc", "FR"); - public static final Locale PL_PL = new Locale("pl", "PL"); - public static final Locale PT_BR = new Locale("pt", "BR"); - public static final Locale PT_PT = new Locale("pt", "PT"); - public static final Locale QYA_AA = new Locale("qya", "AA"); - public static final Locale RO_RO = new Locale("ro", "RO"); - public static final Locale RU_RU = new Locale("ru", "RU"); - public static final Locale SE_NO = new Locale("se", "NO"); - public static final Locale SK_SK = new Locale("sk", "SK"); - public static final Locale SL_SI = new Locale("sl", "SI"); - public static final Locale SR_SP = new Locale("sr", "SP"); - public static final Locale SV_SE = new Locale("sv", "SE"); - public static final Locale TH_TH = new Locale("th", "TH"); - public static final Locale TLH_AA = new Locale("tlh", "AA"); - public static final Locale TR_TR = new Locale("tr", "TR"); - public static final Locale UK_UA = new Locale("uk", "UA"); - public static final Locale VAL_ES = new Locale("val", "ES"); - public static final Locale VI_VN = new Locale("vi", "VN"); + public static final Locale KW_GB = Locale.of("kw", "GB"); + public static final Locale LA_LA = Locale.of("la", "LA"); + public static final Locale LB_LU = Locale.of("lb", "LU"); + public static final Locale LT_LT = Locale.of("lt", "LT"); + public static final Locale LV_LV = Locale.of("lv", "LV"); + public static final Locale MI_NZ = Locale.of("mi", "NZ"); + public static final Locale MS_MY = Locale.of("ms", "MY"); + public static final Locale MT_MT = Locale.of("mt", "MT"); + public static final Locale NDS_DE = Locale.of("nds", "DE"); + public static final Locale NL_NL = Locale.of("nl", "NL"); + public static final Locale NN_NO = Locale.of("nn", "NO"); + public static final Locale NO_NO = Locale.of("no", "NO"); + public static final Locale OC_FR = Locale.of("oc", "FR"); + public static final Locale PL_PL = Locale.of("pl", "PL"); + public static final Locale PT_BR = Locale.of("pt", "BR"); + public static final Locale PT_PT = Locale.of("pt", "PT"); + public static final Locale QYA_AA = Locale.of("qya", "AA"); + public static final Locale RO_RO = Locale.of("ro", "RO"); + public static final Locale RU_RU = Locale.of("ru", "RU"); + public static final Locale SE_NO = Locale.of("se", "NO"); + public static final Locale SK_SK = Locale.of("sk", "SK"); + public static final Locale SL_SI = Locale.of("sl", "SI"); + public static final Locale SR_SP = Locale.of("sr", "SP"); + public static final Locale SV_SE = Locale.of("sv", "SE"); + public static final Locale TH_TH = Locale.of("th", "TH"); + public static final Locale TLH_AA = Locale.of("tlh", "AA"); + public static final Locale TR_TR = Locale.of("tr", "TR"); + public static final Locale UK_UA = Locale.of("uk", "UA"); + public static final Locale VAL_ES = Locale.of("val", "ES"); + public static final Locale VI_VN = Locale.of("vi", "VN"); public static final Locale ZH_CN = Locale.SIMPLIFIED_CHINESE; public static final Locale ZH_TW = Locale.TRADITIONAL_CHINESE; From aca1deab7718573d0585f1ca833056d8a0d9b94f Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 18 May 2024 03:45:19 -0700 Subject: [PATCH 16/53] Allow custom TicketTypes to be created by plugins. (#2453) * Allow custom TicketTypes to be created by plugins. - Remove TicketTypes from being in the registry. They are not within the registry whatsoever in the base game nor is a resource id required to create them. Thus being impossible to maintain that contract Signed-off-by: Chris Sanders * We won't be exposing Vanilla's tickets Signed-off-by: Chris Sanders * Update on top of Tickets#infinite --------- Signed-off-by: Chris Sanders Co-authored-by: Chris Sanders Co-authored-by: aromaa --- .../api/world/server/ChunkManager.java | 63 ------------ .../api/world/server/TicketType.java | 59 ++++++++++- .../api/world/server/TicketTypes.java | 98 ------------------- 3 files changed, 56 insertions(+), 164 deletions(-) delete mode 100644 src/main/java/org/spongepowered/api/world/server/TicketTypes.java diff --git a/src/main/java/org/spongepowered/api/world/server/ChunkManager.java b/src/main/java/org/spongepowered/api/world/server/ChunkManager.java index 1c8c20d48b..9e3ebbfda5 100644 --- a/src/main/java/org/spongepowered/api/world/server/ChunkManager.java +++ b/src/main/java/org/spongepowered/api/world/server/ChunkManager.java @@ -24,7 +24,6 @@ */ package org.spongepowered.api.world.server; -import org.spongepowered.api.registry.DefaultedRegistryReference; import org.spongepowered.api.util.Ticks; import org.spongepowered.api.util.annotation.DoNotStore; import org.spongepowered.api.world.ChunkRegenerateFlag; @@ -66,38 +65,6 @@ public interface ChunkManager { */ Ticks timeLeft(Ticket ticket); - /** - * Request a {@link Ticket} for a given {@link TicketType} that supports a - * chunk position. - * - * @param type The type of ticket to request. - * @param chunkOrigin The chunk co-ordinates of the central {@link WorldChunk} - * affected by this {@link Ticket} - * @param radius The radius of the area, in chunks, that this {@link Ticket} - * affects. - * @return The ticket, if granted. - */ - default Optional> requestTicket(final DefaultedRegistryReference> type, - final Vector3i chunkOrigin, final int radius) { - return this.requestTicket(type.get(), chunkOrigin, radius); - } - - /** - * Request a {@link Ticket} for a given {@link TicketType} that supports a - * chunk position. - * - * @param type The type of ticket to request. - * @param chunkOrigin The chunk co-ordinates of the central {@link WorldChunk} - * affected by this {@link Ticket} - * @param radius The radius of the area, in chunks, that this {@link Ticket} - * affects. - * @return The ticket, if granted. - */ - default Optional> requestTicket(final TicketType type, final Vector3i chunkOrigin, - final int radius) { - return this.requestTicket(type, chunkOrigin, chunkOrigin, radius); - } - /** * Request a {@link Ticket} for the given {@link TicketType}. * @@ -112,24 +79,6 @@ default Optional> requestTicket(final TicketType type */ Optional> requestTicket(TicketType type, Vector3i chunkOrigin, T value, int radius); - /** - * Request a {@link Ticket} for the given {@link TicketType}. - * - * @param type The type of ticket to request. - * @param chunkOrigin The chunk co-ordinates of the central {@link WorldChunk} - * affected by this {@link Ticket} - * @param value The value to register the ticket with. - * @param radius The radius of the area, in chunks, that this {@link Ticket} - * affects. This may be capped - for the Vanilla impl, this is - * limited to a radius of 33 chunks. - * @param The type of the supplied {@code value}. - * @return The ticket, if granted. - */ - default Optional> requestTicket(final DefaultedRegistryReference> type, - final Vector3i chunkOrigin, final T value, final int radius) { - return this.requestTicket(type.get(), chunkOrigin, value, radius); - } - /** * Attempts to renew this ticket, resetting the lifetime to the default. * @@ -160,18 +109,6 @@ default Optional> requestTicket(final DefaultedRegistryReference Collection> findTickets(TicketType type); - /** - * Gets all currently active {@link Ticket tickets} that are of the - * provided {@link TicketType}. - * - * @param type The {@link TicketType} to retrieve tickets for - * @param The type of value the {@link Ticket} holds - * @return A {@link Collection} of {@link Ticket tickets} - */ - default Collection> findTickets(final DefaultedRegistryReference> type) { - return this.findTickets(type.get()); - } - /** * Regenerates a chunk at the given chunk coordinate position. * diff --git a/src/main/java/org/spongepowered/api/world/server/TicketType.java b/src/main/java/org/spongepowered/api/world/server/TicketType.java index 7740ddce44..f16f082d40 100644 --- a/src/main/java/org/spongepowered/api/world/server/TicketType.java +++ b/src/main/java/org/spongepowered/api/world/server/TicketType.java @@ -24,8 +24,13 @@ */ package org.spongepowered.api.world.server; +import org.checkerframework.checker.nullness.qual.NonNull; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.util.ResettableBuilder; import org.spongepowered.api.util.Ticks; -import org.spongepowered.api.util.annotation.CatalogedBy; + +import java.util.Comparator; /** * Represents a type of {@link Ticket chunk loading ticket} that can be obtained @@ -34,8 +39,19 @@ * @param The type of value that is associated with a {@link Ticket} of this * type. */ -@CatalogedBy(TicketTypes.class) -public interface TicketType { +@SuppressWarnings("unchecked") +public interface TicketType { + + static Builder builder() { + return Sponge.game().builderProvider().provide(Builder.class); + } + + /** + * The name of this type. + * + * @return The name + */ + String name(); /** * Gets the lifetime of any {@link Ticket tickets} of this type. @@ -45,4 +61,41 @@ public interface TicketType { */ Ticks lifetime(); + interface Builder extends ResettableBuilder> { + + /** + * Sets the name of the {@link TicketType type}. + * + * @param name The name + * @return The builder, for chaining + */ + Builder name(@NonNull String name); + + /** + * Sets the {@link Comparator comparator} used by requested {@link Ticket tickets} + * of this type used to determine the appropriate ticket to be used during collisions. + *

+ * If this call is omitted, it is up to the implementation on how the comparison is handled. + * In the official implementation, the resulting comparison value is '0'. + * + * @param comparator The comparator + * @return The builder, for chaining + */ + Builder comparator(@Nullable Comparator comparator); + + /** + * Sets the lifetime of the {@link TicketType type}. + * + * @param lifetime The lifetime + * @return The builder, for chaining + */ + Builder lifetime(Ticks lifetime); + + /** + * Builds a new {@link TicketType type}. + * + * @return The type + */ + TicketType build(); + } } diff --git a/src/main/java/org/spongepowered/api/world/server/TicketTypes.java b/src/main/java/org/spongepowered/api/world/server/TicketTypes.java deleted file mode 100644 index 277e432876..0000000000 --- a/src/main/java/org/spongepowered/api/world/server/TicketTypes.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.world.server; - -import org.spongepowered.api.ResourceKey; -import org.spongepowered.api.Sponge; -import org.spongepowered.api.entity.Entity; -import org.spongepowered.api.registry.DefaultedRegistryReference; -import org.spongepowered.api.registry.Registry; -import org.spongepowered.api.registry.RegistryKey; -import org.spongepowered.api.registry.RegistryTypes; -import org.spongepowered.api.util.Ticks; -import org.spongepowered.api.world.chunk.WorldChunk; -import org.spongepowered.api.world.portal.Portal; -import org.spongepowered.math.vector.Vector3i; - -/** - * Types of {@link Ticket tickets} that can be requested via the - * {@link ChunkManager}. - */ -public final class TicketTypes { - - // @formatter:off - - // SORTFIELDS:ON - - /** - * Represents {@link Ticket tickets} that ensures the target - * {@link WorldChunk chunks} are loaded, but are not guaranteed to be loaded at - * any time in the future, that is, the lifetime of such a ticket is - * effectively one {@link Ticks tick}. - * - *

The position represented by the {@link Vector3i} is a chunk - * position, not a block position, so when requesting a ticket - * using {@link ChunkManager#requestTicket( TicketType, Vector3i, Object, int)}, - * the second and third parameter should be the same.

- */ - public static final DefaultedRegistryReference> STANDARD = TicketTypes.key(ResourceKey.sponge("standard")); - - /** - * Represents {@link Ticket tickets} that are intended to ensure that the - * target {@link WorldChunk chunks} around a {@link Portal} are loaded, ready to - * accept {@link Entity entities} that travel through it. - * - *

The position represented by the {@link Vector3i} is a block - * position, specifically, it is intended it is that of the exit - * point of a portal. When requesting a ticket using - * {@link ChunkManager#requestTicket( TicketType, Vector3i, Object, int)}, - * the second parameter represents a chunk position, the third parameter - * represents a block position.

- */ - public static final DefaultedRegistryReference> PORTAL = TicketTypes.key(ResourceKey.sponge("portal")); - - /** - * Represents {@link Ticket tickets} that are intended to ensure that the - * target {@link WorldChunk chunks} around an {@link Entity} are loaded after - * teleportation. - */ - public static final DefaultedRegistryReference> POST_TELEPORT = TicketTypes.key(ResourceKey.sponge("post_teleport")); - - // SORTFIELDS:OFF - - // @formatter:on - - private TicketTypes() { - } - - public static Registry> registry() { - return Sponge.game().registry(RegistryTypes.TICKET_TYPE); - } - - private static DefaultedRegistryReference> key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.TICKET_TYPE, location).asDefaultedReference(Sponge::game); - } - -} From a6f2cfdba45835126f70d9b2b70153d0960e3803 Mon Sep 17 00:00:00 2001 From: aromaa Date: Sat, 18 May 2024 17:52:08 +0300 Subject: [PATCH 17/53] Use Adventure ResourcePackInfo --- .../java/org/spongepowered/api/Server.java | 6 +- .../api/command/CommandExecutor.java | 1 + .../living/player/server/ServerPlayer.java | 8 -- .../player/ResourcePackStatusEvent.java | 82 ++++--------- .../network/ServerSideConnectionEvent.java | 1 + .../api/resourcepack/ResourcePack.java | 108 ------------------ .../api/resourcepack/package-info.java | 26 ----- 7 files changed, 30 insertions(+), 202 deletions(-) delete mode 100644 src/main/java/org/spongepowered/api/resourcepack/ResourcePack.java delete mode 100644 src/main/java/org/spongepowered/api/resourcepack/package-info.java diff --git a/src/main/java/org/spongepowered/api/Server.java b/src/main/java/org/spongepowered/api/Server.java index 229aa001a5..7f953b13a3 100644 --- a/src/main/java/org/spongepowered/api/Server.java +++ b/src/main/java/org/spongepowered/api/Server.java @@ -26,6 +26,7 @@ import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.ForwardingAudience; +import net.kyori.adventure.resource.ResourcePackRequest; import net.kyori.adventure.text.Component; import org.spongepowered.api.block.entity.CommandBlock; import org.spongepowered.api.command.manager.CommandManager; @@ -38,7 +39,6 @@ import org.spongepowered.api.map.MapStorage; import org.spongepowered.api.network.ServerSideConnection; import org.spongepowered.api.profile.GameProfileManager; -import org.spongepowered.api.resourcepack.ResourcePack; import org.spongepowered.api.scoreboard.Scoreboard; import org.spongepowered.api.service.ServiceProvider; import org.spongepowered.api.user.UserManager; @@ -131,11 +131,11 @@ public interface Server extends ForwardingAudience, Engine, LocaleSource { Component motd(); /** - * Gets the {@link ResourcePack pack} sent to clients when they join. + * Gets the {@link ResourcePackRequest pack} sent to clients when they join. * * @return The resource pack */ - Optional resourcePack(); + Optional resourcePack(); /** * Gets the player idle timeout, in minutes. diff --git a/src/main/java/org/spongepowered/api/command/CommandExecutor.java b/src/main/java/org/spongepowered/api/command/CommandExecutor.java index b154f6f59b..856e2c0e15 100644 --- a/src/main/java/org/spongepowered/api/command/CommandExecutor.java +++ b/src/main/java/org/spongepowered/api/command/CommandExecutor.java @@ -27,6 +27,7 @@ import org.spongepowered.api.command.exception.CommandException; import org.spongepowered.api.command.parameter.CommandContext; + /** * Interface containing the method directing how a certain command will * be executed. diff --git a/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java b/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java index 48faf20679..8f3b1d2636 100644 --- a/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java +++ b/src/main/java/org/spongepowered/api/entity/living/player/server/ServerPlayer.java @@ -48,7 +48,6 @@ import org.spongepowered.api.item.inventory.Container; import org.spongepowered.api.item.inventory.Inventory; import org.spongepowered.api.network.ServerSideConnection; -import org.spongepowered.api.resourcepack.ResourcePack; import org.spongepowered.api.scoreboard.Scoreboard; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.statistic.Statistic; @@ -186,13 +185,6 @@ default SetValue.Mutable displayedSkinParts() { */ ServerSideConnection connection(); - /** - * Sends a given {@link ResourcePack} to this player. - * - * @param pack The ResourcePack to send - */ - void sendResourcePack(ResourcePack pack); - /** * Gets this player's {@link TabList}. * diff --git a/src/main/java/org/spongepowered/api/event/entity/living/player/ResourcePackStatusEvent.java b/src/main/java/org/spongepowered/api/event/entity/living/player/ResourcePackStatusEvent.java index 37c3723d93..5502c27384 100644 --- a/src/main/java/org/spongepowered/api/event/entity/living/player/ResourcePackStatusEvent.java +++ b/src/main/java/org/spongepowered/api/event/entity/living/player/ResourcePackStatusEvent.java @@ -24,35 +24,53 @@ */ package org.spongepowered.api.event.entity.living.player; -import org.checkerframework.checker.nullness.qual.Nullable; +import net.kyori.adventure.resource.ResourcePackInfo; +import net.kyori.adventure.resource.ResourcePackStatus; import org.spongepowered.api.Server; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.api.event.Event; -import org.spongepowered.api.resourcepack.ResourcePack; +import org.spongepowered.api.network.ServerSideConnection; +import org.spongepowered.api.profile.GameProfile; import org.spongepowered.api.util.annotation.eventgen.GenerateFactoryMethod; import java.util.Optional; /** - * Called when a {@link ServerPlayer player} notifies the {@link Server} of the + * Called when a {@link ServerSideConnection connection} notifies the {@link Server} of the * status of a resource pack change request. */ @GenerateFactoryMethod public interface ResourcePackStatusEvent extends Event { /** - * Get the {@link ServerPlayer player}. + * Gets the {@link ServerSideConnection connection}. * - * @return The player + * @return The connection */ - ServerPlayer player(); + ServerSideConnection connection(); + + /** + * Gets the {@link GameProfile profile} associated + * with this connection. + * + * @return The profile + */ + GameProfile profile(); + + /** + * Gets the {@link ServerPlayer player}. + * + * @return The player, or {@link Optional#empty()} if the + * player is in the configuration state. + */ + Optional player(); /** * Gets the pack that this status corresponds to. * * @return The pack that this status corresponds to. */ - ResourcePack pack(); + ResourcePackInfo pack(); /** * Gets the status of the sent pack. @@ -60,54 +78,4 @@ public interface ResourcePackStatusEvent extends Event { * @return The status of the sent pack. */ ResourcePackStatus status(); - - /** - * The different possible responses the client can have. - */ - enum ResourcePackStatus { - - /** - * The client is attempting to download the pack. - */ - ACCEPTED(null), - - /** - * The client declined to download the pack. - */ - DECLINED(false), - - /** - * The client failed to download the resource pack. - * - *

In some client versions, such as 1.8.0, this may only be sent when - * the resource pack URL does not end in {@code .zip}. Otherwise, - * {@link #SUCCESSFULLY_LOADED} will be sent.

- */ - FAILED(false), - - /** - * The pack URI was successfully loaded. This does not mean that pack - * was loaded, as the vanilla client sends this even when encountering a - * 404 or similar. - */ - SUCCESSFULLY_LOADED(true); - - @Nullable private final Boolean success; - - ResourcePackStatus(@Nullable Boolean success) { - this.success = success; - } - - /** - * Gets if this status indicates that the pack was successfully set. - * - * @return true if it was successful, false if it was not, and - * Optional.empty() if it cannot be determined at this time. - */ - public Optional wasSuccessful() { - return Optional.ofNullable(this.success); - } - - } - } diff --git a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java index 67cd0d7f1c..a23d58b213 100644 --- a/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java +++ b/src/main/java/org/spongepowered/api/event/network/ServerSideConnectionEvent.java @@ -170,6 +170,7 @@ interface Handshake extends ProfileScoped { * can be terminated by calling {@link ServerSideConnection#close(Component)}.

*/ interface Configuration extends ProfileScoped { + } /** diff --git a/src/main/java/org/spongepowered/api/resourcepack/ResourcePack.java b/src/main/java/org/spongepowered/api/resourcepack/ResourcePack.java deleted file mode 100644 index 8dedd7d313..0000000000 --- a/src/main/java/org/spongepowered/api/resourcepack/ResourcePack.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package org.spongepowered.api.resourcepack; - -import net.kyori.adventure.text.Component; -import org.spongepowered.api.Sponge; - -import java.io.FileNotFoundException; -import java.net.URI; -import java.util.Optional; - -/** - * Represents a resource pack that can be sent to the client. - */ -public interface ResourcePack { - - /** - * Creates a {@link ResourcePack} from a URI and tries to download and hash - * it. - * - * @param uri The URI to look in - * @return A ResourcePack with the specified URI - * @throws FileNotFoundException If a valid resource pack could not be - * downloaded from the URI - */ - static ResourcePack fromUri(URI uri) throws FileNotFoundException { - return Sponge.game().factoryProvider().provide(Factory.class).fromUri(uri); - } - - /** - * Creates a {@link ResourcePack} from a URI, without checking ("unchecked") - * if there is a valid pack at the URI. - * - * @param uri The URI to look in - * @return A ResourcePack with the specified URI - */ - static ResourcePack fromUriUnchecked(URI uri) { - return Sponge.game().factoryProvider().provide(Factory.class).fromUriUnchecked(uri); - } - - /** - * Gets the URI associated with this resource pack. - * - * @return The URI associated with this resource pack. - */ - URI uri(); - - /** - * Gets the name of this resource pack. This is the filename of the pack - * zip file, with all non-word characters removed. Note to implementers: The - * name MUST be calculated like above, or this API will not - * work. - * - * @return The name of this resource pack. This is the filename of the pack - * .zip, with all non-word characters removed - */ - String name(); - - /** - * Gets the ID of this resource pack. - * - * @return the ID of this resource pack - */ - String id(); - - /** - * Gets the prompt of this resource pack. - * - * @return the prompt of this resource pack - */ - Component prompt(); - - /** - * Gets the hash of this resource pack. - * - * @return The hash of this pack, if present - */ - Optional hash(); - - interface Factory { - - ResourcePack fromUri(URI uri) throws FileNotFoundException; - - ResourcePack fromUriUnchecked(URI uri); - } -} diff --git a/src/main/java/org/spongepowered/api/resourcepack/package-info.java b/src/main/java/org/spongepowered/api/resourcepack/package-info.java deleted file mode 100644 index 36196d31e9..0000000000 --- a/src/main/java/org/spongepowered/api/resourcepack/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of SpongeAPI, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -@org.checkerframework.framework.qual.DefaultQualifier(org.checkerframework.checker.nullness.qual.NonNull.class) -package org.spongepowered.api.resourcepack; From b41a9471cd6b81253eed89702a7453e826833acf Mon Sep 17 00:00:00 2001 From: aromaa Date: Mon, 20 May 2024 16:46:38 +0300 Subject: [PATCH 18/53] Change BannerPatternShape to engine scope --- .../api/data/meta/BannerPatternLayer.java | 5 +- .../api/data/type/BannerPatternShapes.java | 96 +++++++++---------- 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java b/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java index 8e07713f08..3e76743afb 100644 --- a/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java +++ b/src/main/java/org/spongepowered/api/data/meta/BannerPatternLayer.java @@ -31,7 +31,6 @@ import org.spongepowered.api.data.type.BannerPatternShape; import org.spongepowered.api.data.type.DyeColor; import org.spongepowered.api.registry.DefaultedRegistryReference; -import org.spongepowered.api.registry.RegistryReference; import org.spongepowered.api.util.CopyableBuilder; import java.util.function.Supplier; @@ -49,7 +48,7 @@ public interface BannerPatternLayer extends DataSerializable { * @param color The color * @return The new pattern layer */ - static BannerPatternLayer of(RegistryReference shape, DefaultedRegistryReference color) { + static BannerPatternLayer of(DefaultedRegistryReference shape, DefaultedRegistryReference color) { return BannerPatternLayer.of(shape.get(), color.get()); } @@ -61,7 +60,7 @@ static BannerPatternLayer of(RegistryReference sha * @param color The color * @return The new pattern layer */ - static BannerPatternLayer of(RegistryReference shape, DyeColor color) { + static BannerPatternLayer of(DefaultedRegistryReference shape, DyeColor color) { return BannerPatternLayer.of(shape.get(), color); } diff --git a/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java b/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java index 741b48f5e6..6b93e14f41 100644 --- a/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java +++ b/src/main/java/org/spongepowered/api/data/type/BannerPatternShapes.java @@ -25,111 +25,111 @@ package org.spongepowered.api.data.type; import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; import org.spongepowered.api.registry.Registry; import org.spongepowered.api.registry.RegistryKey; -import org.spongepowered.api.registry.RegistryReference; import org.spongepowered.api.registry.RegistryScope; import org.spongepowered.api.registry.RegistryScopes; import org.spongepowered.api.registry.RegistryTypes; -import org.spongepowered.api.world.server.ServerWorld; /** * */ @SuppressWarnings("unused") -@RegistryScopes(scopes = RegistryScope.WORLD) +@RegistryScopes(scopes = RegistryScope.ENGINE) public final class BannerPatternShapes { - public static final RegistryReference BASE = BannerPatternShapes.key(ResourceKey.minecraft("base")); + public static final DefaultedRegistryReference BASE = BannerPatternShapes.key(ResourceKey.minecraft("base")); - public static final RegistryReference BORDER = BannerPatternShapes.key(ResourceKey.minecraft("border")); + public static final DefaultedRegistryReference BORDER = BannerPatternShapes.key(ResourceKey.minecraft("border")); - public static final RegistryReference BRICKS = BannerPatternShapes.key(ResourceKey.minecraft("bricks")); + public static final DefaultedRegistryReference BRICKS = BannerPatternShapes.key(ResourceKey.minecraft("bricks")); - public static final RegistryReference CIRCLE = BannerPatternShapes.key(ResourceKey.minecraft("circle")); + public static final DefaultedRegistryReference CIRCLE = BannerPatternShapes.key(ResourceKey.minecraft("circle")); - public static final RegistryReference CREEPER = BannerPatternShapes.key(ResourceKey.minecraft("creeper")); + public static final DefaultedRegistryReference CREEPER = BannerPatternShapes.key(ResourceKey.minecraft("creeper")); - public static final RegistryReference CROSS = BannerPatternShapes.key(ResourceKey.minecraft("cross")); + public static final DefaultedRegistryReference CROSS = BannerPatternShapes.key(ResourceKey.minecraft("cross")); - public static final RegistryReference CURLY_BORDER = BannerPatternShapes.key(ResourceKey.minecraft("curly_border")); + public static final DefaultedRegistryReference CURLY_BORDER = BannerPatternShapes.key(ResourceKey.minecraft("curly_border")); - public static final RegistryReference DIAGONAL_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_left")); + public static final DefaultedRegistryReference DIAGONAL_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_left")); - public static final RegistryReference DIAGONAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_right")); + public static final DefaultedRegistryReference DIAGONAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_right")); - public static final RegistryReference DIAGONAL_UP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_left")); + public static final DefaultedRegistryReference DIAGONAL_UP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_left")); - public static final RegistryReference DIAGONAL_UP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_right")); + public static final DefaultedRegistryReference DIAGONAL_UP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("diagonal_up_right")); - public static final RegistryReference FLOWER = BannerPatternShapes.key(ResourceKey.minecraft("flower")); + public static final DefaultedRegistryReference FLOWER = BannerPatternShapes.key(ResourceKey.minecraft("flower")); - public static final RegistryReference GLOBE = BannerPatternShapes.key(ResourceKey.minecraft("globe")); + public static final DefaultedRegistryReference GLOBE = BannerPatternShapes.key(ResourceKey.minecraft("globe")); - public static final RegistryReference GRADIENT = BannerPatternShapes.key(ResourceKey.minecraft("gradient")); + public static final DefaultedRegistryReference GRADIENT = BannerPatternShapes.key(ResourceKey.minecraft("gradient")); - public static final RegistryReference GRADIENT_UP = BannerPatternShapes.key(ResourceKey.minecraft("gradient_up")); + public static final DefaultedRegistryReference GRADIENT_UP = BannerPatternShapes.key(ResourceKey.minecraft("gradient_up")); - public static final RegistryReference HALF_HORIZONTAL = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal")); + public static final DefaultedRegistryReference HALF_HORIZONTAL = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal")); - public static final RegistryReference HALF_HORIZONTAL_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal_bottom")); + public static final DefaultedRegistryReference HALF_HORIZONTAL_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("half_horizontal_bottom")); - public static final RegistryReference HALF_VERTICAL = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical")); + public static final DefaultedRegistryReference HALF_VERTICAL = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical")); - public static final RegistryReference HALF_VERTICAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical_right")); + public static final DefaultedRegistryReference HALF_VERTICAL_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("half_vertical_right")); - public static final RegistryReference MOJANG = BannerPatternShapes.key(ResourceKey.minecraft("mojang")); + public static final DefaultedRegistryReference MOJANG = BannerPatternShapes.key(ResourceKey.minecraft("mojang")); - public static final RegistryReference PIGLIN = BannerPatternShapes.key(ResourceKey.minecraft("piglin")); + public static final DefaultedRegistryReference PIGLIN = BannerPatternShapes.key(ResourceKey.minecraft("piglin")); - public static final RegistryReference RHOMBUS = BannerPatternShapes.key(ResourceKey.minecraft("rhombus")); + public static final DefaultedRegistryReference RHOMBUS = BannerPatternShapes.key(ResourceKey.minecraft("rhombus")); - public static final RegistryReference SKULL = BannerPatternShapes.key(ResourceKey.minecraft("skull")); + public static final DefaultedRegistryReference SKULL = BannerPatternShapes.key(ResourceKey.minecraft("skull")); - public static final RegistryReference SMALL_STRIPES = BannerPatternShapes.key(ResourceKey.minecraft("small_stripes")); + public static final DefaultedRegistryReference SMALL_STRIPES = BannerPatternShapes.key(ResourceKey.minecraft("small_stripes")); - public static final RegistryReference SQUARE_BOTTOM_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_left")); + public static final DefaultedRegistryReference SQUARE_BOTTOM_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_left")); - public static final RegistryReference SQUARE_BOTTOM_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_right")); + public static final DefaultedRegistryReference SQUARE_BOTTOM_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_bottom_right")); - public static final RegistryReference SQUARE_TOP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_left")); + public static final DefaultedRegistryReference SQUARE_TOP_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_left")); - public static final RegistryReference SQUARE_TOP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_right")); + public static final DefaultedRegistryReference SQUARE_TOP_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("square_top_right")); - public static final RegistryReference STRAIGHT_CROSS = BannerPatternShapes.key(ResourceKey.minecraft("straight_cross")); + public static final DefaultedRegistryReference STRAIGHT_CROSS = BannerPatternShapes.key(ResourceKey.minecraft("straight_cross")); - public static final RegistryReference STRIPE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("stripe_bottom")); + public static final DefaultedRegistryReference STRIPE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("stripe_bottom")); - public static final RegistryReference STRIPE_CENTER = BannerPatternShapes.key(ResourceKey.minecraft("stripe_center")); + public static final DefaultedRegistryReference STRIPE_CENTER = BannerPatternShapes.key(ResourceKey.minecraft("stripe_center")); - public static final RegistryReference STRIPE_DOWNLEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downleft")); + public static final DefaultedRegistryReference STRIPE_DOWNLEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downleft")); - public static final RegistryReference STRIPE_DOWNRIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downright")); + public static final DefaultedRegistryReference STRIPE_DOWNRIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_downright")); - public static final RegistryReference STRIPE_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_left")); + public static final DefaultedRegistryReference STRIPE_LEFT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_left")); - public static final RegistryReference STRIPE_MIDDLE = BannerPatternShapes.key(ResourceKey.minecraft("stripe_middle")); + public static final DefaultedRegistryReference STRIPE_MIDDLE = BannerPatternShapes.key(ResourceKey.minecraft("stripe_middle")); - public static final RegistryReference STRIPE_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_right")); + public static final DefaultedRegistryReference STRIPE_RIGHT = BannerPatternShapes.key(ResourceKey.minecraft("stripe_right")); - public static final RegistryReference STRIPE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("stripe_top")); + public static final DefaultedRegistryReference STRIPE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("stripe_top")); - public static final RegistryReference TRIANGLE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangle_bottom")); + public static final DefaultedRegistryReference TRIANGLE_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangle_bottom")); - public static final RegistryReference TRIANGLE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangle_top")); + public static final DefaultedRegistryReference TRIANGLE_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangle_top")); - public static final RegistryReference TRIANGLES_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangles_bottom")); + public static final DefaultedRegistryReference TRIANGLES_BOTTOM = BannerPatternShapes.key(ResourceKey.minecraft("triangles_bottom")); - public static final RegistryReference TRIANGLES_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangles_top")); + public static final DefaultedRegistryReference TRIANGLES_TOP = BannerPatternShapes.key(ResourceKey.minecraft("triangles_top")); private BannerPatternShapes() { } - public static Registry registry(final ServerWorld world) { - return world.registry(RegistryTypes.BANNER_PATTERN_SHAPE); + public static Registry registry() { + return Sponge.server().registry(RegistryTypes.BANNER_PATTERN_SHAPE); } - private static RegistryReference key(final ResourceKey location) { - return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asReference(); + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.BANNER_PATTERN_SHAPE, location).asDefaultedReference(Sponge::server); } } From 570af09e42e407ddfa31ec65e09e2491cbb0c46f Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 16:03:05 +0200 Subject: [PATCH 19/53] Bump Adventure to 4.17 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ca9f42cf71..e406cbbd73 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ format = { version = "1.1" } [versions] -adventure = "4.16.0" +adventure = "4.17.0" caffeine = "3.1.8" checker = "3.42.0" checkstyle = "10.12.7" From cc4bb6aeb902b5ff55531f2b9f6737083c8c050d Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 25 May 2024 21:18:18 +0200 Subject: [PATCH 20/53] Update verification metadata --- gradle/verification-metadata.xml | 98 ++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index bf35d259c6..4bb0905c47 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -186,6 +186,11 @@
+ + + + + @@ -194,6 +199,17 @@ + + + + + + + + + + + @@ -783,6 +799,17 @@ + + + + + + + + + + + @@ -791,6 +818,11 @@ + + + + + @@ -802,6 +834,17 @@ + + + + + + + + + + + @@ -813,6 +856,17 @@ + + + + + + + + + + + @@ -824,6 +878,17 @@ + + + + + + + + + + + @@ -835,6 +900,17 @@ + + + + + + + + + + + @@ -846,6 +922,17 @@ + + + + + + + + + + + @@ -857,6 +944,17 @@ + + + + + + + + + + + From 69d9d422e8a2d985ca402d3df7fdcce26d69bad4 Mon Sep 17 00:00:00 2001 From: ImMorpheus Date: Sat, 25 May 2024 21:38:00 +0200 Subject: [PATCH 21/53] Update verification metadata --- gradle/verification-metadata.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 4bb0905c47..5b9cf0c009 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -822,6 +822,9 @@ + + + From 1023ee8714e0165e4fba0f2aa0a605f3be14d428 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 23:08:37 +0200 Subject: [PATCH 22/53] Keys.REPAIR_COST --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 9ef65a1b3b..f58a5cf724 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2611,6 +2611,11 @@ public final class Keys { */ public static final Key> REMAINING_SPAWN_DELAY = Keys.key(ResourceKey.sponge("remaining_spawn_delay"), Ticks.class); + /** + * The additional experience cost required to modify an {@link ItemStack} in an {@link BlockTypes#ANVIL}. + */ + public static final Key> REPAIR_COST = Keys.key(ResourceKey.sponge("repair_cost"), Integer.class); + /** * The amount of food a food {@link ItemStack} restores when eaten. * Readonly From 7c584c382b0e8b427bb666c922d75f87d9fa1a6b Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 23:08:46 +0200 Subject: [PATCH 23/53] Keys.HIDE_STORED_ENCHANTMENTS --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index f58a5cf724..75772419cb 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1369,6 +1369,11 @@ public final class Keys { */ public static final Key> HIDE_MISCELLANEOUS = Keys.key(ResourceKey.sponge("hide_miscellaneous"), Boolean.class); + /** + * Whether the {@link #STORED_ENCHANTMENTS} of an {@link ItemStack} are hidden. + */ + public static final Key> HIDE_STORED_ENCHANTMENTS = Keys.key(ResourceKey.sponge("hide_stored_enchantments"), Boolean.class); + /** * Whether {@link #IS_UNBREAKABLE} state of an {@link ItemStack} is hidden. */ From bb32d3cd6e827174de581b5f4e20f50f7b7288ad Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 23:12:57 +0200 Subject: [PATCH 24/53] Keys.ENCHANTMENT_GLINT_OVERRIDE --- src/main/java/org/spongepowered/api/data/Keys.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 75772419cb..2ecb926a9d 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -893,6 +893,12 @@ public final class Keys { */ public static final Key> EGG_TIME = Keys.key(ResourceKey.sponge("egg_time"), Ticks.class); + /** + * Whether the glint effect on an {@link ItemStack} is shown. + * This overrides the default behaviour when {@link #APPLIED_ENCHANTMENTS} or {@link #STORED_ENCHANTMENTS} are present. + */ + public static final Key> ENCHANTMENT_GLINT_OVERRIDE = Keys.key(ResourceKey.sponge("enchantment_glint_override"), Boolean.class); + /** * The age (in ticks) of an {@link EndGateway} */ From 8ff798ccaa819d3616c6e5c989571afa748c3699 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 23:17:40 +0200 Subject: [PATCH 25/53] Keys.CHARGED_PROJECTILES --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 2ecb926a9d..d2c78d2c24 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -642,6 +642,11 @@ public final class Keys { */ public static final Key> CAT_TYPE = Keys.key(ResourceKey.sponge("cat_type"), CatType.class); + /** + * The projectiles stored in an {@link ItemTypes#CROSSBOW}. + */ + public static final Key> CHARGED_PROJECTILES = Keys.listKey(ResourceKey.sponge("charged_projectiles"), ItemStackSnapshot.class); + /** * Whether a {@link ServerPlayer} can will see colours sent in messages. */ From 4f4c21314d1cc7f6942a535dfe8d8bdc02d8fb60 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sat, 25 May 2024 23:31:13 +0200 Subject: [PATCH 26/53] Keys.INTANGIBLE_PROJECTILE --- src/main/java/org/spongepowered/api/data/Keys.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index d2c78d2c24..be9f5ae143 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1434,6 +1434,13 @@ public final class Keys { */ public static final Key> INSTRUMENT_TYPE = Keys.key(ResourceKey.sponge("instrument_type"), InstrumentType.class); + /** + * Whether a projectile {@link ItemStack} would be intangible when fired. + * Intangible {@link Projectile projectiles} have {@link org.spongepowered.api.data.type.PickupRules#CREATIVE_ONLY}. + * See {@link Keys#PICKUP_RULE}. + */ + public static final Key> INTANGIBLE_PROJECTILE = Keys.key(ResourceKey.sponge("intangible_projectile"), Boolean.class); + /** * The interpolation delay of a {@link DisplayEntity} */ From b9653aa5b696b065c990a75577d9bb7ffe4f93b9 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 00:19:36 +0200 Subject: [PATCH 27/53] Keys.INVENTORY --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index be9f5ae143..44be35f841 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1451,6 +1451,11 @@ public final class Keys { */ public static final Key> INTERPOLATION_DURATION = Keys.key(ResourceKey.sponge("interpolation_duration"), Ticks.class); + /** + * The {@link Inventory} held in an {@link ItemStack} such as {@link ItemTypes#SHULKER_BOX}. + */ + public static final Key> INVENTORY = Keys.key(ResourceKey.sponge("inventory"), Inventory.class); + /** * Whether a {@link BlockTypes#DAYLIGHT_DETECTOR} {@link BlockState} is inverted. */ From 2ad78e7dd52f1ef69badcd96cd2942aa0e747e60 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 00:55:19 +0200 Subject: [PATCH 28/53] Keys.NOTE_BLOCK_SOUND --- src/main/java/org/spongepowered/api/data/Keys.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 44be35f841..d3f9ff64ac 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2375,6 +2375,12 @@ public final class Keys { */ public static final Key> NOTE_PITCH = Keys.key(ResourceKey.sponge("note_pitch"), NotePitch.class); + /** + * The sound played by a {@link ItemTypes#PLAYER_HEAD} {@link ItemStack} on a {@link BlockTypes#NOTE_BLOCK}. + * Value is the key of a {@link SoundType}. + */ + public static final Key> NOTE_BLOCK_SOUND = Keys.key(ResourceKey.sponge("note_block_sound"), ResourceKey.class); + /** * The notifier, usually of an {@link Entity}. It is up to the implementation to define. */ From d6aa813c17582a61657449ac008c839fe167a85c Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 01:18:13 +0200 Subject: [PATCH 29/53] Keys.LODESTONE_TRACKED --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index d3f9ff64ac..98459293fe 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2140,6 +2140,11 @@ public final class Keys { */ public static final Key> LODESTONE = Keys.key(ResourceKey.sponge("lodestone"), ServerLocation.class); + /** + * Whether to remove the {@link #LODESTONE target location} when the {@link BlockTypes#LODESTONE} at that location is removed. + */ + public static final Key> LODESTONE_TRACKED = Keys.key(ResourceKey.sponge("lodestone_tracked"), Boolean.class); + /** * The displayed description ("lore") text of an {@link ItemStack}. * From a9d83adb6c564600b3dea703bf800d592198812f Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 01:27:16 +0200 Subject: [PATCH 30/53] Keys.HIDE_TOOLTIP --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 98459293fe..5a8c9dd54f 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1385,6 +1385,11 @@ public final class Keys { */ public static final Key> HIDE_STORED_ENCHANTMENTS = Keys.key(ResourceKey.sponge("hide_stored_enchantments"), Boolean.class); + /** + * Whether the tooltip of an {@link ItemStack} is hidden. + */ + public static final Key> HIDE_TOOLTIP = Keys.key(ResourceKey.sponge("hide_tooltip"), Boolean.class); + /** * Whether {@link #IS_UNBREAKABLE} state of an {@link ItemStack} is hidden. */ From 7a66eb558c8372f5fa49ffda319eea99aa679220 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 02:10:41 +0200 Subject: [PATCH 31/53] food related Keys --- src/main/java/org/spongepowered/api/data/Keys.java | 11 +++++++---- .../api/util/weighted/NestedTableEntry.java | 9 +++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 5a8c9dd54f..3d3d9514fe 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -380,7 +380,6 @@ public final class Keys { /** * The set of {@link PotionEffect}s applied on use of an {@link ItemStack}. - * Readonly */ public static final Key> APPLICABLE_POTION_EFFECTS = Keys.weightedKey(ResourceKey.sponge("applicable_potion_effects"), PotionEffect.class); @@ -569,6 +568,11 @@ public final class Keys { */ public static final Key> BURN_TIME = Keys.key(ResourceKey.sponge("burn_time"), Integer.class); + /** + * Whether an {@link ItemStack} can always be eaten. + */ + public static final Key> CAN_ALWAYS_EAT = Keys.key(ResourceKey.sponge("can_always_eat"), Boolean.class); + /** * Whether an {@link Animal} can breed. * In Vanilla, animals can breed if their {@link Keys#BREEDING_COOLDOWN} is equal to 0. @@ -876,7 +880,8 @@ public final class Keys { public static final Key> DYE_COLOR = Keys.key(ResourceKey.sponge("dye_color"), DyeColor.class); /** - * The time a {@link Panda} has been eating (in ticks) + * The time a {@link Panda} has been eating (in ticks) or + * the time an {@link ItemStack} takes to eat. */ public static final Key> EATING_TIME = Keys.key(ResourceKey.sponge("eating_time"), Ticks.class); @@ -2662,13 +2667,11 @@ public final class Keys { /** * The amount of food a food {@link ItemStack} restores when eaten. - * Readonly */ public static final Key> REPLENISHED_FOOD = Keys.key(ResourceKey.sponge("replenished_food"), Integer.class); /** * The amount of saturation a food {@link ItemStack} provides when eaten. - * Readonly */ public static final Key> REPLENISHED_SATURATION = Keys.key(ResourceKey.sponge("replenished_saturation"), Double.class); diff --git a/src/main/java/org/spongepowered/api/util/weighted/NestedTableEntry.java b/src/main/java/org/spongepowered/api/util/weighted/NestedTableEntry.java index 2fc92a58b2..cf67981845 100644 --- a/src/main/java/org/spongepowered/api/util/weighted/NestedTableEntry.java +++ b/src/main/java/org/spongepowered/api/util/weighted/NestedTableEntry.java @@ -61,6 +61,15 @@ public List get(final RandomGenerator rand) { return this.table.get(rand); } + /** + * Returns the nested table + * + * @return The nested table + */ + public RandomObjectTable getNestedTable() { + return this.table; + } + @Override public boolean equals(final Object o) { if (o == this) { From cc4122ecc8d366190b8bbb9ae372fd5a28a2c99e Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 02:23:37 +0200 Subject: [PATCH 32/53] Keys.MAX_DURABILITY no longer readonly --- src/main/java/org/spongepowered/api/data/Keys.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 3d3d9514fe..3e7f8ec424 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2256,7 +2256,6 @@ public final class Keys { /** * The maximum durability of an {@link ItemStack}. {@link #ITEM_DURABILITY} - * Readonly */ public static final Key> MAX_DURABILITY = Keys.key(ResourceKey.sponge("max_durability"), Integer.class); From 1bc60856d5cdd44ad8d5798051d36b0c79041c32 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 11:28:49 +0200 Subject: [PATCH 33/53] Keys.FIRE_RESISTANT --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 3e7f8ec424..e75480baf0 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1035,6 +1035,11 @@ public final class Keys { */ public static final Key> FIRE_DAMAGE_DELAY = Keys.key(ResourceKey.sponge("fire_damage_delay"), Ticks.class); + /** + * Whether an {@link ItemStack} will burn in fire. + */ + public static final Key> FIRE_RESISTANT = Keys.key(ResourceKey.sponge("fire_resistant"), Boolean.class); + /** * The amount of ticks an {@link Entity} is still burning. */ From 8349d1f73413e0e2265e1b0f6565e167ae7736cb Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 11:36:01 +0200 Subject: [PATCH 34/53] Keys.ITEM_NAME --- src/main/java/org/spongepowered/api/data/Keys.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index e75480baf0..d87c567723 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2038,6 +2038,12 @@ public final class Keys { */ public static final Key> ITEM_DURABILITY = Keys.key(ResourceKey.sponge("item_durability"), Integer.class); + /** + * The default item name of an {@link ItemStack}. + *

May be overridden by {@link #CUSTOM_NAME}

+ */ + public static final Key> ITEM_NAME = Keys.key(ResourceKey.sponge("item_name"), Component.class); + /** * The rarity of an item. */ From 7ac71d7798c3e85a60169a3112a53886362d3fa2 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 12:17:56 +0200 Subject: [PATCH 35/53] Keys.TOOL_DAMAGE_PER_BLOCK + Keys.EFFICIENCY no longer readonly --- src/main/java/org/spongepowered/api/data/Keys.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index d87c567723..f3ab493587 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -887,7 +887,6 @@ public final class Keys { /** * The efficiency of an {@link ItemStack} tool. Affects mining speed of supported materials. {@link #CAN_HARVEST} - * Readonly */ public static final Key> EFFICIENCY = Keys.key(ResourceKey.sponge("efficiency"), Double.class); @@ -3115,6 +3114,11 @@ public final class Keys { */ public static final Key> TILT = Keys.key(ResourceKey.sponge("tilt"), Tilt.class); + /** + * The {@link #ITEM_DURABILITY} damage an {@link ItemStack} tool takes per block. + */ + public static final Key> TOOL_DAMAGE_PER_BLOCK = Keys.key(ResourceKey.sponge("tool_damage_per_block"), Integer.class); + /** * The {@link ItemTier} of an {@link ItemStack} tool. * Readonly From 36aaf56950c681df0bc684c99c1bd5568b9ff256 Mon Sep 17 00:00:00 2001 From: Anselm Brehme Date: Sun, 26 May 2024 13:15:26 +0200 Subject: [PATCH 36/53] Keys.TOOL_RULES --- .../java/org/spongepowered/api/data/Keys.java | 11 +- .../spongepowered/api/data/type/ToolRule.java | 183 ++++++++++++++++++ 2 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/spongepowered/api/data/type/ToolRule.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index f3ab493587..49fc3566fb 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -87,6 +87,7 @@ import org.spongepowered.api.data.type.StairShape; import org.spongepowered.api.data.type.StructureMode; import org.spongepowered.api.data.type.Tilt; +import org.spongepowered.api.data.type.ToolRule; import org.spongepowered.api.data.type.TropicalFishShape; import org.spongepowered.api.data.type.VillagerType; import org.spongepowered.api.data.type.WallConnectionState; @@ -600,7 +601,8 @@ public final class Keys { public static final Key> CAN_GRIEF = Keys.key(ResourceKey.sponge("can_grief"), Boolean.class); /** - * The set of harvestable {@link BlockType}s with an {@link ItemStack}. {@link #EFFICIENCY} + * The set of harvestable {@link BlockType}s with an {@link ItemStack}. + * See {@link #TOOL_RULES} for the rules resulting in this set. * Readonly */ public static final Key> CAN_HARVEST = Keys.setKey(ResourceKey.sponge("can_harvest"), BlockType.class); @@ -887,6 +889,7 @@ public final class Keys { /** * The efficiency of an {@link ItemStack} tool. Affects mining speed of supported materials. {@link #CAN_HARVEST} + * Removing this from a tool makes it no longer a tool. */ public static final Key> EFFICIENCY = Keys.key(ResourceKey.sponge("efficiency"), Double.class); @@ -3119,6 +3122,12 @@ public final class Keys { */ public static final Key> TOOL_DAMAGE_PER_BLOCK = Keys.key(ResourceKey.sponge("tool_damage_per_block"), Integer.class); + /** + * The {@link ToolRule rules} of an {@link ItemStack} tool. + * See {@link #CAN_HARVEST} for a list of {@link BlockType block types}. + */ + public static final Key> TOOL_RULES = Keys.listKey(ResourceKey.sponge("tool_rules"), ToolRule.class); + /** * The {@link ItemTier} of an {@link ItemStack} tool. * Readonly diff --git a/src/main/java/org/spongepowered/api/data/type/ToolRule.java b/src/main/java/org/spongepowered/api/data/type/ToolRule.java new file mode 100644 index 0000000000..aec0b1e332 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/ToolRule.java @@ -0,0 +1,183 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.checkerframework.checker.nullness.qual.Nullable; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.block.BlockType; +import org.spongepowered.api.tag.Tag; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +/** + * A tool rule that applied via {@link org.spongepowered.api.data.Keys#TOOL_RULES} to an {@link org.spongepowered.api.item.inventory.ItemStack} + * determines what {@link BlockType block types} can be mined at what speed and whether they drop items. + */ +public interface ToolRule { + + + static ToolRule minesAndDrops(List blocks, double speed) { + return ToolRule.factory().minesAndDrops(blocks, speed); + } + + static ToolRule minesAndDrops(Tag blockTypeTag, double speed) { + return ToolRule.factory().minesAndDrops(blockTypeTag, speed); + } + + static ToolRule deniesDrops(List blocks) { + return ToolRule.factory().deniesDrops(blocks); + } + + static ToolRule deniesDrops(Tag blockTypeTag) { + return ToolRule.factory().deniesDrops(blockTypeTag); + } + + static ToolRule overrideSpeed(List blocks, double speed) { + return ToolRule.factory().overrideSpeed(blocks, speed); + } + + static ToolRule overrideSpeed(Tag blockTypeTag, double speed) { + return ToolRule.factory().overrideSpeed(blockTypeTag, speed); + } + + static ToolRule forBlocks(List blocks, @Nullable Double speed, @Nullable Boolean drops) { + return ToolRule.factory().forBlocks(blocks, speed, drops); + } + + static ToolRule forTag(Tag blockTypeTag, @Nullable Double speed, @Nullable Boolean drops) { + return ToolRule.factory().forTag(blockTypeTag, speed, drops); + } + + /** + * Returns the {@link BlockType block types} this rule applies to. + * + * @return the affected blocks + */ + Set blocks(); + + /** + * Returns the speed override. + *

If present overrides the default {@link org.spongepowered.api.data.Keys#EFFICIENCY mining speed}.

+ * + * @return the speed override + */ + Optional speed(); + + /** + * Returns the drops override. + *

If present determines whether a block mined with this rule drops its item

+ * + * @return the drops override + */ + Optional drops(); + + private static Factory factory() { + return Sponge.game().factoryProvider().provide(Factory.class); + } + + interface Factory { + + /** + * Generates a rule for mining and dropping given blocks at given speed. + * + * @param blocks the blocks + * @param speed the speed + * @return the generated rule + */ + ToolRule minesAndDrops(List blocks, double speed); + + /** + * Generates a rule for mining and dropping given block type tag at given speed. + * + * @param blockTypeTag the block type tag + * @param speed the speed + * + * @return the generated rule + */ + ToolRule minesAndDrops(Tag blockTypeTag, double speed); + + /** + * Generates a rule for preventing drops for given blocks. + * + * @param blocks the blocks + * + * @return the generated rule + */ + ToolRule deniesDrops(List blocks); + + /** + * Generates a rule for preventing drops for given block type tag. + * + * @param blockTypeTag the block type tag + * + * @return the generated rule + */ + ToolRule deniesDrops(Tag blockTypeTag); + + /** + * Generates a rule overriding mining speed drops for given blocks. + * + * @param blocks the blocks + * @param speed the speed + * + * @return the generated rule + */ + ToolRule overrideSpeed(List blocks, double speed); + + /** + * Generates a rule overriding mining speed drops for given block type tag. + * + * @param blockTypeTag the block type tag + * @param speed the speed + * + * @return the generated rule + */ + ToolRule overrideSpeed(Tag blockTypeTag, double speed); + + /** + * Generates a rule for blocks. Optionally overriding speed and/or drops. + * + * @param blocks the blocks + * @param speed the optional override speed + * @param drops the optional drops override + * + * @return the generated rule + */ + ToolRule forBlocks(List blocks, @Nullable Double speed, @Nullable Boolean drops); + + /** + * Generates a rule for a block type tag. Optionally overriding speed and/or drops. + * + * @param blockTypeTag the block type tag + * @param speed the optional override speed + * @param drops the optional drops override + * + * @return the generated rule + */ + ToolRule forTag(Tag blockTypeTag, @Nullable Double speed, @Nullable Boolean drops); + } +} From fa59da123a7f6f362e58d0c12f405f221faa6c14 Mon Sep 17 00:00:00 2001 From: aromaa Date: Wed, 29 May 2024 19:06:09 +0300 Subject: [PATCH 37/53] Allow per slot readonly mode for InventoryMenu --- .../api/item/inventory/menu/InventoryMenu.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/org/spongepowered/api/item/inventory/menu/InventoryMenu.java b/src/main/java/org/spongepowered/api/item/inventory/menu/InventoryMenu.java index cfd8bff88f..910c8ec0ee 100644 --- a/src/main/java/org/spongepowered/api/item/inventory/menu/InventoryMenu.java +++ b/src/main/java/org/spongepowered/api/item/inventory/menu/InventoryMenu.java @@ -27,6 +27,7 @@ import net.kyori.adventure.text.Component; import org.spongepowered.api.entity.living.player.server.ServerPlayer; import org.spongepowered.api.item.inventory.Container; +import org.spongepowered.api.item.inventory.Slot; import org.spongepowered.api.item.inventory.menu.handler.ClickHandler; import org.spongepowered.api.item.inventory.menu.handler.CloseHandler; import org.spongepowered.api.item.inventory.menu.handler.InventoryCallbackHandler; @@ -149,6 +150,18 @@ static InventoryMenu of(ViewableInventory inventory) { */ InventoryMenu setReadOnly(boolean readOnly); + /** + * Sets the {@link Slot} readonly mode for this menu. + * By default, uses the menus current readonly mode. + * This can be used to override per slot. + * + * @param slot the slot which readonly mode is changed + * @param readOnly whether to make the slot readonly or not. + * @return this menu + * @throws IllegalArgumentException if the slot is not part of the menu + */ + InventoryMenu setReadOnly(Slot slot, boolean readOnly); + /** * Opens this menu for given {@link ServerPlayer player}. * From 6dbbd37f2de8538c8292f5fd71a83b661fbf3d85 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Wed, 15 May 2024 21:43:32 -0700 Subject: [PATCH 38/53] feat: Add BlockVolume.blockPalette accessor --- .../api/world/volume/block/BlockVolume.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/spongepowered/api/world/volume/block/BlockVolume.java b/src/main/java/org/spongepowered/api/world/volume/block/BlockVolume.java index 97a63d28d4..eb02e1dd9f 100644 --- a/src/main/java/org/spongepowered/api/world/volume/block/BlockVolume.java +++ b/src/main/java/org/spongepowered/api/world/volume/block/BlockVolume.java @@ -46,6 +46,17 @@ public interface BlockVolume extends Volume { + /** + * Gets the {@link Palette} in use for this particular {@link Volume}. + * It is not guaranteed that the palette is the same across smaller + * {@link Volume Volumes} that may be contained within this volume. + * An example can be the difference between a {@link org.spongepowered.api.world.chunk.Chunk} + * and {@link org.spongepowered.api.world.World}'s palette. + * + * @return The block palette in use for this volume + */ + Palette blockPalette(); + BlockState block(int x, int y, int z); default BlockState block(final Vector3i vector3i) { From 22c65048cba23a68f12e83a6cf98225be5ab7088 Mon Sep 17 00:00:00 2001 From: MrHell228 <82652479+MrHell228@users.noreply.github.com> Date: Mon, 3 Jun 2024 00:11:29 +0300 Subject: [PATCH 39/53] Add Keys.MAX_GROWTH_STAGE (#2511) --- src/main/java/org/spongepowered/api/data/Keys.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 49fc3566fb..9032d917f0 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -2298,6 +2298,13 @@ public final class Keys { */ public static final Key> MAX_FROZEN_TIME = Keys.key(ResourceKey.sponge("max_frozen_time"), Ticks.class); + /** + * The max growth stage of a {@link BlockState}. + * e.g. {@link BlockTypes#CACTUS} or {@link BlockTypes#WHEAT} etc. + * Readonly + */ + public static final Key> MAX_GROWTH_STAGE = Keys.key(ResourceKey.sponge("max_growth_stage"), Integer.class); + /** * The maximum health of a {@link Living}. * From 73fd67dfa582001bce539bd51848b57b9b0bb658 Mon Sep 17 00:00:00 2001 From: Morpheus Date: Sun, 2 Jun 2024 22:25:48 +0000 Subject: [PATCH 40/53] Add new EntityTypes (#2512) --- .../spongepowered/api/entity/EntityTypes.java | 13 +++++++- .../api/entity/OminousItemSpawner.java | 28 +++++++++++++++++ .../api/entity/living/animal/Armadillo.java | 28 +++++++++++++++++ .../living/monster/skeleton/Bogged.java | 28 +++++++++++++++++ .../windcharge/BreezeWindCharge.java | 28 +++++++++++++++++ .../{ => windcharge}/WindCharge.java | 4 +-- .../projectile/windcharge/WindChargeLike.java | 30 +++++++++++++++++++ 7 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/entity/OminousItemSpawner.java create mode 100644 src/main/java/org/spongepowered/api/entity/living/animal/Armadillo.java create mode 100644 src/main/java/org/spongepowered/api/entity/living/monster/skeleton/Bogged.java create mode 100644 src/main/java/org/spongepowered/api/entity/projectile/windcharge/BreezeWindCharge.java rename src/main/java/org/spongepowered/api/entity/projectile/{ => windcharge}/WindCharge.java (91%) create mode 100644 src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindChargeLike.java diff --git a/src/main/java/org/spongepowered/api/entity/EntityTypes.java b/src/main/java/org/spongepowered/api/entity/EntityTypes.java index 6d14073117..636720a328 100644 --- a/src/main/java/org/spongepowered/api/entity/EntityTypes.java +++ b/src/main/java/org/spongepowered/api/entity/EntityTypes.java @@ -38,6 +38,7 @@ import org.spongepowered.api.entity.living.Bat; import org.spongepowered.api.entity.living.Human; import org.spongepowered.api.entity.living.animal.Allay; +import org.spongepowered.api.entity.living.animal.Armadillo; import org.spongepowered.api.entity.living.animal.Axolotl; import org.spongepowered.api.entity.living.animal.Bee; import org.spongepowered.api.entity.living.animal.Cat; @@ -102,6 +103,7 @@ import org.spongepowered.api.entity.living.monster.raider.illager.Vindicator; import org.spongepowered.api.entity.living.monster.raider.illager.spellcaster.Evoker; import org.spongepowered.api.entity.living.monster.raider.illager.spellcaster.Illusioner; +import org.spongepowered.api.entity.living.monster.skeleton.Bogged; import org.spongepowered.api.entity.living.monster.skeleton.Skeleton; import org.spongepowered.api.entity.living.monster.skeleton.Stray; import org.spongepowered.api.entity.living.monster.skeleton.WitherSkeleton; @@ -127,7 +129,6 @@ import org.spongepowered.api.entity.projectile.Potion; import org.spongepowered.api.entity.projectile.ShulkerBullet; import org.spongepowered.api.entity.projectile.Snowball; -import org.spongepowered.api.entity.projectile.WindCharge; import org.spongepowered.api.entity.projectile.arrow.Arrow; import org.spongepowered.api.entity.projectile.arrow.SpectralArrow; import org.spongepowered.api.entity.projectile.arrow.Trident; @@ -136,6 +137,8 @@ import org.spongepowered.api.entity.projectile.explosive.fireball.DragonFireball; import org.spongepowered.api.entity.projectile.explosive.fireball.ExplosiveFireball; import org.spongepowered.api.entity.projectile.explosive.fireball.SmallFireball; +import org.spongepowered.api.entity.projectile.windcharge.BreezeWindCharge; +import org.spongepowered.api.entity.projectile.windcharge.WindCharge; import org.spongepowered.api.entity.vehicle.Boat; import org.spongepowered.api.entity.vehicle.ChestBoat; import org.spongepowered.api.entity.vehicle.minecart.CommandBlockMinecart; @@ -164,6 +167,8 @@ public final class EntityTypes { public static final DefaultedRegistryReference> AREA_EFFECT_CLOUD = EntityTypes.key(ResourceKey.minecraft("area_effect_cloud")); + public static final DefaultedRegistryReference> ARMADILLO = EntityTypes.key(ResourceKey.minecraft("armadillo")); + public static final DefaultedRegistryReference> ARMOR_STAND = EntityTypes.key(ResourceKey.minecraft("armor_stand")); public static final DefaultedRegistryReference> ARROW = EntityTypes.key(ResourceKey.minecraft("arrow")); @@ -180,8 +185,12 @@ public final class EntityTypes { public static final DefaultedRegistryReference> BOAT = EntityTypes.key(ResourceKey.minecraft("boat")); + public static final DefaultedRegistryReference> BOGGED = EntityTypes.key(ResourceKey.minecraft("bogged")); + public static final DefaultedRegistryReference> BREEZE = EntityTypes.key(ResourceKey.minecraft("breeze")); + public static final DefaultedRegistryReference> BREEZE_WIND_CHARGE = EntityTypes.key(ResourceKey.minecraft("breeze_wind_charge")); + public static final DefaultedRegistryReference> CAMEL = EntityTypes.key(ResourceKey.minecraft("camel")); public static final DefaultedRegistryReference> CAT = EntityTypes.key(ResourceKey.minecraft("cat")); @@ -302,6 +311,8 @@ public final class EntityTypes { public static final DefaultedRegistryReference> OCELOT = EntityTypes.key(ResourceKey.minecraft("ocelot")); + public static final DefaultedRegistryReference> OMINOUS_ITEM_SPAWNER = EntityTypes.key(ResourceKey.minecraft("ominous_item_spawner")); + public static final DefaultedRegistryReference> PAINTING = EntityTypes.key(ResourceKey.minecraft("painting")); public static final DefaultedRegistryReference> PANDA = EntityTypes.key(ResourceKey.minecraft("panda")); diff --git a/src/main/java/org/spongepowered/api/entity/OminousItemSpawner.java b/src/main/java/org/spongepowered/api/entity/OminousItemSpawner.java new file mode 100644 index 0000000000..77d161317f --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/OminousItemSpawner.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity; + +public interface OminousItemSpawner extends Entity { +} diff --git a/src/main/java/org/spongepowered/api/entity/living/animal/Armadillo.java b/src/main/java/org/spongepowered/api/entity/living/animal/Armadillo.java new file mode 100644 index 0000000000..bbd41be17f --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/living/animal/Armadillo.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity.living.animal; + +public interface Armadillo extends Animal { +} diff --git a/src/main/java/org/spongepowered/api/entity/living/monster/skeleton/Bogged.java b/src/main/java/org/spongepowered/api/entity/living/monster/skeleton/Bogged.java new file mode 100644 index 0000000000..a91d6ae005 --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/living/monster/skeleton/Bogged.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity.living.monster.skeleton; + +public interface Bogged extends SkeletonLike { +} diff --git a/src/main/java/org/spongepowered/api/entity/projectile/windcharge/BreezeWindCharge.java b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/BreezeWindCharge.java new file mode 100644 index 0000000000..6c15f74095 --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/BreezeWindCharge.java @@ -0,0 +1,28 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity.projectile.windcharge; + +public interface BreezeWindCharge extends WindChargeLike { +} diff --git a/src/main/java/org/spongepowered/api/entity/projectile/WindCharge.java b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindCharge.java similarity index 91% rename from src/main/java/org/spongepowered/api/entity/projectile/WindCharge.java rename to src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindCharge.java index cf7fe6c8d4..5b0d76c2d3 100644 --- a/src/main/java/org/spongepowered/api/entity/projectile/WindCharge.java +++ b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindCharge.java @@ -22,10 +22,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package org.spongepowered.api.entity.projectile; +package org.spongepowered.api.entity.projectile.windcharge; /** * Represents a WindCharge. */ -public interface WindCharge extends DamagingProjectile { +public interface WindCharge extends WindChargeLike { } diff --git a/src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindChargeLike.java b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindChargeLike.java new file mode 100644 index 0000000000..3ab50a3796 --- /dev/null +++ b/src/main/java/org/spongepowered/api/entity/projectile/windcharge/WindChargeLike.java @@ -0,0 +1,30 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.entity.projectile.windcharge; + +import org.spongepowered.api.entity.projectile.DamagingProjectile; + +public interface WindChargeLike extends DamagingProjectile { +} From 791f2622159aeaccb068dc83fa2607fbc3e99073 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Sun, 2 Jun 2024 22:39:21 -0700 Subject: [PATCH 41/53] feat: Add PushReactions --- .../java/org/spongepowered/api/data/Keys.java | 7 +++ .../api/data/type/PushReaction.java | 32 ++++++++++++ .../api/data/type/PushReactions.java | 52 +++++++++++++++++++ .../api/registry/RegistryTypes.java | 3 ++ 4 files changed, 94 insertions(+) create mode 100644 src/main/java/org/spongepowered/api/data/type/PushReaction.java create mode 100644 src/main/java/org/spongepowered/api/data/type/PushReactions.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 9032d917f0..403653aa46 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -77,6 +77,7 @@ import org.spongepowered.api.data.type.PistonType; import org.spongepowered.api.data.type.PortionType; import org.spongepowered.api.data.type.ProfessionType; +import org.spongepowered.api.data.type.PushReaction; import org.spongepowered.api.data.type.RabbitType; import org.spongepowered.api.data.type.RailDirection; import org.spongepowered.api.data.type.SculkSensorState; @@ -2608,6 +2609,12 @@ public final class Keys { */ public static final Key> PROFESSION_LEVEL = Keys.key(ResourceKey.sponge("profession_level"), Integer.class); + /** + * The {@link Entity} or {@link BlockState} push reaction when a {@link Piston} pushes it. + * Readonly + */ + public static final Key> PUSH_REACTION = Keys.key(ResourceKey.sponge("push_reaction"), PushReaction.class); + /** * Whether pvp combat is enabled in a world of a {@link WorldTemplate} or {@link ServerWorldProperties} * Readonly diff --git a/src/main/java/org/spongepowered/api/data/type/PushReaction.java b/src/main/java/org/spongepowered/api/data/type/PushReaction.java new file mode 100644 index 0000000000..374eb454a1 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/PushReaction.java @@ -0,0 +1,32 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(PushReactions.class) +public interface PushReaction { + +} diff --git a/src/main/java/org/spongepowered/api/data/type/PushReactions.java b/src/main/java/org/spongepowered/api/data/type/PushReactions.java new file mode 100644 index 0000000000..681ec52667 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/PushReactions.java @@ -0,0 +1,52 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryScope; +import org.spongepowered.api.registry.RegistryScopes; +import org.spongepowered.api.registry.RegistryTypes; + +@RegistryScopes(scopes = RegistryScope.GAME) +public final class PushReactions { + + public static final DefaultedRegistryReference NORMAL = key(ResourceKey.minecraft("NORMAL")); + public static final DefaultedRegistryReference DESTROY = key(ResourceKey.minecraft("DESTROY")); + public static final DefaultedRegistryReference BLOCK = key(ResourceKey.minecraft("BLOCK")); + public static final DefaultedRegistryReference IGNORE = key(ResourceKey.minecraft("IGNORE")); + public static final DefaultedRegistryReference PUSH_ONLY = key(ResourceKey.minecraft("PUSH_ONLY")); + + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.PUSH_REACTION); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.PUSH_REACTION, location).asDefaultedReference(Sponge::game); + } +} diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index c313490b92..ee53b273ec 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -77,6 +77,7 @@ import org.spongepowered.api.data.type.PistonType; import org.spongepowered.api.data.type.PortionType; import org.spongepowered.api.data.type.ProfessionType; +import org.spongepowered.api.data.type.PushReaction; import org.spongepowered.api.data.type.RabbitType; import org.spongepowered.api.data.type.RaidStatus; import org.spongepowered.api.data.type.RailDirection; @@ -254,6 +255,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType PROFESSION_TYPE = RegistryTypes.minecraftKeyInGame("villager_profession"); + public static final DefaultedRegistryType PUSH_REACTION = RegistryTypes.spongeKeyInGame("push_reaction"); + public static final DefaultedRegistryType POTION_TYPE = RegistryTypes.minecraftKeyInGame("potion"); public static final DefaultedRegistryType> RECIPE_TYPE = RegistryTypes.minecraftKeyInGame("recipe_type"); From 779d47211bf647e920a6c1ffbfb3dabfdf69f926 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Mon, 3 Jun 2024 20:07:01 -0700 Subject: [PATCH 42/53] feat: Add StringRepresentable For some usages it's helpful to have the serializable name that gets used and assists with interpreting values from user parsed files. --- .../java/org/spongepowered/api/data/Keys.java | 6 +++ .../api/data/type/AttachmentSurface.java | 2 +- .../api/data/type/BambooLeavesType.java | 2 +- .../api/data/type/BellAttachmentType.java | 2 +- .../api/data/type/ChestAttachmentType.java | 2 +- .../api/data/type/ComparatorMode.java | 2 +- .../api/data/type/DoorHinge.java | 2 +- .../api/data/type/DripstoneSegment.java | 2 +- .../api/data/type/InstrumentType.java | 2 +- .../api/data/type/JigsawBlockOrientation.java | 2 +- .../api/data/type/PistonType.java | 2 +- .../api/data/type/PortionType.java | 2 +- .../api/data/type/RailDirection.java | 2 +- .../api/data/type/SculkSensorState.java | 2 +- .../api/data/type/SlabPortion.java | 2 +- .../api/data/type/StairShape.java | 2 +- .../api/data/type/StringRepresentable.java | 37 +++++++++++++++++++ .../api/data/type/StructureMode.java | 2 +- .../org/spongepowered/api/data/type/Tilt.java | 2 +- .../api/data/type/WallConnectionState.java | 2 +- .../api/data/type/WireAttachmentType.java | 2 +- .../api/registry/RegistryTypes.java | 6 +++ .../api/state/EnumStateProperty.java | 3 +- .../java/org/spongepowered/api/util/Axis.java | 9 ++++- .../org/spongepowered/api/util/Direction.java | 8 +++- 25 files changed, 85 insertions(+), 22 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/data/type/StringRepresentable.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 403653aa46..07b6bc53ec 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -563,6 +563,12 @@ public final class Keys { */ public static final Key> BREEDING_COOLDOWN = Keys.key(ResourceKey.sponge("breeding_cooldown"), Ticks.class); + /** + * Whether a {@link BlockState} can be lit on fire by things like spreading lava, + * or sometimes a {@link ServerLocation} to be directionally specific. + */ + public static final Key> BURNABLE = Keys.key(ResourceKey.sponge("burnable"), Boolean.class); + /** * The burntime of an {@link ItemStack} fuel in a furnace. * See {@link #FUEL} for the time diff --git a/src/main/java/org/spongepowered/api/data/type/AttachmentSurface.java b/src/main/java/org/spongepowered/api/data/type/AttachmentSurface.java index 1e8cf2101e..6c40aadf68 100644 --- a/src/main/java/org/spongepowered/api/data/type/AttachmentSurface.java +++ b/src/main/java/org/spongepowered/api/data/type/AttachmentSurface.java @@ -31,6 +31,6 @@ * Represents a block surface. */ @CatalogedBy(AttachmentSurfaces.class) -public interface AttachmentSurface extends DefaultedRegistryValue, Comparable { +public interface AttachmentSurface extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/BambooLeavesType.java b/src/main/java/org/spongepowered/api/data/type/BambooLeavesType.java index 467d705b3b..f94c386171 100644 --- a/src/main/java/org/spongepowered/api/data/type/BambooLeavesType.java +++ b/src/main/java/org/spongepowered/api/data/type/BambooLeavesType.java @@ -32,6 +32,6 @@ * Represents the type of leaves of a {@link BlockTypes#BAMBOO} block. */ @CatalogedBy(BambooLeavesTypes.class) -public interface BambooLeavesType extends DefaultedRegistryValue, Comparable { +public interface BambooLeavesType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/BellAttachmentType.java b/src/main/java/org/spongepowered/api/data/type/BellAttachmentType.java index 3083ad8bf2..106643793b 100644 --- a/src/main/java/org/spongepowered/api/data/type/BellAttachmentType.java +++ b/src/main/java/org/spongepowered/api/data/type/BellAttachmentType.java @@ -32,6 +32,6 @@ * Represents the attachment-type of a {@link BlockTypes#BELL} block. */ @CatalogedBy(BellAttachmentTypes.class) -public interface BellAttachmentType extends DefaultedRegistryValue, Comparable { +public interface BellAttachmentType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/ChestAttachmentType.java b/src/main/java/org/spongepowered/api/data/type/ChestAttachmentType.java index a4c7989c9c..d533040eda 100644 --- a/src/main/java/org/spongepowered/api/data/type/ChestAttachmentType.java +++ b/src/main/java/org/spongepowered/api/data/type/ChestAttachmentType.java @@ -34,6 +34,6 @@ * chests into a double chests. */ @CatalogedBy(ChestAttachmentTypes.class) -public interface ChestAttachmentType extends DefaultedRegistryValue, Comparable { +public interface ChestAttachmentType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/ComparatorMode.java b/src/main/java/org/spongepowered/api/data/type/ComparatorMode.java index 63b995ddb0..02a2ab223d 100644 --- a/src/main/java/org/spongepowered/api/data/type/ComparatorMode.java +++ b/src/main/java/org/spongepowered/api/data/type/ComparatorMode.java @@ -28,6 +28,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(ComparatorModes.class) -public interface ComparatorMode extends DefaultedRegistryValue, Comparable { +public interface ComparatorMode extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/DoorHinge.java b/src/main/java/org/spongepowered/api/data/type/DoorHinge.java index 559c82a552..e24042f987 100644 --- a/src/main/java/org/spongepowered/api/data/type/DoorHinge.java +++ b/src/main/java/org/spongepowered/api/data/type/DoorHinge.java @@ -32,6 +32,6 @@ * Represents a side of a hinge. */ @CatalogedBy(DoorHinges.class) -public interface DoorHinge extends DefaultedRegistryValue, Cycleable, Comparable { +public interface DoorHinge extends DefaultedRegistryValue, Cycleable, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/DripstoneSegment.java b/src/main/java/org/spongepowered/api/data/type/DripstoneSegment.java index 4ea07bd2ce..156051a015 100644 --- a/src/main/java/org/spongepowered/api/data/type/DripstoneSegment.java +++ b/src/main/java/org/spongepowered/api/data/type/DripstoneSegment.java @@ -28,6 +28,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(DripstoneSegments.class) -public interface DripstoneSegment extends DefaultedRegistryValue, Comparable { +public interface DripstoneSegment extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/InstrumentType.java b/src/main/java/org/spongepowered/api/data/type/InstrumentType.java index 84a6d4eb9a..9d3d1649c1 100644 --- a/src/main/java/org/spongepowered/api/data/type/InstrumentType.java +++ b/src/main/java/org/spongepowered/api/data/type/InstrumentType.java @@ -32,7 +32,7 @@ * Represents a type of instrument. */ @CatalogedBy(InstrumentTypes.class) -public interface InstrumentType extends DefaultedRegistryValue, Comparable { +public interface InstrumentType extends DefaultedRegistryValue, Comparable, StringRepresentable { /** * Gets the {@link SoundType} that is used by diff --git a/src/main/java/org/spongepowered/api/data/type/JigsawBlockOrientation.java b/src/main/java/org/spongepowered/api/data/type/JigsawBlockOrientation.java index 7c117aab40..84cabb9c2c 100644 --- a/src/main/java/org/spongepowered/api/data/type/JigsawBlockOrientation.java +++ b/src/main/java/org/spongepowered/api/data/type/JigsawBlockOrientation.java @@ -33,7 +33,7 @@ * Represents the front and top orientation of {@link BlockTypes#JIGSAW} blocks. */ @CatalogedBy(JigsawBlockOrientations.class) -public interface JigsawBlockOrientation extends DefaultedRegistryValue, Comparable { +public interface JigsawBlockOrientation extends DefaultedRegistryValue, Comparable, StringRepresentable { /** * The front facing direction of a jigsaw block. diff --git a/src/main/java/org/spongepowered/api/data/type/PistonType.java b/src/main/java/org/spongepowered/api/data/type/PistonType.java index 1bb90ccdc5..a52e8c2f20 100644 --- a/src/main/java/org/spongepowered/api/data/type/PistonType.java +++ b/src/main/java/org/spongepowered/api/data/type/PistonType.java @@ -31,6 +31,6 @@ * Represents a "type" of piston. */ @CatalogedBy(PistonTypes.class) -public interface PistonType extends DefaultedRegistryValue, Comparable { +public interface PistonType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/PortionType.java b/src/main/java/org/spongepowered/api/data/type/PortionType.java index df57aceb2b..efac7f3021 100644 --- a/src/main/java/org/spongepowered/api/data/type/PortionType.java +++ b/src/main/java/org/spongepowered/api/data/type/PortionType.java @@ -28,6 +28,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(PortionTypes.class) -public interface PortionType extends DefaultedRegistryValue, Comparable { +public interface PortionType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/RailDirection.java b/src/main/java/org/spongepowered/api/data/type/RailDirection.java index 2d7e68ef5d..4d21ad9d24 100644 --- a/src/main/java/org/spongepowered/api/data/type/RailDirection.java +++ b/src/main/java/org/spongepowered/api/data/type/RailDirection.java @@ -29,6 +29,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(RailDirections.class) -public interface RailDirection extends DefaultedRegistryValue, Cycleable, Comparable { +public interface RailDirection extends DefaultedRegistryValue, Cycleable, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/SculkSensorState.java b/src/main/java/org/spongepowered/api/data/type/SculkSensorState.java index e9b50d6c4f..2870604f94 100644 --- a/src/main/java/org/spongepowered/api/data/type/SculkSensorState.java +++ b/src/main/java/org/spongepowered/api/data/type/SculkSensorState.java @@ -28,6 +28,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(SculkSensorStates.class) -public interface SculkSensorState extends DefaultedRegistryValue, Comparable { +public interface SculkSensorState extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/SlabPortion.java b/src/main/java/org/spongepowered/api/data/type/SlabPortion.java index 2fdb64d5ef..af3853a2be 100644 --- a/src/main/java/org/spongepowered/api/data/type/SlabPortion.java +++ b/src/main/java/org/spongepowered/api/data/type/SlabPortion.java @@ -33,6 +33,6 @@ * example {@link BlockTypes#STONE_SLAB}. */ @CatalogedBy(SlabPortions.class) -public interface SlabPortion extends DefaultedRegistryValue, Comparable { +public interface SlabPortion extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/StairShape.java b/src/main/java/org/spongepowered/api/data/type/StairShape.java index 99bb8f11f0..a445a42913 100644 --- a/src/main/java/org/spongepowered/api/data/type/StairShape.java +++ b/src/main/java/org/spongepowered/api/data/type/StairShape.java @@ -31,6 +31,6 @@ * Represents a stair shape. */ @CatalogedBy(StairShapes.class) -public interface StairShape extends DefaultedRegistryValue, Comparable { +public interface StairShape extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/StringRepresentable.java b/src/main/java/org/spongepowered/api/data/type/StringRepresentable.java new file mode 100644 index 0000000000..dba958f291 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/StringRepresentable.java @@ -0,0 +1,37 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +/** + * Represents a type that has a stable string representation, usually an enumerated + * set of values, like most catalog types: + * {@link org.spongepowered.api.data.type.ArtType}, + * {@link RabbitType}, {@link RailDirection}, etc. + */ +public interface StringRepresentable { + + String serializationString(); + +} diff --git a/src/main/java/org/spongepowered/api/data/type/StructureMode.java b/src/main/java/org/spongepowered/api/data/type/StructureMode.java index 755c31d10f..7562aa8d9f 100644 --- a/src/main/java/org/spongepowered/api/data/type/StructureMode.java +++ b/src/main/java/org/spongepowered/api/data/type/StructureMode.java @@ -32,6 +32,6 @@ * Represents a mode that a {@link StructureBlock} may be in. */ @CatalogedBy(StructureModes.class) -public interface StructureMode extends DefaultedRegistryValue, Comparable { +public interface StructureMode extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/Tilt.java b/src/main/java/org/spongepowered/api/data/type/Tilt.java index bba46d8536..eeca1951d7 100644 --- a/src/main/java/org/spongepowered/api/data/type/Tilt.java +++ b/src/main/java/org/spongepowered/api/data/type/Tilt.java @@ -28,7 +28,7 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(Tilts.class) -public interface Tilt extends DefaultedRegistryValue, Comparable { +public interface Tilt extends DefaultedRegistryValue, Comparable, StringRepresentable { /** * {@return Whether a block entering this tilt state will trigger any diff --git a/src/main/java/org/spongepowered/api/data/type/WallConnectionState.java b/src/main/java/org/spongepowered/api/data/type/WallConnectionState.java index a8ed41917b..2ea5feec8e 100644 --- a/src/main/java/org/spongepowered/api/data/type/WallConnectionState.java +++ b/src/main/java/org/spongepowered/api/data/type/WallConnectionState.java @@ -31,6 +31,6 @@ * Represents the type of wall BlockStates */ @CatalogedBy(WallConnectionStates.class) -public interface WallConnectionState extends DefaultedRegistryValue, Comparable { +public interface WallConnectionState extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/data/type/WireAttachmentType.java b/src/main/java/org/spongepowered/api/data/type/WireAttachmentType.java index 3f18c8e87b..dc35ec8fb7 100644 --- a/src/main/java/org/spongepowered/api/data/type/WireAttachmentType.java +++ b/src/main/java/org/spongepowered/api/data/type/WireAttachmentType.java @@ -28,6 +28,6 @@ import org.spongepowered.api.util.annotation.CatalogedBy; @CatalogedBy(WireAttachmentTypes.class) -public interface WireAttachmentType extends DefaultedRegistryValue, Comparable { +public interface WireAttachmentType extends DefaultedRegistryValue, Comparable, StringRepresentable { } diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index ee53b273ec..ad1d2d9724 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -88,7 +88,9 @@ import org.spongepowered.api.data.type.StairShape; import org.spongepowered.api.data.type.StructureMode; import org.spongepowered.api.data.type.Tilt; +import org.spongepowered.api.data.type.TrialSpawnerState; import org.spongepowered.api.data.type.TropicalFishShape; +import org.spongepowered.api.data.type.VaultState; import org.spongepowered.api.data.type.VillagerType; import org.spongepowered.api.data.type.WallConnectionState; import org.spongepowered.api.data.type.WireAttachmentType; @@ -496,10 +498,14 @@ public final class RegistryTypes { public static final DefaultedRegistryType TRANSACTION_TYPE = RegistryTypes.spongeKeyInGame("transaction_type"); + public static final DefaultedRegistryType TRIAL_SPAWNER_STATE = RegistryTypes.spongeKeyInGame("trial_spawner_state"); + public static final DefaultedRegistryType TROPICAL_FISH_SHAPE = RegistryTypes.spongeKeyInGame("tropical_fish_shape"); public static final DefaultedRegistryType TILT = RegistryTypes.spongeKeyInGame("tilt"); + public static final RegistryType VAULT_STATE = RegistryTypes.spongeKeyInGame("vault_state"); + public static final DefaultedRegistryType VISIBILITY = RegistryTypes.spongeKeyInGame("visibility"); public static final DefaultedRegistryType WALL_CONNECTION_STATE = RegistryTypes.spongeKeyInGame("wall_connection_state"); diff --git a/src/main/java/org/spongepowered/api/state/EnumStateProperty.java b/src/main/java/org/spongepowered/api/state/EnumStateProperty.java index 3b3679f0ca..db83a2c42e 100644 --- a/src/main/java/org/spongepowered/api/state/EnumStateProperty.java +++ b/src/main/java/org/spongepowered/api/state/EnumStateProperty.java @@ -25,6 +25,7 @@ package org.spongepowered.api.state; import org.spongepowered.api.Sponge; +import org.spongepowered.api.data.type.StringRepresentable; import org.spongepowered.api.util.annotation.CatalogedBy; /** @@ -33,7 +34,7 @@ * may not be exposed in the API. */ @CatalogedBy(EnumStateProperties.class) -public interface EnumStateProperty> extends StateProperty { +public interface EnumStateProperty & StringRepresentable> extends StateProperty { static > EnumStateProperty of(String name) { return Sponge.game().factoryProvider().provide(Factory.class).of(name); diff --git a/src/main/java/org/spongepowered/api/util/Axis.java b/src/main/java/org/spongepowered/api/util/Axis.java index 1c569851b7..4537059c7a 100644 --- a/src/main/java/org/spongepowered/api/util/Axis.java +++ b/src/main/java/org/spongepowered/api/util/Axis.java @@ -24,12 +24,13 @@ */ package org.spongepowered.api.util; +import org.spongepowered.api.data.type.StringRepresentable; import org.spongepowered.math.vector.Vector3d; /** * Represents a three dimensional cartesian axis. */ -public enum Axis implements Cycleable { +public enum Axis implements Cycleable, StringRepresentable { X(new Vector3d(1, 0, 0)), Y(new Vector3d(0, 1, 0)), @@ -142,4 +143,10 @@ public Axis cycleNext() { } return Axis.X; } + + @Override + public String serializationString() { + return this.name(); + } + } diff --git a/src/main/java/org/spongepowered/api/util/Direction.java b/src/main/java/org/spongepowered/api/util/Direction.java index f88bfa412a..7ffc7dc87b 100644 --- a/src/main/java/org/spongepowered/api/util/Direction.java +++ b/src/main/java/org/spongepowered/api/util/Direction.java @@ -25,6 +25,7 @@ package org.spongepowered.api.util; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.spongepowered.api.data.type.StringRepresentable; import org.spongepowered.math.GenericMath; import org.spongepowered.math.TrigMath; import org.spongepowered.math.vector.Vector3d; @@ -42,7 +43,7 @@ *
  • {@link #DOWN} targeting towards -Y
  • * */ -public enum Direction { +public enum Direction implements StringRepresentable { NORTH(new Vector3d(0, 0, -1), Division.CARDINAL), NORTH_NORTHEAST(new Vector3d(C.S8, 0, -C.C8), Division.SECONDARY_ORDINAL), NORTHEAST(new Vector3d(1, 0, -1), Division.ORDINAL), @@ -341,6 +342,11 @@ public Vector3i asBlockOffset() { return this.blockOffset; } + @Override + public String serializationString() { + return this.name(); + } + private interface C { double C8 = Math.cos(Math.PI / 8); From e4bae211a6d535b0ab4401ca853a6c8afd5a2e75 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Mon, 3 Jun 2024 20:11:23 -0700 Subject: [PATCH 43/53] feat: Implement Vault and Trial States --- .../api/data/type/TrialSpawnerState.java | 32 +++++++++++ .../api/data/type/TrialSpawnerStates.java | 56 +++++++++++++++++++ .../api/data/type/VaultState.java | 32 +++++++++++ .../api/data/type/VaultStates.java | 49 ++++++++++++++++ .../api/state/EnumStateProperties.java | 6 +- .../api/state/EnumStateProperty.java | 4 +- 6 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/spongepowered/api/data/type/TrialSpawnerState.java create mode 100644 src/main/java/org/spongepowered/api/data/type/TrialSpawnerStates.java create mode 100644 src/main/java/org/spongepowered/api/data/type/VaultState.java create mode 100644 src/main/java/org/spongepowered/api/data/type/VaultStates.java diff --git a/src/main/java/org/spongepowered/api/data/type/TrialSpawnerState.java b/src/main/java/org/spongepowered/api/data/type/TrialSpawnerState.java new file mode 100644 index 0000000000..504d2ecacc --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/TrialSpawnerState.java @@ -0,0 +1,32 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(TrialSpawnerStates.class) +public interface TrialSpawnerState extends Comparable, StringRepresentable { + +} diff --git a/src/main/java/org/spongepowered/api/data/type/TrialSpawnerStates.java b/src/main/java/org/spongepowered/api/data/type/TrialSpawnerStates.java new file mode 100644 index 0000000000..7724165f31 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/TrialSpawnerStates.java @@ -0,0 +1,56 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryTypes; + +public final class TrialSpawnerStates { + + public static final DefaultedRegistryReference INACTIVE = TrialSpawnerStates.key(ResourceKey.sponge("INACTIVE")); + + public static final DefaultedRegistryReference WAITING_FOR_PLAYERS = TrialSpawnerStates.key(ResourceKey.sponge("WAITING_FOR_PLAYERS")); + + public static final DefaultedRegistryReference ACTIVE = TrialSpawnerStates.key(ResourceKey.sponge("ACTIVE")); + + public static final DefaultedRegistryReference WAITING_FOR_REWARD_EJECTION = TrialSpawnerStates.key(ResourceKey.sponge("WAITING_FOR_REWARD_EJECTION")); + + public static final DefaultedRegistryReference EJECTING_REWARD = TrialSpawnerStates.key(ResourceKey.sponge("EJECTING_REWARD")); + + public static final DefaultedRegistryReference COOLDOWN = TrialSpawnerStates.key(ResourceKey.sponge("COOLDOWN")); + + + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.TRIAL_SPAWNER_STATE); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.TRIAL_SPAWNER_STATE, location).asDefaultedReference(Sponge::game); + } +} diff --git a/src/main/java/org/spongepowered/api/data/type/VaultState.java b/src/main/java/org/spongepowered/api/data/type/VaultState.java new file mode 100644 index 0000000000..b80f20a53d --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/VaultState.java @@ -0,0 +1,32 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(VaultStates.class) +public interface VaultState extends Comparable, StringRepresentable { + +} diff --git a/src/main/java/org/spongepowered/api/data/type/VaultStates.java b/src/main/java/org/spongepowered/api/data/type/VaultStates.java new file mode 100644 index 0000000000..e017753800 --- /dev/null +++ b/src/main/java/org/spongepowered/api/data/type/VaultStates.java @@ -0,0 +1,49 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.data.type; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryTypes; + +public final class VaultStates { + + public static final DefaultedRegistryReference INACTIVE = VaultStates.key(ResourceKey.sponge("inactive")); + public static final DefaultedRegistryReference ACTIVE = VaultStates.key(ResourceKey.sponge("active")); + public static final DefaultedRegistryReference UNLOCKING = VaultStates.key(ResourceKey.sponge("unlocking")); + public static final DefaultedRegistryReference EJECTING = VaultStates.key(ResourceKey.sponge("ejecting")); + + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.VAULT_STATE); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.VAULT_STATE, location).asDefaultedReference(Sponge::game); + } + +} diff --git a/src/main/java/org/spongepowered/api/state/EnumStateProperties.java b/src/main/java/org/spongepowered/api/state/EnumStateProperties.java index 3300563ee1..8cdaa8c716 100644 --- a/src/main/java/org/spongepowered/api/state/EnumStateProperties.java +++ b/src/main/java/org/spongepowered/api/state/EnumStateProperties.java @@ -41,6 +41,8 @@ import org.spongepowered.api.data.type.StairShape; import org.spongepowered.api.data.type.StructureMode; import org.spongepowered.api.data.type.Tilt; +import org.spongepowered.api.data.type.TrialSpawnerState; +import org.spongepowered.api.data.type.VaultState; import org.spongepowered.api.data.type.WallConnectionState; import org.spongepowered.api.data.type.WireAttachmentType; import org.spongepowered.api.util.Axis; @@ -179,11 +181,11 @@ public static EnumStateProperty property_TILT() { return EnumStateProperty.of("TILT"); } - public static EnumStateProperty property_TRIAL_SPAWNER_STATE() { + public static EnumStateProperty property_TRIAL_SPAWNER_STATE() { return EnumStateProperty.of("TRIAL_SPAWNER_STATE"); } - public static EnumStateProperty property_VAULT_STATE() { + public static EnumStateProperty property_VAULT_STATE() { return EnumStateProperty.of("VAULT_STATE"); } diff --git a/src/main/java/org/spongepowered/api/state/EnumStateProperty.java b/src/main/java/org/spongepowered/api/state/EnumStateProperty.java index db83a2c42e..5d5fb69431 100644 --- a/src/main/java/org/spongepowered/api/state/EnumStateProperty.java +++ b/src/main/java/org/spongepowered/api/state/EnumStateProperty.java @@ -36,12 +36,12 @@ @CatalogedBy(EnumStateProperties.class) public interface EnumStateProperty & StringRepresentable> extends StateProperty { - static > EnumStateProperty of(String name) { + static & StringRepresentable> EnumStateProperty of(String name) { return Sponge.game().factoryProvider().provide(Factory.class).of(name); } interface Factory { - > EnumStateProperty of(String name); + & StringRepresentable> EnumStateProperty of(String name); } } From 22cb82d9c0504d07e1044362f6d1fc1b0079123c Mon Sep 17 00:00:00 2001 From: aromaa Date: Tue, 4 Jun 2024 22:52:11 +0300 Subject: [PATCH 44/53] Add PotionSlot --- .../java/org/spongepowered/api/data/Keys.java | 5 +++ .../api/item/inventory/slot/PotionSlot.java | 32 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/main/java/org/spongepowered/api/item/inventory/slot/PotionSlot.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 07b6bc53ec..29796d2198 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -787,6 +787,11 @@ public final class Keys { */ public static final Key> CUSTOM_NAME = Keys.key(ResourceKey.sponge("custom_name"), Component.class); + /** + * The custom potion effects that are stored on an {@link ItemStack}. + */ + public static final Key> CUSTOM_POTION_EFFECTS = Keys.listKey(ResourceKey.sponge("custom_potion_effects"), PotionEffect.class); + /** * The damage absorbed by an armor {@link ItemStack}. * Readonly diff --git a/src/main/java/org/spongepowered/api/item/inventory/slot/PotionSlot.java b/src/main/java/org/spongepowered/api/item/inventory/slot/PotionSlot.java new file mode 100644 index 0000000000..ef97aaf17b --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/inventory/slot/PotionSlot.java @@ -0,0 +1,32 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.inventory.slot; + +/** + * An inventory slot which can only contain potions. + * e.g. BrewingStand + */ +public interface PotionSlot extends FilteringSlot { +} From 289329afbd94666c5ee2fcf2127e2a58c6d84767 Mon Sep 17 00:00:00 2001 From: MrHell228 <82652479+MrHell228@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:58:48 +0300 Subject: [PATCH 45/53] Change BlockEntity#setValid() to remove() (#2516) * Change BlockEntity#setValid() to remove() * Fix description Co-authored-by: Joni Aromaa --------- Co-authored-by: Joni Aromaa --- .../api/block/entity/BlockEntity.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java index 0b9874c9d7..bc74a110b3 100644 --- a/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java +++ b/src/main/java/org/spongepowered/api/block/entity/BlockEntity.java @@ -56,31 +56,16 @@ public interface BlockEntity extends SerializableDataHolder.Mutable, Locatable { /** - * Checks for whether the block entity is currently valid or not. + * Returns whether this block entity has been removed. * - *

    Use this method to check if processing should be run on this - * {@link BlockEntity}. If it is valid, then processing can be run on it. - * If not, then processing should wait until it becomes valid or is - * destroyed.

    - * - * @return True if the block entity is valid, false if not + * @return True if this block entity has been removed */ - boolean isValid(); + boolean isRemoved(); /** - * Changes the validation of this block entity. - * - *

    If the block entity is invalid, no processing will be done on this - * {@link BlockEntity} until it either becomes valid or is reset on the next - * tick.

    - * - *

    If the block entity is valid, then processing can continue and this - * {@link BlockEntity} will not be reset on the next tick.

    - * - * @param valid True if the block entity should be validated, or false if - * it should be invalidated + * Removes this block entity from the world and its corresponding block. */ - void setValid(boolean valid); + void remove(); /** * Gets the type of {@link BlockEntity} this is. From e42b62562441016316e4c090f4498b0bbc0338fa Mon Sep 17 00:00:00 2001 From: aromaa Date: Sun, 9 Jun 2024 23:34:28 +0300 Subject: [PATCH 46/53] Change Cooking and Brewing events to use AffectSlotEvent --- .../api/event/block/entity/BrewingEvent.java | 23 +++---------------- .../api/event/block/entity/CookingEvent.java | 14 +++-------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/spongepowered/api/event/block/entity/BrewingEvent.java b/src/main/java/org/spongepowered/api/event/block/entity/BrewingEvent.java index 585dde367f..c2fc31bdd0 100644 --- a/src/main/java/org/spongepowered/api/event/block/entity/BrewingEvent.java +++ b/src/main/java/org/spongepowered/api/event/block/entity/BrewingEvent.java @@ -25,13 +25,12 @@ package org.spongepowered.api.event.block.entity; import org.spongepowered.api.block.entity.carrier.BrewingStand; -import org.spongepowered.api.data.Transaction; import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.Event; +import org.spongepowered.api.event.item.inventory.AffectSlotEvent; import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.ItemStackSnapshot; -import java.util.List; /** * Fires during the brewing process where {@link ItemStack}s are brewed into different {@link ItemStack}s @@ -61,15 +60,7 @@ interface Start extends BrewingEvent, Cancellable {} /** * Fired when a fuel item is consumed to refill the fuel bar. */ - interface ConsumeFuel extends BrewingEvent, Cancellable { - - /** - * The consumed fuel transaction. - * - * @return The consumed fuel transaction. - */ - Transaction fuel(); - + interface ConsumeFuel extends BrewingEvent, AffectSlotEvent, Cancellable { } /** @@ -85,14 +76,6 @@ interface Interrupt extends BrewingEvent {} /** * Fires when brewing finished. */ - interface Finish extends BrewingEvent { - - /** - * Gets an immutable {@link List} of {@link ItemStackSnapshot}s that are the result - * of the brew. - * - * @return The brewed items - */ - List brewedItemStacks(); + interface Finish extends BrewingEvent, AffectSlotEvent { } } diff --git a/src/main/java/org/spongepowered/api/event/block/entity/CookingEvent.java b/src/main/java/org/spongepowered/api/event/block/entity/CookingEvent.java index c71c95e4fa..577b837d1c 100644 --- a/src/main/java/org/spongepowered/api/event/block/entity/CookingEvent.java +++ b/src/main/java/org/spongepowered/api/event/block/entity/CookingEvent.java @@ -28,11 +28,10 @@ import org.spongepowered.api.block.entity.BlockEntity; import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.Event; -import org.spongepowered.api.event.item.inventory.AffectItemStackEvent; +import org.spongepowered.api.event.item.inventory.AffectSlotEvent; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.recipe.cooking.CookingRecipe; -import java.util.List; import java.util.Optional; /** @@ -74,7 +73,7 @@ interface Start extends CookingEvent, Cancellable {} * Fires whenever fuel is consumed to refill the current burn time. * Canceling this event prevents fuel from being consumed in a furnace In the current burn time to 0. */ - interface ConsumeFuel extends CookingEvent, AffectItemStackEvent {} + interface ConsumeFuel extends CookingEvent, AffectSlotEvent {} /** * The cooking timer ticking up or down. @@ -95,13 +94,6 @@ interface Tick extends CookingEvent, Cancellable { interface Interrupt extends CookingEvent { } - interface Finish extends CookingEvent { - /** - * Gets an immutable {@link List} of {@link ItemStackSnapshot}s that are the result of the cooking. - * Always exactly one item. - * - * @return The cooked items - */ - List cookedItems(); + interface Finish extends CookingEvent, AffectSlotEvent { } } From 1460c68d2460bb60dd1ab23375f5959bc8d99f50 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Sat, 15 Jun 2024 18:02:37 -0700 Subject: [PATCH 47/53] feat: Release API 11 Signed-off-by: Gabriel Harris-Rouquette --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bbd9a55f2f..8625a21a8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=org.spongepowered -version=11.0.0-SNAPSHOT +version=11.0.0 organization=SpongePowered projectUrl=https://www.spongepowered.org projectDescription=A plugin API for Minecraft: Java Edition From 734374cfa08053c605a7d66c2363e1977798d9e2 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Sat, 15 Jun 2024 18:05:19 -0700 Subject: [PATCH 48/53] chore: Update towards next snapshot Signed-off-by: Gabriel Harris-Rouquette --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8625a21a8c..5feddbda90 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ group=org.spongepowered -version=11.0.0 +version=11.1.0-SNAPSHOT organization=SpongePowered projectUrl=https://www.spongepowered.org projectDescription=A plugin API for Minecraft: Java Edition From e77997062fe9d369957312442fb0a440c20329b4 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Sun, 2 Jun 2024 21:08:52 +0300 Subject: [PATCH 49/53] Add Viewer#sendBlockProgress --- .../org/spongepowered/api/effect/Viewer.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/main/java/org/spongepowered/api/effect/Viewer.java b/src/main/java/org/spongepowered/api/effect/Viewer.java index b79025d091..4a7897d6d3 100644 --- a/src/main/java/org/spongepowered/api/effect/Viewer.java +++ b/src/main/java/org/spongepowered/api/effect/Viewer.java @@ -161,4 +161,60 @@ default void resetBlockChange(final Vector3i position) { */ void resetBlockChange(int x, int y, int z); + /** + * Sends a client-only block breaking progress. + * + *

    In vanilla breaking progress will not be rendered if player + * is further than 32 blocks from given position.
    + * Sent breaking progress expires on client 400 ticks after receiving.

    + * + * @param position The position + * @param progress The breaking progress from 0 to 1 (1 excluded) + */ + default void sendBlockProgress(final Vector3i position, final float progress) { + Objects.requireNonNull(position, "position"); + this.sendBlockProgress(position.x(), position.y(), position.z(), progress); + } + + /** + * Sends a client-only block breaking progress. + * + *

    In vanilla breaking progress will not be rendered if player + * is further than 32 blocks from given position.
    + * Sent breaking progress expires on client 400 ticks after receiving.

    + * + * @param x The x position + * @param y The y position + * @param z The z position + * @param progress The breaking progress from 0 to 1 (1 excluded) + */ + void sendBlockProgress(int x, int y, int z, float progress); + + /** + * Resets the client's view of the provided position to actual + * breaking progress. + * + *

    This is useful for resetting what the client sees + * after sending a {@link #sendBlockProgress block progress}.

    + * + * @param position The position + */ + default void resetBlockProgress(final Vector3i position) { + Objects.requireNonNull(position, "position"); + this.resetBlockProgress(position.x(), position.y(), position.z()); + } + + /** + * Resets the client's view of the provided position to actual + * breaking progress. + * + *

    This is useful for resetting what the client sees + * after sending a {@link #sendBlockProgress block progress}.

    + * + * @param x The x position + * @param y The y position + * @param z The z position + */ + void resetBlockProgress(int x, int y, int z); + } From ba2c603f65bbf2025db4e5735e8a4f28c4d7a0b1 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 3 Jun 2024 11:27:25 +0300 Subject: [PATCH 50/53] Allow 1 for block progress --- src/main/java/org/spongepowered/api/effect/Viewer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/effect/Viewer.java b/src/main/java/org/spongepowered/api/effect/Viewer.java index 4a7897d6d3..a6c47dc449 100644 --- a/src/main/java/org/spongepowered/api/effect/Viewer.java +++ b/src/main/java/org/spongepowered/api/effect/Viewer.java @@ -169,7 +169,7 @@ default void resetBlockChange(final Vector3i position) { * Sent breaking progress expires on client 400 ticks after receiving.

    * * @param position The position - * @param progress The breaking progress from 0 to 1 (1 excluded) + * @param progress The breaking progress from 0 to 1 */ default void sendBlockProgress(final Vector3i position, final float progress) { Objects.requireNonNull(position, "position"); @@ -186,7 +186,7 @@ default void sendBlockProgress(final Vector3i position, final float progress) { * @param x The x position * @param y The y position * @param z The z position - * @param progress The breaking progress from 0 to 1 (1 excluded) + * @param progress The breaking progress from 0 to 1 */ void sendBlockProgress(int x, int y, int z, float progress); From 7612a9dda11f746d6ada5e9b5669bf05f416f62a Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Mon, 3 Jun 2024 20:54:08 +0300 Subject: [PATCH 51/53] Make progress double instead of float --- src/main/java/org/spongepowered/api/effect/Viewer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spongepowered/api/effect/Viewer.java b/src/main/java/org/spongepowered/api/effect/Viewer.java index a6c47dc449..ca1b44495f 100644 --- a/src/main/java/org/spongepowered/api/effect/Viewer.java +++ b/src/main/java/org/spongepowered/api/effect/Viewer.java @@ -171,7 +171,7 @@ default void resetBlockChange(final Vector3i position) { * @param position The position * @param progress The breaking progress from 0 to 1 */ - default void sendBlockProgress(final Vector3i position, final float progress) { + default void sendBlockProgress(final Vector3i position, final double progress) { Objects.requireNonNull(position, "position"); this.sendBlockProgress(position.x(), position.y(), position.z(), progress); } @@ -188,7 +188,7 @@ default void sendBlockProgress(final Vector3i position, final float progress) { * @param z The z position * @param progress The breaking progress from 0 to 1 */ - void sendBlockProgress(int x, int y, int z, float progress); + void sendBlockProgress(int x, int y, int z, double progress); /** * Resets the client's view of the provided position to actual From eea04caa0f06d40aaad9ce82444e2cd464e28ec5 Mon Sep 17 00:00:00 2001 From: MrHell228 Date: Sun, 23 Jun 2024 03:14:58 +0300 Subject: [PATCH 52/53] Remove vanilla behaviour description --- src/main/java/org/spongepowered/api/effect/Viewer.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/org/spongepowered/api/effect/Viewer.java b/src/main/java/org/spongepowered/api/effect/Viewer.java index ca1b44495f..d0e23ae2a9 100644 --- a/src/main/java/org/spongepowered/api/effect/Viewer.java +++ b/src/main/java/org/spongepowered/api/effect/Viewer.java @@ -164,10 +164,6 @@ default void resetBlockChange(final Vector3i position) { /** * Sends a client-only block breaking progress. * - *

    In vanilla breaking progress will not be rendered if player - * is further than 32 blocks from given position.
    - * Sent breaking progress expires on client 400 ticks after receiving.

    - * * @param position The position * @param progress The breaking progress from 0 to 1 */ @@ -179,10 +175,6 @@ default void sendBlockProgress(final Vector3i position, final double progress) { /** * Sends a client-only block breaking progress. * - *

    In vanilla breaking progress will not be rendered if player - * is further than 32 blocks from given position.
    - * Sent breaking progress expires on client 400 ticks after receiving.

    - * * @param x The x position * @param y The y position * @param z The z position From fcfb9213f66959667ae63523d593e2e5cf567af9 Mon Sep 17 00:00:00 2001 From: Jesse McKee Date: Fri, 31 May 2024 17:02:39 -0500 Subject: [PATCH 53/53] Add Keys.TELEPORT_DURATION for DisplayEntity Closes #2508 --- src/main/java/org/spongepowered/api/data/Keys.java | 5 +++++ .../spongepowered/api/entity/display/DisplayEntity.java | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 29796d2198..8efdf7d032 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -3113,6 +3113,11 @@ public final class Keys { */ public static final Key> TARGET_POSITION = Keys.key(ResourceKey.sponge("target_position"), Vector3i.class); + /** + * The teleport duration of a {@link DisplayEntity} + */ + public static final Key> TELEPORT_DURATION = Keys.key(ResourceKey.sponge("teleport_duration"), Ticks.class); + /** * The {@link TemperatureModifier} of a {@link Biome}. * Readonly diff --git a/src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java b/src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java index ea6e470db0..0173171c71 100644 --- a/src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java +++ b/src/main/java/org/spongepowered/api/entity/display/DisplayEntity.java @@ -64,6 +64,15 @@ default Ticks interpolationDelay() { return this.require(Keys.INTERPOLATION_DELAY); } + /** + * Returns the duration of the teleportation + * + * @return the duration of the teleportation + */ + default Ticks teleportDuration() { + return this.require(Keys.TELEPORT_DURATION); + } + default BillboardType billboardType() { return this.require(Keys.BILLBOARD_TYPE); }