Skip to content

Commit

Permalink
Implement frog type key
Browse files Browse the repository at this point in the history
  • Loading branch information
aromaa committed Oct 23, 2024
1 parent 51ba905 commit f402974
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SpongeAPI
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void registerProviders() {
FireworkRocketData.register(this.registrator);
FishingBobberData.register(this.registrator);
FoxData.register(this.registrator);
FrogData.register(this.registrator);
FurnaceMinecartData.register(this.registrator);
FusedExplosiveData.register(this.registrator);
GrieferData.register(this.registrator);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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.common.data.provider.entity;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.FrogVariant;
import net.minecraft.world.entity.animal.frog.Frog;
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.type.FrogType;
import org.spongepowered.common.data.provider.DataProviderRegistrator;

public final class FrogData {

private FrogData() {
}

// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator
.asMutable(Frog.class)
.create(Keys.FROG_TYPE)
.get(h -> (FrogType) (Object) h.getVariant().value())
.set((h, v) -> h.setVariant(BuiltInRegistries.FROG_VARIANT.wrapAsHolder((FrogVariant) (Object) v)));
}
// @formatter:on
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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.common.mixin.api.minecraft.world.entity.animal;

import net.minecraft.world.entity.animal.FrogVariant;
import org.spongepowered.api.data.type.FrogType;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(FrogVariant.class)
public abstract class FrogVariantMixin_API implements FrogType {
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.spongepowered.common.mixin.api.minecraft.world.entity.animal.frog;

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.living.animal.frog.Frog;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -38,6 +39,8 @@ public abstract class FrogMixin_API extends AnimalMixin_API implements Frog {
protected Set<Value.Immutable<?>> api$getVanillaValues() {
final Set<Value.Immutable<?>> values = super.api$getVanillaValues();

values.add(this.requireValue(Keys.FROG_TYPE).asImmutable());

return values;
}

Expand Down
1 change: 1 addition & 0 deletions src/mixins/resources/mixins.sponge.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@
"minecraft.world.entity.animal.FlyingAnimalMixin_API",
"minecraft.world.entity.animal.Fox_TypeMixin_API",
"minecraft.world.entity.animal.FoxMixin_API",
"minecraft.world.entity.animal.FrogVariantMixin_API",
"minecraft.world.entity.animal.IronGolemMixin_API",
"minecraft.world.entity.animal.MushroomCow_MushroomTypeMixin_API",
"minecraft.world.entity.animal.MushroomCowMixin_API",
Expand Down

0 comments on commit f402974

Please sign in to comment.