From 6ab4634bfafdb8a6fd142ad0f777ff63ea9ebd9b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 8 Jul 2023 12:32:27 +0200 Subject: [PATCH] everything but loot compiles --- build.gradle | 276 ++++++++++-------- gradle.properties | 55 +++- gradle/wrapper/gradle-wrapper.properties | 3 +- settings.gradle | 13 + .../java/de/ellpeck/naturesaura/Helper.java | 36 ++- .../de/ellpeck/naturesaura/NaturesAura.java | 5 +- .../blocks/BlockAncientLeaves.java | 5 +- .../naturesaura/blocks/BlockAncientLog.java | 5 +- .../blocks/BlockAncientSapling.java | 8 +- .../blocks/BlockAnimalGenerator.java | 13 +- .../blocks/BlockAnimalSpawner.java | 3 +- .../naturesaura/blocks/BlockAuraBloom.java | 6 +- .../naturesaura/blocks/BlockAuraDetector.java | 3 +- .../naturesaura/blocks/BlockAutoCrafter.java | 3 +- .../naturesaura/blocks/BlockChunkLoader.java | 3 +- .../blocks/BlockContainerImpl.java | 9 +- .../blocks/BlockDecayedLeaves.java | 3 +- .../blocks/BlockDimensionRail.java | 2 +- .../naturesaura/blocks/BlockEndFlower.java | 22 +- .../naturesaura/blocks/BlockEnderCrate.java | 5 +- .../naturesaura/blocks/BlockFieldCreator.java | 3 +- .../blocks/BlockFireworkGenerator.java | 3 +- .../blocks/BlockFlowerGenerator.java | 3 +- .../blocks/BlockFurnaceHeater.java | 3 +- .../blocks/BlockGeneratorLimitRemover.java | 3 +- .../naturesaura/blocks/BlockGoldenLeaves.java | 7 +- .../naturesaura/blocks/BlockGratedChute.java | 3 +- .../blocks/BlockHopperUpgrade.java | 3 +- .../naturesaura/blocks/BlockLight.java | 3 +- .../naturesaura/blocks/BlockLowerLimiter.java | 3 +- .../blocks/BlockMossGenerator.java | 3 +- .../naturesaura/blocks/BlockNatureAltar.java | 3 +- .../naturesaura/blocks/BlockNetherGrass.java | 4 +- .../naturesaura/blocks/BlockOakGenerator.java | 12 +- .../blocks/BlockOfferingTable.java | 3 +- .../blocks/BlockPickupStopper.java | 9 +- .../naturesaura/blocks/BlockPlacer.java | 3 +- .../blocks/BlockPotionGenerator.java | 3 +- .../naturesaura/blocks/BlockPowderPlacer.java | 3 +- .../blocks/BlockProjectileGenerator.java | 11 +- .../naturesaura/blocks/BlockRFConverter.java | 3 +- .../blocks/BlockSlimeSplitGenerator.java | 4 +- .../naturesaura/blocks/BlockSpawnLamp.java | 11 +- .../naturesaura/blocks/BlockSpring.java | 2 +- .../naturesaura/blocks/BlockTimeChanger.java | 3 +- .../naturesaura/blocks/BlockWoodStand.java | 3 +- .../naturesaura/blocks/multi/Multiblocks.java | 3 +- .../tiles/BlockEntityAnimalSpawner.java | 2 +- .../blocks/tiles/BlockEntityAutoCrafter.java | 5 +- .../tiles/BlockEntityBlastFurnaceBooster.java | 2 +- .../blocks/tiles/BlockEntityFieldCreator.java | 4 +- .../tiles/BlockEntityFurnaceHeater.java | 2 +- .../blocks/tiles/BlockEntityPlacer.java | 2 +- .../blocks/tiles/BlockEntitySnowCreator.java | 10 +- .../blocks/tiles/render/RenderEnderCrate.java | 2 +- .../render/RenderGeneratorLimitRemover.java | 4 +- .../tiles/render/RenderNatureAltar.java | 8 +- .../tiles/render/RenderOfferingTable.java | 10 +- .../render/RenderProjectileGenerator.java | 8 +- .../blocks/tiles/render/RenderWoodStand.java | 10 +- .../naturesaura/chunk/effect/AngerEffect.java | 2 +- .../chunk/effect/AnimalEffect.java | 18 +- .../chunk/effect/BreathlessEffect.java | 2 +- .../chunk/effect/CacheRechargeEffect.java | 4 +- .../chunk/effect/ExplosionEffect.java | 10 +- .../chunk/effect/GrassDieEffect.java | 4 +- .../chunk/effect/NetherDecayEffect.java | 4 +- .../chunk/effect/NetherGrassEffect.java | 4 +- .../chunk/effect/OreSpawnEffect.java | 4 +- .../chunk/effect/PlantBoostEffect.java | 4 +- .../naturesaura/commands/CommandAura.java | 12 +- .../naturesaura/compat/CuriosCompat.java | 2 +- .../compat/jei/AnimalSpawnerCategory.java | 19 +- .../compat/patchouli/PatchouliCompat.java | 42 +-- .../compat/patchouli/ProcessorAltar.java | 8 +- .../patchouli/ProcessorAnimalSpawner.java | 5 +- .../compat/patchouli/ProcessorOffering.java | 5 +- .../compat/patchouli/ProcessorTreeRitual.java | 5 +- .../naturesaura/data/ItemTagProvider.java | 13 +- .../entities/EntityEffectInhibitor.java | 26 +- .../entities/EntityLightProjectile.java | 10 +- .../entities/EntityMoverMinecart.java | 18 +- .../entities/EntityStructureFinder.java | 14 +- .../render/RenderEffectInhibitor.java | 7 +- .../entities/render/RenderMoverMinecart.java | 4 +- .../naturesaura/events/ClientEvents.java | 86 +++--- .../naturesaura/events/CommonEvents.java | 16 +- .../naturesaura/gen/LevelGenAncientTree.java | 15 +- .../naturesaura/gui/GuiEnderCrate.java | 28 +- .../naturesaura/items/ItemAuraBottle.java | 15 +- .../naturesaura/items/ItemAuraCache.java | 15 +- .../naturesaura/items/ItemBirthSpirit.java | 14 +- .../naturesaura/items/ItemCaveFinder.java | 2 +- .../naturesaura/items/ItemDeathRing.java | 4 +- .../naturesaura/items/ItemEffectPowder.java | 5 +- .../naturesaura/items/ItemEnderAccess.java | 2 +- .../de/ellpeck/naturesaura/items/ItemEye.java | 8 +- .../ellpeck/naturesaura/items/ItemImpl.java | 2 +- .../naturesaura/items/ItemPetReviver.java | 32 +- .../items/ItemRangeVisualizer.java | 4 +- .../items/ItemShockwaveCreator.java | 25 +- .../items/ItemStructureFinder.java | 4 +- .../naturesaura/items/tools/ItemArmor.java | 14 +- .../naturesaura/items/tools/ItemAxe.java | 10 +- .../naturesaura/items/tools/ItemHoe.java | 14 +- .../naturesaura/items/tools/ItemPickaxe.java | 6 +- .../naturesaura/items/tools/ItemShovel.java | 10 +- .../naturesaura/items/tools/ItemSword.java | 10 +- .../naturesaura/packet/PacketParticles.java | 8 +- .../naturesaura/particles/ParticleMagic.java | 6 +- .../naturesaura/potion/PotionBreathless.java | 3 +- .../naturesaura/recipes/AltarRecipe.java | 3 +- .../recipes/AnimalSpawnerRecipe.java | 5 +- .../naturesaura/recipes/ModRecipe.java | 3 +- .../naturesaura/recipes/OfferingRecipe.java | 3 +- .../naturesaura/recipes/TreeRitualRecipe.java | 3 +- .../naturesaura/reg/ModArmorMaterial.java | 10 +- .../ellpeck/naturesaura/reg/ModRegistry.java | 62 ++-- .../renderers/PlayerLayerTrinkets.java | 12 +- .../renderers/SupporterFancyHandler.java | 6 +- src/main/resources/META-INF/mods.toml | 74 +++-- 121 files changed, 771 insertions(+), 678 deletions(-) create mode 100644 settings.gradle diff --git a/build.gradle b/build.gradle index 73d0d79f..58da5157 100644 --- a/build.gradle +++ b/build.gradle @@ -1,95 +1,133 @@ -buildscript { - repositories { - // These repositories are only for Gradle plugins, put any other repositories in the repository block further below - maven { url = 'https://maven.minecraftforge.net' } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true - } +plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '[6.0,6.2)' } -apply plugin: 'net.minecraftforge.gradle' -// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. -apply plugin: 'eclipse' -apply plugin: 'maven-publish' - -version = '38.2' -group = 'de.ellpeck.naturesaura' // http://maven.apache.org/guides/mini/guide-naming-conventions.html -archivesBaseName = 'NaturesAura' +version = mod_version if (System.getenv('BUILD_NUMBER') != null) { version += "." + System.getenv('BUILD_NUMBER') } +group = mod_group_id + +base { + archivesName = mod_name +} + +// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) +println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { - mappings channel: 'official', version: '1.19.2' + // The mappings can be changed at any time and must be in the following format. + // Channel: Version: + // official MCVersion Official field/method names from Mojang mapping files + // parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official + // + // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. + // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md + // + // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge + // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started + // + // Use non-default mappings at your own risk. They may not always work. + // Simply re-run your setup task after changing the mappings to update your workspace. + mappings channel: mapping_channel, version: mapping_version + // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game. + // In most cases, it is not necessary to enable. + // enableEclipsePrepareRuns = true + // enableIdeaPrepareRuns = true + + // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game. + // It is REQUIRED to be set to true for this template to function. + // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html + copyIdeResources = true + + // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations. + // The folder name can be set on a run configuration using the "folderName" property. + // By default, the folder name of a run configuration is the name of the Gradle project containing it. + // generateRunFolders = true + + // This property enables access transformers for use in development. + // They will be applied to the Minecraft artifact. + // The access transformer file can be anywhere in the project. + // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge. + // This default location is a best practice to automatically put the file in the right place in the final jar. + // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information. + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + + // Default run configurations. + // These can be tweaked, removed, or duplicated as needed. runs { - client { + // applies to all the run configs below + configureEach { workingDirectory project.file('run') // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + // The markers can be added/remove as needed separated by commas. + // "SCAN": For mods scan. + // "REGISTRIES": For firing of registry events. + // "REGISTRYDUMP": For getting the contents of all registries. + property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console + // You can set various levels here. + // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'info' - property 'mixin.env.disableRefMap', 'true' mods { - naturesaura { + "${mod_id}" { source sourceSets.main } } } + client { + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', mod_id + } + server { - workingDirectory project.file('run') + property 'forge.enabledGameTestNamespaces', mod_id + args '--nogui' + } - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console - property 'forge.logging.console.level', 'info' - property 'mixin.env.disableRefMap', 'true' - - mods { - naturesaura { - source sourceSets.main - } - } + // This run config launches GameTestServer and runs all registered gametests, then exits. + // By default, the server will crash when no gametests are provided. + // The gametest system is also enabled by default for other run configs under the /test command. + gameTestServer { + property 'forge.enabledGameTestNamespaces', mod_id } data { - workingDirectory project.file('run') + // example of overriding the workingDirectory set in configureEach above + workingDirectory project.file('run-data') - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - - // Recommended logging level for the console - property 'forge.logging.console.level', 'info' - property 'mixin.env.disableRefMap', 'true' - - args '--mod', 'naturesaura', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/'), '--existing', file('src/generated/resources') - - mods { - naturesaura { - source sourceSets.main - } - } + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } -sourceSets.main.resources { - srcDir 'src/generated/resources' -} +// Include resources generated by data generators. +sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { - maven { - url = "https://dvs1.progwml6.com/files/maven" - } + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you + + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so. + // See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver + // flatDir { + // dir 'libs' + // } + + // it says this gets included automatically but apparently it doesn't + mavenCentral() + maven { url = "https://maven.blamejared.com" } @@ -102,77 +140,83 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.19.2-43.2.0' + // Specify the version of Minecraft to use. + // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact. + // The "userdev" classifier will be requested and setup by ForgeGradle. + // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"], + // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. + minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" + + // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings + // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime + compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}") + compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}") + runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}") - compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.5.0.297") - runtimeOnly fg.deobf("mezz.jei:jei-1.19.2-forge:11.5.0.297") + runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}") + compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:${curios_version}:api") + + compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}:api") + runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}") - compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.19.2-77:api") - runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.19.2-77") + // Example mod dependency using a mod jar from ./libs with a flat dir repository + // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar + // The group id is ignored when searching -- in this case, it is "blank" + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") - runtimeOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19.2-5.1.1.0") - compileOnly fg.deobf("top.theillusivec4.curios:curios-forge:1.19.2-5.1.1.0:api") - - // TODO Enchantability -/* compile fg.deobf("quarris.enchantability:Enchantability:11.0.48")*/ + // For more info: + // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html + // http://www.gradle.org/docs/current/userguide/dependency_management.html } -// Example for how to get properties into the manifest for reading by the runtime.. -jar { - manifest { - attributes([ - "Specification-Title" : "naturesaura", - "Specification-Vendor" : "Ellpeck", - "Specification-Version" : "1", // We are version 1 of ourselves - "Implementation-Title" : project.name, - "Implementation-Version" : "${version}", - "Implementation-Vendor" : "Ellpeck", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) +// This block of code expands all declared replace properties in the specified resource targets. +// A missing property will result in an error. Properties are expanded using ${} Groovy notation. +// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. +// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html +tasks.named('processResources', ProcessResources).configure { + var replaceProperties = [ + minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range, + forge_version : forge_version, forge_version_range: forge_version_range, + loader_version_range: loader_version_range, + mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: version, + mod_authors : mod_authors, mod_description: mod_description, + ] + inputs.properties replaceProperties + + filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { + expand replaceProperties + [project: project] } } -task deobfJar(type: Jar) { - from(sourceSets.main.output) - archiveName = "${baseName}-${version}-deobf.${extension}" +// Example for how to get properties into the manifest for reading at runtime. +tasks.named('jar', Jar).configure { + manifest { + attributes([ + 'Specification-Title' : mod_id, + 'Specification-Vendor' : mod_authors, + 'Specification-Version' : '1', // We are version 1 of ourselves + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : mod_authors, + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } + // This is the preferred method to reobfuscate your jar file + finalizedBy 'reobfJar' } -task sourcesJar(type: Jar) { - from(sourceSets.main.allSource) - archiveName = "${baseName}-${version}-sources.${extension}" -} - -task apiJar(type: Jar) { - from(sourceSets.main.output) - from(sourceSets.main.java) - include("de/ellpeck/naturesaura/api/**") - archiveName = "${baseName}-${version}-api.${extension}" -} - -artifacts { - archives deobfJar - archives sourcesJar - archives apiJar -} +// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing: +// tasks.named('publish').configure { +// dependsOn 'reobfJar' +// } +// Example configuration to allow publishing using the maven-publish plugin publishing { publications { - mavenJava(MavenPublication) { - groupId project.group - artifactId project.archivesBaseName - version project.version - from components.java - - artifact deobfJar { - classifier 'deobf' - } - artifact sourcesJar { - classifier 'sources' - } - artifact apiJar { - classifier 'api' - } - + register('mavenJava', MavenPublication) { + groupId mod_group_id + artifactId mod_name + artifact jar pom.withXml { def node = asNode() if (node.dependencies.size() > 0) @@ -186,3 +230,7 @@ publishing { } } } + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} diff --git a/gradle.properties b/gradle.properties index 878bf1f7..c6d60e07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,57 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. # This is required to provide enough memory for the Minecraft decompilation process. org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +org.gradle.daemon=false +## Environment Properties +# The Minecraft version must agree with the Forge version to get a valid artifact +minecraft_version=1.20.1 +# The Minecraft version range can use any release version of Minecraft as bounds. +# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly +# as they do not follow standard versioning conventions. +minecraft_version_range=[1.20.1,1.21) +# The Forge version must agree with the Minecraft version to get a valid artifact +forge_version=47.1.0 +# The Forge version range can use any version of Forge as bounds or match the loader version range +forge_version_range=[47,) +# The loader version range can only use the major version of Forge/FML as bounds +loader_version_range=[47,) +# The mapping channel to use for mappings. +# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"]. +# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin. +# +# | Channel | Version | | +# |-----------|----------------------|--------------------------------------------------------------------------------| +# | official | MCVersion | Official field/method names from Mojang mapping files | +# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official | +# +# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings. +# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md +# +# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge. +# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started +mapping_channel=official +# The mapping version to query from the mapping channel. +# This must match the format required by the mapping channel. +mapping_version=1.20.1 +jei_version=15.2.0.22 +curios_version=5.2.0-beta.3+1.20.1 +patchouli_version=1.20.1-80-FORGE-SNAPSHOT + +## Mod Properties +# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63} +# Must match the String constant located in the main mod class annotated with @Mod. +mod_id=naturesaura +# The human-readable display name for the mod. +mod_name=NaturesAura +# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. +mod_license=MIT +# The mod version. See https://semver.org/ +mod_version=38.2 +# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. +# This should match the base package used for the mod sources. +# See https://maven.apache.org/guides/mini/guide-naming-conventions.html +mod_group_id=de.ellpeck.naturesaura +# The authors of the mod. This is a simple text string that is used for display purposes in the mod list. +mod_authors=Ellpeck +# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list. +mod_description=Nature's Aura is a Minecraft mod about collecting, using and replenishing the Aura naturally present in the world to create useful devices and unique mechanics. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e750102e..37aef8d3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..a30364e8 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' +} diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 861a2421..d3654b0b 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -13,6 +13,7 @@ import de.ellpeck.naturesaura.misc.LevelData; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; @@ -117,22 +118,19 @@ public final class Helper { } public static boolean areItemsEqual(ItemStack first, ItemStack second, boolean nbt) { - if (!ItemStack.isSame(first, second)) - return false; - return !nbt || ItemStack.tagMatches(first, second); + // TODO see if this is the correct new comparison method? + return nbt ? ItemStack.isSameItemSameTags(first, second) : ItemStack.isSameItem(first, second); } @OnlyIn(Dist.CLIENT) - public static void renderItemInGui(ItemStack stack, int x, int y, float scale) { - var poseStack = RenderSystem.getModelViewStack(); + public static void renderItemInGui(GuiGraphics graphics, ItemStack stack, int x, int y, float scale) { + var poseStack = graphics.pose(); poseStack.pushPose(); poseStack.translate(x, y, 0); poseStack.scale(scale, scale, scale); - RenderSystem.applyModelViewMatrix(); - Minecraft.getInstance().getItemRenderer().renderGuiItem(stack, 0, 0); - Minecraft.getInstance().getItemRenderer().renderGuiItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null); + graphics.renderItem(stack, 0, 0); + graphics.renderItemDecorations(Minecraft.getInstance().font, stack, 0, 0, null); poseStack.popPose(); - RenderSystem.applyModelViewMatrix(); } @OnlyIn(Dist.CLIENT) @@ -164,18 +162,18 @@ public final class Helper { } public static InteractionResult putStackOnTile(Player player, InteractionHand hand, BlockPos pos, int slot, boolean sound) { - var tile = player.level.getBlockEntity(pos); + var tile = player.level().getBlockEntity(pos); if (tile instanceof BlockEntityImpl) { var handler = ((BlockEntityImpl) tile).getItemHandler(); if (handler != null) { var handStack = player.getItemInHand(hand); if (!handStack.isEmpty()) { - var remain = handler.insertItem(slot, handStack, player.level.isClientSide); + var remain = handler.insertItem(slot, handStack, player.level().isClientSide); if (!ItemStack.matches(remain, handStack)) { if (sound) - player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.PLAYERS, 0.75F, 1F); - if (!player.level.isClientSide) + if (!player.level().isClientSide) player.setItemInHand(hand, remain); return InteractionResult.SUCCESS; } @@ -183,13 +181,13 @@ public final class Helper { if (!handler.getStackInSlot(slot).isEmpty()) { if (sound) - player.level.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, + player.level().playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.ITEM_FRAME_REMOVE_ITEM, SoundSource.PLAYERS, 0.75F, 1F); - if (!player.level.isClientSide) { + if (!player.level().isClientSide) { var stack = handler.getStackInSlot(slot); if (!player.addItem(stack)) { - var item = new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), stack); - player.level.addFreshEntity(item); + var item = new ItemEntity(player.level(), player.getX(), player.getY(), player.getZ(), stack); + player.level().addFreshEntity(item); } handler.setStackInSlot(slot, ItemStack.EMPTY); } @@ -260,7 +258,7 @@ public final class Helper { public static void addAdvancement(Player player, ResourceLocation advancement, String criterion) { if (!(player instanceof ServerPlayer playerMp)) return; - var adv = playerMp.getLevel().getServer().getAdvancements().getAdvancement(advancement); + var adv = playerMp.level().getServer().getAdvancements().getAdvancement(advancement); if (adv != null) playerMp.getAdvancements().award(adv, criterion); } @@ -372,7 +370,7 @@ public final class Helper { return false; var disabled = !Helper.isToolEnabled(stack); stack.getOrCreateTag().putBoolean(NaturesAura.MOD_ID + ":disabled", !disabled); - player.level.playSound(null, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.65F, 1F); + player.level().playSound(null, player.getX() + 0.5, player.getY() + 0.5, player.getZ() + 0.5, SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 0.65F, 1F); return true; } } diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 35f8f248..e9b83df6 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -32,12 +32,13 @@ public final class NaturesAura { public static final String MOD_NAME = "Nature's Aura"; public static final Logger LOGGER = LogManager.getLogger(NaturesAura.MOD_NAME); - public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(NaturesAura.MOD_ID) { + // TODO creative tab + /* public static final CreativeModeTab CREATIVE_TAB = new CreativeModeTab(NaturesAura.MOD_ID) { @Override public ItemStack makeIcon() { return new ItemStack(ModItems.GOLD_LEAF); } - }; + };*/ public static NaturesAura instance; // this causes a classloading issue if it's not wrapped like this @SuppressWarnings("Convert2MethodRef") diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java index 20429bcd..60705d1d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java @@ -16,8 +16,7 @@ import net.minecraft.world.level.block.LeavesBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.jetbrains.annotations.Nullable; @@ -25,7 +24,7 @@ import org.jetbrains.annotations.Nullable; public class BlockAncientLeaves extends LeavesBlock implements IModItem, IColorProvidingBlock, IColorProvidingItem, ICustomBlockState, EntityBlock { public BlockAncientLeaves() { - super(Block.Properties.of(Material.LEAVES, MaterialColor.COLOR_PINK).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); + super(Block.Properties.of().mapColor(MapColor.COLOR_PINK).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); ModRegistry.ALL_ITEMS.add(this); ModRegistry.ALL_ITEMS.add(new ModTileType<>(BlockEntityAncientLeaves::new, this)); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java index 47513057..96d12778 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLog.java @@ -6,15 +6,14 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.world.level.block.RotatedPillarBlock; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; public class BlockAncientLog extends RotatedPillarBlock implements IModItem, ICustomBlockState { private final String baseName; public BlockAncientLog(String baseName) { - super(Properties.of(Material.WOOD, MaterialColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD)); + super(Properties.of().mapColor(MapColor.COLOR_PURPLE).strength(2.0F).sound(SoundType.WOOD)); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java index 62083846..319c15c1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientSapling.java @@ -12,10 +12,10 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +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.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.event.ForgeEventFactory; @@ -26,7 +26,7 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, protected static final VoxelShape SHAPE = Block.box(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D); public BlockAncientSapling() { - super(Properties.of(Material.GRASS).strength(0.0F).sound(SoundType.GRASS)); + super(Properties.of().strength(0.0F).sound(SoundType.GRASS)); ModRegistry.ALL_ITEMS.add(this); } @@ -58,7 +58,7 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, } @Override - public boolean isValidBonemealTarget(BlockGetter level, BlockPos pos, BlockState state, boolean b) { + public boolean isValidBonemealTarget(LevelReader p_256559_, BlockPos p_50898_, BlockState p_50899_, boolean p_50900_) { return true; } @@ -85,4 +85,4 @@ public class BlockAncientSapling extends BushBlock implements BonemealableBlock, public void generateCustomItemModel(ItemModelGenerator generator) { generator.withExistingParent(this.getBaseName(), "item/generated").texture("layer0", "block/" + this.getBaseName()); } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java index 907e95b4..fa73a386 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalGenerator.java @@ -14,7 +14,6 @@ import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.npc.Npc; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -28,7 +27,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockAnimalGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockAnimalGenerator() { - super("animal_generator", BlockEntityAnimalGenerator.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); + super("animal_generator", BlockEntityAnimalGenerator.class, Properties.of().strength(3F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @@ -36,7 +35,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @SubscribeEvent public void onLivingUpdate(LivingEvent.LivingTickEvent event) { var entity = event.getEntity(); - if (entity.level.isClientSide || entity.level.getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Npc) + if (entity.level().isClientSide || entity.level().getGameTime() % 40 != 0 || !(entity instanceof Animal) || entity instanceof Npc) return; var data = entity.getPersistentData(); var timeAlive = data.getInt(NaturesAura.MOD_ID + ":time_alive"); @@ -46,10 +45,10 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali @SubscribeEvent public void onEntityDeath(LivingDeathEvent event) { var entity = event.getEntity(); - if (entity.level.isClientSide || !(entity instanceof Animal) || entity instanceof Npc) + if (entity.level().isClientSide || !(entity instanceof Animal) || entity instanceof Npc) return; var pos = entity.blockPosition(); - Helper.getBlockEntitiesInArea(entity.level, pos, 5, tile -> { + Helper.getBlockEntitiesInArea(entity.level(), pos, 5, tile -> { if (!(tile instanceof BlockEntityAnimalGenerator gen)) return false; @@ -71,7 +70,7 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali gen.setGenerationValues(time, amount); var genPos = gen.getBlockPos(); - PacketHandler.sendToAllAround(entity.level, pos, 32, new PacketParticles( + 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), @@ -114,4 +113,4 @@ public class BlockAnimalGenerator extends BlockContainerImpl implements IVisuali generator.modLoc("block/" + this.getBaseName() + "_bottom"), generator.modLoc("block/" + this.getBaseName() + "_top"))); } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java index 976ed717..f8292e7e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalSpawner.java @@ -2,11 +2,10 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAnimalSpawner; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; public class BlockAnimalSpawner extends BlockContainerImpl { public BlockAnimalSpawner() { - super("animal_spawner", BlockEntityAnimalSpawner.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); + super("animal_spawner", BlockEntityAnimalSpawner.class, Properties.of().strength(2F).sound(SoundType.STONE)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java index 3668f793..8d01ecf7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraBloom.java @@ -10,7 +10,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.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -23,7 +22,6 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.Nullable; @@ -37,7 +35,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS private final Block[] allowedGround; public BlockAuraBloom(String baseName, Block... allowedGround) { - super(Properties.of(Material.PLANT).noCollission().strength(0).sound(SoundType.GRASS)); + super(Properties.of().noCollission().strength(0).sound(SoundType.GRASS)); this.baseName = baseName; this.allowedGround = allowedGround; ModRegistry.ALL_ITEMS.add(this); @@ -58,7 +56,7 @@ public class BlockAuraBloom extends BushBlock implements IModItem, ICustomBlockS @SuppressWarnings("deprecation") public void entityInside(BlockState state, Level levelIn, BlockPos pos, Entity entityIn) { if (this == ModBlocks.AURA_CACTUS) - entityIn.hurt(DamageSource.CACTUS, 1); + entityIn.hurt(entityIn.damageSources().cactus(), 1); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java index 47a89c14..4964e57e 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAuraDetector.java @@ -5,12 +5,11 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; public class BlockAuraDetector extends BlockContainerImpl { public BlockAuraDetector() { - super("aura_detector", BlockEntityAuraDetector.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); + super("aura_detector", BlockEntityAuraDetector.class, Properties.of().strength(2F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java index cf3cc0a3..a65c90cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java @@ -10,14 +10,13 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.material.Material; public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlockState { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public BlockAutoCrafter() { - super("auto_crafter", BlockEntityAutoCrafter.class, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD)); + super("auto_crafter", BlockEntityAutoCrafter.class, Properties.of().strength(1.5F).sound(SoundType.WOOD)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java index 044e5a6e..638d0e78 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockChunkLoader.java @@ -15,7 +15,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -27,7 +26,7 @@ public class BlockChunkLoader extends BlockContainerImpl implements IVisualizabl private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12); public BlockChunkLoader() { - super("chunk_loader", BlockEntityChunkLoader.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); + super("chunk_loader", BlockEntityChunkLoader.class, Properties.of().strength(3F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java index bcc7201c..6849aab0 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockContainerImpl.java @@ -27,7 +27,7 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import javax.annotation.Nullable; @@ -113,7 +113,7 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem { @Override @SuppressWarnings("deprecation") - public List getDrops(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootParams.Builder builder) { var drops = super.getDrops(state, builder); var tile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); @@ -176,8 +176,9 @@ public class BlockContainerImpl extends BaseEntityBlock implements IModItem { private BlockEntity createBlockEntity(BlockPos pos, BlockState state) { try { return this.tileClass.getConstructor(BlockPos.class, BlockState.class).newInstance(pos, state); - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException e) { throw new IllegalStateException("Cannot construct block entity from class " + this.tileClass, e); } } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java index 8b320185..82634e78 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDecayedLeaves.java @@ -8,12 +8,11 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; public class BlockDecayedLeaves extends BlockImpl implements ICustomBlockState { public BlockDecayedLeaves() { - super("decayed_leaves", Properties.of(Material.LEAVES).strength(0.2F).sound(SoundType.GRASS).noOcclusion().randomTicks()); + super("decayed_leaves", Properties.of().strength(0.2F).sound(SoundType.GRASS).noOcclusion().randomTicks()); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java index 3a800cf5..b798cec3 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockDimensionRail.java @@ -99,7 +99,7 @@ public class BlockDimensionRail extends BaseRailBlock implements IModItem, ICust @Override public Entity placeEntity(Entity entity, ServerLevel currentLevel, ServerLevel destLevel, float yaw, Function repositionEntity) { // repositionEntity always causes a NPE because why wouldn't it, so this is a fixed copy - entity.level.getProfiler().popPush("reloading"); + entity.level().getProfiler().popPush("reloading"); var result = entity.getType().create(destLevel); if (result != null) { result.restoreFrom(entity); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java index f046866b..26be1db8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEndFlower.java @@ -21,8 +21,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.material.FluidState; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -38,7 +37,7 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS protected static final VoxelShape SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 10.0D, 11.0D); public BlockEndFlower() { - super(Properties.of(Material.GRASS).noCollission().strength(0.5F).sound(SoundType.GRASS)); + super(Properties.of().noCollission().strength(0.5F).sound(SoundType.GRASS)); MinecraftForge.EVENT_BUS.register(this); ModRegistry.ALL_ITEMS.add(this); ModRegistry.ALL_ITEMS.add(new ModTileType<>(BlockEntityEndFlower::new, this)); @@ -54,20 +53,20 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS @SubscribeEvent public void onDragonTick(LivingEvent.LivingTickEvent event) { var living = event.getEntity(); - if (living.level.isClientSide || !(living instanceof EnderDragon dragon)) + if (living.level().isClientSide || !(living instanceof EnderDragon dragon)) return; if (dragon.dragonDeathTime < 150 || dragon.dragonDeathTime % 10 != 0) return; for (var i = 0; i < 6; i++) { - var x = dragon.level.random.nextInt(256) - 128; - var z = dragon.level.random.nextInt(256) - 128; - var pos = new BlockPos(x, dragon.level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z); - if (!dragon.level.isLoaded(pos)) + var x = dragon.level().random.nextInt(256) - 128; + var z = dragon.level().random.nextInt(256) - 128; + var pos = new BlockPos(x, dragon.level().getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z); + if (!dragon.level().isLoaded(pos)) continue; - if (dragon.level.getBlockState(pos.below()).getBlock() != Blocks.END_STONE) + if (dragon.level().getBlockState(pos.below()).getBlock() != Blocks.END_STONE) continue; - dragon.level.setBlockAndUpdate(pos, this.defaultBlockState()); + dragon.level().setBlockAndUpdate(pos, this.defaultBlockState()); } } @@ -104,9 +103,10 @@ public class BlockEndFlower extends BushBlock implements IModItem, ICustomBlockS levelIn.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); } + @Override @SuppressWarnings("deprecation") - public List getDrops(BlockState state, LootContext.Builder builder) { + public List getDrops(BlockState state, LootParams.Builder builder) { var tile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); if (tile instanceof BlockEntityEndFlower f && f.isDrainMode) return NonNullList.create(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java index b5816aa3..24f514bf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockEnderCrate.java @@ -27,7 +27,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -42,7 +41,7 @@ import java.util.List; public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { public BlockEnderCrate() { - super("ender_crate", BlockEntityEnderCrate.class, Properties.of(Material.STONE).strength(5F).lightLevel(s -> 7).sound(SoundType.STONE)); + super("ender_crate", BlockEntityEnderCrate.class, Properties.of().strength(5F).lightLevel(s -> 7).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @@ -77,7 +76,7 @@ public class BlockEnderCrate extends BlockContainerImpl implements ITESRProvider var name = event.getName(); if (name == null || name.isEmpty()) return; - if (ILevelData.getOverworldData(player.level).isEnderStorageLocked(name)) + if (ILevelData.getOverworldData(player.level()).isEnderStorageLocked(name)) return; var output = stack.copy(); output.getOrCreateTag().putString(NaturesAura.MOD_ID + ":ender_name", name); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java index 3b49a056..6321a78f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFieldCreator.java @@ -14,7 +14,6 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -22,7 +21,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockFieldCreator extends BlockContainerImpl implements ICustomBlockState { public BlockFieldCreator() { - super("field_creator", BlockEntityFieldCreator.class, Properties.of(Material.STONE).strength(2F).noCollission().sound(SoundType.STONE)); + super("field_creator", BlockEntityFieldCreator.class, Properties.of().strength(2F).noCollission().sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java index 8607eba9..10685316 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFireworkGenerator.java @@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -15,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockFireworkGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockFireworkGenerator() { - super("firework_generator", BlockEntityFireworkGenerator.class, Properties.of(Material.STONE).strength(3F).sound(SoundType.STONE)); + super("firework_generator", BlockEntityFireworkGenerator.class, Properties.of().strength(3F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java index b46370ab..7eb8556d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFlowerGenerator.java @@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -15,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockFlowerGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockFlowerGenerator() { - super("flower_generator", BlockEntityFlowerGenerator.class, Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F)); + super("flower_generator", BlockEntityFlowerGenerator.class, Properties.of().sound(SoundType.WOOD).strength(2F)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java index e83a4555..25190a65 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java @@ -15,7 +15,6 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; @@ -37,7 +36,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl implements ICustomBlo }; public BlockFurnaceHeater() { - super("furnace_heater", BlockEntityFurnaceHeater.class, Properties.of(Material.STONE).strength(3F)); + super("furnace_heater", BlockEntityFurnaceHeater.class, Properties.of().strength(3F)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java index 5b589e7a..f0ebcbfe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGeneratorLimitRemover.java @@ -8,12 +8,11 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; public class BlockGeneratorLimitRemover extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { public BlockGeneratorLimitRemover() { - super("generator_limit_remover", BlockEntityGeneratorLimitRemover.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); + super("generator_limit_remover", BlockEntityGeneratorLimitRemover.class, Properties.of().strength(2F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java index cfae9061..07a49d71 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGoldenLeaves.java @@ -18,8 +18,7 @@ import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; -import net.minecraft.world.level.material.Material; -import net.minecraft.world.level.material.MaterialColor; +import net.minecraft.world.level.material.MapColor; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -29,7 +28,7 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr public static final IntegerProperty STAGE = IntegerProperty.create("stage", 0, BlockGoldenLeaves.HIGHEST_STAGE); public BlockGoldenLeaves() { - super(Properties.of(Material.LEAVES, MaterialColor.GOLD).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); + super(Properties.of().mapColor(MapColor.GOLD).strength(0.2F).randomTicks().noOcclusion().sound(SoundType.GRASS)); ModRegistry.ALL_ITEMS.add(this); } @@ -115,4 +114,4 @@ public class BlockGoldenLeaves extends LeavesBlock implements IModItem, IColorPr public void generateCustomBlockState(BlockStateGenerator generator) { generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java index 83009233..622c7159 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockGratedChute.java @@ -22,7 +22,6 @@ 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; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; @@ -51,7 +50,7 @@ public class BlockGratedChute extends BlockContainerImpl implements ICustomBlock 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)); public BlockGratedChute() { - super("grated_chute", BlockEntityGratedChute.class, Properties.of(Material.METAL).strength(3.0F, 8.0F).sound(SoundType.METAL)); + super("grated_chute", BlockEntityGratedChute.class, Properties.of().strength(3.0F, 8.0F).sound(SoundType.METAL)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java index 5337209d..3360ead4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockHopperUpgrade.java @@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityHopperUpgrade; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -13,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockHopperUpgrade extends BlockContainerImpl implements IVisualizable { public BlockHopperUpgrade() { - super("hopper_upgrade", BlockEntityHopperUpgrade.class, Properties.of(Material.METAL).strength(2.5F).sound(SoundType.METAL)); + super("hopper_upgrade", BlockEntityHopperUpgrade.class, Properties.of().strength(2.5F).sound(SoundType.METAL)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java index 98092cd2..278307eb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java @@ -11,7 +11,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; @@ -22,7 +21,7 @@ public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemB private static final VoxelShape SHAPE = Block.box(4, 4, 4, 12, 12, 12); public BlockLight() { - super("light", Properties.of(Material.WOOL).noCollission().lightLevel(s -> 15)); + super("light", Properties.of().noCollission().lightLevel(s -> 15)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLowerLimiter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLowerLimiter.java index 895326d5..0465abf7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLowerLimiter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLowerLimiter.java @@ -8,12 +8,11 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import de.ellpeck.naturesaura.reg.ITESRProvider; import net.minecraft.client.renderer.blockentity.BlockEntityRenderers; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; public class BlockLowerLimiter extends BlockContainerImpl implements ICustomBlockState, ITESRProvider { public BlockLowerLimiter() { - super("lower_limiter", BlockEntityLowerLimiter.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); + super("lower_limiter", BlockEntityLowerLimiter.class, Properties.of().strength(2F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java index 77a98075..24910e7b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockMossGenerator.java @@ -5,7 +5,6 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityMossGenerator; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -13,7 +12,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockMossGenerator extends BlockContainerImpl implements IVisualizable { public BlockMossGenerator() { - super("moss_generator", BlockEntityMossGenerator.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); + super("moss_generator", BlockEntityMossGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java index 4b948bc4..21d948b8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNatureAltar.java @@ -16,7 +16,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -27,7 +26,7 @@ public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvide private static final VoxelShape SHAPE = Shapes.create(0, 0, 0, 1, 12 / 16F, 1); public BlockNatureAltar() { - super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F)); + super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of().strength(4F)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java index fd1b8acf..5385391c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockNetherGrass.java @@ -6,8 +6,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.RandomSource; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.BonemealableBlock; import net.minecraft.world.level.block.state.BlockState; @@ -36,7 +36,7 @@ public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, Bo } @Override - public boolean isValidBonemealTarget(BlockGetter levelIn, BlockPos pos, BlockState state, boolean isClient) { + public boolean isValidBonemealTarget(LevelReader levelIn, BlockPos pos, BlockState state, boolean isClient) { return levelIn.getBlockState(pos.above()).isAir(); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java index 2ff0ae64..bd071bd7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOakGenerator.java @@ -14,7 +14,6 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SaplingBlock; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -25,7 +24,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockOakGenerator extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockOakGenerator() { - super("oak_generator", BlockEntityOakGenerator.class, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD)); + super("oak_generator", BlockEntityOakGenerator.class, Properties.of().strength(2F).sound(SoundType.WOOD)); MinecraftForge.EVENT_BUS.register(this); } @@ -39,11 +38,11 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab Helper.getBlockEntitiesInArea(level, pos, 10, tile -> { if (!(tile instanceof BlockEntityOakGenerator oak)) return false; - var replacement = BlockOakGenerator.getReplacement(event.getFeature()); + /* var replacement = BlockOakGenerator.getReplacement(event.getFeature()); if (replacement != null) { oak.scheduledBigTrees.add(pos); event.setFeature(replacement); - } + }*/ return true; }); } @@ -69,7 +68,8 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab generator.modLoc("block/" + this.getBaseName() + "_top"))); } - private static Holder> getReplacement(Holder> feature) { + // TODO oak gen replacements + /*private static Holder> getReplacement(Holder> feature) { if (feature == TreeFeatures.FANCY_OAK || feature == TreeFeatures.FANCY_OAK_BEES) { return TreeFeatures.OAK; } else if (feature == TreeFeatures.FANCY_OAK_BEES_002) { @@ -81,5 +81,5 @@ public class BlockOakGenerator extends BlockContainerImpl implements IVisualizab } else { return null; } - } + }*/ } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java index ba56439e..f9951038 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockOfferingTable.java @@ -16,7 +16,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -27,7 +26,7 @@ public class BlockOfferingTable extends BlockContainerImpl implements ITESRProvi private static final VoxelShape SHAPE = Shapes.create(2 / 16F, 0F, 2 / 16F, 14 / 16F, 1F, 14 / 16F); public BlockOfferingTable() { - super("offering_table", BlockEntityOfferingTable.class, Properties.of(Material.WOOD).strength(2F).sound(SoundType.WOOD)); + super("offering_table", BlockEntityOfferingTable.class, Properties.of().strength(2F).sound(SoundType.WOOD)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java index 9f5cbc71..77c549bf 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPickupStopper.java @@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -21,7 +20,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockPickupStopper extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockPickupStopper() { - super("pickup_stopper", BlockEntityPickupStopper.class, Properties.of(Material.STONE).strength(2F).sound(SoundType.STONE)); + super("pickup_stopper", BlockEntityPickupStopper.class, Properties.of().strength(2F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); } @@ -32,7 +31,7 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza if (player != null && !player.isShiftKeyDown()) { var item = event.getItem(); var pos = item.blockPosition(); - Helper.getBlockEntitiesInArea(item.level, pos, 8, tile -> { + Helper.getBlockEntitiesInArea(item.level(), pos, 8, tile -> { if (!(tile instanceof BlockEntityPickupStopper stopper)) return false; var radius = stopper.getRadius(); @@ -44,8 +43,8 @@ public class BlockPickupStopper extends BlockContainerImpl implements IVisualiza event.setCanceled(true); - if (item.level.getGameTime() % 3 == 0) - PacketHandler.sendToAllAround(item.level, pos, 32, + if (item.level().getGameTime() % 3 == 0) + PacketHandler.sendToAllAround(item.level(), pos, 32, new PacketParticles((float) item.getX(), (float) item.getY(), (float) item.getZ(), PacketParticles.Type.PICKUP_STOPPER)); return true; }); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java index 86c76b95..847e4d90 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPlacer.java @@ -7,7 +7,6 @@ import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -15,7 +14,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; public class BlockPlacer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { public BlockPlacer() { - super("placer", BlockEntityPlacer.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); + super("placer", BlockEntityPlacer.class, Properties.of().strength(2.5F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java index 5e2a1221..f8173ee2 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPotionGenerator.java @@ -3,12 +3,11 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityPotionGenerator; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; -import net.minecraft.world.level.material.Material; public class BlockPotionGenerator extends BlockContainerImpl implements ICustomBlockState { public BlockPotionGenerator() { - super("potion_generator", BlockEntityPotionGenerator.class, Properties.of(Material.STONE).strength(5F)); + super("potion_generator", BlockEntityPotionGenerator.class, Properties.of().strength(5F)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java index dcd37820..3e2143dc 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockPowderPlacer.java @@ -7,7 +7,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; @@ -17,7 +16,7 @@ public class BlockPowderPlacer extends BlockContainerImpl implements ICustomBloc private static final VoxelShape SHAPE = Shapes.create(0F, 0F, 0F, 1F, 4 / 16F, 1F); public BlockPowderPlacer() { - super("powder_placer", BlockEntityPowderPlacer.class, Properties.of(Material.STONE).strength(2, 5F).sound(SoundType.STONE)); + super("powder_placer", BlockEntityPowderPlacer.class, Properties.of().strength(2, 5F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java index c0c1d794..ca4275e9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockProjectileGenerator.java @@ -24,7 +24,6 @@ import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.ProjectileImpactEvent; @@ -34,7 +33,7 @@ import net.minecraftforge.fml.util.ObfuscationReflectionHelper; public class BlockProjectileGenerator extends BlockContainerImpl implements ITESRProvider, ICustomBlockState { public BlockProjectileGenerator() { - super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); + super("projectile_generator", BlockEntityProjectileGenerator.class, Properties.of().strength(2.5F).sound(SoundType.STONE)); MinecraftForge.EVENT_BUS.register(this); DispenserBlock.registerBehavior(Items.ENDER_PEARL, new AbstractProjectileDispenseBehavior() { @@ -61,7 +60,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES @SubscribeEvent public void onProjectileImpact(ProjectileImpactEvent event) { var entity = event.getEntity(); - if (entity.level.isClientSide) + if (entity.level().isClientSide) return; var ray = event.getRayTraceResult(); if (!(ray instanceof BlockHitResult blockRay)) @@ -69,7 +68,7 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES var pos = blockRay.getBlockPos(); if (pos == null) return; - var tile = entity.level.getBlockEntity(pos); + var tile = entity.level().getBlockEntity(pos); if (!(tile instanceof BlockEntityProjectileGenerator generator)) return; if (generator.nextSide != blockRay.getDirection()) @@ -81,9 +80,9 @@ public class BlockProjectileGenerator extends BlockContainerImpl implements ITES return; generator.generateAura(amount); - PacketHandler.sendToAllAround(entity.level, pos, 32, + PacketHandler.sendToAllAround(entity.level(), pos, 32, new PacketParticles((float) entity.getX(), (float) entity.getY(), (float) entity.getZ(), PacketParticles.Type.PROJECTILE_GEN, pos.getX(), pos.getY(), pos.getZ())); - entity.level.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F); + entity.level().playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.BLOCKS, 0.8F, 1F); generator.nextSide = generator.nextSide.getClockWise(); generator.sendToClients(); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java index affb0fff..7ca60db4 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockRFConverter.java @@ -4,12 +4,11 @@ import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityRFConverter; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; public class BlockRFConverter extends BlockContainerImpl { public BlockRFConverter() { - super("rf_converter", BlockEntityRFConverter.class, Properties.of(Material.STONE).sound(SoundType.STONE).strength(3)); + super("rf_converter", BlockEntityRFConverter.class, Properties.of().sound(SoundType.STONE).strength(3)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java index 7dc9bb9d..29de1fd5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSlimeSplitGenerator.java @@ -48,12 +48,12 @@ public class BlockSlimeSplitGenerator extends BlockContainerImpl implements IVis @SubscribeEvent public void onLivingDeath(LivingDeathEvent event) { var entity = event.getEntity(); - if (!(entity instanceof Slime slime) || entity.level.isClientSide) + if (!(entity instanceof Slime slime) || entity.level().isClientSide) return; var size = slime.getSize(); if (size <= 1) return; - Helper.getBlockEntitiesInArea(entity.level, entity.blockPosition(), 8, tile -> { + Helper.getBlockEntitiesInArea(entity.level(), entity.blockPosition(), 8, tile -> { if (!(tile instanceof BlockEntitySlimeSplitGenerator gen)) return false; if (gen.isBusy()) diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java index 7c5d9573..190647c1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpawnLamp.java @@ -15,7 +15,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; @@ -24,7 +23,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingSpawnEvent; +import net.minecraftforge.event.entity.living.MobSpawnEvent; import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -33,7 +32,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, private static final VoxelShape SHAPE = Shapes.create(4 / 16F, 0F, 4 / 16F, 12 / 16F, 13 / 16F, 12 / 16F); public BlockSpawnLamp() { - super("spawn_lamp", BlockEntitySpawnLamp.class, Properties.of(Material.METAL).strength(3F).lightLevel(s -> 15).sound(SoundType.METAL)); + super("spawn_lamp", BlockEntitySpawnLamp.class, Properties.of().strength(3F).lightLevel(s -> 15).sound(SoundType.METAL)); MinecraftForge.EVENT_BUS.register(this); } @@ -43,12 +42,12 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, } @SubscribeEvent - public void onSpawn(LivingSpawnEvent.CheckSpawn event) { + public void onSpawn(MobSpawnEvent.PositionCheck event) { var amountToUse = 200; if (event.getSpawner() != null) return; var accessor = event.getLevel(); - var pos = new BlockPos(event.getX(), event.getY(), event.getZ()); + var pos = BlockPos.containing(event.getX(), event.getY(), event.getZ()); if (!(accessor instanceof Level level)) return; var data = (LevelData) ILevelData.getLevelData(level); @@ -65,7 +64,7 @@ public class BlockSpawnLamp extends BlockContainerImpl implements IVisualizable, continue; var entity = (Mob) event.getEntity(); - if (entity.checkSpawnRules(level, event.getSpawnReason()) && entity.checkSpawnObstruction(level)) { + if (entity.checkSpawnRules(level, event.getSpawnType()) && entity.checkSpawnObstruction(level)) { var spot = IAuraChunk.getHighestSpot(level, lampPos, 32, lampPos); IAuraChunk.getAuraChunk(level, spot).drainAura(spot, amountToUse); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java index d233ff0a..f8580547 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockSpring.java @@ -46,7 +46,7 @@ public class BlockSpring extends BlockContainerImpl implements ICustomBlockState Player player = Minecraft.getInstance().player; if (player == null) return 0; - return BiomeColors.getAverageWaterColor(player.level, player.blockPosition()); + return BiomeColors.getAverageWaterColor(player.level(), player.blockPosition()); } }; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java index 194bab00..fdc50b19 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockTimeChanger.java @@ -4,12 +4,11 @@ import de.ellpeck.naturesaura.blocks.tiles.BlockEntityTimeChanger; import de.ellpeck.naturesaura.data.BlockStateGenerator; import de.ellpeck.naturesaura.reg.ICustomBlockState; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.material.Material; public class BlockTimeChanger extends BlockContainerImpl implements ICustomBlockState { public BlockTimeChanger() { - super("time_changer", BlockEntityTimeChanger.class, Properties.of(Material.STONE).strength(2.5F).sound(SoundType.STONE)); + super("time_changer", BlockEntityTimeChanger.class, Properties.of().strength(2.5F).sound(SoundType.STONE)); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index 26df78c2..5f887f4c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -20,7 +20,6 @@ import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -39,7 +38,7 @@ public class BlockWoodStand extends BlockContainerImpl implements ITESRProvider< private static final VoxelShape SHAPE = Shapes.create(3 / 16F, 0F, 3 / 16F, 13 / 16F, 13 / 16F, 13 / 16F); public BlockWoodStand() { - super("wood_stand", BlockEntityWoodStand.class, Properties.of(Material.WOOD).strength(1.5F).sound(SoundType.WOOD)); + super("wood_stand", BlockEntityWoodStand.class, Properties.of().strength(1.5F).sound(SoundType.WOOD)); MinecraftForge.EVENT_BUS.register(this); } 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 290eebf8..1e9abb81 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/multi/Multiblocks.java @@ -12,7 +12,6 @@ import net.minecraft.tags.BlockTags; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.SaplingBlock; -import net.minecraft.world.level.material.Material; public final class Multiblocks { @@ -38,7 +37,7 @@ public final class Multiblocks { 'G', ModBlocks.GOLD_POWDER, '0', new Matcher(Blocks.OAK_SAPLING.defaultBlockState(), (level, start, offset, pos, state, c) -> { - if (state.getBlock() instanceof SaplingBlock || state.getMaterial() == Material.WOOD) + 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 { 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 fddee714..db7e5ed8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAnimalSpawner.java @@ -59,7 +59,7 @@ public class BlockEntityAnimalSpawner extends BlockEntityImpl implements ITickab this.time += 10; if (this.time >= this.currentRecipe.time) { - var entity = this.currentRecipe.makeEntity(this.level, new BlockPos(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ)); + var entity = this.currentRecipe.makeEntity(this.level, BlockPos.containing(this.spawnX, this.worldPosition.getY() + 1, this.spawnZ)); this.level.addFreshEntity(entity); this.currentRecipe = null; 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 ed0da18d..961fc9a7 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityAutoCrafter.java @@ -10,6 +10,7 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.CraftingContainer; +import net.minecraft.world.inventory.TransientCraftingContainer; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.state.BlockState; @@ -17,7 +18,7 @@ import net.minecraft.world.phys.AABB; public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickableBlockEntity { - public final CraftingContainer crafting = new CraftingContainer(new AbstractContainerMenu(null, 0) { + public final CraftingContainer crafting = new TransientCraftingContainer(new AbstractContainerMenu(null, 0) { @Override public ItemStack quickMoveStack(Player p_38941_, int p_38942_) { return ItemStack.EMPTY; @@ -81,7 +82,7 @@ public class BlockEntityAutoCrafter extends BlockEntityImpl implements ITickable if (recipe == null) return; - var result = recipe.assemble(this.crafting); + var result = recipe.assemble(this.crafting, this.level.registryAccess()); if (result.isEmpty()) return; var resultItem = new ItemEntity(this.level, 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 b72d3062..95c5bb44 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityBlastFurnaceBooster.java @@ -57,7 +57,7 @@ public class BlockEntityBlastFurnaceBooster extends BlockEntityImpl implements I return; if (output.isEmpty()) { - var result = recipe.getResultItem(); + var result = recipe.getResultItem(this.level.registryAccess()); tile.setItem(2, result.copy()); } else { output.grow(1); 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 60f5e68e..57b1b0bd 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFieldCreator.java @@ -14,7 +14,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.LootParams; import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.MinecraftForge; @@ -109,7 +109,7 @@ public class BlockEntityFieldCreator extends BlockEntityImpl implements ITickabl if (!state.isAir() && state.getDestroySpeed(this.level, pos) >= 0F) { var fake = FakePlayerFactory.getMinecraft((ServerLevel) this.level); if (!MinecraftForge.EVENT_BUS.post(new BlockEvent.BreakEvent(this.level, pos, state, fake))) { - var drops = state.getDrops(new LootContext.Builder((ServerLevel) this.level) + var drops = state.getDrops(new LootParams.Builder((ServerLevel) this.level) .withParameter(LootContextParams.THIS_ENTITY, fake) .withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos)) .withParameter(LootContextParams.BLOCK_STATE, state) 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 6e31e62f..a30e5d64 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityFurnaceHeater.java @@ -105,7 +105,7 @@ public class BlockEntityFurnaceHeater extends BlockEntityImpl implements ITickab var recipe = this.level.getRecipeManager().getRecipeFor(BlockEntityFurnaceHeater.getRecipeType(furnace), furnace, this.level).orElse(null); if (recipe == null) return false; - var output = recipe.getResultItem(); + var output = recipe.getResultItem(this.level.registryAccess()); var currOutput = furnace.getItem(2); return currOutput.isEmpty() || Helper.areItemsEqual(currOutput, output, true) && currOutput.getCount() + output.getCount() <= output.getMaxStackSize(); } else diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityPlacer.java index d348e4af..89600dbe 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntityPlacer.java @@ -59,7 +59,7 @@ public class BlockEntityPlacer extends BlockEntityImpl implements ITickableBlock var up = pos.above(); var state = this.level.getBlockState(up); - if (state.getMaterial().isReplaceable()) + if (state.canBeReplaced()) validPositions.add(up); } if (validPositions.isEmpty()) 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 0975addf..47ad2b35 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/BlockEntitySnowCreator.java @@ -49,15 +49,15 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable for (var i = 0; i < 10; i++) { var angle = this.level.random.nextFloat() * Math.PI * 2; - var pos = this.worldPosition.offset(Math.cos(angle) * range * this.level.random.nextFloat(), 0, Math.sin(angle) * range * this.level.random.nextFloat()); + var pos = this.worldPosition.offset(Mth.floor(Math.cos(angle) * range * this.level.random.nextFloat()), 0, Mth.floor(Math.sin(angle) * range * this.level.random.nextFloat())); pos = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); var down = pos.below(); var fluid = this.level.getFluidState(down).getType(); if (fluid == Fluids.WATER) { - if (this.level.getBlockState(down).getMaterial().isReplaceable()) + if (this.level.getBlockState(down).canBeReplaced()) this.level.setBlockAndUpdate(down, Blocks.ICE.defaultBlockState()); - } else if (Blocks.SNOW.defaultBlockState().canSurvive(this.level, pos) && this.level.getBlockState(pos).getBlock() != Blocks.SNOW && this.level.getBlockState(pos).getMaterial().isReplaceable()) { + } else if (Blocks.SNOW.defaultBlockState().canSurvive(this.level, pos) && this.level.getBlockState(pos).getBlock() != Blocks.SNOW && this.level.getBlockState(pos).canBeReplaced()) { this.level.setBlockAndUpdate(pos, Blocks.SNOW.defaultBlockState()); if (this.snowmanCount < range / 2 && this.level.random.nextFloat() >= 0.995F) { @@ -83,9 +83,9 @@ public class BlockEntitySnowCreator extends BlockEntityImpl implements ITickable for (var i = range * 4; i >= 0; i--) { var angle = this.level.random.nextFloat() * Math.PI * 2; var pos = this.worldPosition.offset( - Math.cos(angle) * range * this.level.random.nextFloat(), + Mth.floor(Math.cos(angle) * range * this.level.random.nextFloat()), Mth.nextInt(this.level.random, range / 2, range), - Math.sin(angle) * range * this.level.random.nextFloat()); + Mth.floor(Math.sin(angle) * range * this.level.random.nextFloat())); NaturesAuraAPI.instance().spawnMagicParticle( pos.getX() + this.level.random.nextFloat(), pos.getY() + 1, pos.getZ() + this.level.random.nextFloat(), this.level.random.nextGaussian() * 0.05, 0, this.level.random.nextGaussian() * 0.05, diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java index 3deee36a..4749ea64 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderEnderCrate.java @@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityEnderCrate; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -10,6 +9,7 @@ import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.joml.Matrix4f; @OnlyIn(Dist.CLIENT) public class RenderEnderCrate implements BlockEntityRenderer { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java index 949d3767..90dabf1c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/render/RenderGeneratorLimitRemover.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.blocks.tiles.render; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityGeneratorLimitRemover; import de.ellpeck.naturesaura.blocks.tiles.BlockEntityImpl; @@ -44,7 +44,7 @@ public class RenderGeneratorLimitRemover implements BlockEntityRenderer { @@ -23,8 +23,8 @@ public class RenderNatureAltar implements BlockEntityRenderer { @@ -22,7 +22,7 @@ public class RenderWoodStand implements BlockEntityRenderer this.dist * this.dist) return ActiveType.INACTIVE; @@ -65,9 +65,11 @@ public class ExplosionEffect implements IDrainSpotEffect { var z = Mth.floor(pos.getZ() + level.random.nextGaussian() * this.dist); var chosenPos = new BlockPos(x, level.getHeight(Heightmap.Types.WORLD_SURFACE, x, z), z); if (chosenPos.distSqr(pos) <= this.dist * this.dist && level.isLoaded(chosenPos)) { - level.explode(null, - chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5, - this.strength, false, Explosion.BlockInteraction.DESTROY); + var explosion = new Explosion(level, null, chosenPos.getX() + 0.5, chosenPos.getY() + 0.5, chosenPos.getZ() + 0.5, this.strength, false, Explosion.BlockInteraction.DESTROY); + if (!net.minecraftforge.event.ForgeEventFactory.onExplosionStart(level, explosion)) { + explosion.explode(); + explosion.finalizeExplosion(true); + } } } 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 688960a9..a3bfba60 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/GrassDieEffect.java @@ -45,7 +45,7 @@ public class GrassDieEffect implements IDrainSpotEffect { @Override public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.level, pos, spot)) + if (!this.calcValues(player.level(), pos, spot)) return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; @@ -62,7 +62,7 @@ public class GrassDieEffect implements IDrainSpotEffect { if (!this.calcValues(level, pos, spot)) return; for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) { - var grassPos = new BlockPos( + 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 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 db0dda83..1b224698 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherDecayEffect.java @@ -44,7 +44,7 @@ public class NetherDecayEffect implements IDrainSpotEffect { @Override public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.level, pos, spot)) + if (!this.calcValues(player.level(), pos, spot)) return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; @@ -61,7 +61,7 @@ public class NetherDecayEffect implements IDrainSpotEffect { if (!this.calcValues(level, pos, spot)) return; for (var i = this.amount / 2 + level.random.nextInt(this.amount / 2); i >= 0; i--) { - var offset = new BlockPos( + 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); 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 c156ba56..a23b4e26 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/NetherGrassEffect.java @@ -43,11 +43,11 @@ public class NetherGrassEffect implements IDrainSpotEffect { @Override public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.level, pos, spot)) + if (!this.calcValues(player.level(), pos, spot)) return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), NetherGrassEffect.NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level(), player.blockPosition(), NetherGrassEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } 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 17a43787..e83caf42 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/OreSpawnEffect.java @@ -59,11 +59,11 @@ public class OreSpawnEffect implements IDrainSpotEffect { @Override public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.level, pos, spot)) + if (!this.calcValues(player.level(), pos, spot)) return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), OreSpawnEffect.NAME)) + if (!NaturesAuraAPI.instance().isEffectPowderActive(player.level(), player.blockPosition(), OreSpawnEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } 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 6fb54788..709885ff 100644 --- a/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/chunk/effect/PlantBoostEffect.java @@ -49,11 +49,11 @@ public class PlantBoostEffect implements IDrainSpotEffect { @Override public ActiveType isActiveHere(Player player, LevelChunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) { - if (!this.calcValues(player.level, pos, spot)) + if (!this.calcValues(player.level(), pos, spot)) return ActiveType.INACTIVE; if (player.distanceToSqr(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist) return ActiveType.INACTIVE; - if (NaturesAuraAPI.instance().isEffectPowderActive(player.level, player.blockPosition(), PlantBoostEffect.NAME)) + if (NaturesAuraAPI.instance().isEffectPowderActive(player.level(), player.blockPosition(), PlantBoostEffect.NAME)) return ActiveType.INHIBITED; return ActiveType.ACTIVE; } diff --git a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java index 7b9b88f3..c5b40b29 100644 --- a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java +++ b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java @@ -15,29 +15,29 @@ public final class CommandAura { .then(Commands.literal("add").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> { var amount = IntegerArgumentType.getInteger(context, "amount"); var source = context.getSource(); - var pos = new BlockPos(source.getPosition()); + var pos = BlockPos.containing(source.getPosition()); while (amount > 0) { var spot = IAuraChunk.getLowestSpot(source.getLevel(), pos, 35, pos); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).storeAura(spot, amount); } - source.sendSuccess(Component.literal("Added aura to area"), true); + source.sendSuccess(() -> Component.literal("Added aura to area"), true); return 0; }))) .then(Commands.literal("remove").then(Commands.argument("amount", IntegerArgumentType.integer(1)).executes(context -> { var amount = IntegerArgumentType.getInteger(context, "amount"); var source = context.getSource(); - var pos = new BlockPos(source.getPosition()); + var pos = BlockPos.containing(source.getPosition()); while (amount > 0) { var spot = IAuraChunk.getHighestSpot(source.getLevel(), pos, 35, pos); amount -= IAuraChunk.getAuraChunk(source.getLevel(), spot).drainAura(spot, amount); } - source.sendSuccess(Component.literal("Removed aura from area"), true); + source.sendSuccess(() -> Component.literal("Removed aura from area"), true); return 0; }))) .then(Commands.literal("reset").then(Commands.argument("range", IntegerArgumentType.integer(10, 1000)).executes(context -> { var range = IntegerArgumentType.getInteger(context, "range"); var source = context.getSource(); - var pos = new BlockPos(source.getPosition()); + var pos = BlockPos.containing(source.getPosition()); IAuraChunk.getSpotsInArea(source.getLevel(), pos, range, (spot, amount) -> { var chunk = IAuraChunk.getAuraChunk(source.getLevel(), spot); if (amount > 0) @@ -45,7 +45,7 @@ public final class CommandAura { else chunk.storeAura(spot, -amount); }); - source.sendSuccess(Component.literal("Reset aura in area"), true); + source.sendSuccess(() -> Component.literal("Reset aura in area"), true); return 0; })))); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java index eb1df8c6..e6df341d 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/CuriosCompat.java @@ -60,7 +60,7 @@ public class CuriosCompat implements ICompat { private final LazyOptional curio = LazyOptional.of(() -> new ICurio() { @Override public void curioTick(SlotContext slotContext) { - stack.getItem().inventoryTick(stack, slotContext.entity().level, slotContext.entity(), -1, false); + stack.getItem().inventoryTick(stack, slotContext.entity().level(), slotContext.entity(), -1, false); } @Override 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 426d4fe0..e941a449 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/AnimalSpawnerCategory.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.compat.jei; import com.mojang.blaze3d.platform.Lighting; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import mezz.jei.api.gui.builder.IRecipeLayoutBuilder; @@ -15,6 +15,7 @@ import mezz.jei.api.recipe.RecipeIngredientRole; import mezz.jei.api.recipe.RecipeType; import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -47,8 +48,8 @@ public class AnimalSpawnerCategory implements IRecipeCategory= x && event.getMouseY() >= y && event.getMouseX() < x + 43 && event.getMouseY() < y + 42) - gui.renderComponentTooltip(event.getPoseStack(), + event.getGraphics().renderTooltip(Minecraft.getInstance().font, Collections.singletonList(Component.literal("It's the author Ellpeck's birthday!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD))), - event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); + 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; - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, ClientEvents.BOOK_GUI); - Screen.blit(event.getPoseStack(), x, y, 424, 0, 45, 26, 512, 256); + event.getGraphics().blit(ClientEvents.BOOK_GUI, x, y, 424, 0, 45, 26, 512, 256); if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 45 && event.getMouseY() < y + 26) - gui.renderComponentTooltip(event.getPoseStack(), - Collections.singletonList(Component.literal("\u00A76Happy \u00A74P\u00A76r\u00A7ei\u00A72d\u00A79e\u00A75!")), - event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); + //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()); } var name = gui.getMinecraft().player.getName().getString(); @@ -128,24 +121,21 @@ public class PatchouliCompat implements ICompat { var x = gui.width / 2 - 272 / 2 + 20; var y = gui.height / 2 + 180 / 2; - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, ClientEvents.BOOK_GUI); - - Screen.blit(event.getPoseStack(), x, y, 496, 44, 16, 18, 512, 256); + event.getGraphics().blit(ClientEvents.BOOK_GUI, x, y, 496, 44, 16, 18, 512, 256); if (info.tier() == 1) { - Screen.blit(event.getPoseStack(), x, y, 496 - 16, 44, 16, 18, 512, 256); + event.getGraphics().blit(ClientEvents.BOOK_GUI, x, y, 496 - 16, 44, 16, 18, 512, 256); } else { var r = (info.color() >> 16 & 255) / 255F; var g = (info.color() >> 8 & 255) / 255F; var b = (info.color() & 255) / 255F; RenderSystem.setShaderColor(r, g, b, 1); - Screen.blit(event.getPoseStack(), x, y, 496 - 32, 44, 16, 18, 512, 256); + event.getGraphics().blit(ClientEvents.BOOK_GUI, x, y, 496 - 32, 44, 16, 18, 512, 256); } if (event.getMouseX() >= x && event.getMouseY() >= y && event.getMouseX() < x + 16 && event.getMouseY() < y + 18) - gui.renderComponentTooltip(event.getPoseStack(), - Collections.singletonList(Component.literal("Thanks for your support, " + name + "!").setStyle(Style.EMPTY.applyFormat(ChatFormatting.YELLOW))), - event.getMouseX(), event.getMouseY(), gui.getMinecraft().font); + 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()); } } 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 d196e89f..2fa30e0b 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.recipes.AltarRecipe; import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariableProvider; @@ -11,18 +12,19 @@ public class ProcessorAltar implements IComponentProcessor { private AltarRecipe recipe; @Override - public void setup(IVariableProvider provider) { + public void setup(Level level, IVariableProvider provider) { this.recipe = PatchouliCompat.getRecipe("altar", provider.get("recipe").asString()); } @Override - public IVariable process(String key) { + public IVariable process(Level level, String key) { 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 "catalyst" -> + this.recipe.catalyst != Ingredient.EMPTY ? PatchouliCompat.ingredientVariable(this.recipe.catalyst) : null; case "name" -> IVariable.wrap(this.recipe.output.getHoverName().getString()); 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 98d41f6c..0b91fa3a 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.recipes.AnimalSpawnerRecipe; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; import net.minecraftforge.common.ForgeSpawnEggItem; import net.minecraftforge.registries.ForgeRegistries; import vazkii.patchouli.api.IComponentProcessor; @@ -13,12 +14,12 @@ public class ProcessorAnimalSpawner implements IComponentProcessor { private AnimalSpawnerRecipe recipe; @Override - public void setup(IVariableProvider provider) { + public void setup(Level level, IVariableProvider provider) { this.recipe = PatchouliCompat.getRecipe("animal_spawner", provider.get("recipe").asString()); } @Override - public IVariable process(String key) { + public IVariable process(Level level, String key) { if (this.recipe == null) return null; if (key.startsWith("input")) { 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 fa1a8e57..67de66fa 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.recipes.OfferingRecipe; +import net.minecraft.world.level.Level; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariableProvider; @@ -10,12 +11,12 @@ public class ProcessorOffering implements IComponentProcessor { private OfferingRecipe recipe; @Override - public void setup(IVariableProvider provider) { + public void setup(Level level, IVariableProvider provider) { this.recipe = PatchouliCompat.getRecipe("offering", provider.get("recipe").asString()); } @Override - public IVariable process(String key) { + public IVariable process(Level level, String key) { if (this.recipe == null) return null; return switch (key) { 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 169f1b50..ce8ab970 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import net.minecraft.world.level.Level; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariableProvider; @@ -10,12 +11,12 @@ public class ProcessorTreeRitual implements IComponentProcessor { private TreeRitualRecipe recipe; @Override - public void setup(IVariableProvider provider) { + public void setup(Level level, IVariableProvider provider) { this.recipe = PatchouliCompat.getRecipe("tree_ritual", provider.get("recipe").asString()); } @Override - public IVariable process(String key) { + public IVariable process(Level level, String key) { if (this.recipe == null) return null; if (key.startsWith("input")) { diff --git a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java index 84a70d1b..dc3c13cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ItemTagProvider.java @@ -8,6 +8,7 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.BlockTagsProvider; +import net.minecraft.data.tags.IntrinsicHolderTagsProvider; import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.tags.BlockTags; import net.minecraft.tags.ItemTags; @@ -39,15 +40,15 @@ public class ItemTagProvider extends ItemTagsProvider { ModRegistry.ALL_ITEMS.stream().sorted(Comparator.comparing(IModItem::getBaseName)).filter(i -> i instanceof Item).map(i -> (Item) i).forEach(i -> { if (i instanceof ItemPickaxe) { this.tag(ItemTags.CLUSTER_MAX_HARVESTABLES).add(i); - this.tag(Tags.Items.TOOLS_PICKAXES).add(i); + this.tag(ItemTags.PICKAXES).add(i); } else if (i instanceof ItemAxe) { - this.tag(Tags.Items.TOOLS_AXES).add(i); + this.tag(ItemTags.AXES).add(i); } else if (i instanceof ItemHoe) { - this.tag(Tags.Items.TOOLS_HOES).add(i); + this.tag(ItemTags.HOES).add(i); } else if (i instanceof ItemSword) { - this.tag(Tags.Items.TOOLS_SWORDS).add(i); + this.tag(ItemTags.SWORDS).add(i); } else if (i instanceof ItemShovel) { - this.tag(Tags.Items.TOOLS_SHOVELS).add(i); + this.tag(ItemTags.SHOVELS).add(i); } }); @@ -55,7 +56,7 @@ public class ItemTagProvider extends ItemTagsProvider { } @Override - public TagAppender tag(TagKey tag) { + public IntrinsicHolderTagsProvider.IntrinsicTagAppender tag(TagKey tag) { // super is protected, but CuriosCompat needs this return super.tag(tag); } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java index ead2ae95..bf2f236e 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityEffectInhibitor.java @@ -10,13 +10,13 @@ import de.ellpeck.naturesaura.misc.LevelData; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Tuple; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.damagesource.EntityDamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.player.Player; @@ -94,16 +94,16 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { if (this.powderListDirty) this.updatePowderListStatus(this.getInhibitedEffect()); - if (this.level.isClientSide) { - if (this.level.getGameTime() % 5 == 0) { + if (this.level().isClientSide) { + if (this.level().getGameTime() % 5 == 0) { NaturesAuraAPI.instance().spawnMagicParticle( - this.getX() + this.level.random.nextGaussian() * 0.1F, + 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.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++; } @@ -124,18 +124,18 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { } @Override - public Packet getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public boolean skipAttackInteraction(Entity entity) { - return entity instanceof Player player && (!this.level.mayInteract(player, this.blockPosition()) || this.hurt(DamageSource.playerAttack(player), 0.0F)); + return entity instanceof Player player && (!this.level().mayInteract(player, this.blockPosition()) || this.hurt(this.damageSources().playerAttack(player), 0.0F)); } @Override public boolean hurt(DamageSource source, float amount) { - if (source instanceof EntityDamageSource && !this.level.isClientSide) { + if (source.getEntity() != null && !this.level().isClientSide) { this.spawnAtLocation(this.getDrop(), 0F); this.kill(); return true; @@ -200,7 +200,7 @@ public class EntityEffectInhibitor extends Entity implements IVisualizable { } private void updatePowderListStatus(ResourceLocation inhibitedEffect) { - var powders = ((LevelData) ILevelData.getLevelData(this.level)).effectPowders; + var powders = ((LevelData) ILevelData.getLevelData(this.level())).effectPowders; if (this.lastEffect != null) { var oldList = powders.get(this.lastEffect); oldList.removeIf(t -> this.getEyePosition().equals(t.getA())); diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java index e21f54a9..d4126680 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java @@ -29,7 +29,7 @@ public class EntityLightProjectile extends ThrowableProjectile { @Override public void tick() { super.tick(); - if (this.level.isClientSide && this.tickCount > 1) { + 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()), @@ -43,12 +43,12 @@ public class EntityLightProjectile extends ThrowableProjectile { @Override protected void onHit(HitResult result) { - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { if (result instanceof BlockHitResult res) { var pos = res.getBlockPos().relative(res.getDirection()); - var state = this.level.getBlockState(pos); - if (state.getMaterial().isReplaceable()) - this.level.setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState()); + var state = this.level().getBlockState(pos); + if (state.canBeReplaced()) + this.level().setBlockAndUpdate(pos, ModBlocks.LIGHT.defaultBlockState()); } else if (result instanceof EntityHitResult entity) { entity.getEntity().setSecondsOnFire(5); } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java index 1067be77..1c16bee9 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityMoverMinecart.java @@ -10,6 +10,8 @@ import net.minecraft.nbt.ListTag; import net.minecraft.nbt.LongTag; import net.minecraft.nbt.Tag; import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.game.ClientGamePacketListener; +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; @@ -57,15 +59,15 @@ public class EntityMoverMinecart extends Minecart { return; var pos = this.blockPosition(); - if (!this.spotOffsets.isEmpty() && this.level.getGameTime() % 10 == 0) - PacketHandler.sendToAllAround(this.level, pos, 32, new PacketParticles( + 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))); if (pos.distSqr(this.lastPosition) < 8 * 8) return; - this.moveAura(this.level, this.lastPosition, this.level, pos); + this.moveAura(this.level(), this.lastPosition, this.level(), pos); this.lastPosition = pos; } @@ -93,13 +95,13 @@ public class EntityMoverMinecart extends Minecart { var pos = this.blockPosition(); if (!this.isActive) { - this.moveAura(this.level, this.lastPosition, this.level, pos); + this.moveAura(this.level(), this.lastPosition, this.level(), pos); this.spotOffsets.clear(); this.lastPosition = BlockPos.ZERO; return; } - IAuraChunk.getSpotsInArea(this.level, pos, 25, (spot, amount) -> { + IAuraChunk.getSpotsInArea(this.level(), pos, 25, (spot, amount) -> { if (amount > 0) this.spotOffsets.add(spot.subtract(pos)); }); @@ -110,7 +112,7 @@ public class EntityMoverMinecart extends Minecart { @Override public void destroy(DamageSource source) { this.kill(); - if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) + if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) this.spawnAtLocation(new ItemStack(ModItems.MOVER_CART), 0); } @@ -145,7 +147,7 @@ public class EntityMoverMinecart extends Minecart { var entity = super.changeDimension(destination, teleporter); if (entity instanceof EntityMoverMinecart) { var pos = entity.blockPosition(); - this.moveAura(this.level, this.lastPosition, entity.level, pos); + this.moveAura(this.level(), this.lastPosition, entity.level(), pos); ((EntityMoverMinecart) entity).lastPosition = pos; } return entity; @@ -183,7 +185,7 @@ public class EntityMoverMinecart extends Minecart { } @Override - public Packet getAddEntityPacket() { + public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java index d508def7..b87230f0 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityStructureFinder.java @@ -92,7 +92,7 @@ public class EntityStructureFinder extends EyeOfEnder { this.yRotO += 360.0F; this.setXRot(Mth.lerp(0.2F, this.xRotO, this.getXRot())); this.setYRot(Mth.lerp(0.2F, this.yRotO, this.getYRot())); - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { var d3 = this.targetX - d0; var d4 = this.targetZ - d2; var f1 = (float) Math.sqrt(d3 * d3 + d4 * d4); @@ -111,21 +111,21 @@ public class EntityStructureFinder extends EyeOfEnder { if (this.isInWater()) { for (var i = 0; i < 4; ++i) - this.level.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); - } else if (this.level.isClientSide) { + this.level().addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); + } else if (this.level().isClientSide) { NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.random.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.entityData.get(EntityStructureFinder.COLOR), 1, 50, 0, false, true); } - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { this.setPos(d0, d1, d2); ++this.despawnTimer; - if (this.despawnTimer > 80 && !this.level.isClientSide) { + if (this.despawnTimer > 80 && !this.level().isClientSide) { this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F); this.remove(RemovalReason.DISCARDED); if (this.shatterOrDrop) { - this.level.addFreshEntity(new ItemEntity(this.level, this.getX(), this.getY(), this.getZ(), this.getItem())); + this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem())); } else { - PacketHandler.sendToAllAround(this.level, this.blockPosition(), 32, new PacketParticles((float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getId())); + PacketHandler.sendToAllAround(this.level(), this.blockPosition(), 32, new PacketParticles((float) this.getX(), (float) this.getY(), (float) this.getZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getId())); } } } else { diff --git a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderEffectInhibitor.java b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderEffectInhibitor.java index bd693403..4148df6f 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderEffectInhibitor.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderEffectInhibitor.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.entities.render; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; import de.ellpeck.naturesaura.items.ItemEffectPowder; import de.ellpeck.naturesaura.items.ModItems; @@ -13,6 +13,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -40,11 +41,11 @@ public class RenderEffectInhibitor extends EntityRenderer var time = entity.renderTicks + entity.getId() + partialTicks; var bob = (float) Math.sin(time / 10F) * 0.05F; matrixStackIn.translate(0, 0.15F + bob, 0); - matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(time * 3 % 360)); + matrixStackIn.mulPose(Axis.YP.rotationDegrees(time * 3 % 360)); var effect = entity.getInhibitedEffect(); var stack = this.items.computeIfAbsent(effect, res -> ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect)); - Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn, 0); + Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLightIn, OverlayTexture.NO_OVERLAY, matrixStackIn, bufferIn, entity.level(), 0); matrixStackIn.popPose(); } } 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 5034438e..1080a18f 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderMoverMinecart.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.entities.render; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import net.minecraft.client.model.Model; @@ -35,7 +35,7 @@ public class RenderMoverMinecart extends MinecartRenderer { matrixStackIn.pushPose(); matrixStackIn.translate(0, 22 / 16F, 0); matrixStackIn.translate(0, 0, 1); - matrixStackIn.mulPose(Vector3f.XP.rotationDegrees(180)); + 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); matrixStackIn.popPose(); } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 0301409c..cff9077b 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -2,7 +2,10 @@ package de.ellpeck.naturesaura.events; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; +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 de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; @@ -18,8 +21,8 @@ import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.packet.PacketAuraChunk; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.ChatScreen; -import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.BiomeColors; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.resources.language.I18n; @@ -197,7 +200,7 @@ public class ClientEvents { // 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) { - if (pos.equals(new BlockPos(playerEye.add(playerView.scale(d))))) { + if (pos.equals(BlockPos.containing(playerEye.add(playerView.scale(d))))) { ClientEvents.hoveringAuraSpot = pos; break; } @@ -250,7 +253,8 @@ public class ClientEvents { @SubscribeEvent public void onOverlayRender(RenderGuiOverlayEvent.Post event) { var mc = Minecraft.getInstance(); - var stack = event.getPoseStack(); + var graphics = event.getGuiGraphics(); + var stack = graphics.pose(); if (event.getOverlay() == VanillaGuiOverlay.HOTBAR.type()) { var res = event.getWindow(); if (mc.player != null) { @@ -266,17 +270,16 @@ public class ClientEvents { var color = container.getAuraColor(); RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); if (width < 80) - Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) - Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x, y, 0, 6, width, 6, 256, 256); var scale = 0.75F; stack.pushPose(); stack.scale(scale, scale, scale); var s = ClientEvents.heldCache.getHoverName().getString(); - mc.font.drawShadow(stack, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color); + graphics.drawString(mc.font, s, conf == 1 ? x / scale : (x + 80) / scale - mc.font.width(s), (y - 7) / scale, color, true); stack.popPose(); RenderSystem.setShaderColor(1F, 1F, 1F, 1); @@ -285,7 +288,6 @@ public class ClientEvents { if (!ClientEvents.heldEye.isEmpty() || !ClientEvents.heldOcular.isEmpty()) { stack.pushPose(); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); int conf = ModConfig.instance.auraBarLocation.get(); if (!mc.options.renderDebug && (conf != 2 || !(mc.screen instanceof ChatScreen))) { @@ -306,33 +308,33 @@ public class ClientEvents { var tHeight = Mth.ceil(Mth.clamp(totalPercentage, 0F, 1F) * 50); var y = !ClientEvents.heldOcular.isEmpty() && totalPercentage > 1F ? startY + 26 : startY; if (tHeight < 50) - Screen.blit(stack, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, y, 6, 12, 6, 50 - tHeight, 256, 256); if (tHeight > 0) - Screen.blit(stack, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, y + 50 - tHeight, 0, 12 + 50 - tHeight, 6, tHeight, 256, 256); if (!ClientEvents.heldOcular.isEmpty()) { var topHeight = Mth.ceil(Mth.clamp((totalPercentage - 1F) * 2F, 0F, 1F) * 25); if (topHeight > 0) { if (topHeight < 25) - Screen.blit(stack, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256); - Screen.blit(stack, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, startY, 18, 12, 6, 25 - topHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, startY + 25 - topHeight, 12, 12 + 25 - topHeight, 6, topHeight, 256, 256); } var bottomHeight = Mth.floor(Mth.clamp((totalPercentage + 1F) * 2F - 1F, 0F, 1F) * 25); if (bottomHeight < 25) { - Screen.blit(stack, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, startY + 51, 18, 12, 6, 25 - bottomHeight, 256, 256); if (bottomHeight > 0) - Screen.blit(stack, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, startX, startY + 51 + 25 - bottomHeight, 12, 12 + 25 - bottomHeight, 6, bottomHeight, 256, 256); } } if (totalPercentage > (ClientEvents.heldOcular.isEmpty() ? 1F : 1.5F)) - mc.font.drawShadow(stack, "+", startX + plusOffX, startY - 0.5F, color); + graphics.drawString(mc.font, "+", startX + plusOffX, startY - 0.5F, color, true); if (totalPercentage < (ClientEvents.heldOcular.isEmpty() ? 0F : -0.5F)) - mc.font.drawShadow(stack, "-", startX + plusOffX, startY - 0.5F + (ClientEvents.heldOcular.isEmpty() ? 44 : 70), color); + graphics.drawString(mc.font, "-", startX + plusOffX, startY - 0.5F + (ClientEvents.heldOcular.isEmpty() ? 44 : 70), color, true); stack.pushPose(); stack.scale(textScale, textScale, textScale); - mc.font.drawShadow(stack, text, textX / textScale, textY / textScale, color); + graphics.drawString(mc.font, text, textX / textScale, textY / textScale, color, true); stack.popPose(); if (!ClientEvents.heldOcular.isEmpty()) { @@ -342,11 +344,10 @@ public class ClientEvents { var stackY = conf < 2 ? 10 : res.getGuiScaledHeight() - 60; for (var effect : ClientEvents.SHOWING_EFFECTS.values()) { var itemStack = effect.getA(); - Helper.renderItemInGui(itemStack, stackX, stackY, 1F); + Helper.renderItemInGui(graphics, itemStack, stackX, stackY, 1F); if (effect.getB()) { RenderSystem.disableDepthTest(); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); - Screen.blit(stack, stackX, stackY, 240, 0, 16, 16, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, stackX, stackY, 240, 0, 16, 16, 256, 256); RenderSystem.enableDepthTest(); } stackY += 12; @@ -365,7 +366,7 @@ public class ClientEvents { if (tile != null && (container = tile.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null)) != null) { var state = mc.level.getBlockState(pos); var blockStack = state.getBlock().getCloneItemStack(state, blockHitResult, mc.level, pos, mc.player); - this.drawContainerInfo(stack, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), + this.drawContainerInfo(graphics, container.getStoredAura(), container.getMaxAura(), container.getAuraColor(), mc, res, 35, blockStack.getHoverName().getString(), null); if (tile instanceof BlockEntityNatureAltar) { @@ -373,46 +374,44 @@ public class ClientEvents { if (!tileStack.isEmpty()) { var stackCont = tileStack.getCapability(NaturesAuraAPI.CAP_AURA_CONTAINER, null).orElse(null); if (stackCont != null) { - this.drawContainerInfo(stack, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), + this.drawContainerInfo(graphics, stackCont.getStoredAura(), stackCont.getMaxAura(), stackCont.getAuraColor(), mc, res, 55, tileStack.getHoverName().getString(), null); } } } } else if (tile instanceof BlockEntityRFConverter) { EnergyStorage storage = ((BlockEntityRFConverter) tile).storage; - this.drawContainerInfo(stack, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, + this.drawContainerInfo(graphics, storage.getEnergyStored(), storage.getMaxEnergyStored(), 0xcc4916, mc, res, 35, I18n.get("block.naturesaura.rf_converter"), storage.getEnergyStored() + " / " + storage.getMaxEnergyStored() + " RF"); } else if (tile instanceof BlockEntityGratedChute chute) { var itemStack = chute.getItemHandler().getStackInSlot(0); if (itemStack.isEmpty()) { - mc.font.drawShadow(stack, + graphics.drawString(mc.font, ChatFormatting.GRAY.toString() + ChatFormatting.ITALIC + I18n.get("info.naturesaura.empty"), x + 5, y - 11, 0xFFFFFF); } else { - Helper.renderItemInGui(itemStack, x + 2, y - 18, 1F); + Helper.renderItemInGui(graphics, itemStack, x + 2, y - 18, 1F); } - Helper.renderItemInGui(ClientEvents.ITEM_FRAME, x - 24, y - 24, 1F); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); + Helper.renderItemInGui(graphics, ClientEvents.ITEM_FRAME, x - 24, y - 24, 1F); var u = chute.isBlacklist ? 240 : 224; RenderSystem.disableDepthTest(); - Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x - 18, y - 18, u, 0, 16, 16, 256, 256); RenderSystem.enableDepthTest(); } else if (tile instanceof BlockEntityItemDistributor distributor) { - Helper.renderItemInGui(ClientEvents.DISPENSER, x - 24, y - 24, 1F); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); + Helper.renderItemInGui(graphics, ClientEvents.DISPENSER, x - 24, y - 24, 1F); var u = !distributor.isRandomMode ? 240 : 224; RenderSystem.disableDepthTest(); - Screen.blit(stack, x - 18, y - 18, u, 0, 16, 16, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x - 18, y - 18, u, 0, 16, 16, 256, 256); RenderSystem.enableDepthTest(); } else if (tile instanceof BlockEntityAuraTimer timer) { var itemStack = timer.getItemHandler().getStackInSlot(0); if (!itemStack.isEmpty()) { - Helper.renderItemInGui(itemStack, x - 20, y - 20, 1); - mc.font.drawShadow(stack, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF); - mc.font.drawShadow(stack, ChatFormatting.GRAY + I18n.get("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF); + Helper.renderItemInGui(graphics, itemStack, x - 20, y - 20, 1); + graphics.drawString(mc.font, ChatFormatting.GRAY + this.createTimeString(timer.getTotalTime()), x + 5, y - 11, 0xFFFFFF); + graphics.drawString(mc.font, ChatFormatting.GRAY + I18n.get("info.naturesaura.remaining", this.createTimeString(timer.getTimeLeft())), x + 5, y + 3, 0xFFFFFF); } } } @@ -426,10 +425,10 @@ public class ClientEvents { var format = NumberFormat.getInstance(); var spot = IAuraChunk.getAuraChunk(mc.level, ClientEvents.hoveringAuraSpot).getActualDrainSpot(ClientEvents.hoveringAuraSpot, false); var color = spot.intValue() > 0 ? ChatFormatting.GREEN : ChatFormatting.RED; - mc.font.drawShadow(stack, "Pos: " + spot.pos.toShortString(), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 20, 0xFFFFFF); - mc.font.drawShadow(stack, "Amount: " + color + format.format(spot.intValue()), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 10, 0xFFFFFF); + graphics.drawString(mc.font, "Pos: " + spot.pos.toShortString(), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 20, 0xFFFFFF, true); + graphics.drawString(mc.font, "Amount: " + color + format.format(spot.intValue()), res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F - 10, 0xFFFFFF, true); if (spot.originalSpreadPos != null) - mc.font.drawShadow(stack, "Dist from Original: " + (int) Math.sqrt(spot.pos.distSqr(spot.originalSpreadPos)) + " (" + spot.originalSpreadPos.toShortString() + ")", res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F, 0xFFFFFF); + graphics.drawString(mc.font, "Dist from Original: " + (int) Math.sqrt(spot.pos.distSqr(spot.originalSpreadPos)) + " (" + spot.originalSpreadPos.toShortString() + ")", res.getGuiScaledWidth() / 2F + 5, res.getGuiScaledHeight() / 2F, 0xFFFFFF, true); } } } @@ -443,22 +442,21 @@ public class ClientEvents { return String.format("%02d:%02d:%02d.%02d", hours, minutes, seconds, ticks); } - private void drawContainerInfo(PoseStack stack, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) { + private void drawContainerInfo(GuiGraphics graphics, int stored, int max, int color, Minecraft mc, Window res, int yOffset, String name, String textBelow) { RenderSystem.setShaderColor((color >> 16 & 255) / 255F, (color >> 8 & 255) / 255F, (color & 255) / 255F, 1); var x = res.getGuiScaledWidth() / 2 - 40; var y = res.getGuiScaledHeight() / 2 + yOffset; var width = Mth.ceil(stored / (float) max * 80); - RenderSystem.setShaderTexture(0, ClientEvents.OVERLAYS); if (width < 80) - Screen.blit(stack, x + width, y, width, 0, 80 - width, 6, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x + width, y, width, 0, 80 - width, 6, 256, 256); if (width > 0) - Screen.blit(stack, x, y, 0, 6, width, 6, 256, 256); + graphics.blit(ClientEvents.OVERLAYS, x, y, 0, 6, width, 6, 256, 256); - mc.font.drawShadow(stack, name, x + 40 - mc.font.width(name) / 2F, y - 9, color); + graphics.drawString(mc.font, name, x + 40 - mc.font.width(name) / 2F, y - 9, color, true); if (textBelow != null) - mc.font.drawShadow(stack, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color); + graphics.drawString(mc.font, textBelow, x + 40 - mc.font.width(textBelow) / 2F, y + 7, color, true); } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index e95add0c..9f0256bc 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -65,13 +65,13 @@ public class CommonEvents { @SubscribeEvent public void onItemUse(PlayerInteractEvent.RightClickBlock event) { var player = event.getEntity(); - if (player.level.isClientSide) + if (player.level().isClientSide) return; var held = event.getItemStack(); if (!held.isEmpty() && ForgeRegistries.ITEMS.getKey(held.getItem()).getPath().contains("chisel")) { - var state = player.level.getBlockState(event.getPos()); + var state = player.level().getBlockState(event.getPos()); if (NaturesAuraAPI.BOTANIST_PICKAXE_CONVERSIONS.containsKey(state)) { - var data = (LevelData) ILevelData.getLevelData(player.level); + var data = (LevelData) ILevelData.getLevelData(player.level()); data.addMossStone(event.getPos()); } } @@ -104,16 +104,16 @@ public class CommonEvents { @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { - if (!event.player.level.isClientSide && event.phase == TickEvent.Phase.END) { - if (event.player.level.getGameTime() % 10 == 0) { + 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)); } - if (event.player.level.getGameTime() % 200 != 0) + if (event.player.level().getGameTime() % 200 != 0) return; - var aura = IAuraChunk.triangulateAuraInArea(event.player.level, event.player.blockPosition(), 25); + var aura = IAuraChunk.triangulateAuraInArea(event.player.level(), event.player.blockPosition(), 25); if (aura <= 0) Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); else if (aura >= 1500000) @@ -127,7 +127,7 @@ public class CommonEvents { } private boolean handleChunkWatchDeferred(Player player, ChunkPos pos) { - var chunk = Helper.getLoadedChunk(player.level, pos.x, pos.z); + var chunk = Helper.getLoadedChunk(player.level(), pos.x, pos.z); if (!(chunk instanceof LevelChunk levelChunk)) return false; var auraChunk = (AuraChunk) levelChunk.getCapability(NaturesAuraAPI.CAP_AURA_CHUNK, null).orElse(null); diff --git a/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java b/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java index 99c6a5d9..12de4891 100644 --- a/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java +++ b/src/main/java/de/ellpeck/naturesaura/gen/LevelGenAncientTree.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.gen; import com.mojang.serialization.Codec; import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; @@ -14,9 +15,9 @@ import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext; import net.minecraft.world.level.levelgen.feature.TreeFeature; import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -import net.minecraft.world.level.material.Material; import static net.minecraft.core.Direction.Axis; +import static net.minecraft.world.level.block.state.BlockBehaviour.BlockStateBase; public class LevelGenAncientTree extends Feature { @@ -41,8 +42,8 @@ public class LevelGenAncientTree extends Feature { var x = (float) Math.sin(angle) * length; var z = (float) Math.cos(angle) * length; - var goal = pos.offset(x, 0, z); - while (level.isStateAtPosition(goal, state -> state.getMaterial().isReplaceable())) { + var goal = pos.offset(Mth.floor(x), 0, Mth.floor(z)); + while (level.isStateAtPosition(goal, BlockStateBase::canBeReplaced)) { goal = goal.below(); if (goal.distSqr(pos) >= 10 * 10) break; @@ -71,7 +72,7 @@ public class LevelGenAncientTree extends Feature { var x = (float) Math.sin(angle) * length; var z = (float) Math.cos(angle) * length; - var goal = trunkTop.offset(x, rand.nextInt(3) + 1, z); + var goal = trunkTop.offset(Mth.floor(x), rand.nextInt(3) + 1, Mth.floor(z)); this.makeBranch(level, trunkTop, goal, ModBlocks.ANCIENT_LOG.defaultBlockState(), true); this.makeLeaves(level, goal, ModBlocks.ANCIENT_LEAVES.defaultBlockState(), rand.nextInt(2) + 2, rand); } @@ -87,7 +88,7 @@ public class LevelGenAncientTree extends Feature { var stepZ = (float) pos.getZ() / (float) length; for (var i = 0; i <= length; i++) { - var goal = first.offset(0.5F + i * stepX, 0.5F + i * stepY, 0.5F + i * stepZ); + var goal = first.offset(Mth.floor(0.5F + i * stepX), Mth.floor(0.5F + i * stepY), Mth.floor(0.5F + i * stepZ)); if (!level.isStateAtPosition(goal, s -> !TreeFeature.validTreePos(level, goal))) { if (hasAxis) { var axis = this.getLogAxis(first, goal); @@ -105,8 +106,8 @@ public class LevelGenAncientTree extends Feature { for (var z = -radius; z <= radius; z++) { var goal = pos.offset(x, y, z); if (pos.distSqr(goal) <= radius * radius + rand.nextInt(3) - 1) { - if (!level.isStateAtPosition(goal, s -> s.getMaterial() == Material.LEAVES)) { - if (level.isStateAtPosition(goal, st -> st.getMaterial() != Material.WOOD && st.getBlock() != Blocks.DIRT && st.getBlock() != Blocks.GRASS)) + if (!level.isStateAtPosition(goal, s -> s.is(BlockTags.LEAVES))) { + if (level.isStateAtPosition(goal, st -> !st.is(BlockTags.LOGS) && st.getBlock() != Blocks.DIRT && st.getBlock() != Blocks.GRASS)) this.setBlock(level, goal, state); } } diff --git a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java index 2ab9bea5..10bf0588 100644 --- a/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java +++ b/src/main/java/de/ellpeck/naturesaura/gui/GuiEnderCrate.java @@ -1,9 +1,7 @@ package de.ellpeck.naturesaura.gui; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; -import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; @@ -21,25 +19,23 @@ public class GuiEnderCrate extends AbstractContainerScreen } @Override - public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { - this.renderBackground(matrixStack); - super.render(matrixStack, mouseX, mouseY, partialTicks); - this.renderTooltip(matrixStack, mouseX, mouseY); + public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(graphics); + super.render(graphics, mouseX, mouseY, partialTicks); + this.renderTooltip(graphics, mouseX, mouseY); } @Override - protected void renderLabels(PoseStack matrixStack, int mouseX, int mouseY) { - this.font.draw(matrixStack, this.title.getString(), 8, 6, 4210752); - this.font.draw(matrixStack, this.playerInventoryTitle, 8, this.imageHeight - 96 + 2, 4210752); + protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) { + graphics.drawString(this.font, this.title.getString(), 8, 6, 4210752); + graphics.drawString(this.font, this.playerInventoryTitle, 8, this.imageHeight - 96 + 2, 4210752); } @Override - protected void renderBg(PoseStack matrixStack, float partialTicks, int mouseX, int mouseY) { - RenderSystem.setShader(GameRenderer::getPositionTexShader); - RenderSystem.setShaderTexture(0, GuiEnderCrate.CHEST_GUI_TEXTURE); + protected void renderBg(GuiGraphics graphics, float partialTicks, int mouseX, int mouseY) { var i = (this.width - this.imageWidth) / 2; var j = (this.height - this.imageHeight) / 2; - this.blit(matrixStack, i, j, 0, 0, this.imageWidth, 3 * 18 + 17); - this.blit(matrixStack, i, j + 3 * 18 + 17, 0, 126, this.imageWidth, 96); + graphics.blit(GuiEnderCrate.CHEST_GUI_TEXTURE, i, j, 0, 0, this.imageWidth, 3 * 18 + 17); + graphics.blit(GuiEnderCrate.CHEST_GUI_TEXTURE, i, j + 3 * 18 + 17, 0, 126, this.imageWidth, 96); } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index 7c28323b..d6699eec 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -52,7 +52,8 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu }); } - @Override + // TODO aura bottle creative +/* @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { if (this.allowedIn(tab)) { for (var type : NaturesAuraAPI.AURA_TYPES.values()) { @@ -61,7 +62,7 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu items.add(stack); } } - } + }*/ @Override public Component getName(ItemStack stack) { @@ -116,19 +117,19 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem, ICu if (held.isEmpty() || held.getItem() != ModItems.BOTTLE_TWO_THE_REBOTTLING) return; var player = event.getEntity(); - HitResult ray = Item.getPlayerPOVHitResult(player.level, player, ClipContext.Fluid.NONE); + HitResult ray = Item.getPlayerPOVHitResult(player.level(), player, ClipContext.Fluid.NONE); if (ray.getType() == HitResult.Type.BLOCK) return; - var bottle = ItemAuraBottle.create(player.level, player.blockPosition()); + var bottle = ItemAuraBottle.create(player.level(), player.blockPosition()); if (bottle.isEmpty()) return; - if (!player.level.isClientSide) { + if (!player.level().isClientSide) { held.shrink(1); if (!player.addItem(bottle)) - player.level.addFreshEntity(new ItemEntity(player.level, player.getX(), player.getY(), player.getZ(), bottle)); + player.level().addFreshEntity(new ItemEntity(player.level(), player.getX(), player.getY(), player.getZ(), bottle)); - player.level.playSound(null, player.getX(), player.getY(), player.getZ(), + player.level().playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_FILL_DRAGONBREATH, SoundSource.PLAYERS, 1F, 1F); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index 13e68a6d..c204f5cf 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.items; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer; @@ -9,15 +9,13 @@ import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.enchant.ModEnchantments; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.core.Direction; -import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; @@ -63,7 +61,8 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { } } - @Override + // TODO creative tabs for items with variations + /* @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { if (this.allowedIn(tab)) { items.add(new ItemStack(this)); @@ -74,7 +73,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { items.add(stack); }); } - } + }*/ @Override public boolean isBarVisible(ItemStack stack) { @@ -122,8 +121,8 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { var legs = !player.getInventory().armor.get(EquipmentSlot.LEGS.getIndex()).isEmpty(); matrices.translate(-0.15F, 0.65F, chest ? -0.195F : legs ? -0.165F : -0.1475F); matrices.scale(0.5F, 0.5F, 0.5F); - matrices.mulPose(Vector3f.XP.rotationDegrees(180F)); - Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0); + matrices.mulPose(Axis.XP.rotationDegrees(180F)); + Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, player.level(), 0); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java b/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java index 0e1a507f..fddae081 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemBirthSpirit.java @@ -20,18 +20,18 @@ public class ItemBirthSpirit extends ItemGlowing { @SubscribeEvent public void onBabyBorn(BabyEntitySpawnEvent event) { LivingEntity parent = event.getParentA(); - if (!parent.level.isClientSide && event.getCausedByPlayer() != null) { + if (!parent.level().isClientSide && event.getCausedByPlayer() != null) { var pos = parent.blockPosition(); - var aura = IAuraChunk.getAuraInArea(parent.level, pos, 30); + var aura = IAuraChunk.getAuraInArea(parent.level(), pos, 30); if (aura < 1200000) return; - var amount = parent.level.random.nextInt(3) + 1; - var item = new ItemEntity(parent.level, parent.getX(), parent.getY(), parent.getZ(), new ItemStack(ModItems.BIRTH_SPIRIT, amount)); - parent.level.addFreshEntity(item); + var amount = parent.level().random.nextInt(3) + 1; + var item = new ItemEntity(parent.level(), parent.getX(), parent.getY(), parent.getZ(), new ItemStack(ModItems.BIRTH_SPIRIT, amount)); + parent.level().addFreshEntity(item); - var spot = IAuraChunk.getHighestSpot(parent.level, pos, 30, pos); - IAuraChunk.getAuraChunk(parent.level, spot).drainAura(spot, 800 * amount); + var spot = IAuraChunk.getHighestSpot(parent.level(), pos, 30, pos); + IAuraChunk.getAuraChunk(parent.level(), spot).drainAura(spot, 800 * amount); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java index c712377c..74493231 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemCaveFinder.java @@ -42,7 +42,7 @@ public class ItemCaveFinder extends ItemImpl { var offUp = offset.above(); var stateUp = levelIn.getBlockState(offUp); - if (stateUp.isCollisionShapeFullBlock(levelIn, offUp) || stateUp.getMaterial().isLiquid()) + if (stateUp.isCollisionShapeFullBlock(levelIn, offUp) || stateUp.liquid()) continue; var sky = levelIn.getBrightness(LightLayer.SKY, offUp); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java b/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java index 3cdcf769..53ef7312 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemDeathRing.java @@ -23,7 +23,7 @@ public class ItemDeathRing extends ItemImpl { @SubscribeEvent public void onDeath(LivingDeathEvent event) { var entity = event.getEntity(); - if (!entity.level.isClientSide && entity instanceof Player) { + if (!entity.level().isClientSide && entity instanceof Player) { var equipped = Helper.getEquippedItem(s -> s.getItem() == ModItems.DEATH_RING, (Player) entity); if (!equipped.isEmpty()) { entity.setHealth(entity.getMaxHealth() / 2); @@ -32,7 +32,7 @@ public class ItemDeathRing extends ItemImpl { var data = new CompoundTag(); data.putInt("id", entity.getId()); - PacketHandler.sendToAllAround(entity.level, entity.blockPosition(), 32, new PacketClient(1, data)); + PacketHandler.sendToAllAround(entity.level(), entity.blockPosition(), 32, new PacketClient(1, data)); equipped.shrink(1); event.setCanceled(true); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java index 4e07359b..3db7fb13 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEffectPowder.java @@ -46,7 +46,8 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { return InteractionResult.SUCCESS; } - @Override + // TODO effect powder creative tab + /* @Override public void fillItemCategory(CreativeModeTab tab, NonNullList items) { if (this.allowedIn(tab)) { for (var effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) { @@ -55,7 +56,7 @@ public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem { items.add(stack); } } - } + }*/ @Override public Component getName(ItemStack stack) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java index c0d5e539..9b0de9d8 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEnderAccess.java @@ -51,7 +51,7 @@ public class ItemEnderAccess extends ItemImpl { @Nullable @Override public AbstractContainerMenu createMenu(int windowId, Inventory inv, Player player) { - IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(name); + IItemHandler handler = ILevelData.getOverworldData(inv.player.level()).getEnderStorage(name); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, player, handler); } }, buffer -> buffer.writeUtf(name)); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java b/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java index 1f376732..d13ffbbe 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemEye.java @@ -1,14 +1,14 @@ package de.ellpeck.naturesaura.items; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.api.render.ITrinketItem; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -26,8 +26,8 @@ public class ItemEye extends ItemImpl implements ITrinketItem { var armor = !player.getInventory().armor.get(EquipmentSlot.CHEST.getIndex()).isEmpty(); matrices.translate(0.1F, 0.225F, armor ? -0.195F : -0.1475F); matrices.scale(0.3F, 0.3F, 0.3F); - matrices.mulPose(Vector3f.XP.rotationDegrees(180)); - Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0); + matrices.mulPose(Axis.XP.rotationDegrees(180)); + Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, player.level(), 0); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java index 477aba8e..95729d3b 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemImpl.java @@ -14,7 +14,7 @@ public class ItemImpl extends Item implements IModItem { } public ItemImpl(String baseName, Item.Properties properties) { - super(properties.tab(NaturesAura.CREATIVE_TAB)); + super(properties); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java index 33c29aaa..7a605a44 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemPetReviver.java @@ -33,19 +33,19 @@ public class ItemPetReviver extends ItemImpl { @SubscribeEvent public void onEntityTick(LivingEvent.LivingTickEvent event) { var entity = event.getEntity(); - if (entity.level.isClientSide || entity.level.getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable)) + if (entity.level().isClientSide || entity.level().getGameTime() % 20 != 0 || !(entity instanceof TamableAnimal tameable)) return; if (!tameable.isTame() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver")) return; var owner = tameable.getOwner(); if (owner == null || owner.distanceToSqr(tameable) > 5 * 5) return; - if (entity.level.random.nextFloat() >= 0.65F) { - ((ServerLevel) entity.level).sendParticles(ParticleTypes.HEART, - entity.getX() + entity.level.random.nextGaussian() * 0.25F, - entity.getEyeY() + entity.level.random.nextGaussian() * 0.25F, - entity.getZ() + entity.level.random.nextGaussian() * 0.25F, - entity.level.random.nextInt(2) + 1, 0, 0, 0, 0); + if (entity.level().random.nextFloat() >= 0.65F) { + ((ServerLevel) entity.level()).sendParticles(ParticleTypes.HEART, + entity.getX() + entity.level().random.nextGaussian() * 0.25F, + entity.getEyeY() + entity.level().random.nextGaussian() * 0.25F, + entity.getZ() + entity.level().random.nextGaussian() * 0.25F, + entity.level().random.nextInt(2) + 1, 0, 0, 0, 0); } } @@ -61,7 +61,7 @@ public class ItemPetReviver extends ItemImpl { if (stack.getItem() != ModItems.PET_REVIVER) return; target.getPersistentData().putBoolean(NaturesAura.MOD_ID + ":pet_reviver", true); - if (!target.level.isClientSide) + if (!target.level().isClientSide) stack.shrink(1); event.setCancellationResult(InteractionResult.SUCCESS); event.setCanceled(true); @@ -71,13 +71,13 @@ public class ItemPetReviver extends ItemImpl { @SubscribeEvent(priority = EventPriority.LOWEST) public void onLivingDeath(LivingDeathEvent event) { var entity = event.getEntity(); - if (entity.level.isClientSide || !(entity instanceof TamableAnimal tameable)) + if (entity.level().isClientSide || !(entity instanceof TamableAnimal tameable)) return; if (!tameable.isTame() || !tameable.getPersistentData().getBoolean(NaturesAura.MOD_ID + ":pet_reviver")) return; // get the overworld, and the overworld's spawn point, by default - var spawnLevel = tameable.level.getServer().overworld(); + var spawnLevel = tameable.level().getServer().overworld(); var spawn = Vec3.atBottomCenterOf(spawnLevel.getSharedSpawnPos()); // check if the owner is online, and respawn at the bed if they are @@ -87,18 +87,18 @@ public class ItemPetReviver extends ItemImpl { if (pos != null) { var f = player.getRespawnAngle(); var b = player.isRespawnForced(); - var bed = Player.findRespawnPositionAndUseSpawnBlock((ServerLevel) player.level, pos, f, b, false); + var bed = Player.findRespawnPositionAndUseSpawnBlock((ServerLevel) player.level(), pos, f, b, false); if (bed.isPresent()) { - spawnLevel = (ServerLevel) player.level; + spawnLevel = (ServerLevel) player.level(); spawn = bed.get(); } } } - PacketHandler.sendToAllAround(tameable.level, tameable.blockPosition(), 32, new PacketParticles((float) tameable.getX(), (float) tameable.getEyeY(), (float) tameable.getZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d)); + PacketHandler.sendToAllAround(tameable.level(), tameable.blockPosition(), 32, new PacketParticles((float) tameable.getX(), (float) tameable.getEyeY(), (float) tameable.getZ(), PacketParticles.Type.PET_REVIVER, 0xc2461d)); var spawnedPet = tameable; - if (tameable.level != spawnLevel) { + if (tameable.level() != spawnLevel) { tameable.remove(Entity.RemovalReason.DISCARDED); spawnedPet = (TamableAnimal) tameable.getType().create(spawnLevel); } @@ -114,7 +114,7 @@ public class ItemPetReviver extends ItemImpl { spawnedPet.setInSittingPose(true); spawnedPet.setJumping(false); spawnedPet.setTarget(null); - if (tameable.level != spawnLevel) { + if (tameable.level() != spawnLevel) { spawnLevel.addFreshEntity(spawnedPet); tameable.remove(Entity.RemovalReason.DISCARDED); } @@ -123,7 +123,7 @@ public class ItemPetReviver extends ItemImpl { var auraPos = IAuraChunk.getHighestSpot(spawnLevel, spawnedPet.blockPosition(), 35, spawnedPet.blockPosition()); IAuraChunk.getAuraChunk(spawnLevel, auraPos).drainAura(auraPos, 200000); - PacketHandler.sendToAllAround(spawnedPet.level, spawnedPet.blockPosition(), 32, new PacketParticles((float) spawnedPet.getX(), (float) spawnedPet.getEyeY(), (float) spawnedPet.getZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); + PacketHandler.sendToAllAround(spawnedPet.level(), spawnedPet.blockPosition(), 32, new PacketParticles((float) spawnedPet.getX(), (float) spawnedPet.getEyeY(), (float) spawnedPet.getZ(), PacketParticles.Type.PET_REVIVER, 0x4dba2f)); if (owner instanceof Player) owner.sendSystemMessage(Component.translatable("info." + NaturesAura.MOD_ID + ".pet_reviver", spawnedPet.getDisplayName()).withStyle(ChatFormatting.ITALIC, ChatFormatting.GRAY)); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java index 9cfa8961..ff22dfd1 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemRangeVisualizer.java @@ -83,8 +83,8 @@ public class ItemRangeVisualizer extends ItemImpl { return; var entity = event.getTarget(); if (entity instanceof IVisualizable) { - if (entity.level.isClientSide) { - var dim = entity.level.dimension().location(); + if (entity.level().isClientSide) { + var dim = entity.level().dimension().location(); ItemRangeVisualizer.visualize(event.getEntity(), ItemRangeVisualizer.VISUALIZED_ENTITIES, dim, entity); } event.getEntity().swing(event.getHand()); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java index 1fa3edf0..f10b6691 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.items; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +import com.mojang.math.Axis; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.render.ITrinketItem; import de.ellpeck.naturesaura.items.tools.ItemArmor; @@ -10,7 +10,6 @@ import de.ellpeck.naturesaura.packet.PacketParticles; import de.ellpeck.naturesaura.reg.ModArmorMaterial; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; -import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.sounds.SoundSource; import net.minecraft.world.damagesource.DamageSource; @@ -20,9 +19,9 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.AABB; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -37,7 +36,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { public void inventoryTick(ItemStack stack, Level levelIn, Entity entityIn, int itemSlot, boolean isSelected) { if (levelIn.isClientSide || !(entityIn instanceof LivingEntity living)) return; - if (!living.isOnGround()) { + if (!living.onGround()) { var compound = stack.getOrCreateTag(); if (compound.getBoolean("air")) return; @@ -62,13 +61,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 1000, false)) return; - DamageSource source; - if (living instanceof Player) - source = DamageSource.playerAttack((Player) living); - else - source = DamageSource.MAGIC; var infusedSet = ItemArmor.isFullSetEquipped(living, ModArmorMaterial.INFUSED); - var range = 5; var mobs = levelIn.getEntitiesOfClass(LivingEntity.class, new AABB( living.getX() - range, living.getY() - 0.5, living.getZ() - range, @@ -80,6 +73,12 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { continue; if (living instanceof Player && !NaturesAuraAPI.instance().extractAuraFromPlayer((Player) living, 500, false)) break; + + DamageSource source; + if (living instanceof Player) + source = mob.damageSources().playerAttack((Player) living); + else + source = mob.damageSources().magic(); mob.hurt(source, 4F); if (infusedSet) @@ -90,7 +89,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { var down = pos.below(); var downState = levelIn.getBlockState(down); - if (downState.getMaterial() != Material.AIR) { + if (!downState.isAir()) { var type = downState.getBlock().getSoundType(downState, levelIn, down, null); levelIn.playSound(null, pos, type.getBreakSound(), SoundSource.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F); } @@ -106,8 +105,8 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { var armor = !player.getInventory().armor.get(EquipmentSlot.CHEST.getIndex()).isEmpty(); matrices.translate(0, 0.125F, armor ? -0.195F : -0.1475F); matrices.scale(0.3F, 0.3F, 0.3F); - matrices.mulPose(Vector3f.XP.rotationDegrees(180)); - Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemTransforms.TransformType.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, 0); + matrices.mulPose(Axis.XP.rotationDegrees(180)); + Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, packedLight, OverlayTexture.NO_OVERLAY, matrices, buffer, player.level(), 0); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java index 68f9be0c..1c83dcd7 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemStructureFinder.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.entities.EntityStructureFinder; import de.ellpeck.naturesaura.entities.ModEntities; import net.minecraft.core.HolderSet; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; @@ -31,7 +31,7 @@ public class ItemStructureFinder extends ItemImpl { public InteractionResultHolder use(Level levelIn, Player playerIn, InteractionHand handIn) { var stack = playerIn.getItemInHand(handIn); if (!levelIn.isClientSide && ((ServerLevel) levelIn).structureManager().shouldGenerateStructures()) { - var registry = levelIn.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY); + var registry = levelIn.registryAccess().registryOrThrow(Registries.STRUCTURE); var holderSet = registry.getHolder(this.structure).map(HolderSet::direct).orElse(null); if (holderSet != null) { var pos = ((ServerLevel) levelIn).getChunkSource().getGenerator().findNearestMapStructure((ServerLevel) levelIn, holderSet, playerIn.blockPosition(), this.radius, false); 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 b7546dc8..7c87dae6 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemArmor.java @@ -35,8 +35,8 @@ public class ItemArmor extends ArmorItem implements IModItem { private static final Map SETS = new ConcurrentHashMap<>(); private final String baseName; - public ItemArmor(String baseName, ArmorMaterial materialIn, EquipmentSlot equipmentSlotIn) { - super(materialIn, equipmentSlotIn, new Properties().tab(NaturesAura.CREATIVE_TAB)); + public ItemArmor(String baseName, ArmorMaterial materialIn, ArmorItem.Type equipmentSlotIn) { + super(materialIn, equipmentSlotIn, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -44,7 +44,7 @@ public class ItemArmor extends ArmorItem implements IModItem { public static boolean isFullSetEquipped(LivingEntity entity, ArmorMaterial material) { var set = ItemArmor.SETS.computeIfAbsent(material, m -> ForgeRegistries.ITEMS.getValues().stream() .filter(i -> i instanceof ItemArmor && ((ItemArmor) i).getMaterial() == material) - .sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getSlot().ordinal())) + .sorted(Comparator.comparingInt(i -> ((ItemArmor) i).getEquipmentSlot().ordinal())) .toArray(Item[]::new)); for (var i = 0; i < 4; i++) { var slot = EquipmentSlot.values()[i + 2]; @@ -72,13 +72,13 @@ public class ItemArmor extends ArmorItem implements IModItem { @SubscribeEvent public static void onAttack(LivingAttackEvent event) { var entity = event.getEntity(); - if (!entity.level.isClientSide) { + if (!entity.level().isClientSide) { if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) { var source = event.getSource().getEntity(); if (source instanceof LivingEntity) ((LivingEntity) source).addEffect(new MobEffectInstance(MobEffects.WITHER, 40)); } else if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.DEPTH)) { - for (var other : entity.level.getEntitiesOfClass(LivingEntity.class, new AABB(entity.position(), Vec3.ZERO).inflate(2))) { + for (var other : entity.level().getEntitiesOfClass(LivingEntity.class, new AABB(entity.position(), Vec3.ZERO).inflate(2))) { if (other != entity && (!(other instanceof Player otherPlayer) || !otherPlayer.isAlliedTo(entity))) other.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 255)); } @@ -97,13 +97,13 @@ public class ItemArmor extends ArmorItem implements IModItem { // we just equipped it nbt.putBoolean(key, true); // TODO use new forge attribute for step height - player.maxUpStep = 1.1F; + player.setMaxUpStep(1.1F); if (!speed.hasModifier(ItemArmor.SKY_MOVEMENT_MODIFIER)) speed.addPermanentModifier(ItemArmor.SKY_MOVEMENT_MODIFIER); } else if (!equipped && nbt.getBoolean(key)) { // we just unequipped it nbt.putBoolean(key, false); - player.maxUpStep = 0.6F; + player.setMaxUpStep(0.6F); speed.removeModifier(ItemArmor.SKY_MOVEMENT_MODIFIER); } } 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 db166d30..43a8af19 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemAxe.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; @@ -18,7 +17,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.material.Material; import net.minecraftforge.common.capabilities.ICapabilityProvider; import javax.annotation.Nullable; @@ -28,7 +26,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { private final String baseName; public ItemAxe(String baseName, Tier material, float damage, float speed) { - super(material, damage, speed, new Properties().tab(NaturesAura.CREATIVE_TAB)); + super(material, damage, speed, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -40,7 +38,7 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @Override public float getDestroySpeed(ItemStack stack, BlockState state) { - if (state.getMaterial() == Material.LEAVES) { + if (state.is(BlockTags.LEAVES)) { return this.speed; } else { return super.getDestroySpeed(stack, state); @@ -49,9 +47,9 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel { @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)) { + if ((stack.getItem() == ModItems.SKY_AXE || stack.getItem() == ModItems.DEPTH_AXE) && Helper.isToolEnabled(stack) && player.level().getBlockState(pos).is(BlockTags.LOGS)) { var horRange = stack.getItem() == ModItems.DEPTH_AXE ? 6 : 1; - Helper.mineRecursively(player.level, pos, pos, true, horRange, 32, s -> s.is(BlockTags.LOGS)); + Helper.mineRecursively(player.level(), pos, pos, true, horRange, 32, s -> s.is(BlockTags.LOGS)); return true; } return false; 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 35cd87e7..6da2e8ac 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemHoe.java @@ -31,7 +31,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().tab(NaturesAura.CREATIVE_TAB)); + super(material, speed, 0, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -82,10 +82,10 @@ 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(); + 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) { + if (!player.level().isClientSide) { var range = 3; for (var x = -range; x <= range; x++) { for (var y = -range; y <= range; y++) { @@ -93,11 +93,11 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel { if (x == 0 && y == 0 && z == 0) continue; var offset = pos.offset(x, y, z); - var offState = player.level.getBlockState(offset); + 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, ItemStack.EMPTY); - player.level.setBlock(offset, Blocks.AIR.defaultBlockState(), 3); + var entity = offState.hasBlockEntity() ? player.level().getBlockEntity(offset) : null; + Block.dropResources(offState, player.level(), offset, entity, null, ItemStack.EMPTY); + player.level().setBlock(offset, Blocks.AIR.defaultBlockState(), 3); } } } 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 0feb8662..81825db6 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemPickaxe.java @@ -36,7 +36,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().tab(NaturesAura.CREATIVE_TAB)); + super(material, damage, speed, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -90,8 +90,8 @@ 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, true, 5, 5, s -> s.is(Tags.Blocks.ORES)); + if (itemstack.getItem() == ModItems.DEPTH_PICKAXE && Helper.isToolEnabled(itemstack) && player.level().getBlockState(pos).is(Tags.Blocks.ORES)) { + Helper.mineRecursively(player.level(), pos, pos, true, 5, 5, s -> s.is(Tags.Blocks.ORES)); return true; } return false; 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 81c4cf9e..5129188e 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemShovel.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura.items.tools; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.data.ItemModelGenerator; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.reg.ICustomItemModel; @@ -22,7 +21,6 @@ import net.minecraft.world.item.Tier; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.material.Material; import net.minecraft.world.phys.BlockHitResult; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -34,7 +32,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().tab(NaturesAura.CREATIVE_TAB)); + super(material, damage, speed, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -49,7 +47,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel // turning dirt to grass if (this == ModItems.INFUSED_IRON_SHOVEL || this == ModItems.DEPTH_SHOVEL) { - if ((state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.MYCELIUM) && level.getBlockState(pos.above()).getMaterial() == Material.AIR) { + if ((state.getBlock() == Blocks.DIRT || state.getBlock() == Blocks.MYCELIUM) && level.getBlockState(pos.above()).isAir()) { level.setBlockAndUpdate(pos, Blocks.GRASS_BLOCK.defaultBlockState()); var damage = 5F; @@ -60,7 +58,7 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel for (var y = -1; y <= 1; y++) { var offset = pos.offset(x, y, z); var offState = level.getBlockState(offset); - if ((offState.getBlock() == Blocks.DIRT || offState.getBlock() == Blocks.MYCELIUM) && level.getBlockState(offset.above()).getMaterial() == Material.AIR) + if ((offState.getBlock() == Blocks.DIRT || offState.getBlock() == Blocks.MYCELIUM) && level.getBlockState(offset.above()).isAir()) possible.add(offset); } } @@ -87,7 +85,7 @@ 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()).getMaterial() == Material.AIR + && level.getBlockState(actualPos.above()).isAir() && level.getBlockState(actualPos).getBlock() == Blocks.GRASS_BLOCK) { if (!level.isClientSide) level.setBlock(actualPos, Blocks.DIRT_PATH.defaultBlockState(), 11); 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 f0188423..9617ed54 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java +++ b/src/main/java/de/ellpeck/naturesaura/items/tools/ItemSword.java @@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.reg.IModItem; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Mth; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; @@ -31,7 +30,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().tab(NaturesAura.CREATIVE_TAB)); + super(material, damage, speed, new Properties()); this.baseName = baseName; ModRegistry.ALL_ITEMS.add(this); } @@ -50,10 +49,11 @@ public class ItemSword extends SwordItem implements IModItem, ICustomItemModel { } else if (this == ModItems.DEPTH_SWORD && attacker instanceof Player player) { // this is just a modified copy of Player.attack's sweeping damage code var damage = (float) player.getAttributeValue(Attributes.ATTACK_DAMAGE) * 0.75F; - for (var other : player.level.getEntitiesOfClass(LivingEntity.class, stack.getSweepHitBox(player, target))) { - if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker()) && player.canHit(other, 0)) { + for (var other : player.level().getEntitiesOfClass(LivingEntity.class, stack.getSweepHitBox(player, target))) { + // TODO we removed canHit here, is that okay? + if (other != player && other != target && !player.isAlliedTo(other) && (!(other instanceof ArmorStand stand) || !stand.isMarker())) { other.knockback(0.4F, Mth.sin(player.getYRot() * (Mth.PI / 180)), -Mth.cos(player.getYRot() * (Mth.PI / 180))); - other.hurt(DamageSource.playerAttack(player), damage); + other.hurt(other.damageSources().playerAttack(player), damage); } } // this just displays the particles diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 76710a7a..ee6871c1 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -80,7 +80,7 @@ public class PacketParticles { public enum Type { TR_GOLD_POWDER((message, level) -> { - var pos = new BlockPos(message.posX, message.posY, message.posZ); + var pos = BlockPos.containing(message.posX, message.posY, message.posZ); Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> { var state = level.getBlockState(dustPos); var box = state.getShape(level, dustPos).bounds(); @@ -333,7 +333,7 @@ public class PacketParticles { }), RF_CONVERTER((message, level) -> { for (var i = level.random.nextInt(5) + 2; i >= 0; i--) - Multiblocks.RF_CONVERTER.forEach(new BlockPos(message.posX, message.posY, message.posZ), 'R', (blockPos, matcher) -> { + Multiblocks.RF_CONVERTER.forEach(BlockPos.containing(message.posX, message.posY, message.posZ), 'R', (blockPos, matcher) -> { if (level.random.nextFloat() < 0.35F) { NaturesAuraAPI.instance().spawnParticleStream( blockPos.getX() + level.random.nextFloat(), @@ -451,7 +451,7 @@ public class PacketParticles { level.random.nextGaussian() * 0.005F); if (worked) { - var pos = new BlockPos(message.posX, message.posY, message.posZ); + var pos = BlockPos.containing(message.posX, message.posY, message.posZ); var color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); for (var i = level.random.nextInt(10) + 10; i >= 0; i--) NaturesAuraAPI.instance().spawnParticleStream( @@ -473,7 +473,7 @@ public class PacketParticles { ); }), SNOW_CREATOR((message, level) -> { - var pos = new BlockPos(message.posX, message.posY, message.posZ); + var pos = BlockPos.containing(message.posX, message.posY, message.posZ); var color = IAuraChunk.getAuraChunk(level, pos).getType().getColor(); for (var i = level.random.nextInt(3) + 1; i > 0; i--) NaturesAuraAPI.instance().spawnParticleStream( diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java index 9ee5dc59..3cb63286 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleMagic.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura.particles; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Vector3f; import de.ellpeck.naturesaura.NaturesAura; import net.minecraft.client.Camera; import net.minecraft.client.multiplayer.ClientLevel; @@ -13,6 +12,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import org.joml.Vector3f; import java.util.Collections; @@ -103,7 +103,7 @@ public class ParticleMagic extends Particle { for (var i = 0; i < 4; ++i) { var vector3f = avector3f[i]; - vector3f.transform(quaternion); + vector3f.rotate(quaternion); vector3f.mul(f4); vector3f.add(f, f1, f2); } @@ -124,4 +124,4 @@ public class ParticleMagic extends Particle { protected int getLightColor(float p_107249_) { return 15 << 20 | 15 << 4; } -} \ No newline at end of file +} diff --git a/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java index d5bad028..47be3734 100644 --- a/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java +++ b/src/main/java/de/ellpeck/naturesaura/potion/PotionBreathless.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.potion; -import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.effect.MobEffectCategory; import net.minecraft.world.entity.LivingEntity; import net.minecraftforge.common.MinecraftForge; @@ -37,6 +36,6 @@ public class PotionBreathless extends PotionImpl { @Override public void applyEffectTick(LivingEntity entity, int amplifier) { - entity.hurt(DamageSource.MAGIC, 1F); + entity.hurt(entity.damageSources().magic(), 1F); } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java index e15cf98d..d7fa1995 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.recipes; import com.google.gson.JsonObject; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -29,7 +30,7 @@ public class AltarRecipe extends ModRecipe { } @Override - public ItemStack getResultItem() { + public ItemStack getResultItem(RegistryAccess access) { return this.output; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java index 4b76710e..f6ff1063 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/AnimalSpawnerRecipe.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.recipes; import com.google.gson.JsonObject; import net.minecraft.core.BlockPos; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; @@ -38,11 +39,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, null, pos, MobSpawnType.SPAWNER, false, false); + return this.entity.create((ServerLevel) level, null, null, pos, MobSpawnType.SPAWNER, false, false); } @Override - public ItemStack getResultItem() { + public ItemStack getResultItem(RegistryAccess access) { return ItemStack.EMPTY; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java index e28a33d4..255ec858 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipe.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.recipes; +import net.minecraft.core.RegistryAccess; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; @@ -21,7 +22,7 @@ public abstract class ModRecipe implements Recipe { } @Override - public ItemStack assemble(RecipeWrapper inv) { + public ItemStack assemble(RecipeWrapper inv, RegistryAccess access) { return ItemStack.EMPTY; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java index 57f16823..45020b6d 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/OfferingRecipe.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.recipes; import com.google.gson.JsonObject; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -25,7 +26,7 @@ public class OfferingRecipe extends ModRecipe { } @Override - public ItemStack getResultItem() { + public ItemStack getResultItem(RegistryAccess access) { return this.output; } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java index c85092be..9aa1b37e 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.recipes; import com.google.gson.JsonObject; +import net.minecraft.core.RegistryAccess; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; @@ -29,7 +30,7 @@ public class TreeRitualRecipe extends ModRecipe { } @Override - public ItemStack getResultItem() { + public ItemStack getResultItem(RegistryAccess access) { return this.result; } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java b/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java index e5a41654..c34e28b2 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModArmorMaterial.java @@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; -import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; @@ -41,13 +41,13 @@ public enum ModArmorMaterial implements ArmorMaterial { } @Override - public int getDurabilityForSlot(EquipmentSlot slotIn) { - return ModArmorMaterial.MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor; + public int getDurabilityForType(ArmorItem.Type p_266807_) { + return ModArmorMaterial.MAX_DAMAGE_ARRAY[p_266807_.getSlot().getIndex()] * this.maxDamageFactor; } @Override - public int getDefenseForSlot(EquipmentSlot slotIn) { - return this.damageReductionAmountArray[slotIn.getIndex()]; + public int getDefenseForType(ArmorItem.Type p_266807_) { + return this.damageReductionAmountArray[p_266807_.getSlot().getIndex()]; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index acdfb3f0..be4bbd00 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -22,12 +22,10 @@ import de.ellpeck.naturesaura.potion.ModPotions; import de.ellpeck.naturesaura.potion.PotionBreathless; import de.ellpeck.naturesaura.recipes.EnabledCondition; import de.ellpeck.naturesaura.recipes.ModRecipes; -import net.minecraft.data.worldgen.features.FeatureUtils; -import net.minecraft.data.worldgen.placement.PlacementUtils; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; @@ -35,10 +33,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.FlowerPotBlock; import net.minecraft.world.level.block.SoundType; -import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; -import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration; import net.minecraft.world.level.levelgen.structure.BuiltinStructures; -import net.minecraft.world.level.material.Material; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -62,7 +57,7 @@ public final class ModRegistry { ModRegistry.registerAll(h, new BlockAncientLog("ancient_log"), new BlockAncientLog("ancient_bark"), - temp = new BlockImpl("ancient_planks", Block.Properties.of(Material.WOOD).sound(SoundType.WOOD).strength(2F)), + temp = new BlockImpl("ancient_planks", Block.Properties.of().sound(SoundType.WOOD).strength(2F)), new BlockStairsNA("ancient_stairs", "ancient_planks", temp::defaultBlockState, Block.Properties.copy(temp)), new Slab("ancient_slab", "ancient_planks", Block.Properties.copy(temp)), new BlockAncientLeaves(), @@ -72,23 +67,23 @@ public final class ModRegistry { new BlockGoldenLeaves(), new BlockGoldPowder(), new BlockWoodStand(), - temp = new BlockImpl("infused_stone", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.75F)), + temp = new BlockImpl("infused_stone", Block.Properties.of().sound(SoundType.STONE).strength(1.75F)), new BlockStairsNA("infused_stairs", "infused_stone", temp::defaultBlockState, Block.Properties.copy(temp)), new Slab("infused_slab", "infused_stone", Block.Properties.copy(temp)), - temp = new BlockImpl("infused_brick", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(1.5F)), + 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.copy(temp)), new Slab("infused_brick_slab", "infused_brick", Block.Properties.copy(temp)), new BlockFurnaceHeater(), new BlockPotionGenerator(), new BlockAuraDetector(), - new BlockImpl("conversion_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), - new BlockImpl("crushing_catalyst", Block.Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.5F)), + 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(Material.METAL).sound(SoundType.METAL).strength(3F)), + new BlockImpl("infused_iron_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), new BlockOfferingTable(), new BlockPickupStopper(), new BlockSpawnLamp(), @@ -124,7 +119,7 @@ public final class ModRegistry { ModRegistry.createFlowerPot(temp), temp = new BlockAuraBloom("aura_mushroom", Blocks.MYCELIUM), ModRegistry.createFlowerPot(temp), - new BlockImpl("tainted_gold_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(3F)), + new BlockImpl("tainted_gold_block", Block.Properties.of().sound(SoundType.METAL).strength(3F)), new BlockNetherGrass(), new BlockLight(), new BlockChorusGenerator(), @@ -135,8 +130,8 @@ public final class ModRegistry { new BlockRFConverter(), new BlockChunkLoader(), new BlockLowerLimiter(), - new BlockImpl("sky_ingot_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(4F)), - new BlockImpl("depth_ingot_block", Block.Properties.of(Material.METAL).sound(SoundType.METAL).strength(6F)) + 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, event.getForgeRegistry()); }); @@ -144,7 +139,7 @@ public final class ModRegistry { event.register(ForgeRegistries.Keys.ITEMS, h -> { for (var block : ModRegistry.ALL_ITEMS) { if (block instanceof Block && !(block instanceof INoItemBlock)) { - var item = new BlockItem((Block) block, new Item.Properties().tab(NaturesAura.CREATIVE_TAB)); + var item = new BlockItem((Block) block, new Item.Properties()); h.register(new ResourceLocation(NaturesAura.MOD_ID, block.getBaseName()), item); } } @@ -156,10 +151,10 @@ public final class ModRegistry { 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, EquipmentSlot.HEAD), - new ItemArmor("infused_iron_chest", ModArmorMaterial.INFUSED, EquipmentSlot.CHEST), - new ItemArmor("infused_iron_pants", ModArmorMaterial.INFUSED, EquipmentSlot.LEGS), - new ItemArmor("infused_iron_shoes", ModArmorMaterial.INFUSED, EquipmentSlot.FEET), + 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(), @@ -201,10 +196,10 @@ public final class ModRegistry { 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, EquipmentSlot.HEAD), - new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlot.CHEST), - new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlot.LEGS), - new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlot.FEET), + 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), @@ -218,10 +213,10 @@ public final class ModRegistry { 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, EquipmentSlot.HEAD), - new ItemArmor("depth_chest", ModArmorMaterial.DEPTH, EquipmentSlot.CHEST), - new ItemArmor("depth_pants", ModArmorMaterial.DEPTH, EquipmentSlot.LEGS), - new ItemArmor("depth_shoes", ModArmorMaterial.DEPTH, EquipmentSlot.FEET) + 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, event.getForgeRegistry()); }); @@ -244,13 +239,13 @@ public final class ModRegistry { event.register(ForgeRegistries.Keys.MENU_TYPES, h -> { h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_crate"), IForgeMenuType.create((windowId, inv, data) -> { - var tile = inv.player.level.getBlockEntity(data.readBlockPos()); + var tile = inv.player.level().getBlockEntity(data.readBlockPos()); if (tile instanceof BlockEntityEnderCrate crate) return new ContainerEnderCrate(ModContainers.ENDER_CRATE, windowId, inv.player, crate.getItemHandler()); return null; })); h.register(new ResourceLocation(NaturesAura.MOD_ID, "ender_access"), IForgeMenuType.create((windowId, inv, data) -> { - IItemHandler handler = ILevelData.getOverworldData(inv.player.level).getEnderStorage(data.readUtf()); + IItemHandler handler = ILevelData.getOverworldData(inv.player.level()).getEnderStorage(data.readUtf()); return new ContainerEnderCrate(ModContainers.ENDER_ACCESS, windowId, inv.player, handler); })); Helper.populateObjectHolders(ModContainers.class, event.getForgeRegistry()); @@ -309,7 +304,8 @@ public final class ModRegistry { } public static void init() { - ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); + // TODO fucking features changed again + /*ModFeatures.Configured.AURA_BLOOM = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_bloom", ModFeatures.AURA_BLOOM, NoneFeatureConfiguration.INSTANCE); ModFeatures.Configured.AURA_CACTUS = FeatureUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.AURA_CACTUS, NoneFeatureConfiguration.INSTANCE); ModFeatures.Configured.WARPED_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.WARPED_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); ModFeatures.Configured.CRIMSON_AURA_MUSHROOM = FeatureUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.CRIMSON_AURA_MUSHROOM, NoneFeatureConfiguration.INSTANCE); @@ -321,11 +317,11 @@ public final class ModRegistry { ModFeatures.Placed.AURA_CACTUS = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_cactus", ModFeatures.Configured.AURA_CACTUS); ModFeatures.Placed.WARPED_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":warped_aura_mushroom", ModFeatures.Configured.WARPED_AURA_MUSHROOM); ModFeatures.Placed.CRIMSON_AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":crimson_aura_mushroom", ModFeatures.Configured.CRIMSON_AURA_MUSHROOM); - ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.Configured.AURA_MUSHROOM); + ModFeatures.Placed.AURA_MUSHROOM = PlacementUtils.register(NaturesAura.MOD_ID + ":aura_mushroom", ModFeatures.Configured.AURA_MUSHROOM);*/ } public static Block createFlowerPot(Block block) { - var props = Block.Properties.of(Material.DECORATION).strength(0F); + var props = Block.Properties.of().strength(0F); Block potted = new BlockFlowerPot(() -> (FlowerPotBlock) Blocks.FLOWER_POT, () -> block, props); ((FlowerPotBlock) Blocks.FLOWER_POT).addPlant(ForgeRegistries.BLOCKS.getKey(block), () -> potted); return potted; diff --git a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java index d4fde826..9cbb6da9 100644 --- a/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java +++ b/src/main/java/de/ellpeck/naturesaura/renderers/PlayerLayerTrinkets.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.renderers; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; +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; @@ -48,9 +48,9 @@ public class PlayerLayerTrinkets extends RenderLayer= 0.75F) { int color; if (info.tier == 1) { var pos = player.blockPosition(); - color = BiomeColors.getAverageGrassColor(player.level, pos); + color = BiomeColors.getAverageGrassColor(player.level(), pos); } else { color = info.color; } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a605204a..3e08fd8d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -4,49 +4,67 @@ # Note that there are a couple of TOML lists in this file. # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader = "javafml" #mandatory +modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion = "[28,)" #mandatory (28 is current forge version) +loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. +# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. +license="${mod_license}" # A URL to refer people to when problems occur with this mod -issueTrackerURL = "https://github.com/Ellpeck/NaturesAura" #optional -license = "GPLv3" +#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] #mandatory # The modid of the mod -modId = "naturesaura" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version = "${file.jarVersion}" +modId="${mod_id}" #mandatory +# The version number of the mod +version="${mod_version}" #mandatory # A display name for the mod -displayName = "Nature's Aura" #mandatory -# A URL to query for updates for this mod. See the JSON update specification -#updateJSONURL="http://myurl.me/" #optional +displayName="${mod_name}" #mandatory +# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/ +#updateJSONURL="https://change.me.example.invalid/updates.json" #optional # A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="http://example.com/" #optional +#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional # A file name (in the root of the mod JAR) containing a logo for display #logoFile="examplemod.png" #optional # A text field displayed in the mod UI #credits="" #optional # A text field displayed in the mod UI -authors = "Ellpeck" #optional +authors="${mod_authors}" #optional +# Display Test controls the display for your mod in the server connection screen +# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod. +# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod. +# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component. +# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value. +# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself. +#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional) + # The description text for the mod (multi line!) (#mandatory) -description = ''' -Nature's Aura is a Minecraft mod about collecting, using and replenishing the Aura naturally present in the world to create useful devices and unique mechanics.''' +description='''${mod_description}''' # A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.naturesaura]] #optional +[[dependencies.${mod_id}]] #optional # the modid of the dependency -modId = "patchouli" #mandatory +modId="forge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified -mandatory = true #mandatory +mandatory=true #mandatory # The version range of the dependency -versionRange = "[1.16.2-44,)" #mandatory -# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory -ordering = "NONE" -# Side this dependency is applied on - BOTH, CLIENT or SERVER -side = "BOTH" +versionRange="${forge_version_range}" #mandatory +# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory +# BEFORE - This mod is loaded BEFORE the dependency +# AFTER - This mod is loaded AFTER the dependency +ordering="NONE" +# Side this dependency is applied on - BOTH, CLIENT, or SERVER +side="BOTH" # Here's another dependency -#[[dependencies.naturesaura]] -# modId="minecraft" -# mandatory=true -# versionRange="[1.14.4]" -# ordering="NONE" -# side="BOTH" +[[dependencies.${mod_id}]] +modId="minecraft" +mandatory=true +# This version range declares a minimum of the current minecraft version up to but not including the next major version +versionRange="${minecraft_version_range}" +ordering="NONE" +side="BOTH" + +# Features are specific properties of the game environment, that you may want to declare you require. This example declares +# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't +# stop your mod loading on the server for example. +#[features.${mod_id}] +#openGLVersion="[3.2,)"