Skip to content

Commit

Permalink
Fix frog-release variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakllp committed Dec 29, 2024
1 parent 13ebde9 commit ead8a96
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import de.Keyle.MyPet.api.entity.types.*;
import de.Keyle.MyPet.api.util.Compat;
import de.Keyle.MyPet.api.util.ReflectionUtil;
import de.Keyle.MyPet.compat.v1_20_R4.util.VariantConverter;
import de.Keyle.MyPet.compat.v1_20_R4.util.inventory.ItemStackNBTConverter;
import de.keyle.knbt.*;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -335,7 +336,7 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) {
} else if (myPet instanceof MyFox) {
((Fox) normalEntity).setFoxType(((MyFox) myPet).getFoxType());
}else if (myPet instanceof MyFrog) {
((Frog) normalEntity).setVariant(Frog.Variant.values()[((MyFrog) myPet).getFrogVariant()]);
((Frog) normalEntity).setVariant(VariantConverter.getBukkitFrogVariant(((MyFrog) myPet).getFrogVariant()));
}

if (myPet instanceof MyPetBaby && normalEntity instanceof Ageable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.CatVariant;
import net.minecraft.world.entity.animal.FrogVariant;
import org.bukkit.entity.Frog;

/**
* Converts numerical variants into fancy new variants
Expand All @@ -28,13 +29,15 @@ private static enum CatVariants {
}

private static enum FrogVariants {
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE)),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM)),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD));
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE), Frog.Variant.TEMPERATE),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM), Frog.Variant.WARM),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD), Frog.Variant.COLD);

FrogVariant variant;
FrogVariants(FrogVariant fV) {
Frog.Variant bukkitVariant;
FrogVariants(FrogVariant fV, Frog.Variant fV2) {
this.variant = fV;
this.bukkitVariant = fV2;
}
}

Expand All @@ -45,4 +48,7 @@ public static CatVariant convertCatVariant(int varId) {
public static FrogVariant convertFrogVariant(int varId) {
return FrogVariants.values()[varId].variant;
}
public static Frog.Variant getBukkitFrogVariant(int varId) {
return FrogVariants.values()[varId].bukkitVariant;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import de.Keyle.MyPet.api.entity.types.*;
import de.Keyle.MyPet.api.util.Compat;
import de.Keyle.MyPet.api.util.ReflectionUtil;
import de.Keyle.MyPet.compat.v1_21_R1.util.VariantConverter;
import de.Keyle.MyPet.compat.v1_21_R1.util.inventory.ItemStackNBTConverter;
import de.keyle.knbt.*;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -334,7 +335,7 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) {
} else if (myPet instanceof MyFox) {
((Fox) normalEntity).setFoxType(((MyFox) myPet).getFoxType());
}else if (myPet instanceof MyFrog) {
((Frog) normalEntity).setVariant(Frog.Variant.values()[((MyFrog) myPet).getFrogVariant()]);
((Frog) normalEntity).setVariant(VariantConverter.getBukkitFrogVariant(((MyFrog) myPet).getFrogVariant()));
}else if (myPet instanceof MyWolf) {
Method getVariant = ReflectionUtil.getMethod(Wolf.Variant.class, "getVariant", String.class);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.CatVariant;
import net.minecraft.world.entity.animal.FrogVariant;
import org.bukkit.entity.Frog;

/**
* Converts numerical variants into fancy new variants
Expand All @@ -28,13 +29,15 @@ private static enum CatVariants {
}

private static enum FrogVariants {
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE)),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM)),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD));
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE), Frog.Variant.TEMPERATE),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM), Frog.Variant.WARM),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD), Frog.Variant.COLD);

FrogVariant variant;
FrogVariants(FrogVariant fV) {
Frog.Variant bukkitVariant;
FrogVariants(FrogVariant fV, Frog.Variant fV2) {
this.variant = fV;
this.bukkitVariant = fV2;
}
}

Expand All @@ -45,4 +48,7 @@ public static CatVariant convertCatVariant(int varId) {
public static FrogVariant convertFrogVariant(int varId) {
return FrogVariants.values()[varId].variant;
}
public static Frog.Variant getBukkitFrogVariant(int varId) {
return FrogVariants.values()[varId].bukkitVariant;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import de.Keyle.MyPet.api.entity.types.*;
import de.Keyle.MyPet.api.util.Compat;
import de.Keyle.MyPet.api.util.ReflectionUtil;
import de.Keyle.MyPet.compat.v1_21_R2.util.VariantConverter;
import de.Keyle.MyPet.compat.v1_21_R2.util.inventory.ItemStackNBTConverter;
import de.keyle.knbt.*;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -334,7 +335,7 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) {
} else if (myPet instanceof MyFox) {
((Fox) normalEntity).setFoxType(((MyFox) myPet).getFoxType());
}else if (myPet instanceof MyFrog) {
((Frog) normalEntity).setVariant(Frog.Variant.values()[((MyFrog) myPet).getFrogVariant()]);
((Frog) normalEntity).setVariant(VariantConverter.getBukkitFrogVariant(((MyFrog) myPet).getFrogVariant()));
}else if (myPet instanceof MyWolf) {
Method getVariant = ReflectionUtil.getMethod(Wolf.Variant.class, "getVariant", String.class);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.CatVariant;
import net.minecraft.world.entity.animal.FrogVariant;
import org.bukkit.entity.Frog;

/**
* Converts numerical variants into fancy new variants
Expand All @@ -28,13 +29,15 @@ private static enum CatVariants {
}

private static enum FrogVariants {
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE).value()),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM).value()),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD).value());
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE).value(), Frog.Variant.TEMPERATE),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM).value(), Frog.Variant.WARM),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD).value(), Frog.Variant.COLD);

FrogVariant variant;
FrogVariants(FrogVariant fV) {
Frog.Variant bukkitVariant;
FrogVariants(FrogVariant fV, Frog.Variant fV2) {
this.variant = fV;
this.bukkitVariant = fV2;
}
}

Expand All @@ -45,4 +48,7 @@ public static CatVariant convertCatVariant(int varId) {
public static FrogVariant convertFrogVariant(int varId) {
return FrogVariants.values()[varId].variant;
}
public static Frog.Variant getBukkitFrogVariant(int varId) {
return FrogVariants.values()[varId].bukkitVariant;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import de.Keyle.MyPet.api.entity.types.*;
import de.Keyle.MyPet.api.util.Compat;
import de.Keyle.MyPet.api.util.ReflectionUtil;
import de.Keyle.MyPet.compat.v1_21_R3.util.VariantConverter;
import de.Keyle.MyPet.compat.v1_21_R3.util.inventory.ItemStackNBTConverter;
import de.keyle.knbt.*;
import net.minecraft.core.registries.BuiltInRegistries;
Expand Down Expand Up @@ -334,7 +335,7 @@ public void convertEntity(MyPet myPet, LivingEntity normalEntity) {
} else if (myPet instanceof MyFox) {
((Fox) normalEntity).setFoxType(((MyFox) myPet).getFoxType());
}else if (myPet instanceof MyFrog) {
((Frog) normalEntity).setVariant(Frog.Variant.values()[((MyFrog) myPet).getFrogVariant()]);
((Frog) normalEntity).setVariant(VariantConverter.getBukkitFrogVariant(((MyFrog) myPet).getFrogVariant()));
}else if (myPet instanceof MyWolf) {
Method getVariant = ReflectionUtil.getMethod(Wolf.Variant.class, "getVariant", String.class);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.animal.CatVariant;
import net.minecraft.world.entity.animal.FrogVariant;
import org.bukkit.entity.Frog;

/**
* Converts numerical variants into fancy new variants
Expand All @@ -28,13 +29,15 @@ private static enum CatVariants {
}

private static enum FrogVariants {
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE).value()),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM).value()),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD).value());
TEMPERATE(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.TEMPERATE).value(), Frog.Variant.TEMPERATE),
WARM(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.WARM).value(), Frog.Variant.WARM),
COLD(BuiltInRegistries.FROG_VARIANT.getOrThrow(FrogVariant.COLD).value(), Frog.Variant.COLD);

FrogVariant variant;
FrogVariants(FrogVariant fV) {
Frog.Variant bukkitVariant;
FrogVariants(FrogVariant fV, Frog.Variant fV2) {
this.variant = fV;
this.bukkitVariant = fV2;
}
}

Expand All @@ -45,4 +48,7 @@ public static CatVariant convertCatVariant(int varId) {
public static FrogVariant convertFrogVariant(int varId) {
return FrogVariants.values()[varId].variant;
}
public static Frog.Variant getBukkitFrogVariant(int varId) {
return FrogVariants.values()[varId].bukkitVariant;
}
}

0 comments on commit ead8a96

Please sign in to comment.