Skip to content

Commit d78a7b3

Browse files
committed
Merge branch 'api-15' into api-16
# Conflicts: # SpongeAPI
2 parents 1a43c70 + e09cc34 commit d78a7b3

File tree

8 files changed

+137
-1
lines changed

8 files changed

+137
-1
lines changed

SpongeAPI

src/main/java/org/spongepowered/common/data/provider/entity/ChickenData.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
*/
2525
package org.spongepowered.common.data.provider.entity;
2626

27+
import net.minecraft.core.registries.Registries;
2728
import net.minecraft.world.entity.animal.Chicken;
2829
import org.spongepowered.api.data.Keys;
30+
import org.spongepowered.api.data.type.ChickenVariant;
2931
import org.spongepowered.common.data.provider.DataProviderRegistrator;
3032
import org.spongepowered.common.util.SpongeTicks;
3133

@@ -47,6 +49,13 @@ public static void register(final DataProviderRegistrator registrator) {
4749
}
4850
h.eggTime = ticks;
4951
return true;
52+
})
53+
.create(Keys.CHICKEN_VARIANT)
54+
.get(h -> (ChickenVariant) (Object) h.getVariant().value())
55+
.set((h, v) -> {
56+
final var holder = h.level().registryAccess().lookupOrThrow(Registries.CHICKEN_VARIANT)
57+
.wrapAsHolder((net.minecraft.world.entity.animal.ChickenVariant) (Object) v);
58+
h.setVariant(holder);
5059
});
5160
}
5261
// @formatter:on
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.data.provider.entity;
26+
27+
import net.minecraft.core.registries.Registries;
28+
import net.minecraft.world.entity.animal.Cow;
29+
import org.spongepowered.api.data.Keys;
30+
import org.spongepowered.api.data.type.CowVariant;
31+
import org.spongepowered.common.data.provider.DataProviderRegistrator;
32+
33+
public final class CowData {
34+
35+
private CowData() {
36+
}
37+
38+
// @formatter:off
39+
public static void register(final DataProviderRegistrator registrator) {
40+
registrator
41+
.asMutable(Cow.class)
42+
.create(Keys.COW_VARIANT)
43+
.get(h -> (CowVariant) (Object) h.getVariant().value())
44+
.set((h, v) -> {
45+
final var holder = h.level().registryAccess().lookupOrThrow(Registries.COW_VARIANT)
46+
.wrapAsHolder((net.minecraft.world.entity.animal.CowVariant) (Object) v);
47+
h.setVariant(holder);
48+
});
49+
}
50+
// @formatter:on
51+
}

src/main/java/org/spongepowered/common/data/provider/entity/EntityDataProviders.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public void registerProviders() {
117117
CatData.register(this.registrator);
118118
ChickenData.register(this.registrator);
119119
CommandBlockMinecartData.register(this.registrator);
120+
CowData.register(this.registrator);
120121
CreakingData.register(this.registrator);
121122
CreeperData.register(this.registrator);
122123
DamagingProjectileData.register(this.registrator);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.mixin.api.minecraft.world.entity.animal;
26+
27+
import net.minecraft.world.entity.animal.ChickenVariant;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
30+
@Mixin(ChickenVariant.class)
31+
public abstract class ChickenVariantMixin_API implements org.spongepowered.api.data.type.ChickenVariant {
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.mixin.api.minecraft.world.entity.animal;
26+
27+
import net.minecraft.world.entity.animal.CowVariant;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
30+
@Mixin(CowVariant.class)
31+
public abstract class CowVariantMixin_API implements org.spongepowered.api.data.type.CowVariant {
32+
}

src/mixins/resources/mixins.sponge.api.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@
151151
"minecraft.world.entity.animal.CatMixin_API",
152152
"minecraft.world.entity.animal.CatVariantMixin_API",
153153
"minecraft.world.entity.animal.ChickenMixin_API",
154+
"minecraft.world.entity.animal.ChickenVariantMixin_API",
154155
"minecraft.world.entity.animal.CodMixin_API",
156+
"minecraft.world.entity.animal.CowVariantMixin_API",
155157
"minecraft.world.entity.animal.DolphinMixin_API",
156158
"minecraft.world.entity.animal.FlyingAnimalMixin_API",
157159
"minecraft.world.entity.animal.Fox_VariantMixin_API",

testplugins/src/main/java/org/spongepowered/test/data/DataTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
import org.spongepowered.api.data.type.BoatTypes;
5252
import org.spongepowered.api.data.type.BodyParts;
5353
import org.spongepowered.api.data.type.CatTypes;
54+
import org.spongepowered.api.data.type.ChickenVariants;
55+
import org.spongepowered.api.data.type.CowVariants;
5456
import org.spongepowered.api.data.type.DyeColors;
5557
import org.spongepowered.api.data.type.FoxTypes;
5658
import org.spongepowered.api.data.type.FrogTypes;
@@ -964,6 +966,13 @@ public void testData(final ServerPlayer player) {
964966
this.checkOfferData(frog, Keys.FROG_TYPE, FrogTypes.WARM.get());
965967
this.checkGetData(frog, Keys.FROG_TYPE, FrogTypes.WARM.get());
966968

969+
this.checkOfferData(chicken, Keys.CHICKEN_VARIANT, ChickenVariants.WARM.get());
970+
this.checkGetData(chicken, Keys.CHICKEN_VARIANT, ChickenVariants.WARM.get());
971+
972+
final Entity cow = world.createEntity(EntityTypes.COW.get(), position);
973+
this.checkOfferData(cow, Keys.COW_VARIANT, CowVariants.WARM.get());
974+
this.checkGetData(cow, Keys.COW_VARIANT, CowVariants.WARM.get());
975+
967976
// this.checkOfferData(panda, Keys.IS_UNHAPPY, true);
968977

969978
this.checkWithData(acaciaStairs, Keys.IS_WATERLOGGED, true);

0 commit comments

Comments
 (0)