From e50d3fc69a1fd1fda5c95dff13ca876b7e9d41d0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 25 Sep 2024 18:29:38 +0200 Subject: [PATCH] a bunch more work on the port --- .../java/de/ellpeck/naturesaura/Helper.java | 12 +- .../de/ellpeck/naturesaura/ModConfig.java | 208 ++++----- .../de/ellpeck/naturesaura/NaturesAura.java | 10 +- .../blocks/BlockAncientSapling.java | 12 +- .../blocks/BlockAnimalGenerator.java | 26 +- .../naturesaura/blocks/BlockAuraTimer.java | 9 +- .../naturesaura/blocks/BlockEnderCrate.java | 19 +- .../naturesaura/blocks/BlockFieldCreator.java | 30 +- .../naturesaura/blocks/BlockGratedChute.java | 25 +- .../blocks/BlockItemDistributor.java | 15 +- .../naturesaura/blocks/BlockNatureAltar.java | 8 +- .../blocks/BlockOfferingTable.java | 9 +- .../naturesaura/blocks/BlockSpawnLamp.java | 8 +- .../naturesaura/blocks/BlockStairsNA.java | 5 +- .../naturesaura/blocks/multi/Multiblocks.java | 154 +++---- .../tiles/BlockEntityAncientLeaves.java | 9 +- .../tiles/BlockEntityAnimalSpawner.java | 42 +- .../blocks/tiles/BlockEntityAuraBloom.java | 9 +- .../blocks/tiles/BlockEntityAuraTimer.java | 28 +- .../blocks/tiles/BlockEntityAutoCrafter.java | 33 +- .../tiles/BlockEntityBlastFurnaceBooster.java | 8 +- .../tiles/BlockEntityChorusGenerator.java | 19 +- .../blocks/tiles/BlockEntityChunkLoader.java | 9 +- .../blocks/tiles/BlockEntityEndFlower.java | 9 +- .../blocks/tiles/BlockEntityEnderCrate.java | 9 +- .../blocks/tiles/BlockEntityFieldCreator.java | 9 +- .../tiles/BlockEntityFlowerGenerator.java | 11 +- .../tiles/BlockEntityFurnaceHeater.java | 27 +- .../blocks/tiles/BlockEntityGratedChute.java | 18 +- .../blocks/tiles/BlockEntityImpl.java | 38 +- .../tiles/BlockEntityItemDistributor.java | 9 +- .../blocks/tiles/BlockEntityNatureAltar.java | 44 +- .../tiles/BlockEntityOfferingTable.java | 21 +- .../tiles/BlockEntityProjectileGenerator.java | 9 +- .../blocks/tiles/BlockEntityRFConverter.java | 9 +- .../tiles/BlockEntitySlimeSplitGenerator.java | 9 +- .../blocks/tiles/BlockEntitySnowCreator.java | 9 +- .../blocks/tiles/BlockEntityTimeChanger.java | 9 +- .../tiles/BlockEntityWeatherChanger.java | 9 +- .../blocks/tiles/BlockEntityWoodStand.java | 39 +- .../blocks/tiles/render/RenderAuraTimer.java | 9 +- .../blocks/tiles/render/RenderEnderCrate.java | 9 +- .../render/RenderGeneratorLimitRemover.java | 11 +- .../tiles/render/RenderLowerLimiter.java | 2 +- .../render/RenderProjectileGenerator.java | 11 +- .../naturesaura/chunk/effect/AngerEffect.java | 3 +- .../chunk/effect/AnimalEffect.java | 19 +- .../chunk/effect/BalanceEffect.java | 2 +- .../chunk/effect/BreathlessEffect.java | 6 +- .../chunk/effect/CacheRechargeEffect.java | 3 +- .../chunk/effect/ExplosionEffect.java | 2 +- .../chunk/effect/GrassDieEffect.java | 9 +- .../chunk/effect/NetherDecayEffect.java | 9 +- .../chunk/effect/NetherGrassEffect.java | 7 +- .../chunk/effect/OreSpawnEffect.java | 8 +- .../chunk/effect/PlantBoostEffect.java | 5 +- .../chunk/effect/ReplenishingEffect.java | 2 +- .../chunk/effect/SpreadEffect.java | 2 +- .../de/ellpeck/naturesaura/compat/Compat.java | 9 +- .../naturesaura/compat/jei/AltarCategory.java | 3 +- .../compat/jei/AnimalSpawnerCategory.java | 10 +- .../compat/jei/JEINaturesAuraPlugin.java | 59 ++- .../compat/jei/OfferingCategory.java | 3 +- .../compat/jei/TreeRitualCategory.java | 2 +- .../compat/patchouli/PatchouliCompat.java | 37 +- .../compat/patchouli/ProcessorAltar.java | 10 +- .../patchouli/ProcessorAnimalSpawner.java | 10 +- .../compat/patchouli/ProcessorOffering.java | 10 +- .../compat/patchouli/ProcessorTreeRitual.java | 11 +- .../naturesaura/data/BlockLootProvider.java | 14 +- .../naturesaura/data/BlockTagProvider.java | 37 +- .../de/ellpeck/naturesaura/data/ModData.java | 3 +- .../enchant/AuraMendingEnchantment.java | 2 +- .../entities/EntityEffectInhibitor.java | 34 +- .../entities/EntityLightProjectile.java | 15 +- .../entities/EntityMoverMinecart.java | 23 +- .../entities/EntityStructureFinder.java | 6 +- .../entities/render/RenderMoverMinecart.java | 11 +- .../naturesaura/events/ClientEvents.java | 189 ++++---- .../naturesaura/events/CommonEvents.java | 33 +- .../ellpeck/naturesaura/gen/ModFeatures.java | 49 +-- .../naturesaura/gui/GuiEnderCrate.java | 2 +- .../naturesaura/items/ItemAuraCache.java | 3 +- .../naturesaura/items/ItemCaveFinder.java | 11 +- .../naturesaura/items/tools/ItemArmor.java | 40 +- .../naturesaura/items/tools/ItemAxe.java | 16 +- .../naturesaura/items/tools/ItemHoe.java | 44 +- .../naturesaura/items/tools/ItemPickaxe.java | 17 +- .../naturesaura/items/tools/ItemShovel.java | 13 +- .../naturesaura/items/tools/ItemSword.java | 2 +- .../naturesaura/misc/ColoredBlockHelper.java | 2 +- .../ellpeck/naturesaura/misc/LevelData.java | 11 +- .../particles/ParticleHandler.java | 26 +- .../naturesaura/particles/ParticleMagic.java | 11 +- .../naturesaura/potion/PotionBreathless.java | 6 +- .../naturesaura/proxy/ClientProxy.java | 37 +- .../naturesaura/recipes/AltarRecipe.java | 40 +- .../recipes/AnimalSpawnerRecipe.java | 42 +- .../naturesaura/recipes/EnabledCondition.java | 7 +- .../naturesaura/recipes/ModRecipe.java | 5 +- .../naturesaura/recipes/ModRecipes.java | 19 +- .../naturesaura/recipes/OfferingRecipe.java | 35 +- .../naturesaura/recipes/TreeRitualRecipe.java | 42 +- .../ellpeck/naturesaura/reg/ModItemTier.java | 20 +- .../ellpeck/naturesaura/reg/ModRegistry.java | 407 +++++++++--------- .../renderers/PlayerLayerTrinkets.java | 7 +- .../renderers/SupporterFancyHandler.java | 32 +- 107 files changed, 1322 insertions(+), 1269 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 6c812907..024e6944 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -6,7 +6,6 @@ import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.misc.ILevelData; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; import de.ellpeck.naturesaura.chunk.AuraChunk; -import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -15,6 +14,8 @@ import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.nbt.IntArrayTag; +import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerPlayer; @@ -367,4 +368,13 @@ public final class Helper { return true; } + public static BlockPos readBlockPos(Tag tag) { + if (tag instanceof IntArrayTag i) { + var arr = i.getAsIntArray(); + if (arr.length == 3) + return new BlockPos(arr[0], arr[1], arr[2]); + } + return null; + } + } diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java index 82114bfb..307fcacf 100644 --- a/src/main/java/de/ellpeck/naturesaura/ModConfig.java +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -54,135 +54,135 @@ public final class ModConfig { public ModConfig(ModConfigSpec.Builder builder) { builder.push("general"); this.additionalBotanistPickaxeConversions = builder - .comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".additionalBotanistPickaxeConversions") - .defineList("additionalBotanistPickaxeConversions", Collections.emptyList(), s -> true); + .comment("Additional conversion recipes for the Botanist's Pickaxe right click function. Each entry needs to be formatted as modid:input_block[prop1=value1,...]->modid:output_block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".additionalBotanistPickaxeConversions") + .defineList("additionalBotanistPickaxeConversions", Collections.emptyList(), () -> "", s -> true); this.auraTypeOverrides = builder - .comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".auraTypeOverrides") - .defineList("auraTypeOverrides", Collections.emptyList(), s -> true); + .comment("Additional dimensions that map to Aura types that should be present in them. This is useful if you have a modpack with custom dimensions that should have Aura act similarly to an existing dimension in them. Each entry needs to be formatted as dimension_name->aura_type, where aura_type can be any of naturesaura:overworld, naturesaura:nether and naturesaura:end, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".auraTypeOverrides") + .defineList("auraTypeOverrides", Collections.emptyList(), () -> "", s -> true); this.additionalOres = builder - .comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as tag_name->oreWeight->dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".additionalOres") - .defineList("additionalOres", Collections.emptyList(), s -> true); + .comment("Additional blocks that are recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as tag_name->oreWeight->dimension where a higher weight makes the ore more likely to spawn with 5000 being the weight of coal, the default ore with the highest weight, and dimension being any of overworld and nether, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".additionalOres") + .defineList("additionalOres", Collections.emptyList(), () -> "", s -> true); this.oreExceptions = builder - .comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".oreExceptions") - .defineList("oreExceptions", Collections.emptyList(), s -> true); + .comment("Blocks that are exempt from being recognized as generatable ores for the passive ore generation effect. Each entry needs to be formatted as modid:block[prop1=value1,...] where block state properties are optional, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".oreExceptions") + .defineList("oreExceptions", Collections.emptyList(), () -> "", s -> true); this.plantBoostExceptions = builder - .comment("Blocks that are exept from being fertilized by the plant boost effect. Each entry needs to be formatted as modid:block, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".plantBoostExceptions") - .defineList("plantBoostExceptions", Collections.emptyList(), s -> true); + .comment("Blocks that are exept from being fertilized by the plant boost effect. Each entry needs to be formatted as modid:block, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".plantBoostExceptions") + .defineList("plantBoostExceptions", Collections.emptyList(), () -> "", s -> true); this.additionalProjectiles = builder - .comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") - .translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles") - .defineList("additionalProjectiles", Collections.emptyList(), s -> true); + .comment("Additional projectile types that are allowed to be consumed by the projectile generator. Each entry needs to be formatted as entity_registry_name->aura_amount, and entries follow standard TOML array formatting (https://toml.io/en/v1.0.0#array).") + .translation("config." + NaturesAura.MOD_ID + ".additionalProjectiles") + .defineList("additionalProjectiles", Collections.emptyList(), () -> "", s -> true); this.fieldCreatorRange = builder - .comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together") - .translation("config." + NaturesAura.MOD_ID + ".fieldCreatorRange") - .define("fieldCreatorRange", 24); + .comment("The amount of blocks that can be between two Aura Field Creators for them to be connectable and work together") + .translation("config." + NaturesAura.MOD_ID + ".fieldCreatorRange") + .define("fieldCreatorRange", 24); this.auraToRFRatio = builder - .comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf") - .translation("config." + NaturesAura.MOD_ID + ".auraToRFRatio") - .define("auraToRFRatio", 0.05); + .comment("The Aura to RF ratio used by the RF converter, read as aura*ratio = rf") + .translation("config." + NaturesAura.MOD_ID + ".auraToRFRatio") + .define("auraToRFRatio", 0.05); this.maxAnimalsAroundPowder = builder - .comment("The maximum amount of animals that can be around the powder of fertility before it stops working") - .translation("config." + NaturesAura.MOD_ID + ".maxAnimalsAroundPowder") - .define("maxAnimalsAroundPowder", 200); + .comment("The maximum amount of animals that can be around the powder of fertility before it stops working") + .translation("config." + NaturesAura.MOD_ID + ".maxAnimalsAroundPowder") + .define("maxAnimalsAroundPowder", 200); this.maxAuraSpreadRange = builder - .comment("The maximum amount of blocks that aura can spread from an initial position before it starts fizzling out. It's recommended to lower this value on a large server to avoid lag caused by players chunk-loading their bases for extended amounts of time without an Aura Detector present.") - .translation("config." + NaturesAura.MOD_ID + ".maxAuraSpreadRange") - .define("maxAuraSpreadRange", 150); + .comment("The maximum amount of blocks that aura can spread from an initial position before it starts fizzling out. It's recommended to lower this value on a large server to avoid lag caused by players chunk-loading their bases for extended amounts of time without an Aura Detector present.") + .translation("config." + NaturesAura.MOD_ID + ".maxAuraSpreadRange") + .define("maxAuraSpreadRange", 150); builder.pop(); builder.push("features"); this.rfConverter = builder - .comment("If the RF converter block should be enabled") - .translation("config." + NaturesAura.MOD_ID + ".rfConverter") - .define("rfConverter", true); + .comment("If the RF converter block should be enabled") + .translation("config." + NaturesAura.MOD_ID + ".rfConverter") + .define("rfConverter", true); this.chunkLoader = builder - .comment("If the chunk loader block should be enabled") - .translation("config." + NaturesAura.MOD_ID + ".chunkLoader") - .define("chunkLoader", true); + .comment("If the chunk loader block should be enabled") + .translation("config." + NaturesAura.MOD_ID + ".chunkLoader") + .define("chunkLoader", true); this.grassDieEffect = builder - .comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur") - .translation("config." + NaturesAura.MOD_ID + ".grassDieEffect") - .define("grassDieEffect", true); + .comment("If the Aura Imbalance effect of grass and trees dying in the area if the Aura levels are too low should occur") + .translation("config." + NaturesAura.MOD_ID + ".grassDieEffect") + .define("grassDieEffect", true); this.netherDecayEffect = builder - .comment("If the Aura Imbalance effect of nether blocks degrading in the area if the Aura levels are too low should occur") - .translation("config." + NaturesAura.MOD_ID + ".netherDecayEffect") - .define("netherDecayEffect", true); + .comment("If the Aura Imbalance effect of nether blocks degrading in the area if the Aura levels are too low should occur") + .translation("config." + NaturesAura.MOD_ID + ".netherDecayEffect") + .define("netherDecayEffect", true); this.plantBoostEffect = builder - .comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur") - .translation("config." + NaturesAura.MOD_ID + ".plantBoostEffect") - .define("plantBoostEffect", true); + .comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur") + .translation("config." + NaturesAura.MOD_ID + ".plantBoostEffect") + .define("plantBoostEffect", true); this.cacheRechargeEffect = builder - .comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur") - .translation("config." + NaturesAura.MOD_ID + ".cacheRechargeEffect") - .define("cacheRechargeEffect", true); + .comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur") + .translation("config." + NaturesAura.MOD_ID + ".cacheRechargeEffect") + .define("cacheRechargeEffect", true); this.explosionEffect = builder - .comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur") - .translation("config." + NaturesAura.MOD_ID + ".explosionEffect") - .define("explosionEffect", true); + .comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur") + .translation("config." + NaturesAura.MOD_ID + ".explosionEffect") + .define("explosionEffect", true); this.breathlessEffect = builder - .comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur") - .translation("config." + NaturesAura.MOD_ID + ".breathlessEffect") - .define("breathlessEffect", true); + .comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur") + .translation("config." + NaturesAura.MOD_ID + ".breathlessEffect") + .define("breathlessEffect", true); this.angerEffect = builder - .comment("If the Aura Imbalance effect of passive mobs being angered if Aura levels are too low should occur") - .translation("config." + NaturesAura.MOD_ID + ".angerEffect") - .define("angerEffect", true); + .comment("If the Aura Imbalance effect of passive mobs being angered if Aura levels are too low should occur") + .translation("config." + NaturesAura.MOD_ID + ".angerEffect") + .define("angerEffect", true); this.animalEffect = builder - .comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur") - .translation("config." + NaturesAura.MOD_ID + ".animalEffect") - .define("animalEffect", true); + .comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur") + .translation("config." + NaturesAura.MOD_ID + ".animalEffect") + .define("animalEffect", true); this.oreEffect = builder - .comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur") - .translation("config." + NaturesAura.MOD_ID + ".oreEffect") - .define("oreEffect", true); + .comment("If the Aura Imbalance effect of ores spawning in the area if Aura levels are too high should occur") + .translation("config." + NaturesAura.MOD_ID + ".oreEffect") + .define("oreEffect", true); this.auraBlooms = builder - .comment("If Aura Blooms and Aura Cacti should generate in the level") - .translation("config." + NaturesAura.MOD_ID + ".auraBlooms") - .define("auraBlooms", true); + .comment("If Aura Blooms and Aura Cacti should generate in the level") + .translation("config." + NaturesAura.MOD_ID + ".auraBlooms") + .define("auraBlooms", true); this.netherGrassEffect = builder - .comment("If the Aura Imbalance effect of grass growing on netherrack if the Aura levels are high enough should occur") - .translation("config." + NaturesAura.MOD_ID + ".netherGrassEffect") - .define("netherGrassEffect", true); + .comment("If the Aura Imbalance effect of grass growing on netherrack if the Aura levels are high enough should occur") + .translation("config." + NaturesAura.MOD_ID + ".netherGrassEffect") + .define("netherGrassEffect", true); builder.pop(); builder.push("client"); this.particleAmount = builder - .comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%") - .translation("config." + NaturesAura.MOD_ID + ".particleAmount") - .defineInRange("particleAmount", 1D, 0, 1); + .comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%") + .translation("config." + NaturesAura.MOD_ID + ".particleAmount") + .defineInRange("particleAmount", 1D, 0, 1); this.respectVanillaParticleSettings = builder - .comment("If particle spawning should respect the particle setting in Minecraft's video settings screen") - .translation("config." + NaturesAura.MOD_ID + ".respectVanillaParticleSettings") - .define("respectVanillaParticleSettings", false); + .comment("If particle spawning should respect the particle setting in Minecraft's video settings screen") + .translation("config." + NaturesAura.MOD_ID + ".respectVanillaParticleSettings") + .define("respectVanillaParticleSettings", false); this.excessParticleAmount = builder - .comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%") - .translation("config." + NaturesAura.MOD_ID + ".excessParticleAmount") - .define("excessParticleAmount", 1D); + .comment("The percentage of particles that should spawn when there is an excess amount of Aura in the environment, where 1 is 100% and 0 is 0%") + .translation("config." + NaturesAura.MOD_ID + ".excessParticleAmount") + .define("excessParticleAmount", 1D); this.auraBarLocation = builder - .comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right") - .translation("config." + NaturesAura.MOD_ID + ".auraBarLocation") - .defineInRange("auraBarLocation", 0, 0, 3); + .comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right") + .translation("config." + NaturesAura.MOD_ID + ".auraBarLocation") + .defineInRange("auraBarLocation", 0, 0, 3); this.cacheBarLocation = builder - .comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar") - .translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation") - .defineInRange("cacheBarLocation", 0, 0, 1); + .comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar") + .translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation") + .defineInRange("cacheBarLocation", 0, 0, 1); this.debugText = builder - .comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode") - .translation("config." + NaturesAura.MOD_ID + ".debugText") - .define("debugText", true); + .comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode") + .translation("config." + NaturesAura.MOD_ID + ".debugText") + .define("debugText", true); this.debugLevel = builder - .comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes") - .translation("config." + NaturesAura.MOD_ID + ".debugLevel") - .define("debugLevel", false); + .comment("If, when the F3 debug menu is open and the player is in creative mode, every Aura spot should be highlighted in the level for debug purposes") + .translation("config." + NaturesAura.MOD_ID + ".debugLevel") + .define("debugLevel", false); this.renderItemsOnPlayer = builder - .comment("If certain equippable items, like the Environmental Eye, should be rendered on the player") - .translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer") - .define("renderItemsOnPlayer", true); + .comment("If certain equippable items, like the Environmental Eye, should be rendered on the player") + .translation("config." + NaturesAura.MOD_ID + ".renderItemsOnPlayer") + .define("renderItemsOnPlayer", true); builder.pop(); } @@ -191,21 +191,21 @@ public final class ModConfig { throw new IllegalStateException("Nature's Aura has detected that all negative Aura Imbalance effects are disabled in the config file. This is disallowed behavior. Please enable at least one negative effect."); try { - for (String s : this.additionalBotanistPickaxeConversions.get()) { + for (var s : this.additionalBotanistPickaxeConversions.get()) { var split = s.split("->"); NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( - Objects.requireNonNull(Helper.getStateFromString(split[0]), "state1"), - Objects.requireNonNull(Helper.getStateFromString(split[1]), "state2")); + Objects.requireNonNull(Helper.getStateFromString(split[0]), "state1"), + Objects.requireNonNull(Helper.getStateFromString(split[1]), "state2")); } } catch (Exception e) { NaturesAura.LOGGER.warn("Error parsing additionalBotanistPickaxeConversions", e); } try { - for (String s : this.auraTypeOverrides.get()) { + for (var s : this.auraTypeOverrides.get()) { var split = s.split("->"); - var dim = new ResourceLocation(split[0]); - var type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(new ResourceLocation(split[1])), "type"); + var dim = ResourceLocation.parse(split[0]); + var type = Objects.requireNonNull((BasicAuraType) NaturesAuraAPI.AURA_TYPES.get(ResourceLocation.parse(split[1])), "type"); type.addDimensionType(dim); } } catch (Exception e) { @@ -213,9 +213,9 @@ public final class ModConfig { } try { - for (String s : this.additionalOres.get()) { + for (var s : this.additionalOres.get()) { var split = s.split("->"); - var ore = new WeightedOre(new ResourceLocation(split[0]), Integer.parseInt(split[1])); + var ore = new WeightedOre(ResourceLocation.parse(split[0]), Integer.parseInt(split[1])); var dimension = split[2]; if ("nether".equalsIgnoreCase(dimension)) { NaturesAuraAPI.NETHER_ORES.removeIf(o -> o.tag.equals(ore.tag)); @@ -232,7 +232,7 @@ public final class ModConfig { } try { - for (String s : this.oreExceptions.get()) + for (var s : this.oreExceptions.get()) OreSpawnEffect.SPAWN_EXCEPTIONS.add(Objects.requireNonNull(Helper.getStateFromString(s))); } catch (Exception e) { NaturesAura.LOGGER.warn("Error parsing oreExceptions", e); @@ -240,7 +240,7 @@ public final class ModConfig { try { for (var s : this.plantBoostExceptions.get()) - PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(BuiltInRegistries.BLOCK.get(new ResourceLocation(s)))); + PlantBoostEffect.EXCEPTIONS.add(Objects.requireNonNull(BuiltInRegistries.BLOCK.get(ResourceLocation.parse(s)))); } catch (Exception e) { NaturesAura.LOGGER.warn("Error parsing plantBoostExceptions", e); @@ -249,7 +249,7 @@ public final class ModConfig { try { for (var s : this.additionalProjectiles.get()) { var split = s.split("->"); - var name = new ResourceLocation(split[0]); + var name = ResourceLocation.parse(split[0]); var type = Objects.requireNonNull(BuiltInRegistries.ENTITY_TYPE.get(name)); var amount = Integer.parseInt(split[1]); NaturesAuraAPI.PROJECTILE_GENERATIONS.put(type, amount); diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 93ed2ab1..499c9f7e 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -10,8 +10,7 @@ import de.ellpeck.naturesaura.proxy.ClientProxy; import de.ellpeck.naturesaura.proxy.IProxy; import de.ellpeck.naturesaura.proxy.ServerProxy; import de.ellpeck.naturesaura.recipes.ModRecipes; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.fml.ModLoadingContext; +import net.neoforged.fml.ModContainer; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.fml.loading.FMLEnvironment; @@ -30,15 +29,16 @@ public final class NaturesAura { public static NaturesAura instance; public static IProxy proxy; - public NaturesAura(IEventBus eventBus) { + public NaturesAura(ModContainer container) { NaturesAura.instance = this; NaturesAura.proxy = FMLEnvironment.dist.isClient() ? new ClientProxy() : new ServerProxy(); - eventBus.addListener(this::setup); + container.getEventBus().addListener(this::setup); + container.getEventBus().register(NaturesAura.proxy); var builder = new ModConfigSpec.Builder(); ModConfig.instance = new ModConfig(builder); - ModLoadingContext.get().registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, builder.build()); + container.registerConfig(net.neoforged.fml.config.ModConfig.Type.COMMON, builder.build()); } public void setup(FMLCommonSetupEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 58162db5..4b551b1b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; @@ -19,11 +18,9 @@ import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.neoforged.neoforge.event.EventHooks; -import net.neoforged.bus.api.Event; public class BlockAncientSapling extends BushBlock implements BonemealableBlock, IModItem, ICustomBlockState, ICustomItemModel { @@ -75,9 +72,12 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, public void performBonemeal(ServerLevel level, RandomSource rand, BlockPos pos, BlockState state) { if (state.getValue(SaplingBlock.STAGE) == 0) { level.setBlock(pos, state.cycle(SaplingBlock.STAGE), 4); - } else if (!EventHooks.blockGrowFeature(level, rand, pos, null).getResult().equals(Event.Result.DENY)) { - Registry> registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE); - registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos); + } else { + var event = EventHooks.fireBlockGrowFeature(level, rand, pos, null); + if (!event.isCanceled()) { + var registry = level.registryAccess().registryOrThrow(Registries.CONFIGURED_FEATURE); + registry.getHolderOrThrow(ModFeatures.Configured.ANCIENT_TREE).value().place(level, level.getChunkSource().getGenerator(), rand, pos); + } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java index 75cf5b06..97a88a12 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java @@ -17,11 +17,12 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.phys.AABB; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.common.NeoForge; -import net.neoforged.neoforge.event.entity.living.*; -import net.neoforged.neoforge.event.entity.living.LivingExperienceDropEvent; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.neoforge.event.entity.living.LivingEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.entity.living.LivingDeathEvent; +import net.neoforged.neoforge.event.entity.living.LivingDropsEvent; +import net.neoforged.neoforge.event.entity.living.LivingExperienceDropEvent; +import net.neoforged.neoforge.event.tick.EntityTickEvent; public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { @@ -32,7 +33,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali } @SubscribeEvent - public void onLivingUpdate(LivingEvent.LivingTickEvent event) { + public void onLivingUpdate(EntityTickEvent event) { var entity = event.getEntity(); if (entity.level().isClientSide || entity.level().getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Npc) return; @@ -70,10 +71,10 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali var genPos = gen.getBlockPos(); PacketHandler.sendToAllAround(entity.level(), pos, 32, new PacketParticles( - (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME, - child ? 1 : 0, - (int) (entity.getEyeHeight() * 10F), - genPos.getX(), genPos.getY(), genPos.getZ())); + (float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.ANIMAL_GEN_CONSUME, + child ? 1 : 0, + (int) (entity.getEyeHeight() * 10F), + genPos.getX(), genPos.getY(), genPos.getZ())); return true; }); @@ -108,8 +109,9 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), - generator.modLoc("block/" + this.getBaseName()), - generator.modLoc("block/" + this.getBaseName() + "_bottom"), - generator.modLoc("block/" + this.getBaseName() + "_top"))); + generator.modLoc("block/" + this.getBaseName()), + generator.modLoc("block/" + this.getBaseName() + "_bottom"), + generator.modLoc("block/" + this.getBaseName() + "_top"))); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java index cd641f45..35135203 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraTimer.java @@ -13,8 +13,9 @@ import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -52,9 +53,8 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult p_225533_6_) { - return Helper.putStackOnTile(player, handIn, pos, 0, true); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + return Helper.putStackOnTile(player, hand, pos, 0, true); } @Override @@ -80,4 +80,5 @@ public class BlockAuraTimer extends BlockContainerImpl implements ICustomBlockSt public void registerTESR() { BlockEntityRenderers.register(ModBlockEntities.AURA_TIMER, RenderAuraTimer::new); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java index 6ded3dda..7f97c504 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java @@ -20,6 +20,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.TooltipFlag; @@ -85,10 +86,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - if (!levelIn.isClientSide) { - var tile = levelIn.getBlockEntity(pos); + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + if (!level.isClientSide) { + var tile = level.getBlockEntity(pos); if (tile instanceof BlockEntityEnderCrate crate && crate.canOpen() && crate.canUseRightNow(2500)) { crate.drainAura(2500); player.openMenu(crate, pos); @@ -98,9 +98,8 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider } @Override - @OnlyIn(Dist.CLIENT) - public void appendHoverText(ItemStack stack, @Nullable BlockGetter levelIn, List tooltip, TooltipFlag flagIn) { - BlockEnderCrate.addEnderNameInfo(stack, tooltip); + public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltipComponents, TooltipFlag tooltipFlag) { + BlockEnderCrate.addEnderNameInfo(stack, tooltipComponents); } @Override @@ -122,9 +121,9 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), - generator.modLoc("block/" + this.getBaseName()), - generator.modLoc("block/" + this.getBaseName() + "_bottom"), - generator.modLoc("block/" + this.getBaseName() + "_top"))); + generator.modLoc("block/" + this.getBaseName()), + generator.modLoc("block/" + this.getBaseName() + "_bottom"), + generator.modLoc("block/" + this.getBaseName() + "_top"))); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java index 48620c32..2b54d894 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java @@ -9,8 +9,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; @@ -25,11 +26,10 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult result) { - var tile = levelIn.getBlockEntity(pos); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + var tile = level.getBlockEntity(pos); if (tile instanceof BlockEntityFieldCreator) { - if (!levelIn.isClientSide) { + if (!level.isClientSide) { var key = NaturesAura.MOD_ID + ":field_creator_pos"; var compound = player.getPersistentData(); if (!player.isShiftKeyDown() && compound.contains(key)) { @@ -37,7 +37,7 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc var creator = (BlockEntityFieldCreator) tile; if (!pos.equals(stored)) { if (creator.isCloseEnough(stored)) { - var otherTile = levelIn.getBlockEntity(stored); + var otherTile = level.getBlockEntity(stored); if (otherTile instanceof BlockEntityFieldCreator otherCreator) { creator.connectionOffset = stored.subtract(pos); creator.isMain = true; @@ -60,9 +60,9 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc player.displayClientMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".stored_pos"), true); } } - return InteractionResult.SUCCESS; + return ItemInteractionResult.SUCCESS; } else - return InteractionResult.FAIL; + return ItemInteractionResult.FAIL; } @Override @@ -73,13 +73,13 @@ public class BlockFieldCreator extends BlockContainerImpl implements ICustomBloc var connected = creator.getConnectedPos(); if (connected != null) NaturesAuraAPI.instance().spawnParticleStream( - pos.getX() + 0.25F + rand.nextFloat() * 0.5F, - pos.getY() + 0.25F + rand.nextFloat() * 0.5F, - pos.getZ() + 0.25F + rand.nextFloat() * 0.5F, - connected.getX() + 0.25F + rand.nextFloat() * 0.5F, - connected.getY() + 0.25F + rand.nextFloat() * 0.5F, - connected.getZ() + 0.25F + rand.nextFloat() * 0.5F, - 0.65F, 0x4245f4, 1F + pos.getX() + 0.25F + rand.nextFloat() * 0.5F, + pos.getY() + 0.25F + rand.nextFloat() * 0.5F, + pos.getZ() + 0.25F + rand.nextFloat() * 0.5F, + connected.getX() + 0.25F + rand.nextFloat() * 0.5F, + connected.getY() + 0.25F + rand.nextFloat() * 0.5F, + connected.getZ() + 0.25F + rand.nextFloat() * 0.5F, + 0.65F, 0x4245f4, 1F ); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java index 9ad54945..adbc857a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java @@ -8,7 +8,6 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.util.Mth; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; @@ -18,7 +17,6 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.HopperBlock; import net.minecraft.world.level.block.RenderShape; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.block.entity.Hopper; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.DirectionProperty; @@ -28,27 +26,27 @@ import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.neoforged.neoforge.capabilities.Capabilities; -import net.neoforged.neoforge.items.IItemHandler; import javax.annotation.Nullable; public class BlockGratedChute extends BlockContainerImpl implements ICustomBlockState, ICustomItemModel { public static final DirectionProperty FACING = HopperBlock.FACING; + private static final VoxelShape INSIDE = Block.box(2.0, 11.0, 2.0, 14.0, 16.0, 14.0); private static final VoxelShape INPUT_SHAPE = Block.box(0.0D, 10.0D, 0.0D, 16.0D, 16.0D, 16.0D); private static final VoxelShape MIDDLE_SHAPE = Block.box(4.0D, 4.0D, 4.0D, 12.0D, 10.0D, 12.0D); private static final VoxelShape INPUT_MIDDLE_SHAPE = Shapes.or(BlockGratedChute.MIDDLE_SHAPE, BlockGratedChute.INPUT_SHAPE); - private static final VoxelShape COMBINED_SHAPE = Shapes.join(BlockGratedChute.INPUT_MIDDLE_SHAPE, Hopper.INSIDE, BooleanOp.ONLY_FIRST); + private static final VoxelShape COMBINED_SHAPE = Shapes.join(BlockGratedChute.INPUT_MIDDLE_SHAPE, BlockGratedChute.INSIDE, BooleanOp.ONLY_FIRST); private static final VoxelShape DOWN_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 0.0D, 6.0D, 10.0D, 4.0D, 10.0D)); private static final VoxelShape EAST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(12.0D, 4.0D, 6.0D, 16.0D, 8.0D, 10.0D)); private static final VoxelShape NORTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 0.0D, 10.0D, 8.0D, 4.0D)); private static final VoxelShape SOUTH_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(6.0D, 4.0D, 12.0D, 10.0D, 8.0D, 16.0D)); private static final VoxelShape WEST_SHAPE = Shapes.or(BlockGratedChute.COMBINED_SHAPE, Block.box(0.0D, 4.0D, 6.0D, 4.0D, 8.0D, 10.0D)); - private static final VoxelShape DOWN_RAYTRACE_SHAPE = Hopper.INSIDE; - private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); - private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); - private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); - private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(Hopper.INSIDE, Block.box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); + private static final VoxelShape DOWN_RAYTRACE_SHAPE = BlockGratedChute.INSIDE; + private static final VoxelShape EAST_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(12.0D, 8.0D, 6.0D, 16.0D, 10.0D, 10.0D)); + private static final VoxelShape NORTH_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(6.0D, 8.0D, 0.0D, 10.0D, 10.0D, 4.0D)); + private static final VoxelShape SOUTH_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(6.0D, 8.0D, 12.0D, 10.0D, 10.0D, 16.0D)); + private static final VoxelShape WEST_RAYTRACE_SHAPE = Shapes.or(BlockGratedChute.INSIDE, Block.box(0.0D, 8.0D, 6.0D, 4.0D, 10.0D, 10.0D)); public BlockGratedChute() { super("grated_chute", BlockEntityGratedChute.class, Properties.of().strength(3.0F, 8.0F).sound(SoundType.METAL)); @@ -81,17 +79,16 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock case SOUTH -> BlockGratedChute.SOUTH_RAYTRACE_SHAPE; case WEST -> BlockGratedChute.WEST_RAYTRACE_SHAPE; case EAST -> BlockGratedChute.EAST_RAYTRACE_SHAPE; - default -> Hopper.INSIDE; + default -> BlockGratedChute.INSIDE; }; } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - var tile = levelIn.getBlockEntity(pos); + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { + var tile = level.getBlockEntity(pos); if (!(tile instanceof BlockEntityGratedChute chute)) return InteractionResult.FAIL; - if (!levelIn.isClientSide) { + if (!level.isClientSide) { chute.isBlacklist = !chute.isBlacklist; chute.sendToClients(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java index 66facef7..d235aac3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockItemDistributor.java @@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityItemDistributor; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; -import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; @@ -19,14 +18,13 @@ public class BlockItemDistributor extends BlockContainerImpl implements ICustomB } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (!player.isShiftKeyDown()) return InteractionResult.FAIL; - var tile = levelIn.getBlockEntity(pos); + var tile = level.getBlockEntity(pos); if (!(tile instanceof BlockEntityItemDistributor)) return InteractionResult.FAIL; - if (!levelIn.isClientSide) { + if (!level.isClientSide) { var distributor = (BlockEntityItemDistributor) tile; distributor.isRandomMode = !distributor.isRandomMode; distributor.sendToClients(); @@ -37,8 +35,9 @@ public class BlockItemDistributor extends BlockContainerImpl implements ICustomB @Override public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(), - generator.modLoc("block/" + this.getBaseName()), - generator.modLoc("block/" + this.getBaseName() + "_bottom"), - generator.modLoc("block/" + this.getBaseName() + "_top"))); + generator.modLoc("block/" + this.getBaseName()), + generator.modLoc("block/" + this.getBaseName() + "_bottom"), + generator.modLoc("block/" + this.getBaseName() + "_top"))); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index 21d948b8..94555386 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -10,8 +10,9 @@ import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -41,9 +42,8 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return Helper.putStackOnTile(player, handIn, pos, 0, true); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + return Helper.putStackOnTile(player, hand, pos, 0, true); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java index f9951038..7c2cee79 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java @@ -10,8 +10,9 @@ import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; +import net.minecraft.world.ItemInteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; @@ -35,9 +36,8 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi } @Override - @SuppressWarnings("deprecation") - public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { - return Helper.putStackOnTile(player, handIn, pos, 0, true); + protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) { + return Helper.putStackOnTile(player, hand, pos, 0, true); } @Override @@ -55,4 +55,5 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi public void registerTESR() { BlockEntityRenderers.register(ModBlockEntities.OFFERING_TABLE, RenderOfferingTable::new); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java index 42932483..04f7bc1e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java @@ -22,10 +22,9 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.entity.living.MobSpawnEvent; -import net.neoforged.bus.api.Event; -import net.neoforged.bus.api.SubscribeEvent; public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, ICustomBlockState { @@ -69,10 +68,10 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, IAuraChunk.getAuraChunk(level, spot).drainAura(spot, amountToUse); PacketHandler.sendToAllAround(level, lampPos, 32, - new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP)); + new PacketParticles(lampPos.getX(), lampPos.getY(), lampPos.getZ(), PacketParticles.Type.SPAWN_LAMP)); } - event.setResult(Event.Result.DENY); + event.setResult(MobSpawnEvent.PositionCheck.Result.FAIL); break; } } @@ -105,4 +104,5 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java index 01513050..eb4b568e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockStairsNA.java @@ -8,14 +8,12 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.StairBlock; import net.minecraft.world.level.block.state.BlockState; -import java.util.function.Supplier; - public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockState { public final String textureName; private final String baseName; - public BlockStairsNA(String baseName, String textureName, Supplier modelState, Block.Properties properties) { + public BlockStairsNA(String baseName, String textureName, BlockState modelState, Block.Properties properties) { super(modelState, properties.dynamicShape()); this.baseName = baseName; this.textureName = textureName; @@ -31,4 +29,5 @@ public class BlockStairsNA extends StairBlock implements IModItem, ICustomBlockS public void generateCustomBlockState(BlockStateGenerator generator) { generator.stairsBlock(this, generator.modLoc("block/" + this.textureName)); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java index b21220c5..1354dd42 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -16,88 +16,88 @@ import net.minecraft.world.level.block.SaplingBlock; public final class Multiblocks { public static final IMultiblock ALTAR = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "altar"), - new String[][]{ - {" M ", " ", " ", " ", "M M", " ", " ", " ", " M "}, - {" B ", " ", " ", " ", "B B", " ", " ", " ", " B "}, - {" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "}, - {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}, - 'C', Matcher.tag(Blocks.CHISELED_STONE_BRICKS, BlockTagProvider.ALTAR_FANCY_BRICK), - 'B', Matcher.tag(Blocks.STONE_BRICKS, BlockTagProvider.ALTAR_STONE), - 'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTagProvider.ALTAR_WOOD), - 'M', Matcher.tag(ModBlocks.GOLD_BRICK, BlockTagProvider.ALTAR_GOLD_BRICK), - '0', ModBlocks.NATURE_ALTAR, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar"), + new String[][]{ + {" M ", " ", " ", " ", "M M", " ", " ", " ", " M "}, + {" B ", " ", " ", " ", "B B", " ", " ", " ", " B "}, + {" B ", " ", " M M ", " ", "B 0 B", " ", " M M ", " ", " B "}, + {" ", " WBW ", " WBW ", " WWCWCWW ", " BBW WBB ", " WWCWCWW ", " WBW ", " WBW ", " "}}, + 'C', Matcher.tag(Blocks.CHISELED_STONE_BRICKS, BlockTagProvider.ALTAR_FANCY_BRICK), + 'B', Matcher.tag(Blocks.STONE_BRICKS, BlockTagProvider.ALTAR_STONE), + 'W', Matcher.tag(Blocks.OAK_PLANKS, BlockTagProvider.ALTAR_WOOD), + 'M', Matcher.tag(ModBlocks.GOLD_BRICK, BlockTagProvider.ALTAR_GOLD_BRICK), + '0', ModBlocks.NATURE_ALTAR, + ' ', Matcher.any()); public static final IMultiblock TREE_RITUAL = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), - new String[][]{ - {" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}}, - 'W', new Matcher(ModBlocks.WOOD_STAND.defaultBlockState(), - (level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND), - 'G', ModBlocks.GOLD_POWDER, - '0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(), - (level, start, offset, pos, state, c) -> { - if (state.getBlock() instanceof SaplingBlock || state.is(BlockTags.LOGS)) - return true; - // try-catch to prevent blocks that need to have been placed crashing here - try { - var stack = new ItemStack(state.getBlock()); - return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.value().saplingType.test(stack)); - } catch (Exception e) { - return false; - } - } - ), - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "tree_ritual"), + new String[][]{ + {" W ", " W W ", " GGG ", " GG GG ", "W G 0 G W", " GG GG ", " GGG ", " W W ", " W "}}, + 'W', new Matcher(ModBlocks.WOOD_STAND.defaultBlockState(), + (level, start, offset, pos, state, c) -> level != null || state.getBlock() == ModBlocks.WOOD_STAND), + 'G', ModBlocks.GOLD_POWDER, + '0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(), + (level, start, offset, pos, state, c) -> { + if (state.getBlock() instanceof SaplingBlock || state.is(BlockTags.LOGS)) + return true; + // try-catch to prevent blocks that need to have been placed crashing here + try { + var stack = new ItemStack(state.getBlock()); + return !stack.isEmpty() && level.getRecipeManager().getRecipesFor(ModRecipes.TREE_RITUAL_TYPE, null, level).stream().anyMatch(r -> r.value().saplingType.test(stack)); + } catch (Exception e) { + return false; + } + } + ), + ' ', Matcher.any()); public static final IMultiblock POTION_GENERATOR = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "potion_generator"), - new String[][]{ - {"R R", " ", " ", " ", " ", " ", "R R"}, - {"N N", " ", " ", " ", " ", " ", "N N"}, - {"N N", " ", " ", " 0 ", " ", " ", "N N"}, - {" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}}, - 'N', Blocks.NETHER_BRICKS, - 'R', Blocks.RED_NETHER_BRICKS, - '0', ModBlocks.POTION_GENERATOR, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "potion_generator"), + new String[][]{ + {"R R", " ", " ", " ", " ", " ", "R R"}, + {"N N", " ", " ", " ", " ", " ", "N N"}, + {"N N", " ", " ", " 0 ", " ", " ", "N N"}, + {" N N ", "NNN NNN", " NRRRN ", " R R ", " NRRRN ", "NNN NNN", " N N "}}, + 'N', Blocks.NETHER_BRICKS, + 'R', Blocks.RED_NETHER_BRICKS, + '0', ModBlocks.POTION_GENERATOR, + ' ', Matcher.any()); public static final IMultiblock OFFERING_TABLE = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "offering_table"), - new String[][]{ - {" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}}, - 'R', new Matcher(Blocks.POPPY.defaultBlockState(), - (level, start, offset, pos, state, c) -> state.is(BlockTags.SMALL_FLOWERS)), - '0', ModBlocks.OFFERING_TABLE, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "offering_table"), + new String[][]{ + {" RRRRR ", " R R ", "R RRR R", "R R R R", "R R 0 R R", "R R R R", "R RRR R", " R R ", " RRRRR "}}, + 'R', new Matcher(Blocks.POPPY.defaultBlockState(), + (level, start, offset, pos, state, c) -> state.is(BlockTags.SMALL_FLOWERS)), + '0', ModBlocks.OFFERING_TABLE, + ' ', Matcher.any()); public static final IMultiblock ANIMAL_SPAWNER = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), - new String[][]{ - {" ", " ", " ", " 0 ", " ", " ", " "}, - {" HHH ", " HRRRH ", "HRWRWRH", "HRR RRH", "HRWRWRH", " HRRRH ", " HHH "}}, - 'H', Blocks.HAY_BLOCK, - 'R', ModBlocks.INFUSED_BRICK, - 'W', ModBlocks.ANCIENT_PLANKS, - '0', ModBlocks.ANIMAL_SPAWNER, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "animal_spawner"), + new String[][]{ + {" ", " ", " ", " 0 ", " ", " ", " "}, + {" HHH ", " HRRRH ", "HRWRWRH", "HRR RRH", "HRWRWRH", " HRRRH ", " HHH "}}, + 'H', Blocks.HAY_BLOCK, + 'R', ModBlocks.INFUSED_BRICK, + 'W', ModBlocks.ANCIENT_PLANKS, + '0', ModBlocks.ANIMAL_SPAWNER, + ' ', Matcher.any()); public static final IMultiblock AUTO_CRAFTER = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "auto_crafter"), - new String[][]{ - {"PPPPPPP", "PLPLPLP", "PPPPPPP", "PLP0PLP", "PPPPPPP", "PLPLPLP", "PPPPPPP"}}, - 'P', ModBlocks.ANCIENT_PLANKS, - 'L', ModBlocks.ANCIENT_LOG, - '0', ModBlocks.AUTO_CRAFTER, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "auto_crafter"), + new String[][]{ + {"PPPPPPP", "PLPLPLP", "PPPPPPP", "PLP0PLP", "PPPPPPP", "PLPLPLP", "PPPPPPP"}}, + 'P', ModBlocks.ANCIENT_PLANKS, + 'L', ModBlocks.ANCIENT_LOG, + '0', ModBlocks.AUTO_CRAFTER, + ' ', Matcher.any()); public static final IMultiblock RF_CONVERTER = NaturesAuraAPI.instance().createMultiblock( - new ResourceLocation(NaturesAura.MOD_ID, "rf_converter"), - new String[][]{ - {" ", " ", " ", " R ", " ", " ", " "}, - {" ", " R ", " ", " R R ", " ", " R ", " "}, - {" ", " ", " ", " ", " ", " ", " "}, - {" R ", " R R ", " ", "R 0 R", " ", " R R ", " R "}, - {" ", " ", " ", " ", " ", " ", " "}, - {" ", " R ", " ", " R R ", " ", " R ", " "}, - {" ", " ", " ", " R ", " ", " ", " "}}, - 'R', Blocks.REDSTONE_BLOCK, - '0', ModBlocks.RF_CONVERTER, - ' ', Matcher.any()); + ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "rf_converter"), + new String[][]{ + {" ", " ", " ", " R ", " ", " ", " "}, + {" ", " R ", " ", " R R ", " ", " R ", " "}, + {" ", " ", " ", " ", " ", " ", " "}, + {" R ", " R R ", " ", "R 0 R", " ", " R R ", " R "}, + {" ", " ", " ", " ", " ", " ", " "}, + {" ", " R ", " ", " R R ", " ", " R ", " "}, + {" ", " ", " ", " R ", " ", " ", " "}}, + 'R', Blocks.REDSTONE_BLOCK, + '0', ModBlocks.RF_CONVERTER, + ' ', Matcher.any()); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java index c60ac5c6..5bad2dab 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAncientLeaves.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.state.BlockState; @@ -29,15 +30,15 @@ public class BlockEntityAncientLeaves extends BlockEntityImpl { } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) this.container.writeNBT(compound); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) this.container.readNBT(compound); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java index a7628897..583d84a6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java @@ -10,6 +10,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -21,7 +22,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickableBlockEntity { @@ -69,7 +69,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab } } else { var items = this.level.getEntitiesOfClass(ItemEntity.class, - new AABB(this.worldPosition).inflate(2)); + new AABB(this.worldPosition).inflate(2)); for (var recipe : this.level.getRecipeManager().getRecipesFor(ModRecipes.ANIMAL_SPAWNER_TYPE, null, this.level)) { if (recipe.value().ingredients.size() != items.size()) @@ -94,7 +94,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab for (var item : items) { item.remove(Entity.RemovalReason.KILLED); PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER)); + new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER)); } this.currentRecipe = recipe; @@ -113,15 +113,15 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab } NaturesAuraAPI.instance().spawnParticleStream( - this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F, - this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F, - this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F, - this.worldPosition.getX() + this.level.random.nextFloat(), - this.worldPosition.getY() + this.level.random.nextFloat(), - this.worldPosition.getZ() + this.level.random.nextFloat(), - this.level.random.nextFloat() * 0.07F + 0.07F, - IAuraType.forLevel(this.level).getColor(), - this.level.random.nextFloat() + 0.5F); + this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F, + this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F, + this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F, + this.worldPosition.getX() + this.level.random.nextFloat(), + this.worldPosition.getY() + this.level.random.nextFloat(), + this.worldPosition.getZ() + this.level.random.nextFloat(), + this.level.random.nextFloat() * 0.07F + 0.07F, + IAuraType.forLevel(this.level).getColor(), + this.level.random.nextFloat() + 0.5F); if (this.entityClient == null) { this.entityClient = this.currentRecipe.value().makeEntity(this.level, BlockPos.ZERO); @@ -130,16 +130,16 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab var bounds = this.entityClient.getBoundingBox(); for (var i = this.level.random.nextInt(5) + 5; i >= 0; i--) NaturesAuraAPI.instance().spawnMagicParticle( - bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX), - bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY), - bounds.minZ + this.level.random.nextFloat() * (bounds.maxZ - bounds.minZ), - 0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true); + bounds.minX + this.level.random.nextFloat() * (bounds.maxX - bounds.minX), + bounds.minY + this.level.random.nextFloat() * (bounds.maxY - bounds.minY), + bounds.minZ + this.level.random.nextFloat() * (bounds.maxZ - bounds.minZ), + 0F, 0F, 0F, 0x2fd8d3, 2F, 60, 0F, false, true); } } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (this.currentRecipe != null) { compound.putString("recipe", this.currentRecipe.id().toString()); @@ -152,12 +152,12 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab @SuppressWarnings("unchecked") @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (compound.contains("recipe")) { if (this.hasLevel()) { - var name = new ResourceLocation(compound.getString("recipe")); + var name = ResourceLocation.parse(compound.getString("recipe")); this.currentRecipe = (RecipeHolder) this.level.getRecipeManager().byKey(name).orElse(null); } this.spawnX = compound.getDouble("spawn_x"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraBloom.java index 6cb67d7d..6dbcc870 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraBloom.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; @@ -27,15 +28,15 @@ public class BlockEntityAuraBloom extends BlockEntityImpl implements ITickableBl } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) compound.putBoolean("just_generated", this.justGenerated); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) this.justGenerated = compound.getBoolean("just_generated"); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java index a61ca66a..430519b7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAuraTimer.java @@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; @@ -18,9 +19,9 @@ import java.util.Map; public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBlockEntity { private static final Map TIMES = ImmutableMap.builder() - .put(NaturesAuraAPI.TYPE_OVERWORLD, 20) - .put(NaturesAuraAPI.TYPE_NETHER, 20 * 60) - .put(NaturesAuraAPI.TYPE_END, 20 * 60 * 60).build(); + .put(NaturesAuraAPI.TYPE_OVERWORLD, 20) + .put(NaturesAuraAPI.TYPE_NETHER, 20 * 60) + .put(NaturesAuraAPI.TYPE_END, 20 * 60 * 60).build(); public final ItemStackHandlerNA itemHandler = new ItemStackHandlerNA(1, this, true) { @Override protected boolean canInsert(ItemStack stack, int slot) { @@ -56,10 +57,10 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl if (this.level.getGameTime() % 8 == 0) { var color = ItemAuraBottle.getType(this.itemHandler.getStackInSlot(0)).getColor(); NaturesAuraAPI.instance().spawnMagicParticle( - this.worldPosition.getX() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, - this.worldPosition.getY() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, - this.worldPosition.getZ() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, - 0, 0, 0, color, 1, 80 + this.level.random.nextInt(50), 0, false, true); + this.worldPosition.getX() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, + this.worldPosition.getY() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, + this.worldPosition.getZ() + 1 / 16F + this.level.random.nextFloat() * 14 / 16F, + 0, 0, 0, color, 1, 80 + this.level.random.nextInt(50), 0, false, true); } return; } @@ -98,20 +99,21 @@ public class BlockEntityAuraTimer extends BlockEntityImpl implements ITickableBl } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { - compound.put("items", this.itemHandler.serializeNBT()); + compound.put("items", this.itemHandler.serializeNBT(registries)); compound.putInt("timer", this.timer); } } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { - this.itemHandler.deserializeNBT(compound.getCompound("items")); + this.itemHandler.deserializeNBT(registries, compound.getCompound("items")); this.timer = compound.getInt("timer"); } } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java index 8bb68e7c..2b0b2610 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java @@ -49,26 +49,26 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable var topPos = middlePos.relative(facing, 2); var bottomPos = middlePos.relative(facing.getOpposite(), 2); var poses = new BlockPos[]{ - topPos.relative(facing.getCounterClockWise(), 2), - topPos, - topPos.relative(facing.getClockWise(), 2), - middlePos.relative(facing.getCounterClockWise(), 2), - middlePos, - middlePos.relative(facing.getClockWise(), 2), - bottomPos.relative(facing.getCounterClockWise(), 2), - bottomPos, - bottomPos.relative(facing.getClockWise(), 2) + topPos.relative(facing.getCounterClockWise(), 2), + topPos, + topPos.relative(facing.getClockWise(), 2), + middlePos.relative(facing.getCounterClockWise(), 2), + middlePos, + middlePos.relative(facing.getClockWise(), 2), + bottomPos.relative(facing.getCounterClockWise(), 2), + bottomPos, + bottomPos.relative(facing.getClockWise(), 2) }; var items = new ItemEntity[9]; for (var i = 0; i < poses.length; i++) { var entities = this.level.getEntitiesOfClass( - ItemEntity.class, new AABB(poses[i]).inflate(0.25), EntitySelector.ENTITY_STILL_ALIVE); + ItemEntity.class, new AABB(poses[i]).inflate(0.25), EntitySelector.ENTITY_STILL_ALIVE); if (entities.size() > 1) return; if (entities.isEmpty()) continue; - var entity = entities.get(0); + var entity = entities.getFirst(); if (entity.hasPickUpDelay()) return; var stack = entity.getItem(); @@ -78,19 +78,19 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable this.crafting.setItem(i, stack.copy()); } - var recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.crafting, this.level).orElse(null); + var recipe = this.level.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.crafting.asCraftInput(), this.level).orElse(null); if (recipe == null) return; - var result = recipe.value().assemble(this.crafting, this.level.registryAccess()); + var result = recipe.value().assemble(this.crafting.asCraftInput(), this.level.registryAccess()); if (result.isEmpty()) return; var resultItem = new ItemEntity(this.level, - this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy()); + this.worldPosition.getX() + 0.5F, this.worldPosition.getY() - 0.35F, this.worldPosition.getZ() + 0.5F, result.copy()); resultItem.setDeltaMovement(0, 0, 0); this.level.addFreshEntity(resultItem); - var remainingItems = recipe.value().getRemainingItems(this.crafting); + var remainingItems = recipe.value().getRemainingItems(this.crafting.asCraftInput()); for (var i = 0; i < items.length; i++) { var item = items[i]; if (item == null) @@ -111,8 +111,9 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable } PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER)); + new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.ANIMAL_SPAWNER)); } } } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java index 9a37dd2a..019d2238 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java @@ -8,6 +8,7 @@ import net.minecraft.core.Direction; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.neoforge.capabilities.Capabilities; @@ -35,7 +36,8 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I var below = this.level.getBlockEntity(this.worldPosition.below()); if (!(below instanceof BlastFurnaceBlockEntity tile)) return; - Recipe recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), tile, this.level).orElse(null).value(); + var input = new SingleRecipeInput(tile.getItem(0)); + Recipe recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(tile), input, this.level).orElse(null).value(); if (recipe == null) return; if (!this.isApplicable(recipe.getIngredients())) @@ -48,7 +50,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I if (this.level.random.nextFloat() > 0.45F) { PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0)); + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 0)); return; } @@ -67,7 +69,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I IAuraChunk.getAuraChunk(this.level, pos).drainAura(pos, toUse); PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); + new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.BLAST_FURNACE_BOOSTER, 1)); } private boolean isApplicable(List ingredients) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChorusGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChorusGenerator.java index 13eb8f21..b95ed61a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChorusGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChorusGenerator.java @@ -1,9 +1,11 @@ package de.ellpeck.naturesaura.blocks.tiles; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtUtils; @@ -43,7 +45,7 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), PacketParticles.Type.CHORUS_GENERATOR, pos.getX(), pos.getY(), pos.getZ())); this.level.removeBlock(pos, false); this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, - SoundEvents.CHORUS_FRUIT_TELEPORT, SoundSource.BLOCKS, 0.5F, 1F); + SoundEvents.CHORUS_FRUIT_TELEPORT, SoundSource.BLOCKS, 0.5F, 1F); this.generateAura(this.auraPerBlock); } @@ -97,8 +99,8 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) { var list = new ListTag(); for (var pos : this.currentlyBreaking) @@ -109,14 +111,15 @@ public class BlockEntityChorusGenerator extends BlockEntityImpl implements ITick } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) { this.currentlyBreaking.clear(); - var list = compound.getList("breaking", 10); - for (var i = 0; i < list.size(); i++) - this.currentlyBreaking.add(NbtUtils.readBlockPos(list.getCompound(i))); + var list = compound.getList("breaking", ListTag.TAG_INT_ARRAY); + for (var tag : list) + this.currentlyBreaking.add(Helper.readBlockPos(tag)); this.auraPerBlock = compound.getInt("aura"); } } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java index 93c719fa..daf2aa2c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityChunkLoader.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; @@ -108,15 +109,15 @@ public class BlockEntityChunkLoader extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) compound.putLongArray("forced_chunks", this.forcedChunks.stream().map(ChunkPos::toLong).collect(Collectors.toList())); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) { this.forcedChunks.clear(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEndFlower.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEndFlower.java index 03af68af..147fd418 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEndFlower.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEndFlower.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.item.ItemEntity; @@ -94,8 +95,8 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { this.container.writeNBT(compound); compound.putBoolean("drain_mode", this.isDrainMode); @@ -103,8 +104,8 @@ public class BlockEntityEndFlower extends BlockEntityImpl implements ITickableBl } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { this.container.readNBT(compound); this.isDrainMode = compound.getBoolean("drain_mode"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java index 5f7c8e99..f6267fdb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityEnderCrate.java @@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.gui.ContainerEnderCrate; import de.ellpeck.naturesaura.gui.ModContainers; import net.minecraft.ChatFormatting; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; @@ -110,8 +111,8 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (this.name != null) compound.putString("name", this.name); @@ -119,8 +120,8 @@ public class BlockEntityEnderCrate extends BlockEntityImpl implements MenuProvid } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (compound.contains("name")) this.name = compound.getString("name"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java index 1d8674d1..d2a29bf0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; @@ -175,8 +176,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (this.connectionOffset != null) compound.putLong("connection", this.connectionOffset.asLong()); @@ -189,8 +190,8 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { if (compound.contains("connection")) this.connectionOffset = BlockPos.of(compound.getLong("connection")); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java index 474dfa56..c1f43817 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFlowerGenerator.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -96,8 +97,8 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.SYNC && !this.consumedRecently.isEmpty()) { var list = new ListTag(); @@ -115,14 +116,14 @@ public class BlockEntityFlowerGenerator extends BlockEntityImpl implements ITick } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.SYNC) { this.consumedRecently.clear(); var list = compound.getList("consumed_recently", 10); for (var base : list) { var tag = (CompoundTag) base; - var block = BuiltInRegistries.BLOCK.get(new ResourceLocation(tag.getString("block"))); + var block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse(tag.getString("block"))); if (block != null) this.consumedRecently.put(block.defaultBlockState(), new MutableInt(tag.getInt("amount"))); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java index b7b2e71e..9f07aa5b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java @@ -8,11 +8,13 @@ import de.ellpeck.naturesaura.blocks.BlockFurnaceHeater; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; import net.minecraft.world.inventory.ContainerData; import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.SingleRecipeInput; import net.minecraft.world.level.block.AbstractFurnaceBlock; import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity; import net.minecraft.world.level.block.entity.BlastFurnaceBlockEntity; @@ -77,13 +79,13 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab if (this.level.getGameTime() % 15 == 0) { PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( - this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F, - this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F, - this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F, - tilePos.getX() + this.level.random.nextFloat(), - tilePos.getY() + this.level.random.nextFloat(), - tilePos.getZ() + this.level.random.nextFloat(), - this.level.random.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.random.nextFloat() + 0.5F + this.worldPosition.getX() + (float) this.level.random.nextGaussian() * 5F, + this.worldPosition.getY() + 1 + this.level.random.nextFloat() * 5F, + this.worldPosition.getZ() + (float) this.level.random.nextGaussian() * 5F, + tilePos.getX() + this.level.random.nextFloat(), + tilePos.getY() + this.level.random.nextFloat(), + tilePos.getZ() + this.level.random.nextFloat(), + this.level.random.nextFloat() * 0.07F + 0.07F, IAuraType.forLevel(this.level).getColor(), this.level.random.nextFloat() + 0.5F )); } } @@ -102,7 +104,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab var input = furnace.getItem(0); if (!input.isEmpty()) { - var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), furnace, this.level).orElse(null); + var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), new SingleRecipeInput(input), this.level).orElse(null); if (recipe == null) return false; var output = recipe.value().getResultItem(this.level.registryAccess()); @@ -113,16 +115,16 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.SYNC) compound.putBoolean("active", this.isActive); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.SYNC) this.isActive = compound.getBoolean("active"); @@ -132,4 +134,5 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab public boolean allowsLowerLimiter() { return true; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityGratedChute.java index 907c650d..8eae1d56 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityGratedChute.java @@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.blocks.BlockGratedChute; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.item.ItemStack; @@ -64,8 +65,8 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable pull: if (curr.isEmpty() || curr.getCount() < curr.getMaxStackSize()) { var items = this.level.getEntitiesOfClass(ItemEntity.class, new AABB( - this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(), - this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1)); + this.worldPosition.getX(), this.worldPosition.getY() + 0.5, this.worldPosition.getZ(), + this.worldPosition.getX() + 1, this.worldPosition.getY() + 2, this.worldPosition.getZ() + 1)); for (var item : items) { if (!item.isAlive()) continue; @@ -119,24 +120,23 @@ public class BlockEntityGratedChute extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { compound.putInt("cooldown", this.cooldown); - compound.put("items", this.items.serializeNBT()); + compound.put("items", this.items.serializeNBT(registries)); compound.putBoolean("blacklist", this.isBlacklist); } } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { this.cooldown = compound.getInt("cooldown"); - this.items.deserializeNBT(compound.getCompound("items")); + this.items.deserializeNBT(registries, compound.getCompound("items")); this.isBlacklist = compound.getBoolean("blacklist"); } } - } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityImpl.java index 8cd5b193..c03b9f3a 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityImpl.java @@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.Connection; import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; @@ -25,25 +26,25 @@ public class BlockEntityImpl extends BlockEntity { } @Override - public void saveAdditional(CompoundTag compound) { - this.writeNBT(compound, SaveType.TILE); + public void saveAdditional(CompoundTag compound, HolderLookup.Provider registries) { + this.writeNBT(compound, SaveType.TILE, registries); } @Override - public void load(CompoundTag compound) { - this.readNBT(compound, SaveType.TILE); + protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { + this.readNBT(tag, SaveType.TILE, registries); } - public void writeNBT(CompoundTag compound, SaveType type) { + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { if (type != SaveType.BLOCK) { - super.saveAdditional(compound); + super.saveAdditional(compound, registries); compound.putInt("redstone", this.redstonePower); } } - public void readNBT(CompoundTag compound, SaveType type) { + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { if (type != SaveType.BLOCK) { - super.load(compound); + super.loadWithComponents(compound, registries); this.redstonePower = compound.getInt("redstone"); } } @@ -54,29 +55,28 @@ public class BlockEntityImpl extends BlockEntity { @Override public final ClientboundBlockEntityDataPacket getUpdatePacket() { - return ClientboundBlockEntityDataPacket.create(this, e -> { + return ClientboundBlockEntityDataPacket.create(this, (e, r) -> { var compound = new CompoundTag(); - this.writeNBT(compound, SaveType.SYNC); + this.writeNBT(compound, SaveType.SYNC, r); return compound; }); } @Override - public final CompoundTag getUpdateTag() { + public final CompoundTag getUpdateTag(HolderLookup.Provider registries) { var compound = new CompoundTag(); - this.writeNBT(compound, SaveType.SYNC); + this.writeNBT(compound, SaveType.SYNC, registries); return compound; } @Override - public void handleUpdateTag(CompoundTag tag) { - this.readNBT(tag, SaveType.SYNC); + public void handleUpdateTag(CompoundTag tag, HolderLookup.Provider registries) { + this.readNBT(tag, SaveType.SYNC, registries); } @Override - public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { - super.onDataPacket(net, pkt); - this.readNBT(pkt.getTag(), SaveType.SYNC); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt, HolderLookup.Provider registries) { + this.readNBT(pkt.getTag(), SaveType.SYNC, registries); } public void sendToClients() { @@ -102,7 +102,7 @@ public class BlockEntityImpl extends BlockEntity { public void modifyDrop(ItemStack regularItem) { var compound = new CompoundTag(); - this.writeNBT(compound, SaveType.BLOCK); + this.writeNBT(compound, SaveType.BLOCK, this.getLevel().registryAccess()); if (!compound.isEmpty()) { if (!regularItem.hasTag()) regularItem.setTag(new CompoundTag()); @@ -114,7 +114,7 @@ public class BlockEntityImpl extends BlockEntity { if (stack.hasTag()) { var compound = stack.getTag().getCompound("data"); if (compound != null) - this.readNBT(compound, SaveType.BLOCK); + this.readNBT(compound, SaveType.BLOCK, this.level.registryAccess()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityItemDistributor.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityItemDistributor.java index 65b7f12a..f2fe0f3b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityItemDistributor.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityItemDistributor.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; @@ -83,8 +84,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) { compound.putInt("cooldown", this.cooldown); compound.putInt("side", this.currentSide.ordinal()); @@ -94,8 +95,8 @@ public class BlockEntityItemDistributor extends BlockEntityImpl implements ITick } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) { this.cooldown = compound.getInt("cooldown"); this.currentSide = Direction.values()[compound.getInt("side")]; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityNatureAltar.java index 55fb852d..5376a3a4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityNatureAltar.java @@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer; -import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -12,7 +11,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.recipes.AltarRecipe; import de.ellpeck.naturesaura.recipes.ModRecipes; import net.minecraft.core.BlockPos; -import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; @@ -24,7 +23,6 @@ import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.items.IItemHandlerModifiable; import net.neoforged.neoforge.items.ItemStackHandler; public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickableBlockEntity { @@ -110,11 +108,11 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable if (this.level.getGameTime() % 3 == 0) PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( - this.worldPosition.getX() + (float) rand.nextGaussian() * 10F, - this.worldPosition.getY() + rand.nextFloat() * 10F, - this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F, - this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F, - rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F + this.worldPosition.getX() + (float) rand.nextGaussian() * 10F, + this.worldPosition.getY() + rand.nextFloat() * 10F, + this.worldPosition.getZ() + (float) rand.nextGaussian() * 10F, + this.worldPosition.getX() + 0.5F, this.worldPosition.getY() + 0.5F, this.worldPosition.getZ() + 0.5F, + rand.nextFloat() * 0.1F + 0.1F, this.container.getAuraColor(), rand.nextFloat() + 1F )); } } @@ -173,23 +171,23 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable var fourths = this.container.getMaxAura() / 4; if (this.container.getStoredAura() > 0) { NaturesAuraAPI.instance().spawnMagicParticle( - this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), - 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); + this.worldPosition.getX() - 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), + 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths) { NaturesAuraAPI.instance().spawnMagicParticle( - this.worldPosition.getX() + 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), - 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); + this.worldPosition.getX() + 4F + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + rand.nextFloat(), + 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 2) { NaturesAuraAPI.instance().spawnMagicParticle( - this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() - 4F + rand.nextFloat(), - 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); + this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() - 4F + rand.nextFloat(), + 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 3) { NaturesAuraAPI.instance().spawnMagicParticle( - this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + 4F + rand.nextFloat(), - 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); + this.worldPosition.getX() + rand.nextFloat(), this.worldPosition.getY() + 3F, this.worldPosition.getZ() + 4F + rand.nextFloat(), + 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } } @@ -215,10 +213,10 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { - compound.put("items", this.items.serializeNBT()); + compound.put("items", this.items.serializeNBT(registries)); compound.putBoolean("complete", this.isComplete); this.container.writeNBT(compound); } @@ -232,17 +230,17 @@ public class BlockEntityNatureAltar extends BlockEntityImpl implements ITickable @SuppressWarnings("unchecked") @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { - this.items.deserializeNBT(compound.getCompound("items")); + this.items.deserializeNBT(registries, compound.getCompound("items")); this.isComplete = compound.getBoolean("complete"); this.container.readNBT(compound); } if (type == SaveType.TILE) { if (compound.contains("recipe")) { if (this.hasLevel()) - this.currentRecipe = (RecipeHolder) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null); + this.currentRecipe = (RecipeHolder) this.level.getRecipeManager().byKey(ResourceLocation.parse(compound.getString("recipe"))).orElse(null); this.timer = compound.getInt("timer"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOfferingTable.java index 12f32d07..d82ae2fc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityOfferingTable.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.recipes.ModRecipes; import de.ellpeck.naturesaura.recipes.OfferingRecipe; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.world.entity.EntityType; @@ -92,8 +93,8 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab lightningboltentity.moveTo(Vec3.atCenterOf(this.worldPosition)); this.level.addFreshEntity(lightningboltentity); PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticles( - (float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.OFFERING_TABLE, - this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ())); + (float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.OFFERING_TABLE, + this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ())); break; } @@ -105,31 +106,31 @@ public class BlockEntityOfferingTable extends BlockEntityImpl implements ITickab } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { - compound.put("items", this.items.serializeNBT()); + compound.put("items", this.items.serializeNBT(registries)); if (type != SaveType.SYNC) { var list = new ListTag(); for (var stack : this.itemsToSpawn) - list.add(stack.save(new CompoundTag())); + list.add(stack.save(registries, new CompoundTag())); compound.put("items_to_spawn", list); } } } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { - this.items.deserializeNBT(compound.getCompound("items")); + this.items.deserializeNBT(registries, compound.getCompound("items")); if (type != SaveType.SYNC) { this.itemsToSpawn.clear(); var list = compound.getList("items_to_spawn", 10); for (var base : list) - this.itemsToSpawn.add(ItemStack.of((CompoundTag) base)); + this.itemsToSpawn.add(ItemStack.parseOptional(registries, (CompoundTag) base)); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityProjectileGenerator.java index aae95624..bd8042cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityProjectileGenerator.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.level.block.state.BlockState; @@ -14,15 +15,15 @@ public class BlockEntityProjectileGenerator extends BlockEntityImpl { } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) compound.putInt("next_side", this.nextSide.ordinal()); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) this.nextSide = Direction.values()[compound.getInt("next_side")]; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityRFConverter.java index da646d5c..3e9e5c7b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityRFConverter.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; import net.minecraft.world.level.block.state.BlockState; @@ -23,14 +24,14 @@ public class BlockEntityRFConverter extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); compound.putInt("energy", this.storage.getEnergyStored()); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); this.storage.setEnergy(compound.getInt("energy")); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java index 57b524ee..6fae936f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySlimeSplitGenerator.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.monster.MagmaCube; import net.minecraft.world.entity.monster.Slime; @@ -52,8 +53,8 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) { compound.putInt("timer", this.generationTimer); compound.putInt("amount", this.amountToRelease); @@ -62,8 +63,8 @@ public class BlockEntitySlimeSplitGenerator extends BlockEntityImpl implements I } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) { this.generationTimer = compound.getInt("timer"); this.amountToRelease = compound.getInt("amount"); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java index 47ad2b35..ae5722f0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; @@ -96,15 +97,15 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type == SaveType.TILE) compound.putInt("snowman_count", this.snowmanCount); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type == SaveType.TILE) this.snowmanCount = compound.getInt("snowman_count"); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java index b458021f..c8dbd500 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityTimeChanger.java @@ -6,6 +6,7 @@ import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.game.ClientboundSetTimePacket; import net.minecraft.server.level.ServerLevel; @@ -106,15 +107,15 @@ public class BlockEntityTimeChanger extends BlockEntityImpl implements ITickable } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) compound.putLong("goal", this.goalTime); } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) this.goalTime = compound.getLong("goal"); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWeatherChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWeatherChanger.java index 7354f0bc..ddbb4214 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWeatherChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWeatherChanger.java @@ -5,6 +5,7 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.misc.WeatherType; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; @@ -88,8 +89,8 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) { compound.putInt("time", this.processTime); if (this.type != null) @@ -99,8 +100,8 @@ public class BlockEntityWeatherChanger extends BlockEntityImpl implements ITicka } @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) { this.processTime = compound.getInt("time"); this.type = WeatherType.values()[compound.getInt("weather")]; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java index baefc512..0a55fefc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityWoodStand.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; @@ -61,18 +62,18 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl var tile = this.level.getBlockEntity(pos); if (tile instanceof BlockEntityWoodStand && !((BlockEntityWoodStand) tile).items.getStackInSlot(0).isEmpty()) { PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, new PacketParticleStream( - (float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F, - (float) pos.getY() + 0.85F, - (float) pos.getZ() + 0.2F + this.level.random.nextFloat() * 0.6F, - this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.random.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F, - this.level.random.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.random.nextFloat() + 1F + (float) pos.getX() + 0.2F + this.level.random.nextFloat() * 0.6F, + (float) pos.getY() + 0.85F, + (float) pos.getZ() + 0.2F + this.level.random.nextFloat() * 0.6F, + this.ritualPos.getX() + 0.5F, this.ritualPos.getY() + this.level.random.nextFloat() * 3F + 2F, this.ritualPos.getZ() + 0.5F, + this.level.random.nextFloat() * 0.04F + 0.04F, 0x89cc37, this.level.random.nextFloat() + 1F )); } return true; }); PacketHandler.sendToAllAround(this.level, this.ritualPos, 32, - new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER)); + new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER)); if (this.timer >= this.recipe.value().time) { Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> { @@ -82,14 +83,14 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl Helper.mineRecursively(this.level, this.ritualPos, this.ritualPos, ItemStack.EMPTY, 6, 32, s -> s.is(BlockTags.LOGS) || s.getBlock() instanceof LeavesBlock); var item = new ItemEntity(this.level, - this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5, - this.recipe.value().output.copy()); + this.ritualPos.getX() + 0.5, this.ritualPos.getY() + 4.5, this.ritualPos.getZ() + 0.5, + this.recipe.value().output.copy()); this.level.addFreshEntity(item); PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.TR_SPAWN_RESULT)); + new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.TR_SPAWN_RESULT)); this.level.playSound(null, this.worldPosition.getX() + 0.5, this.worldPosition.getY() + 0.5, this.worldPosition.getZ() + 0.5, - SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 0.65F, 1F); + SoundEvents.ENDERMAN_TELEPORT, SoundSource.BLOCKS, 0.65F, 1F); this.ritualPos = null; this.recipe = null; @@ -99,9 +100,9 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl var tile = this.level.getBlockEntity(pos); if (tile instanceof BlockEntityWoodStand stand && !stand.items.getStackInSlot(0).isEmpty()) { PacketHandler.sendToAllAround(this.level, this.worldPosition, 32, - new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM)); + new PacketParticles(stand.worldPosition.getX(), stand.worldPosition.getY(), stand.worldPosition.getZ(), PacketParticles.Type.TR_CONSUME_ITEM)); this.level.playSound(null, stand.worldPosition.getX() + 0.5, stand.worldPosition.getY() + 0.5, stand.worldPosition.getZ() + 0.5, - SoundEvents.WOOD_STEP, SoundSource.BLOCKS, 0.5F, 1F); + SoundEvents.WOOD_STEP, SoundSource.BLOCKS, 0.5F, 1F); stand.items.setStackInSlot(0, ItemStack.EMPTY); stand.sendToClients(); @@ -154,10 +155,10 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl } @Override - public void writeNBT(CompoundTag compound, SaveType type) { - super.writeNBT(compound, type); + public void writeNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.writeNBT(compound, type, registries); if (type != SaveType.BLOCK) - compound.put("items", this.items.serializeNBT()); + compound.put("items", this.items.serializeNBT(registries)); if (type == SaveType.TILE) { if (this.ritualPos != null && this.recipe != null) { @@ -170,17 +171,17 @@ public class BlockEntityWoodStand extends BlockEntityImpl implements ITickableBl @SuppressWarnings("unchecked") @Override - public void readNBT(CompoundTag compound, SaveType type) { - super.readNBT(compound, type); + public void readNBT(CompoundTag compound, SaveType type, HolderLookup.Provider registries) { + super.readNBT(compound, type, registries); if (type != SaveType.BLOCK) - this.items.deserializeNBT(compound.getCompound("items")); + this.items.deserializeNBT(registries, compound.getCompound("items")); if (type == SaveType.TILE) { if (compound.contains("recipe")) { this.ritualPos = BlockPos.of(compound.getLong("ritual_pos")); this.timer = compound.getInt("timer"); if (this.hasLevel()) - this.recipe = (RecipeHolder) this.level.getRecipeManager().byKey(new ResourceLocation(compound.getString("recipe"))).orElse(null); + this.recipe = (RecipeHolder) this.level.getRecipeManager().byKey(ResourceLocation.parse(compound.getString("recipe"))).orElse(null); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java index 55b591b8..542a952d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderAuraTimer.java @@ -16,11 +16,12 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.FastColor; import net.neoforged.neoforge.capabilities.Capabilities; public class RenderAuraTimer implements BlockEntityRenderer { - private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png"); + private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/aura_timer_aura.png"); private final AuraModel model = new AuraModel(); public RenderAuraTimer(BlockEntityRendererProvider.Context context) { @@ -41,7 +42,7 @@ public class RenderAuraTimer implements BlockEntityRenderer> 16 & 255) / 255F; var g = (type.getColor() >> 8 & 255) / 255F; var b = (type.getColor() & 255) / 255F; - this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderAuraTimer.RES)), combinedLightIn, combinedOverlayIn, r, g, b, 0.75F); + this.model.renderToBuffer(stack, buffer.getBuffer(this.model.renderType(RenderAuraTimer.RES)), combinedLightIn, combinedOverlayIn, FastColor.ARGB32.colorFromFloat(r, g, b, 0.75F)); stack.popPose(); } @@ -59,8 +60,8 @@ public class RenderAuraTimer implements BlockEntityRenderer { - private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png"); + private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/generator_limit_remover_glint.png"); private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint(); public RenderGeneratorLimitRemover(BlockEntityRendererProvider.Context context) { @@ -46,7 +47,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer { - private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/lower_limiter_glint.png"); + private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/lower_limiter_glint.png"); private final ModelLimitRemoverGlint model = new ModelLimitRemoverGlint(); public RenderLowerLimiter(BlockEntityRendererProvider.Context context) {} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java index f7a86872..8066e954 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderProjectileGenerator.java @@ -17,13 +17,14 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.FastColor; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class RenderProjectileGenerator implements BlockEntityRenderer { - private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png"); + private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/projectile_generator_overlay.png"); private final ModelOverlay model = new ModelOverlay(); public RenderProjectileGenerator(BlockEntityRendererProvider.Context context) { @@ -46,7 +47,7 @@ public class RenderProjectileGenerator implements BlockEntityRenderer e != first && !e.isInLove() && !e.isBaby()) - .min(Comparator.comparingDouble(e -> e.distanceToSqr(first))); + .filter(e -> e != first && !e.isInLove() && !e.isBaby()) + .min(Comparator.comparingDouble(e -> e.distanceToSqr(first))); if (secondOptional.isEmpty()) return; var second = secondOptional.get(); @@ -133,12 +133,12 @@ public class AnimalEffect implements IDrainSpotEffect { animal.setInLove(null); for (var j = 0; j < 7; j++) animal.level().addParticle(ParticleTypes.HEART, - animal.getX() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(), - animal.getY() + 0.5D + (double) (animal.level().random.nextFloat() * animal.getBbHeight()), - animal.getZ() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(), - animal.level().random.nextGaussian() * 0.02D, - animal.level().random.nextGaussian() * 0.02D, - animal.level().random.nextGaussian() * 0.02D); + animal.getX() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(), + animal.getY() + 0.5D + (double) (animal.level().random.nextFloat() * animal.getBbHeight()), + animal.getZ() + (double) (animal.level().random.nextFloat() * animal.getBbWidth() * 2.0F) - animal.getBbWidth(), + animal.level().random.nextGaussian() * 0.02D, + animal.level().random.nextGaussian() * 0.02D, + animal.level().random.nextGaussian() * 0.02D); } @Override @@ -150,4 +150,5 @@ public class AnimalEffect implements IDrainSpotEffect { public ResourceLocation getName() { return AnimalEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java index 400539c0..9eba248d 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BalanceEffect.java @@ -13,7 +13,7 @@ import org.apache.commons.lang3.mutable.MutableInt; public class BalanceEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "balance"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "balance"); @Override public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java index d3289c5b..f14651b7 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/BreathlessEffect.java @@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.potion.ModPotions; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffectInstance; @@ -21,7 +22,7 @@ import net.minecraft.world.phys.AABB; public class BreathlessEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "breathless"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "breathless"); private int amp; private AABB bb; @@ -62,7 +63,7 @@ public class BreathlessEffect implements IDrainSpotEffect { return; var entities = level.getEntitiesOfClass(LivingEntity.class, this.bb); for (var entity : entities) - entity.addEffect(new MobEffectInstance(ModPotions.BREATHLESS, 300, this.amp)); + entity.addEffect(new MobEffectInstance(Holder.direct(ModPotions.BREATHLESS), 300, this.amp)); } @Override @@ -74,4 +75,5 @@ public class BreathlessEffect implements IDrainSpotEffect { public ResourceLocation getName() { return BreathlessEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java index fd6588b6..86be70db 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/CacheRechargeEffect.java @@ -19,7 +19,7 @@ import net.minecraft.world.phys.AABB; public class CacheRechargeEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "cache_recharge"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "cache_recharge"); private int amount; private AABB bb; @@ -77,4 +77,5 @@ public class CacheRechargeEffect implements IDrainSpotEffect { public ResourceLocation getName() { return CacheRechargeEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java index 1c2e1fed..e9a1961f 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ExplosionEffect.java @@ -20,7 +20,7 @@ import net.neoforged.neoforge.event.EventHooks; public class ExplosionEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "explosions"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "explosions"); private float strength; private int dist; diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java index a3bfba60..64c3f8fc 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java @@ -23,7 +23,7 @@ import net.minecraft.world.level.chunk.LevelChunk; public class GrassDieEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "grass_die"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "grass_die"); private int amount; private int dist; @@ -63,9 +63,9 @@ public class GrassDieEffect implements IDrainSpotEffect { return; for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) { var grassPos = BlockPos.containing( - pos.getX() + level.random.nextGaussian() * this.dist, - pos.getY() + level.random.nextGaussian() * this.dist, - pos.getZ() + level.random.nextGaussian() * this.dist + pos.getX() + level.random.nextGaussian() * this.dist, + pos.getY() + level.random.nextGaussian() * this.dist, + pos.getZ() + level.random.nextGaussian() * this.dist ); if (grassPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(grassPos)) { var state = level.getBlockState(grassPos); @@ -96,4 +96,5 @@ public class GrassDieEffect implements IDrainSpotEffect { public ResourceLocation getName() { return GrassDieEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java index 1b224698..4fe5347c 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java @@ -23,7 +23,7 @@ import net.minecraft.world.level.chunk.LevelChunk; public class NetherDecayEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nether_decay"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "nether_decay"); private int amount; private int dist; @@ -62,9 +62,9 @@ public class NetherDecayEffect implements IDrainSpotEffect { return; for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) { var offset = BlockPos.containing( - pos.getX() + level.random.nextGaussian() * this.dist, - pos.getY() + level.random.nextGaussian() * this.dist, - pos.getZ() + level.random.nextGaussian() * this.dist); + pos.getX() + level.random.nextGaussian() * this.dist, + pos.getY() + level.random.nextGaussian() * this.dist, + pos.getZ() + level.random.nextGaussian() * this.dist); if (offset.distSqr(pos) > this.dist * this.dist || !level.isLoaded(offset)) continue; @@ -101,4 +101,5 @@ public class NetherDecayEffect implements IDrainSpotEffect { public ResourceLocation getName() { return NetherDecayEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java index 1d3ff388..df15e503 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java @@ -22,7 +22,7 @@ import net.neoforged.neoforge.common.Tags; public class NetherGrassEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nether_grass"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "nether_grass"); private int amount; private int dist; @@ -78,14 +78,14 @@ public class NetherGrassEffect implements IDrainSpotEffect { continue; var state = level.getBlockState(goalPos); - if (state.is(Tags.Blocks.NETHERRACK)) { + if (state.is(Tags.Blocks.NETHERRACKS)) { level.setBlockAndUpdate(goalPos, ModBlocks.NETHER_GRASS.defaultBlockState()); var closestSpot = IAuraChunk.getHighestSpot(level, goalPos, 25, pos); IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 500); PacketHandler.sendToAllAround(level, goalPos, 32, - new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST)); + new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST)); break; } } @@ -102,4 +102,5 @@ public class NetherGrassEffect implements IDrainSpotEffect { public ResourceLocation getName() { return NetherGrassEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java index bf3289f4..d2a61dc5 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -39,7 +39,7 @@ import java.util.Set; public class OreSpawnEffect implements IDrainSpotEffect { public static final Set SPAWN_EXCEPTIONS = new HashSet<>(); - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "ore_spawn"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "ore_spawn"); private int amount; private int dist; @@ -93,7 +93,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { var totalWeight = WeightedRandom.getTotalWeight(ores); var powders = NaturesAuraAPI.instance().getActiveEffectPowders(level, - new AABB(pos).inflate(this.dist), OreSpawnEffect.NAME); + new AABB(pos).inflate(this.dist), OreSpawnEffect.NAME); if (powders.isEmpty()) return; for (var i = 0; i < this.amount; i++) { @@ -105,7 +105,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { var z = Mth.floor(powderPos.z + level.random.nextGaussian() * range); var orePos = new BlockPos(x, y, z); if (orePos.distToCenterSqr(powderPos.x, powderPos.y, powderPos.z) <= range * range - && orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) { + && orePos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(orePos)) { var state = level.getBlockState(orePos); if (state.getBlock() != requiredBlock) continue; @@ -149,7 +149,7 @@ public class OreSpawnEffect implements IDrainSpotEffect { @Override public boolean appliesHere(LevelChunk chunk, IAuraChunk auraChunk, IAuraType type) { return ModConfig.instance.oreEffect.get() && - (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER)); + (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java index dfc2526c..9ab5c3eb 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java @@ -28,7 +28,7 @@ import java.util.Set; public class PlantBoostEffect implements IDrainSpotEffect { public static final Set EXCEPTIONS = new HashSet<>(List.of(Blocks.GRASS_BLOCK, Blocks.MOSS_BLOCK, Blocks.GLOW_LICHEN, Blocks.SMALL_DRIPLEAF, Blocks.BIG_DRIPLEAF, Blocks.BIG_DRIPLEAF_STEM)); - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "plant_boost"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "plant_boost"); private int amount; private int dist; @@ -90,7 +90,7 @@ public class PlantBoostEffect implements IDrainSpotEffect { IAuraChunk.getAuraChunk(level, closestSpot).drainAura(closestSpot, 3500); PacketHandler.sendToAllAround(level, plantPos, 32, - new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), PacketParticles.Type.PLANT_BOOST)); + new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), PacketParticles.Type.PLANT_BOOST)); } } } @@ -106,4 +106,5 @@ public class PlantBoostEffect implements IDrainSpotEffect { public ResourceLocation getName() { return PlantBoostEffect.NAME; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java index 903438fa..352fc218 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/ReplenishingEffect.java @@ -18,7 +18,7 @@ import java.util.List; public class ReplenishingEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "replenishing"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "replenishing"); @Override public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) { diff --git a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java index 21d3b700..8567b9e6 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/SpreadEffect.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.chunk.LevelChunk; public class SpreadEffect implements IDrainSpotEffect { - public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "spread"); + public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "spread"); @Override public void update(Level level, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot, AuraChunk.DrainSpot actualSpot) { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java index bf2769ed..384d536f 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java @@ -18,10 +18,11 @@ public final class Compat { @SuppressWarnings("Convert2MethodRef") // bleh classloading compat issues private static final Map> MODULE_TYPES = ImmutableMap.>builder() - .put("patchouli", () -> new PatchouliCompat()) - .put("curios", () -> new CuriosCompat()) - //.put("enchantability", EnchantibilityCompat::new) - .build(); + .put("patchouli", () -> new PatchouliCompat()) + // TODO curios? + //.put("curios", () -> new CuriosCompat()) + //.put("enchantability", EnchantibilityCompat::new) + .build(); private static final Map MODULES = new HashMap<>(); public static void setup(FMLCommonSetupEvent event) { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java index 8613d937..a1c6d55f 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AltarCategory.java @@ -24,7 +24,7 @@ public class AltarCategory implements IRecipeCategory { private final ItemStack altar = new ItemStack(ModBlocks.NATURE_ALTAR); public AltarCategory(IGuiHelper helper) { - this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/altar.png"), 0, 0, 103, 57); + this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/altar.png"), 0, 0, 103, 57); } @Override @@ -53,4 +53,5 @@ public class AltarCategory implements IRecipeCategory { builder.addSlot(RecipeIngredientRole.OUTPUT, 81, 19).addItemStack(recipe.output); builder.addSlot(RecipeIngredientRole.CATALYST, 38, 19).addItemStacks(recipe.catalyst == Ingredient.EMPTY ? Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getItems())); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java index fe132e8d..29ea4af2 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java @@ -24,7 +24,6 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; -import net.neoforged.neoforge.common.DeferredSpawnEggItem; import java.util.Arrays; import java.util.HashMap; @@ -36,15 +35,15 @@ public class AnimalSpawnerCategory implements IRecipeCategory, Entity> entityCache = new HashMap<>(); public AnimalSpawnerCategory(IGuiHelper helper) { - this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86); + this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/animal_spawner.png"), 0, 0, 72, 86); } private static void renderEntity(PoseStack matrixstack, int x, int y, float scale, float yaw, float pitch, LivingEntity entity) { var f = (float) Math.atan(yaw / 40.0F); var f1 = (float) Math.atan(pitch / 40.0F); var posestack = RenderSystem.getModelViewStack(); - posestack.pushPose(); - posestack.translate(x, y, 1050.0D); + posestack.pushMatrix(); + posestack.translate(x, y, 1050.0F); posestack.scale(1.0F, 1.0F, -1.0F); RenderSystem.applyModelViewMatrix(); matrixstack.translate(0.0D, 0.0D, 1000.0D); @@ -77,7 +76,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory ItemEffectPowder.getEffect(stack).toString()); - registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, (stack, context) -> ItemAuraBottle.getType(stack).getName().toString()); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.EFFECT_POWDER, new ISubtypeInterpreter<>() { + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) { + return ItemEffectPowder.getEffect(ingredient); + } - var auraInterpreter = (IIngredientSubtypeInterpreter) (stack, context) -> { - var container = stack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY); - if (container != null) - return String.valueOf(container.getStoredAura()); - return IIngredientSubtypeInterpreter.NONE; + @Override + public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) { + return ItemEffectPowder.getEffect(ingredient).toString(); + } + }); + registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_BOTTLE, new ISubtypeInterpreter<>() { + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) { + return ItemAuraBottle.getType(ingredient).getName(); + } + + @Override + public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) { + return ItemAuraBottle.getType(ingredient).getName().toString(); + } + }); + + var auraInterpreter = new ISubtypeInterpreter() { + @Override + public @Nullable Object getSubtypeData(ItemStack ingredient, UidContext context) { + var container = ingredient.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY); + return container != null ? container.getStoredAura() : null; + } + + @Override + public String getLegacyStringSubtypeInfo(ItemStack ingredient, UidContext context) { + var container = ingredient.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY); + return container != null ? String.valueOf(container.getStoredAura()) : ""; + } }; - registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_CACHE, auraInterpreter); - registration.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, ModItems.AURA_TROVE, auraInterpreter); + registration.registerSubtypeInterpreter(ModItems.AURA_CACHE, auraInterpreter); + registration.registerSubtypeInterpreter(ModItems.AURA_TROVE, auraInterpreter); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java index cacfaced..11a5c30d 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/OfferingCategory.java @@ -19,7 +19,7 @@ public class OfferingCategory implements IRecipeCategory { private final IDrawable background; public OfferingCategory(IGuiHelper helper) { - this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36); + this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/offering.png"), 0, 0, 87, 36); } @Override @@ -48,4 +48,5 @@ public class OfferingCategory implements IRecipeCategory { builder.addSlot(RecipeIngredientRole.OUTPUT, 66, 15).addItemStack(recipe.output); builder.addSlot(RecipeIngredientRole.INPUT, 28, 1).addItemStacks(Arrays.asList(recipe.startItem.getItems())); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java index 86818e9e..41fa0f72 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/TreeRitualCategory.java @@ -19,7 +19,7 @@ public class TreeRitualCategory implements IRecipeCategory { private final IDrawable background; public TreeRitualCategory(IGuiHelper helper) { - this.background = helper.createDrawable(new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/jei/tree_ritual.png"), 0, 0, 146, 86); + this.background = helper.createDrawable(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/jei/tree_ritual.png"), 0, 0, 146, 86); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java index 0dc938b5..541713f1 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java @@ -5,11 +5,11 @@ import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.multiblock.Matcher; import de.ellpeck.naturesaura.compat.ICompat; -import de.ellpeck.naturesaura.data.ItemTagProvider; import de.ellpeck.naturesaura.events.ClientEvents; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.core.HolderLookup; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; import net.minecraft.resources.ResourceLocation; @@ -17,9 +17,9 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.common.NeoForge; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.neoforge.common.NeoForge; import vazkii.patchouli.api.BookDrawScreenEvent; import vazkii.patchouli.api.IMultiblock; import vazkii.patchouli.api.IVariable; @@ -32,7 +32,7 @@ import java.util.stream.Collectors; public class PatchouliCompat implements ICompat { - public static final ResourceLocation BOOK = new ResourceLocation(NaturesAura.MOD_ID, "book"); + public static final ResourceLocation BOOK = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "book"); private static final Map MULTIBLOCKS = new HashMap<>(); public static void addPatchouliMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers) { @@ -43,7 +43,7 @@ public class PatchouliCompat implements ICompat { rawMatchers[i] = PatchouliAPI.get().anyMatcher(); else rawMatchers[i] = PatchouliAPI.get().predicateMatcher(matcher.defaultState(), - state -> check.matches(null, null, null, null, state, (char) 0)); + state -> check.matches(null, null, null, null, state, (char) 0)); } } PatchouliCompat.MULTIBLOCKS.put(name, PatchouliAPI.get().makeMultiblock(pattern, rawMatchers)); @@ -52,14 +52,13 @@ public class PatchouliCompat implements ICompat { @SuppressWarnings("unchecked") public static > T getRecipe(String type, String name) { var manager = Minecraft.getInstance().level.getRecipeManager(); - var res = new ResourceLocation(name); - var pre = new ResourceLocation(res.getNamespace(), type + "/" + res.getPath()); + var res = ResourceLocation.parse(name); + var pre = ResourceLocation.fromNamespaceAndPath(res.getNamespace(), type + "/" + res.getPath()); return (T) manager.byKey(pre).orElse(null).value(); } - public static IVariable ingredientVariable(Ingredient ingredient) { - return IVariable.wrapList(Arrays.stream(ingredient.getItems()) - .map(IVariable::from).collect(Collectors.toList())); + public static IVariable ingredientVariable(Ingredient ingredient, HolderLookup.Provider registries) { + return IVariable.wrapList(Arrays.stream(ingredient.getItems()).map(i -> IVariable.from(i, registries)).collect(Collectors.toList()), registries); } @Override @@ -78,11 +77,6 @@ public class PatchouliCompat implements ICompat { NeoForge.EVENT_BUS.register(this); } - @Override - public void addItemTags(ItemTagProvider provider) { - - } - @SubscribeEvent @OnlyIn(Dist.CLIENT) public void onBookDraw(BookDrawScreenEvent event) { @@ -99,9 +93,9 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 43 && event.getMouseY() < y + 42) event.getGraphics().renderTooltip(Minecraft.getInstance().font, - Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))), - Optional.empty(), - event.getMouseX(), event.getMouseY()); + Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))), + Optional.empty(), + event.getMouseX(), event.getMouseY()); } else if (now.getMonth() == Month.JUNE) { var x = gui.width / 2 + 272 / 2; var y = gui.height / 2 + 32; @@ -111,8 +105,8 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 45 && event.getMouseY() < y + 26) //noinspection UnnecessaryUnicodeEscape event.getGraphics().renderTooltip(gui.getMinecraft().font, - Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), Optional.empty(), - event.getMouseX(), event.getMouseY()); + Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), Optional.empty(), + event.getMouseX(), event.getMouseY()); } var name = gui.getMinecraft().player.getName().getString(); @@ -134,9 +128,10 @@ public class PatchouliCompat implements ICompat { if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 16 && event.getMouseY() < y + 18) event.getGraphics().renderTooltip(gui.getMinecraft().font, - Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), Optional.empty(), - event.getMouseX(), event.getMouseY()); + Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), Optional.empty(), + event.getMouseX(), event.getMouseY()); } } + } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java index 86752d70..af352b24 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -13,7 +13,7 @@ public class ProcessorAltar implements IComponentProcessor { @Override public void setup(Level level, IVariableProvider provider) { - this.recipe = PatchouliCompat.getRecipe("altar", provider.get("recipe").asString()); + this.recipe = PatchouliCompat.getRecipe("altar", provider.get("recipe", level.registryAccess()).asString()); } @Override @@ -21,10 +21,10 @@ public class ProcessorAltar implements IComponentProcessor { if (this.recipe == null) return null; return switch (key) { - case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input); - case "output" -> IVariable.from(this.recipe.output); - case "catalyst" -> this.recipe.catalyst != Ingredient.EMPTY ? PatchouliCompat.ingredientVariable(this.recipe.catalyst) : null; - case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString()); + case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input, level.registryAccess()); + case "output" -> IVariable.from(this.recipe.output, level.registryAccess()); + case "catalyst" -> this.recipe.catalyst != Ingredient.EMPTY ? PatchouliCompat.ingredientVariable(this.recipe.catalyst, level.registryAccess()) : null; + case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess()); default -> null; }; } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java index 4a2a874f..11b9dec1 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java @@ -15,7 +15,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor { @Override public void setup(Level level, IVariableProvider provider) { - this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe").asString()); + this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe", level.registryAccess()).asString()); } @Override @@ -24,12 +24,12 @@ public class ProcessorAnimalSpawner implements IComponentProcessor { return null; if (key.startsWith("input")) { var id = Integer.parseInt(key.substring(5)) - 1; - return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null; + return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id), level.registryAccess()) : null; } else { return switch (key) { - case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString()); - case "entity" -> IVariable.wrap(BuiltInRegistries.ENTITY_TYPE.getKey(this.recipe.entity).toString()); - case "egg" -> IVariable.from(new ItemStack(SpawnEggItem.byId(this.recipe.entity))); + case "name" -> IVariable.wrap(this.recipe.entity.getDescription().getString(), level.registryAccess()); + case "entity" -> IVariable.wrap(BuiltInRegistries.ENTITY_TYPE.getKey(this.recipe.entity).toString(), level.registryAccess()); + case "egg" -> IVariable.from(new ItemStack(SpawnEggItem.byId(this.recipe.entity)), level.registryAccess()); default -> null; }; } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java index 67de66fa..c0bb6f6d 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java @@ -12,7 +12,7 @@ public class ProcessorOffering implements IComponentProcessor { @Override public void setup(Level level, IVariableProvider provider) { - this.recipe = PatchouliCompat.getRecipe("offering", provider.get("recipe").asString()); + this.recipe = PatchouliCompat.getRecipe("offering", provider.get("recipe", level.registryAccess()).asString()); } @Override @@ -20,10 +20,10 @@ public class ProcessorOffering implements IComponentProcessor { if (this.recipe == null) return null; return switch (key) { - case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input); - case "output" -> IVariable.from(this.recipe.output); - case "start" -> PatchouliCompat.ingredientVariable(this.recipe.startItem); - case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString()); + case "input" -> PatchouliCompat.ingredientVariable(this.recipe.input, level.registryAccess()); + case "output" -> IVariable.from(this.recipe.output, level.registryAccess()); + case "start" -> PatchouliCompat.ingredientVariable(this.recipe.startItem, level.registryAccess()); + case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess()); default -> null; }; } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java index 01bda960..1df121e3 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -12,7 +12,7 @@ public class ProcessorTreeRitual implements IComponentProcessor { @Override public void setup(Level level, IVariableProvider provider) { - this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe").asString()); + this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe", level.registryAccess()).asString()); } @Override @@ -21,14 +21,15 @@ public class ProcessorTreeRitual implements IComponentProcessor { return null; if (key.startsWith("input")) { var id = Integer.parseInt(key.substring(5)) - 1; - return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id)) : null; + return this.recipe.ingredients.size() > id ? PatchouliCompat.ingredientVariable(this.recipe.ingredients.get(id), level.registryAccess()) : null; } else { return switch (key) { - case "output" -> IVariable.from(this.recipe.output); - case "sapling" -> PatchouliCompat.ingredientVariable(this.recipe.saplingType); - case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString()); + case "output" -> IVariable.from(this.recipe.output, level.registryAccess()); + case "sapling" -> PatchouliCompat.ingredientVariable(this.recipe.saplingType, level.registryAccess()); + case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString(), level.registryAccess()); default -> null; }; } } + } diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java index efa06c0e..b502a8ce 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockLootProvider.java @@ -7,6 +7,7 @@ import de.ellpeck.naturesaura.blocks.Slab; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.advancements.critereon.StatePropertiesPredicate; +import net.minecraft.core.HolderLookup; import net.minecraft.data.loot.BlockLootSubProvider; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.item.Items; @@ -25,8 +26,8 @@ import java.util.Set; public class BlockLootProvider extends BlockLootSubProvider { - public BlockLootProvider() { - super(Set.of(), FeatureFlags.REGISTRY.allFlags()); + public BlockLootProvider(HolderLookup.Provider registries) { + super(Set.of(), FeatureFlags.REGISTRY.allFlags(), registries); } @Override @@ -43,15 +44,16 @@ public class BlockLootProvider extends BlockLootSubProvider { } } - this.add(ModBlocks.ANCIENT_LEAVES, BlockLootProvider::createSilkTouchOnlyTable); - this.add(ModBlocks.DECAYED_LEAVES, BlockLootProvider::createSilkTouchOnlyTable); + this.add(ModBlocks.ANCIENT_LEAVES, this::createSilkTouchOnlyTable); + this.add(ModBlocks.DECAYED_LEAVES, this::createSilkTouchOnlyTable); this.add(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(this.applyExplosionCondition(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F)))); - this.add(ModBlocks.NETHER_WART_MUSHROOM, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2))))); - this.add(ModBlocks.NETHER_GRASS, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Blocks.NETHERRACK))); + this.add(ModBlocks.NETHER_WART_MUSHROOM, b -> this.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2))))); + this.add(ModBlocks.NETHER_GRASS, b -> this.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Blocks.NETHERRACK))); } @Override protected Iterable getKnownBlocks() { return ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof Block).map(i -> (Block) i).toList(); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java index 8b8020ab..275f47b2 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java @@ -17,10 +17,10 @@ import java.util.concurrent.CompletableFuture; public class BlockTagProvider extends BlockTagsProvider { - public static final TagKey ALTAR_WOOD = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_wood")); - public static final TagKey ALTAR_STONE = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_stone")); - public static final TagKey ALTAR_GOLD_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_gold_brick")); - public static final TagKey ALTAR_FANCY_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_fancy_brick")); + public static final TagKey ALTAR_WOOD = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_wood")); + public static final TagKey ALTAR_STONE = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_stone")); + public static final TagKey ALTAR_GOLD_BRICK = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_gold_brick")); + public static final TagKey ALTAR_FANCY_BRICK = BlockTags.create(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar_fancy_brick")); public BlockTagProvider(PackOutput output, CompletableFuture lookupProvider, @Nullable ExistingFileHelper existingFileHelper) { super(output, lookupProvider, NaturesAura.MOD_ID, existingFileHelper); @@ -42,21 +42,22 @@ public class BlockTagProvider extends BlockTagsProvider { this.tag(BlockTagProvider.ALTAR_FANCY_BRICK).add(Blocks.RED_NETHER_BRICKS, Blocks.CHISELED_STONE_BRICKS); this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(ModBlocks.ANIMAL_CONTAINER, ModBlocks.ANIMAL_GENERATOR, - ModBlocks.ANIMAL_SPAWNER, ModBlocks.AURA_DETECTOR, ModBlocks.AURA_TIMER, ModBlocks.BLAST_FURNACE_BOOSTER, - ModBlocks.CHORUS_GENERATOR, ModBlocks.CHUNK_LOADER, ModBlocks.CONVERSION_CATALYST, ModBlocks.CRUSHING_CATALYST, - ModBlocks.DEPTH_INGOT_BLOCK, ModBlocks.ENDER_CRATE, ModBlocks.FIELD_CREATOR, ModBlocks.FIREWORK_GENERATOR, - ModBlocks.FURNACE_HEATER, ModBlocks.GENERATOR_LIMIT_REMOVER, ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK, - ModBlocks.GRATED_CHUTE, ModBlocks.HOPPER_UPGRADE, ModBlocks.INFUSED_BRICK, ModBlocks.INFUSED_BRICK_SLAB, - ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_IRON_BLOCK, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_STAIRS, - ModBlocks.INFUSED_STONE, ModBlocks.ITEM_DISTRIBUTOR, ModBlocks.LOWER_LIMITER, ModBlocks.MOSS_GENERATOR, - ModBlocks.NATURE_ALTAR, ModBlocks.NETHER_GRASS, ModBlocks.PICKUP_STOPPER, ModBlocks.PLACER, ModBlocks.POTION_GENERATOR, - ModBlocks.POWDER_PLACER, ModBlocks.PROJECTILE_GENERATOR, ModBlocks.RF_CONVERTER, ModBlocks.SKY_INGOT_BLOCK, - ModBlocks.SNOW_CREATOR, ModBlocks.SPAWN_LAMP, ModBlocks.SPRING, ModBlocks.TAINTED_GOLD_BLOCK, - ModBlocks.TIME_CHANGER, ModBlocks.WEATHER_CHANGER); + ModBlocks.ANIMAL_SPAWNER, ModBlocks.AURA_DETECTOR, ModBlocks.AURA_TIMER, ModBlocks.BLAST_FURNACE_BOOSTER, + ModBlocks.CHORUS_GENERATOR, ModBlocks.CHUNK_LOADER, ModBlocks.CONVERSION_CATALYST, ModBlocks.CRUSHING_CATALYST, + ModBlocks.DEPTH_INGOT_BLOCK, ModBlocks.ENDER_CRATE, ModBlocks.FIELD_CREATOR, ModBlocks.FIREWORK_GENERATOR, + ModBlocks.FURNACE_HEATER, ModBlocks.GENERATOR_LIMIT_REMOVER, ModBlocks.GOLD_BRICK, ModBlocks.GOLD_NETHER_BRICK, + ModBlocks.GRATED_CHUTE, ModBlocks.HOPPER_UPGRADE, ModBlocks.INFUSED_BRICK, ModBlocks.INFUSED_BRICK_SLAB, + ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_IRON_BLOCK, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_STAIRS, + ModBlocks.INFUSED_STONE, ModBlocks.ITEM_DISTRIBUTOR, ModBlocks.LOWER_LIMITER, ModBlocks.MOSS_GENERATOR, + ModBlocks.NATURE_ALTAR, ModBlocks.NETHER_GRASS, ModBlocks.PICKUP_STOPPER, ModBlocks.PLACER, ModBlocks.POTION_GENERATOR, + ModBlocks.POWDER_PLACER, ModBlocks.PROJECTILE_GENERATOR, ModBlocks.RF_CONVERTER, ModBlocks.SKY_INGOT_BLOCK, + ModBlocks.SNOW_CREATOR, ModBlocks.SPAWN_LAMP, ModBlocks.SPRING, ModBlocks.TAINTED_GOLD_BLOCK, + ModBlocks.TIME_CHANGER, ModBlocks.WEATHER_CHANGER); this.tag(BlockTags.MINEABLE_WITH_AXE).add(ModBlocks.ANCIENT_BARK, ModBlocks.ANCIENT_LOG, - ModBlocks.ANCIENT_PLANKS, ModBlocks.ANCIENT_SLAB, ModBlocks.ANCIENT_STAIRS, - ModBlocks.AUTO_CRAFTER, ModBlocks.FLOWER_GENERATOR, ModBlocks.NETHER_WART_MUSHROOM, - ModBlocks.OAK_GENERATOR, ModBlocks.OFFERING_TABLE, ModBlocks.WOOD_STAND); + ModBlocks.ANCIENT_PLANKS, ModBlocks.ANCIENT_SLAB, ModBlocks.ANCIENT_STAIRS, + ModBlocks.AUTO_CRAFTER, ModBlocks.FLOWER_GENERATOR, ModBlocks.NETHER_WART_MUSHROOM, + ModBlocks.OAK_GENERATOR, ModBlocks.OFFERING_TABLE, ModBlocks.WOOD_STAND); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/data/ModData.java b/src/main/java/de/ellpeck/naturesaura/data/ModData.java index e267f193..974037ab 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ModData.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ModData.java @@ -13,7 +13,6 @@ import net.minecraft.data.registries.VanillaRegistries; import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; -import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider; import net.neoforged.neoforge.data.event.GatherDataEvent; import net.neoforged.neoforge.registries.DataPackRegistriesHooks; @@ -38,7 +37,7 @@ public final class ModData { var blockTags = new BlockTagProvider(out, lookup, existing); gen.addProvider(event.includeServer(), blockTags); gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing)); - gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK)))); + gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK)), lookup)); gen.addProvider(event.includeServer(), new BlockStateGenerator(out, existing)); gen.addProvider(event.includeServer(), new ItemModelGenerator(out, existing)); gen.addProvider(event.includeServer(), new DatapackBuiltinEntriesProvider(out, CompletableFuture.supplyAsync(ModData::getProvider), Set.of(NaturesAura.MOD_ID))); diff --git a/src/main/java/de/ellpeck/naturesaura/enchant/AuraMendingEnchantment.java b/src/main/java/de/ellpeck/naturesaura/enchant/AuraMendingEnchantment.java index 348b55d2..8ec7c44c 100644 --- a/src/main/java/de/ellpeck/naturesaura/enchant/AuraMendingEnchantment.java +++ b/src/main/java/de/ellpeck/naturesaura/enchant/AuraMendingEnchantment.java @@ -3,8 +3,8 @@ package de.ellpeck.naturesaura.enchant; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Rarity; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentCategory; import net.minecraft.world.item.enchantment.Enchantments; public class AuraMendingEnchantment extends ModEnchantment { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java index d28e49a0..f42da50a 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java @@ -51,23 +51,23 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { } @Override - public void onAddedToWorld() { - super.onAddedToWorld(); + public void onAddedToLevel() { + super.onAddedToLevel(); this.powderListDirty = true; } @Override - public void onRemovedFromWorld() { - super.onRemovedFromWorld(); + public void onRemovedFromLevel() { + super.onRemovedFromLevel(); // we pass a null effect because we want to remove our effect from the world this.updatePowderListStatus(null); } @Override - protected void defineSynchedData() { - this.entityData.define(EntityEffectInhibitor.INHIBITED_EFFECT, ""); - this.entityData.define(EntityEffectInhibitor.COLOR, 0); - this.entityData.define(EntityEffectInhibitor.AMOUNT, 0); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + builder.define(EntityEffectInhibitor.INHIBITED_EFFECT, ""); + builder.define(EntityEffectInhibitor.COLOR, 0); + builder.define(EntityEffectInhibitor.AMOUNT, 0); } @Override @@ -94,13 +94,13 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { if (this.level().isClientSide) { if (this.level().getGameTime() % 5 == 0) { NaturesAuraAPI.instance().spawnMagicParticle( - this.getX() + this.level().random.nextGaussian() * 0.1F, - this.getY(), - this.getZ() + this.level().random.nextGaussian() * 0.1F, - this.level().random.nextGaussian() * 0.005F, - this.level().random.nextFloat() * 0.03F, - this.level().random.nextGaussian() * 0.005F, - this.getColor(), this.level().random.nextFloat() * 3F + 1F, 120, 0F, true, true); + this.getX() + this.level().random.nextGaussian() * 0.1F, + this.getY(), + this.getZ() + this.level().random.nextGaussian() * 0.1F, + this.level().random.nextGaussian() * 0.005F, + this.level().random.nextFloat() * 0.03F, + this.level().random.nextGaussian() * 0.005F, + this.getColor(), this.level().random.nextFloat() * 3F + 1F, 120, 0F, true, true); } this.renderTicks++; } @@ -108,7 +108,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { @Override protected void readAdditionalSaveData(CompoundTag compound) { - this.setInhibitedEffect(new ResourceLocation(compound.getString("effect"))); + this.setInhibitedEffect(ResourceLocation.parse(compound.getString("effect"))); this.setColor(compound.getInt("color")); this.setAmount(compound.contains("amount") ? compound.getInt("amount") : 24); } @@ -156,7 +156,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { var effect = this.entityData.get(EntityEffectInhibitor.INHIBITED_EFFECT); if (effect == null || effect.isEmpty()) return null; - return new ResourceLocation(effect); + return ResourceLocation.parse(effect); } public void setInhibitedEffect(ResourceLocation effect) { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java index d4126680..1d28105f 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.entities; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.ModBlocks; +import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.util.Mth; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -22,7 +23,7 @@ public class EntityLightProjectile extends ThrowableProjectile { } @Override - protected void defineSynchedData() { + protected void defineSynchedData(SynchedEntityData.Builder builder) { } @@ -32,11 +33,11 @@ public class EntityLightProjectile extends ThrowableProjectile { if (this.level().isClientSide && this.tickCount > 1) { for (float i = 0; i <= 1; i += 0.2F) { NaturesAuraAPI.instance().spawnMagicParticle( - Mth.lerp(i, this.xOld, this.getX()), - Mth.lerp(i, this.yOld, this.getY()), - Mth.lerp(i, this.zOld, this.getZ()), - this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, - 0xffcb5c, this.random.nextFloat() * 0.5F + 1, 20, 0, false, true); + Mth.lerp(i, this.xOld, this.getX()), + Mth.lerp(i, this.yOld, this.getY()), + Mth.lerp(i, this.zOld, this.getZ()), + this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, this.random.nextGaussian() * 0.01F, + 0xffcb5c, this.random.nextFloat() * 0.5F + 1, 20, 0, false, true); } } } @@ -50,7 +51,7 @@ public class EntityLightProjectile extends ThrowableProjectile { if (state.canBeReplaced()) this.level().setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState()); } else if (result instanceof EntityHitResult entity) { - entity.getEntity().setSecondsOnFire(5); + entity.getEntity().setRemainingFireTicks(5 * 20); } } this.discard(); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index dd6a619a..373f11c1 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -9,7 +9,6 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.LongTag; import net.minecraft.nbt.Tag; -import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -23,10 +22,9 @@ import net.minecraft.world.level.GameRules; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.portal.DimensionTransition; import net.minecraft.world.phys.HitResult; -import net.neoforged.neoforge.common.util.ITeleporter; -import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; @@ -57,8 +55,8 @@ public class EntityMoverMinecart extends Minecart { if (!this.spotOffsets.isEmpty() && this.level().getGameTime() % 10 == 0) PacketHandler.sendToAllAround(this.level(), pos, 32, new PacketParticles( - (float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.MOVER_CART, - Mth.floor(this.getDeltaMovement().x * 100F), Mth.floor(this.getDeltaMovement().y * 100F), Mth.floor(this.getDeltaMovement().z * 100F))); + (float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.MOVER_CART, + Mth.floor(this.getDeltaMovement().x * 100F), Mth.floor(this.getDeltaMovement().y * 100F), Mth.floor(this.getDeltaMovement().z * 100F))); if (pos.distSqr(this.lastPosition) < 8 * 8) return; @@ -113,8 +111,8 @@ public class EntityMoverMinecart extends Minecart { } @Override - public CompoundTag serializeNBT() { - var compound = super.serializeNBT(); + protected void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); compound.putBoolean("active", this.isActive); compound.putLong("last_pos", this.lastPosition.asLong()); @@ -122,12 +120,11 @@ public class EntityMoverMinecart extends Minecart { for (var offset : this.spotOffsets) list.add(LongTag.valueOf(offset.asLong())); compound.put("offsets", list); - return compound; } @Override - public void deserializeNBT(CompoundTag compound) { - super.deserializeNBT(compound); + protected void readAdditionalSaveData(CompoundTag compound) { + super.readAdditionalSaveData(compound); this.isActive = compound.getBoolean("active"); this.lastPosition = BlockPos.of(compound.getLong("last_pos")); @@ -137,10 +134,9 @@ public class EntityMoverMinecart extends Minecart { this.spotOffsets.add(BlockPos.of(((LongTag) base).getAsLong())); } - @Nullable @Override - public Entity changeDimension(ServerLevel destination, ITeleporter teleporter) { - var entity = super.changeDimension(destination, teleporter); + public @org.jetbrains.annotations.Nullable Entity changeDimension(DimensionTransition transition) { + var entity = super.changeDimension(transition); if (entity instanceof EntityMoverMinecart) { var pos = entity.blockPosition(); this.moveAura(this.level(), this.lastPosition, entity.level(), pos); @@ -179,4 +175,5 @@ public class EntityMoverMinecart extends Minecart { public InteractionResult interact(Player p_38483_, InteractionHand p_38484_) { return InteractionResult.PASS; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java index b87230f0..500f612e 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java @@ -32,9 +32,9 @@ public class EntityStructureFinder extends EyeOfEnder { } @Override - protected void defineSynchedData() { - super.defineSynchedData(); - this.entityData.define(EntityStructureFinder.COLOR, 0); + protected void defineSynchedData(SynchedEntityData.Builder builder) { + super.defineSynchedData(builder); + builder.define(EntityStructureFinder.COLOR, 0); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java index 1080a18f..d0ef3493 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java @@ -18,11 +18,12 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MinecartRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.FastColor; import net.minecraft.world.level.block.state.BlockState; public class RenderMoverMinecart extends MinecartRenderer { - private static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "textures/models/mover_cart.png"); + private static final ResourceLocation RES = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/models/mover_cart.png"); public RenderMoverMinecart(EntityRendererProvider.Context p_174300_) { super(p_174300_, ModelLayers.MINECART); @@ -36,7 +37,7 @@ public class RenderMoverMinecart extends MinecartRenderer { matrixStackIn.translate(0, 22 / 16F, 0); matrixStackIn.translate(0, 0, 1); matrixStackIn.mulPose(Axis.XP.rotationDegrees(180)); - this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RenderMoverMinecart.RES)), packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 1); + this.model.renderToBuffer(matrixStackIn, bufferIn.getBuffer(this.model.renderType(RenderMoverMinecart.RES)), packedLightIn, OverlayTexture.NO_OVERLAY, FastColor.ARGB32.colorFromFloat(1, 1, 1, 1)); matrixStackIn.popPose(); } @@ -53,8 +54,10 @@ public class RenderMoverMinecart extends MinecartRenderer { } @Override - public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) { - this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha); + public void renderToBuffer(PoseStack matrixStackIn, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, int color) { + this.model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, color); } + } + } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index d2736930..6c4bf181 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -2,10 +2,7 @@ package de.ellpeck.naturesaura.events; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexFormat; +import com.mojang.blaze3d.vertex.*; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; @@ -40,15 +37,14 @@ import net.minecraft.world.level.block.MyceliumBlock; import net.minecraft.world.phys.BlockHitResult; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; -import net.neoforged.neoforge.capabilities.Capabilities; -import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent; -import net.neoforged.neoforge.client.event.RenderGuiOverlayEvent; -import net.neoforged.neoforge.client.event.RenderLevelStageEvent; -import net.neoforged.neoforge.client.gui.overlay.VanillaGuiOverlay; -import net.neoforged.neoforge.common.IPlantable; -import net.neoforged.neoforge.energy.EnergyStorage; -import net.neoforged.neoforge.event.TickEvent; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.neoforge.capabilities.Capabilities; +import net.neoforged.neoforge.client.event.ClientTickEvent; +import net.neoforged.neoforge.client.event.CustomizeGuiOverlayEvent; +import net.neoforged.neoforge.client.event.RenderGuiLayerEvent; +import net.neoforged.neoforge.client.event.RenderLevelStageEvent; +import net.neoforged.neoforge.client.gui.VanillaGuiLayers; +import net.neoforged.neoforge.energy.EnergyStorage; import org.apache.commons.lang3.mutable.MutableInt; import java.text.NumberFormat; @@ -60,8 +56,8 @@ import java.util.Map; @OnlyIn(Dist.CLIENT) public class ClientEvents { - public static final ResourceLocation OVERLAYS = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/overlays.png"); - public static final ResourceLocation BOOK_GUI = new ResourceLocation(NaturesAura.MOD_ID, "textures/gui/book.png"); + public static final ResourceLocation OVERLAYS = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/overlays.png"); + public static final ResourceLocation BOOK_GUI = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/gui/book.png"); public static final List PENDING_AURA_CHUNKS = new ArrayList<>(); private static final ItemStack ITEM_FRAME = new ItemStack(Items.ITEM_FRAME); private static final ItemStack DISPENSER = new ItemStack(Blocks.DISPENSER); @@ -95,74 +91,72 @@ public class ClientEvents { } @SubscribeEvent - public void onClientTick(TickEvent.ClientTickEvent event) { - if (event.phase != TickEvent.Phase.END) { - ClientEvents.heldCache = ItemStack.EMPTY; - ClientEvents.heldEye = ItemStack.EMPTY; - ClientEvents.heldOcular = ItemStack.EMPTY; + public void onClientTick(ClientTickEvent.Post event) { + ClientEvents.heldCache = ItemStack.EMPTY; + ClientEvents.heldEye = ItemStack.EMPTY; + ClientEvents.heldOcular = ItemStack.EMPTY; - var mc = Minecraft.getInstance(); - if (mc.level == null) { - ItemRangeVisualizer.clear(); - ClientEvents.PENDING_AURA_CHUNKS.clear(); - } else { - ClientEvents.PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); + var mc = Minecraft.getInstance(); + if (mc.level == null) { + ItemRangeVisualizer.clear(); + ClientEvents.PENDING_AURA_CHUNKS.clear(); + } else { + ClientEvents.PENDING_AURA_CHUNKS.removeIf(next -> next.tryHandle(mc.level)); - if (!mc.isPaused()) { - if (mc.level.getGameTime() % 20 == 0) { - var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get()); - for (var i = 0; i < amount; i++) { - var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32; - var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16; - var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32; - var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below(); - var state = mc.level.getBlockState(pos); - var block = state.getBlock(); - if (block instanceof BonemealableBlock || block instanceof IPlantable || block instanceof LeavesBlock || block instanceof MyceliumBlock) { - var excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA; - if (excess > 0) { - var chance = Math.max(10, 50 - excess / 25000); - if (mc.level.random.nextInt(chance) <= 0) - NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + mc.level.random.nextFloat(), - pos.getY() + 0.5F, - pos.getZ() + mc.level.random.nextFloat(), - mc.level.random.nextGaussian() * 0.01F, - mc.level.random.nextFloat() * 0.025F, - mc.level.random.nextGaussian() * 0.01F, - block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getAverageGrassColor(mc.level, pos), - Math.min(2F, 1F + mc.level.random.nextFloat() * (excess / 30000F)), - Math.min(300, 100 + mc.level.random.nextInt(excess / 3000 + 1)), - 0F, false, true); - } + if (!mc.isPaused()) { + if (mc.level.getGameTime() % 20 == 0) { + var amount = Mth.floor(190 * ModConfig.instance.excessParticleAmount.get()); + for (var i = 0; i < amount; i++) { + var x = Mth.floor(mc.player.getX()) + mc.level.random.nextInt(64) - 32; + var y = Mth.floor(mc.player.getY()) + mc.level.random.nextInt(32) - 16; + var z = Mth.floor(mc.player.getZ()) + mc.level.random.nextInt(64) - 32; + var pos = Helper.getClosestAirAboveGround(mc.level, new BlockPos(x, y, z), 16).below(); + var state = mc.level.getBlockState(pos); + var block = state.getBlock(); + if (block instanceof BonemealableBlock || block instanceof LeavesBlock || block instanceof MyceliumBlock) { + var excess = IAuraChunk.triangulateAuraInArea(mc.level, pos, 45) - IAuraChunk.DEFAULT_AURA; + if (excess > 0) { + var chance = Math.max(10, 50 - excess / 25000); + if (mc.level.random.nextInt(chance) <= 0) + NaturesAuraAPI.instance().spawnMagicParticle( + pos.getX() + mc.level.random.nextFloat(), + pos.getY() + 0.5F, + pos.getZ() + mc.level.random.nextFloat(), + mc.level.random.nextGaussian() * 0.01F, + mc.level.random.nextFloat() * 0.025F, + mc.level.random.nextGaussian() * 0.01F, + block instanceof MyceliumBlock ? 0x875ca1 : BiomeColors.getAverageGrassColor(mc.level, pos), + Math.min(2F, 1F + mc.level.random.nextFloat() * (excess / 30000F)), + Math.min(300, 100 + mc.level.random.nextInt(excess / 3000 + 1)), + 0F, false, true); } } } + } - if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.level.getGameTime() % 5 == 0) { - var inst = NaturesAuraAPI.instance(); - inst.setParticleSpawnRange(512); - inst.setParticleDepth(false); - for (var pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.dimension().location())) { - NaturesAuraAPI.instance().spawnMagicParticle( - pos.getX() + mc.level.random.nextFloat(), - pos.getY() + mc.level.random.nextFloat(), - pos.getZ() + mc.level.random.nextFloat(), - 0F, 0F, 0F, 0xe0faff, mc.level.random.nextFloat() * 5 + 1, 100, 0F, false, true); - } - inst.setParticleDepth(true); - inst.setParticleSpawnRange(32); + if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER) && mc.level.getGameTime() % 5 == 0) { + var inst = NaturesAuraAPI.instance(); + inst.setParticleSpawnRange(512); + inst.setParticleDepth(false); + for (var pos : ItemRangeVisualizer.VISUALIZED_RAILS.get(mc.level.dimension().location())) { + NaturesAuraAPI.instance().spawnMagicParticle( + pos.getX() + mc.level.random.nextFloat(), + pos.getY() + mc.level.random.nextFloat(), + pos.getZ() + mc.level.random.nextFloat(), + 0F, 0F, 0F, 0xe0faff, mc.level.random.nextFloat() * 5 + 1, 100, 0F, false, true); } + inst.setParticleDepth(true); + inst.setParticleSpawnRange(32); + } - ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player, false); - ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true); - ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false); + ClientEvents.heldCache = Helper.getEquippedItem(s -> s.getItem() instanceof ItemAuraCache, mc.player, false); + ClientEvents.heldEye = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE, mc.player, true); + ClientEvents.heldOcular = Helper.getEquippedItem(s -> s.getItem() == ModItems.EYE_IMPROVED, mc.player, false); - if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { - ClientEvents.SHOWING_EFFECTS.clear(); - Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100, - chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS)); - } + if (!ClientEvents.heldOcular.isEmpty() && mc.level.getGameTime() % 20 == 0) { + ClientEvents.SHOWING_EFFECTS.clear(); + Helper.getAuraChunksWithSpotsInArea(mc.level, mc.player.blockPosition(), 100, + chunk -> chunk.getActiveEffectIcons(mc.player, ClientEvents.SHOWING_EFFECTS)); } } } @@ -175,15 +169,14 @@ public class ClientEvents { var mc = Minecraft.getInstance(); var view = mc.gameRenderer.getMainCamera().getPosition(); var tesselator = Tesselator.getInstance(); - var buffer = tesselator.getBuilder(); mc.getProfiler().push(NaturesAura.MOD_ID + ":onLevelRender"); RenderSystem.enableDepthTest(); var mv = RenderSystem.getModelViewStack(); - mv.pushPose(); - mv.mulPoseMatrix(event.getPoseStack().last().pose()); - mv.translate(-view.x, -view.y, -view.z); + mv.pushMatrix(); + mv.mul(event.getPoseStack().last().pose()); + mv.translate((float) -view.x, (float) -view.y, (float) -view.z); RenderSystem.applyModelViewMatrix(); RenderSystem.enableBlend(); RenderSystem.setShader(GameRenderer::getPositionColorShader); @@ -192,12 +185,12 @@ public class ClientEvents { // aura spot debug ClientEvents.hoveringAuraSpot = null; if (mc.getDebugOverlay().showDebugScreen() && (mc.player.isCreative() || mc.player.isSpectator()) && ModConfig.instance.debugLevel.get()) { - var playerEye = mc.player.getEyePosition(event.getPartialTick()); - var playerView = mc.player.getViewVector(event.getPartialTick()).normalize(); - var range = mc.gameMode.getPickRange(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + var playerEye = mc.player.getEyePosition(event.getPartialTick().getGameTimeDeltaPartialTick(true)); + var playerView = mc.player.getViewVector(event.getPartialTick().getGameTimeDeltaPartialTick(true)).normalize(); + var range = mc.gameMode.getDestroyStage(); + var builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); IAuraChunk.getSpotsInArea(mc.level, mc.player.blockPosition(), 64, (pos, spot) -> { - Helper.renderWeirdBox(buffer, pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1, spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F); + Helper.renderWeirdBox(builder, pos.getX(), pos.getY(), pos.getZ(), 1, 1, 1, spot > 0 ? 0F : 1F, spot > 0 ? 1F : 0F, 0F, 0.35F); // dirty raytrace to see if we're looking at roughly this spot if (playerEye.distanceToSqr(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5) <= range * range) { for (var d = 0F; d <= range; d += 0.5F) { @@ -209,14 +202,14 @@ public class ClientEvents { } }); - tesselator.end(); + BufferUploader.drawWithShader(builder.build()); } // range visualizer if (Helper.isHoldingItem(mc.player, ModItems.RANGE_VISUALIZER)) { RenderSystem.disableCull(); var dim = mc.level.dimension().location(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + var builder = tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); for (var pos : ItemRangeVisualizer.VISUALIZED_BLOCKS.get(dim)) { if (!mc.level.isLoaded(pos)) continue; @@ -224,18 +217,18 @@ public class ClientEvents { var block = state.getBlock(); if (!(block instanceof IVisualizable)) continue; - this.renderVisualize(buffer, (IVisualizable) block, mc.level, pos); + this.renderVisualize(builder, (IVisualizable) block, mc.level, pos); } for (var entity : ItemRangeVisualizer.VISUALIZED_ENTITIES.get(dim)) { if (!entity.isAlive() || !(entity instanceof IVisualizable)) continue; - this.renderVisualize(buffer, (IVisualizable) entity, mc.level, entity.blockPosition()); + this.renderVisualize(builder, (IVisualizable) entity, mc.level, entity.blockPosition()); } - tesselator.end(); + BufferUploader.drawWithShader(builder.build()); RenderSystem.enableCull(); } - mv.popPose(); + mv.popMatrix(); RenderSystem.applyModelViewMatrix(); RenderSystem.disableBlend(); @@ -247,17 +240,17 @@ public class ClientEvents { if (box != null) { box = box.inflate(0.05F); var color = visualize.getVisualizationColor(level, pos); - Helper.renderWeirdBox(buffer, box.minX, box.minY, box.minZ, box.maxX - box.minX, box.maxY - box.minY, box.maxZ - box.minZ, (color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F); + Helper.renderWeirdBox(buffer, (float) box.minX, (float) box.minY, (float) box.minZ, (float) (box.maxX - box.minX), (float) (box.maxY - box.minY), (float) (box.maxZ - box.minZ), (color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 0.5F); } } @SubscribeEvent - public void onOverlayRender(RenderGuiOverlayEvent.Post event) { + public void onOverlayRender(RenderGuiLayerEvent.Post event) { var mc = Minecraft.getInstance(); var graphics = event.getGuiGraphics(); var stack = graphics.pose(); - if (event.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) { - var res = event.getWindow(); + if (event.getName() == VanillaGuiLayers.HOTBAR) { + var res = mc.getWindow(); if (mc.player != null) { if (!ClientEvents.heldCache.isEmpty()) { var container = ClientEvents.heldCache.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY, null); @@ -368,7 +361,7 @@ public class ClientEvents { var state = mc.level.getBlockState(pos); var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player); this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), - mc, res, 35, blockStack.getHoverName().getString(), null); + mc, res, 35, blockStack.getHoverName().getString(), null); if (tile instanceof BlockEntityNatureAltar) { var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null); @@ -377,23 +370,23 @@ public class ClientEvents { var stackCont = tileStack.getCapability(NaturesAuraAPI.AURA_CONTAINER_ITEM_CAPABILITY); if (stackCont != null) { this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), - mc, res, 55, tileStack.getHoverName().getString(), null); + mc, res, 55, tileStack.getHoverName().getString(), null); } } } } else if (tile instanceof BlockEntityRFConverter) { EnergyStorage storage = ((BlockEntityRFConverter) tile).storage; this.drawContainerInfo(graphics, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, - mc, res, 35, I18n.get("block.naturesaura.rf_converter"), - storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); + mc, res, 35, I18n.get("block.naturesaura.rf_converter"), + storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); } else if (tile instanceof BlockEntityGratedChute chute) { var itemHandler = tile.getLevel().getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null); var itemStack = itemHandler.getStackInSlot(0); if (itemStack.isEmpty()) { graphics.drawString(mc.font, - ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"), - x + 5, y - 11, 0xFFFFFF); + ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"), + x + 5, y - 11, 0xFFFFFF); } else { Helper.renderItemInGui(graphics, itemStack, x + 2, y - 18, 1F); } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index c0d7b1f6..48850e66 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -19,13 +19,14 @@ import net.minecraft.server.level.ServerChunkCache; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.LevelChunk; -import net.neoforged.neoforge.event.TickEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import net.neoforged.neoforge.event.level.ChunkEvent; import net.neoforged.neoforge.event.level.ChunkWatchEvent; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.util.ObfuscationReflectionHelper; import net.neoforged.neoforge.event.RegisterCommandsEvent; +import net.neoforged.neoforge.event.tick.LevelTickEvent; +import net.neoforged.neoforge.event.tick.PlayerTickEvent; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -65,12 +66,12 @@ public class CommonEvents { @SubscribeEvent @SuppressWarnings("unchecked") - public void onLevelTick(TickEvent.LevelTickEvent event) { - if (!event.level.isClientSide && event.phase == TickEvent.Phase.END) { - if (event.level.getGameTime() % 20 == 0) { - event.level.getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick"); + public void onLevelTick(LevelTickEvent.Post event) { + if (!event.getLevel().isClientSide) { + if (event.getLevel().getGameTime() % 20 == 0) { + event.getLevel().getProfiler().push(NaturesAura.MOD_ID + ":onLevelTick"); try { - var manager = ((ServerChunkCache) event.level.getChunkSource()).chunkMap; + var manager = ((ServerChunkCache) event.getLevel().getChunkSource()).chunkMap; var chunks = (Iterable) CommonEvents.GET_LOADED_CHUNKS_METHOD.invoke(manager); for (var holder : chunks) { var chunk = holder.getTickingChunk(); @@ -83,27 +84,27 @@ public class CommonEvents { } catch (IllegalAccessException | InvocationTargetException e) { NaturesAura.LOGGER.fatal(e); } - event.level.getProfiler().pop(); + event.getLevel().getProfiler().pop(); } } } @SubscribeEvent - public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (!event.player.level().isClientSide && event.phase == TickEvent.Phase.END) { - if (event.player.level().getGameTime() % 10 == 0) { - var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.player.getUUID()); - pending.removeIf(p -> this.handleChunkWatchDeferred(event.player, p)); + public void onPlayerTick(PlayerTickEvent.Post event) { + if (!event.getEntity().level().isClientSide) { + if (event.getEntity().level().getGameTime() % 10 == 0) { + var pending = CommonEvents.PENDING_AURA_CHUNKS.get(event.getEntity().getUUID()); + pending.removeIf(p -> this.handleChunkWatchDeferred(event.getEntity(), p)); } - if (event.player.level().getGameTime() % 200 != 0) + if (event.getEntity().level().getGameTime() % 200 != 0) return; - var aura = IAuraChunk.triangulateAuraInArea(event.player.level(), event.player.blockPosition(), 25); + var aura = IAuraChunk.triangulateAuraInArea(event.getEntity().level(), event.getEntity().blockPosition(), 25); if (aura <= 0) - Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); + Helper.addAdvancement(event.getEntity(), ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); else if (aura >= 1500000) - Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "positive_imbalance"), "triggered_in_code"); + Helper.addAdvancement(event.getEntity(), ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "positive_imbalance"), "triggered_in_code"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java index 6644366b..38d96d25 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/ModFeatures.java @@ -1,9 +1,8 @@ package de.ellpeck.naturesaura.gen; import de.ellpeck.naturesaura.NaturesAura; -import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; -import net.minecraft.data.worldgen.BootstapContext; +import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.data.worldgen.features.FeatureUtils; import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.resources.ResourceKey; @@ -13,7 +12,7 @@ import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConf import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.placement.PlacedFeature; -@SuppressWarnings("NonConstantFieldWithUpperCaseName") +@SuppressWarnings({"NonConstantFieldWithUpperCaseName", "FieldNamingConvention"}) public final class ModFeatures { public static Feature ANCIENT_TREE; @@ -26,16 +25,15 @@ public final class ModFeatures { public static final class Configured { - public static ResourceKey> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree"); - public static ResourceKey> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom"); - public static ResourceKey> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); - public static ResourceKey> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); - public static ResourceKey> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); - public static ResourceKey> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); - public static ResourceKey> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); + public static final ResourceKey> ANCIENT_TREE = FeatureUtils.createKey(NaturesAura.MOD_ID + ":ancient_tree"); + public static final ResourceKey> NETHER_WART_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":nether_wart_mushroom"); + public static final ResourceKey> AURA_BLOOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); + public static final ResourceKey> AURA_CACTUS = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); + public static final ResourceKey> WARPED_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); + public static final ResourceKey> CRIMSON_AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); + public static final ResourceKey> AURA_MUSHROOM = FeatureUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); - - public static void bootstrap(BootstapContext> context) { + public static void bootstrap(BootstrapContext> context) { FeatureUtils.register(context, ModFeatures.Configured.AURA_BLOOM, ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); FeatureUtils.register(context, ModFeatures.Configured.AURA_CACTUS, ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE); FeatureUtils.register(context, ModFeatures.Configured.WARPED_AURA_MUSHROOM, ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); @@ -45,25 +43,28 @@ public final class ModFeatures { FeatureUtils.register(context, ModFeatures.Configured.NETHER_WART_MUSHROOM, ModFeatures.NETHER_WART_MUSHROOM, NoneFeatureConfiguration.INSTANCE); } + } public static final class Placed { - public static ResourceKey AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); - public static ResourceKey AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); - public static ResourceKey WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); - public static ResourceKey CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); - public static ResourceKey AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); + public static final ResourceKey AURA_BLOOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_bloom"); + public static final ResourceKey AURA_CACTUS = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_cactus"); + public static final ResourceKey WARPED_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":warped_aura_mushroom"); + public static final ResourceKey CRIMSON_AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":crimson_aura_mushroom"); + public static final ResourceKey AURA_MUSHROOM = PlacementUtils.createKey(NaturesAura.MOD_ID + ":aura_mushroom"); - public static void bootstrap(BootstapContext context) { - HolderGetter> holdergetter = context.lookup(Registries.CONFIGURED_FEATURE); + public static void bootstrap(BootstrapContext context) { + var holdergetter = context.lookup(Registries.CONFIGURED_FEATURE); - PlacementUtils.register(context, AURA_BLOOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_BLOOM)); - PlacementUtils.register(context, AURA_CACTUS, holdergetter.getOrThrow(ModFeatures.Configured.AURA_CACTUS)); - PlacementUtils.register(context, WARPED_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.WARPED_AURA_MUSHROOM)); - PlacementUtils.register(context, CRIMSON_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.CRIMSON_AURA_MUSHROOM)); - PlacementUtils.register(context, AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_MUSHROOM)); + PlacementUtils.register(context, Placed.AURA_BLOOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_BLOOM)); + PlacementUtils.register(context, Placed.AURA_CACTUS, holdergetter.getOrThrow(ModFeatures.Configured.AURA_CACTUS)); + PlacementUtils.register(context, Placed.WARPED_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.WARPED_AURA_MUSHROOM)); + PlacementUtils.register(context, Placed.CRIMSON_AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.CRIMSON_AURA_MUSHROOM)); + PlacementUtils.register(context, Placed.AURA_MUSHROOM, holdergetter.getOrThrow(ModFeatures.Configured.AURA_MUSHROOM)); } + } + } diff --git a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java index b2d519de..10f9ad9c 100644 --- a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java @@ -11,7 +11,7 @@ import net.neoforged.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class GuiEnderCrate extends AbstractContainerScreen { - private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png"); + private static final ResourceLocation CHEST_GUI_TEXTURE = ResourceLocation.withDefaultNamespace("textures/gui/container/generic_54.png"); public GuiEnderCrate(ContainerEnderCrate container, Inventory inv, Component title) { super(container, inv, title); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index 6f3f6a86..3e2ea56c 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -10,6 +10,7 @@ import de.ellpeck.naturesaura.reg.ICustomCreativeTab; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.core.Holder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; @@ -40,7 +41,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem, ICustomCrea if (recharge != null) { if (recharge.rechargeFromContainer(container, itemSlot, i, player.getInventory().selected == i)) break; - } else if (stack.getEnchantmentLevel(ModEnchantments.AURA_MENDING) > 0) { + } else if (stack.getEnchantmentLevel(Holder.direct(ModEnchantments.AURA_MENDING)) > 0) { var mainSize = player.getInventory().items.size(); var isArmor = i >= mainSize && i < mainSize + player.getInventory().armor.size(); if ((isArmor || player.getInventory().selected == i) && Helper.rechargeAuraItem(stack, container, 1000)) diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java index 74493231..0e62fba7 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java @@ -4,7 +4,6 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.SpawnPlacements; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -33,12 +32,13 @@ public class ItemCaveFinder extends ItemImpl { for (var z = -range; z <= range; z++) { var offset = pos.offset(x, y, z); var state = levelIn.getBlockState(offset); - try { + // TODO figure out an entity-independent way of checking if a block is a valid spawn (just checking for air & ground below?) +/* try { if (!state.getBlock().isValidSpawn(state, levelIn, offset, SpawnPlacements.Type.ON_GROUND, null)) continue; } catch (Exception e) { continue; - } + }*/ var offUp = offset.above(); var stateUp = levelIn.getBlockState(offUp); @@ -51,8 +51,8 @@ public class ItemCaveFinder extends ItemImpl { continue; inst.spawnMagicParticle( - offset.getX() + 0.5F, offset.getY() + 1.5F, offset.getZ() + 0.5F, - 0F, 0F, 0F, 0x992101, 2.5F, 20 * 30, 0F, false, true); + offset.getX() + 0.5F, offset.getY() + 1.5F, offset.getZ() + 0.5F, + 0F, 0F, 0F, 0x992101, 2.5F, 20 * 30, 0F, false, true); } inst.setParticleDepth(true); inst.setParticleSpawnRange(32); @@ -63,4 +63,5 @@ public class ItemCaveFinder extends ItemImpl { playerIn.getCooldowns().addCooldown(this, 20 * 30); return new InteractionResultHolder<>(InteractionResult.SUCCESS, stack); } + } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java index 4cad93e7..129699ea 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java @@ -4,7 +4,9 @@ import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModArmorMaterial; import de.ellpeck.naturesaura.reg.ModRegistry; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.EquipmentSlot; @@ -18,24 +20,22 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.phys.AABB; import net.neoforged.bus.api.SubscribeEvent; -import net.neoforged.fml.common.Mod; -import net.neoforged.neoforge.common.NeoForgeMod; -import net.neoforged.neoforge.event.TickEvent; -import net.neoforged.neoforge.event.entity.living.LivingAttackEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent; +import net.neoforged.neoforge.event.tick.PlayerTickEvent; import java.util.Comparator; import java.util.Map; -import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; public class ItemArmor extends ArmorItem implements IModItem { - private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(UUID.fromString("c1f96acc-e117-4dc1-a351-e196a4de6071"), NaturesAura.MOD_ID + ":sky_movement_speed", 0.15F, AttributeModifier.Operation.MULTIPLY_TOTAL); - private static final AttributeModifier SKY_STEP_MODIFIER = new AttributeModifier(UUID.fromString("ac3ce414-7243-418c-97f8-ac84c2c102f6"), NaturesAura.MOD_ID + ":sky_step_modifier", 0.5F, AttributeModifier.Operation.ADDITION); + private static final AttributeModifier SKY_MOVEMENT_MODIFIER = new AttributeModifier(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "sky_movement_speed"), 0.15F, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL); + private static final AttributeModifier SKY_STEP_MODIFIER = new AttributeModifier(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "sky_step_modifier"), 0.5F, AttributeModifier.Operation.ADD_VALUE); private static final Map SETS = new ConcurrentHashMap<>(); private final String baseName; - public ItemArmor(String baseName, ArmorMaterial materialIn, ArmorItem.Type equipmentSlotIn) { + public ItemArmor(String baseName, Holder materialIn, ArmorItem.Type equipmentSlotIn) { super(materialIn, equipmentSlotIn, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); @@ -43,9 +43,9 @@ public class ItemArmor extends ArmorItem implements IModItem { public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) { var set = ItemArmor.SETS.computeIfAbsent(material, m -> BuiltInRegistries.ITEM.stream() - .filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material) - .sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal())) - .toArray(Item[]::new)); + .filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial().value() == material) + .sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal())) + .toArray(Item[]::new)); for (var i = 0; i < 4; i++) { var slot = EquipmentSlot.values()[i + 2]; var stack = entity.getItemBySlot(slot); @@ -60,11 +60,11 @@ public class ItemArmor extends ArmorItem implements IModItem { return this.baseName; } - @Mod.EventBusSubscriber + @EventBusSubscriber private static final class EventHandler { @SubscribeEvent - public static void onAttack(LivingAttackEvent event) { + public static void onAttack(LivingIncomingDamageEvent event) { var entity = event.getEntity(); if (!entity.level().isClientSide) { if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) { @@ -81,25 +81,25 @@ public class ItemArmor extends ArmorItem implements IModItem { } @SubscribeEvent - public static void update(TickEvent.PlayerTickEvent event) { - var player = event.player; + public static void update(PlayerTickEvent event) { + var player = event.getEntity(); var speed = player.getAttribute(Attributes.MOVEMENT_SPEED); - var step = player.getAttribute(NeoForgeMod.STEP_HEIGHT.value()); + var step = player.getAttribute(Attributes.STEP_HEIGHT); var key = NaturesAura.MOD_ID + ":sky_equipped"; var nbt = player.getPersistentData(); var equipped = ItemArmor.isFullSetEquipped(player, ModArmorMaterial.SKY); if (equipped && !nbt.getBoolean(key)) { // we just equipped it nbt.putBoolean(key, true); - if (!step.hasModifier(ItemArmor.SKY_STEP_MODIFIER)) + if (!step.hasModifier(ItemArmor.SKY_STEP_MODIFIER.id())) step.addPermanentModifier(ItemArmor.SKY_STEP_MODIFIER); - if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER)) + if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.id())) speed.addPermanentModifier(ItemArmor.SKY_MOVEMENT_MODIFIER); } else if (!equipped && nbt.getBoolean(key)) { // we just unequipped it nbt.putBoolean(key, false); - step.removeModifier(ItemArmor.SKY_STEP_MODIFIER.getId()); - speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.getId()); + step.removeModifier(ItemArmor.SKY_STEP_MODIFIER.id()); + speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER.id()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java index 18a06838..6b444db9 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -10,6 +10,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.tags.BlockTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.AxeItem; import net.minecraft.world.item.ItemStack; @@ -20,10 +21,12 @@ import net.minecraft.world.level.block.state.BlockState; public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { private final String baseName; + private final float defaultSpeed; public ItemAxe(String baseName, Tier material, float damage, float speed) { - super(material, damage, speed, new Properties()); + super(material, new Properties().attributes(AxeItem.createAttributes(material, damage, speed))); this.baseName = baseName; + this.defaultSpeed = speed; ModRegistry.ALL_ITEMS.add(this); } @@ -35,20 +38,19 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public float getDestroySpeed(ItemStack stack, BlockState state) { if (state.is(BlockTags.LEAVES)) { - return this.speed; + return this.defaultSpeed; } else { return super.getDestroySpeed(stack, state); } } @Override - public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) { - if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.isToolEnabled(stack) && player.level().getBlockState(pos).is(BlockTags.LOGS)) { + public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity miningEntity) { + if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.isToolEnabled(stack) && level.getBlockState(pos).is(BlockTags.LOGS)) { var horRange = stack.getItem() == ModItems.DEPTH_AXE ? 6 : 1; - Helper.mineRecursively(player.level(), pos, pos, stack, horRange, 32, s -> s.is(BlockTags.LOGS)); - return true; + Helper.mineRecursively(level, pos, pos, stack, horRange, 32, s -> s.is(BlockTags.LOGS)); } - return false; + return super.mineBlock(stack, level, state, pos, miningEntity); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java index 74cf976e..7674111a 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java @@ -7,17 +7,19 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.HoeItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BushBlock; import net.minecraft.world.level.block.LeavesBlock; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { @@ -25,7 +27,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { private final String baseName; public ItemHoe(String baseName, Tier material, int speed) { - super(material, speed, 0, new Properties()); + super(material, new Properties().attributes(HoeItem.createAttributes(material, 0, speed))); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -74,31 +76,31 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { } @Override - public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, Player player) { - if (!player.isShiftKeyDown() && (stack.getItem() == ModItems.SKY_HOE || stack.getItem() == ModItems.DEPTH_HOE)) { - var block = player.level().getBlockState(pos).getBlock(); - if (!(block instanceof BushBlock) && (stack.getItem() != ModItems.DEPTH_HOE || !(block instanceof LeavesBlock))) - return false; - if (!player.level().isClientSide) { - var range = 3; - for (var x = -range; x <= range; x++) { - for (var y = -range; y <= range; y++) { - for (var z = -range; z <= range; z++) { - if (x == 0 && y == 0 && z == 0) - continue; - var offset = pos.offset(x, y, z); - var offState = player.level().getBlockState(offset); - if (offState.getBlock() instanceof BushBlock || stack.getItem() == ModItems.DEPTH_HOE && offState.getBlock() instanceof LeavesBlock) { - var entity = offState.hasBlockEntity() ? player.level().getBlockEntity(offset) : null; - Block.dropResources(offState, player.level(), offset, entity, null, stack); - player.level().setBlock(offset, Blocks.AIR.defaultBlockState(), 3); + public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity miningEntity) { + if (!miningEntity.isShiftKeyDown() && (stack.getItem() == ModItems.SKY_HOE || stack.getItem() == ModItems.DEPTH_HOE)) { + var block = level.getBlockState(pos).getBlock(); + if (block instanceof BushBlock || stack.getItem() == ModItems.DEPTH_HOE && block instanceof LeavesBlock) { + if (!level.isClientSide) { + var range = 3; + for (var x = -range; x <= range; x++) { + for (var y = -range; y <= range; y++) { + for (var z = -range; z <= range; z++) { + if (x == 0 && y == 0 && z == 0) + continue; + var offset = pos.offset(x, y, z); + var offState = level.getBlockState(offset); + if (offState.getBlock() instanceof BushBlock || stack.getItem() == ModItems.DEPTH_HOE && offState.getBlock() instanceof LeavesBlock) { + var entity = offState.hasBlockEntity() ? level.getBlockEntity(offset) : null; + Block.dropResources(offState, level, offset, entity, null, stack); + level.setBlock(offset, Blocks.AIR.defaultBlockState(), 3); + } } } } } } } - return false; + return super.mineBlock(stack, level, state, pos, miningEntity); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java index 1f149e7e..65154926 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java @@ -16,6 +16,7 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; @@ -23,6 +24,7 @@ import net.minecraft.world.item.PickaxeItem; import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; import net.neoforged.neoforge.common.Tags; @@ -31,7 +33,7 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod private final String baseName; public ItemPickaxe(String baseName, Tier material, int damage, float speed) { - super(material, damage, speed, new Properties()); + super(material, new Properties().attributes(PickaxeItem.createAttributes(material, damage, speed))); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -58,7 +60,7 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod data.addMossStone(pos); } level.playSound(player, pos, SoundEvents.STONE_PLACE, SoundSource.BLOCKS, 1.0F, 1.0F); - stack.hurtAndBreak(15, player, p -> p.broadcastBreakEvent(context.getHand())); + stack.hurtAndBreak(15, player, LivingEntity.getSlotForHand(context.getHand())); return InteractionResult.SUCCESS; } } @@ -84,12 +86,11 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod } @Override - public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, Player player) { - if (itemstack.getItem() == ModItems.DEPTH_PICKAXE && Helper.isToolEnabled(itemstack) && player.level().getBlockState(pos).is(Tags.Blocks.ORES)) { - Helper.mineRecursively(player.level(), pos, pos, itemstack, 5, 5, s -> s.is(Tags.Blocks.ORES)); - return true; - } - return false; + public boolean mineBlock(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity miningEntity) { + // TODO test depth pickaxe vein mining + if (stack.getItem() == ModItems.DEPTH_PICKAXE && Helper.isToolEnabled(stack) && level.getBlockState(pos).is(Tags.Blocks.ORES)) + Helper.mineRecursively(level, pos, pos, stack, 5, 5, s -> s.is(Tags.Blocks.ORES)); + return super.mineBlock(stack, level, state, pos, miningEntity); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java index 8497e378..eb3d6e7f 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java @@ -12,6 +12,7 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ShovelItem; import net.minecraft.world.item.Tier; @@ -27,7 +28,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel private final String baseName; public ItemShovel(String baseName, Tier material, float damage, float speed) { - super(material, damage, speed, new Properties()); + super(material, new Properties().attributes(ShovelItem.createAttributes(material, damage, speed))); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -65,7 +66,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel } level.playSound(player, pos, SoundEvents.GRASS_PLACE, SoundSource.BLOCKS, 1.0F, 1.0F); - stack.hurtAndBreak(Mth.ceil(damage), player, p -> p.broadcastBreakEvent(context.getHand())); + stack.hurtAndBreak(Mth.ceil(damage), player, LivingEntity.getSlotForHand(context.getHand())); return InteractionResult.SUCCESS; } } @@ -80,8 +81,8 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel var facing = context.getClickedFace(); if (player.mayUseItemAt(actualPos.relative(facing), facing, stack)) { if (facing != Direction.DOWN - && level.getBlockState(actualPos.above()).isAir() - && level.getBlockState(actualPos).getBlock() == Blocks.GRASS_BLOCK) { + && level.getBlockState(actualPos.above()).isAir() + && level.getBlockState(actualPos).getBlock() == Blocks.GRASS_BLOCK) { if (!level.isClientSide) level.setBlock(actualPos, Blocks.DIRT_PATH.defaultBlockState(), 11); flattened = true; @@ -91,7 +92,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel } if (flattened) { level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); - stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand())); + stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(context.getHand())); return InteractionResult.SUCCESS; } } @@ -109,7 +110,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel Block.dropResources(state, level, pos, tile, null, stack); var newContext = new UseOnContext(player, otherHand, new BlockHitResult(context.getClickLocation(), context.getClickedFace(), context.getClickedPos(), context.isInside())); other.useOn(newContext); - stack.hurtAndBreak(1, player, p -> p.broadcastBreakEvent(context.getHand())); + stack.hurtAndBreak(1, player, LivingEntity.getSlotForHand(context.getHand())); return InteractionResult.SUCCESS; } diff --git a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java index a612a345..2b50b572 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -24,7 +24,7 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { private final String baseName; public ItemSword(String baseName, Tier material, int damage, float speed) { - super(material, damage, speed, new Properties()); + super(material, new Properties().attributes(SwordItem.createAttributes(material, damage, speed))); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } diff --git a/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java b/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java index 64c8f6d7..5ad6badc 100644 --- a/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java +++ b/src/main/java/de/ellpeck/naturesaura/misc/ColoredBlockHelper.java @@ -23,7 +23,7 @@ public final class ColoredBlockHelper { private static List collectBlocks(String name) { return Arrays.stream(DyeColor.values()).sorted(Comparator.comparingInt(DyeColor::getId)).map(c -> { - var loc = new ResourceLocation(c.getName() + '_' + name); + var loc = ResourceLocation.parse(c.getName() + '_' + name); var block = BuiltInRegistries.BLOCK.get(loc); if (block == null || block == Blocks.AIR) throw new IllegalStateException("Couldn't find block with name " + loc); diff --git a/src/main/java/de/ellpeck/naturesaura/misc/LevelData.java b/src/main/java/de/ellpeck/naturesaura/misc/LevelData.java index b68ec288..3a1b1548 100644 --- a/src/main/java/de/ellpeck/naturesaura/misc/LevelData.java +++ b/src/main/java/de/ellpeck/naturesaura/misc/LevelData.java @@ -10,6 +10,7 @@ import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.items.ModItems; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.LongTag; @@ -39,24 +40,24 @@ public class LevelData extends SavedData implements ILevelData { } - public LevelData(CompoundTag compound) { + public LevelData(CompoundTag compound, HolderLookup.Provider registries) { for (var base : compound.getList("storages", 10)) { var storageComp = (CompoundTag) base; var storage = this.getEnderStorage(storageComp.getString("name")); - storage.deserializeNBT(storageComp); + storage.deserializeNBT(registries, storageComp); } for (var base : compound.getList("converted_moss", Tag.TAG_LONG)) this.recentlyConvertedMossStones.add(BlockPos.of(((LongTag) base).getAsLong())); } @Override - public CompoundTag save(CompoundTag compound) { + public CompoundTag save(CompoundTag compound, HolderLookup.Provider registries) { var storages = new ListTag(); for (var entry : this.enderStorages.entrySet()) { var handler = entry.getValue(); if (Helper.isEmpty(handler)) continue; - var storageComp = handler.serializeNBT(); + var storageComp = handler.serializeNBT(registries); storageComp.putString("name", entry.getKey()); storages.add(storageComp); } @@ -94,7 +95,7 @@ public class LevelData extends SavedData implements ILevelData { public void addMossStone(BlockPos pos) { this.recentlyConvertedMossStones.add(pos); if (this.recentlyConvertedMossStones.size() > 512) - this.recentlyConvertedMossStones.remove(0); + this.recentlyConvertedMossStones.removeFirst(); } } diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index ef46597a..4b31eeba 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -16,6 +16,7 @@ import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; +import org.jetbrains.annotations.Nullable; import java.util.Locale; import java.util.function.Supplier; @@ -26,15 +27,10 @@ public final class ParticleHandler { public static final ParticleRenderType MAGIC = new ParticleRenderType() { @Override - public void begin(BufferBuilder buffer, TextureManager textureManager) { + public @Nullable BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) { ParticleHandler.setupRendering(); RenderSystem.enableDepthTest(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - } - - @Override - public void end(Tesselator tessellator) { - tessellator.end(); + return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } @Override @@ -45,15 +41,10 @@ public final class ParticleHandler { public static final ParticleRenderType MAGIC_NO_DEPTH = new ParticleRenderType() { @Override - public void begin(BufferBuilder buffer, TextureManager textureManager) { + public @Nullable BufferBuilder begin(Tesselator tesselator, TextureManager textureManager) { ParticleHandler.setupRendering(); RenderSystem.disableDepthTest(); - buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); - } - - @Override - public void end(Tesselator tessellator) { - tessellator.end(); + return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); } @Override @@ -73,8 +64,8 @@ public final class ParticleHandler { if (ModConfig.instance.respectVanillaParticleSettings.get()) { var setting = mc.options.particles().get(); if (setting != ParticleStatus.ALL && - (setting != ParticleStatus.DECREASED || mc.level.random.nextInt(3) != 0) && - (setting != ParticleStatus.MINIMAL || mc.level.random.nextInt(10) != 0)) + (setting != ParticleStatus.DECREASED || mc.level.random.nextInt(3) != 0) && + (setting != ParticleStatus.MINIMAL || mc.level.random.nextInt(10) != 0)) return; } double setting = ModConfig.instance.particleAmount.get(); @@ -94,4 +85,5 @@ public final class ParticleHandler { RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, ParticleMagic.TEXTURE); } -} \ No newline at end of file + +} diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java index ad0dff04..fd1592e0 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java @@ -19,7 +19,7 @@ import java.util.Collections; @OnlyIn(Dist.CLIENT) public class ParticleMagic extends Particle { - public static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "textures/particles/magic_round.png"); + public static final ResourceLocation TEXTURE = ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "textures/particles/magic_round.png"); private final float desiredScale; private final boolean fade; @@ -109,10 +109,10 @@ public class ParticleMagic extends Particle { } var j = this.getLightColor(partialTicks); - buffer.vertex(avector3f[0].x(), avector3f[0].y(), avector3f[0].z()).uv(0, 1).color(this.rCol, this.gCol, this.bCol, this.alpha).uv2(j).endVertex(); - buffer.vertex(avector3f[1].x(), avector3f[1].y(), avector3f[1].z()).uv(1, 1).color(this.rCol, this.gCol, this.bCol, this.alpha).uv2(j).endVertex(); - buffer.vertex(avector3f[2].x(), avector3f[2].y(), avector3f[2].z()).uv(1, 0).color(this.rCol, this.gCol, this.bCol, this.alpha).uv2(j).endVertex(); - buffer.vertex(avector3f[3].x(), avector3f[3].y(), avector3f[3].z()).uv(0, 0).color(this.rCol, this.gCol, this.bCol, this.alpha).uv2(j).endVertex(); + buffer.addVertex(avector3f[0].x(), avector3f[0].y(), avector3f[0].z()).setUv(0, 1).setColor(this.rCol, this.gCol, this.bCol, this.alpha).setLight(j); + buffer.addVertex(avector3f[1].x(), avector3f[1].y(), avector3f[1].z()).setUv(1, 1).setColor(this.rCol, this.gCol, this.bCol, this.alpha).setLight(j); + buffer.addVertex(avector3f[2].x(), avector3f[2].y(), avector3f[2].z()).setUv(1, 0).setColor(this.rCol, this.gCol, this.bCol, this.alpha).setLight(j); + buffer.addVertex(avector3f[3].x(), avector3f[3].y(), avector3f[3].z()).setUv(0, 0).setColor(this.rCol, this.gCol, this.bCol, this.alpha).setLight(j); } @Override @@ -124,4 +124,5 @@ public class ParticleMagic extends Particle { protected int getLightColor(float p_107249_) { return 15 << 20 | 15 << 4; } + } diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java index 4a804316..1c2ab911 100644 --- a/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.potion; +import net.minecraft.core.Holder; import net.minecraft.world.effect.MobEffectCategory; import net.minecraft.world.entity.LivingEntity; import net.neoforged.neoforge.common.NeoForge; @@ -19,7 +20,7 @@ public class PotionBreathless extends PotionImpl { @SubscribeEvent public void onHeal(LivingHealEvent event) { - var effect = event.getEntity().getEffect(this); + var effect = event.getEntity().getEffect(Holder.direct(this)); if (effect == null) return; var chance = (effect.getAmplifier() + 1) / 15F; @@ -35,8 +36,9 @@ public class PotionBreathless extends PotionImpl { } @Override - public void applyEffectTick(LivingEntity entity, int amplifier) { + public boolean applyEffectTick(LivingEntity entity, int amplifier) { entity.hurt(entity.damageSources().magic(), 1F); + return true; } } diff --git a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java index 2f6ccedd..e17b5402 100644 --- a/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java +++ b/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java @@ -22,7 +22,6 @@ import de.ellpeck.naturesaura.reg.ModRegistry; import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets; import de.ellpeck.naturesaura.renderers.SupporterFancyHandler; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.EntityRenderer; @@ -30,35 +29,43 @@ import net.minecraft.client.renderer.entity.EntityRenderers; import net.minecraft.client.renderer.entity.ThrownItemRenderer; import net.minecraft.client.renderer.entity.player.PlayerRenderer; import net.minecraft.client.renderer.item.ItemProperties; +import net.minecraft.client.resources.PlayerSkin; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; -import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent; +import net.neoforged.neoforge.common.NeoForge; public class ClientProxy implements IProxy { + // TODO check ender crate registry functions + @SubscribeEvent + public void registerMenuScreens(RegisterMenuScreensEvent event) { + event.register(ModContainers.ENDER_CRATE, GuiEnderCrate::new); + event.register(ModContainers.ENDER_ACCESS, GuiEnderCrate::new); + } + @Override public void preInit(FMLCommonSetupEvent event) { NeoForge.EVENT_BUS.register(new ClientEvents()); Compat.setupClient(); - MenuScreens.register(ModContainers.ENDER_CRATE, GuiEnderCrate::new); - MenuScreens.register(ModContainers.ENDER_ACCESS, GuiEnderCrate::new); - ItemProperties.register(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "fill_mode"), - (stack, level, entity, i) -> ItemColorChanger.isFillMode(stack) ? 1 : 0); - ItemProperties.register(ModItems.COLOR_CHANGER, new ResourceLocation(NaturesAura.MOD_ID, "has_color"), - (stack, level, entity, i) -> ItemColorChanger.getStoredColor(stack) != null ? 1 : 0); + ItemProperties.register(ModItems.COLOR_CHANGER, ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "fill_mode"), + (stack, level, entity, i) -> ItemColorChanger.isFillMode(stack) ? 1 : 0); + ItemProperties.register(ModItems.COLOR_CHANGER, ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "has_color"), + (stack, level, entity, i) -> ItemColorChanger.getStoredColor(stack) != null ? 1 : 0); for (var item : new Item[]{ModItems.SKY_AXE, ModItems.DEPTH_PICKAXE, ModItems.DEPTH_AXE}) { - ItemProperties.register(item, new ResourceLocation(NaturesAura.MOD_ID, "enabled"), - (stack, level, entity, i) -> Helper.isToolEnabled(stack) ? 1 : 0); + ItemProperties.register(item, ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "enabled"), + (stack, level, entity, i) -> Helper.isToolEnabled(stack) ? 1 : 0); } } @Override public void init(FMLCommonSetupEvent event) { var skinMap = Minecraft.getInstance().getEntityRenderDispatcher().getSkinMap(); - for (var render : new EntityRenderer[]{skinMap.get("default"), skinMap.get("slim")}) { + for (var render : new EntityRenderer[]{skinMap.get(PlayerSkin.Model.WIDE), skinMap.get(PlayerSkin.Model.SLIM)}) { if (render instanceof PlayerRenderer living) living.addLayer(new PlayerLayerTrinkets(living)); } @@ -89,9 +96,9 @@ public class ClientProxy implements IProxy { @Override public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level, - posX, posY, posZ, - motionX, motionY, motionZ, - color, scale, maxAge, gravity, collision, fade, ParticleHandler.depthEnabled), posX, posY, posZ); + posX, posY, posZ, + motionX, motionY, motionZ, + color, scale, maxAge, gravity, collision, fade, ParticleHandler.depthEnabled), posX, posY, posZ); } @Override @@ -126,4 +133,4 @@ public class ClientProxy implements IProxy { Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block); } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java index 8b00bd1d..ae65cbe1 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java @@ -1,16 +1,17 @@ package de.ellpeck.naturesaura.recipes; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; -import javax.annotation.Nullable; - public class AltarRecipe extends ModRecipe { public final Ingredient input; @@ -28,7 +29,7 @@ public class AltarRecipe extends ModRecipe { } @Override - public ItemStack getResultItem(RegistryAccess access) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return this.output; } @@ -44,32 +45,23 @@ public class AltarRecipe extends ModRecipe { public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input), - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("output").forGetter(r -> r.output), - Ingredient.CODEC.optionalFieldOf("catalyst", Ingredient.EMPTY).forGetter(r -> r.catalyst), - Codec.INT.fieldOf("aura").forGetter(r -> r.aura), - Codec.INT.fieldOf("time").forGetter(r -> r.time) + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( + Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input), + ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output), + Ingredient.CODEC.optionalFieldOf("catalyst", Ingredient.EMPTY).forGetter(r -> r.catalyst), + Codec.INT.fieldOf("aura").forGetter(r -> r.aura), + Codec.INT.fieldOf("time").forGetter(r -> r.time) ).apply(i, AltarRecipe::new)); + private static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(Serializer.CODEC.codec()); @Override - public Codec codec() { + public MapCodec codec() { return Serializer.CODEC; } - @Nullable @Override - public AltarRecipe fromNetwork(FriendlyByteBuf buffer) { - return new AltarRecipe(Ingredient.fromNetwork(buffer), buffer.readItem(), Ingredient.fromNetwork(buffer), buffer.readInt(), buffer.readInt()); - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, AltarRecipe recipe) { - recipe.input.toNetwork(buffer); - buffer.writeItem(recipe.output); - recipe.catalyst.toNetwork(buffer); - buffer.writeInt(recipe.aura); - buffer.writeInt(recipe.time); + public StreamCodec streamCodec() { + return Serializer.STREAM_CODEC; } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java index eee486fb..74e92cf1 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java @@ -1,11 +1,14 @@ package de.ellpeck.naturesaura.recipes; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.core.BlockPos; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; @@ -17,7 +20,6 @@ import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; -import java.util.ArrayList; import java.util.List; public class AnimalSpawnerRecipe extends ModRecipe { @@ -38,11 +40,11 @@ public class AnimalSpawnerRecipe extends ModRecipe { // passed position is zero on the client, so we don't want to do initialization stuff for the entity if (pos == BlockPos.ZERO) return this.entity.create(level); - return this.entity.create((ServerLevel) level, null, null, pos, MobSpawnType.SPAWNER, false, false); + return this.entity.create((ServerLevel) level, null, pos, MobSpawnType.SPAWNER, false, false); } @Override - public ItemStack getResultItem(RegistryAccess access) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -58,34 +60,22 @@ public class AnimalSpawnerRecipe extends ModRecipe { public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - ResourceLocation.CODEC.fieldOf("entity").forGetter(r -> BuiltInRegistries.ENTITY_TYPE.getKey(r.entity)), - Codec.INT.fieldOf("aura").forGetter(r -> r.aura), - Codec.INT.fieldOf("time").forGetter(r -> r.time), - Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(r -> r.ingredients) + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( + ResourceLocation.CODEC.fieldOf("entity").forGetter(r -> BuiltInRegistries.ENTITY_TYPE.getKey(r.entity)), + Codec.INT.fieldOf("aura").forGetter(r -> r.aura), + Codec.INT.fieldOf("time").forGetter(r -> r.time), + Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(r -> r.ingredients) ).apply(i, AnimalSpawnerRecipe::new)); + private static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(AnimalSpawnerRecipe.Serializer.CODEC.codec()); @Override - public Codec codec() { + public MapCodec codec() { return Serializer.CODEC; } @Override - public AnimalSpawnerRecipe fromNetwork(FriendlyByteBuf buffer) { - var ingredients = new ArrayList(); - for (var i = buffer.readInt(); i > 0; i--) - ingredients.add(Ingredient.fromNetwork(buffer)); - return new AnimalSpawnerRecipe(buffer.readResourceLocation(), buffer.readInt(), buffer.readInt(), ingredients); - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, AnimalSpawnerRecipe recipe) { - buffer.writeInt(recipe.ingredients.size()); - for (var ing : recipe.ingredients) - ing.toNetwork(buffer); - buffer.writeResourceLocation(BuiltInRegistries.ENTITY_TYPE.getKey(recipe.entity)); - buffer.writeInt(recipe.aura); - buffer.writeInt(recipe.time); + public StreamCodec streamCodec() { + return Serializer.STREAM_CODEC; } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java b/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java index 966c25d5..c1646189 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/EnabledCondition.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.recipes; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; @@ -9,8 +10,8 @@ import net.neoforged.neoforge.common.conditions.ICondition; public class EnabledCondition implements ICondition { - private static final Codec CODEC = RecordCodecBuilder.create(i -> - i.group(Codec.STRING.fieldOf("name").forGetter(c -> c.name)).apply(i, EnabledCondition::new) + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> + i.group(Codec.STRING.fieldOf("name").forGetter(c -> c.name)).apply(i, EnabledCondition::new) ); private ModConfigSpec.ConfigValue config; @@ -32,7 +33,7 @@ public class EnabledCondition implements ICondition { } @Override - public Codec codec() { + public MapCodec codec() { return EnabledCondition.CODEC; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java index 4c6cc45b..30ffda89 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.recipes; -import net.minecraft.core.RegistryAccess; +import net.minecraft.core.HolderLookup; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.level.Level; @@ -15,7 +15,7 @@ public abstract class ModRecipe implements Recipe { } @Override - public ItemStack assemble(RecipeWrapper inv, RegistryAccess access) { + public ItemStack assemble(RecipeWrapper input, HolderLookup.Provider registries) { return ItemStack.EMPTY; } @@ -24,5 +24,4 @@ public abstract class ModRecipe implements Recipe { return false; } - } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 321e1989..f2a4f9eb 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -30,18 +30,19 @@ public final class ModRecipes { public static void init() { NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( - Blocks.COBBLESTONE.defaultBlockState(), - Blocks.MOSSY_COBBLESTONE.defaultBlockState()); + Blocks.COBBLESTONE.defaultBlockState(), + Blocks.MOSSY_COBBLESTONE.defaultBlockState()); NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( - Blocks.STONE_BRICKS.defaultBlockState(), - Blocks.MOSSY_STONE_BRICKS.defaultBlockState()); + Blocks.STONE_BRICKS.defaultBlockState(), + Blocks.MOSSY_STONE_BRICKS.defaultBlockState()); NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( - Blocks.COBBLESTONE_WALL.defaultBlockState(), - Blocks.MOSSY_COBBLESTONE_WALL.defaultBlockState()); + Blocks.COBBLESTONE_WALL.defaultBlockState(), + Blocks.MOSSY_COBBLESTONE_WALL.defaultBlockState()); NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.put( - Blocks.STONE_BRICK_WALL.defaultBlockState(), - Blocks.MOSSY_STONE_BRICK_WALL.defaultBlockState()); + Blocks.STONE_BRICK_WALL.defaultBlockState(), + Blocks.MOSSY_STONE_BRICK_WALL.defaultBlockState()); + // TODO test if these ores still work! ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/coal", 5000); ModRecipes.ore(NaturesAuraAPI.NETHER_ORES, "ores/nether/coal", 5000); ModRecipes.ore(NaturesAuraAPI.OVERWORLD_ORES, "ores/iron", 3000); @@ -111,7 +112,7 @@ public final class ModRecipes { } private static void ore(List list, String name, int weight) { - var res = new ResourceLocation("forge", name); + var res = ResourceLocation.fromNamespaceAndPath("c", name); list.add(new WeightedOre(res, weight)); } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java index 18e671de..9047c725 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java @@ -1,16 +1,16 @@ package de.ellpeck.naturesaura.recipes; -import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; -import javax.annotation.Nullable; - public class OfferingRecipe extends ModRecipe { public final Ingredient input; @@ -24,7 +24,7 @@ public class OfferingRecipe extends ModRecipe { } @Override - public ItemStack getResultItem(RegistryAccess access) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return this.output; } @@ -40,28 +40,21 @@ public class OfferingRecipe extends ModRecipe { public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input), - Ingredient.CODEC.fieldOf("start_item").forGetter(r -> r.startItem), - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("output").forGetter(r -> r.output) + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( + Ingredient.CODEC.fieldOf("input").forGetter(r -> r.input), + Ingredient.CODEC.fieldOf("start_item").forGetter(r -> r.startItem), + ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output) ).apply(i, OfferingRecipe::new)); + private static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(OfferingRecipe.Serializer.CODEC.codec()); @Override - public Codec codec() { + public MapCodec codec() { return Serializer.CODEC; } - @Nullable @Override - public OfferingRecipe fromNetwork(FriendlyByteBuf buffer) { - return new OfferingRecipe(Ingredient.fromNetwork(buffer), Ingredient.fromNetwork(buffer), buffer.readItem()); - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, OfferingRecipe recipe) { - recipe.input.toNetwork(buffer); - recipe.startItem.toNetwork(buffer); - buffer.writeItem(recipe.output); + public StreamCodec streamCodec() { + return Serializer.STREAM_CODEC; } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java index 4e3fcf0b..2e32ca7d 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java @@ -1,16 +1,17 @@ package de.ellpeck.naturesaura.recipes; import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.core.HolderLookup; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; -import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; public class TreeRitualRecipe extends ModRecipe { @@ -28,7 +29,7 @@ public class TreeRitualRecipe extends ModRecipe { } @Override - public ItemStack getResultItem(RegistryAccess access) { + public ItemStack getResultItem(HolderLookup.Provider registries) { return this.output; } @@ -44,35 +45,22 @@ public class TreeRitualRecipe extends ModRecipe { public static class Serializer implements RecipeSerializer { - private static final Codec CODEC = RecordCodecBuilder.create(i -> i.group( - Ingredient.CODEC.fieldOf("sapling").forGetter(r -> r.saplingType), - ItemStack.ITEM_WITH_COUNT_CODEC.fieldOf("output").forGetter(r -> r.output), - Codec.INT.fieldOf("time").forGetter(r -> r.time), - Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(recipe -> recipe.ingredients) + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(i -> i.group( + Ingredient.CODEC.fieldOf("sapling").forGetter(r -> r.saplingType), + ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output), + Codec.INT.fieldOf("time").forGetter(r -> r.time), + Ingredient.CODEC.listOf().fieldOf("ingredients").forGetter(recipe -> recipe.ingredients) ).apply(i, TreeRitualRecipe::new)); + private static final StreamCodec STREAM_CODEC = ByteBufCodecs.fromCodecWithRegistries(TreeRitualRecipe.Serializer.CODEC.codec()); @Override - public Codec codec() { + public MapCodec codec() { return Serializer.CODEC; } - @Nullable @Override - public TreeRitualRecipe fromNetwork(FriendlyByteBuf buffer) { - var ingredients = new ArrayList(); - for (var i = buffer.readInt(); i > 0; i--) - ingredients.add(Ingredient.fromNetwork(buffer)); - return new TreeRitualRecipe(Ingredient.fromNetwork(buffer), buffer.readItem(), buffer.readInt(), ingredients); - } - - @Override - public void toNetwork(FriendlyByteBuf buffer, TreeRitualRecipe recipe) { - buffer.writeInt(recipe.ingredients.size()); - for (var ing : recipe.ingredients) - ing.toNetwork(buffer); - recipe.saplingType.toNetwork(buffer); - buffer.writeItem(recipe.output); - buffer.writeInt(recipe.time); + public StreamCodec streamCodec() { + return Serializer.STREAM_CODEC; } } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModItemTier.java b/src/main/java/de/ellpeck/naturesaura/reg/ModItemTier.java index ba3100de..8b963edd 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModItemTier.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModItemTier.java @@ -1,27 +1,30 @@ package de.ellpeck.naturesaura.reg; import de.ellpeck.naturesaura.items.ModItems; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.item.Tier; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.block.Block; import net.neoforged.neoforge.common.util.Lazy; import java.util.function.Supplier; public enum ModItemTier implements Tier { - INFUSED(2, 250, 6, 2, 16, () -> Ingredient.of(ModItems.INFUSED_IRON)), - SKY(3, 1500, 8, 3, 12, () -> Ingredient.of(ModItems.SKY_INGOT)), - DEPTH(4, 2500, 10, 5, 18, () -> Ingredient.of(ModItems.DEPTH_INGOT)); + INFUSED(BlockTags.INCORRECT_FOR_IRON_TOOL, 250, 6, 2, 16, () -> Ingredient.of(ModItems.INFUSED_IRON)), + SKY(BlockTags.INCORRECT_FOR_DIAMOND_TOOL, 1500, 8, 3, 12, () -> Ingredient.of(ModItems.SKY_INGOT)), + DEPTH(BlockTags.INCORRECT_FOR_NETHERITE_TOOL, 2500, 10, 5, 18, () -> Ingredient.of(ModItems.DEPTH_INGOT)); - private final int harvestLevel; + private final TagKey incorrectBlocksForDrops; private final int maxUses; private final float efficiency; private final float attackDamage; private final int enchantability; private final Lazy repairMaterial; - ModItemTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier repairMaterialIn) { - this.harvestLevel = harvestLevelIn; + ModItemTier(TagKey incorrectBlocksForDrops, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier repairMaterialIn) { + this.incorrectBlocksForDrops = incorrectBlocksForDrops; this.maxUses = maxUsesIn; this.efficiency = efficiencyIn; this.attackDamage = attackDamageIn; @@ -45,9 +48,8 @@ public enum ModItemTier implements Tier { } @Override - @SuppressWarnings({"deprecation", "RedundantSuppression"}) - public int getLevel() { - return this.harvestLevel; + public TagKey getIncorrectBlocksForDrops() { + return this.incorrectBlocksForDrops; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index ead9885c..765b03c4 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -40,6 +40,7 @@ import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.capabilities.Capabilities.EnergyStorage; import net.neoforged.neoforge.capabilities.Capabilities.FluidHandler; @@ -54,7 +55,7 @@ import vazkii.patchouli.api.PatchouliAPI; import java.util.ArrayList; import java.util.List; -@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD) public final class ModRegistry { // we use a list so that the creative tab maintains addition order @@ -65,83 +66,83 @@ public final class ModRegistry { event.register(Registries.BLOCK, h -> { Block temp; ModRegistry.registerAll(h, - new BlockAncientLog("ancient_log"), - new BlockAncientLog("ancient_bark"), - temp = new BlockImpl("ancient_planks", Block.Properties.of().sound(SoundType.WOOD).strength(2F)), - new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)), - new Slab("ancient_slab", "ancient_planks", Block.Properties.ofFullCopy(temp)), - new BlockAncientLeaves(), - new BlockAncientSapling(), - new BlockNatureAltar(), - new BlockDecayedLeaves(), - new BlockGoldenLeaves(), - new BlockGoldPowder(), - new BlockWoodStand(), - temp = new BlockImpl("infused_stone", Block.Properties.of().sound(SoundType.STONE).strength(1.75F)), - new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)), - new Slab("infused_slab", "infused_stone", Block.Properties.ofFullCopy(temp)), - temp = new BlockImpl("infused_brick", Block.Properties.of().sound(SoundType.STONE).strength(1.5F)), - new BlockStairsNA("infused_brick_stairs", "infused_brick", temp::defaultBlockState, Block.Properties.ofFullCopy(temp)), - new Slab("infused_brick_slab", "infused_brick", Block.Properties.ofFullCopy(temp)), - new BlockFurnaceHeater(), - new BlockPotionGenerator(), - new BlockAuraDetector(), - new BlockImpl("conversion_catalyst", Block.Properties.of().sound(SoundType.STONE).strength(2.5F)), - new BlockImpl("crushing_catalyst", Block.Properties.of().sound(SoundType.STONE).strength(2.5F)), - new BlockFlowerGenerator(), - new BlockPlacer(), - new BlockHopperUpgrade(), - new BlockFieldCreator(), - new BlockOakGenerator(), - new BlockImpl("infused_iron_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), - new BlockOfferingTable(), - new BlockPickupStopper(), - new BlockSpawnLamp(), - new BlockAnimalGenerator(), - new BlockEndFlower(), - new BlockGratedChute(), - new BlockAnimalSpawner(), - new BlockAutoCrafter(), - new BlockImpl("gold_brick", Block.Properties.ofFullCopy(Blocks.STONE_BRICKS)), - new BlockImpl("gold_nether_brick", Block.Properties.ofFullCopy(Blocks.NETHER_BRICKS)), - new BlockMossGenerator(), - new BlockTimeChanger(), - new BlockGeneratorLimitRemover(), - new BlockEnderCrate(), - new BlockPowderPlacer(), - new BlockFireworkGenerator(), - new BlockProjectileGenerator(), - new BlockDimensionRail("overworld", Level.OVERWORLD, Level.NETHER, Level.END), - new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD), - new BlockDimensionRail("end", Level.END, Level.OVERWORLD), - new BlockBlastFurnaceBooster(), - new BlockImpl("nether_wart_mushroom", Block.Properties.ofFullCopy(Blocks.RED_MUSHROOM_BLOCK)), - new BlockAnimalContainer(), - new BlockSnowCreator(), - new BlockItemDistributor(), - temp = new BlockAuraBloom("aura_bloom", Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.FARMLAND), - ModRegistry.createFlowerPot(temp), - temp = new BlockAuraBloom("aura_cactus", Blocks.SAND, Blocks.RED_SAND), - ModRegistry.createFlowerPot(temp), - temp = new BlockAuraBloom("warped_aura_mushroom", Blocks.WARPED_NYLIUM), - ModRegistry.createFlowerPot(temp), - temp = new BlockAuraBloom("crimson_aura_mushroom", Blocks.CRIMSON_NYLIUM), - ModRegistry.createFlowerPot(temp), - temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), - ModRegistry.createFlowerPot(temp), - new BlockImpl("tainted_gold_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), - new BlockNetherGrass(), - new BlockLight(), - new BlockChorusGenerator(), - new BlockAuraTimer(), - new BlockSlimeSplitGenerator(), - new BlockSpring(), - new BlockWeatherChanger(), - new BlockRFConverter(), - new BlockChunkLoader(), - new BlockLowerLimiter(), - new BlockImpl("sky_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(4F)), - new BlockImpl("depth_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(6F)) + new BlockAncientLog("ancient_log"), + new BlockAncientLog("ancient_bark"), + temp = new BlockImpl("ancient_planks", Block.Properties.of().sound(SoundType.WOOD).strength(2F)), + new BlockStairsNA("ancient_stairs", "ancient_planks", temp.defaultBlockState(), Block.Properties.ofFullCopy(temp)), + new Slab("ancient_slab", "ancient_planks", Block.Properties.ofFullCopy(temp)), + new BlockAncientLeaves(), + new BlockAncientSapling(), + new BlockNatureAltar(), + new BlockDecayedLeaves(), + new BlockGoldenLeaves(), + new BlockGoldPowder(), + new BlockWoodStand(), + temp = new BlockImpl("infused_stone", Block.Properties.of().sound(SoundType.STONE).strength(1.75F)), + new BlockStairsNA("infused_stairs", "infused_stone", temp.defaultBlockState(), Block.Properties.ofFullCopy(temp)), + new Slab("infused_slab", "infused_stone", Block.Properties.ofFullCopy(temp)), + temp = new BlockImpl("infused_brick", Block.Properties.of().sound(SoundType.STONE).strength(1.5F)), + new BlockStairsNA("infused_brick_stairs", "infused_brick", temp.defaultBlockState(), Block.Properties.ofFullCopy(temp)), + new Slab("infused_brick_slab", "infused_brick", Block.Properties.ofFullCopy(temp)), + new BlockFurnaceHeater(), + new BlockPotionGenerator(), + new BlockAuraDetector(), + new BlockImpl("conversion_catalyst", Block.Properties.of().sound(SoundType.STONE).strength(2.5F)), + new BlockImpl("crushing_catalyst", Block.Properties.of().sound(SoundType.STONE).strength(2.5F)), + new BlockFlowerGenerator(), + new BlockPlacer(), + new BlockHopperUpgrade(), + new BlockFieldCreator(), + new BlockOakGenerator(), + new BlockImpl("infused_iron_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), + new BlockOfferingTable(), + new BlockPickupStopper(), + new BlockSpawnLamp(), + new BlockAnimalGenerator(), + new BlockEndFlower(), + new BlockGratedChute(), + new BlockAnimalSpawner(), + new BlockAutoCrafter(), + new BlockImpl("gold_brick", Block.Properties.ofFullCopy(Blocks.STONE_BRICKS)), + new BlockImpl("gold_nether_brick", Block.Properties.ofFullCopy(Blocks.NETHER_BRICKS)), + new BlockMossGenerator(), + new BlockTimeChanger(), + new BlockGeneratorLimitRemover(), + new BlockEnderCrate(), + new BlockPowderPlacer(), + new BlockFireworkGenerator(), + new BlockProjectileGenerator(), + new BlockDimensionRail("overworld", Level.OVERWORLD, Level.NETHER, Level.END), + new BlockDimensionRail("nether", Level.NETHER, Level.OVERWORLD), + new BlockDimensionRail("end", Level.END, Level.OVERWORLD), + new BlockBlastFurnaceBooster(), + new BlockImpl("nether_wart_mushroom", Block.Properties.ofFullCopy(Blocks.RED_MUSHROOM_BLOCK)), + new BlockAnimalContainer(), + new BlockSnowCreator(), + new BlockItemDistributor(), + temp = new BlockAuraBloom("aura_bloom", Blocks.GRASS_BLOCK, Blocks.DIRT, Blocks.PODZOL, Blocks.COARSE_DIRT, Blocks.FARMLAND), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("aura_cactus", Blocks.SAND, Blocks.RED_SAND), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("warped_aura_mushroom", Blocks.WARPED_NYLIUM), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("crimson_aura_mushroom", Blocks.CRIMSON_NYLIUM), + ModRegistry.createFlowerPot(temp), + temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), + ModRegistry.createFlowerPot(temp), + new BlockImpl("tainted_gold_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), + new BlockNetherGrass(), + new BlockLight(), + new BlockChorusGenerator(), + new BlockAuraTimer(), + new BlockSlimeSplitGenerator(), + new BlockSpring(), + new BlockWeatherChanger(), + new BlockRFConverter(), + new BlockChunkLoader(), + new BlockLowerLimiter(), + new BlockImpl("sky_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(4F)), + new BlockImpl("depth_ingot_block", Block.Properties.of().sound(SoundType.METAL).strength(6F)) ); Helper.populateObjectHolders(ModBlocks.class, BuiltInRegistries.BLOCK); }); @@ -150,83 +151,83 @@ public final class ModRegistry { for (var block : ModRegistry.ALL_ITEMS) { if (block instanceof Block && !(block instanceof INoItemBlock)) { var item = new BlockItem((Block) block, new Item.Properties()); - h.register(new ResourceLocation(NaturesAura.MOD_ID, block.getBaseName()), item); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, block.getBaseName()), item); } } Item temp; ModRegistry.registerAll(h, - new ItemPickaxe("infused_iron_pickaxe", ModItemTier.INFUSED, 1, -2.8F), - new ItemAxe("infused_iron_axe", ModItemTier.INFUSED, 6.0F, -3.1F), - new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F), - new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1), - new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F), - new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, ArmorItem.Type.HELMET), - new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, ArmorItem.Type.CHESTPLATE), - new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, ArmorItem.Type.LEGGINGS), - new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, ArmorItem.Type.BOOTS), - new ItemEye("eye"), - new ItemEye("eye_improved"), - new ItemGoldFiber(), - new ItemImpl("gold_leaf"), - new ItemImpl("infused_iron"), - new ItemImpl("ancient_stick"), - new ItemColorChanger(), - new ItemAuraCache("aura_cache"), - new ItemAuraCache("aura_trove"), - new ItemShockwaveCreator(), - new ItemMultiblockMaker(), - temp = new ItemImpl("bottle_two_the_rebottling"), - new ItemAuraBottle(temp), - new ItemImpl("farming_stencil"), - new ItemImpl("sky_ingot"), - new ItemGlowing("calling_spirit"), - new ItemEffectPowder(), - new ItemBirthSpirit(), - new ItemMoverMinecart(), - new ItemRangeVisualizer(), - new ItemImpl("clock_hand"), - new ItemImpl("token_joy"), - new ItemImpl("token_fear"), - new ItemImpl("token_anger"), - new ItemImpl("token_sorrow"), - new ItemImpl("token_euphoria"), - new ItemImpl("token_terror"), - new ItemImpl("token_rage"), - new ItemImpl("token_grief"), - new ItemEnderAccess(), - new ItemCaveFinder(), - new ItemCrimsonMeal(), - new ItemDeathRing(), - new ItemImpl("tainted_gold"), - new ItemLootFinder(), - new ItemLightStaff(), - new ItemPickaxe("sky_pickaxe", ModItemTier.SKY, 1, -2.8F), - new ItemAxe("sky_axe", ModItemTier.SKY, 5.0F, -3.0F), - new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F), - new ItemHoe("sky_hoe", ModItemTier.SKY, -1), - new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F), - new ItemArmor("sky_helmet", ModArmorMaterial.SKY, ArmorItem.Type.HELMET), - new ItemArmor("sky_chest", ModArmorMaterial.SKY, ArmorItem.Type.CHESTPLATE), - new ItemArmor("sky_pants", ModArmorMaterial.SKY, ArmorItem.Type.LEGGINGS), - new ItemArmor("sky_shoes", ModArmorMaterial.SKY, ArmorItem.Type.BOOTS), - new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024), - new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024), - new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048), - new ItemBreakPrevention(), - new ItemPetReviver(), - new ItemNetheriteFinder(), - new ItemImpl("vacuum_bottle"), - new ItemImpl("depth_ingot"), - new ItemPickaxe("depth_pickaxe", ModItemTier.DEPTH, 1, -2.8F), - new ItemAxe("depth_axe", ModItemTier.DEPTH, 5, -3), - new ItemShovel("depth_shovel", ModItemTier.DEPTH, 1.5F, -3), - new ItemHoe("depth_hoe", ModItemTier.DEPTH, -1), - new ItemSword("depth_sword", ModItemTier.DEPTH, 3, -2.4F), - new ItemArmor("depth_helmet", ModArmorMaterial.DEPTH, ArmorItem.Type.HELMET), - new ItemArmor("depth_chest", ModArmorMaterial.DEPTH, ArmorItem.Type.CHESTPLATE), - new ItemArmor("depth_pants", ModArmorMaterial.DEPTH, ArmorItem.Type.LEGGINGS), - new ItemArmor("depth_shoes", ModArmorMaterial.DEPTH, ArmorItem.Type.BOOTS) + new ItemPickaxe("infused_iron_pickaxe", ModItemTier.INFUSED, 1, -2.8F), + new ItemAxe("infused_iron_axe", ModItemTier.INFUSED, 6.0F, -3.1F), + new ItemShovel("infused_iron_shovel", ModItemTier.INFUSED, 1.5F, -3.0F), + new ItemHoe("infused_iron_hoe", ModItemTier.INFUSED, -1), + new ItemSword("infused_iron_sword", ModItemTier.INFUSED, 3, -2.4F), + new ItemArmor("infused_iron_helmet", ModArmorMaterial.INFUSED, ArmorItem.Type.HELMET), + new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, ArmorItem.Type.CHESTPLATE), + new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, ArmorItem.Type.LEGGINGS), + new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, ArmorItem.Type.BOOTS), + new ItemEye("eye"), + new ItemEye("eye_improved"), + new ItemGoldFiber(), + new ItemImpl("gold_leaf"), + new ItemImpl("infused_iron"), + new ItemImpl("ancient_stick"), + new ItemColorChanger(), + new ItemAuraCache("aura_cache"), + new ItemAuraCache("aura_trove"), + new ItemShockwaveCreator(), + new ItemMultiblockMaker(), + temp = new ItemImpl("bottle_two_the_rebottling"), + new ItemAuraBottle(temp), + new ItemImpl("farming_stencil"), + new ItemImpl("sky_ingot"), + new ItemGlowing("calling_spirit"), + new ItemEffectPowder(), + new ItemBirthSpirit(), + new ItemMoverMinecart(), + new ItemRangeVisualizer(), + new ItemImpl("clock_hand"), + new ItemImpl("token_joy"), + new ItemImpl("token_fear"), + new ItemImpl("token_anger"), + new ItemImpl("token_sorrow"), + new ItemImpl("token_euphoria"), + new ItemImpl("token_terror"), + new ItemImpl("token_rage"), + new ItemImpl("token_grief"), + new ItemEnderAccess(), + new ItemCaveFinder(), + new ItemCrimsonMeal(), + new ItemDeathRing(), + new ItemImpl("tainted_gold"), + new ItemLootFinder(), + new ItemLightStaff(), + new ItemPickaxe("sky_pickaxe", ModItemTier.SKY, 1, -2.8F), + new ItemAxe("sky_axe", ModItemTier.SKY, 5.0F, -3.0F), + new ItemShovel("sky_shovel", ModItemTier.SKY, 1.5F, -3.0F), + new ItemHoe("sky_hoe", ModItemTier.SKY, -1), + new ItemSword("sky_sword", ModItemTier.SKY, 3, -2.4F), + new ItemArmor("sky_helmet", ModArmorMaterial.SKY, ArmorItem.Type.HELMET), + new ItemArmor("sky_chest", ModArmorMaterial.SKY, ArmorItem.Type.CHESTPLATE), + new ItemArmor("sky_pants", ModArmorMaterial.SKY, ArmorItem.Type.LEGGINGS), + new ItemArmor("sky_shoes", ModArmorMaterial.SKY, ArmorItem.Type.BOOTS), + new ItemStructureFinder("fortress_finder", BuiltinStructures.FORTRESS, 0xba2800, 1024), + new ItemStructureFinder("end_city_finder", BuiltinStructures.END_CITY, 0xca5cd6, 1024), + new ItemStructureFinder("outpost_finder", BuiltinStructures.PILLAGER_OUTPOST, 0xab9f98, 2048), + new ItemBreakPrevention(), + new ItemPetReviver(), + new ItemNetheriteFinder(), + new ItemImpl("vacuum_bottle"), + new ItemImpl("depth_ingot"), + new ItemPickaxe("depth_pickaxe", ModItemTier.DEPTH, 1, -2.8F), + new ItemAxe("depth_axe", ModItemTier.DEPTH, 5, -3), + new ItemShovel("depth_shovel", ModItemTier.DEPTH, 1.5F, -3), + new ItemHoe("depth_hoe", ModItemTier.DEPTH, -1), + new ItemSword("depth_sword", ModItemTier.DEPTH, 3, -2.4F), + new ItemArmor("depth_helmet", ModArmorMaterial.DEPTH, ArmorItem.Type.HELMET), + new ItemArmor("depth_chest", ModArmorMaterial.DEPTH, ArmorItem.Type.CHESTPLATE), + new ItemArmor("depth_pants", ModArmorMaterial.DEPTH, ArmorItem.Type.LEGGINGS), + new ItemArmor("depth_shoes", ModArmorMaterial.DEPTH, ArmorItem.Type.BOOTS) ); Helper.populateObjectHolders(ModItems.class, BuiltInRegistries.ITEM); }); @@ -237,18 +238,18 @@ public final class ModRegistry { for (var item : ModRegistry.ALL_ITEMS) { if (item instanceof ModTileType type) - h.register(new ResourceLocation(NaturesAura.MOD_ID, type.getBaseName()), type.type); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, type.getBaseName()), type.type); } Helper.populateObjectHolders(ModBlockEntities.class, BuiltInRegistries.BLOCK_ENTITY_TYPE); }); event.register(Registries.MOB_EFFECT, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "breathless"), new PotionBreathless()); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "breathless"), new PotionBreathless()); Helper.populateObjectHolders(ModPotions.class, BuiltInRegistries.MOB_EFFECT); }); event.register(Registries.MENU, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IMenuTypeExtension.create((windowId, inv, data) -> { + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "ender_crate"), IMenuTypeExtension.create((windowId, inv, data) -> { var tile = inv.player.level().getBlockEntity(data.readBlockPos()); if (tile instanceof BlockEntityEnderCrate) { var handler = tile.getLevel().getCapability(ItemHandler.BLOCK, tile.getBlockPos(), tile.getBlockState(), tile, null); @@ -256,7 +257,7 @@ public final class ModRegistry { } return null; })); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_access"), IMenuTypeExtension.create((windowId, inv, data) -> { + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "ender_access"), IMenuTypeExtension.create((windowId, inv, data) -> { IItemHandler handler = ILevelData.getOverworldData(inv.player.level()).getEnderStorage(data.readUtf()); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler); })); @@ -264,76 +265,76 @@ public final class ModRegistry { }); event.register(Registries.ENCHANTMENT, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mending"), new AuraMendingEnchantment()); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_mending"), new AuraMendingEnchantment()); Helper.populateObjectHolders(ModEnchantments.class, BuiltInRegistries.ENCHANTMENT); }); event.register(Registries.ENTITY_TYPE, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "mover_cart"), EntityType.Builder - .of(EntityMoverMinecart::new, MobCategory.MISC) - .sized(1, 1).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":mover_minecart")); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "effect_inhibitor"), EntityType.Builder - .of(EntityEffectInhibitor::new, MobCategory.MISC) - .sized(1, 1).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(20).fireImmune().build(NaturesAura.MOD_ID + ":effect_inhibitor")); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "light_projectile"), EntityType.Builder - .of(EntityLightProjectile::new, MobCategory.MISC) - .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":light_projectile")); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "structure_finder"), EntityType.Builder - .of(EntityStructureFinder::new, MobCategory.MISC) - .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) - .setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder")); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "mover_cart"), EntityType.Builder + .of(EntityMoverMinecart::new, MobCategory.MISC) + .sized(1, 1).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":mover_minecart")); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "effect_inhibitor"), EntityType.Builder + .of(EntityEffectInhibitor::new, MobCategory.MISC) + .sized(1, 1).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(20).fireImmune().build(NaturesAura.MOD_ID + ":effect_inhibitor")); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "light_projectile"), EntityType.Builder + .of(EntityLightProjectile::new, MobCategory.MISC) + .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(3).fireImmune().build(NaturesAura.MOD_ID + ":light_projectile")); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "structure_finder"), EntityType.Builder + .of(EntityStructureFinder::new, MobCategory.MISC) + .sized(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(2).fireImmune().build(NaturesAura.MOD_ID + ":structure_finder")); Helper.populateObjectHolders(ModEntities.class, BuiltInRegistries.ENTITY_TYPE); }); event.register(Registries.FEATURE, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false)); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false)); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "warped_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true)); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "crimson_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true)); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_mushroom"), new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false)); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "ancient_tree"), new LevelGenAncientTree()); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom()); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_bloom"), new LevelGenAuraBloom(ModBlocks.AURA_BLOOM, 60, false)); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_cactus"), new LevelGenAuraBloom(ModBlocks.AURA_CACTUS, 60, false)); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "warped_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.WARPED_AURA_MUSHROOM, 10, true)); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "crimson_aura_mushroom"), new LevelGenAuraBloom(ModBlocks.CRIMSON_AURA_MUSHROOM, 10, true)); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_mushroom"), new LevelGenAuraBloom(ModBlocks.AURA_MUSHROOM, 20, false)); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "ancient_tree"), new LevelGenAncientTree()); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "nether_wart_mushroom"), new LevelGenNetherWartMushroom()); Helper.populateObjectHolders(ModFeatures.class, BuiltInRegistries.FEATURE); }); event.register(Registries.RECIPE_TYPE, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_TYPE); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_TYPE); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_TYPE); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_TYPE); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_TYPE); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_TYPE); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_TYPE); }); event.register(Registries.RECIPE_SERIALIZER, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_SERIALIZER); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_SERIALIZER); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_SERIALIZER); - h.register(new ResourceLocation(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "altar"), ModRecipes.ALTAR_SERIALIZER); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "animal_spawner"), ModRecipes.ANIMAL_SPAWNER_SERIALIZER); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "offering"), ModRecipes.OFFERING_SERIALIZER); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "tree_ritual"), ModRecipes.TREE_RITUAL_SERIALIZER); }); event.register(Registries.CREATIVE_MODE_TAB, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "tab"), CreativeModeTab.builder() - .title(Component.translatable("item_group." + NaturesAura.MOD_ID + ".tab")) - .icon(() -> new ItemStack(ModItems.GOLD_LEAF)) - .displayItems((params, output) -> { - output.accept(PatchouliAPI.get().getBookStack(PatchouliCompat.BOOK)); - ModRegistry.ALL_ITEMS.forEach(i -> { - if (i instanceof ICustomCreativeTab c) { - output.acceptAll(c.getCreativeTabItems()); - } else if (i instanceof ItemLike l) { - if (l.asItem() != Items.AIR) - output.accept(l); - } - }); - }) - .build() + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "tab"), CreativeModeTab.builder() + .title(Component.translatable("item_group." + NaturesAura.MOD_ID + ".tab")) + .icon(() -> new ItemStack(ModItems.GOLD_LEAF)) + .displayItems((params, output) -> { + output.accept(PatchouliAPI.get().getBookStack(PatchouliCompat.BOOK)); + ModRegistry.ALL_ITEMS.forEach(i -> { + if (i instanceof ICustomCreativeTab c) { + output.acceptAll(c.getCreativeTabItems()); + } else if (i instanceof ItemLike l) { + if (l.asItem() != Items.AIR) + output.accept(l); + } + }); + }) + .build() ); }); event.register(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, h -> { - h.register(new ResourceLocation(NaturesAura.MOD_ID, "aura_chunk"), NaturesAuraAPI.AURA_CHUNK_ATTACHMENT); + h.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, "aura_chunk"), NaturesAuraAPI.AURA_CHUNK_ATTACHMENT); }); } @@ -375,7 +376,7 @@ public final class ModRegistry { @SafeVarargs private static void registerAll(RegisterEvent.RegisterHelper helper, T... items) { for (var item : items) - helper.register(new ResourceLocation(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item); + helper.register(ResourceLocation.fromNamespaceAndPath(NaturesAura.MOD_ID, ((IModItem) item).getBaseName()), item); } } diff --git a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java index d31f5fd1..49c8c0f3 100644 --- a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java +++ b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java @@ -5,7 +5,6 @@ import com.mojang.math.Axis; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.api.render.ITrinketItem.RenderType; -import de.ellpeck.naturesaura.compat.Compat; import net.minecraft.client.model.PlayerModel; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.MultiBufferSource; @@ -18,7 +17,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; -import top.theillusivec4.curios.api.CuriosApi; import java.util.HashSet; import java.util.Set; @@ -59,14 +57,15 @@ public class PlayerLayerTrinkets extends RenderLayer