Skip to content

Commit 6cf1ba3

Browse files
committed
Merge branch 'api-14' into api-15
# Conflicts: # SpongeAPI # neoforge/src/mixins/resources/mixins.spongeneo.core.json # src/main/java/org/spongepowered/common/data/provider/item/stack/ItemStackData.java # testplugins/src/main/java/org/spongepowered/test/data/DataTest.java
2 parents e09cc34 + 0aaf455 commit 6cf1ba3

File tree

26 files changed

+2149
-1461
lines changed

26 files changed

+2149
-1461
lines changed

generator/src/main/java/org/spongepowered/vanilla/generator/world/entities/EntityRegistries.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.minecraft.resources.ResourceLocation;
2929
import net.minecraft.world.entity.Display;
3030
import net.minecraft.world.entity.EquipmentSlot;
31+
import net.minecraft.world.entity.EquipmentSlotGroup;
3132
import net.minecraft.world.entity.MobCategory;
3233
import net.minecraft.world.entity.animal.Fox;
3334
import net.minecraft.world.entity.animal.MushroomCow;
@@ -159,6 +160,13 @@ public static List<Generator> enumEntries(final Context context) {
159160
"getSerializedName",
160161
"sponge"
161162
),
163+
new EnumEntriesValidator<>(
164+
"item.inventory.equipment",
165+
"EquipmentConditions",
166+
EquipmentSlotGroup.class,
167+
"getSerializedName",
168+
"sponge"
169+
),
162170
new EnumEntriesValidator<>(
163171
"item.inventory.equipment",
164172
"EquipmentGroups",

gradle/verification-metadata.xml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
<trust group="org.codehaus.groovy" name="groovy-templates" reason="FIX"/>
2020
<trust group="org.codehaus.groovy" name="groovy-test" reason="FIX"/>
2121
<trust group="org.codehaus.groovy" name="groovy-xml" reason="FIX"/>
22-
<trust group="org.spongepowered" name="vanillagradle" reason="FIX THIS"/>
23-
<trust group="org.spongepowered" name="vanillagradle-downloader-apache-http" reason="FIX THIS"/>
24-
<trust group="org.spongepowered" name="vanillagradle-resolver-core" reason="FIX THIS"/>
25-
<trust group="org.spongepowered.gradle.vanilla" name="org.spongepowered.gradle.vanilla.gradle.plugin" reason="SNAPSHOT"/>
2622
<trust file=".*-javadoc[.]jar" regex="true"/>
2723
<trust file=".*-sources[.]jar" regex="true"/>
2824
<trust group="gradle" name="gradle" file="gradle-.*-src.zip" regex="true"/>
@@ -2224,6 +2220,14 @@
22242220
<sha256 value="14e4faabaa430bfc33a6e93ddafcc88f50adf3cb866ff457ceaa8294911535c7" origin="Generated by Gradle"/>
22252221
</artifact>
22262222
</component>
2223+
<component group="gradle.plugin.org.jetbrains.gradle.plugin.idea-ext" name="gradle-idea-ext" version="1.3">
2224+
<artifact name="gradle-idea-ext-1.3.jar">
2225+
<sha256 value="a50ba79776c223679c878af380f7b7efac5d8b6e0865c8d3d6207450e0135a30" origin="Generated by Gradle"/>
2226+
</artifact>
2227+
<artifact name="gradle-idea-ext-1.3.pom">
2228+
<sha256 value="d930f23a39107c8f18809dd732d2163e615e6e2a27ad9621c1b4f6e6703d4a11" origin="Generated by Gradle"/>
2229+
</artifact>
2230+
</component>
22272231
<component group="info.picocli" name="picocli" version="4.7.5">
22282232
<artifact name="picocli-4.7.5.jar">
22292233
<sha256 value="e83a906fb99b57091d1d68ac11f7c3d2518bd7a81a9c71b259e2c00d1564c8e8" origin="Generated by Gradle"/>
@@ -9596,6 +9600,30 @@
95969600
<sha256 value="8f616cd91d8706de772d4a65ffd7a40e7021a09278a712bf69bfac4e8980ba9c" origin="Generated by Gradle"/>
95979601
</artifact>
95989602
</component>
9603+
<component group="org.spongepowered" name="vanillagradle" version="0.2.1">
9604+
<artifact name="vanillagradle-0.2.1.jar">
9605+
<sha256 value="f9adf8a826af0907c039725c3e2f2495076ecfa9d1d39fc92244a097c2e16126" origin="Generated by Gradle"/>
9606+
</artifact>
9607+
<artifact name="vanillagradle-0.2.1.module">
9608+
<sha256 value="b62c076c3819bafa88d34f5c4de503914f13ab06918121eda37209ad231a3b4b" origin="Generated by Gradle"/>
9609+
</artifact>
9610+
</component>
9611+
<component group="org.spongepowered" name="vanillagradle-downloader-apache-http" version="0.2.1">
9612+
<artifact name="vanillagradle-downloader-apache-http-0.2.1.jar">
9613+
<sha256 value="7252a8f9ef41b87c9d0613e00f2d58f1847b1e9869ccd63a2d0e326a9c45ec28" origin="Generated by Gradle"/>
9614+
</artifact>
9615+
<artifact name="vanillagradle-downloader-apache-http-0.2.1.module">
9616+
<sha256 value="2e740dcbcb0981d14ddf35226df09b1a660361ab93dbdb883014895fe3e5ab03" origin="Generated by Gradle"/>
9617+
</artifact>
9618+
</component>
9619+
<component group="org.spongepowered" name="vanillagradle-resolver-core" version="0.2.1">
9620+
<artifact name="vanillagradle-resolver-core-0.2.1.jar">
9621+
<sha256 value="ce94b6afecf1f6ae2f406997255ab06240f335a6cba8da7fba3636da87958a4c" origin="Generated by Gradle"/>
9622+
</artifact>
9623+
<artifact name="vanillagradle-resolver-core-0.2.1.module">
9624+
<sha256 value="af0b9f9b20ea5faa9b791b99b566f99b46efe9ba03a70c2583010ff185e39712" origin="Generated by Gradle"/>
9625+
</artifact>
9626+
</component>
95999627
<component group="org.spongepowered.gradle.event-impl-gen" name="org.spongepowered.gradle.event-impl-gen.gradle.plugin" version="7.1.0">
96009628
<artifact name="org.spongepowered.gradle.event-impl-gen.gradle.plugin-7.1.0.pom">
96019629
<sha256 value="1690d120b1c16e2a70e7bd0f6674b8ed8a523f701c1c99cede3484031fc5faa7" origin="Generated by Gradle"/>
@@ -9606,6 +9634,11 @@
96069634
<sha256 value="38cce278fd1102dbe3b8c7c11d14098622e4f7f091eb21d71ab0d09f2ff1ab8b" origin="Generated by Gradle"/>
96079635
</artifact>
96089636
</component>
9637+
<component group="org.spongepowered.gradle.vanilla" name="org.spongepowered.gradle.vanilla.gradle.plugin" version="0.2.1">
9638+
<artifact name="org.spongepowered.gradle.vanilla.gradle.plugin-0.2.1.pom">
9639+
<sha256 value="6e384769218bc8ba48c66b3db599638d65bc62c0e699355444b3ef66bef1d355" origin="Generated by Gradle"/>
9640+
</artifact>
9641+
</component>
96099642
<component group="org.springframework" name="spring-framework-bom" version="5.3.24">
96109643
<artifact name="spring-framework-bom-5.3.24.module">
96119644
<sha256 value="1996e1f617cb03fa76ea11850fe2a1e20b0e30a1046ba6d5db3bdbbf44113fce" origin="Generated by Gradle"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.neoforge.mixin.core.network.protocol.common;
26+
27+
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
28+
import org.spongepowered.asm.mixin.Final;
29+
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.Shadow;
31+
import org.spongepowered.asm.mixin.injection.At;
32+
import org.spongepowered.asm.mixin.injection.Redirect;
33+
import org.spongepowered.common.network.channel.ChannelUtils;
34+
35+
import java.util.ArrayList;
36+
import java.util.List;
37+
38+
@SuppressWarnings({"rawtypes", "unchecked"})
39+
@Mixin(ClientboundCustomPayloadPacket.class)
40+
public abstract class ClientboundCustomPayloadPacketMixin_Neo {
41+
42+
// @formatter: off
43+
@Shadow @Final private static int MAX_PAYLOAD_SIZE;
44+
// @formatter: on
45+
46+
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/Lists;newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;"), remap = false)
47+
private static ArrayList neo$registerCustomPacketPayloadsGame(final Object[] registrations) {
48+
final ArrayList allRegistrations = new ArrayList<>(List.of(registrations));
49+
allRegistrations.addAll(ChannelUtils.spongeChannelCodecs(ClientboundCustomPayloadPacketMixin_Neo.MAX_PAYLOAD_SIZE));
50+
return allRegistrations;
51+
}
52+
53+
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Ljava/util/List;of(Ljava/lang/Object;)Ljava/util/List;"))
54+
private static List neo$registerCustomPacketPayloadsConfiguration(final Object registrations) {
55+
final List allRegistrations = new ArrayList<>(List.of(registrations));
56+
allRegistrations.addAll(ChannelUtils.spongeChannelCodecs(ClientboundCustomPayloadPacketMixin_Neo.MAX_PAYLOAD_SIZE));
57+
return allRegistrations;
58+
}
59+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.neoforge.mixin.core.network.protocol.common;
26+
27+
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
28+
import org.spongepowered.asm.mixin.Final;
29+
import org.spongepowered.asm.mixin.Mixin;
30+
import org.spongepowered.asm.mixin.Shadow;
31+
import org.spongepowered.asm.mixin.injection.At;
32+
import org.spongepowered.asm.mixin.injection.Redirect;
33+
import org.spongepowered.common.network.channel.ChannelUtils;
34+
35+
import java.util.ArrayList;
36+
import java.util.List;
37+
38+
@SuppressWarnings({"rawtypes", "unchecked"})
39+
@Mixin(ServerboundCustomPayloadPacket.class)
40+
public abstract class ServerboundCustomPayloadPacketMixin_Neo {
41+
42+
// @formatter: off
43+
@Shadow @Final private static int MAX_PAYLOAD_SIZE;
44+
// @formatter: on
45+
46+
@Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/Lists;newArrayList([Ljava/lang/Object;)Ljava/util/ArrayList;"), remap = false)
47+
private static ArrayList neo$registerCustomPacketPayloads(final Object[] registrations) {
48+
final ArrayList allRegistrations = new ArrayList<>(List.of(registrations));
49+
allRegistrations.addAll(ChannelUtils.spongeChannelCodecs(ServerboundCustomPayloadPacketMixin_Neo.MAX_PAYLOAD_SIZE));
50+
return allRegistrations;
51+
}
52+
}

neoforge/src/mixins/resources/mixins.spongeneo.core.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"neoforge.registries.GameDataMixin_Neo",
2020
"neoforge.registries.RegistryManagerMixin_Neo",
2121
"network.ConnectionMixin_Neo",
22+
"network.protocol.common.ClientboundCustomPayloadPacketMixin_Neo",
23+
"network.protocol.common.ServerboundCustomPayloadPacketMixin_Neo",
2224
"resources.RegistryDataLoaderMixin_Neo",
2325
"server.BootstrapMixin_Neo",
2426
"server.MinecraftServerMixin_Neo",

settings.gradle.kts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,10 @@ pluginManagement {
99
name = "architectury"
1010
}
1111
}
12-
val vanillaGradleVersion = "0.2.1-20241107.194040-91"
1312
plugins {
14-
id("org.spongepowered.gradle.vanilla") version vanillaGradleVersion
13+
id("org.spongepowered.gradle.vanilla") version "0.2.1"
1514
id("implementation-structure")
1615
}
17-
resolutionStrategy {
18-
eachPlugin {
19-
if (requested.id.id == "org.spongepowered.gradle.vanilla") {
20-
useModule("org.spongepowered:vanillagradle:$vanillaGradleVersion")
21-
}
22-
}
23-
}
2416
}
2517

2618
plugins {

src/main/java/org/spongepowered/common/data/provider/item/stack/ItemStackData.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import net.minecraft.world.item.component.CustomModelData;
4444
import net.minecraft.world.item.component.DamageResistant;
4545
import net.minecraft.world.item.component.DeathProtection;
46+
import net.minecraft.world.item.component.ItemAttributeModifiers;
4647
import net.minecraft.world.item.component.ItemContainerContents;
4748
import net.minecraft.world.item.component.ItemLore;
4849
import net.minecraft.world.item.component.UseCooldown;
@@ -56,6 +57,7 @@
5657
import org.spongepowered.api.data.Keys;
5758
import org.spongepowered.api.data.type.ItemAction;
5859
import org.spongepowered.api.data.value.Value;
60+
import org.spongepowered.api.entity.attribute.ItemAttribute;
5961
import org.spongepowered.api.item.ItemRarity;
6062
import org.spongepowered.api.item.ItemType;
6163
import org.spongepowered.api.item.inventory.Inventory;
@@ -83,7 +85,6 @@ private ItemStackData() {
8385
// @formatter:off
8486
public static void register(final DataProviderRegistrator registrator) {
8587
// TODO DataComponents.SUSPICIOUS_STEW_EFFECTS
86-
// TODO maybe DataComponents.ATTRIBUTE_MODIFIERS as keys?
8788
// TODO DataComponents.BUNDLE_CONTENTS also check for Shulker Boxes? - removing the component prevents using the bundle
8889
// TODO DataComponents.CONTAINER_LOOT for containers with loottable data, also for blockentity?
8990
// TODO DataComponents.BLOCK_ENTITY_DATA maybe expose as raw DataContainer? (id MUST have block entity type)
@@ -423,6 +424,16 @@ public static void register(final DataProviderRegistrator registrator) {
423424
h.set(DataComponents.WEAPON, new Weapon(weapon.itemDamagePerAttack()));
424425
}
425426
})
427+
.create(Keys.ITEM_ATTRIBUTES)
428+
.get(stack -> {
429+
final var attributes = stack.getOrDefault(DataComponents.ATTRIBUTE_MODIFIERS, ItemAttributeModifiers.EMPTY).modifiers();
430+
return attributes.isEmpty() ? null : (List<ItemAttribute>) (Object) List.copyOf(attributes);
431+
})
432+
.set((stack, v) -> {
433+
final var attributes = (List<ItemAttributeModifiers.Entry>) (Object) List.copyOf(v);
434+
stack.set(DataComponents.ATTRIBUTE_MODIFIERS, new ItemAttributeModifiers(attributes));
435+
})
436+
.resetOnDelete(List.of())
426437
;
427438
}
428439
// @formatter:on
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* This file is part of Sponge, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.common.entity.attribute;
26+
27+
import net.minecraft.core.registries.Registries;
28+
import net.minecraft.world.entity.EquipmentSlotGroup;
29+
import net.minecraft.world.entity.ai.attributes.Attribute;
30+
import net.minecraft.world.item.component.ItemAttributeModifiers;
31+
import org.spongepowered.api.entity.attribute.AttributeModifier;
32+
import org.spongepowered.api.entity.attribute.ItemAttribute;
33+
import org.spongepowered.api.entity.attribute.type.AttributeType;
34+
import org.spongepowered.api.item.inventory.equipment.EquipmentCondition;
35+
import org.spongepowered.common.SpongeCommon;
36+
37+
import java.util.Objects;
38+
39+
public final class SpongeItemAttributeFactory implements ItemAttribute.Factory {
40+
41+
@Override
42+
public ItemAttribute of(final AttributeType type, final AttributeModifier modifier, final EquipmentCondition condition) {
43+
Objects.requireNonNull(type, "type");
44+
Objects.requireNonNull(modifier, "modifier");
45+
Objects.requireNonNull(condition, "condition");
46+
return (ItemAttribute) (Object) new ItemAttributeModifiers.Entry(
47+
SpongeCommon.vanillaRegistry(Registries.ATTRIBUTE).wrapAsHolder((Attribute) type),
48+
(net.minecraft.world.entity.ai.attributes.AttributeModifier) (Object) modifier,
49+
(EquipmentSlotGroup) (Object) condition
50+
);
51+
}
52+
}

src/main/java/org/spongepowered/common/network/PacketUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public static net.minecraft.network.protocol.Packet<?> createLoginPayloadRequest
7575

7676
public static net.minecraft.network.protocol.Packet<?> createPlayPayload(final CustomPacketPayload.Type<? extends CustomPacketPayload> channel, final ChannelBuf payload, final EngineConnectionSide<?> side) {
7777
if (side == EngineConnectionSide.CLIENT) {
78-
return new ServerboundCustomPayloadPacket(SpongeChannelPayload.fromType(channel, (b) -> b.writeBytes((FriendlyByteBuf) payload).slice()));
78+
return new ServerboundCustomPayloadPacket(SpongeChannelPayload.fromType(channel, (b) -> b.writeBytes(((FriendlyByteBuf) payload).slice())));
7979
} else if (side == EngineConnectionSide.SERVER) {
80-
return new ClientboundCustomPayloadPacket(SpongeChannelPayload.fromType(channel, (b) -> b.writeBytes((FriendlyByteBuf) payload).slice()));
80+
return new ClientboundCustomPayloadPacket(SpongeChannelPayload.fromType(channel, (b) -> b.writeBytes(((FriendlyByteBuf) payload).slice())));
8181
} else {
8282
throw new UnsupportedOperationException();
8383
}

0 commit comments

Comments
 (0)