diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2125666 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto \ No newline at end of file diff --git a/build.gradle b/build.gradle index a127a2b..444b55f 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,9 @@ repositories { maven { url = "https://api.modrinth.com/maven" } + maven { + url = "https://maven.bawnorton.com/releases" + } } fabricApi { @@ -30,10 +33,12 @@ dependencies { modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - + modImplementation "maven.modrinth:mavapi:${project.mavapi_version}" modImplementation "maven.modrinth:midnightlib:${project.midnightlib_version}" + include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.2.0"))) include(modImplementation "maven.modrinth:modmenu-badges-lib:${badges_lib}") + } processResources { diff --git a/gradle.properties b/gradle.properties index 640600c..973e175 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,5 @@ archives_base_name = joymod fabric_version=0.104.0+1.21.1 midnightlib_version=1.5.7-fabric +mavapi_version=1.2.1 badges_lib=2023.6.1 diff --git a/src/main/java/gay/pridecraft/joy/Joy.java b/src/main/java/gay/pridecraft/joy/Joy.java index fb9c619..42c3148 100644 --- a/src/main/java/gay/pridecraft/joy/Joy.java +++ b/src/main/java/gay/pridecraft/joy/Joy.java @@ -24,7 +24,7 @@ public class Joy implements ModInitializer { ModItemGroups.registerItemGroups(); ModItems.registerModItems(); ModBlocks.registerModBlocks(); - ModEntities.registerBlockEntities(); + ModEntities.registerEntities(); ModSoundEvents.registerModSoundEvents(); // this is now has to be done in a mixin. @@ -63,9 +63,6 @@ public class Joy implements ModInitializer { .add(EntityAttributes.GENERIC_FLYING_SPEED, 0.6) .add(EntityAttributes.GENERIC_FOLLOW_RANGE, 48.0)); - FabricDefaultAttributeRegistry.register(ModEntities.AXOLOTL, MobEntity.createMobAttributes() - .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 2.0) - .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 1.0)); FabricDefaultAttributeRegistry.register(ModEntities.FROG, MobEntity.createMobAttributes() .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 10.0) diff --git a/src/main/java/gay/pridecraft/joy/JoyClient.java b/src/main/java/gay/pridecraft/joy/JoyClient.java index b6b68c3..121ab9b 100644 --- a/src/main/java/gay/pridecraft/joy/JoyClient.java +++ b/src/main/java/gay/pridecraft/joy/JoyClient.java @@ -59,7 +59,6 @@ public class JoyClient implements ClientModInitializer { EntityRendererRegistry.register(ModEntities.ENBEE, EnbeeRenderer::new); EntityRendererRegistry.register(ModEntities.TRANS_BEE, TransBeeRenderer::new); EntityRendererRegistry.register(ModEntities.TREE, TreeRenderer::new); - EntityRendererRegistry.register(ModEntities.AXOLOTL, AxolotlRenderer::new); EntityRendererRegistry.register(ModEntities.FROG, FrogRenderer::new); EntityRendererRegistry.register(ModEntities.SNIFFER, SnifferRenderer::new); } diff --git a/src/main/java/gay/pridecraft/joy/datagen/ModModelProvider.java b/src/main/java/gay/pridecraft/joy/datagen/ModModelProvider.java index b936883..10ca711 100644 --- a/src/main/java/gay/pridecraft/joy/datagen/ModModelProvider.java +++ b/src/main/java/gay/pridecraft/joy/datagen/ModModelProvider.java @@ -43,7 +43,6 @@ public class ModModelProvider extends FabricModelProvider { itemModelGenerator.register(ModItems.BII_SPAWN_EGG, Models.GENERATED); itemModelGenerator.register(ModItems.ENBEE_SPAWN_EGG, Models.GENERATED); itemModelGenerator.register(ModItems.TRANS_BEE_SPAWN_EGG, Models.GENERATED); - itemModelGenerator.register(ModItems.AXOLOTL_SPAWN_EGG, Models.GENERATED); itemModelGenerator.register(ModItems.FROG_SPAWN_EGG, Models.GENERATED); itemModelGenerator.register(ModItems.SNIFFER_SPAWN_EGG, Models.GENERATED); itemModelGenerator.register(ModItems.TEST_DISC, Models.GENERATED); diff --git a/src/main/java/gay/pridecraft/joy/entity/ModAxolotlVariants.java b/src/main/java/gay/pridecraft/joy/entity/ModAxolotlVariants.java new file mode 100644 index 0000000..a25c5f2 --- /dev/null +++ b/src/main/java/gay/pridecraft/joy/entity/ModAxolotlVariants.java @@ -0,0 +1,32 @@ +package gay.pridecraft.joy.entity; + +import gay.pridecraft.joy.Joy; +import io.github.akashiikun.mavapi.v1.api.ModdedAxolotlVariant; +import net.minecraft.util.Identifier; + +public class ModAxolotlVariants { + public static void registerAxolotlVariants() { + Joy.LOGGER.info("Registering Axolotl Variants for {} via MoreAxolotlVariantsAPI", Joy.MOD_ID); + register("bi"); + register("ace"); + register("aro"); + register("lesbian"); + register("mlm"); + register("progress"); + register("trans"); + register("aroace"); + + } + + private static void register(String name) { + register(name, true); + } + + private static void register(String name, boolean natural) { + ModdedAxolotlVariant.Builder builder = ModdedAxolotlVariant.register(Identifier.of(Joy.MOD_ID, name)); + if (natural) { + builder.natural(); + } + builder.build(); + } +} diff --git a/src/main/java/gay/pridecraft/joy/entity/ModEntities.java b/src/main/java/gay/pridecraft/joy/entity/ModEntities.java index 77a692c..f9c39de 100644 --- a/src/main/java/gay/pridecraft/joy/entity/ModEntities.java +++ b/src/main/java/gay/pridecraft/joy/entity/ModEntities.java @@ -79,15 +79,6 @@ public class ModEntities { .build() ); - public static final EntityType AXOLOTL = Registry.register( - Registries.ENTITY_TYPE, - Identifier.of(Joy.MOD_ID, "axolotl"), - EntityType.Builder.create(CustomAxolotlEntity.AxolotlEntity::new, EntityType.AXOLOTL.getSpawnGroup()) - .dimensions(0.75F, 0.42F) - .maxTrackingRange(10) - .build() - ); - public static final EntityType FROG = Registry.register( Registries.ENTITY_TYPE, Identifier.of(Joy.MOD_ID, "frog"), @@ -107,7 +98,8 @@ public class ModEntities { .build() ); - public static void registerBlockEntities() { + public static void registerEntities() { Joy.LOGGER.info("Registering Entities for " + Joy.MOD_ID); + ModAxolotlVariants.registerAxolotlVariants(); } } \ No newline at end of file diff --git a/src/main/java/gay/pridecraft/joy/entity/custom/living/CustomAxolotlEntity.java b/src/main/java/gay/pridecraft/joy/entity/custom/living/CustomAxolotlEntity.java deleted file mode 100644 index 9f155ea..0000000 --- a/src/main/java/gay/pridecraft/joy/entity/custom/living/CustomAxolotlEntity.java +++ /dev/null @@ -1,17 +0,0 @@ -package gay.pridecraft.joy.entity.custom.living; - -import net.minecraft.entity.EntityType; -import net.minecraft.entity.passive.AxolotlEntity; -import net.minecraft.world.World; - -public class CustomAxolotlEntity extends AxolotlEntity { - public CustomAxolotlEntity(EntityType entityType, World world) { - super(entityType, world); - } - - public static class AxolotlEntity extends CustomAxolotlEntity { - public AxolotlEntity(EntityType entityType, World world) { - super(entityType, world); - } - } -} diff --git a/src/main/java/gay/pridecraft/joy/item/ModItemGroups.java b/src/main/java/gay/pridecraft/joy/item/ModItemGroups.java index 37a8dfe..95d7602 100644 --- a/src/main/java/gay/pridecraft/joy/item/ModItemGroups.java +++ b/src/main/java/gay/pridecraft/joy/item/ModItemGroups.java @@ -67,7 +67,6 @@ public class ModItemGroups { entries.add(ModItems.ENBEE_SPAWN_EGG); entries.add(ModItems.TRANS_BEE_SPAWN_EGG); entries.add(ModItems.TREE_SPAWN_EGG); - entries.add(ModItems.AXOLOTL_SPAWN_EGG); entries.add(ModItems.FROG_SPAWN_EGG); entries.add(ModItems.SNIFFER_SPAWN_EGG); diff --git a/src/main/java/gay/pridecraft/joy/item/ModItems.java b/src/main/java/gay/pridecraft/joy/item/ModItems.java index 5794a3f..02e9a42 100644 --- a/src/main/java/gay/pridecraft/joy/item/ModItems.java +++ b/src/main/java/gay/pridecraft/joy/item/ModItems.java @@ -28,7 +28,6 @@ public class ModItems { public static final Item ENBEE_SPAWN_EGG = registerItem("enbee_spawn_egg", new CustomSpawnEggItem(ModEntities.ENBEE, 16577588, 0x9C59D1, new Item.Settings())); public static final Item TRANS_BEE_SPAWN_EGG = registerItem("trans_bee_spawn_egg", new CustomSpawnEggItem(ModEntities.TRANS_BEE, 49963900, 0x48B518, new Item.Settings())); public static final Item TREE_SPAWN_EGG = registerItem("tree_spawn_egg", new CustomSpawnEggItem(ModEntities.TREE, 16577588, 0x9C59D1, new Item.Settings())); - public static final Item AXOLOTL_SPAWN_EGG = registerItem("axolotl_spawn_egg", new CustomSpawnEggItem(ModEntities.AXOLOTL, 16499171, 0xff80bf, new Item.Settings())); public static final Item FROG_SPAWN_EGG = registerItem("frog_spawn_egg", new CustomSpawnEggItem(ModEntities.FROG, 13661252, 0xff80bf, new Item.Settings())); public static final Item SNIFFER_SPAWN_EGG = registerItem("sniffer_spawn_egg", new CustomSpawnEggItem(ModEntities.SNIFFER, 8855049, 0xff80bf, new Item.Settings())); // Test disc item that can be used as template in case someone wants to create one. Note: it's not added to any item group, only obtainable via commands. diff --git a/src/main/java/gay/pridecraft/joy/mixin/fix/JoyMixinCanceller.java b/src/main/java/gay/pridecraft/joy/mixin/fix/JoyMixinCanceller.java new file mode 100644 index 0000000..650c3b5 --- /dev/null +++ b/src/main/java/gay/pridecraft/joy/mixin/fix/JoyMixinCanceller.java @@ -0,0 +1,13 @@ +package gay.pridecraft.joy.mixin.fix; + +import com.bawnorton.mixinsquared.api.MixinCanceller; + +import java.util.List; + +public class JoyMixinCanceller implements MixinCanceller { + + @Override + public boolean shouldCancel(List targetClassNames, String mixinClassName) { + return mixinClassName.equals("io.github.akashiikun.mavapi.v1.mixin.MobBucketItemMixin"); + } +} \ No newline at end of file diff --git a/src/main/java/gay/pridecraft/joy/mixin/fix/mavapi/EntityBucketItemMixin.java b/src/main/java/gay/pridecraft/joy/mixin/fix/mavapi/EntityBucketItemMixin.java new file mode 100644 index 0000000..e46e803 --- /dev/null +++ b/src/main/java/gay/pridecraft/joy/mixin/fix/mavapi/EntityBucketItemMixin.java @@ -0,0 +1,117 @@ +/* + * Based on: https://github.com/AkashiiKun/MoreAxolotlVariantsAPI-Common/blob/c692a509be0bab64b9a6087f6eed090409d98a27/Common/src/main/java/io/github/akashiikun/mavapi/v1/mixin/MobBucketItemMixin.java + * Original Author KxmischesDomi | https://github.com/kxmischesdomi + * Translated into Yarn mappings and modified by rotgruengelb + * + * Provided originally by Akashii and KxmischesDomi under the MIT license: + * + * The MIT License (MIT) + * + * Copyright (c) 2021 - 2024 Akashii, 2023 - 2024 KxmischesDomi + * + * 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 gay.pridecraft.joy.mixin.fix.mavapi; + +import io.github.akashiikun.mavapi.v1.impl.AxolotlTypeExtension; +import io.github.akashiikun.mavapi.v1.impl.MoreAxolotlVariant; +import net.minecraft.client.resource.language.I18n; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.AxolotlEntity; +import net.minecraft.item.EntityBucketItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipType; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtElement; +import net.minecraft.text.MutableText; +import net.minecraft.text.Style; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.List; +import java.util.Locale; + +/** + * Based on: ... + * Original Author KxmischesDomi ... + * Translated into Yarn mappings and modified by rotgruengelb
+ * Provided originally by Akashii and KxmischesDomi under the MIT license see Top of file for + * more information. + */ +@Mixin(EntityBucketItem.class) +public abstract class EntityBucketItemMixin { + @Shadow private EntityType entityType; + + @Inject(method = "appendTooltip", at = @At(value = "HEAD")) + public void appendTooltip(ItemStack itemStack, Item.TooltipContext tooltipContext, List list, TooltipType tooltipFlag, CallbackInfo ci) { + if (entityType == EntityType.AXOLOTL) { + NbtCompound nbtCompound = itemStack.get(DataComponentTypes.BUCKET_ENTITY_DATA) + .copyNbt(); + if (nbtCompound != null && nbtCompound.contains(AxolotlEntity.VARIANT_KEY, NbtElement.STRING_TYPE)) { + String variantIdentifier = nbtCompound.getString(AxolotlEntity.VARIANT_KEY); + + for (AxolotlEntity.Variant variant : AxolotlEntity.Variant.values()) { + + MoreAxolotlVariant metadata = ((AxolotlTypeExtension) (Object) variant).mavapi$metadata(); + + Identifier id = metadata.getId(); + if (id.equals(Identifier.of(variantIdentifier))) { + + int age = nbtCompound.getInt("Age"); + + MutableText component = Text.translatable("mavapi.bucket.format", age < 0 ? Text.translatable("mavapi.bucket.translation.baby") : Text.translatable("mavapi.bucket.translation.adult"), translateOrFormat(String.format("mavapi.variant.%s.%s", id.getNamespace(), id.getPath()), id.getPath()), translateOrFormat(String.format("mavapi.mod.%s", id.getNamespace()), id.getNamespace())); + component.setStyle(Style.EMPTY.withColor(Formatting.GRAY)); + list.add(component); + break; + } + } + + } + } + } + + private MutableText translateOrFormat(String translation, String toFormat) { + try { + MutableText component = Text.translatable(translation); + if (!I18n.hasTranslation(translation)) { + component = Text.literal(formatName(toFormat)); + } + return component; + } catch (Exception e) { + return Text.literal("Error in gay.pridecraft.joy.mixin.fix.mavapi.EntityBucketItemMixin#translateOrFormat"); + } + } + + private String formatName(String s) { + s = s.replace("_", " "); + s = String.valueOf(s.charAt(0)) + .toUpperCase(Locale.ROOT) + s.substring(1); + return s; + } + +} \ No newline at end of file diff --git a/src/main/java/gay/pridecraft/joy/renderer/entity/AxolotlRenderer.java b/src/main/java/gay/pridecraft/joy/renderer/entity/AxolotlRenderer.java deleted file mode 100644 index 64828c0..0000000 --- a/src/main/java/gay/pridecraft/joy/renderer/entity/AxolotlRenderer.java +++ /dev/null @@ -1,38 +0,0 @@ -package gay.pridecraft.joy.renderer.entity; - -import gay.pridecraft.joy.Joy; -import gay.pridecraft.joy.entity.custom.living.CustomAxolotlEntity; -import gay.pridecraft.joy.renderer.model.AxolotlEntityModel; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.render.entity.EntityRendererFactory; -import net.minecraft.client.render.entity.MobEntityRenderer; -import net.minecraft.client.render.entity.model.EntityModelLayers; -import net.minecraft.entity.passive.AxolotlEntity; -import net.minecraft.util.Identifier; - -import java.util.HashMap; -import java.util.Map; - -@Environment(EnvType.CLIENT) -public class AxolotlRenderer extends MobEntityRenderer> { - private static final Map TEXTURES = new HashMap<>(); - - static { - TEXTURES.put(net.minecraft.entity.passive.AxolotlEntity.Variant.BLUE, Identifier.of(Joy.MOD_ID, "textures/entity/axolotl/axolotl_blue.png")); - TEXTURES.put(net.minecraft.entity.passive.AxolotlEntity.Variant.GOLD, Identifier.of(Joy.MOD_ID, "textures/entity/axolotl/axolotl_gold.png")); - TEXTURES.put(net.minecraft.entity.passive.AxolotlEntity.Variant.CYAN, Identifier.of(Joy.MOD_ID, "textures/entity/axolotl/axolotl_cyan.png")); - TEXTURES.put(net.minecraft.entity.passive.AxolotlEntity.Variant.LUCY, Identifier.of(Joy.MOD_ID, "textures/entity/axolotl/axolotl_lucy.png")); - TEXTURES.put(net.minecraft.entity.passive.AxolotlEntity.Variant.WILD, Identifier.of(Joy.MOD_ID, "textures/entity/axolotl/axolotl_wild.png")); - } - - public AxolotlRenderer(EntityRendererFactory.Context context) { - super(context, new AxolotlEntityModel<>(context.getPart(EntityModelLayers.AXOLOTL)), 0.5F); - } - - @Override - public Identifier getTexture(CustomAxolotlEntity.AxolotlEntity entity) { - AxolotlEntity.Variant variant = entity.getVariant(); - return TEXTURES.get(variant); - } -} diff --git a/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_wild.png b/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_aroace.png similarity index 100% rename from src/main/resources/assets/joy/textures/entity/axolotl/axolotl_wild.png rename to src/main/resources/assets/joy/textures/entity/axolotl/axolotl_aroace.png diff --git a/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_cyan.png b/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_lesbian.png similarity index 100% rename from src/main/resources/assets/joy/textures/entity/axolotl/axolotl_cyan.png rename to src/main/resources/assets/joy/textures/entity/axolotl/axolotl_lesbian.png diff --git a/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_blue.png b/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_mlm.png similarity index 100% rename from src/main/resources/assets/joy/textures/entity/axolotl/axolotl_blue.png rename to src/main/resources/assets/joy/textures/entity/axolotl/axolotl_mlm.png diff --git a/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_gold.png b/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_progress.png similarity index 100% rename from src/main/resources/assets/joy/textures/entity/axolotl/axolotl_gold.png rename to src/main/resources/assets/joy/textures/entity/axolotl/axolotl_progress.png diff --git a/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_lucy.png b/src/main/resources/assets/joy/textures/entity/axolotl/axolotl_trans.png similarity index 100% rename from src/main/resources/assets/joy/textures/entity/axolotl/axolotl_lucy.png rename to src/main/resources/assets/joy/textures/entity/axolotl/axolotl_trans.png diff --git a/src/main/resources/assets/minecraft/texts/credits.json b/src/main/resources/assets/minecraft/texts/credits.json index eed17ff..2adb8a3 100644 --- a/src/main/resources/assets/minecraft/texts/credits.json +++ b/src/main/resources/assets/minecraft/texts/credits.json @@ -8835,6 +8835,7 @@ "Ampflower", "Blurryface", "KTrain", + "rotgruengelb", "Santiago 'Zhamty' Navas", "TheClashFruit", "Wolren" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index af19d09..2704c0c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "Joy", "description": "This is an LGBT pride mod made by Pridecraft Studios.", "authors": [ - "Pridecraft Studios", "Wolren", "Blurryface", "Sake", "Ampflower", "UnlikePaladin", "TheClashFruit", "WorldWidePixel" + "Pridecraft Studios", "Wolren", "Blurryface", "Sake", "Ampflower", "UnlikePaladin", "TheClashFruit", "WorldWidePixel", "rotgruengelb" ], "contact": { "homepage": "https://pridecraft.gay/", @@ -23,6 +23,9 @@ ], "main": [ "gay.pridecraft.joy.Joy" + ], + "mixinsquared": [ + "gay.pridecraft.joy.mixin.fix.JoyMixinCanceller" ] }, "mixins": [ @@ -33,6 +36,7 @@ "minecraft": "${minecraft_version}", "java": ">=17", "fabric-api": "*", - "midnightlib": ">=1.5.3-fabric" + "midnightlib": ">=1.5.3-fabric", + "mavapi": ">=1.2.1" } } diff --git a/src/main/resources/joy.mixins.json b/src/main/resources/joy.mixins.json index d5b3d94..a668e53 100644 --- a/src/main/resources/joy.mixins.json +++ b/src/main/resources/joy.mixins.json @@ -9,7 +9,8 @@ ], "client": [ "ClientPlayNetworkHandlerMixin", - "SplashTextResourceSupplierMixin" + "SplashTextResourceSupplierMixin", + "fix.mavapi.EntityBucketItemMixin" ], "injectors": { "defaultRequire": 1