From 7983fc6e08164ee7ab0d98770370ccd9198b798f Mon Sep 17 00:00:00 2001 From: unilock Date: Wed, 28 Feb 2024 08:42:38 -0500 Subject: [PATCH] fixes? Signed-off-by: unilock --- build.gradle | 42 +++++++++++----- gradle.properties | 6 +-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../client/RatsMischiefClient.java | 4 +- .../client/RatsMischiefClientHelper.java | 2 +- .../client/model/RatEntityModel.java | 4 +- .../client/model/RatItemModel.java | 6 +-- .../entity/EnderEyeFeatureRenderer.java | 2 +- .../entity/PartyHatFeatureRenderer.java | 2 +- .../item/RatMasterMaskItemRenderer.java | 11 +++-- .../item/recipe/SpyRatCraftingRecipe.java | 2 +- .../ratsmischief/common/RatsMischief.java | 10 ++-- .../common/RatsMischiefUtils.java | 4 +- .../ratsmischief/common/entity/RatEntity.java | 49 +++++++++---------- .../common/entity/ai/BreedGoal.java | 4 +- .../common/entity/ai/FollowOwnerRatGoal.java | 4 +- .../entity/ai/HarvestPlantMealGoal.java | 19 +++---- .../common/entity/ai/RatMeleeAttackGoal.java | 2 +- .../ratsmischief/common/init/ModBlocks.java | 2 +- .../common/init/ModDamageTypes.java | 6 +-- .../common/init/ModEnchantments.java | 2 +- .../ratsmischief/common/init/ModEntities.java | 2 +- .../common/init/ModItemGroup.java | 2 +- .../ratsmischief/common/init/ModItems.java | 2 +- .../common/init/ModLootTables.java | 4 +- .../common/init/ModSoundEvents.java | 2 +- .../common/init/ModStatusEffects.java | 2 +- .../ratsmischief/common/init/ModTags.java | 15 ++++++ .../ratsmischief/common/item/RatItem.java | 4 +- .../common/item/RatMasterArmorItem.java | 13 ++++- .../common/item/RatMasterMaskItem.java | 19 +++---- .../common/item/RatPouchItem.java | 6 +-- .../common/util/PlayerRatOwner.java | 4 +- .../ratsmischief/common/world/RatSpawner.java | 1 - .../mialeemisc/util/MialeeText.java | 2 +- .../mixin/FollowTargetGoalMixin.java | 2 +- .../ratsmischief/mixin/PlayerEntityMixin.java | 4 +- .../mixin/ScreenHandlerMixin.java | 5 +- .../mixin/SculkSensorBlockEntityMixin.java | 2 +- .../mixin/SculkShriekerBlockEntityMixin.java | 2 +- .../ratsmischief/mixin/WardenEntityMixin.java | 2 +- .../client/HeadFeatureRendererMixin.java | 3 +- .../mialeemisc/client/ItemRendererMixin.java | 34 ------------- .../ratsmischief/tags/items/rat_pouches.json | 9 ++++ src/main/resources/ratsmischief.mixins.json | 1 - 45 files changed, 172 insertions(+), 155 deletions(-) create mode 100644 src/main/java/ladysnake/ratsmischief/common/init/ModTags.java delete mode 100644 src/main/java/ladysnake/ratsmischief/mixin/mialeemisc/client/ItemRendererMixin.java create mode 100644 src/main/resources/data/ratsmischief/tags/items/rat_pouches.json diff --git a/build.gradle b/build.gradle index 62dbc5b..59ca3cb 100644 --- a/build.gradle +++ b/build.gradle @@ -7,18 +7,28 @@ archivesBaseName = project.archives_base_name version = project.version group = project.maven_group +loom { + mods { + "ratsmischief" { + sourceSet sourceSets.main + } + } +} + repositories { + mavenLocal() + // CCA, Requiem chenille.repositories.ladysnake() // Mod Menu - maven { url 'https://maven.terraformersmc.com/'} + maven { url = "https://maven.terraformersmc.com/" } // GeckoLib - maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' } + maven { url = "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/" } // MialeeMisc - maven { url 'https://maven.willbl.dev/releases/' } + maven { url = "https://maven.willbl.dev/releases/" } // Publishing maven { @@ -31,32 +41,39 @@ repositories { } mavenCentral() - maven { url 'https://jitpack.io' } - mavenLocal() + maven { url = "https://jitpack.io" } } dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2" - modImplementation "software.bernie.geckolib:${project.geckolib_version}" - modImplementation "org.quiltmc:quilt-loader:${project.loader_version}" modImplementation "org.quiltmc:qsl:${qsl_version}+${minecraft_version}" modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}-${minecraft_version}" + modImplementation("software.bernie.geckolib:${project.geckolib_version}") { + exclude group: 'net.fabricmc' + exclude group: 'net.fabricmc.fabric-api' + } + // SHEA - modImplementation include("com.github.emilyploszaj:step-height-entity-attribute:${project.shea_version}") + modImplementation include("com.github.emilyploszaj:step-height-entity-attribute:${project.shea_version}") { + exclude group: 'net.fabricmc' + exclude group: 'net.fabricmc.fabric-api' + } // Mod Menu - modLocalImplementation("com.terraformersmc:modmenu:${mod_menu_version}") { transitive = false } + modLocalRuntime("com.terraformersmc:modmenu:${mod_menu_version}") { + transitive = false + } // MialeeMisc //modImplementation include("xyz.amymialee:mialeemisc:${project.mialeemisc_version}") // CCA - modImplementation include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}") + //modCompileOnly include("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cca_version}") // Requiem //modCompileOnly("io.github.ladysnake:PlayerAbilityLib:${project.pal_version}") @@ -65,7 +82,10 @@ dependencies { //modImplementation include("io.github.ladysnake:requiem-lite:${project.requiem_version}") // Trinkets - modImplementation ("dev.emi:trinkets:${project.trinkets_version}") + modImplementation("dev.emi:trinkets:${project.trinkets_version}") { + exclude group: 'net.fabricmc' + exclude group: 'net.fabricmc.fabric-api' + } } chenille { diff --git a/gradle.properties b/gradle.properties index a869966..da44b7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,18 +10,18 @@ archives_base_name = ratsmischief minecraft_version = 1.20.1 quilt_mappings = 23 -loader_version = 0.23.0 +loader_version = 0.24.0-beta.8 # QSL qsl_version = 6.1.2 # Quilted Fabric API -quilted_fabric_api_version = 7.4.0+0.90.0 +quilted_fabric_api_version = 7.5.0+0.91.0 #Mod Depencencies mod_menu_version = 7.2.2 cca_version = 5.2.2 -geckolib_version = geckolib-fabric-1.20.1:4.3.1 +geckolib_version = geckolib-fabric-1.20.1:4.4.2 mialeemisc_version = 1.0.38 pal_version = 1.8.0 shea_version = v1.2.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3499ded..509c4a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClient.java b/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClient.java index c958c83..ac95933 100644 --- a/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClient.java +++ b/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClient.java @@ -49,11 +49,11 @@ public void onInitializeClient(ModContainer mod) { BuiltinItemRendererRegistry.INSTANCE.register(ModItems.RAT_MASTER_MASK, inventoryItemRenderer); ModelLoadingPlugin.register(pluginContext -> { pluginContext.addModels(new ModelIdentifier(itemId, "inventory")); - pluginContext.addModels(new ModelIdentifier(new Identifier(itemId + "_worn"), "inventory")); + pluginContext.addModels(new ModelIdentifier(new Identifier(itemId.getNamespace(), itemId.getPath() + "_worn"), "inventory")); }); // model predicates - ModelPredicateProviderRegistry.register(new Identifier(RatsMischief.MOD_ID + ":filled"), (itemStack, world, livingEntity, seed) -> itemStack.getOrCreateSubNbt(RatsMischief.MOD_ID).getFloat("filled")); + ModelPredicateProviderRegistry.register(RatsMischief.id("filled"), (itemStack, world, livingEntity, seed) -> itemStack.getOrCreateSubNbt(RatsMischief.MOD_ID).getFloat("filled")); // // block render layer map // BlockRenderLayerMap.put(RenderLayer.getCutout(), ModBlock.MOD_BLOCK); diff --git a/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClientHelper.java b/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClientHelper.java index 20620b5..6f8efe5 100644 --- a/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClientHelper.java +++ b/src/main/java/ladysnake/ratsmischief/client/RatsMischiefClientHelper.java @@ -20,7 +20,7 @@ public static void addSetBonus(List tooltip) { public static boolean shouldRatsBringItems() { PlayerEntity player = MinecraftClient.getInstance().player; if (player instanceof PlayerRatOwner playerRatOwner) { - return playerRatOwner.ratsmischief$shouldBringItems(); + return playerRatOwner.mischief$shouldBringItems(); } return false; } diff --git a/src/main/java/ladysnake/ratsmischief/client/model/RatEntityModel.java b/src/main/java/ladysnake/ratsmischief/client/model/RatEntityModel.java index e48da92..6cd87cd 100644 --- a/src/main/java/ladysnake/ratsmischief/client/model/RatEntityModel.java +++ b/src/main/java/ladysnake/ratsmischief/client/model/RatEntityModel.java @@ -10,8 +10,8 @@ import software.bernie.geckolib.model.GeoModel; public class RatEntityModel extends GeoModel { - private static final Identifier MODEL = new Identifier(RatsMischief.MOD_ID, "geo/entity/rat.geo.json"); - private static final Identifier ANIMATION = new Identifier(RatsMischief.MOD_ID, "animations/entity/rat.animation.json"); + private static final Identifier MODEL = RatsMischief.id("geo/entity/rat.geo.json"); + private static final Identifier ANIMATION = RatsMischief.id("animations/entity/rat.animation.json"); @Override public Identifier getModelResource(RatEntity rat) { diff --git a/src/main/java/ladysnake/ratsmischief/client/model/RatItemModel.java b/src/main/java/ladysnake/ratsmischief/client/model/RatItemModel.java index b6dab3b..87c1da8 100644 --- a/src/main/java/ladysnake/ratsmischief/client/model/RatItemModel.java +++ b/src/main/java/ladysnake/ratsmischief/client/model/RatItemModel.java @@ -6,9 +6,9 @@ import software.bernie.geckolib.model.GeoModel; public class RatItemModel extends GeoModel { - private static final Identifier MODEL = new Identifier(RatsMischief.MOD_ID, "geo/item/rat.geo.json"); - private static final Identifier DEFAULT_TEXTURE = new Identifier(RatsMischief.MOD_ID, "textures/entity/wild.png"); - private static final Identifier ANIMATION = new Identifier(RatsMischief.MOD_ID, "animations/item/rat.animation.json"); + private static final Identifier MODEL = RatsMischief.id("geo/item/rat.geo.json"); + private static final Identifier DEFAULT_TEXTURE = RatsMischief.id("textures/entity/wild.png"); + private static final Identifier ANIMATION = RatsMischief.id("animations/item/rat.animation.json"); @Override public Identifier getModelResource(RatItem rat) { diff --git a/src/main/java/ladysnake/ratsmischief/client/render/entity/EnderEyeFeatureRenderer.java b/src/main/java/ladysnake/ratsmischief/client/render/entity/EnderEyeFeatureRenderer.java index 7c7715a..df5dcb5 100644 --- a/src/main/java/ladysnake/ratsmischief/client/render/entity/EnderEyeFeatureRenderer.java +++ b/src/main/java/ladysnake/ratsmischief/client/render/entity/EnderEyeFeatureRenderer.java @@ -12,7 +12,7 @@ import software.bernie.geckolib.renderer.layer.GeoRenderLayer; public class EnderEyeFeatureRenderer extends GeoRenderLayer { - public static final Identifier TEXTURE = new Identifier(RatsMischief.MOD_ID, "textures/entity/ender_eye.png"); + public static final Identifier TEXTURE = RatsMischief.id("textures/entity/ender_eye.png"); private final EnderEyeEntityRenderer enderEyeEntityRenderer; diff --git a/src/main/java/ladysnake/ratsmischief/client/render/entity/PartyHatFeatureRenderer.java b/src/main/java/ladysnake/ratsmischief/client/render/entity/PartyHatFeatureRenderer.java index 56c9c56..c1daa84 100644 --- a/src/main/java/ladysnake/ratsmischief/client/render/entity/PartyHatFeatureRenderer.java +++ b/src/main/java/ladysnake/ratsmischief/client/render/entity/PartyHatFeatureRenderer.java @@ -32,7 +32,7 @@ public void render(MatrixStack matrixStackIn, RatEntity ratEntity, BakedGeoModel if (TEXTURES == null) { TEXTURES = new Identifier[RatEntity.PartyHat.values().length]; for (RatEntity.PartyHat hat : RatEntity.PartyHat.values()) { - TEXTURES[hat.ordinal()] = new Identifier(RatsMischief.MOD_ID, "textures/entity/birthday_hats/" + hat.toString().toLowerCase() + ".png"); + TEXTURES[hat.ordinal()] = RatsMischief.id("textures/entity/birthday_hats/" + hat.toString().toLowerCase() + ".png"); } } Identifier hatTexture = TEXTURES[ratEntity.getPartyHat().ordinal()]; diff --git a/src/main/java/ladysnake/ratsmischief/client/render/item/RatMasterMaskItemRenderer.java b/src/main/java/ladysnake/ratsmischief/client/render/item/RatMasterMaskItemRenderer.java index 350de70..c2af549 100644 --- a/src/main/java/ladysnake/ratsmischief/client/render/item/RatMasterMaskItemRenderer.java +++ b/src/main/java/ladysnake/ratsmischief/client/render/item/RatMasterMaskItemRenderer.java @@ -1,7 +1,6 @@ package ladysnake.ratsmischief.client.render.item; import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry; -import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; @@ -14,11 +13,13 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Unit; import net.minecraft.util.profiler.Profiler; +import org.jetbrains.annotations.NotNull; +import org.quiltmc.qsl.resource.loader.api.reloader.IdentifiableResourceReloader; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; -public class RatMasterMaskItemRenderer implements BuiltinItemRendererRegistry.DynamicItemRenderer, IdentifiableResourceReloadListener { +public class RatMasterMaskItemRenderer implements BuiltinItemRendererRegistry.DynamicItemRenderer, IdentifiableResourceReloader { private final Identifier rendererId; private final Identifier itemId; private ItemRenderer itemRenderer; @@ -26,12 +27,12 @@ public class RatMasterMaskItemRenderer implements BuiltinItemRendererRegistry.Dy private BakedModel wornModel; public RatMasterMaskItemRenderer(Identifier itemId) { - this.rendererId = new Identifier(itemId.getNamespace(), itemId.getPath() + "_renderer"); + this.rendererId = Identifier.tryParse(itemId + "_renderer"); this.itemId = itemId; } @Override - public Identifier getFabricId() { + public @NotNull Identifier getQuiltId() { return this.rendererId; } @@ -43,7 +44,7 @@ public CompletableFuture reload(Synchronizer synchronizer, ResourceManager final MinecraftClient client = MinecraftClient.getInstance(); this.itemRenderer = client.getItemRenderer(); this.inventoryModel = client.getBakedModelManager().getModel(new ModelIdentifier(this.itemId, "inventory")); - this.wornModel = client.getBakedModelManager().getModel(new ModelIdentifier(new Identifier(this.itemId + "_worn"), "inventory")); + this.wornModel = client.getBakedModelManager().getModel(new ModelIdentifier(new Identifier(this.itemId.getNamespace(), this.itemId.getPath() + "_worn"), "inventory")); applyProfiler.pop(); applyProfiler.endTick(); }, applyExecutor); diff --git a/src/main/java/ladysnake/ratsmischief/client/render/item/recipe/SpyRatCraftingRecipe.java b/src/main/java/ladysnake/ratsmischief/client/render/item/recipe/SpyRatCraftingRecipe.java index 8a057c4..151fc63 100644 --- a/src/main/java/ladysnake/ratsmischief/client/render/item/recipe/SpyRatCraftingRecipe.java +++ b/src/main/java/ladysnake/ratsmischief/client/render/item/recipe/SpyRatCraftingRecipe.java @@ -49,7 +49,7 @@ public ItemStack craft(RecipeInputInventory inventory, DynamicRegistryManager re for (int i = 6; i < 9; ++i) { ItemStack ratStack = inventory.getStack(i); if (!ratStack.isEmpty()) { - if (ratStack.getItem() instanceof RatItem + if (ratStack.isOf(ModItems.RAT) && ratStack.getNbt() != null && ratStack.getNbt().contains(RatsMischief.MOD_ID) && ratStack.getNbt().getCompound(RatsMischief.MOD_ID).contains("rat") diff --git a/src/main/java/ladysnake/ratsmischief/common/RatsMischief.java b/src/main/java/ladysnake/ratsmischief/common/RatsMischief.java index 5cced04..f8d0b00 100644 --- a/src/main/java/ladysnake/ratsmischief/common/RatsMischief.java +++ b/src/main/java/ladysnake/ratsmischief/common/RatsMischief.java @@ -8,6 +8,7 @@ import ladysnake.ratsmischief.common.init.ModLootTables; import ladysnake.ratsmischief.common.init.ModSoundEvents; import ladysnake.ratsmischief.common.init.ModStatusEffects; +import ladysnake.ratsmischief.common.init.ModTags; import ladysnake.ratsmischief.common.world.RatSpawner; import ladysnake.ratsmischief.mialeemisc.MialeeMisc; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; @@ -17,6 +18,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTables; import net.minecraft.loot.condition.RandomChanceLootCondition; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.provider.number.UniformLootNumberProvider; @@ -35,7 +37,6 @@ public class RatsMischief implements ModInitializer { public static final SpecialRecipeSerializer SPY_RAT_RECIPE = RecipeSerializer.register( "ratsmischief:crafting_special_spy_rat", new SpecialRecipeSerializer<>(SpyRatCraftingRecipe::new) ); - public static final Identifier ANCIENT_CITY_CHESTS = new Identifier("minecraft", "chests/ancient_city"); public static Identifier id(String path) { return new Identifier(MOD_ID, path); @@ -48,10 +49,11 @@ public void onInitialize(ModContainer mod) { ModBlocks.initialize(); // ModItemGroup.initialize(); ModItems.initialize(); - ModSoundEvents.initialize(); ModEnchantments.initialize(); ModLootTables.initialize(); + ModSoundEvents.initialize(); ModStatusEffects.initialize(); + ModTags.initialize(); // custom rat spawner in abandoned villages RatSpawner ratSpawner = new RatSpawner(); @@ -61,12 +63,12 @@ public void onInitialize(ModContainer mod) { }); // rat kid painting - Registry.register(Registries.PAINTING_VARIANT, new Identifier(MOD_ID, "a_rat_in_time"), new PaintingVariant(64, 48)); + Registry.register(Registries.PAINTING_VARIANT, RatsMischief.id("a_rat_in_time"), new PaintingVariant(64, 48)); // clothed ingots and rat curse books spawning in ancient city chests UniformLootNumberProvider lootTableRange = UniformLootNumberProvider.create(1, 1); LootTableEvents.MODIFY.register((resourceManager, lootManager, id, supplier, setter) -> { - if (ANCIENT_CITY_CHESTS.equals(id)) { + if (LootTables.ANCIENT_CITY_CHEST.equals(id)) { { // clothed ingot LootPool lootPool = LootPool.builder() .rolls(lootTableRange) diff --git a/src/main/java/ladysnake/ratsmischief/common/RatsMischiefUtils.java b/src/main/java/ladysnake/ratsmischief/common/RatsMischiefUtils.java index 6a0f976..1acee1e 100644 --- a/src/main/java/ladysnake/ratsmischief/common/RatsMischiefUtils.java +++ b/src/main/java/ladysnake/ratsmischief/common/RatsMischiefUtils.java @@ -13,7 +13,7 @@ public class RatsMischiefUtils { // DATES public static final boolean IS_WORLD_RAT_DAY = DateTimeFormatter.ofPattern("dd/MM").format(LocalDateTime.now()).equals("04/04"); // RENDER - public static final Identifier REMY_TEXTURE = new Identifier(RatsMischief.MOD_ID, "textures/entity/named/remy.png"); + public static final Identifier REMY_TEXTURE = RatsMischief.id("textures/entity/named/remy.png"); private static final LocalDate today = LocalDate.now(); public static final boolean IS_RAT_BIRTHDAY = LocalDate.of(today.getYear(), 7, 19).compareTo(today) * today.compareTo(LocalDate.of(today.getYear(), 7, 25)) >= 0; public static final boolean IS_MISCHIEF_BIRTHDAY = (LocalDate.of(today.getYear(), 12, 28).compareTo(today) * today.compareTo(LocalDate.of(today.getYear(), 12, 31)) >= 0) @@ -26,7 +26,7 @@ public static Identifier getRatTexture(RatEntity.Type ratType, DyeColor ratColor if (RAT_KID_TEXTURES == null) { RAT_KID_TEXTURES = new Identifier[16]; for (DyeColor color : DyeColor.values()) { - RAT_KID_TEXTURES[color.getId()] = new Identifier(RatsMischief.MOD_ID, "textures/entity/rat_kid/rat_kid_" + color.getName().toLowerCase(Locale.ROOT) + ".png"); + RAT_KID_TEXTURES[color.getId()] = RatsMischief.id("textures/entity/rat_kid/rat_kid_" + color.getName().toLowerCase(Locale.ROOT) + ".png"); } } diff --git a/src/main/java/ladysnake/ratsmischief/common/entity/RatEntity.java b/src/main/java/ladysnake/ratsmischief/common/entity/RatEntity.java index 7cb63cc..d0c814b 100644 --- a/src/main/java/ladysnake/ratsmischief/common/entity/RatEntity.java +++ b/src/main/java/ladysnake/ratsmischief/common/entity/RatEntity.java @@ -12,10 +12,10 @@ import ladysnake.ratsmischief.common.init.ModEntities; import ladysnake.ratsmischief.common.init.ModItems; import ladysnake.ratsmischief.common.init.ModSoundEvents; +import ladysnake.ratsmischief.common.init.ModTags; import ladysnake.ratsmischief.common.item.RatMasterArmorItem; -import ladysnake.ratsmischief.common.item.RatMasterOcarinaItem; -import ladysnake.ratsmischief.common.item.RatPouchItem; import ladysnake.ratsmischief.common.util.PlayerRatOwner; +import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; @@ -415,7 +415,7 @@ public void readCustomDataFromNbt(NbtCompound tag) { } if (tag.contains("PotionGene")) { - Identifier id = new Identifier(tag.getString("PotionGene")); + Identifier id = Identifier.tryParse(tag.getString("PotionGene")); StatusEffect potion = Registries.STATUS_EFFECT.get(id); this.dataTracker.set(POTION_GENE, Registries.STATUS_EFFECT.getRawId(potion)); } @@ -442,11 +442,6 @@ public void writeCustomDataToNbt(NbtCompound tag) { } } - @Override - public boolean isServer() { - return super.isServer(); - } - @Override public void setYaw(float yaw) { if (!this.isFlying()) { @@ -731,7 +726,7 @@ public ActionResult interactMob(PlayerEntity player, Hand hand) { } // sitting - if (!(item instanceof RatPouchItem) && !(item instanceof RatMasterOcarinaItem) && (!this.isBreedingItem(itemStack)) && !(itemStack.getItem() instanceof DyeItem && this.getRatType() == Type.RAT_KID)) { + if (!(itemStack.isIn(ModTags.RAT_POUCHES)) && !(itemStack.isOf(ModItems.RAT_MASTER_OCARINA)) && (!this.isBreedingItem(itemStack)) && !(itemStack.getItem() instanceof DyeItem && this.getRatType() == Type.RAT_KID)) { this.setSitting(!this.isSitting()); return ActionResult.SUCCESS; } @@ -848,12 +843,12 @@ public boolean canAttackWithOwner(LivingEntity target, LivingEntity owner) { if (!(target instanceof CreeperEntity || (target instanceof GhastEntity))) { if (target instanceof RatEntity rat) { return !rat.isTamed() || rat.getOwner() != owner; - } else if (target instanceof PlayerEntity && owner instanceof PlayerEntity && !((PlayerEntity) owner).shouldDamagePlayer((PlayerEntity) target)) { + } else if (target instanceof PlayerEntity targetPlayer && owner instanceof PlayerEntity ownerPlayer && !ownerPlayer.shouldDamagePlayer(targetPlayer)) { return false; - } else if (target instanceof HorseEntity && ((HorseEntity) target).isTame()) { + } else if (target instanceof HorseEntity horse && horse.isTame()) { return false; } else { - return !(target instanceof TameableEntity) || !((TameableEntity) target).isTamed(); + return !(target instanceof TameableEntity tameable) || !(tameable.isTamed()); } } else { return false; @@ -1055,24 +1050,24 @@ public EntityView getEntityView() { } public enum Type { - WILD(new Identifier(RatsMischief.MOD_ID, "textures/entity/wild.png")), - ALBINO(new Identifier(RatsMischief.MOD_ID, "textures/entity/albino.png")), - BLACK(new Identifier(RatsMischief.MOD_ID, "textures/entity/black.png")), - GREY(new Identifier(RatsMischief.MOD_ID, "textures/entity/grey.png")), - HUSKY(new Identifier(RatsMischief.MOD_ID, "textures/entity/husky.png")), - LIGHT_BROWN(new Identifier(RatsMischief.MOD_ID, "textures/entity/light_brown.png")), - BLUE(new Identifier(RatsMischief.MOD_ID, "textures/entity/blue.png")), - GOLD(new Identifier(RatsMischief.MOD_ID, "textures/entity/gold.png")), + WILD(RatsMischief.id("textures/entity/wild.png")), + ALBINO(RatsMischief.id("textures/entity/albino.png")), + BLACK(RatsMischief.id("textures/entity/black.png")), + GREY(RatsMischief.id("textures/entity/grey.png")), + HUSKY(RatsMischief.id("textures/entity/husky.png")), + LIGHT_BROWN(RatsMischief.id("textures/entity/light_brown.png")), + BLUE(RatsMischief.id("textures/entity/blue.png")), + GOLD(RatsMischief.id("textures/entity/gold.png")), RAT_KID(null), - DOCTOR4T(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/doctor4t.png")), - ASTRONYU(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/astronyu.png")), + DOCTOR4T(RatsMischief.id("textures/entity/named/doctor4t.png")), + ASTRONYU(RatsMischief.id("textures/entity/named/astronyu.png")), - REMY(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/remy.png")), - RATATER(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/ratater.png")), - JERMA(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/jerma.png")), - BIGGIE_CHEESE(new Identifier(RatsMischief.MOD_ID, "textures/entity/named/biggie_cheese.png")); + REMY(RatsMischief.id("textures/entity/named/remy.png")), + RATATER(RatsMischief.id("textures/entity/named/ratater.png")), + JERMA(RatsMischief.id("textures/entity/named/jerma.png")), + BIGGIE_CHEESE(RatsMischief.id("textures/entity/named/biggie_cheese.png")); public final Identifier ratTexture; @@ -1163,7 +1158,7 @@ public void tick() { @Override public boolean canStart() { if (RatEntity.this.getOwner() instanceof PlayerRatOwner playerRatOwner) { - if (!playerRatOwner.ratsmischief$shouldBringItems()) { + if (!playerRatOwner.mischief$shouldBringItems()) { return false; } } diff --git a/src/main/java/ladysnake/ratsmischief/common/entity/ai/BreedGoal.java b/src/main/java/ladysnake/ratsmischief/common/entity/ai/BreedGoal.java index acaadfe..73e6e30 100644 --- a/src/main/java/ladysnake/ratsmischief/common/entity/ai/BreedGoal.java +++ b/src/main/java/ladysnake/ratsmischief/common/entity/ai/BreedGoal.java @@ -42,9 +42,9 @@ public void tick() { ItemStack itemStack = this.rat.getEquippedStack(EquipmentSlot.MAINHAND); if (this.rat.squaredDistanceTo(this.target.getX(), this.target.getY(), this.target.getZ()) <= 5) { - if (this.rat.getOwner() instanceof PlayerEntity) { + if (this.rat.getOwner() instanceof PlayerEntity owner) { itemStack.decrement(1); - this.target.lovePlayer((PlayerEntity) this.rat.getOwner()); + this.target.lovePlayer(owner); } this.target = null; diff --git a/src/main/java/ladysnake/ratsmischief/common/entity/ai/FollowOwnerRatGoal.java b/src/main/java/ladysnake/ratsmischief/common/entity/ai/FollowOwnerRatGoal.java index 08b5b70..50d6ed3 100644 --- a/src/main/java/ladysnake/ratsmischief/common/entity/ai/FollowOwnerRatGoal.java +++ b/src/main/java/ladysnake/ratsmischief/common/entity/ai/FollowOwnerRatGoal.java @@ -2,7 +2,6 @@ import ladysnake.ratsmischief.common.entity.RatEntity; import net.minecraft.block.BlockState; -import net.minecraft.block.LeavesBlock; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.ai.pathing.BirdNavigation; @@ -10,6 +9,7 @@ import net.minecraft.entity.ai.pathing.LandPathNodeMaker; import net.minecraft.entity.ai.pathing.MobNavigation; import net.minecraft.entity.ai.pathing.PathNodeType; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.world.WorldView; @@ -133,7 +133,7 @@ private boolean canTeleportTo(BlockPos pos) { return false; } else { BlockState blockState = this.world.getBlockState(pos.down()); - if (!this.leavesAllowed && blockState.getBlock() instanceof LeavesBlock) { + if (!this.leavesAllowed && blockState.isIn(BlockTags.LEAVES)) { return false; } else { BlockPos blockPos = pos.subtract(this.rat.getBlockPos()); diff --git a/src/main/java/ladysnake/ratsmischief/common/entity/ai/HarvestPlantMealGoal.java b/src/main/java/ladysnake/ratsmischief/common/entity/ai/HarvestPlantMealGoal.java index 07472ff..4bcb786 100644 --- a/src/main/java/ladysnake/ratsmischief/common/entity/ai/HarvestPlantMealGoal.java +++ b/src/main/java/ladysnake/ratsmischief/common/entity/ai/HarvestPlantMealGoal.java @@ -6,10 +6,11 @@ import net.minecraft.block.FarmlandBlock; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.ai.goal.Goal; -import net.minecraft.item.AliasedBlockItem; +import net.minecraft.item.BlockItem; import net.minecraft.item.BoneMealItem; import net.minecraft.item.ItemStack; import net.minecraft.particle.ParticleTypes; +import net.minecraft.registry.tag.BlockTags; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -30,20 +31,20 @@ public HarvestPlantMealGoal(RatEntity rat) { public boolean canStart() { this.targetBlockPos = null; - if (this.rat.getTarget() == null && this.rat.getAttacker() == null && !this.rat.isSitting() && this.rat.isTamed() && (this.rat.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() || (this.rat.getEquippedStack(EquipmentSlot.MAINHAND).getItem() instanceof AliasedBlockItem && ((AliasedBlockItem) this.rat.getEquippedStack(EquipmentSlot.MAINHAND).getItem()).getBlock() instanceof CropBlock) || this.rat.getEquippedStack(EquipmentSlot.MAINHAND).getItem() instanceof BoneMealItem)) { + if (this.rat.getTarget() == null && this.rat.getAttacker() == null && !this.rat.isSitting() && this.rat.isTamed() && (this.rat.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() || (this.rat.getEquippedStack(EquipmentSlot.MAINHAND).getItem() instanceof BlockItem bi && bi.getBlock().getDefaultState().isIn(BlockTags.CROPS)) || this.rat.getEquippedStack(EquipmentSlot.MAINHAND).getItem() instanceof BoneMealItem)) { ItemStack itemStack = this.rat.getEquippedStack(EquipmentSlot.MAINHAND); for (BlockPos blockPos : BlockPos.iterateOutwards(this.rat.getBlockPos(), 8, 2, 8)) { if (itemStack.isEmpty()) { // harvest BlockState blockState = this.rat.getWorld().getBlockState(blockPos); - if (blockState.getBlock() instanceof CropBlock && ((CropBlock) blockState.getBlock()).isMature(blockState)) { + if (blockState.getBlock() instanceof CropBlock crop && crop.isMature(blockState)) { if (this.rat.getNavigation().startMovingTo(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 1f)) { this.targetBlockPos = blockPos; return true; } } - } else if (itemStack.getItem() instanceof AliasedBlockItem && ((AliasedBlockItem) itemStack.getItem()).getBlock() instanceof CropBlock) { + } else if (itemStack.getItem() instanceof BlockItem bi && bi.getBlock() instanceof CropBlock) { // plant BlockState blockState = this.rat.getWorld().getBlockState(blockPos.add(0, -1, 0)); if (blockState.getBlock() instanceof FarmlandBlock && this.rat.getWorld().getBlockState(blockPos).isAir()) { @@ -55,7 +56,7 @@ public boolean canStart() { } else if (itemStack.getItem() instanceof BoneMealItem) { // bonemeal BlockState blockState = this.rat.getWorld().getBlockState(blockPos); - if (blockState.getBlock() instanceof CropBlock && ((CropBlock) blockState.getBlock()).isFertilizable(this.rat.getWorld(), blockPos, this.rat.getWorld().getBlockState(blockPos), this.rat.getWorld().isClient())) { + if (blockState.getBlock() instanceof CropBlock crop && crop.isFertilizable(this.rat.getWorld(), blockPos, this.rat.getWorld().getBlockState(blockPos), this.rat.getWorld().isClient())) { if (this.rat.getNavigation().startMovingTo(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 1f)) { this.targetBlockPos = blockPos; return true; @@ -75,7 +76,7 @@ public void tick() { if (itemStack.isEmpty()) { // harvest BlockState blockState = this.rat.getWorld().getBlockState(this.targetBlockPos); - if (!(blockState.getBlock() instanceof CropBlock && ((CropBlock) blockState.getBlock()).isMature(blockState))) { + if (!(blockState.getBlock() instanceof CropBlock crop && crop.isMature(blockState))) { this.canStart(); } @@ -85,7 +86,7 @@ public void tick() { } else { this.rat.getNavigation().startMovingTo(this.targetBlockPos.getX(), this.targetBlockPos.getY(), this.targetBlockPos.getZ(), 1D); } - } else if (itemStack.getItem() instanceof AliasedBlockItem && ((AliasedBlockItem) itemStack.getItem()).getBlock() instanceof CropBlock) { + } else if (itemStack.getItem() instanceof BlockItem bi && bi.getBlock() instanceof CropBlock) { // plant BlockState blockState = this.rat.getWorld().getBlockState(this.targetBlockPos.add(0, -1, 0)); if (!(blockState.getBlock() instanceof FarmlandBlock && this.rat.getWorld().getBlockState(this.targetBlockPos).isAir())) { @@ -93,7 +94,7 @@ public void tick() { } if (this.rat.squaredDistanceTo(this.targetBlockPos.getX(), this.targetBlockPos.getY(), this.targetBlockPos.getZ()) <= 5) { - this.rat.getWorld().setBlockState(this.targetBlockPos, ((AliasedBlockItem) itemStack.getItem()).getBlock().getDefaultState()); + this.rat.getWorld().setBlockState(this.targetBlockPos, bi.getBlock().getDefaultState()); this.rat.getEquippedStack(EquipmentSlot.MAINHAND).decrement(1); this.targetBlockPos = null; } else { @@ -102,7 +103,7 @@ public void tick() { } else if (itemStack.getItem() instanceof BoneMealItem) { // bonemeal BlockState blockState = this.rat.getWorld().getBlockState(this.targetBlockPos); - if (blockState.getBlock() instanceof CropBlock && ((CropBlock) blockState.getBlock()).isFertilizable(this.rat.getWorld(), this.targetBlockPos, this.rat.getWorld().getBlockState(this.targetBlockPos), this.rat.getWorld().isClient())) { + if (blockState.getBlock() instanceof CropBlock crop && crop.isFertilizable(this.rat.getWorld(), this.targetBlockPos, this.rat.getWorld().getBlockState(this.targetBlockPos), this.rat.getWorld().isClient())) { this.canStart(); } diff --git a/src/main/java/ladysnake/ratsmischief/common/entity/ai/RatMeleeAttackGoal.java b/src/main/java/ladysnake/ratsmischief/common/entity/ai/RatMeleeAttackGoal.java index 144954c..8f73cff 100644 --- a/src/main/java/ladysnake/ratsmischief/common/entity/ai/RatMeleeAttackGoal.java +++ b/src/main/java/ladysnake/ratsmischief/common/entity/ai/RatMeleeAttackGoal.java @@ -74,7 +74,7 @@ public boolean shouldContinue() { } else if (!this.rat.isInWalkTargetRange(livingEntity.getBlockPos())) { return false; } else { - return !(livingEntity instanceof PlayerEntity) || !livingEntity.isSpectator() && !((PlayerEntity) livingEntity).isCreative(); + return !(livingEntity instanceof PlayerEntity player) || !livingEntity.isSpectator() && !player.isCreative(); } } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModBlocks.java b/src/main/java/ladysnake/ratsmischief/common/init/ModBlocks.java index f33d62e..ca27d6a 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModBlocks.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModBlocks.java @@ -21,7 +21,7 @@ static void initialize() { } private static T createBlock(String name, T block, boolean createItem) { - BLOCKS.put(block, new Identifier(RatsMischief.MOD_ID, name)); + BLOCKS.put(block, RatsMischief.id(name)); if (createItem) { ModItems.ITEMS.put(new BlockItem(block, new QuiltItemSettings()), BLOCKS.get(block)); } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModDamageTypes.java b/src/main/java/ladysnake/ratsmischief/common/init/ModDamageTypes.java index fcd400e..0f48e12 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModDamageTypes.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModDamageTypes.java @@ -7,10 +7,10 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; -public class ModDamageTypes { - public static final RegistryKey RAT = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, RatsMischief.id("rat")); +public interface ModDamageTypes { + RegistryKey RAT = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, RatsMischief.id("rat")); - public static DamageSource ratDamage(RatEntity rat) { + static DamageSource ratDamage(RatEntity rat) { return new DamageSource(rat.getWorld().getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).getHolderOrThrow(RAT), rat); } } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModEnchantments.java b/src/main/java/ladysnake/ratsmischief/common/init/ModEnchantments.java index 8c622cf..95d16fc 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModEnchantments.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModEnchantments.java @@ -18,7 +18,7 @@ public interface ModEnchantments { @SuppressWarnings("SameParameterValue") private static Enchantment createEnchantment(String name, Enchantment entity) { - ENCHANTMENTS.put(entity, new Identifier(RatsMischief.MOD_ID, name)); + ENCHANTMENTS.put(entity, RatsMischief.id(name)); return entity; } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModEntities.java b/src/main/java/ladysnake/ratsmischief/common/init/ModEntities.java index 793bdfe..61c4856 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModEntities.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModEntities.java @@ -20,7 +20,7 @@ public interface ModEntities { EntityType RAT = createEntity("rat", QuiltEntityTypeBuilder.createMob().entityFactory(RatEntity::new).defaultAttributes(RatEntity.createRatAttributes()).setDimensions(EntityDimensions.changing(0.6F, 0.4F)).maxChunkTrackingRange(128).build()); private static > T createEntity(String name, T entity) { - ENTITIES.put(entity, new Identifier(RatsMischief.MOD_ID, name)); + ENTITIES.put(entity, RatsMischief.id(name)); return entity; } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModItemGroup.java b/src/main/java/ladysnake/ratsmischief/common/init/ModItemGroup.java index 223c538..79c16c7 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModItemGroup.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModItemGroup.java @@ -14,7 +14,7 @@ // public static ItemGroup MOD_ITEMS; // // public static void initialize() { -// MOD_ITEMS = FabricItemGroup.builder(new Identifier(RatsMischief.MOD_ID, "items")) +// MOD_ITEMS = FabricItemGroup.builder(RatsMischief.id("items")) // .name(Text.literal("Explosive Ideas")) // .icon(() -> new ItemStack(Items.TNT)) // .build(); diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModItems.java b/src/main/java/ladysnake/ratsmischief/common/init/ModItems.java index fb11334..b1f31d3 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModItems.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModItems.java @@ -45,7 +45,7 @@ public interface ModItems { Item RAT_MASTER_MASK = createItem("rat_master_mask", new RatMasterMaskItem(new QuiltItemSettings().maxCount(1))); private static T createItem(String name, T item) { - ITEMS.put(item, new Identifier(RatsMischief.MOD_ID, name)); + ITEMS.put(item, RatsMischief.id(name)); return item; } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModLootTables.java b/src/main/java/ladysnake/ratsmischief/common/init/ModLootTables.java index b32258a..f6922b4 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModLootTables.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModLootTables.java @@ -1,12 +1,12 @@ package ladysnake.ratsmischief.common.init; -import ladysnake.ratsmischief.common.RatsMischief; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.minecraft.enchantment.EnchantmentLevelEntry; import net.minecraft.item.EnchantedBookItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTables; import net.minecraft.loot.condition.RandomChanceLootCondition; import net.minecraft.loot.context.LootContext; import net.minecraft.loot.entry.ItemEntry; @@ -19,7 +19,7 @@ public class ModLootTables { public static void initialize() { LootTableEvents.MODIFY.register((resourceManager, lootManager, identifier, fabricLootSupplierBuilder, lootTableSetter) -> { - if (RatsMischief.ANCIENT_CITY_CHESTS.equals(identifier)) { + if (LootTables.ANCIENT_CITY_CHEST.equals(identifier)) { fabricLootSupplierBuilder.pool(new LootPool.Builder() .rolls(ConstantLootNumberProvider.create(1)) .with(ItemEntry.builder(Items.BOOK).apply(() -> new LootFunction() { diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModSoundEvents.java b/src/main/java/ladysnake/ratsmischief/common/init/ModSoundEvents.java index f28f5d0..74671c0 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModSoundEvents.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModSoundEvents.java @@ -25,7 +25,7 @@ static void initialize() { } private static SoundEvent createSoundEvent(String path) { - SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(new Identifier(RatsMischief.MOD_ID, path)); + SoundEvent soundEvent = SoundEvent.createVariableRangeEvent(RatsMischief.id(path)); SOUND_EVENTS.put(soundEvent, new Identifier(RatsMischief.MOD_ID, path)); return soundEvent; } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModStatusEffects.java b/src/main/java/ladysnake/ratsmischief/common/init/ModStatusEffects.java index 5eecac3..0a0a3a9 100644 --- a/src/main/java/ladysnake/ratsmischief/common/init/ModStatusEffects.java +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModStatusEffects.java @@ -19,7 +19,7 @@ public interface ModStatusEffects { StatusEffect RAT_CURSE_COOLDOWN = createStatusEffect("rat_curse_cooldown", new RatCurseCooldownStatusEffect(StatusEffectType.NEUTRAL, 0x31363F)); private static T createStatusEffect(String name, T effect) { - EFFECTS.put(effect, new Identifier(RatsMischief.MOD_ID, name)); + EFFECTS.put(effect, RatsMischief.id(name)); return effect; } diff --git a/src/main/java/ladysnake/ratsmischief/common/init/ModTags.java b/src/main/java/ladysnake/ratsmischief/common/init/ModTags.java new file mode 100644 index 0000000..ecaca0f --- /dev/null +++ b/src/main/java/ladysnake/ratsmischief/common/init/ModTags.java @@ -0,0 +1,15 @@ +package ladysnake.ratsmischief.common.init; + +import ladysnake.ratsmischief.common.RatsMischief; +import net.minecraft.item.Item; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; + +@SuppressWarnings("unused") +public interface ModTags { + TagKey RAT_POUCHES = TagKey.of(RegistryKeys.ITEM, RatsMischief.id("rat_pouches")); + + static void initialize() { + // NO-OP + } +} diff --git a/src/main/java/ladysnake/ratsmischief/common/item/RatItem.java b/src/main/java/ladysnake/ratsmischief/common/item/RatItem.java index d825987..075629e 100644 --- a/src/main/java/ladysnake/ratsmischief/common/item/RatItem.java +++ b/src/main/java/ladysnake/ratsmischief/common/item/RatItem.java @@ -135,7 +135,7 @@ public void registerControllers(AnimatableManager.ControllerRegistrar controller @Override public TypedActionResult use(World world, PlayerEntity user, Hand hand) { if (!world.isClient()) { - RatEntity rat = this.getRatFromItem(world, user.getStackInHand(hand), new Vec3d(user.getX(), user.getEyeY() - 0.10000000149011612D, user.getZ()), + RatEntity rat = this.getRatFromItem(world, user.getStackInHand(hand), new Vec3d(user.getX(), user.getEyeY() - 0.1, user.getZ()), hand == Hand.OFF_HAND ? PlayerInventory.OFF_HAND_SLOT : user.getInventory().getSlotWithStack(user.getStackInHand(hand))); if (rat == null) { return TypedActionResult.fail(user.getStackInHand(hand)); @@ -199,7 +199,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too } // potion genes - var potionId = new Identifier(ratTag.getString("PotionGene")); + var potionId = Identifier.tryParse(ratTag.getString("PotionGene")); var statusEffect = Registries.STATUS_EFFECT.get(potionId); if (statusEffect != null) { tooltip.add(Text.translatable("item.ratsmischief.rat.tooltip.potion").setStyle(EMPTY.withColor(Formatting.GRAY)).append(MialeeText.withColor(Text.translatable(statusEffect.getTranslationKey()).setStyle(EMPTY), statusEffect.getColor()))); diff --git a/src/main/java/ladysnake/ratsmischief/common/item/RatMasterArmorItem.java b/src/main/java/ladysnake/ratsmischief/common/item/RatMasterArmorItem.java index 593599b..fed27f4 100644 --- a/src/main/java/ladysnake/ratsmischief/common/item/RatMasterArmorItem.java +++ b/src/main/java/ladysnake/ratsmischief/common/item/RatMasterArmorItem.java @@ -1,6 +1,7 @@ package ladysnake.ratsmischief.common.item; import ladysnake.ratsmischief.client.RatsMischiefClientHelper; +import ladysnake.ratsmischief.common.RatsMischief; import ladysnake.ratsmischief.mialeemisc.util.MialeeMath; import ladysnake.ratsmischief.mialeemisc.util.MialeeText; import net.minecraft.client.item.TooltipContext; @@ -15,8 +16,11 @@ import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.quiltmc.loader.api.minecraft.ClientOnly; import java.util.List; import java.util.Set; @@ -116,6 +120,8 @@ public enum MasterArmorBoost { public static class RatMasterArmorMaterial implements ArmorMaterial { public static final RatMasterArmorMaterial INSTANCE = new RatMasterArmorMaterial(); + private static final String NAME = "rat_master"; + private static final Identifier TEXTURE = RatsMischief.id("textures/models/armor/" + NAME); private static final int[] BASE_DURABILITY = new int[]{13, 15, 16, 11}; private static final int[] PROTECTION_AMOUNTS = new int[]{3, 6, 8, 3}; @@ -146,7 +152,7 @@ public Ingredient getRepairIngredient() { @Override public String getName() { - return "rat_master"; + return NAME; } @Override @@ -158,5 +164,10 @@ public float getToughness() { public float getKnockbackResistance() { return 0.0f; } + + @Override + public @ClientOnly @NotNull Identifier getTexture() { + return TEXTURE; + } } } diff --git a/src/main/java/ladysnake/ratsmischief/common/item/RatMasterMaskItem.java b/src/main/java/ladysnake/ratsmischief/common/item/RatMasterMaskItem.java index cf614be..856748d 100644 --- a/src/main/java/ladysnake/ratsmischief/common/item/RatMasterMaskItem.java +++ b/src/main/java/ladysnake/ratsmischief/common/item/RatMasterMaskItem.java @@ -1,9 +1,8 @@ package ladysnake.ratsmischief.common.item; -import dev.emi.trinkets.api.SlotReference; -import dev.emi.trinkets.api.TrinketComponent; import dev.emi.trinkets.api.TrinketItem; import dev.emi.trinkets.api.TrinketsApi; +import ladysnake.ratsmischief.common.init.ModItems; import ladysnake.ratsmischief.mialeemisc.util.MialeeMath; import ladysnake.ratsmischief.mialeemisc.util.MialeeText; import net.minecraft.client.item.TooltipContext; @@ -12,7 +11,6 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import net.minecraft.util.Pair; import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; @@ -29,15 +27,14 @@ public static boolean isWearingMask(LivingEntity livingEntity) { } public static ItemStack getWornMask(LivingEntity livingEntity) { - Optional component = TrinketsApi.getTrinketComponent(livingEntity); - if (component.isPresent()) { - for (Pair pair : component.get().getAllEquipped()) { - if (pair.getRight().getItem() instanceof RatMasterMaskItem) { - return pair.getRight(); - } + return TrinketsApi.getTrinketComponent(livingEntity).flatMap(h -> { + var results = h.getEquipped(ModItems.RAT_MASTER_MASK); + if (results.isEmpty()) { + return Optional.empty(); + } else { + return Optional.of(results.get(0).getRight()); } - } - return ItemStack.EMPTY; + }).orElse(ItemStack.EMPTY); } public static int getOffset(ItemStack stack) { diff --git a/src/main/java/ladysnake/ratsmischief/common/item/RatPouchItem.java b/src/main/java/ladysnake/ratsmischief/common/item/RatPouchItem.java index 8faa36b..9bc63a3 100644 --- a/src/main/java/ladysnake/ratsmischief/common/item/RatPouchItem.java +++ b/src/main/java/ladysnake/ratsmischief/common/item/RatPouchItem.java @@ -92,12 +92,12 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han public ActionResult useOnEntity(ItemStack stack, PlayerEntity user, LivingEntity entity, Hand hand) { NbtList NbtList = user.getStackInHand(hand).getOrCreateSubNbt(RatsMischief.MOD_ID).getList("rats", NbtElement.COMPOUND_TYPE); - if (NbtList.size() < this.size && entity instanceof RatEntity && ((RatEntity) entity).getOwnerUuid() != null && ((RatEntity) entity).getOwnerUuid().equals(user.getUuid())) { + if (NbtList.size() < this.size && entity instanceof RatEntity rat && rat.getOwnerUuid() != null && rat.getOwnerUuid().equals(user.getUuid())) { NbtCompound NbtCompound = new NbtCompound(); entity.saveNbt(NbtCompound); NbtList.add(NbtCompound); user.getStackInHand(hand).getOrCreateSubNbt(RatsMischief.MOD_ID).put("rats", NbtList); - ((RatEntity) entity).playSpawnEffects(); + rat.playSpawnEffects(); entity.remove(Entity.RemovalReason.DISCARDED); user.getStackInHand(hand).getOrCreateSubNbt(RatsMischief.MOD_ID).putFloat("filled", 1F); @@ -136,7 +136,7 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List too } // potion genes - var potionId = new Identifier(((NbtCompound) ratTag).getString("PotionGene")); + var potionId = Identifier.tryParse(((NbtCompound) ratTag).getString("PotionGene")); var statusEffect = Registries.STATUS_EFFECT.get(potionId); if (statusEffect != null) { text = text.append(" (").append(Text.translatable("item.ratsmischief.rat.tooltip.potion").setStyle(EMPTY.withColor(Formatting.GRAY)).append(MialeeText.withColor(Text.translatable(statusEffect.getTranslationKey()).setStyle(EMPTY), statusEffect.getColor()))).append(")"); diff --git a/src/main/java/ladysnake/ratsmischief/common/util/PlayerRatOwner.java b/src/main/java/ladysnake/ratsmischief/common/util/PlayerRatOwner.java index 99cdfae..0d1d4dc 100644 --- a/src/main/java/ladysnake/ratsmischief/common/util/PlayerRatOwner.java +++ b/src/main/java/ladysnake/ratsmischief/common/util/PlayerRatOwner.java @@ -1,7 +1,7 @@ package ladysnake.ratsmischief.common.util; public interface PlayerRatOwner { - boolean ratsmischief$shouldBringItems(); + boolean mischief$shouldBringItems(); - void ratsmischief$setBringingItems(boolean bringingItems); + void mischief$setBringingItems(boolean bringingItems); } diff --git a/src/main/java/ladysnake/ratsmischief/common/world/RatSpawner.java b/src/main/java/ladysnake/ratsmischief/common/world/RatSpawner.java index 7a4c990..114b6a0 100644 --- a/src/main/java/ladysnake/ratsmischief/common/world/RatSpawner.java +++ b/src/main/java/ladysnake/ratsmischief/common/world/RatSpawner.java @@ -60,7 +60,6 @@ public int spawn(ServerWorld world, boolean spawnMonsters, boolean spawnAnimals) } private int spawnInHouse(ServerWorld world, BlockPos pos) { - boolean i = true; if (world.getPointOfInterestStorage().count((registryEntry) -> registryEntry.isRegistryKey(PointOfInterestTypes.HOME), pos, 48, PointOfInterestStorage.OccupationStatus.HAS_SPACE) > 4L) { List list = world.getNonSpectatingEntities(RatEntity.class, (new Box(pos)).expand(48.0D, 8.0D, 48.0D)); if (list.size() < 10) { diff --git a/src/main/java/ladysnake/ratsmischief/mialeemisc/util/MialeeText.java b/src/main/java/ladysnake/ratsmischief/mialeemisc/util/MialeeText.java index 832d631..4f0c152 100644 --- a/src/main/java/ladysnake/ratsmischief/mialeemisc/util/MialeeText.java +++ b/src/main/java/ladysnake/ratsmischief/mialeemisc/util/MialeeText.java @@ -24,7 +24,7 @@ public static Text withColor(Text text, int color) { */ public static Text withoutItalics(Text text) { List styled = text.setStyle(text.getStyle().withItalic(false)); - if (styled.size() > 0) { + if (!styled.isEmpty()) { return styled.get(0); } //MialeeMisc.LOGGER.error("Failed to remove italics from text: " + text.getString()); diff --git a/src/main/java/ladysnake/ratsmischief/mixin/FollowTargetGoalMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/FollowTargetGoalMixin.java index 7f26d66..5e7fb6f 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/FollowTargetGoalMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/FollowTargetGoalMixin.java @@ -1,4 +1,4 @@ -package ladysnake.ratsmischief.mixin;// +//package ladysnake.ratsmischief.mixin; ///* // * Requiem // * Copyright (C) 2017-2021 Ladysnake diff --git a/src/main/java/ladysnake/ratsmischief/mixin/PlayerEntityMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/PlayerEntityMixin.java index cf185ce..38a9024 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/PlayerEntityMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/PlayerEntityMixin.java @@ -47,12 +47,12 @@ protected PlayerEntityMixin(EntityType entityType, World } @Override - public boolean ratsmischief$shouldBringItems() { + public boolean mischief$shouldBringItems() { return this.shouldRatsBringItems; } @Override - public void ratsmischief$setBringingItems(boolean bringingItems) { + public void mischief$setBringingItems(boolean bringingItems) { this.shouldRatsBringItems = bringingItems; } diff --git a/src/main/java/ladysnake/ratsmischief/mixin/ScreenHandlerMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/ScreenHandlerMixin.java index f16ff51..c443f63 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/ScreenHandlerMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/ScreenHandlerMixin.java @@ -1,5 +1,6 @@ package ladysnake.ratsmischief.mixin; +import ladysnake.ratsmischief.common.init.ModItems; import ladysnake.ratsmischief.common.init.ModSoundEvents; import ladysnake.ratsmischief.common.item.RatItem; import ladysnake.ratsmischief.common.item.RatMasterArmorItem; @@ -45,13 +46,13 @@ public class ScreenHandlerMixin { player.playSound(ModSoundEvents.ITEM_RAT_TOGGLE, SoundCategory.PLAYERS, 0.9f, 1.5f); ci.cancel(); } - } else if (stack.getItem() instanceof RatMasterMaskItem) { + } else if (stack.isOf(ModItems.RAT_MASTER_MASK)) { RatMasterMaskItem.incrementOffset(stack); player.playSound(ModSoundEvents.ITEM_RAT_TOGGLE, SoundCategory.PLAYERS, 0.9f, 1.5f); ci.cancel(); } else if (stack.getItem() instanceof RatMasterOcarinaItem) { if (player instanceof PlayerRatOwner playerRatOwner) { - playerRatOwner.ratsmischief$setBringingItems(!playerRatOwner.ratsmischief$shouldBringItems()); + playerRatOwner.mischief$setBringingItems(!playerRatOwner.mischief$shouldBringItems()); player.playSound(ModSoundEvents.ITEM_RAT_TOGGLE, SoundCategory.PLAYERS, 0.9f, 1.5f); ci.cancel(); } diff --git a/src/main/java/ladysnake/ratsmischief/mixin/SculkSensorBlockEntityMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/SculkSensorBlockEntityMixin.java index ad4909b..ef63bc7 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/SculkSensorBlockEntityMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/SculkSensorBlockEntityMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net.minecraft.block.entity.SculkSensorBlockEntity.VibrationCallback") +@Mixin(targets = "net/minecraft/block/entity/SculkSensorBlockEntity$VibrationCallback") public class SculkSensorBlockEntityMixin { @Inject(method = "accepts", at = @At(value = "HEAD"), cancellable = true) private void mischief$noRats(ServerWorld world, BlockPos pos, GameEvent event, GameEvent.Context eventContext, CallbackInfoReturnable cir) { diff --git a/src/main/java/ladysnake/ratsmischief/mixin/SculkShriekerBlockEntityMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/SculkShriekerBlockEntityMixin.java index 4e88153..d726197 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/SculkShriekerBlockEntityMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/SculkShriekerBlockEntityMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net.minecraft.block.entity.SculkShriekerBlockEntity.VibrationCallback") +@Mixin(targets = "net/minecraft/block/entity/SculkShriekerBlockEntity$VibrationCallback") public class SculkShriekerBlockEntityMixin { @Inject(method = "accepts", at = @At(value = "HEAD"), cancellable = true) private void mischief$noRats(ServerWorld world, BlockPos pos, GameEvent event, GameEvent.Context eventContext, CallbackInfoReturnable cir) { diff --git a/src/main/java/ladysnake/ratsmischief/mixin/WardenEntityMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/WardenEntityMixin.java index c61ac6d..e06c988 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/WardenEntityMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/WardenEntityMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(targets = "net.minecraft.entity.mob.warden.WardenEntity.C_xfllwcxz") +@Mixin(targets = "net/minecraft/entity/mob/warden/WardenEntity$C_xfllwcxz") public class WardenEntityMixin { @Inject(method = "accepts", at = @At(value = "HEAD"), cancellable = true) private void mischief$noRats(ServerWorld world, BlockPos pos, GameEvent event, GameEvent.Context eventContext, CallbackInfoReturnable cir) { diff --git a/src/main/java/ladysnake/ratsmischief/mixin/client/HeadFeatureRendererMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/client/HeadFeatureRendererMixin.java index e17c9b6..339ed0a 100644 --- a/src/main/java/ladysnake/ratsmischief/mixin/client/HeadFeatureRendererMixin.java +++ b/src/main/java/ladysnake/ratsmischief/mixin/client/HeadFeatureRendererMixin.java @@ -2,6 +2,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import ladysnake.ratsmischief.common.init.ModItems; import ladysnake.ratsmischief.common.item.RatMasterMaskItem; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.HeadFeatureRenderer; @@ -27,7 +28,7 @@ public class HeadFeatureRendererMixin { @Inject(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"), locals = LocalCapture.CAPTURE_FAILSOFT) private void amarite$maskOffset(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T livingEntity, float f, float g, float h, float j, float k, float l, CallbackInfo ci, ItemStack stack) { - if (stack.getItem() instanceof RatMasterMaskItem) { + if (stack.isOf(ModItems.RAT_MASTER_MASK)) { matrixStack.translate(0, RatMasterMaskItem.getOffset(stack) * 0.1, 0); } } diff --git a/src/main/java/ladysnake/ratsmischief/mixin/mialeemisc/client/ItemRendererMixin.java b/src/main/java/ladysnake/ratsmischief/mixin/mialeemisc/client/ItemRendererMixin.java deleted file mode 100644 index ca56482..0000000 --- a/src/main/java/ladysnake/ratsmischief/mixin/mialeemisc/client/ItemRendererMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package ladysnake.ratsmischief.mixin.mialeemisc.client; - -import ladysnake.ratsmischief.common.init.ModItems; -import net.minecraft.client.render.item.ItemModels; -import net.minecraft.client.render.item.ItemRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.util.ModelIdentifier; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Identifier; -import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Final; -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.CallbackInfoReturnable; - -@Mixin(ItemRenderer.class) -public abstract class ItemRendererMixin { - - @Shadow @Final private ItemModels models; - - @Inject(method = "getHeldItemModel", at = @At("HEAD"), cancellable = true) - private void mialeeMisc$heldItemModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable cir) { - if (ModItems.RAT_MASTER_MASK.equals(stack.getItem())) { - var bakedModel = this.models.getModelManager().getModel(new ModelIdentifier(new Identifier("minecraft:trident_in_hand"), "inventory")); - var clientWorld = world instanceof ClientWorld ? (ClientWorld) world : null; - var bakedModel2 = bakedModel.getOverrides().apply(bakedModel, stack, clientWorld, entity, seed); - cir.setReturnValue(bakedModel2 == null ? this.models.getModelManager().getMissingModel() : bakedModel2); - } - } -} diff --git a/src/main/resources/data/ratsmischief/tags/items/rat_pouches.json b/src/main/resources/data/ratsmischief/tags/items/rat_pouches.json new file mode 100644 index 0000000..78bcd19 --- /dev/null +++ b/src/main/resources/data/ratsmischief/tags/items/rat_pouches.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "ratsmischief:leather_rat_pouch", + "ratsmischief:twisted_rat_pouch", + "ratsmischief:purpur_rat_pouch", + "ratsmischief:rat_master_pouch" + ] +} diff --git a/src/main/resources/ratsmischief.mixins.json b/src/main/resources/ratsmischief.mixins.json index 1e6b6be..b2b680d 100644 --- a/src/main/resources/ratsmischief.mixins.json +++ b/src/main/resources/ratsmischief.mixins.json @@ -23,7 +23,6 @@ "client.HeldItemRendererMixin", "client.ItemEntityRendererMixin", "client.PlayerEntityRendererMixin", - "mialeemisc.client.ItemRendererMixin", "mialeemisc.client.MinecraftClientMixin" ], "injectors": {