diff --git a/.gitattributes b/.gitattributes index dfe0770..f811f6a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ -# Auto detect text files and perform LF normalization -* text=auto +# Disable autocrlf on generated files, they always generate with LF +# Add any extra files or paths here to make git stop saying they +# are changed when only line endings change. +src/generated/**/.cache/cache text eol=lf +src/generated/**/*.json text eol=lf diff --git a/.gitignore b/.gitignore index 727cd99..12f8644 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,6 @@ build # other eclipse run -Mod Changelog.txt # Files from Forge MDK forge*changelog.txt diff --git a/Mod Changelog.md b/Mod Changelog.md index 4b64d30..fde4856 100644 --- a/Mod Changelog.md +++ b/Mod Changelog.md @@ -1,32 +1,29 @@ -## Magic Shelter -- Using this item on a block spawns a mostly obsidian structure around the player to protect them -- The second floor has a chest with loot containing magic powder, crystals, nuggets, cores, and gems, as well as a chance to get one of 2 new enchantments _(see below for more details)_ -- Only places if there's ground directly beneath the player, and there's enough space +## Magic Miner +- Automatically mines blocks +- Requires fuel from a nearby Magic Energizer _(see below)_ +- Can be upgraded with the new upgrades _(see below)_ +- Only mines blocks best mined with a pickaxe or shovel +- Automatically stops when inventory fills up - Crafted as follows: -- ![Magic Shelter Recipe](https://user-images.githubusercontent.com/55959311/166120665-a00db5b7-b3d7-4e55-b10d-91f33d196d9f.png) -## Magic Finder Enchantment -- New treasure enchantment -- Can be applied to tools (pickaxe, axe, and shovel) -- Max level of 3 -- Found in Magic Shelter loot chests -- Grants a 10% chance per level to drop a magic powder when a block is mined (2% on insta-mineable blocks) -- **WARNING: Doesn't work on vanilla tools!** -## Veinminer Enchantment -- New treasure enchantment -- Can be applied to pickaxes -- Max level of 3 -- Found in Magic Shelter loot chests -- Automatically breaks block of the same type in an area around any block broken, similar to the Veinminer mod -- Affected area grows with enchantment level (3x3 for level 1, 5x5 for level 2, etc.) -- Only works if you're using the right tool -- **WARNING: Doesn't work on vanilla tools!** -## Magic Spike -- New spike-shaped block that deals 10x fall damage when fallen on -- Useful for mob farms and traps +![Magic Miner Recipe](https://user-images.githubusercontent.com/55959311/173133628-b3f1781d-6e90-49d6-81e5-3f84761622f0.png) +## Magic Logger +- Works the same as the Magic Miner except mines logs and leaves instead +- Also mines blocks above the logger instead of below - Crafted as follows: -- ![Magic Spike Recipe](https://user-images.githubusercontent.com/55959311/166122283-da78b9cc-5f50-437b-af34-4444bca5d73a.png) +![Magic Logger Recipe](https://user-images.githubusercontent.com/55959311/173133439-5413f25c-c309-4f6d-ae58-f5af78d9ba8c.png) +## Magic Energizer +- Powers Magic Miners and Magic Loggers within 4 blocks +- Requires Magic Fuel _(see below)_ to operate +- Crafted as follows: +![Magic Energizer Recipe](https://user-images.githubusercontent.com/55959311/173197590-180a986c-c4ff-412d-92f5-2ae64016f887.png) +## Magic Fuel +- Used to power Magic Energizers +- Crafted as follows: +![Magic Fuel Recipe](https://user-images.githubusercontent.com/55959311/173133307-903e84f9-265a-42fe-9692-687b7fde4de0.png) +## Magic Gear +- Used to craft Magic Loggers, Miners, and Energizers +- Found in Magic Shelter chests ## Other Changes and Bug Fixes -- Added a close sound for the magic crate -- Magic Pearls now deal a lot less damage -- Reduced cooldown for Magic Pearls -- Fortune now affects magic ore drops \ No newline at end of file +- Updated mod to 1.18 (1.19 coming soon) +- Added Deepslate Magic Ore as a deepslate counterpart to Magic Ore +- Tall grass no longer prevents the Magic Shelter from placing \ No newline at end of file diff --git a/README.txt b/README.txt index 6904b37..344bca7 100644 --- a/README.txt +++ b/README.txt @@ -1,53 +1,46 @@ -------------------------------------------- + Source installation information for modders ------------------------------------------- This code follows the Minecraft Forge installation methodology. It will apply some small patches to the vanilla MCP source code, giving you and it access to some of the data and functions you need to build a successful mod. -Note also that the patches are built against "unrenamed" MCP source code (aka -srgnames) - this means that you will not be able to read them directly against +Note also that the patches are built against "un-renamed" MCP source code (aka +SRG Names) - this means that you will not be able to read them directly against normal code. -Source pack installation information: - -Standalone source installation +Setup Process: ============================== -See the Forge Documentation online for more detailed instructions: -http://mcforge.readthedocs.io/en/latest/gettingstarted/ - Step 1: Open your command-line and browse to the folder where you extracted the zip file. Step 2: You're left with a choice. If you prefer to use Eclipse: -1. Run the following command: "gradlew genEclipseRuns" (./gradlew genEclipseRuns if you are on Mac/Linux) +1. Run the following command: `gradlew genEclipseRuns` (`./gradlew genEclipseRuns` if you are on Mac/Linux) 2. Open Eclipse, Import > Existing Gradle Project > Select Folder - or run "gradlew eclipse" to generate the project. -(Current Issue) -4. Open Project > Run/Debug Settings > Edit runClient and runServer > Environment -5. Edit MOD_CLASSES to show [modid]%%[Path]; 2 times rather then the generated 4. + or run `gradlew eclipse` to generate the project. If you prefer to use IntelliJ: 1. Open IDEA, and import project. 2. Select your build.gradle file and have it import. -3. Run the following command: "gradlew genIntellijRuns" (./gradlew genIntellijRuns if you are on Mac/Linux) +3. Run the following command: `gradlew genIntellijRuns` (`./gradlew genIntellijRuns` if you are on Mac/Linux) 4. Refresh the Gradle Project in IDEA if required. -If at any point you are missing libraries in your IDE, or you've run into problems you can run "gradlew --refresh-dependencies" to refresh the local cache. "gradlew clean" to reset everything {this does not affect your code} and then start the processs again. +If at any point you are missing libraries in your IDE, or you've run into problems you can +run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything +{this does not affect your code} and then start the process again. -Should it still not work, -Refer to #ForgeGradle on EsperNet for more information about the gradle environment. -or the Forge Project Discord discord.gg/UvedJ9m +Mapping Names: +============================= +By default, the MDK is configured to use the official mapping names from Mojang for methods and fields +in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this +license, if you do not agree with it you can change your mapping names to other crowdsourced names in your +build.gradle. For the latest license text, refer to the mapping file itself, or the reference copy here: +https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md -Forge source installation +Additional Resources: ========================= -MinecraftForge ships with this code and installs it as part of the forge -installation process, no further action is required on your part. - -LexManos' Install Video -======================= -https://www.youtube.com/watch?v=8VEdtQLuLO0&feature=youtu.be - -For more details update more often refer to the Forge Forums: -http://www.minecraftforge.net/forum/index.php/topic,14048.0.html +Community Documentation: http://mcforge.readthedocs.io/en/latest/gettingstarted/ +LexManos' Install Video: https://www.youtube.com/watch?v=8VEdtQLuLO0 +Forge Forum: https://forums.minecraftforge.net/ +Forge Discord: https://discord.gg/UvedJ9m \ No newline at end of file diff --git a/build.gradle b/build.gradle index 75cfbd2..cd5878f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,34 +1,46 @@ buildscript { repositories { - maven { url = 'https://files.minecraftforge.net/maven' } - jcenter() + // 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: '3.+', changing: true + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true } } -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' +plugins { + id 'eclipse' + id 'maven-publish' +} +apply plugin: 'net.minecraftforge.gradle' + -version = '2.9.1' +version = '2.10' group = 'com.pitheguy.magicmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'magicmod' -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. +// 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 { - // The mappings can be changed at any time, and must be in the following format. - // snapshot_YYYYMMDD Snapshot are built nightly. - // stable_# Stables are built at the discretion of the MCP team. - // Use non-default mappings at your own risk. they may not always work. + // 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://github.com/ParchmentMC/Parchment/wiki/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: 'snapshot', version: '20200514-1.15.1' - // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. - - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + mappings channel: 'official', version: '1.18.2' + + // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default. // Default run configurations. // These can be tweaked, removed, or duplicated as needed. @@ -37,13 +49,22 @@ minecraft { 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', 'debug' + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', 'examplemod' + mods { - magicmod { + examplemod { source sourceSets.main } } @@ -52,14 +73,43 @@ minecraft { server { workingDirectory project.file('run') + property 'forge.logging.markers', 'REGISTRIES' + + property 'forge.logging.console.level', 'debug' + + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', 'examplemod' + + mods { + examplemod { + 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 { + 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', 'debug' + // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. + property 'forge.enabledGameTestNamespaces', 'examplemod' + mods { - magicmod { + examplemod { source sourceSets.main } } @@ -68,16 +118,15 @@ minecraft { data { workingDirectory project.file('run') - // Recommended logging data for a userdev environment - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.markers', 'REGISTRIES' - // Recommended logging level for the console property 'forge.logging.console.level', 'debug' - args '--mod', 'magicmod', '--all', '--output', file('src/generated/resources/') + // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. + args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { - magicmod { + examplemod { source sourceSets.main } } @@ -85,54 +134,58 @@ minecraft { } } -dependencies { - implementation 'org.jetbrains:annotations:20.1.0' +// Include resources generated by data generators. +sourceSets.main.resources { srcDir 'src/generated/resources' } - // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed - // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. - // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.15.2-31.2.0' +repositories { + // Put repositories for dependencies here + // ForgeGradle automatically adds the Forge maven and Maven Central for you - // You may put jars on which you depend on in ./libs or you may define them like so.. - // compile "some.group:artifact:version:classifier" - // compile "some.group:artifact:version" + // If you have mod jar dependencies in ./libs, you can declare them as a repository like so: + // flatDir { + // dir 'libs' + // } +} - // Real examples - // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env - // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env +dependencies { + // Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed + // that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied. + // The userdev artifact is a special name and will get all sorts of transformations applied to it. + minecraft 'net.minecraftforge:forge:1.18.2-40.1.0' - // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. - // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' + // Real mod deobf dependency examples - these get remapped to your current mappings + // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency + // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency + // implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency - // These dependencies get remapped to your current MCP mappings - // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' + // Examples using mod jars from ./libs + // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") // 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.. +// Example for how to get properties into the manifest for reading at runtime. jar { manifest { attributes([ - "Specification-Title": "examplemod", - "Specification-Vendor": "examplemodsareus", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"examplemodsareus", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "Specification-Title" : "examplemod", + "Specification-Vendor" : "examplemodsareus", + "Specification-Version" : "1", // We are version 1 of ourselves + "Implementation-Title" : project.name, + "Implementation-Version" : project.jar.archiveVersion, + "Implementation-Vendor" : "examplemodsareus", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } -// Example configuration to allow publishing using the maven-publish task +// Example configuration to allow publishing using the maven-publish plugin // This is the preferred method to reobfuscate your jar file -jar.finalizedBy('reobfJar') +jar.finalizedBy('reobfJar') // 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 -//publish.dependsOn('reobfJar') +// publish.dependsOn('reobfJar') publishing { publications { @@ -142,7 +195,11 @@ publishing { } repositories { maven { - url "file:///${project.projectDir}/mcmodsrepo" + url "file://${project.projectDir}/mcmodsrepo" } } -} \ No newline at end of file +} + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} diff --git a/changelog.txt b/changelog.txt index 3715607..bcaf6f7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,941 +1,254 @@ -Build: 1.15.2-31.2.0 - Fri May 15 19:34:16 GMT 2020 - lex: - Bump version for new RB. +1.18.x Changelog +40.1 +==== + - 40.1.0 Mark 1.18.2 Recommended Build. + Co-authored-by: sciwhiz12 + Co-authored-by: Marc Hermans + Co-authored-by: Curle + Co-authored-by: SizableShrimp + Co-authored-by: David Quintana + +40.0 +==== + - 40.0.54 Add event for hooking into StructuresBecomeConfiguredFix Fixes #8505 + Pass-through unknown structure IDs with "unknown." prefix + This avoids the fixer throwing an exception due to the unknown + structure, which causes the chunk data to be dropped (and freshly + regenerated later). The deserializer logs and ignores the unknown + structure ID, avoiding full chunk data loss. + - 40.0.53 Fix missed patch for loading modded dimensions on Dedicated Server start (#8555) + - 40.0.52 Fix potential concurrency issues with BiomeDictionary. Closes #8266 + - 40.0.51 Fix debug text being rendered slightly wrong. + - 40.0.50 Fix intrusive handlers on dummy objects. + - 40.0.49 Amend license header to include contributors and apply to FML subprojects (#8525) + After internal discussion, it was decided that we need to include + "contributors" to the license header. This avoids claiming that the + Java source files are under the exclusive copyright ownership of Forge + LLC, which excludes contributors that still hold copyright ownership + over their contributions (but is licensed under the LGPLv2.1 as stated + in the Forge CLA). + - 40.0.48 Add modern implementation of the Slider widget and deprecate the old one (#8496) + - 40.0.47 Implement ItemStack and LivingEntity sensitive method to get the FoodProperties for an Item (#8477) + - 40.0.46 Add use context and simulate flag to getToolModifiedState, enabled HOE_TILL action. (#8557) + - 40.0.45 Remove bad patch for AbstractFurnaceBlockEntity (#8561) + The patch prevented the entity from being marked as changed when an + item finished smelting. + - 40.0.44 Fix issues with custom forge ingredients causing sub ingredients to be prematurely and invalidly cached (#8550) + Add config option and skip checking for empty ingredients in shapeless recipe deserialization + - 40.0.43 Add EnderManAngerEvent to make it possible to prevent endermen getting angry at a player based on more then their helmet. (#8406) + - 40.0.42 Fix misaligned patch in BlockEntity.save. + - 40.0.41 Expose `getHolder()` method on RegistryObject, as helper for when absolutely necessary to pass into Vanilla code. (#8548) + It is recommended you avoid if you can. + - 40.0.40 Fix return value of Recipe#isIncomplete being inaccurate for empty tags (#8549) + - 40.0.39 Simplfy default behavior of isSimple (#8543) + isSimple should only return true if the ingredient is any more sensitive then JUST itemA == itemB + It used to take metadata and damage into account, but that was removed in the flattening. + Also prevents fetching tag values too early, as tags are not ready during the ingredient constructor + - 40.0.38 Implement IPlantable in BambooBlock (#8508) + - 40.0.37 Fix compiler error in eclipse, bump MCPConfig for FF/Record fix. + - 40.0.36 Fix TagEmptyCondition by passing tag context into conditional and recipe deserializers. (#8546) + - 40.0.35 Allow using DeferredRegisters for vanilla registries (#8527) + Catch and aggregate exceptions when applying object holders + - 40.0.34 Remove cut copper from copper storage blocks tag. Closes #8403 (#8539) + - 40.0.33 Fix brewing stand input placement not auto-splitting stackable potions. (#8534) + - 40.0.32 Fix lost validation of registry data on singleplayer world load (#8533) + Fix some leftover 1.18.2 TODOs + - 40.0.31 1.18 Allow mod menus to have their own recipebook (#8028) + - 40.0.30 [1.18.x] Add 3 new ingredient types, and make existing ingredients compatible with datagen (#8517) + - 40.0.29 [1.18.x] Add the projectile search event. (#8322) + Co-authored-by: noeppi_noeppi + - 40.0.28 Allow confirm-and-save of the Experimental Settings warning. (#7275) + - 40.0.27 Add hook for powdered-snow shoes (#8514) + - 40.0.26 Add some helper Access Transformers (#8490) + - 40.0.25 Fix incorrect method used in getStream (#8532) + The original correct method is getPath, but the patch uses getLocation. + The former is the actual resource path to the sound OGG file, while the + latter is the sound's location. + Fixes #8531 + - 40.0.24 [1.18] Make it easier to register custom skull blocks models (#8351) + - 40.0.23 Rework fog events (#8492) + - 40.0.22 Update Forge Auto Renaming Tool to the latest version (#8515) + - 40.0.21 Add patches to enable MobEffects with IDs > 255 (#8380) + - 40.0.20 Allow sound instances to play custom audio streams (#8295) + - 40.0.19 Fix NPE caused by canceling onServerChatEvent (#8516) + - 40.0.18 [1.18.2] Fix tags for custom forge registries. (#8495) + Tag-enabled registries must now be registered to vanilla's root registry. See RegistryBuilder#hasTags. + Modded tag-enabled registries have to use the format `data//tags///.json` + This format is to prevent conflicts for registries with the same path but different namespaces + EX: Registry name `examplemod:shoe`, tag name `blue_shoes` would be `data//tags/examplemod/shoe/blue_shoes.json` + RegistryEvent.NewRegistry has been moved and renamed to NewRegistryEvent. + RegistryBuilder#create has been made private. See NewRegistryEvent#create + Created new ITagManager system for looking up Forge tags. See IForgeRegistry#tags. + Add lookup methods for Holders from forge registries. See IForgeRegistry#getHolder. + - 40.0.17 Lower custom item entity replacement from highest to high so mods can cancel it during a specific tick (#8417) + - 40.0.16 Fix MC-176559 related to the Mending enchantment (#7606) + - 40.0.15 [1.18.x] Allow blocks to hide faces on a neighboring block (#8300) + * Allow blocks to hide faces on a neighboring block + * Allow blocks to opt-out of external face hiding + - 40.0.14 [1.18.x] Fix FMLOnly in forgedev and userdev (#8512) + - 40.0.13 Clear local variable table on RuntimeEnumExtender transformation (#8502) + - 40.0.12 Pass server resources to reload listener event (#8493) + - 40.0.11 Use UTF-8 charset for Java compilation (#8486) + - 40.0.10 Use wither as griefing entity when it indirectly hurts an entity (#8431) + - 40.0.9 Provide access to the haveTime supplier in WorldTickEvent and ServerTickEvent (#8470) + - 40.0.8 Fix durability bar not respecting an item's custom max damage (#8482) + - 40.0.7 Add event for controlling potion indicators size (#8483) + This event allows forcing the rendering of the potion indicators in the + inventory screen to either compact mode (icons only) or classic mode + (full width with potion effect name). + - 40.0.6 Introduce system mods to mod loading (#8238) + Core game mods are mods which are required to exist in the environment + during mod loading. These may be specially provided mods (for example, + the `minecraft` mod), or mods which are vital to the framework which + FML is connected to (for example, Forge and the `forge` mod). + These core game mods are used as the only existing mods in the mod list + if mod sorting or dependency verification fails. This allows later + steps in the which use resources from these mod files to work correctly + (up to when the error screen is shown and the game exits). + - 40.0.5 Add missing module exports arg to server arguments list (#8500) + - 40.0.4 Fixed swim speed attribute (#8499) + - 40.0.3 Fix incorrect movement distance calculation (#8497) + - 40.0.2 Add support to Forge registry wrappers for new Holder system. Closes #8491 + Fix TagBasedToolTypesTest not generating needed data correctly. + - 40.0.1 Fix JNA not working at runtime and causing issues with natives. + - 40.0.0 Update to 1.18.2 + Co-authored-by: sciwhiz12 + Co-authored-by: Marc Hermans + Co-authored-by: LexManos + Co-authored-by: Curle + +39.1 +==== + - 39.1.2 1.18.x Omnibus (#8239) + - 39.1.1 Bump modlauncher and securejarhandler version (#8489) + - 39.1.0 Update license headers to compact SPDX format. + License has not changed, this is just more compact and doesn't include years. + Bump version for RB. + +39.0 +==== + - 39.0.91 Remove - from allowed characters in mod ids. + The Java Module System does not allow them in module ids. + Closes #8488 + - 39.0.90 Fix static initializer crash when loading BakedRenderable. + - 39.0.89 Fix regressions for onAddedTo/RemovedFromWorld and related events (#8434) + - 39.0.88 [1.18] Integrate the gametest framework with Forge (#8225) + - 39.0.87 Re-add missing Shulker patch for EntityTeleportEvent (#8481) + - 39.0.86 Fix entity type in conversion event to Drowned (#8479) + - 39.0.85 Add VanillaGameEvent to allow for globally listening to vanilla's GameEvents (#8472) + - 39.0.84 Provide damage source context to Item#onDestroyed(ItemEntity) (#8473) + - 39.0.83 Add missing shear and elytra game events (#8471) + - 39.0.82 Fix comment for permission handler config setting (#8466) + - 39.0.81 Apply nullable annotations to LootingLevelEvent (#8422) + - 39.0.80 Fix Mob Spawner logic with CustomSpawnRules. Closes #8398 + - 39.0.79 Fix LivingDropsEvent not having all drops for foxes (#8387) + - 39.0.78 Add missing Locale parameter to String.format calls, Fixes getArmorResource functionality on some locaales. (#8463) + - 39.0.77 Allow items to hide parts of their tooltips by default (#8358) + - 39.0.76 Prevent 1.x Branches being treated as Pull Requests. (#8443) + - 39.0.75 Fix RegistryObject not working if created after registry events (#8383) + - 39.0.74 Add support for tagging StructureFeatures (#8408) + - 39.0.73 Re-added the patch for LivingExperienceDropEvent and enable it for dragons (#8388) + - 39.0.72 Implement getPickupSound on ForgeFlowingFluid (#8374) + - 39.0.71 Add getCodec method in ForgeRegistry (#8333) + - 39.0.70 Fix #8298 (MobBucketItem) and add test mod (#8313) + - 39.0.69 Deprecate IForgeAbstractMinecart::getCartItem (#8283) + - 39.0.68 Fix HoeItem patch incorrectly applied during migration. (#8384) + - 39.0.67 Fix issues with client only commands in combination with server only commands not using MC's command system. (#8452) + - 39.0.66 Fix FoliagePlacerType and TreeDecoratorType registry (#8394) + - 39.0.65 Fix PlayerChangeGameModeEvent (#8441) + - 39.0.64 Fix comparison of custom ParticleRenderTypes leading to broken particle effects. (#8385) + - 39.0.63 Fix cases where null is potentially sent to Screen events. Closes #8432 + - 39.0.62 Ensure ScreenEvent doesn't accept null screens (#8296) + - 39.0.61 Update cobblestone tags (#8292) + - 39.0.60 Prevent release of custom payload packet buffer on the server side. (#8181) + - 39.0.59 Make `MinecraftLocator` respect non-`MOD` FML Mod Types Fixes #8344 (#8346) + - 39.0.58 Fix vanilla worlds being marked experimental (#8415) + - 39.0.57 Simplify usage of IItemRenderProperties::getArmorModel (#8349) + - 39.0.56 Hide mod update notification while screen is still fading in (#8386) + - 39.0.55 Revert "Hooks to allow registering and managing custom DFU schemes and types. (#8242)" + - 39.0.54 Provide NPE protection against out of order init of the TYPES and REF (#8410) + - 39.0.53 Add ShieldBlockEvent (#8261) + - 39.0.52 Add renderable API to allow easier rendering of OBJ and other custom models, from Entity and BlockEntity renderers. (#8259) + This is a redesign of a discarded section of my initial model system rewrite, back in 1.14. + In order to use it with the OBJ loader, you can use OBJLoader.INSTANCE.loadModel to get the OBJModel, and then call OBJModel#bakeRenderable() to get a SimpleRenderable object to render with. + The SimpleRenderable support animation, by providing different transformation matrices for each part in the MultipartTransforms. + Additionally, a BakedRenderable helper exists to turn an arbitrary BakedModel into a renderable. + After trying to get the B3D loader to work, I decided it wasn't worth the trouble and marked it for removal instead. + - 39.0.51 Merge values of defaulted optional tags, Fixes issue where multiple mods declare the same optional tag. (#8250) + - 39.0.50 Added new 1.18 biomes to the BiomeDictionary (#8246) + - 39.0.49 Hooks to allow registering and managing custom DFU schemes and types. (#8242) + - 39.0.48 Ping data compression (#8169) + - 39.0.47 Expand the LevelStem codec to allow dimension jsons to specify that the dimension's chunk generator should use the overworld/server's seed (#7955) + - 39.0.46 Add Client Commands (#7754) + - 39.0.45 Remove references to the now-broken `BlockEntity#save(CompoundTag)` method (#8235) + - 39.0.44 update McModLauncher libraries to newer versions... + - 39.0.43 add extra keystore properties + - 39.0.42 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.41 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.40 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.39 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.38 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.37 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.36 fix crowdin key + - 39.0.35 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.34 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.33 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.32 fix secondary branches builds + - 39.0.31 TeamCity change in 'MinecraftForge / MinecraftForge' project: parameters of 'Build - Secondary Branches' build configuration were updated + - 39.0.30 TeamCity change in 'MinecraftForge / MinecraftForge' project: VCS roots of 'Build - Secondary Branches' build configuration were updated + - 39.0.29 TeamCity change in 'MinecraftForge / MinecraftForge' project: VCS roots of 'Build - Secondary Branches' build configuration were updated + - 39.0.28 TeamCity change in 'MinecraftForge / MinecraftForge' project: VCS roots of 'Build - Secondary Branches' build configuration were updated + - 39.0.27 TeamCity change in 'MinecraftForge / MinecraftForge' project: parameters of 'Build - Secondary Branches' build configuration were updated + - 39.0.26 TeamCity change in 'MinecraftForge / MinecraftForge' project: parameters of 'Build - Secondary Branches' build configuration were updated + - 39.0.25 TeamCity change in 'MinecraftForge / MinecraftForge' project: VCS roots of 'Build - Secondary Branches' build configuration were updated + - 39.0.24 Remove primary branches from building on secondary branch configuration and publish crowdin data. (#8397) + * Remove the normalized branch names also from the filter. + * Add the additional publishing arguments to get the crowdin information. + * TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + * Fix the configuration. + * Remove the required patch and use the base script. + * Make a note about the reference. + Co-authored-by: cpw + - 39.0.23 TeamCity change in 'MinecraftForge / MinecraftForge' project: project parameters were changed + - 39.0.22 Correct the build configuration to support a setup. (#8395) + * Add a setup task and publish the correct versions. + * Reconfigure build task and disable the normal build and test cycle on everything but pull requests, run an assemble there. + * Fix the derp in the build configuration. + - 39.0.21 Enable the TeamCity CI pipeline (#8368) + * Setup the build.gradle + * Setup the teamcity toolchain. + * Revert the usage of the local build of GU. + * Automatically add it now, it will always exist and is added to maven automatically by GU. + * Implement the branch filter and move the constant for the minimal changelog tag to a constant in the extension. + * Adding the JDK and Gradle version to the build script. + - 39.0.20 Fix and improve Ingredient invalidation (#8361) + - 39.0.19 Rework world persistence hooks to fix the double registry injection when loading single player worlds. (#8234) + - 39.0.18 Update tags for new 1.17 and 1.18 content (#7891) + - 39.0.17 Fix TerrainParticle rendering black under certain conditions (#8378) + - 39.0.16 Allow modded tools to work on glow lichen (#8371) + - 39.0.15 Fix custom climbable blocks not sending a death message (#8372) + Fixes #8370 + - 39.0.14 Provide access to the blockstate in BucketPickup#getPickupSound for multiply-logged blocks (#8357) + - 39.0.13 Fix clients being unable to deserialize tags for custom registries (#8352) + - 39.0.12 Fix particles going fullbright for a few frames when first spawning (#8291) + - 39.0.11 Also create parent directories when creating config files (#8364) + - 39.0.10 Fix crash with PermissionsAPI (#8330) + Fixes a crash in singleplayer, when the internal server didn't shut down correctly between world loads. + - 39.0.9 Re-add missing default spawn lists in features (#8285) + Fixes #8265 + Fixes #8301 + - 39.0.8 Fixed incorrect generic in PermissionAPI (#8317) + - 39.0.7 Redo of the whole PermissionAPI (#7780) + Co-authored-by: LexManos + - 39.0.6 Fix misplaced patch in SpreadingSnowyDirtBlock. + Fixes #8308. + - 39.0.5 Add RenderArmEvent to make overriding just the arm rendering not require copying nearly as much vanilla code (#8254) + - 39.0.4 Add MobEffect tags (#8231) + - 39.0.3 Log missing or unsupported dependencies (#8218) + - 39.0.2 Fix datagen test for sounds definitions provider (#8249) + - 39.0.1 Fix wrong stage being declared in transition to common (#8267) + - 39.0.0 Update to 1.18.1 + Co-Authored by: + - Curle + _ Orion -========= -Build: 1.15.2-31.1.99 - Fri May 15 19:25:51 GMT 2020 - lex: - Update MCP Mappings. - -========= -Build: 1.15.2-31.1.98 - Fri May 15 18:34:16 GMT 2020 - ichttt: - fix test mod and add warning comment to framebuffer (#6698) - -========= -Build: 1.15.2-31.1.97 - Fri May 15 18:00:19 GMT 2020 - lex: - Fix incorrect argument passed in RenderPipeline potentially causing crash. #6677 - - lex: - Fix FireBlock using flammability instead of spread speed when looking for places to spread. Closes #6646 - -========= -Build: 1.15.2-31.1.95 - Fri May 15 17:53:00 GMT 2020 - FunwayguyEmail: - Re-added patch to enable stencil buffer in net.minecraft.client.shader.Framebuffer - Add test for the stencil buffer feature. Only tests that it doesn't crash when enabling, for now. - giga - - thesilkminer: - Allow Music Discs to be created with SoundEvent delegates. (#6523) - -========= -Build: 1.15.2-31.1.93 - Fri May 15 17:32:12 GMT 2020 - Edwin.mindcraft: - Use IProperty#getName when generating blockstate jsons (#6582) - - Close #6520 - -========= -Build: 1.15.2-31.1.92 - Fri May 15 17:26:19 GMT 2020 - David Quintana: - Model system fixes: - - Add "origin" key to determine what origin to use. This will default to the existing (broken) behaviour to avoid breaking changes. - - Fix interaction of transforms with variant transforms (transformation ordering). - - Fix OBJ loader ignoring "diffuseLighting" attribute from the json. - This attribute will continue not being used if "ambientToFullbright" is on (default) to avoid breaking changes. - -========= -Build: 1.15.2-31.1.91 - Fri May 15 16:38:42 GMT 2020 - lex: - Fixed Partivle.onGround not updating correctly due to decompile error. Closes #6595 - - lex: - Fixed typo in registry alias writing causing infinite loop. Closes #6689 - -========= -Build: 1.15.2-31.1.89 - Fri May 15 14:45:46 GMT 2020 - laughlan.cov: - Remove duplicate post of ChunkEvent.Load. (#6697) - -========= -Build: 1.15.2-31.1.88 - Thu May 14 20:22:21 GMT 2020 - thpetuaudletang: - Fix LevelChange event not firing after enchanting (#6693) - -========= -Build: 1.15.2-31.1.87 - Tue May 12 22:11:53 GMT 2020 - ichttt: - Fix server config directory remaining locked when integrated server is shut down. (#6644) - -========= -Build: 1.15.2-31.1.86 - Tue May 12 22:02:09 GMT 2020 - LXGaming: - Fix exclusion of coremods not filtering correctly when the mods directory is a symbolic link. (#6600) - -========= -Build: 1.15.2-31.1.85 - Tue May 12 21:29:40 GMT 2020 - jdk: - Allow Bees to use custom hives. (#6656) - -========= -Build: 1.15.2-31.1.84 - Tue May 12 21:23:13 GMT 2020 - jmansfield: - Fix vanilla screens escape key not matching done button behavior (#6682) - - jmansfield: - Fixed CropGrowEvents not firing for Bamboo (#6680) - - tomboshoven: - Fixed tile entities persisting when switching between states that don't have TEs without changing the block. (#6674) - -========= -Build: 1.15.2-31.1.81 - Tue May 12 21:17:26 GMT 2020 - ShetiPhian: - Fixed FluidTank.drain calling onContentsChanged when simulating (#6684) - -========= -Build: 1.15.2-31.1.80 - Tue May 12 21:08:20 GMT 2020 - lex: - Fix infinite loading screen when resources error. Closes #6592 & #6593 - -========= -Build: 1.15.2-31.1.79 - Mon May 11 22:28:50 GMT 2020 - laughlan.cov: - Fix IForgeBlock.removedByPlayer not firing on the client. (#6638) - -========= -Build: 1.15.2-31.1.78 - Mon May 11 00:35:20 GMT 2020 - cpw: - Update to newer eventbus, with typetools compatibility with jvms up to j14. No guarantees on actual game compatibility however. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.77 - Wed May 06 20:49:23 GMT 2020 - jmansfield: - Fixed informational /forge commands being repeated to all ops when logging is enabled. Closes #6330 - -========= -Build: 1.15.2-31.1.76 - Wed May 06 20:41:52 GMT 2020 - jmansfield: - Fix ModListScreen escape key not matching done button behavior. Closes #6672 - -========= -Build: 1.15.2-31.1.75 - Wed May 06 11:31:06 GMT 2020 - David Quintana: - Patch the bucket logic to not hardcode some checks to WATER. Fixes not being able to place custom fluids into modded fluid-loggable blocks that accept fluids other than water. - -========= -Build: 1.15.2-31.1.74 - Sun May 03 23:13:58 GMT 2020 - David Quintana: - Avoid discarding the bottom 4 bits of the lightmap coords. It turns out vanilla relies on those bits. Fixes some blocks being darker than they should be in certain circumstances. - -========= -Build: 1.15.2-31.1.73 - Sun May 03 20:48:25 GMT 2020 - jacob101607: - Fix issue with providing a null ItemStack to onPlayerDestroyItem (#6633) - -========= -Build: 1.15.2-31.1.72 - Sun May 03 20:40:43 GMT 2020 - Bward7864: - Allow overriding of tool level requirements when harvesting a block, via the HarvestCheck event. (#6632) - -========= -Build: 1.15.2-31.1.71 - Sun May 03 20:34:34 GMT 2020 - richard: - Fixed Hoppers not inserting fully into custom contains with slots that can hold more then max stack (#6631) - -========= -Build: 1.15.2-31.1.70 - Sun May 03 20:27:39 GMT 2020 - darklime: - Change recipe condition log level to debug. (#6621) - - darklime: - Fix vanilla loot table resource leak. (#6622) - - LordMonoxide: - Fixed ChunkDataEvent.Save being fired with a null world if chunk isn't fully generated when unloaded. (#6628) - -========= -Build: 1.15.2-31.1.67 - Sun May 03 20:21:40 GMT 2020 - 41904979+CAS-ual-TY: - Fix milk buckets removing potion effects without filters. (#6609) - -========= -Build: 1.15.2-31.1.66 - Sun May 03 20:15:40 GMT 2020 - dion: - Added missing localization for swim speed, and reach distance attributes (#6585) - -========= -Build: 1.15.2-31.1.65 - Sun May 03 20:09:37 GMT 2020 - williewillus: - Allow colors of tooltip to be specified in GuiUtils.drawHoveringText tooltip methods (#6579) - -========= -Build: 1.15.2-31.1.64 - Sun May 03 19:56:55 GMT 2020 - ichttt: - Fix config comments referencing disallowed enum values. (#6542) - -========= -Build: 1.15.2-31.1.63 - Tue Apr 28 17:23:47 GMT 2020 - David Quintana: - Remove redundant call to modifyLoot. Closes #6657 - -========= -Build: 1.15.2-31.1.62 - Tue Apr 28 04:02:06 GMT 2020 - tterrag: - Fix various issues with the loading screen and datagen - - Fix NPE on datagen startup - Fix early loading GUI hanging and never terminating after datagen - Add loading GUI messages for datagen - -========= -Build: 1.15.2-31.1.61 - Mon Apr 27 18:06:44 GMT 2020 - weiland: - Fix BackgroundScanHandler crashing on servers (#6660) - -========= -Build: 1.15.2-31.1.60 - Mon Apr 27 13:55:33 GMT 2020 - cpw: - Remove silly icon override. Squirrels are fun y'all.. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.59 - Mon Apr 27 05:10:06 GMT 2020 - tterrag: - Fix VariantList calling deprecated bake method - - tterrag: - Rename window icon image to avoid conflict, fix not using vanilla icon - -========= -Build: 1.15.2-31.1.57 - Mon Apr 27 03:06:13 GMT 2020 - lex: - Fix Automatic Event Subscriber not detecting mod id defaults, and fix test mods. - - lex: - Fix resource packs not being sorted properly. Closes #6287 - -========= -Build: 1.15.2-31.1.55 - Mon Apr 27 01:42:42 GMT 2020 - roguelogix: - move handOffWindow down near start() - - roguelogix: - Move ClientVisualization to secondary thread - - cpw: - Handle message display a bit better, try to make the UI tick a bit better.. Still a problem with - a modelbake right at the end, happening on the window flip. - - Signed-off-by: cpw - - cpw: - Use forge logo as short term window Icon, fix Buffer cast problems for new JDK stupid. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.51 - Sun Apr 26 22:25:05 GMT 2020 - cpw: - merge early startup into main window if used. It seems to work well.. Also ticks window on main thread, so mac compatible now. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.50 - Sat Apr 25 21:55:22 GMT 2020 - cpw: - Update jenkinsfile and gradle for new versions of things.. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.49 - Sat Apr 25 02:19:14 GMT 2020 - lex: - Fix potential NPEs in RegistryObject.orElseThrow/isPresent/ifPresent Closes #6647 - -========= -Build: 1.15.2-31.1.48 - Thu Apr 23 12:57:42 GMT 2020 - David Quintana: - Add tickRate setter to the ForgeFlowingFluid Properties builder. - -========= -Build: 1.15.2-31.1.47 - Mon Apr 20 01:37:16 GMT 2020 - cpw: - Fix recursion mess in PlayerAdvancement loading, by using an alternative based on a toposorted list of all advancements. - It seems to be fully equivalent in testing, but there may be corner cases, so there is a config to disable, though disabling - may break servers, especially those chunkloading fake players. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.46 - Wed Apr 15 17:10:05 GMT 2020 - lex: - Revert defualt jvm args. - -========= -Build: 1.15.2-31.1.45 - Wed Apr 15 06:54:47 GMT 2020 - lex: - Fixed dev time compilation using J9+ producing incorrect bytecode. - -========= -Build: 1.15.2-31.1.44 - Sun Apr 12 19:27:19 GMT 2020 - David Quintana: - Add "type" field to global loot modifier jsons. (#6554) - - * Add "type" field to global loot modifier jsons and fix tests. - To avoid binary breaking, "type" defaults to be the same as the filename. - * Fix license headers. - -========= -Build: 1.15.2-31.1.43 - Sat Apr 11 06:03:58 GMT 2020 - tterrag: - Fix child annotations not inheriting member name, cleanup - -========= -Build: 1.15.2-31.1.42 - Sat Apr 11 05:20:15 GMT 2020 - tterrag: - Fix element type of scanned child annotations - -========= -Build: 1.15.2-31.1.41 - Thu Apr 09 00:19:35 GMT 2020 - 28677702+patrick-aoc: - Fixed PlantType not extending IExtensibleEnum, Closes #6286 - -========= -Build: 1.15.2-31.1.40 - Thu Apr 09 00:12:15 GMT 2020 - 46117728+valoeghese: - Added hook to allow modded Hill Biomes (#6571) - -========= -Build: 1.15.2-31.1.39 - Wed Apr 08 01:45:04 GMT 2020 - tterrag: - Revive forge lighting pipeline, disabled by default for now - - Remove a lot of light value convolution by using 0..1 for nearly everything - Fix a lot of TODOs that are needed for the lighting pipeline to function - Potential fix for #6425 - - tterrag: - Improve performance of VertexBufferConsumer by inlining element locs - -========= -Build: 1.15.2-31.1.37 - Sun Apr 05 04:50:22 GMT 2020 - tterrag: - Fix Tag serializing empty optionals, improve RegistryObject error msg - -========= -Build: 1.15.2-31.1.36 - Sat Apr 04 19:36:37 GMT 2020 - tterrag: - Remove SideOnly from WoodType methods - -========= -Build: 1.15.2-31.1.35 - Wed Apr 01 19:38:28 GMT 2020 - lex: - Cleanup IForgeTagBuilder code style. - -========= -Build: 1.15.2-31.1.34 - Wed Apr 01 00:16:26 GMT 2020 - tterrag: - Add support for optional tag values to Tag.Builder - - Add optional tag values to data gen test - Fix data gen test not running by correcting gui_light value - - tterrag: - Move global loot test data files out of generated folder - -========= -Build: 1.15.2-31.1.32 - Tue Mar 31 23:57:39 GMT 2020 - tterrag: - Deprecate ModelBuilder#gui3d, add ModelBuilder#guiLight - - tterrag: - Fix a few issues with BufferBuilder - - Fix vanilla bug that caused the byte order of the buffer from getNextBuffer to be incorrect - Fix missing modification to nextElementBytes in putBulkData - -========= -Build: 1.15.2-31.1.30 - Fri Mar 27 23:26:45 GMT 2020 - naqaden: - Add renderer to RenderNameplateEvent (#6562) - -========= -Build: 1.15.2-31.1.29 - Fri Mar 27 23:19:42 GMT 2020 - dags-: - Defer writing the server.properties file until after mods have loaded to prevent config loss (#6545) - -========= -Build: 1.15.2-31.1.28 - Fri Mar 27 23:10:32 GMT 2020 - 36975818+hnOsmium0001: - Fix ownership leak in ItemStackHandler (#6580) - - - Triggered by invoking ItemStackHandler#extractItem with `simulate=true` - -========= -Build: 1.15.2-31.1.27 - Sat Mar 21 00:06:03 GMT 2020 - cpw: - Fix cycle happening in noteblock even though we're setting the new value as well.. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.26 - Fri Mar 20 21:35:06 GMT 2020 - cpw: - Add a progress message for atlas textures. Fills a big time gap on bigger packs. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.25 - Tue Mar 17 09:41:49 GMT 2020 - bjfccb: - Remove ArrowEntity patch, vanilla fixed MC-107941 - -========= -Build: 1.15.2-31.1.24 - Sun Mar 15 23:28:36 GMT 2020 - lex: - Fix Forge's tps and gen commands. - -========= -Build: 1.15.2-31.1.23 - Sun Mar 15 20:55:21 GMT 2020 - lex: - Update gradle wrapper - Update MCPConfig to version that bypasses javac compiler bugs - Fix Global loot test compile errors. - -========= -Build: 1.15.2-31.1.22 - Sun Mar 15 07:39:18 GMT 2020 - tterrag: - Fix loading text not rendering after mojang logo appears - -========= -Build: 1.15.2-31.1.21 - Sun Mar 15 07:28:02 GMT 2020 - tterrag: - Fix loading GUI corrupting matrix state - -========= -Build: 1.15.2-31.1.20 - Sun Mar 15 03:29:03 GMT 2020 - cpw: - Somewhat restore the loading screen overlay. It seems that once the mojang logo and progress bar - start running, I can no longer write to the window, even though I am obviously trying to.. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.19 - Wed Mar 11 07:00:30 GMT 2020 - 17338378+Nightenom: - Add projection matrix to RenderWorldLastEvent (#6536) - -========= -Build: 1.15.2-31.1.18 - Thu Feb 27 06:13:47 GMT 2020 - draco18s: - Global Loot Functions (#6401) - -========= -Build: 1.15.2-31.1.17 - Wed Feb 26 03:45:24 GMT 2020 - Colby Prince: - Updated ForgeDev MCP Mapping Version (#6532) - -========= -Build: 1.15.2-31.1.16 - Mon Feb 24 03:17:00 GMT 2020 - cpw: - Fix up alarming security crisis with network handling that allowed for wrong code execution on the server, resulting in CRASHED SERVERS. AWFUL stuff. - - Also fixed a silly log message from the login handler. - - This change introduces a mechanism to direct certain packets to only process on one side or another. Invalid sidedness will result in the connection being terminated. - - Signed-off-by: cpw - -========= -Build: 1.15.2-31.1.15 - Sun Feb 23 17:32:42 GMT 2020 - julian.dunskus: - Make TransformationHelper.slerp for quaternions public (#6528) - -========= -Build: 1.15.2-31.1.14 - Mon Feb 17 19:01:48 GMT 2020 - Colby Prince: - Fixed Conduit and Beacon Activation on Vanilla Servers (#6438) - -========= -Build: 1.15.2-31.1.13 - Mon Feb 17 16:16:56 GMT 2020 - richard: - Fix ITeleporter being ignored when teleporting from the end to the overworld (#6505) - - * Fix custom teleporters triggering end credits when returning from the end - * Fix setdimension command ignoring position - -========= -Build: 1.15.2-31.1.12 - Fri Feb 14 21:43:40 GMT 2020 - williewillus: - Fix missing call to itemstack TER (#6445) - -========= -Build: 1.15.2-31.1.11 - Fri Feb 14 21:33:36 GMT 2020 - williewillus: - Fix missed modeldata passing in BlockModelRenderer (#6442) - -========= -Build: 1.15.2-31.1.10 - Fri Feb 14 20:34:50 GMT 2020 - treborx555: - Fix NPE when players rejoin the server in a dimension that was deleted (#6511) - -========= -Build: 1.15.2-31.1.9 - Fri Feb 14 20:16:05 GMT 2020 - loic.frasse-mathon: - Fix a wrong RenderState name MC-167447 (#6501) - -========= -Build: 1.15.2-31.1.8 - Fri Feb 14 20:09:19 GMT 2020 - malte0811: - Fixed ChunkWatchEvent.(Un)Watch not firing correctly (#6453) - - ewewukek: - Fix wrong arguments passed to ForgeHooksClient.renderSpecificFirstPersonHand() (#6496) - - 12281102+Aeltumn: - Fix client not informing server when it attempts to interact with things, and is canceled by a client side handler. - -========= -Build: 1.15.2-31.1.5 - Fri Feb 14 20:02:26 GMT 2020 - joetarbit: - Fixed Food not using effect suppliers, to better support delayed initialization and registry replacements. (#6411) - - Unnoen: - Update version and support data on README. (#6429) - -========= -Build: 1.15.2-31.1.3 - Fri Feb 14 19:55:38 GMT 2020 - hawkeboyz2: - Fixed displaying item names when only more sensitive version changes (#6402) - -========= -Build: 1.15.2-31.1.2 - Fri Feb 14 18:28:35 GMT 2020 - David Quintana: - Fix gui_light for forge's item parent models. - -========= -Build: 1.15.2-31.1.1 - Thu Feb 06 22:53:49 GMT 2020 - richard: - Allows custom blocks to define if they should use the fluid overlay instead of the flowing texture when in a fluid (#6493) - -========= -Build: 1.15.2-31.1.0 - Mon Feb 03 21:24:29 GMT 2020 - lex: - Fix a small patch misalignment. - -========= -Build: 1.15.2-31.0.19 - Mon Feb 03 20:52:28 GMT 2020 - richard: - Add FluidStack support to the Forge packet buffer. (#6353) (#6485) - - richard: - Make Minecarts work with modded powered/activator rails. (#6486) - - Re-adds functionality for rails to have different maximum speeds. - -========= -Build: 1.15.2-31.0.17 - Mon Feb 03 20:21:20 GMT 2020 - ichttt: - Revert game data to frozen on disconnect from a remote server or when terminating a local server. Closes #6487 (#6497) - -========= -Build: 1.15.2-31.0.16 - Sun Feb 02 22:11:19 GMT 2020 - David Quintana: - Remove unintended changes. - -========= -Build: 1.15.2-31.0.15 - Sun Feb 02 22:03:15 GMT 2020 - David Quintana: - Implement fluid overlay texture rendering for custom fluids. - -========= -Build: 1.15.2-31.0.14 - Thu Jan 30 06:12:15 GMT 2020 - Colby Prince: - Fixed Attacks/Punches not Registering (#6481) - - Replaced incorrect magic number with constant - -========= -Build: 1.15.2-31.0.13 - Wed Jan 29 23:46:30 GMT 2020 - williewillus: - Clean up a bunch of render events (#6444) - - * Delete RenderHandEvent as RenderSpecificHandEvent can do everything it does and more. Rename RenderSpecificHandEvent to RenderHandEvent as it's now the only hand rendering event. - * Pass MatrixStack and IRenderTypeBuffer into the event whenever they are available. If they're available, that means we're in a batching environment and the modder should not be using the tessellator or other buffers on their own, or they risk "Already building" crashes. - -========= -Build: 1.15.2-31.0.12 - Wed Jan 29 21:55:18 GMT 2020 - Barteks2x: - Fix NullPointerException on java 8u242 in dev environment. (#6473) - - Java 8u242 no longer re-initializes internal sys_paths and usr_paths fields in loadLibrary when they are null, so the value can't be set to null. - -========= -Build: 1.15.2-31.0.11 - Wed Jan 29 21:18:05 GMT 2020 - 12281102+Aeltumn: - Fix RightClickBlock code differences between client and server implementation (#6451) - - williewillus: - Fix incorrectly ported patch for restoreBlurMipmap (#6450) - -========= -Build: 1.15.2-31.0.9 - Wed Jan 29 21:11:24 GMT 2020 - 40495288+Yamahari: - Defer material getting for ChestTileEntityRenderer into seperate function (#6465) - -========= -Build: 1.15.2-31.0.8 - Wed Jan 29 21:04:44 GMT 2020 - 37298044+Cadiboo: - Small Forge config fixes (#6466) - -========= -Build: 1.15.2-31.0.7 - Wed Jan 29 20:50:44 GMT 2020 - lex: - Fix PlayerChangedDimensionEvent using incorrect from dimension argument in ServerPlayerEntity.teleport. Closes #6457 - - lex: - Fix incorrect keybinding modifiers patch. Closes #6478 - - lex: - Fix ChunkDataEvent.Load not firing, it now fires in the aync thread. Be careful. Closes #6471 - -========= -Build: 1.15.2-31.0.4 - Wed Jan 29 19:31:50 GMT 2020 - lex: - Fix WakeupEvent patch misalign. Closes #6474 - - lex: - Fix default mod resources loosing it's sort order. - -========= -Build: 1.15.2-31.0.2 - Wed Jan 29 17:26:58 GMT 2020 - goto.minecraft: - [1.15] Reimplemented the ITeleporter interface (#6404) - -========= -Build: 1.15.2-31.0.1 - Thu Jan 23 21:59:18 GMT 2020 - David Quintana: - Hook "gui_light" value from the model into the IBakedModel implementations. - Apply some of the suggestions from the 1.14 models PR. - -========= -Build: 1.15.2-31.0.0 - Wed Jan 22 21:47:51 GMT 2020 - lex: - 1.15.2 Initial Update - -========= -Build: 1.15.1-30.0.51 - Wed Jan 22 21:10:07 GMT 2020 - ichttt: - Cleanup fml packages removing old deprecated classes related to GUIs/Configs and fix HoverChecker (#6437) - - Fixed ModListWidget name to avoid confusion and collision. - Delete CheckBox, as vanilla has it's own CheckBox now which looks much better - Rename ModConfigEvent.ConfigReloading to ModConfigEvent.Reloading - -========= -Build: 1.15.1-30.0.50 - Wed Jan 22 20:38:22 GMT 2020 - 12281102+Aeltumn: - Fixed parameter name issue in ISTER rename. #6461 (#6468) - -========= -Build: 1.15.1-30.0.49 - Wed Jan 22 19:56:16 GMT 2020 - lex: - Fix default widget foreground color. - -========= -Build: 1.15.1-30.0.48 - Wed Jan 22 19:30:35 GMT 2020 - diesieben07: - Use extended version of getLightValue in all places (#6433) - - Bward7864: - Fixed RenderTypeLookup loosing mappings for registry replacements. (#6452) - - wynprice999: - Fixed rounding issue with entity navigation fix (#6455) (#6456) - - 37298044+Cadiboo: - Fix Widget Foreground Color not allowing pure black (#6460) - - 12281102+Aeltumn: - Updated method names referencing ItemStackTileEntityRenderer (#6461) - -========= -Build: 1.15.1-30.0.43 - Wed Jan 22 19:22:15 GMT 2020 - scottehboeh: - [1.15.x] Added entity nameplate rendering event hook (#6416) - -========= -Build: 1.15.1-30.0.42 - Tue Jan 21 03:47:02 GMT 2020 - tterrag: - Remove emissive items hook, add small utility for bakedquad lighting - -========= -Build: 1.15.1-30.0.41 - Thu Jan 16 02:30:04 GMT 2020 - David Quintana: - Fix breaking overlay weirdness. applyBakedNormals was not transforming the baked normals when applying them. Fixes #6432 - -========= -Build: 1.15.1-30.0.40 - Thu Jan 16 00:30:10 GMT 2020 - 12281102+Aeltumn: - [1.15] Add new InputEvent.ClickInputEvent, addresses #5802 (#6047) - -========= -Build: 1.15.1-30.0.39 - Mon Jan 13 22:21:01 GMT 2020 - David Quintana: - Fix dark spots in fullbright quad rendering. - Fix multi-layer model not declaring dependency on the particle texture. - Fix mistake in 2c054fca which I didn't intend to push when I did. - -========= -Build: 1.15.1-30.0.38 - Mon Jan 13 18:39:06 GMT 2020 - David Quintana: - Attempt to fix fullbright lighting. - - Fix lightmap value calculation. - - David Quintana: - Fix multi-layer model loader to actually work in a sane way. No more "base" model involved, and now transforms and overrides work as expected. - -========= -Build: 1.15.1-30.0.36 - Thu Jan 09 22:28:02 GMT 2020 - tterrag: - Add constructor for FishBucketItem that accepts suppliers - -========= -Build: 1.15.1-30.0.35 - Tue Jan 07 22:58:54 GMT 2020 - David Quintana: - Fix QuadTransformer normal processing. - - Choonster.2010: - Fix validation in RotationBuilder#angle (fixes #6323) (#6408) - -========= -Build: 1.15.1-30.0.33 - Tue Jan 07 22:20:46 GMT 2020 - richard: - Add support for custom nether portal frame blocks (#6389) - -========= -Build: 1.15.1-30.0.32 - Tue Jan 07 21:22:49 GMT 2020 - RANKSHANK: - InputEvent.RawMouseEvent fix (#6395) - -========= -Build: 1.15.1-30.0.31 - Tue Jan 07 21:15:19 GMT 2020 - Colby Prince: - Fixed Big Mushrooms not generating (#6390) - - Removed vanilla negation from Forge logic that negated the vanilla logic it was replacing - also ran datagen to update the dirt tag to reflect changes that were previously made in the datagen code - -========= -Build: 1.15.1-30.0.30 - Mon Jan 06 00:04:17 GMT 2020 - tterrag: - Fix dyes tag containing dye items instead of tags - - Update generated data - -========= -Build: 1.15.1-30.0.29 - Sun Jan 05 19:36:08 GMT 2020 - Choonster.2010: - [1.15.x] Remove unused parameter from ElementBuilder#rotation (fixes #6321) (#6407) - -========= -Build: 1.15.1-30.0.28 - Sun Jan 05 19:29:10 GMT 2020 - tterrag: - Refactor BlockStateProvider to encapsulate a BlockModelProvider - - Make most protected methods of data generators public - -========= -Build: 1.15.1-30.0.27 - Sun Jan 05 18:39:00 GMT 2020 - tterrag: - Fix crash when building BakedQuadBuilder - - Add javadocs and move sprite to constructor where possible - -========= -Build: 1.15.1-30.0.26 - Sun Jan 05 05:05:58 GMT 2020 - tterrag: - Fix incorrect check for missing texture in DynamicBucketModel - -========= -Build: 1.15.1-30.0.25 - Sun Jan 05 04:38:48 GMT 2020 - tterrag: - Remove custom vertex format from BakedQuad - -========= -Build: 1.15.1-30.0.24 - Sat Jan 04 16:19:24 GMT 2020 - David Quintana: - Cherry-pick ca819e09 from the 1.14.x branch. Removes a patch from NativeImage which was invalid. - - David Quintana: - A few more binary-breaking changes, before it's too late: - - Move CompositeModel out of its package. - - Move a few inner classes from the OBJ loader. - - Rename the bucket model and fluid model classes to match the naming convention. - - Remove BiomeEvent.* and WorldTypeEvent.InitBiomeGens as they are not currently implemented and they haven't been in the previous version either. - -========= -Build: 1.15.1-30.0.22 - Fri Jan 03 03:02:54 GMT 2020 - lex: - Fix the particle renderer not setting GL state between each type. MC-168672 - -========= -Build: 1.15.1-30.0.21 - Thu Jan 02 05:21:55 GMT 2020 - David Quintana: - Fix CompositeModel not respecting "display" transforms. - Remove leftovers from discarded feature. - -========= -Build: 1.15.1-30.0.20 - Wed Jan 01 16:41:59 GMT 2020 - David Quintana: - Allow model jsons to override the material library used by OBJ models. - Fix model loader test mod resources. - Update licenses. - -========= -Build: 1.15.1-30.0.19 - Mon Dec 30 21:14:20 GMT 2019 - tterrag: - Apply baked-in lightmap data to rendering - - - Fix ForgeHooksClient.fillNormal injecting data to lightmap - - Fix OBJModel not filling lightmap data - - Fix NewModelLoaderTest blockitem not linking with block - -========= -Build: 1.15.1-30.0.18 - Sun Dec 29 16:16:44 GMT 2019 - David Quintana: - Fix LightUtil.unpack to set the 4th component to 1 when expanding an xyz position into a 4-component vector. - Add TRSRTransformer test mod. - Fix signature of the bindTileEntityRenderer method, to account for covariance. - -========= -Build: 1.15.1-30.0.17 - Sun Dec 29 01:16:20 GMT 2019 - David Quintana: - More model/rendering fixes: - - Breaking change: Change ClientRegistry.bindTileEntityRenderer to a factory, so mods don't have to manually specify the dispatcher. - - Breaking change: Delete obsolete SimpleModelState (the class was duplicated by mistake, see SimpleModelTransform) and ICustomModelState (part of the old loader API). - - Breaking change: Rename getTextureDependencies to getTextures, for consistency. - - Reinstate the getRenderLayer method, fixed appropriately to return the new RenderType value. - - Fix OBJ loader applying the model transform in the wrong reference frame. - - Fix vanilla bug in TransformationMatrix#func_227986_a_ - - Fix QuadTransformer logic. - - Added new method to IModelConfiguration to retrieve the owner IUnbakedModel, needed in order to construct ItemOverrideLists when baking custom models. - - Reintroduce multi-layer model through the new model loader system. - -========= -Build: 1.15.1-30.0.16 - Tue Dec 24 12:16:17 GMT 2019 - David Quintana: - New batch of Model/rendering fixes: - - PerspectiveMapWrapper did not pass IModelData through to the wrapped model. - - CompositeModel did not store the returned textures from getTextureDependencies. - - VertexFormat used COLOR instead of UV to detect UV presence. - - QuadTransformer would crash due to index out of bounds. - - Small cleanup of TransformationHelper - -========= -Build: 1.15.1-30.0.15 - Fri Dec 20 17:15:21 GMT 2019 - David Quintana: - Fix obj models having all faces in the same mesh, breaking material assignments and visibility in the process. - Reintroduce lost patch from the model loader, which would cause the custom values to be missing from generated models. - -========= -Build: 1.15.1-30.0.14 - Fri Dec 20 04:14:34 GMT 2019 - tterrag: - Fix diffuse lighting being baked into models, fixes dark items - -========= -Build: 1.15.1-30.0.13 - Fri Dec 20 03:50:53 GMT 2019 - David Quintana: - Fix item quads not using the existing vertex color when applying tint colors. - -========= -Build: 1.15.1-30.0.12 - Fri Dec 20 01:44:40 GMT 2019 - David Quintana: - Fix bucket model. Some mask textures were not added to the repository, and the bucket override generation was broken. - Fix OBJ loading crash due to a float value being parsed as int. - Fixes 6377 - -========= -Build: 1.15.1-30.0.11 - Thu Dec 19 05:56:10 GMT 2019 - bl4ckscor33: - Fix game crashing when modded entities are present (#6364) - -========= -Build: 1.15.1-30.0.10 - Thu Dec 19 05:02:29 GMT 2019 - ichttt: - Fix warning screen about missing minecraft registry entries (#6363) - - richard: - Fix capabilities becoming inaccessible on returning from end (#6368) - -========= -Build: 1.15.1-30.0.8 - Thu Dec 19 04:39:52 GMT 2019 - ichttt: - Some code cleanup for 1.15 (#6362) - -========= -Build: 1.15.1-30.0.7 - Wed Dec 18 02:11:01 GMT 2019 - tterrag: - Fix MainMenuScreen patch - - tterrag: - Mod list GUI detail pass - - - Make padding consistent on all elements - - Properly horizontally center the "Search" text - - Update and resize forge/mcp logos - - Enable linear filtering on logo rendering by default - - Can be disabled with the "logoBlur" mods.toml property - -========= -Build: 1.15.1-30.0.5 - Wed Dec 18 01:03:20 GMT 2019 - ichttt: - Fix mod list screen (#6367) - -========= -Build: 1.15.1-30.0.4 - Tue Dec 17 23:47:00 GMT 2019 - David Quintana: - Fix items in ground being too small, we were applying perspectives twice. - Restore forge patch and fix a tiny mistake in it. - - tobias.hotz: - Fix keybinds not loading/saving correctly - -========= -Build: 1.15.1-30.0.2 - Tue Dec 17 22:38:00 GMT 2019 - tterrag: - Remove uvlock hook, fixes broken stair/fence/etc models - - tterrag: - Update fallback spec version - -========= -Build: 1.15.1-30.0.0 - Tue Dec 17 19:42:28 GMT 2019 - tterrag: - Update to 1.15.1 - -========= -Build: 1.15-29.0.4 - Tue Dec 17 18:15:10 GMT 2019 - David Quintana: - Finish converting the code from javax.vecmath to the vanilla vector classes. Forge is now vecmath-free! - -========= -Build: 1.15-29.0.3 - Tue Dec 17 09:50:53 GMT 2019 - tterrag: - Remove deprecations - -========= -Build: 1.15-29.0.2 - Tue Dec 17 04:47:01 GMT 2019 - tterrag: - Fix incorrect item lighting - -========= -Build: 1.15-29.0.1 - Tue Dec 17 04:22:29 GMT 2019 - tterrag: - Revert fluid change to use Material, fixes server crash diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..7454180 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1d5b29f..41dfb87 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..c53aefa 100644 --- a/gradlew +++ b/gradlew @@ -1,78 +1,129 @@ -#!/usr/bin/env sh +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +APP_BASE_NAME=${0##*/} # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -81,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" + JAVACMD=java which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the @@ -89,84 +140,95 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,28 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/pitheguy/magicmod/MagicMod.java b/src/main/java/com/pitheguy/magicmod/MagicMod.java index b2885ac..f737f7b 100644 --- a/src/main/java/com/pitheguy/magicmod/MagicMod.java +++ b/src/main/java/com/pitheguy/magicmod/MagicMod.java @@ -1,51 +1,45 @@ package com.pitheguy.magicmod; +import com.pitheguy.magicmod.client.entity.model.*; import com.pitheguy.magicmod.client.entity.render.*; -import com.pitheguy.magicmod.client.gui.MagicCrateScreen; -import com.pitheguy.magicmod.client.gui.MagicInfuserScreen; -import com.pitheguy.magicmod.client.gui.MagicPressScreen; -import com.pitheguy.magicmod.init.ModContainerTypes; -import com.pitheguy.magicmod.init.ModEntityTypes; -import com.pitheguy.magicmod.init.ModTileEntityTypes; -import com.pitheguy.magicmod.items.ModSpawnEggItem; +import com.pitheguy.magicmod.client.gui.*; +import com.pitheguy.magicmod.entities.FluffyMagician; +import com.pitheguy.magicmod.entities.MagicFriend; +import com.pitheguy.magicmod.init.*; import com.pitheguy.magicmod.util.RegistryHandler; -import com.pitheguy.magicmod.world.gen.ModOreGen; -import net.minecraft.client.gui.ScreenManager; +import net.minecraft.client.gui.screens.MenuScreens; +import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; -import net.minecraft.client.renderer.RenderTypeLookup; -import net.minecraft.entity.EntityType; -import net.minecraft.item.ItemGroup; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.client.event.EntityRenderersEvent; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.event.entity.EntityAttributeCreationEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.minecraftforge.fml.event.lifecycle.*; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod("magicmod") @Mod.EventBusSubscriber(modid = "magicmod", bus = EventBusSubscriber.Bus.MOD) -public class MagicMod -{ +public class MagicMod { public static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "magicmod"; public MagicMod() { final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - //modEventBus.addListener(this::setup); + modEventBus.addListener(this::setup); - //FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); RegistryHandler.init(); - ModTileEntityTypes.TILE_ENTITY_TYPES.register(modEventBus); + ModTileEntityTypes.BLOCK_ENTITY_TYPES.register(modEventBus); ModContainerTypes.CONTAINER_TYPES.register(modEventBus); ModEntityTypes.ENTITY_TYPES.register(modEventBus); @@ -53,35 +47,48 @@ public MagicMod() { } - /*private void setup(final FMLCommonSetupEvent event) - { - - }*/ + private void setup(final FMLCommonSetupEvent event) { + } private void doClientStuff(final FMLClientSetupEvent event) { - ScreenManager.registerFactory(ModContainerTypes.MAGIC_INFUSER.get(), MagicInfuserScreen::new); - ScreenManager.registerFactory(ModContainerTypes.MAGIC_CRATE.get(), MagicCrateScreen::new); - ScreenManager.registerFactory(ModContainerTypes.MAGIC_PRESS.get(), MagicPressScreen::new); - RenderTypeLookup.setRenderLayer(RegistryHandler.MAGIC_VEIN.get(), RenderType.getCutout()); - RenderTypeLookup.setRenderLayer(RegistryHandler.MAGIC_WEB.get(), RenderType.getCutout()); - RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.MAGIC_FRIEND.get(), MagicFriendRender::new); - RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.FLUFFY_MAGICIAN.get(), FluffyMagicianRender::new); - RenderingRegistry.registerEntityRenderingHandler(ModEntityTypes.FLUFFY_MAGICIAN_BARE.get(), FluffyMagicianBareRender::new); + MenuScreens.register(ModContainerTypes.MAGIC_INFUSER.get(), MagicInfuserScreen::new); + MenuScreens.register(ModContainerTypes.MAGIC_CRATE.get(), MagicCrateScreen::new); + MenuScreens.register(ModContainerTypes.MAGIC_PRESS.get(), MagicPressScreen::new); + MenuScreens.register(ModContainerTypes.MAGIC_ENERGIZER.get(), MagicEnergizerScreen::new); + MenuScreens.register(ModContainerTypes.MAGIC_MINER.get(), MagicMinerScreen::new); + MenuScreens.register(ModContainerTypes.MAGIC_LOGGER.get(), MagicLoggerScreen::new); + ItemBlockRenderTypes.setRenderLayer(RegistryHandler.MAGIC_VEIN.get(), RenderType.cutout()); + ItemBlockRenderTypes.setRenderLayer(RegistryHandler.MAGIC_WEB.get(), RenderType.cutout()); } @SubscribeEvent public static void loadCompleteEvent(FMLLoadCompleteEvent event) { - ModOreGen.generateOre(); } @SubscribeEvent - public static void onRegisterEntities(final RegistryEvent.Register> event) { - ModSpawnEggItem.initSpawnEggs(); + public static void registerLayers(EntityRenderersEvent.RegisterLayerDefinitions event) { + event.registerLayerDefinition(MagicFriendModel.LAYER_LOCATION, MagicFriendModel::createBodyLayer); + event.registerLayerDefinition(FluffyMagicianModel.LAYER_LOCATION, FluffyMagicianModel::createBodyLayer); + event.registerLayerDefinition(FluffyMagicianBareModel.LAYER_LOCATION, FluffyMagicianBareModel::createBodyLayer); + } + + @SubscribeEvent + public static void registerRenderers(EntityRenderersEvent.RegisterRenderers event) { + event.registerEntityRenderer(ModEntityTypes.MAGIC_FRIEND.get(), MagicFriendRender::new); + event.registerEntityRenderer(ModEntityTypes.FLUFFY_MAGICIAN.get(), FluffyMagicianRender::new); + event.registerEntityRenderer(ModEntityTypes.FLUFFY_MAGICIAN_BARE.get(), FluffyMagicianBareRender::new); + } + + @SubscribeEvent + public static void onRegisterEntityAttributes(EntityAttributeCreationEvent event) { + event.put(ModEntityTypes.FLUFFY_MAGICIAN.get(), FluffyMagician.createAttributes()); + event.put(ModEntityTypes.FLUFFY_MAGICIAN_BARE.get(), FluffyMagician.createAttributes()); + event.put(ModEntityTypes.MAGIC_FRIEND.get(), MagicFriend.createAttributes()); } - public static final ItemGroup TAB = new ItemGroup("magicTab") { + public static final CreativeModeTab TAB = new CreativeModeTab("magicTab") { @Override - public ItemStack createIcon() { + public ItemStack makeIcon() { return new ItemStack(RegistryHandler.MAGIC_GEM.get()); } }; diff --git a/src/main/java/com/pitheguy/magicmod/armor/CustomArmorMagic.java b/src/main/java/com/pitheguy/magicmod/armor/CustomArmorMagic.java index 4d18be1..3c21ccc 100644 --- a/src/main/java/com/pitheguy/magicmod/armor/CustomArmorMagic.java +++ b/src/main/java/com/pitheguy/magicmod/armor/CustomArmorMagic.java @@ -1,33 +1,33 @@ package com.pitheguy.magicmod.armor; import com.pitheguy.magicmod.util.ArmorHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.IArmorMaterial; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraft.world.World; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public class CustomArmorMagic extends ArmorItem { - public CustomArmorMagic(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { + public CustomArmorMagic(ArmorMaterial materialIn, EquipmentSlot slot, Properties builder) { super(materialIn, slot, builder); } @Override - public void onArmorTick(ItemStack itemstack, World world, PlayerEntity player) { + public void onArmorTick(ItemStack itemstack, Level world, Player player) { if (ArmorHandler.isWearingObsidianPlatedReinforcedMagicArmor(player)) { - player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 2, 3, true, false)); - player.addPotionEffect(new EffectInstance(Effects.SATURATION, 1, 0, true, false)); - player.addPotionEffect(new EffectInstance(Effects.SPEED, 1, 1, true, false)); - player.abilities.allowFlying = true; + player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 2, 3, true, false)); + player.addEffect(new MobEffectInstance(MobEffects.SATURATION, 1, 0, true, false)); + player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 1, 1, true, false)); + player.getAbilities().mayfly = true; } else { if (ArmorHandler.isWearingReinforcedMagicArmor(player)) - player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 2, 1, true, false)); - if (!player.abilities.isCreativeMode && player.abilities.allowFlying) { - player.abilities.allowFlying = false; - player.abilities.isFlying = false; + player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 2, 1, true, false)); + if (!player.getAbilities().instabuild && player.getAbilities().mayfly) { + player.getAbilities().mayfly = false; + player.getAbilities().flying = false; } } } diff --git a/src/main/java/com/pitheguy/magicmod/armor/ModArmorMaterials.java b/src/main/java/com/pitheguy/magicmod/armor/ModArmorMaterials.java index 64e3596..085e99b 100644 --- a/src/main/java/com/pitheguy/magicmod/armor/ModArmorMaterials.java +++ b/src/main/java/com/pitheguy/magicmod/armor/ModArmorMaterials.java @@ -1,21 +1,21 @@ package com.pitheguy.magicmod.armor; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.IArmorMaterial; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.SoundEvent; -import net.minecraft.util.SoundEvents; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ArmorMaterial; +import net.minecraft.world.item.crafting.Ingredient; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import java.util.function.Supplier; -public enum ModArmorMaterials implements IArmorMaterial { +public enum ModArmorMaterials implements ArmorMaterial { - MAGIC("magicmod:magic", 1200, new int[] {50,105,125,50}, 40, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 20, () -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get())), - REINFORCED_MAGIC("magicmod:reinforced_magic", 7500, new int[] {120,225,275,120}, 60, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 75, () -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get())), - OBSIDIAN_PLATED_REINFORCED_MAGIC("magicmod:obsidian_plated_reinforced_magic", 20000, new int[] {300,550,675,300}, 80, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 175, () -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get())); + MAGIC("magicmod:magic", 1200, new int[] {50,105,125,50}, 40, SoundEvents.ARMOR_EQUIP_DIAMOND, 20, 0, () -> Ingredient.of(RegistryHandler.MAGIC_GEM.get())), + REINFORCED_MAGIC("magicmod:reinforced_magic", 7500, new int[] {120,225,275,120}, 60, SoundEvents.ARMOR_EQUIP_DIAMOND, 75, 0, () -> Ingredient.of(RegistryHandler.MAGIC_GEM.get())), + OBSIDIAN_PLATED_REINFORCED_MAGIC("magicmod:obsidian_plated_reinforced_magic", 20000, new int[] {300,550,675,300}, 80, SoundEvents.ARMOR_EQUIP_DIAMOND, 175, 0, () -> Ingredient.of(RegistryHandler.MAGIC_GEM.get())); private static final int[] MAX_DAMAGE_ARRAY = new int[] {11,16,15,13}; private final String name; @@ -24,40 +24,42 @@ public enum ModArmorMaterials implements IArmorMaterial { private final int enchantability; private final SoundEvent soundEvent; private final float toughness; + private final float knockbackResistance; private final Supplier repairMaterial; - ModArmorMaterials(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, Supplier repairMaterial){ + ModArmorMaterials(String name, int maxDamageFactor, int[] damageReductionAmountArray, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier repairMaterial){ this.name = name; this.maxDamageFactor = maxDamageFactor; this.damageReductionAmountArray = damageReductionAmountArray; this.enchantability = enchantability; this.soundEvent = soundEvent; this.toughness = toughness; + this.knockbackResistance = knockbackResistance; this.repairMaterial = repairMaterial; } @Override - public int getDurability(EquipmentSlotType slotIn) { + public int getDurabilityForSlot(EquipmentSlot slotIn) { return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * maxDamageFactor; } @Override - public int getDamageReductionAmount(EquipmentSlotType slotIn) { + public int getDefenseForSlot(EquipmentSlot slotIn) { return damageReductionAmountArray[slotIn.getIndex()]; } @Override - public int getEnchantability() { + public int getEnchantmentValue() { return enchantability; } @Override - public SoundEvent getSoundEvent() { + public SoundEvent getEquipSound() { return soundEvent; } @Override - public Ingredient getRepairMaterial() { + public Ingredient getRepairIngredient() { return repairMaterial.get(); } @OnlyIn(Dist.CLIENT) @@ -70,4 +72,9 @@ public String getName() { public float getToughness() { return toughness; } + + @Override + public float getKnockbackResistance() { + return knockbackResistance; + } } diff --git a/src/main/java/com/pitheguy/magicmod/blockentity/AutoActionBlockEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/AutoActionBlockEntity.java new file mode 100644 index 0000000..6fc2c17 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blockentity/AutoActionBlockEntity.java @@ -0,0 +1,299 @@ +package com.pitheguy.magicmod.blockentity; + +import com.google.common.annotations.VisibleForTesting; +import com.pitheguy.magicmod.MagicMod; +import com.pitheguy.magicmod.util.ModItemHandler; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; + +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.List; +import java.util.stream.IntStream; + +public abstract class AutoActionBlockEntity extends BlockEntity implements MenuProvider { + public static final List MINE_BLACKLIST = Arrays.asList(Blocks.LAVA, Blocks.WATER); + protected final ModItemHandler inventory; + public volatile Status status; + @Nullable public MagicEnergizerBlockEntity fuelSourceTileEntity = null; + public int mineCooldown = 60; + public static final int BASE_TICKS_PER_MINE = 60; + public final int baseRange; + public final int rangeIncreaseWithUpgrade; + public final int rangeIncreaseWithObsidianPlatedUpgrade; + public int ticksPerMine = BASE_TICKS_PER_MINE; + public int range; + protected final int direction; + protected final boolean invertedDirection; + @Nullable protected Block filterBlock; + + public AutoActionBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state, int baseRange, int rangeIncreaseWithUpgrade, int rangeIncreaseWithObsidianPlatedUpgrade, MineableArea mineableArea) { + super(tileEntityTypeIn, pos, state); + this.baseRange = baseRange; + this.range = this.baseRange; + this.rangeIncreaseWithUpgrade = rangeIncreaseWithUpgrade; + this.rangeIncreaseWithObsidianPlatedUpgrade = rangeIncreaseWithObsidianPlatedUpgrade; + this.inventory = new ModItemHandler(38); + this.direction = mineableArea.getDirection(); + this.invertedDirection = direction >= 0; + } + + @Override + public void load(CompoundTag compound) { + super.load(compound); + NonNullList inv = NonNullList.withSize(this.inventory.getSlots(), ItemStack.EMPTY); + ContainerHelper.loadAllItems(compound, inv); + this.inventory.setNonNullList(inv); + this.mineCooldown = compound.getInt("mineCooldown"); + } + + @Override + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); + ContainerHelper.saveAllItems(compound, this.inventory.toNonNullList()); + compound.putInt("mineCooldown", this.mineCooldown); + compound.putString("status", this.getStatus()); //For debugging + } + + public final IItemHandlerModifiable getInventory() { + return this.inventory; + } + + @Nullable + @Override + public ClientboundBlockEntityDataPacket getUpdatePacket() { + CompoundTag nbt = new CompoundTag(); + this.saveAdditional(nbt); + return ClientboundBlockEntityDataPacket.create(this); + } + + @Override + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + this.load(pkt.getTag()); + } + + @Override + public CompoundTag getUpdateTag() { + return this.serializeNBT(); + } + + @Override + public void handleUpdateTag(CompoundTag tag) { + super.handleUpdateTag(tag); + this.load(tag); + } + + @Override + public LazyOptional getCapability(Capability cap, Direction side) { + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, LazyOptional.of(() -> this.inventory)); + } + + @Nullable + public abstract AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn); + + public void serverTick(Level level, BlockPos pos, BlockState state, AutoActionBlockEntity tile) { + boolean dirty = false; + if (this.status != Status.INVENTORY_FULL || this.hasInventorySpace()) { + this.updateStatus(); + this.updateUpgrades(); + if (level != null && !level.isClientSide && this.status.isRunning() && this.mineCooldown <= 0) { + BlockPos minePos = this.findMineableBlock(); + if (minePos != null) { + List drops = Block.getDrops(level.getBlockState(minePos), (ServerLevel) level, minePos, level.getBlockEntity(minePos)); + drops.stream().filter(drop -> !drop.isEmpty()).forEach(this::addItemToInventory); + level.destroyBlock(minePos, false); + this.mineCooldown = this.ticksPerMine; + dirty = true; + } + } + if (this.status.isRunning() && this.mineCooldown > 0) this.mineCooldown--; + if (dirty) this.setChanged(); + } + } + + public Component getName() { + return this.getDefaultName(); + } + + protected abstract Component getDefaultName(); + + @Override + public Component getDisplayName() { + return this.getName(); + } + + public synchronized String getStatus() { + return this.status == null ? "Unknown" : this.status.message; + } + + protected void findFuelSource() { + this.fuelSourceTileEntity = null; + double minDistance = Double.MAX_VALUE; + for (int x = -4; x <= 4; x++) { + for (int y = -4; y <= 4; y++) { + for (int z = -4; z <= 4; z++) { + double distance = Math.sqrt(x * x + y * y + z * z); + if (this.getLevel().getBlockState(this.worldPosition.offset(x, y, z)).getBlock() == RegistryHandler.MAGIC_ENERGIZER.get() && distance < minDistance) { + this.fuelSourceTileEntity = (MagicEnergizerBlockEntity) this.getLevel().getBlockEntity(this.worldPosition.offset(x, y, z)); + minDistance = distance; + } + } + } + } + } + + protected void addItemToInventory(ItemStack itemStack) { + if (!this.canAddItem(itemStack)) return; + for (int i = 0; i < 36; i++) { + itemStack = this.inventory.insertItem(i, itemStack, false); + if (itemStack.isEmpty()) break; + } + } + + public synchronized void setStatus(Status status) { + this.status = status; + } + + public void updateStatus() { + this.findFuelSource(); + if (this.fuelSourceTileEntity == null || this.fuelSourceTileEntity.fuel <= 0) { + this.setStatus(Status.NOT_ENOUGH_FUEL); + if (fuelSourceTileEntity != null) this.fuelSourceTileEntity.unregisterFuelConsumer(this); + } else if (!this.hasInventorySpace()) { + this.setStatus(Status.INVENTORY_FULL); + this.fuelSourceTileEntity.unregisterFuelConsumer(this); + } else if (this.findMineableBlock() == null) { + this.setStatus(Status.FINISHED); + this.fuelSourceTileEntity.unregisterFuelConsumer(this); + } else { + this.setStatus(Status.RUNNING); + this.fuelSourceTileEntity.registerFuelConsumer(this); + } + } + + @Nullable private BlockPos findMineableBlock() { + if (this.level == null) return null; + for (int y = invertedDirection ? 0 : 1; y <= (invertedDirection ? this.level.getMaxBuildHeight() - this.worldPosition.getY() : this.worldPosition.getY() - this.level.getMinBuildHeight()); y++) { + for (int x = -range; x <= range; x++) { + for (int z = -range; z <= range; z++) { + BlockPos pos = this.worldPosition.offset(x, y * direction, z); + BlockGetter reader = this.level.getChunkForCollisions(this.level.getChunkAt(pos).getPos().x, this.level.getChunkAt(pos).getPos().z); + BlockState state = this.level.getBlockState(pos); + //printNullReasons(pos, reader, state); + + if (reader != null && !state.isAir() && state.getDestroySpeed(reader, pos) >= 0 && this.level.getBlockEntity(pos) == null && !MINE_BLACKLIST.contains(state.getBlock()) && this.blockMatchesFilter(state.getBlock()) && this.canMineBlock(state)) { + return pos; + } + } + } + } + return null; + } + + @VisibleForTesting + private void printNullReasons(BlockPos pos, BlockGetter reader, BlockState state) { + if (state.getDestroySpeed(reader, pos) < 0) MagicMod.LOGGER.info("Block at {} is not breakable", pos); + if (this.level.getBlockEntity(pos) != null) MagicMod.LOGGER.info("Tile entity found at {}", pos); + if (MINE_BLACKLIST.contains(state.getBlock())) MagicMod.LOGGER.info("Block at {} is blacklisted", pos); + if (!this.blockMatchesFilter(state.getBlock())) MagicMod.LOGGER.info("Block at {} doesn't match filter", pos); + if (!this.canMineBlock(state)) MagicMod.LOGGER.info("Block at {} can't be mined by current auto-miner", pos); + } + + protected abstract boolean canMineBlock(BlockState blockState); + + protected boolean blockMatchesFilter(Block block) { + return this.filterBlock == null || block == this.filterBlock; + } + + protected boolean hasInventorySpace() { + return IntStream.range(0, 36).anyMatch(i -> this.inventory.getStackInSlot(i).isEmpty()); + } + + protected boolean canAddItem(ItemStack stack) { + if (this.hasInventorySpace()) return true; + int count = stack.getCount(); + for (int i = 0; i < 36; i++) { + if (this.inventory.getStackInSlot(i).getItem() == stack.getItem()) { + count -= 64 - this.inventory.getStackInSlot(i).getCount(); + if (count <= 0) return true; + } + } + return false; + } + + public void updateUpgrades() { + int oldMineSpeed = this.ticksPerMine; + this.ticksPerMine = BASE_TICKS_PER_MINE; + this.range = baseRange; + for (int i = 36; i <= 37; i++) { + if (this.inventory.getStackInSlot(i).getItem() == RegistryHandler.SPEED_UPGRADE.get()) this.ticksPerMine /= 2.0; + else if (this.inventory.getStackInSlot(i).getItem() == RegistryHandler.OBSIDIAN_PLATED_SPEED_UPGRADE.get()) this.ticksPerMine /= 3.8; + else if (this.inventory.getStackInSlot(i).getItem() == RegistryHandler.RANGE_UPGRADE.get()) this.range += this.rangeIncreaseWithUpgrade; + else if (this.inventory.getStackInSlot(i).getItem() == RegistryHandler.OBSIDIAN_PLATED_RANGE_UPGRADE.get()) this.range += this.rangeIncreaseWithObsidianPlatedUpgrade; + } + this.filterBlock = IntStream.rangeClosed(36, 37).mapToObj(this.inventory::getStackInSlot).filter(stack -> stack.getItem() == RegistryHandler.FILTER_UPGRADE.get() && stack.hasTag() && stack.getTag().contains("Filter")).findFirst().map(stack -> NbtUtils.readBlockState(stack.getTag().getCompound("Filter")).getBlock()).orElse(null); + if (this.ticksPerMine != oldMineSpeed) { + this.mineCooldown *= (double) this.ticksPerMine / oldMineSpeed; + } + } + + public enum Status { + RUNNING("Running", true), + FINISHED("Finished", false), + NOT_ENOUGH_FUEL("Not Enough Fuel", false), + INVENTORY_FULL("Inventory Full", false); + + final String message; + final boolean running; + Status(String message, boolean running) { + this.message = message; + this.running = running; + } + public String getMessage() { + return this.message; + } + public boolean isRunning() { + return this.running; + } + } + + public enum MineableArea { + ABOVE(1), + BELOW(-1); + + final int direction; + + MineableArea(int direction) { + this.direction = direction; + } + + public int getDirection() { + return this.direction; + } + } +} diff --git a/src/main/java/com/pitheguy/magicmod/blockentity/MagicCrateBlockEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicCrateBlockEntity.java new file mode 100644 index 0000000..c550eb4 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicCrateBlockEntity.java @@ -0,0 +1,183 @@ +package com.pitheguy.magicmod.blockentity; + +import com.pitheguy.magicmod.blocks.MagicCrate; +import com.pitheguy.magicmod.container.MagicCrateContainer; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.wrapper.InvWrapper; + +import javax.annotation.Nonnull; + +public class MagicCrateBlockEntity extends RandomizableContainerBlockEntity { + private NonNullList crateContents = NonNullList.withSize(88, ItemStack.EMPTY); + protected int openCount; + private final IItemHandlerModifiable items = createHandler(); + private LazyOptional itemHandler = LazyOptional.of(() -> items); + + public MagicCrateBlockEntity(BlockEntityType typeIn, BlockPos pos, BlockState state) { + super(typeIn, pos, state); + } + + public MagicCrateBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_CRATE.get(), pos, state); + } + + @Override + public int getContainerSize() { + return 88; + } + + @Override + public NonNullList getItems() { + return this.crateContents; + } + + @Override + public void setItems(NonNullList itemsIn) { + this.crateContents = itemsIn; + } + + @Override + protected Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_crate"); + } + + @Override + protected AbstractContainerMenu createMenu(int id, Inventory player) { + return new MagicCrateContainer(id, player, this); + } + + @Override + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); + if (!this.trySaveLootTable(compound)) { + ContainerHelper.saveAllItems(compound, this.crateContents); + } + } + + @Override + public void load(CompoundTag compound) { + super.load(compound); + this.crateContents = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + if (!this.tryLoadLootTable(compound)) { + ContainerHelper.loadAllItems(compound, this.crateContents); + } + } + + private void playSound(SoundEvent sound) { + double dx = (double) this.worldPosition.getX() + 0.5D; + double dy = (double) this.worldPosition.getY() + 0.5D; + double dz = (double) this.worldPosition.getZ() + 0.5D; + this.level.playSound(null, dx, dy, dz, sound, SoundSource.BLOCKS, 0.5f, + this.level.getRandom().nextFloat() * 0.1f + 0.9f); + } + + @Override + public boolean triggerEvent(int id, int type) { + if (id == 1) { + this.openCount = type; + return true; + } else { + return super.triggerEvent(id, type); + } + } + + @Override + public void startOpen(Player player) { + if (!player.isSpectator()) { + if (this.openCount < 0) { + this.openCount = 0; + } + + ++this.openCount; + this.signalOpenCount(); + } + playSound(SoundEvents.BARREL_OPEN); + } + + @Override + public void stopOpen(Player player) { + if (!player.isSpectator()) { + --this.openCount; + this.signalOpenCount(); + } + playSound(SoundEvents.BARREL_CLOSE); + } + + protected void signalOpenCount() { + Block block = this.getBlockState().getBlock(); + if (block instanceof MagicCrate) { + this.level.blockEvent(this.worldPosition, block, 1, this.openCount); + this.level.updateNeighborsAt(this.worldPosition, block); + } + } + + public static int getOpenCount(BlockGetter reader, BlockPos pos) { + BlockState blockstate = reader.getBlockState(pos); + if (blockstate.hasBlockEntity()) { + BlockEntity blockEntity = reader.getBlockEntity(pos); + if (blockEntity instanceof MagicCrateBlockEntity) { + return ((MagicCrateBlockEntity) blockEntity).openCount; + } + } + return 0; + } + + public static void swapContents(MagicCrateBlockEntity te, MagicCrateBlockEntity otherTe) { + NonNullList list = te.getItems(); + te.setItems(otherTe.getItems()); + otherTe.setItems(list); + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + if (this.itemHandler != null) { + this.itemHandler.invalidate(); + this.itemHandler = null; + } + } + + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @Nonnull Direction side) { + if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { + return itemHandler.cast(); + } + return super.getCapability(cap, side); + } + + private IItemHandlerModifiable createHandler() { + return new InvWrapper(this); + } + + @Override + public void setRemoved() { + super.setRemoved(); + if(itemHandler != null) { + itemHandler.invalidate(); + } + } +} diff --git a/src/main/java/com/pitheguy/magicmod/blockentity/MagicEnergizerBlockEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicEnergizerBlockEntity.java new file mode 100644 index 0000000..34663cd --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicEnergizerBlockEntity.java @@ -0,0 +1,152 @@ +package com.pitheguy.magicmod.blockentity; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.pitheguy.magicmod.container.MagicEnergizerContainer; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import com.pitheguy.magicmod.util.ModItemHandler; +import net.minecraft.core.*; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.items.CapabilityItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Map; + +import static com.pitheguy.magicmod.util.RegistryHandler.MAGIC_FUEL; + +public class MagicEnergizerBlockEntity extends BlockEntity implements MenuProvider { + private final ModItemHandler inventory; + public int fuel = 0; + public int fuelConsumptionPerTick = 0; + public ArrayList fuelConsumers = new ArrayList<>(); + public static final int MAX_FUEL = 6000; + public static final Map ITEM_FUEL_AMOUNT = Maps.newHashMap(ImmutableMap.of(MAGIC_FUEL.get(), 300)); + public MagicEnergizerBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { + super(tileEntityTypeIn, pos, state); + this.inventory = new ModItemHandler(1); + } + + public MagicEnergizerBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_ENERGIZER.get(), pos, state); + } + + @Override + public void load(CompoundTag compound) { + super.load(compound); + NonNullList inv = NonNullList.withSize(this.inventory.getSlots(), ItemStack.EMPTY); + ContainerHelper.loadAllItems(compound, inv); + this.inventory.setNonNullList(inv); + this.fuel = compound.getInt("Fuel"); + this.fuelConsumptionPerTick = compound.getInt("FuelConsumption"); + } + + @Override + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); + ContainerHelper.saveAllItems(compound, this.inventory.toNonNullList()); + compound.putInt("Fuel", this.fuel); + compound.putInt("FuelConsumption", this.fuelConsumptionPerTick); + } + + public final IItemHandlerModifiable getInventory() { + return this.inventory; + } + + @Nullable + @Override + public ClientboundBlockEntityDataPacket getUpdatePacket() { + CompoundTag nbt = new CompoundTag(); + this.saveAdditional(nbt); + return ClientboundBlockEntityDataPacket.create(this); + } + + @Override + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + this.load(pkt.getTag()); + } + + @Override + public CompoundTag getUpdateTag() { + return this.serializeNBT(); + } + + @Override + public void handleUpdateTag(CompoundTag tag) { + super.handleUpdateTag(tag); + this.load(tag); + } + + @Override + public LazyOptional getCapability(Capability cap, Direction side) { + return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.orEmpty(cap, LazyOptional.of(() -> this.inventory)); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn) { + return new MagicEnergizerContainer(windowId, playerInv, this); + } + + public void tick() { + boolean dirty = false; + this.fuelConsumptionPerTick = this.fuelConsumers.size(); + if (level != null && !level.isClientSide()) { + while(ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(0).getItem()) != null && this.fuel <= MAX_FUEL - ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(0).getItem())) { + this.fuel += ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(0).getItem()); + this.inventory.decrStackSize(0, 1); + dirty = true; + } + } + this.fuel -= this.fuelConsumptionPerTick; + if (dirty) this.update(); + } + + public void update() { + requestModelDataUpdate(); + setChanged(); + if (this.level != null) { + this.level.setBlockAndUpdate(this.worldPosition, getBlockState()); + } + } + + public Component getName() { + return this.getDefaultName(); + } + + private Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_energizer"); + } + + @Override + public Component getDisplayName() { + return this.getName(); + } + + public void registerFuelConsumer(BlockEntity consumer) { + if (!this.fuelConsumers.contains(consumer)) { + this.fuelConsumers.add(consumer); + } + } + + public void unregisterFuelConsumer(BlockEntity consumer) { + this.fuelConsumers.remove(consumer); + } +} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/tileentity/MagicInfuserTileEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicInfuserBlockEntity.java similarity index 51% rename from src/main/java/com/pitheguy/magicmod/tileentity/MagicInfuserTileEntity.java rename to src/main/java/com/pitheguy/magicmod/blockentity/MagicInfuserBlockEntity.java index 6a6a18d..9e03c3c 100644 --- a/src/main/java/com/pitheguy/magicmod/tileentity/MagicInfuserTileEntity.java +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicInfuserBlockEntity.java @@ -1,25 +1,24 @@ -package com.pitheguy.magicmod.tileentity; +package com.pitheguy.magicmod.blockentity; import com.pitheguy.magicmod.container.MagicInfuserContainer; import com.pitheguy.magicmod.init.ModTileEntityTypes; import com.pitheguy.magicmod.util.ModItemHandler; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SUpdateTileEntityPacket; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.core.*; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -27,31 +26,30 @@ import javax.annotation.Nullable; -public class MagicInfuserTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { +public class MagicInfuserBlockEntity extends BlockEntity implements MenuProvider { private final ModItemHandler inventory; - public MagicInfuserTileEntity(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); + public MagicInfuserBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { + super(tileEntityTypeIn, pos, state); this.inventory = new ModItemHandler(10); } - public MagicInfuserTileEntity() { - this(ModTileEntityTypes.MAGIC_INFUSER.get()); + public MagicInfuserBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_INFUSER.get(), pos, state); } @Override - public void read(CompoundNBT compound) { - super.read(compound); + public void load(CompoundTag compound) { + super.load(compound); NonNullList inv = NonNullList.withSize(this.inventory.getSlots(), ItemStack.EMPTY); - ItemStackHelper.loadAllItems(compound, inv); + ContainerHelper.loadAllItems(compound, inv); this.inventory.setNonNullList(inv); } @Override - public CompoundNBT write(CompoundNBT compound) { - super.write(compound); - ItemStackHelper.saveAllItems(compound, this.inventory.toNonNullList()); - return compound; + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); + ContainerHelper.saveAllItems(compound, this.inventory.toNonNullList()); } public final IItemHandlerModifiable getInventory() { @@ -60,27 +58,26 @@ public final IItemHandlerModifiable getInventory() { @Nullable @Override - public SUpdateTileEntityPacket getUpdatePacket() { - CompoundNBT nbt = new CompoundNBT(); - this.write(nbt); - return new SUpdateTileEntityPacket(this.pos, 0, nbt); + public ClientboundBlockEntityDataPacket getUpdatePacket() { + CompoundTag nbt = new CompoundTag(); + this.saveAdditional(nbt); + return ClientboundBlockEntityDataPacket.create(this); } @Override - public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { - this.read(pkt.getNbtCompound()); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + this.load(pkt.getTag()); } @Override - public CompoundNBT getUpdateTag() { - CompoundNBT nbt = new CompoundNBT(); - this.write(nbt); - return nbt; + public CompoundTag getUpdateTag() { + return this.serializeNBT(); } @Override - public void handleUpdateTag(CompoundNBT nbt) { - this.read(nbt); + public void handleUpdateTag(CompoundTag tag) { + super.handleUpdateTag(tag); + this.load(tag); } @Override @@ -90,14 +87,13 @@ public LazyOptional getCapability(Capability cap, Direction side) { @Nullable @Override - public Container createMenu(final int windowId, final PlayerInventory playerInv, final PlayerEntity playerIn) { + public AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn) { return new MagicInfuserContainer(windowId, playerInv, this); } - @Override - public void tick() { + public void serverTick() { boolean dirty = false; - if (world != null && !world.isRemote()) { + if (level != null && !level.isClientSide) { while(this.inventory.getStackInSlot(0).getItem() == RegistryHandler.MAGIC_ORB_RED.get() && this.inventory.getStackInSlot(1).getItem() == RegistryHandler.MAGIC_ORB_ORANGE.get() && this.inventory.getStackInSlot(2).getItem() == RegistryHandler.MAGIC_ORB_YELLOW.get() && @@ -115,19 +111,27 @@ public void tick() { } } } - if(dirty) this.markDirty(); + if(dirty) this.update(); + } + + public void update() { + requestModelDataUpdate(); + setChanged(); + if (this.level != null) { + this.level.setBlockAndUpdate(this.worldPosition, getBlockState()); + } } - public ITextComponent getName() { + public Component getName() { return this.getDefaultName(); } - private ITextComponent getDefaultName() { - return new TranslationTextComponent("container.magicmod.magic_infuser"); + private Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_infuser"); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return this.getName(); } diff --git a/src/main/java/com/pitheguy/magicmod/blockentity/MagicLoggerBlockEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicLoggerBlockEntity.java new file mode 100644 index 0000000..81c69cf --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicLoggerBlockEntity.java @@ -0,0 +1,42 @@ +package com.pitheguy.magicmod.blockentity; + +import com.pitheguy.magicmod.container.MagicLoggerContainer; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nullable; + +public class MagicLoggerBlockEntity extends AutoActionBlockEntity implements MenuProvider { + + public MagicLoggerBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { + super(tileEntityTypeIn, pos, state, 15, 2, 4, MineableArea.ABOVE); + } + + public MagicLoggerBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_LOGGER.get(), pos, state); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn) { + return new MagicLoggerContainer(windowId, playerInv, this); + } + + protected Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_logger"); + } + + @Override + protected boolean canMineBlock(BlockState blockState) { + return blockState.is(BlockTags.LOGS); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/blockentity/MagicMinerBlockEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicMinerBlockEntity.java new file mode 100644 index 0000000..df4af8c --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicMinerBlockEntity.java @@ -0,0 +1,59 @@ +package com.pitheguy.magicmod.blockentity; + +import com.pitheguy.magicmod.blocks.state.ModBlockStateProperties; +import com.pitheguy.magicmod.container.MagicMinerContainer; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nullable; + +public class MagicMinerBlockEntity extends AutoActionBlockEntity implements MenuProvider { + + public MagicMinerBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { + super(tileEntityTypeIn, pos, state, 5, 1, 2, MineableArea.BELOW); + } + + public MagicMinerBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_MINER.get(), pos, state); + } + + @Override + public void serverTick(Level level, BlockPos pos, BlockState state, AutoActionBlockEntity tile) { + super.serverTick(level, pos, state, tile); + this.updateBlockState(); + } + + private void updateBlockState() { + BlockState oldBlockState = this.level.getBlockState(this.worldPosition); + BlockState newBlockState = oldBlockState.setValue(ModBlockStateProperties.RUNNING, this.status.isRunning()); + if (oldBlockState != newBlockState) { + this.level.setBlock(this.worldPosition, newBlockState, 3); + } + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn) { + return new MagicMinerContainer(windowId, playerInv, this); + } + + protected Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_miner"); + } + + @Override + protected boolean canMineBlock(BlockState blockState) { + //if(!block.isAir()) MagicMod.LOGGER.info("Block {} has tool type of {}", block.getBlock(), block.getHarvestTool().getName()); + return blockState.is(BlockTags.MINEABLE_WITH_PICKAXE) || blockState.is(BlockTags.MINEABLE_WITH_SHOVEL); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/tileentity/MagicPressTileEntity.java b/src/main/java/com/pitheguy/magicmod/blockentity/MagicPressBlockEntity.java similarity index 53% rename from src/main/java/com/pitheguy/magicmod/tileentity/MagicPressTileEntity.java rename to src/main/java/com/pitheguy/magicmod/blockentity/MagicPressBlockEntity.java index 27865cd..f18d7f4 100644 --- a/src/main/java/com/pitheguy/magicmod/tileentity/MagicPressTileEntity.java +++ b/src/main/java/com/pitheguy/magicmod/blockentity/MagicPressBlockEntity.java @@ -1,27 +1,28 @@ -package com.pitheguy.magicmod.tileentity; +package com.pitheguy.magicmod.blockentity; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.pitheguy.magicmod.container.MagicPressContainer; import com.pitheguy.magicmod.init.ModTileEntityTypes; import com.pitheguy.magicmod.util.ModItemHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.server.SUpdateTileEntityPacket; -import net.minecraft.tileentity.ITickableTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.Direction; -import net.minecraft.util.NonNullList; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.Connection; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.MenuProvider; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; @@ -32,7 +33,7 @@ import static com.pitheguy.magicmod.util.RegistryHandler.*; -public class MagicPressTileEntity extends TileEntity implements ITickableTileEntity, INamedContainerProvider { +public class MagicPressBlockEntity extends BlockEntity implements MenuProvider { private final ModItemHandler inventory; public int fuel = 0; public final int maxFuel = 900; @@ -49,30 +50,29 @@ public class MagicPressTileEntity extends TileEntity implements ITickableTileEnt .put(REINFORCED_MAGIC_SWORD.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_SWORD.get()) .put(REINFORCED_MAGIC_HOE.get(),OBSIDIAN_PLATED_REINFORCED_MAGIC_HOE.get()) .build()); - public MagicPressTileEntity(TileEntityType tileEntityTypeIn) { - super(tileEntityTypeIn); + public MagicPressBlockEntity(BlockEntityType tileEntityTypeIn, BlockPos pos, BlockState state) { + super(tileEntityTypeIn, pos, state); this.inventory = new ModItemHandler(10); } - public MagicPressTileEntity() { - this(ModTileEntityTypes.MAGIC_PRESS.get()); + public MagicPressBlockEntity(BlockPos pos, BlockState state) { + this(ModTileEntityTypes.MAGIC_PRESS.get(), pos, state); } @Override - public void read(CompoundNBT compound) { - super.read(compound); + public void load(CompoundTag compound) { + super.load(compound); NonNullList inv = NonNullList.withSize(this.inventory.getSlots(), ItemStack.EMPTY); - ItemStackHelper.loadAllItems(compound, inv); + ContainerHelper.loadAllItems(compound, inv); this.inventory.setNonNullList(inv); this.fuel = compound.getInt("Fuel"); } @Override - public CompoundNBT write(CompoundNBT compound) { - super.write(compound); - ItemStackHelper.saveAllItems(compound, this.inventory.toNonNullList()); + public void saveAdditional(CompoundTag compound) { + super.saveAdditional(compound); + ContainerHelper.saveAllItems(compound, this.inventory.toNonNullList()); compound.putInt("Fuel", this.fuel); - return compound; } public final IItemHandlerModifiable getInventory() { @@ -81,27 +81,26 @@ public final IItemHandlerModifiable getInventory() { @Nullable @Override - public SUpdateTileEntityPacket getUpdatePacket() { - CompoundNBT nbt = new CompoundNBT(); - this.write(nbt); - return new SUpdateTileEntityPacket(this.pos, 0, nbt); + public ClientboundBlockEntityDataPacket getUpdatePacket() { + CompoundTag nbt = new CompoundTag(); + this.saveAdditional(nbt); + return ClientboundBlockEntityDataPacket.create(this); } @Override - public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { - this.read(pkt.getNbtCompound()); + public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { + this.load(pkt.getTag()); } @Override - public CompoundNBT getUpdateTag() { - CompoundNBT nbt = new CompoundNBT(); - this.write(nbt); - return nbt; + public CompoundTag getUpdateTag() { + return this.serializeNBT(); } @Override - public void handleUpdateTag(CompoundNBT nbt) { - this.read(nbt); + public void handleUpdateTag(CompoundTag tag) { + super.handleUpdateTag(tag); + this.load(tag); } @Override @@ -111,40 +110,47 @@ public LazyOptional getCapability(Capability cap, Direction side) { @Nullable @Override - public Container createMenu(final int windowId, final PlayerInventory playerInv, final PlayerEntity playerIn) { + public AbstractContainerMenu createMenu(final int windowId, final Inventory playerInv, final Player playerIn) { return new MagicPressContainer(windowId, playerInv, this); } - @Override - public void tick() { + public void serverTick() { boolean dirty = false; - if (world != null && !world.isRemote()) { - while(ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem()) != null && fuel <= maxFuel - ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem())) { - fuel += ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem()); + if (level != null && !level.isClientSide) { + while(ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem()) != null && this.fuel <= this.maxFuel - ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem())) { + this.fuel += ITEM_FUEL_AMOUNT.get(this.inventory.getStackInSlot(3).getItem()); this.inventory.decrStackSize(3, 1); dirty = true; } - if (RECIPES.get(this.inventory.getStackInSlot(0).getItem()) != null && this.inventory.getStackInSlot(1).getItem() == OBSIDIAN_PLATE.get() && this.inventory.getStackInSlot(1).getCount() >= 32 && fuel >= fuelPerOperation) { - fuel -= fuelPerOperation; + if (RECIPES.get(this.inventory.getStackInSlot(0).getItem()) != null && this.inventory.getStackInSlot(1).getItem() == OBSIDIAN_PLATE.get() && this.inventory.getStackInSlot(1).getCount() >= 32 && this.fuel >= this.fuelPerOperation) { + this.fuel -= this.fuelPerOperation; this.inventory.insertItem(2,new ItemStack(RECIPES.get(this.inventory.getStackInSlot(0).getItem()), 1), false); this.inventory.decrStackSize(0,1); this.inventory.decrStackSize(1,32); dirty = true; } } - if(dirty) this.markDirty(); + if(dirty) this.update(); + } + + public void update() { + requestModelDataUpdate(); + setChanged(); + if (this.level != null) { + this.level.setBlockAndUpdate(this.worldPosition, getBlockState()); + } } - public ITextComponent getName() { + public Component getName() { return this.getDefaultName(); } - private ITextComponent getDefaultName() { - return new TranslationTextComponent("container.magicmod.magic_press"); + private Component getDefaultName() { + return new TranslatableComponent("container.magicmod.magic_press"); } @Override - public ITextComponent getDisplayName() { + public Component getDisplayName() { return this.getName(); } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/BlockItemBase.java b/src/main/java/com/pitheguy/magicmod/blocks/BlockItemBase.java index 1fbf2da..16da62a 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/BlockItemBase.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/BlockItemBase.java @@ -1,12 +1,12 @@ package com.pitheguy.magicmod.blocks; import com.pitheguy.magicmod.MagicMod; -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; public class BlockItemBase extends BlockItem { public BlockItemBase(Block block) { - super(block, new Item.Properties().group(MagicMod.TAB)); + super(block, new Item.Properties().tab(MagicMod.TAB)); } } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicCrate.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicCrate.java index 47482f7..d61c13e 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicCrate.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicCrate.java @@ -1,76 +1,61 @@ package com.pitheguy.magicmod.blocks; +import com.pitheguy.magicmod.blockentity.MagicCrateBlockEntity; import com.pitheguy.magicmod.init.ModTileEntityTypes; -import com.pitheguy.magicmod.tileentity.MagicCrateTileEntity; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.InventoryHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +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.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; import javax.annotation.Nullable; -public class MagicCrate extends Block { +public class MagicCrate extends Block implements EntityBlock { public MagicCrate() { - super(Properties.create(Material.IRON) - .hardnessAndResistance(6.5f, 12.0f) + super(Properties.of(Material.METAL) + .strength(6.5f, 12.0f) .sound(SoundType.METAL) - .harvestLevel(2) - .harvestTool(ToolType.PICKAXE) + .requiresCorrectToolForDrops() ); } @Override - public boolean hasTileEntity(BlockState state) { - return true; + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return ModTileEntityTypes.MAGIC_CRATE.get().create(pos, state); } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return ModTileEntityTypes.MAGIC_CRATE.get().create(); + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - } - - @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (!worldIn.isRemote()) { - TileEntity tile = worldIn.getTileEntity(pos); - if(tile instanceof MagicCrateTileEntity) { - NetworkHooks.openGui((ServerPlayerEntity) player,(MagicCrateTileEntity) tile,pos); - worldIn.playSound(null, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, SoundEvents.BLOCK_BARREL_OPEN, SoundCategory.BLOCKS, 0.5f, - worldIn.rand.nextFloat() * 0.1f + 0.9f); - return ActionResultType.SUCCESS; + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (!worldIn.isClientSide()) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicCrateBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player, (MagicCrateBlockEntity) tile, pos); + return InteractionResult.SUCCESS; } } - return ActionResultType.FAIL; + return InteractionResult.FAIL; } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { if (state.getBlock() != newState.getBlock()) { - TileEntity te = worldIn.getTileEntity(pos); - if (te instanceof MagicCrateTileEntity) { - InventoryHelper.dropItems(worldIn, pos, ((MagicCrateTileEntity) te).getItems()); + BlockEntity te = worldIn.getBlockEntity(pos); + if (te instanceof MagicCrateBlockEntity magicCrateBlockEntity) { + Containers.dropContents(worldIn, pos, magicCrateBlockEntity.getItems()); } } } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicEnergizer.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicEnergizer.java new file mode 100644 index 0000000..0e4f75e --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicEnergizer.java @@ -0,0 +1,73 @@ +package com.pitheguy.magicmod.blocks; + +import com.pitheguy.magicmod.blockentity.MagicEnergizerBlockEntity; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import com.pitheguy.magicmod.util.ModItemHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; + +import javax.annotation.Nullable; + +public class MagicEnergizer extends BaseEntityBlock implements EntityBlock { + + public MagicEnergizer() { + super(Properties.of(Material.METAL) + .strength(6.5f, 8.0f) + .sound(SoundType.METAL) + .requiresCorrectToolForDrops() + ); + } + + @Override + public RenderShape getRenderShape(BlockState p_49232_) { + return RenderShape.MODEL; + } + + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new MagicEnergizerBlockEntity(pos, state); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide ? null : createTickerHelper(type, (BlockEntityType) ModTileEntityTypes.MAGIC_ENERGIZER.get(), (level1, pos, state1, tile) -> tile.tick()); + } + + @Override + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (worldIn != null && !worldIn.isClientSide()) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicEnergizerBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player,(MenuProvider) tile,pos); + return InteractionResult.SUCCESS; + } + } + return InteractionResult.SUCCESS; + } + + @Override + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicEnergizerBlockEntity) { + MagicEnergizerBlockEntity energizer = (MagicEnergizerBlockEntity) tile; + ((ModItemHandler)energizer.getInventory()).toNonNullList().forEach(item -> { + ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), item); + worldIn.addFreshEntity(itemEntity); + }); + } + if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { + worldIn.removeBlockEntity(pos); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicInfuser.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicInfuser.java index 5d2aaff..f9fb3b0 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicInfuser.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicInfuser.java @@ -1,80 +1,80 @@ package com.pitheguy.magicmod.blocks; +import com.pitheguy.magicmod.blockentity.MagicInfuserBlockEntity; import com.pitheguy.magicmod.init.ModTileEntityTypes; -import com.pitheguy.magicmod.tileentity.MagicInfuserTileEntity; import com.pitheguy.magicmod.util.ModItemHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; import javax.annotation.Nullable; -public class MagicInfuser extends Block { +public class MagicInfuser extends BaseEntityBlock implements EntityBlock { public MagicInfuser() { - super(Block.Properties.create(Material.IRON) - .hardnessAndResistance(6.5f, 8.0f) + super(Block.Properties.of(Material.METAL) + .strength(6.5f, 8.0f) .sound(SoundType.METAL) - .harvestLevel(4) - .harvestTool(ToolType.PICKAXE) + .requiresCorrectToolForDrops() ); } @Override - public boolean hasTileEntity(BlockState state) { - return true; + public RenderShape getRenderShape(BlockState p_49232_) { + return RenderShape.MODEL; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return ModTileEntityTypes.MAGIC_INFUSER.get().create(); + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new MagicInfuserBlockEntity(pos, state); } + @Nullable @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide ? null : createTickerHelper(type, (BlockEntityType) ModTileEntityTypes.MAGIC_INFUSER.get(), (level1, pos, state1, tile) -> tile.serverTick()); } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (worldIn != null && !worldIn.isRemote()) { - TileEntity tile = worldIn.getTileEntity(pos); - if(tile instanceof MagicInfuserTileEntity) { - NetworkHooks.openGui((ServerPlayerEntity) player,(INamedContainerProvider) tile,pos); - return ActionResultType.SUCCESS; + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); + } + + @Override + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (worldIn != null && !worldIn.isClientSide()) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicInfuserBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player,(MenuProvider) tile,pos); + return InteractionResult.SUCCESS; } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - TileEntity tile = worldIn.getTileEntity(pos); - if(tile instanceof MagicInfuserTileEntity) { - MagicInfuserTileEntity infuser = (MagicInfuserTileEntity) tile; + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicInfuserBlockEntity) { + MagicInfuserBlockEntity infuser = (MagicInfuserBlockEntity) tile; ((ModItemHandler)infuser.getInventory()).toNonNullList().forEach(item -> { ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), item); - worldIn.addEntity(itemEntity); + worldIn.addFreshEntity(itemEntity); }); } - if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { - worldIn.removeTileEntity(pos); + if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { + worldIn.removeBlockEntity(pos); } } } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicLamp.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicLamp.java index 664bfb4..3821c36 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicLamp.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicLamp.java @@ -1,16 +1,15 @@ package com.pitheguy.magicmod.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.material.Material; public class MagicLamp extends Block { public MagicLamp() { - super(Properties.create(Material.IRON) - .hardnessAndResistance(2.0f, 2.0f) + super(Properties.of(Material.METAL) + .strength(2.0f, 2.0f) .sound(SoundType.GLASS) - .lightValue(15) + .lightLevel(state -> 15) ); } - } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicLogger.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicLogger.java new file mode 100644 index 0000000..24f7a54 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicLogger.java @@ -0,0 +1,84 @@ +package com.pitheguy.magicmod.blocks; + +import com.pitheguy.magicmod.blockentity.MagicLoggerBlockEntity; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import com.pitheguy.magicmod.util.ModItemHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class MagicLogger extends BaseEntityBlock implements EntityBlock { + + public MagicLogger() { + super(Properties.of(Material.METAL) + .strength(4.5f, 8.0f) + .sound(SoundType.METAL) + .requiresCorrectToolForDrops() + ); + } + + @Override + public RenderShape getRenderShape(BlockState p_49232_) { + return RenderShape.MODEL; + } + + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new MagicLoggerBlockEntity(pos, state); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide ? null : createTickerHelper(type, (BlockEntityType) ModTileEntityTypes.MAGIC_LOGGER.get(), (level1, pos, state1, tile) -> tile.serverTick(level1, pos, state1, tile)); + } + + @Override + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); + } + + @Override + public InteractionResult use(BlockState state, @Nonnull Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (!worldIn.isClientSide()) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicLoggerBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player,(MenuProvider) tile,pos); + return InteractionResult.SUCCESS; + } + } + return InteractionResult.SUCCESS; + } + + @Override + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicLoggerBlockEntity) { + MagicLoggerBlockEntity miner = (MagicLoggerBlockEntity) tile; + ((ModItemHandler)miner.getInventory()).toNonNullList().forEach(item -> { + ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), item); + worldIn.addFreshEntity(itemEntity); + }); + if (miner.fuelSourceTileEntity != null) { + miner.fuelSourceTileEntity.unregisterFuelConsumer(miner); + } + } + if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { + worldIn.removeBlockEntity(pos); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicMiner.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicMiner.java new file mode 100644 index 0000000..5d85a0e --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicMiner.java @@ -0,0 +1,94 @@ +package com.pitheguy.magicmod.blocks; + +import com.pitheguy.magicmod.blockentity.MagicMinerBlockEntity; +import com.pitheguy.magicmod.blocks.state.ModBlockStateProperties; +import com.pitheguy.magicmod.init.ModTileEntityTypes; +import com.pitheguy.magicmod.util.ModItemHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class MagicMiner extends BaseEntityBlock implements EntityBlock { + public static final BooleanProperty RUNNING = ModBlockStateProperties.RUNNING; + + public MagicMiner() { + super(Properties.of(Material.METAL) + .strength(4.5f, 8.0f) + .sound(SoundType.METAL) + .requiresCorrectToolForDrops() + ); + this.registerDefaultState(this.getStateDefinition().any().setValue(RUNNING, false)); + } + + @Override + public RenderShape getRenderShape(BlockState p_49232_) { + return RenderShape.MODEL; + } + + @Override + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new MagicMinerBlockEntity(pos, state); + } + + @Nullable + @Override + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide ? null : createTickerHelper(type, (BlockEntityType) ModTileEntityTypes.MAGIC_MINER.get(), (level1, pos, state1, tile) -> tile.serverTick(level1, pos, state1, tile)); + } + + @Override + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); + } + + @Override + public InteractionResult use(BlockState state, @Nonnull Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (!worldIn.isClientSide()) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicMinerBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player,(MenuProvider) tile,pos); + return InteractionResult.SUCCESS; + } + } + return InteractionResult.SUCCESS; + } + + @Override + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { + if(tile instanceof MagicMinerBlockEntity) { + MagicMinerBlockEntity miner = (MagicMinerBlockEntity) tile; + ((ModItemHandler)miner.getInventory()).toNonNullList().forEach(item -> { + ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), item); + worldIn.addFreshEntity(itemEntity); + }); + if (miner.fuelSourceTileEntity != null) { + miner.fuelSourceTileEntity.unregisterFuelConsumer(miner); + } + } + worldIn.removeBlockEntity(pos); + } + } + + @Override + protected void createBlockStateDefinition(@Nonnull StateDefinition.Builder builder) { + builder.add(RUNNING); + } +} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicPress.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicPress.java index 654ed45..749a27e 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicPress.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicPress.java @@ -1,80 +1,79 @@ package com.pitheguy.magicmod.blocks; +import com.pitheguy.magicmod.blockentity.MagicPressBlockEntity; import com.pitheguy.magicmod.init.ModTileEntityTypes; -import com.pitheguy.magicmod.tileentity.MagicPressTileEntity; import com.pitheguy.magicmod.util.ModItemHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.inventory.container.INamedContainerProvider; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.fml.network.NetworkHooks; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.*; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.block.entity.*; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraftforge.network.NetworkHooks; import javax.annotation.Nullable; -public class MagicPress extends Block { +public class MagicPress extends BaseEntityBlock implements EntityBlock { public MagicPress() { - super(Properties.create(Material.IRON) - .hardnessAndResistance(6.5f, 8.0f) + super(Properties.of(Material.METAL) + .strength(6.5f, 8.0f) .sound(SoundType.METAL) - .harvestLevel(4) - .harvestTool(ToolType.PICKAXE) + .requiresCorrectToolForDrops() ); } @Override - public boolean hasTileEntity(BlockState state) { - return true; + public RenderShape getRenderShape(BlockState p_49232_) { + return RenderShape.MODEL; } @Override - public TileEntity createTileEntity(BlockState state, IBlockReader world) { - return ModTileEntityTypes.MAGIC_PRESS.get().create(); + public BlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new MagicPressBlockEntity(pos, state); } + @Nullable @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); + public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType type) { + return level.isClientSide ? null : createTickerHelper(type, (BlockEntityType) ModTileEntityTypes.MAGIC_PRESS.get(), (level1, pos, state1, tile) -> tile.serverTick()); } @Override - public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { - if (worldIn != null && !worldIn.isRemote()) { - TileEntity tile = worldIn.getTileEntity(pos); - if(tile instanceof MagicPressTileEntity) { - NetworkHooks.openGui((ServerPlayerEntity) player,(INamedContainerProvider) tile,pos); - return ActionResultType.SUCCESS; + public void setPlacedBy(Level worldIn, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { + super.setPlacedBy(worldIn, pos, state, placer, stack); + } + + @Override + public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) { + if (worldIn != null && !worldIn.isClientSide) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicPressBlockEntity) { + NetworkHooks.openGui((ServerPlayer) player,(MenuProvider) tile,pos); + return InteractionResult.SUCCESS; } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } @Override - public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) { - TileEntity tile = worldIn.getTileEntity(pos); - if(tile instanceof MagicPressTileEntity) { - MagicPressTileEntity infuser = (MagicPressTileEntity) tile; + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + BlockEntity tile = worldIn.getBlockEntity(pos); + if(tile instanceof MagicPressBlockEntity infuser) { ((ModItemHandler)infuser.getInventory()).toNonNullList().forEach(item -> { ItemEntity itemEntity = new ItemEntity(worldIn, pos.getX(), pos.getY(), pos.getZ(), item); - worldIn.addEntity(itemEntity); + worldIn.addFreshEntity(itemEntity); }); } - if (state.hasTileEntity() && state.getBlock() != newState.getBlock()) { - worldIn.removeTileEntity(pos); + if (state.hasBlockEntity() && state.getBlock() != newState.getBlock()) { + worldIn.removeBlockEntity(pos); } } } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicSpike.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicSpike.java index 9ff2897..168e44a 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicSpike.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicSpike.java @@ -1,45 +1,43 @@ package com.pitheguy.magicmod.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.util.math.shapes.VoxelShapes; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +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.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; public class MagicSpike extends Block { public MagicSpike() { - super(Properties.create(Material.IRON) - .hardnessAndResistance(2.0f, 2.0f) + super(Properties.of(Material.METAL) + .strength(2.0f, 2.0f) .sound(SoundType.METAL) - .harvestTool(ToolType.PICKAXE) - .notSolid() + .requiresCorrectToolForDrops() ); } @Override - public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + public VoxelShape getCollisionShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { return this.getShape(state, worldIn, pos, context); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - VoxelShape result = VoxelShapes.empty(); + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { + VoxelShape result = Shapes.empty(); for (int i = 0; i < 8; i++) { - result = VoxelShapes.or(result, Block.makeCuboidShape(i, i*2, i, 16 - i, i*2 + 2, 16 - i)); + result = Shapes.or(result, Block.box(i, i*2, i, 16 - i, i*2 + 2, 16 - i)); } return result; } @Override - public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance) { - super.onFallenUpon(worldIn, pos, entityIn, fallDistance * 10); + public void fallOn(Level worldIn, BlockState state, BlockPos pos, Entity entityIn, float fallDistance) { + super.fallOn(worldIn, state, pos, entityIn, fallDistance * 10); } } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicVein.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicVein.java index ab3a885..0cdc254 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicVein.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicVein.java @@ -1,34 +1,32 @@ package com.pitheguy.magicmod.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.shapes.ISelectionContext; -import net.minecraft.util.math.shapes.VoxelShape; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.common.ToolType; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockGetter; +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.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; public class MagicVein extends Block { public MagicVein() { - super(Properties.create(Material.IRON) - .hardnessAndResistance(5, 7) + super(Properties.of(Material.METAL) + .strength(5, 7) .sound(SoundType.METAL) - .harvestLevel(2) - .harvestTool(ToolType.PICKAXE) - .doesNotBlockMovement() - .notSolid() + .requiresCorrectToolForDrops() + .dynamicShape() + .noCollission() ); } @Override - public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - return Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); + public VoxelShape getShape(BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context) { + return Block.box(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D); } @Override - public boolean propagatesSkylightDown(BlockState state, IBlockReader reader, BlockPos pos) { + public boolean propagatesSkylightDown(BlockState state, BlockGetter reader, BlockPos pos) { return true; } } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/blocks/MagicWeb.java b/src/main/java/com/pitheguy/magicmod/blocks/MagicWeb.java index 32f33cc..2cb79e0 100644 --- a/src/main/java/com/pitheguy/magicmod/blocks/MagicWeb.java +++ b/src/main/java/com/pitheguy/magicmod/blocks/MagicWeb.java @@ -1,24 +1,24 @@ package com.pitheguy.magicmod.blocks; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +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.Vec3; public class MagicWeb extends Block { public MagicWeb() { - super(Properties.create(Material.WEB) - .hardnessAndResistance(4.0f) - .doesNotBlockMovement() + super(Properties.of(Material.WEB) + .strength(4.0f) + .noCollission() ); } @Override - public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { - entityIn.setMotionMultiplier(state, new Vec3d(0.05D, 0.01D, 0.05D)); + public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) { + entityIn.makeStuckInBlock(state, new Vec3(0.05D, 0.01D, 0.05D)); } } diff --git a/src/main/java/com/pitheguy/magicmod/blocks/state/ModBlockStateProperties.java b/src/main/java/com/pitheguy/magicmod/blocks/state/ModBlockStateProperties.java new file mode 100644 index 0000000..2b14de7 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/blocks/state/ModBlockStateProperties.java @@ -0,0 +1,7 @@ +package com.pitheguy.magicmod.blocks.state; + +import net.minecraft.world.level.block.state.properties.BooleanProperty; + +public class ModBlockStateProperties { + public static final BooleanProperty RUNNING = BooleanProperty.create("running"); +} diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianBareModel.java b/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianBareModel.java index 1537ccd..cb95a9e 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianBareModel.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianBareModel.java @@ -1,57 +1,61 @@ -package com.pitheguy.magicmod.client.entity.model;// Made with Blockbench 4.2.2 -// Exported for Minecraft version 1.15 - 1.16 with MCP mappings +// Made with Blockbench 4.2.2 +// Exported for Minecraft version 1.17 with Mojang mappings // Paste this class into your mod and generate all required imports +package com.pitheguy.magicmod.client.entity.model; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.geom.*; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; + +public class FluffyMagicianBareModel extends EntityModel { + // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor + public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("magicmod", "fluffy_magician_bare"), "main"); + private final ModelPart Leg1; + private final ModelPart Leg2; + private final ModelPart Leg3; + private final ModelPart Leg4; + private final ModelPart Body; + + public FluffyMagicianBareModel(ModelPart root) { + this.Leg1 = root.getChild("Leg1"); + this.Leg2 = root.getChild("Leg2"); + this.Leg3 = root.getChild("Leg3"); + this.Leg4 = root.getChild("Leg4"); + this.Body = root.getChild("Body"); + } + public static LayerDefinition createBodyLayer() { + MeshDefinition meshdefinition = new MeshDefinition(); + PartDefinition partdefinition = meshdefinition.getRoot(); -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.pitheguy.magicmod.entities.FluffyMagicianBare; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.client.renderer.model.ModelRenderer; - -public class FluffyMagicianBareModel extends EntityModel { - private final ModelRenderer Leg1; - private final ModelRenderer Leg2; - private final ModelRenderer Leg3; - private final ModelRenderer Leg4; - private final ModelRenderer Body; - - public FluffyMagicianBareModel() { - textureWidth = 64; - textureHeight = 64; + PartDefinition Leg1 = partdefinition.addOrReplaceChild("Leg1", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Leg1 = new ModelRenderer(this); - Leg1.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg1.setTextureOffset(0, 0).addBox(-5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg2 = partdefinition.addOrReplaceChild("Leg2", CubeListBuilder.create().texOffs(0, 0).addBox(5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.0F, 24.0F, 0.0F)); - Leg2 = new ModelRenderer(this); - Leg2.setRotationPoint(-2.0F, 24.0F, 0.0F); - Leg2.setTextureOffset(0, 0).addBox(5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg3 = partdefinition.addOrReplaceChild("Leg3", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Leg3 = new ModelRenderer(this); - Leg3.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg3.setTextureOffset(0, 0).addBox(-5.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg4 = partdefinition.addOrReplaceChild("Leg4", CubeListBuilder.create().texOffs(0, 0).addBox(3.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Leg4 = new ModelRenderer(this); - Leg4.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg4.setTextureOffset(0, 0).addBox(3.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Body = partdefinition.addOrReplaceChild("Body", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -12.0F, -5.0F, 10.0F, 6.0F, 10.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Body = new ModelRenderer(this); - Body.setRotationPoint(0.0F, 24.0F, 0.0F); - Body.setTextureOffset(0, 0).addBox(-5.0F, -12.0F, -5.0F, 10.0F, 6.0F, 10.0F, 0.0F, false); + return LayerDefinition.create(meshdefinition, 64, 64); } @Override - public void setRotationAngles(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ - //previously the render function, render code was moved to a method below + public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { + } @Override - public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ - Leg1.render(matrixStack, buffer, packedLight, packedOverlay); - Leg2.render(matrixStack, buffer, packedLight, packedOverlay); - Leg3.render(matrixStack, buffer, packedLight, packedOverlay); - Leg4.render(matrixStack, buffer, packedLight, packedOverlay); - Body.render(matrixStack, buffer, packedLight, packedOverlay); + public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + Leg1.render(poseStack, buffer, packedLight, packedOverlay); + Leg2.render(poseStack, buffer, packedLight, packedOverlay); + Leg3.render(poseStack, buffer, packedLight, packedOverlay); + Leg4.render(poseStack, buffer, packedLight, packedOverlay); + Body.render(poseStack, buffer, packedLight, packedOverlay); } } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianModel.java b/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianModel.java index e53a0a6..bcba04b 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianModel.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/model/FluffyMagicianModel.java @@ -1,64 +1,64 @@ -package com.pitheguy.magicmod.client.entity.model;// Made with Blockbench 4.2.2 -// Exported for Minecraft version 1.15 - 1.16 with MCP mappings +// Made with Blockbench 4.2.2 +// Exported for Minecraft version 1.17 with Mojang mappings // Paste this class into your mod and generate all required imports +package com.pitheguy.magicmod.client.entity.model; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.pitheguy.magicmod.entities.FluffyMagician; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.client.renderer.model.ModelRenderer; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; -public class FluffyMagicianModel extends EntityModel { - private final ModelRenderer Leg1; - private final ModelRenderer Leg2; - private final ModelRenderer Leg3; - private final ModelRenderer Leg4; - private final ModelRenderer Body; +public class FluffyMagicianModel extends EntityModel { + // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor + public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("magicmod", "fluffy_magician"), "main"); + private final ModelPart Leg1; + private final ModelPart Leg2; + private final ModelPart Leg3; + private final ModelPart Leg4; + private final ModelPart Body; - public FluffyMagicianModel() { - textureWidth = 64; - textureHeight = 64; + public FluffyMagicianModel(ModelPart root) { + this.Leg1 = root.getChild("Leg1"); + this.Leg2 = root.getChild("Leg2"); + this.Leg3 = root.getChild("Leg3"); + this.Leg4 = root.getChild("Leg4"); + this.Body = root.getChild("Body"); + } - Leg1 = new ModelRenderer(this); - Leg1.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg1.setTextureOffset(0, 0).addBox(-5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + public static LayerDefinition createBodyLayer() { + MeshDefinition meshdefinition = new MeshDefinition(); + PartDefinition partdefinition = meshdefinition.getRoot(); - Leg2 = new ModelRenderer(this); - Leg2.setRotationPoint(-2.0F, 24.0F, 0.0F); - Leg2.setTextureOffset(0, 0).addBox(5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg1 = partdefinition.addOrReplaceChild("Leg1", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Leg3 = new ModelRenderer(this); - Leg3.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg3.setTextureOffset(0, 0).addBox(-5.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg2 = partdefinition.addOrReplaceChild("Leg2", CubeListBuilder.create().texOffs(0, 0).addBox(5.0F, -6.0F, 3.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(-2.0F, 24.0F, 0.0F)); - Leg4 = new ModelRenderer(this); - Leg4.setRotationPoint(0.0F, 24.0F, 0.0F); - Leg4.setTextureOffset(0, 0).addBox(3.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, 0.0F, false); + PartDefinition Leg3 = partdefinition.addOrReplaceChild("Leg3", CubeListBuilder.create().texOffs(0, 0).addBox(-5.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - Body = new ModelRenderer(this); - Body.setRotationPoint(0.0F, 24.0F, 0.0F); - Body.setTextureOffset(0, 0).addBox(-6.0F, -12.0F, -6.0F, 12.0F, 6.0F, 12.0F, 0.0F, false); - } + PartDefinition Leg4 = partdefinition.addOrReplaceChild("Leg4", CubeListBuilder.create().texOffs(0, 0).addBox(3.0F, -6.0F, -5.0F, 2.0F, 6.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); - @Override - public void setRotationAngles(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ - //previously the render function, render code was moved to a method below + PartDefinition Body = partdefinition.addOrReplaceChild("Body", CubeListBuilder.create().texOffs(0, 0).addBox(-6.0F, -12.0F, -6.0F, 12.0F, 6.0F, 12.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F)); + + return LayerDefinition.create(meshdefinition, 64, 64); } @Override - public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ - Leg1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg3.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg4.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); + public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { + } @Override - public void setLivingAnimations(T entityIn, float limbSwing, float limbSwingAmount, float partialTick) { - super.setLivingAnimations(entityIn, limbSwing, limbSwingAmount, partialTick); + public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + Leg1.render(poseStack, buffer, packedLight, packedOverlay); + Leg2.render(poseStack, buffer, packedLight, packedOverlay); + Leg3.render(poseStack, buffer, packedLight, packedOverlay); + Leg4.render(poseStack, buffer, packedLight, packedOverlay); + Body.render(poseStack, buffer, packedLight, packedOverlay); } - - } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/model/MagicFriendModel.java b/src/main/java/com/pitheguy/magicmod/client/entity/model/MagicFriendModel.java index 2fa1308..7567541 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/model/MagicFriendModel.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/model/MagicFriendModel.java @@ -1,170 +1,142 @@ +// Made with Blockbench 4.2.2 +// Exported for Minecraft version 1.17 with Mojang mappings +// Paste this class into your mod and generate all required imports package com.pitheguy.magicmod.client.entity.model; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import com.pitheguy.magicmod.entities.MagicFriend; -import net.minecraft.client.renderer.entity.model.EntityModel; -import net.minecraft.client.renderer.model.ModelRenderer; - -public class MagicFriendModel extends EntityModel { - private final ModelRenderer Body; - private final ModelRenderer TailA; - private final ModelRenderer Leg1A; - private final ModelRenderer Leg2A; - private final ModelRenderer Leg3A; - private final ModelRenderer Leg4A; - private final ModelRenderer Head; - private final ModelRenderer Ear1; - private final ModelRenderer Ear2; - private final ModelRenderer MuleEarL; - private final ModelRenderer MuleEarR; - private final ModelRenderer Neck; - private final ModelRenderer Bag1; - private final ModelRenderer Bag2; - private final ModelRenderer Saddle; - private final ModelRenderer SaddleMouthL; - private final ModelRenderer SaddleMouthR; - private final ModelRenderer SaddleMouthLine; - private final ModelRenderer SaddleMouthLineR; - private final ModelRenderer HeadSaddle; - - public MagicFriendModel() { - textureWidth = 64; - textureHeight = 64; - - Body = new ModelRenderer(this); - Body.setRotationPoint(0.0F, 11.0F, 9.0F); - Body.setTextureOffset(0, 32).addBox(-5.0F, -8.0F, -20.0F, 10.0F, 10.0F, 22.0F, 0.0F, false); - - TailA = new ModelRenderer(this); - TailA.setRotationPoint(0.0F, 4.0F, 11.0F); - setRotationAngle(TailA, 0.5236F, 0.0F, 0.0F); - TailA.setTextureOffset(42, 36).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 14.0F, 4.0F, 0.0F, false); - - Leg1A = new ModelRenderer(this); - Leg1A.setRotationPoint(3.0F, 13.0F, 9.0F); - Leg1A.setTextureOffset(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, 0.0F, true); - - Leg2A = new ModelRenderer(this); - Leg2A.setRotationPoint(-3.0F, 13.0F, 9.0F); - Leg2A.setTextureOffset(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, 0.0F, false); - - Leg3A = new ModelRenderer(this); - Leg3A.setRotationPoint(3.0F, 13.0F, -9.0F); - Leg3A.setTextureOffset(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, 0.0F, true); - - Leg4A = new ModelRenderer(this); - Leg4A.setRotationPoint(-3.0F, 13.0F, -9.0F); - Leg4A.setTextureOffset(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, 0.0F, false); - - Head = new ModelRenderer(this); - Head.setRotationPoint(0.0F, -4.0F, -11.0F); - setRotationAngle(Head, 0.5236F, 0.0F, 0.0F); - Head.setTextureOffset(0, 13).addBox(-3.0F, -5.0F, -6.0F, 6.0F, 5.0F, 7.0F, 0.0F, false); - Head.setTextureOffset(0, 25).addBox(-2.0F, -5.0F, -11.0F, 4.0F, 5.0F, 5.0F, 0.0F, false); - - Ear1 = new ModelRenderer(this); - Ear1.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(Ear1, 0.5236F, 0.0F, 0.0873F); - Ear1.setTextureOffset(19, 16).addBox(-0.5F, -18.0F, 2.99F, 2.0F, 3.0F, 1.0F, 0.0F, true); - - Ear2 = new ModelRenderer(this); - Ear2.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(Ear2, 0.5236F, 0.0F, -0.0873F); - Ear2.setTextureOffset(19, 16).addBox(-1.5F, -18.0F, 2.99F, 2.0F, 3.0F, 1.0F, 0.0F, false); - - MuleEarL = new ModelRenderer(this); - MuleEarL.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(MuleEarL, 0.5236F, 0.0F, 0.2618F); - MuleEarL.setTextureOffset(0, 12).addBox(-3.0F, -22.0F, 2.99F, 2.0F, 7.0F, 1.0F, 0.0F, true); - - MuleEarR = new ModelRenderer(this); - MuleEarR.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(MuleEarR, 0.5236F, 0.0F, -0.2618F); - MuleEarR.setTextureOffset(0, 12).addBox(1.0F, -22.0F, 2.99F, 2.0F, 7.0F, 1.0F, 0.0F, false); - - Neck = new ModelRenderer(this); - Neck.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(Neck, 0.5236F, 0.0F, 0.0F); - Neck.setTextureOffset(0, 35).addBox(-2.0F, -11.0F, -3.0F, 4.0F, 12.0F, 7.0F, 0.0F, false); - Neck.setTextureOffset(56, 36).addBox(-1.0F, -16.0F, 4.0F, 2.0F, 16.0F, 2.0F, 0.0F, false); - - Bag1 = new ModelRenderer(this); - Bag1.setRotationPoint(-5.0F, 3.0F, 11.0F); - setRotationAngle(Bag1, 0.0F, -1.5708F, 0.0F); - Bag1.setTextureOffset(26, 21).addBox(-9.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, 0.0F, false); - - Bag2 = new ModelRenderer(this); - Bag2.setRotationPoint(5.0F, 3.0F, 11.0F); - setRotationAngle(Bag2, 0.0F, 1.5708F, 0.0F); - Bag2.setTextureOffset(26, 21).addBox(1.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, 0.0F, true); - - Saddle = new ModelRenderer(this); - Saddle.setRotationPoint(0.0F, 2.0F, 2.0F); - Saddle.setTextureOffset(26, 0).addBox(-5.0F, 1.0F, -5.5F, 10.0F, 9.0F, 9.0F, 0.5F, false); - - SaddleMouthL = new ModelRenderer(this); - SaddleMouthL.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(SaddleMouthL, 0.5236F, 0.0F, 0.0F); - SaddleMouthL.setTextureOffset(29, 5).addBox(2.0F, -14.0F, -6.0F, 1.0F, 2.0F, 2.0F, 0.0F, false); - - SaddleMouthR = new ModelRenderer(this); - SaddleMouthR.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(SaddleMouthR, 0.5236F, 0.0F, 0.0F); - SaddleMouthR.setTextureOffset(29, 5).addBox(-3.0F, -14.0F, -6.0F, 1.0F, 2.0F, 2.0F, 0.0F, false); - - SaddleMouthLine = new ModelRenderer(this); - SaddleMouthLine.setRotationPoint(0.0F, 7.0F, -8.0F); - SaddleMouthLine.setTextureOffset(32, 2).addBox(3.1F, -10.0F, -11.5F, 0.0F, 3.0F, 16.0F, 0.0F, false); - - SaddleMouthLineR = new ModelRenderer(this); - SaddleMouthLineR.setRotationPoint(0.0F, 7.0F, -8.0F); - SaddleMouthLineR.setTextureOffset(32, 2).addBox(-3.1F, -10.0F, -11.5F, 0.0F, 3.0F, 16.0F, 0.0F, false); - - HeadSaddle = new ModelRenderer(this); - HeadSaddle.setRotationPoint(0.0F, 7.0F, -8.0F); - setRotationAngle(HeadSaddle, 0.5236F, 0.0F, 0.0F); - HeadSaddle.setTextureOffset(19, 0).addBox(-2.0F, -16.0F, -5.0F, 4.0F, 5.0F, 2.0F, 0.25F, false); - HeadSaddle.setTextureOffset(0, 0).addBox(-3.0F, -16.0F, -3.0F, 6.0F, 5.0F, 7.0F, 0.25F, false); + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.geom.ModelLayerLocation; +import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.client.model.geom.PartPose; +import net.minecraft.client.model.geom.builders.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; + +public class MagicFriendModel extends EntityModel { + // This layer location should be baked with EntityRendererProvider.Context in the entity renderer and passed into this model's constructor + public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(new ResourceLocation("magicmod", "magic_friend"), "main"); + private final ModelPart Body; + private final ModelPart TailA; + private final ModelPart Leg1A; + private final ModelPart Leg2A; + private final ModelPart Leg3A; + private final ModelPart Leg4A; + private final ModelPart Head; + private final ModelPart Ear1; + private final ModelPart Ear2; + private final ModelPart MuleEarL; + private final ModelPart MuleEarR; + private final ModelPart Neck; + private final ModelPart Bag1; + private final ModelPart Bag2; + private final ModelPart Saddle; + private final ModelPart SaddleMouthL; + private final ModelPart SaddleMouthR; + private final ModelPart SaddleMouthLine; + private final ModelPart SaddleMouthLineR; + private final ModelPart HeadSaddle; + + public MagicFriendModel(ModelPart root) { + this.Body = root.getChild("Body"); + this.TailA = root.getChild("TailA"); + this.Leg1A = root.getChild("Leg1A"); + this.Leg2A = root.getChild("Leg2A"); + this.Leg3A = root.getChild("Leg3A"); + this.Leg4A = root.getChild("Leg4A"); + this.Head = root.getChild("Head"); + this.Ear1 = root.getChild("Ear1"); + this.Ear2 = root.getChild("Ear2"); + this.MuleEarL = root.getChild("MuleEarL"); + this.MuleEarR = root.getChild("MuleEarR"); + this.Neck = root.getChild("Neck"); + this.Bag1 = root.getChild("Bag1"); + this.Bag2 = root.getChild("Bag2"); + this.Saddle = root.getChild("Saddle"); + this.SaddleMouthL = root.getChild("SaddleMouthL"); + this.SaddleMouthR = root.getChild("SaddleMouthR"); + this.SaddleMouthLine = root.getChild("SaddleMouthLine"); + this.SaddleMouthLineR = root.getChild("SaddleMouthLineR"); + this.HeadSaddle = root.getChild("HeadSaddle"); } - @Override - public void setRotationAngles(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ - //previously the render function, render code was moved to a method below + public static LayerDefinition createBodyLayer() { + MeshDefinition meshdefinition = new MeshDefinition(); + PartDefinition partdefinition = meshdefinition.getRoot(); + + PartDefinition Body = partdefinition.addOrReplaceChild("Body", CubeListBuilder.create().texOffs(0, 32).addBox(-5.0F, -8.0F, -20.0F, 10.0F, 10.0F, 22.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 11.0F, 9.0F)); + + PartDefinition TailA = partdefinition.addOrReplaceChild("TailA", CubeListBuilder.create().texOffs(42, 36).addBox(-1.5F, 0.0F, -2.0F, 3.0F, 14.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 4.0F, 11.0F, 0.5236F, 0.0F, 0.0F)); + + PartDefinition Leg1A = partdefinition.addOrReplaceChild("Leg1A", CubeListBuilder.create().texOffs(48, 21).mirror().addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(3.0F, 13.0F, 9.0F)); + + PartDefinition Leg2A = partdefinition.addOrReplaceChild("Leg2A", CubeListBuilder.create().texOffs(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-3.0F, 13.0F, 9.0F)); + + PartDefinition Leg3A = partdefinition.addOrReplaceChild("Leg3A", CubeListBuilder.create().texOffs(48, 21).mirror().addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offset(3.0F, 13.0F, -9.0F)); + + PartDefinition Leg4A = partdefinition.addOrReplaceChild("Leg4A", CubeListBuilder.create().texOffs(48, 21).addBox(-2.0F, 0.0F, -2.0F, 4.0F, 11.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(-3.0F, 13.0F, -9.0F)); + + PartDefinition Head = partdefinition.addOrReplaceChild("Head", CubeListBuilder.create().texOffs(0, 13).addBox(-3.0F, -5.0F, -6.0F, 6.0F, 5.0F, 7.0F, new CubeDeformation(0.0F)) + .texOffs(0, 25).addBox(-2.0F, -5.0F, -11.0F, 4.0F, 5.0F, 5.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, -4.0F, -11.0F, 0.5236F, 0.0F, 0.0F)); + + PartDefinition Ear1 = partdefinition.addOrReplaceChild("Ear1", CubeListBuilder.create().texOffs(19, 16).mirror().addBox(-0.5F, -18.0F, 2.99F, 2.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.0873F)); + + PartDefinition Ear2 = partdefinition.addOrReplaceChild("Ear2", CubeListBuilder.create().texOffs(19, 16).addBox(-1.5F, -18.0F, 2.99F, 2.0F, 3.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, -0.0873F)); + + PartDefinition MuleEarL = partdefinition.addOrReplaceChild("MuleEarL", CubeListBuilder.create().texOffs(0, 12).mirror().addBox(-3.0F, -22.0F, 2.99F, 2.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.2618F)); + + PartDefinition MuleEarR = partdefinition.addOrReplaceChild("MuleEarR", CubeListBuilder.create().texOffs(0, 12).addBox(1.0F, -22.0F, 2.99F, 2.0F, 7.0F, 1.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, -0.2618F)); + + PartDefinition Neck = partdefinition.addOrReplaceChild("Neck", CubeListBuilder.create().texOffs(0, 35).addBox(-2.0F, -11.0F, -3.0F, 4.0F, 12.0F, 7.0F, new CubeDeformation(0.0F)) + .texOffs(56, 36).addBox(-1.0F, -16.0F, 4.0F, 2.0F, 16.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.0F)); + + PartDefinition Bag1 = partdefinition.addOrReplaceChild("Bag1", CubeListBuilder.create().texOffs(26, 21).addBox(-9.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-5.0F, 3.0F, 11.0F, 0.0F, -1.5708F, 0.0F)); + + PartDefinition Bag2 = partdefinition.addOrReplaceChild("Bag2", CubeListBuilder.create().texOffs(26, 21).mirror().addBox(1.0F, 0.0F, 0.0F, 8.0F, 8.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false), PartPose.offsetAndRotation(5.0F, 3.0F, 11.0F, 0.0F, 1.5708F, 0.0F)); + + PartDefinition Saddle = partdefinition.addOrReplaceChild("Saddle", CubeListBuilder.create().texOffs(26, 0).addBox(-5.0F, 1.0F, -5.5F, 10.0F, 9.0F, 9.0F, new CubeDeformation(0.5F)), PartPose.offset(0.0F, 2.0F, 2.0F)); + + PartDefinition SaddleMouthL = partdefinition.addOrReplaceChild("SaddleMouthL", CubeListBuilder.create().texOffs(29, 5).addBox(2.0F, -14.0F, -6.0F, 1.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.0F)); + + PartDefinition SaddleMouthR = partdefinition.addOrReplaceChild("SaddleMouthR", CubeListBuilder.create().texOffs(29, 5).addBox(-3.0F, -14.0F, -6.0F, 1.0F, 2.0F, 2.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.0F)); + + PartDefinition SaddleMouthLine = partdefinition.addOrReplaceChild("SaddleMouthLine", CubeListBuilder.create().texOffs(32, 2).addBox(3.1F, -10.0F, -11.5F, 0.0F, 3.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 7.0F, -8.0F)); + + PartDefinition SaddleMouthLineR = partdefinition.addOrReplaceChild("SaddleMouthLineR", CubeListBuilder.create().texOffs(32, 2).addBox(-3.1F, -10.0F, -11.5F, 0.0F, 3.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 7.0F, -8.0F)); + + PartDefinition HeadSaddle = partdefinition.addOrReplaceChild("HeadSaddle", CubeListBuilder.create().texOffs(19, 0).addBox(-2.0F, -16.0F, -5.0F, 4.0F, 5.0F, 2.0F, new CubeDeformation(0.25F)) + .texOffs(0, 0).addBox(-3.0F, -16.0F, -3.0F, 6.0F, 5.0F, 7.0F, new CubeDeformation(0.25F)), PartPose.offsetAndRotation(0.0F, 7.0F, -8.0F, 0.5236F, 0.0F, 0.0F)); + + return LayerDefinition.create(meshdefinition, 64, 64); } @Override - public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ - Body.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - TailA.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg1A.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg2A.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg3A.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Leg4A.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Head.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Ear1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Ear2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - MuleEarL.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - MuleEarR.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Neck.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Bag1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Bag2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - Saddle.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - SaddleMouthL.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - SaddleMouthR.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - SaddleMouthLine.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - SaddleMouthLineR.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - HeadSaddle.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha); - } + public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { - public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { - modelRenderer.rotateAngleX = x; - modelRenderer.rotateAngleY = y; - modelRenderer.rotateAngleZ = z; } @Override - public void setLivingAnimations(T entityIn, float limbSwing, float limbSwingAmount, float partialTick) { - super.setLivingAnimations(entityIn, limbSwing, limbSwingAmount, partialTick); + public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { + Body.render(poseStack, buffer, packedLight, packedOverlay); + TailA.render(poseStack, buffer, packedLight, packedOverlay); + Leg1A.render(poseStack, buffer, packedLight, packedOverlay); + Leg2A.render(poseStack, buffer, packedLight, packedOverlay); + Leg3A.render(poseStack, buffer, packedLight, packedOverlay); + Leg4A.render(poseStack, buffer, packedLight, packedOverlay); + Head.render(poseStack, buffer, packedLight, packedOverlay); + Ear1.render(poseStack, buffer, packedLight, packedOverlay); + Ear2.render(poseStack, buffer, packedLight, packedOverlay); + MuleEarL.render(poseStack, buffer, packedLight, packedOverlay); + MuleEarR.render(poseStack, buffer, packedLight, packedOverlay); + Neck.render(poseStack, buffer, packedLight, packedOverlay); + Bag1.render(poseStack, buffer, packedLight, packedOverlay); + Bag2.render(poseStack, buffer, packedLight, packedOverlay); + Saddle.render(poseStack, buffer, packedLight, packedOverlay); + SaddleMouthL.render(poseStack, buffer, packedLight, packedOverlay); + SaddleMouthR.render(poseStack, buffer, packedLight, packedOverlay); + SaddleMouthLine.render(poseStack, buffer, packedLight, packedOverlay); + SaddleMouthLineR.render(poseStack, buffer, packedLight, packedOverlay); + HeadSaddle.render(poseStack, buffer, packedLight, packedOverlay); } } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianBareRender.java b/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianBareRender.java index 28fd078..28906a7 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianBareRender.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianBareRender.java @@ -1,19 +1,20 @@ package com.pitheguy.magicmod.client.entity.render; import com.pitheguy.magicmod.client.entity.model.FluffyMagicianBareModel; +import com.pitheguy.magicmod.client.entity.model.FluffyMagicianModel; import com.pitheguy.magicmod.entities.FluffyMagicianBare; -import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class FluffyMagicianBareRender extends MobRenderer> { - public FluffyMagicianBareRender(EntityRendererManager renderManagerIn) { - super(renderManagerIn, new FluffyMagicianBareModel<>(), 0.5f); + public FluffyMagicianBareRender(EntityRendererProvider.Context context) { + super(context, new FluffyMagicianBareModel<>(context.bakeLayer(FluffyMagicianModel.LAYER_LOCATION)), 0.5f); } @Override - public ResourceLocation getEntityTexture(FluffyMagicianBare entity) { + public ResourceLocation getTextureLocation(FluffyMagicianBare entity) { return new ResourceLocation("magicmod","textures/entities/fluffy_magician_bare.png"); } } diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianRender.java b/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianRender.java index dcc5a89..36ab360 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianRender.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/render/FluffyMagicianRender.java @@ -2,18 +2,18 @@ import com.pitheguy.magicmod.client.entity.model.FluffyMagicianModel; import com.pitheguy.magicmod.entities.FluffyMagician; -import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class FluffyMagicianRender extends MobRenderer> { - public FluffyMagicianRender(EntityRendererManager renderManagerIn) { - super(renderManagerIn, new FluffyMagicianModel<>(), 0.5f); + public FluffyMagicianRender(EntityRendererProvider.Context context) { + super(context, new FluffyMagicianModel<>(context.bakeLayer(FluffyMagicianModel.LAYER_LOCATION)), 0.5f); } @Override - public ResourceLocation getEntityTexture(FluffyMagician entity) { + public ResourceLocation getTextureLocation(FluffyMagician entity) { return new ResourceLocation("magicmod","textures/entities/fluffy_magician.png"); } } diff --git a/src/main/java/com/pitheguy/magicmod/client/entity/render/MagicFriendRender.java b/src/main/java/com/pitheguy/magicmod/client/entity/render/MagicFriendRender.java index ea09ca5..fb77fd5 100644 --- a/src/main/java/com/pitheguy/magicmod/client/entity/render/MagicFriendRender.java +++ b/src/main/java/com/pitheguy/magicmod/client/entity/render/MagicFriendRender.java @@ -2,20 +2,20 @@ import com.pitheguy.magicmod.client.entity.model.MagicFriendModel; import com.pitheguy.magicmod.entities.MagicFriend; -import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.entity.EntityRendererProvider; import net.minecraft.client.renderer.entity.MobRenderer; -import net.minecraft.util.ResourceLocation; +import net.minecraft.resources.ResourceLocation; public class MagicFriendRender extends MobRenderer> { public static final ResourceLocation TEXTURE = new ResourceLocation("magicmod","textures/entities/magic_friend.png"); - public MagicFriendRender(EntityRendererManager renderManagerIn) { - super(renderManagerIn, new MagicFriendModel<>(), 0.5f); + public MagicFriendRender(EntityRendererProvider.Context context) { + super(context, new MagicFriendModel<>(context.bakeLayer(MagicFriendModel.LAYER_LOCATION)), 0.5f); } @Override - public ResourceLocation getEntityTexture(MagicFriend entity) { + public ResourceLocation getTextureLocation(MagicFriend entity) { return TEXTURE; } } diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicCrateScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicCrateScreen.java index 9a1a677..0837112 100644 --- a/src/main/java/com/pitheguy/magicmod/client/gui/MagicCrateScreen.java +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicCrateScreen.java @@ -1,41 +1,38 @@ package com.pitheguy.magicmod.client.gui; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.pitheguy.magicmod.container.MagicCrateContainer; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; +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; -public class MagicCrateScreen extends ContainerScreen { +public class MagicCrateScreen extends AbstractContainerScreen { private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_crate.png"); - public MagicCrateScreen(MagicCrateContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { + public MagicCrateScreen(MagicCrateContainer screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); - this.guiLeft = 0; - this.guiTop = 0; - this.xSize = 212; - this.ySize = 255; + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 212; + this.imageHeight = 255; + this.inventoryLabelY = 163; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); - this.minecraft.getTextureManager().bindTexture(TEXTURE); - this.blit(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - this.font.drawString(this.title.getFormattedText(), 8, 7, 0x404040); - this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8, 163, 0x404040); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - this.renderBackground(); - super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack, mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); } } diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicEnergizerScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicEnergizerScreen.java new file mode 100644 index 0000000..4f14717 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicEnergizerScreen.java @@ -0,0 +1,42 @@ +package com.pitheguy.magicmod.client.gui; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.pitheguy.magicmod.container.MagicEnergizerContainer; +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; + +; + +public class MagicEnergizerScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_energizer.png"); + public MagicEnergizerScreen(MagicEnergizerContainer screenContainer, Inventory inv, Component titleIn) { + super(screenContainer, inv, titleIn); + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 176; + this.imageHeight = 134; + this.inventoryLabelY = 39; + } + + @Override + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.minecraft.getTextureManager().bindForSetup(TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + this.blit(stack, this.leftPos + 49, this.topPos + 20, 0, 137, this.menu.getFuelScaled(), 16); + } + + + @Override + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack,mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicInfuserScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicInfuserScreen.java index a6a0d1f..5837a1e 100644 --- a/src/main/java/com/pitheguy/magicmod/client/gui/MagicInfuserScreen.java +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicInfuserScreen.java @@ -1,41 +1,39 @@ package com.pitheguy.magicmod.client.gui; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.pitheguy.magicmod.container.MagicInfuserContainer; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; +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; -public class MagicInfuserScreen extends ContainerScreen { +public class MagicInfuserScreen extends AbstractContainerScreen { private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_infuser.png"); - public MagicInfuserScreen(MagicInfuserContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { + public MagicInfuserScreen(MagicInfuserContainer screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); - this.guiLeft = 0; - this.guiTop = 0; - this.xSize = 176; - this.ySize = 214; + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 176; + this.imageHeight = 214; + this.inventoryLabelY = 120; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); - this.minecraft.getTextureManager().bindTexture(TEXTURE); - this.blit(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.minecraft.getTextureManager().bindForSetup(TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - this.font.drawString(this.title.getFormattedText(), 8, 8, 0x404040); - this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8, 120, 0x404040); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - this.renderBackground(); - super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack,mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); } } diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicLoggerScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicLoggerScreen.java new file mode 100644 index 0000000..b937c4c --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicLoggerScreen.java @@ -0,0 +1,48 @@ +package com.pitheguy.magicmod.client.gui; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.pitheguy.magicmod.container.MagicLoggerContainer; +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; + +public class MagicLoggerScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_miner.png"); + public MagicLoggerScreen(MagicLoggerContainer screenContainer, Inventory inv, Component titleIn) { + super(screenContainer, inv, titleIn); + + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 201; + this.imageHeight = 186; + this.inventoryLabelY = 94; + } + + @Override + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.menu.tileEntity.updateStatus(); + this.minecraft.getTextureManager().bindForSetup(TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + this.blit(stack, this.leftPos + 116, this.topPos + 93, 0, 188, this.menu.getMineCooldownScaled(), 16); + + } + + @Override + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack, mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); + } + + @Override + protected void renderLabels(PoseStack stack, int mouseX, int mouseY) { + this.font.draw(stack, this.title.plainCopy().append(String.format(" (Status: %s)", this.menu.tileEntity.status.getMessage())), (float) this.titleLabelX, (float) this.titleLabelY, 0x404040); + this.font.draw(stack, this.playerInventoryTitle, (float) this.inventoryLabelX, (float) this.inventoryLabelY, 0x404040); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicMinerScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicMinerScreen.java new file mode 100644 index 0000000..0462455 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicMinerScreen.java @@ -0,0 +1,48 @@ +package com.pitheguy.magicmod.client.gui; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import com.pitheguy.magicmod.container.MagicMinerContainer; +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; + +public class MagicMinerScreen extends AbstractContainerScreen { + private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_miner.png"); + public MagicMinerScreen(MagicMinerContainer screenContainer, Inventory inv, Component titleIn) { + super(screenContainer, inv, titleIn); + + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 201; + this.imageHeight = 186; + this.inventoryLabelY = 94; + } + + @Override + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.menu.tileEntity.updateStatus(); + this.minecraft.getTextureManager().bindForSetup(TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + this.blit(stack, this.leftPos + 116, this.topPos + 93, 0, 188, this.menu.getMineCooldownScaled(), 16); + + } + + @Override + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack, mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); + } + + @Override + protected void renderLabels(PoseStack stack, int mouseX, int mouseY) { + this.font.draw(stack, this.title.plainCopy().append(String.format(" (Status: %s)", this.menu.tileEntity.status.getMessage())), (float) this.titleLabelX, (float) this.titleLabelY, 0x404040); + this.font.draw(stack, this.playerInventoryTitle, (float) this.inventoryLabelX, (float) this.inventoryLabelY, 0x404040); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/client/gui/MagicPressScreen.java b/src/main/java/com/pitheguy/magicmod/client/gui/MagicPressScreen.java index 5733a83..a162c8e 100644 --- a/src/main/java/com/pitheguy/magicmod/client/gui/MagicPressScreen.java +++ b/src/main/java/com/pitheguy/magicmod/client/gui/MagicPressScreen.java @@ -1,42 +1,40 @@ package com.pitheguy.magicmod.client.gui; import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; import com.pitheguy.magicmod.container.MagicPressContainer; -import net.minecraft.client.gui.screen.inventory.ContainerScreen; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.ITextComponent; +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; -public class MagicPressScreen extends ContainerScreen { +public class MagicPressScreen extends AbstractContainerScreen { private static final ResourceLocation TEXTURE = new ResourceLocation("magicmod", "textures/gui/magic_press.png"); - public MagicPressScreen(MagicPressContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) { + public MagicPressScreen(MagicPressContainer screenContainer, Inventory inv, Component titleIn) { super(screenContainer, inv, titleIn); - this.guiLeft = 0; - this.guiTop = 0; - this.xSize = 176; - this.ySize = 162; + this.leftPos = 0; + this.topPos = 0; + this.imageWidth = 176; + this.imageHeight = 162; + this.inventoryLabelY = 70; } @Override - protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f); - this.minecraft.getTextureManager().bindTexture(TEXTURE); - this.blit(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); - this.blit(this.guiLeft + 49, this.guiTop + 53, 0, 165, this.container.getFuelScaled(), 16); + protected void renderBg(PoseStack stack, float partialTicks, int mouseX, int mouseY) { + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + RenderSystem.setShaderTexture(0, TEXTURE); + this.minecraft.getTextureManager().bindForSetup(TEXTURE); + this.blit(stack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight); + this.blit(stack, this.leftPos + 49, this.topPos + 53, 0, 165, this.menu.getFuelScaled(), 16); } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - this.font.drawString(this.title.getFormattedText(), 8, 8, 0x404040); - this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8, 70, 0x404040); - } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - this.renderBackground(); - super.render(mouseX, mouseY, partialTicks); - this.renderHoveredToolTip(mouseX, mouseY); + public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { + this.renderBackground(stack); + super.render(stack, mouseX, mouseY, partialTicks); + this.renderTooltip(stack, mouseX, mouseY); } } diff --git a/src/main/java/com/pitheguy/magicmod/container/AutoActionContainer.java b/src/main/java/com/pitheguy/magicmod/container/AutoActionContainer.java new file mode 100644 index 0000000..3791907 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/AutoActionContainer.java @@ -0,0 +1,94 @@ +package com.pitheguy.magicmod.container; + +import com.pitheguy.magicmod.container.itemhandlers.ExcludeUpgradesSlotItemHandler; +import com.pitheguy.magicmod.container.itemhandlers.UpgradeSlotItemHandler; +import com.pitheguy.magicmod.blockentity.AutoActionBlockEntity; +import com.pitheguy.magicmod.util.FunctionalIntDataSlot; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; + +import javax.annotation.Nonnull; + +public abstract class AutoActionContainer extends AbstractContainerMenu { + + public T tileEntity; + protected final ContainerLevelAccess canInteractWithCallable; + public FunctionalIntDataSlot mineCooldown; + + //Server constructor + public AutoActionContainer(final int windowID, final Inventory playerInv, final T tile, MenuType containerType) { + super(containerType, windowID); + this.tileEntity = tile; + + //Upgrade Slots + this.addSlot(new UpgradeSlotItemHandler(tile.getInventory(), 36, 177, 26, this.tileEntity)); + this.addSlot(new UpgradeSlotItemHandler(tile.getInventory(), 37, 177, 44, this.tileEntity)); + this.canInteractWithCallable = ContainerLevelAccess.create(tile.getLevel(), tile.getBlockPos()); + final int slotSizePlus2 = 18; + final int startX = 8; + //Inventory + int startY = 18; + for (int row = 0; row < 4; row++) { + for (int column = 0; column < 9; column++) { + this.addSlot(new ExcludeUpgradesSlotItemHandler(tile.getInventory(), (row * 9) + column, startX + (column * slotSizePlus2), startY + (row * slotSizePlus2))); + } + } + + //Hotbar + int hotbarY = 162; + for (int col = 0; col < 9; col++) { + this.addSlot(new Slot(playerInv, col, (startX + (col * slotSizePlus2)), hotbarY)); + } + //Main Player Inventory + int invStartY = 105; + for (int row = 0; row < 3; row++) { + for (int col = 0; col < 9; col++) { + this.addSlot(new Slot(playerInv, 9+(row*9)+col, startX + (col * slotSizePlus2), invStartY + (row * slotSizePlus2))); + } + } + this.addDataSlot(mineCooldown = new FunctionalIntDataSlot(() -> this.tileEntity.mineCooldown, + value -> this.tileEntity.mineCooldown = value)); + } + + @Override + public abstract boolean stillValid(Player playerIn); + + @Nonnull + @Override + public ItemStack quickMoveStack(final Player player, final int index) { + ItemStack returnStack = ItemStack.EMPTY; + final Slot slot = this.slots.get(index); + if (slot != null && slot.hasItem()) { + final ItemStack slotStack = slot.getItem(); + returnStack = slotStack.copy(); + + final int containerSlots = this.slots.size() - player.getInventory().items.size(); + if (index < containerSlots) { + if (!moveItemStackTo(slotStack, containerSlots, this.slots.size(), true)) { + return ItemStack.EMPTY; + } + } else if (!moveItemStackTo(slotStack, 0, containerSlots, false)) { + return ItemStack.EMPTY; + } + if (slotStack.getCount() == 0) { + slot.set(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + if (slotStack.getCount() == returnStack.getCount()) { + return ItemStack.EMPTY; + } + slot.onTake(player, slotStack); + } + return returnStack; + } + + public int getMineCooldownScaled() { + return this.mineCooldown.get() != 0 && this.tileEntity.mineCooldown != 0 ? 52 - this.mineCooldown.get() * 52 / this.tileEntity.ticksPerMine : 0; + } +} diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicCrateContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicCrateContainer.java index 0a95144..28d721d 100644 --- a/src/main/java/com/pitheguy/magicmod/container/MagicCrateContainer.java +++ b/src/main/java/com/pitheguy/magicmod/container/MagicCrateContainer.java @@ -1,33 +1,29 @@ package com.pitheguy.magicmod.container; import com.pitheguy.magicmod.init.ModContainerTypes; -import com.pitheguy.magicmod.tileentity.MagicCrateTileEntity; +import com.pitheguy.magicmod.blockentity.MagicCrateBlockEntity; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IWorldPosCallable; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; import java.util.Objects; -public class MagicCrateContainer extends Container { +public class MagicCrateContainer extends AbstractContainerMenu { - public final MagicCrateTileEntity tileEntity; - private final IWorldPosCallable canInteractWithCallable; + public final MagicCrateBlockEntity tileEntity; + private final ContainerLevelAccess canInteractWithCallable; - public MagicCrateContainer(final int windowId, final PlayerInventory playerInventory, - final MagicCrateTileEntity tileEntity) { + public MagicCrateContainer(final int windowId, final Inventory playerInventory, + final MagicCrateBlockEntity tileEntity) { super(ModContainerTypes.MAGIC_CRATE.get(), windowId); this.tileEntity = tileEntity; - this.canInteractWithCallable = IWorldPosCallable.of(tileEntity.getWorld(), tileEntity.getPos()); + this.canInteractWithCallable = ContainerLevelAccess.create(tileEntity.getLevel(), tileEntity.getBlockPos()); // Main Inventory int startX = 8; @@ -57,56 +53,47 @@ public MagicCrateContainer(final int windowId, final PlayerInventory playerInven } } - private static MagicCrateTileEntity getTileEntity(final PlayerInventory playerInventory, - final PacketBuffer data) { + private static MagicCrateBlockEntity getTileEntity(final Inventory playerInventory, + final FriendlyByteBuf data) { Objects.requireNonNull(playerInventory, "playerInventory cannot be null"); Objects.requireNonNull(data, "data cannot be null"); - final TileEntity tileAtPos = playerInventory.player.world.getTileEntity(data.readBlockPos()); - if (tileAtPos instanceof MagicCrateTileEntity) { - return (MagicCrateTileEntity) tileAtPos; + final BlockEntity tileAtPos = playerInventory.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicCrateBlockEntity) { + return (MagicCrateBlockEntity) tileAtPos; } throw new IllegalStateException("Tile entity is not correct! " + tileAtPos); } - public MagicCrateContainer(final int windowId, final PlayerInventory playerInventory, final PacketBuffer data) { + public MagicCrateContainer(final int windowId, final Inventory playerInventory, final FriendlyByteBuf data) { this(windowId, playerInventory, getTileEntity(playerInventory, data)); } @Override - public boolean canInteractWith(PlayerEntity playerIn) { - return isWithinUsableDistance(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_CRATE.get()); + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_CRATE.get()); } @Override - public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { + public ItemStack quickMoveStack(Player playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; - Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); + Slot slot = this.slots.get(index); + if (slot != null && slot.hasItem()) { + ItemStack itemstack1 = slot.getItem(); itemstack = itemstack1.copy(); if (index < 88) { - if (!this.mergeItemStack(itemstack1, 88, this.inventorySlots.size(), true)) { + if (!this.moveItemStackTo(itemstack1, 88, this.slots.size(), true)) { return ItemStack.EMPTY; } - } else if (!this.mergeItemStack(itemstack1, 0, 88, false)) { + } else if (!this.moveItemStackTo(itemstack1, 0, 88, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { - slot.putStack(ItemStack.EMPTY); + slot.set(ItemStack.EMPTY); } else { - slot.onSlotChanged(); + slot.setChanged(); } } return itemstack; } - - @Override - public void onContainerClosed(PlayerEntity playerIn) { - super.onContainerClosed(playerIn); - World world = tileEntity.getWorld(); - BlockPos pos = tileEntity.getPos(); - world.playSound(null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.BLOCK_BARREL_CLOSE, SoundCategory.BLOCKS, 0.5f, - world.rand.nextFloat() * 0.1f + 0.9f); - } } diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicEnergizerContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicEnergizerContainer.java new file mode 100644 index 0000000..fc9674b --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/MagicEnergizerContainer.java @@ -0,0 +1,110 @@ +package com.pitheguy.magicmod.container; + +import com.pitheguy.magicmod.container.itemhandlers.SingleItemSlotItemHandler; +import com.pitheguy.magicmod.init.ModContainerTypes; +import com.pitheguy.magicmod.blockentity.MagicEnergizerBlockEntity; +import com.pitheguy.magicmod.util.FunctionalIntDataSlot; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +import javax.annotation.Nonnull; +import java.util.Objects; + +import static com.pitheguy.magicmod.util.RegistryHandler.MAGIC_FUEL; + +public class MagicEnergizerContainer extends AbstractContainerMenu { + + public MagicEnergizerBlockEntity tileEntity; + private final ContainerLevelAccess canInteractWithCallable; + public FunctionalIntDataSlot fuel; + + //Server constructor + public MagicEnergizerContainer(final int windowID, final Inventory playerInv, final MagicEnergizerBlockEntity tile) { + super(ModContainerTypes.MAGIC_ENERGIZER.get(), windowID); + this.canInteractWithCallable = ContainerLevelAccess.create(tile.getLevel(), tile.getBlockPos()); + this.tileEntity = tile; + final int slotSizePlus2 = 18; + final int startX = 8; + //Magic Energizer Inventory + this.addSlot(new SingleItemSlotItemHandler(tile.getInventory(), 0, 15, 20, MAGIC_FUEL.get())); + this.addDataSlot(fuel = new FunctionalIntDataSlot(() -> this.tileEntity.fuel, + value -> this.tileEntity.fuel = value)); + //Hotbar + int hotbarY = 110; + for (int col = 0; col < 9; col++) { + this.addSlot(new Slot(playerInv, col, (startX + (col * slotSizePlus2)), hotbarY)); + } + //Main Player Inventory + int startY = 52; + for (int row = 0; row < 3; row++) { + for (int col = 0; col < 9; col++) { + this.addSlot(new Slot(playerInv, 9+(row*9)+col, startX + (col * slotSizePlus2), startY + (row * slotSizePlus2))); + } + } + + } + //Client constructor + public MagicEnergizerContainer(final int windowID, final Inventory playerInv, final FriendlyByteBuf data) { + this(windowID, playerInv, getTileEntity(playerInv, data)); + } + + private static MagicEnergizerBlockEntity getTileEntity(final Inventory playerInv, final FriendlyByteBuf data) { + Objects.requireNonNull(playerInv, "playerInv cannot be null"); + Objects.requireNonNull(data, "data cannot be null"); + final BlockEntity tileAtPos = playerInv.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicEnergizerBlockEntity) { + return (MagicEnergizerBlockEntity) tileAtPos; + } + throw new IllegalStateException("TileEntity is not correct " + tileAtPos); + } + + @Override + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_ENERGIZER.get()); + } + + @Nonnull + @Override + public ItemStack quickMoveStack(final Player player, final int index) { + ItemStack returnStack = ItemStack.EMPTY; + final Slot slot = this.slots.get(index); + if (slot != null && slot.hasItem()) { + final ItemStack slotStack = slot.getItem(); + returnStack = slotStack.copy(); + + final int containerSlots = this.slots.size() - player.getInventory().items.size(); + if (index < containerSlots) { + if (!moveItemStackTo(slotStack, containerSlots, this.slots.size(), true)) { + return ItemStack.EMPTY; + } + } else if (!moveItemStackTo(slotStack, 0, containerSlots, false)) { + return ItemStack.EMPTY; + } + if (slotStack.getCount() == 0) { + slot.set(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + if (slotStack.getCount() == returnStack.getCount()) { + return ItemStack.EMPTY; + } + slot.onTake(player, slotStack); + } + return returnStack; + } + + @OnlyIn(Dist.CLIENT) + public int getFuelScaled() { + return this.fuel.get() != 0 && this.tileEntity.fuel != 0 ? this.fuel.get() * 112 / MagicEnergizerBlockEntity.MAX_FUEL : 0; + } + +} diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicInfuserContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicInfuserContainer.java index 4d9f754..769053b 100644 --- a/src/main/java/com/pitheguy/magicmod/container/MagicInfuserContainer.java +++ b/src/main/java/com/pitheguy/magicmod/container/MagicInfuserContainer.java @@ -2,29 +2,29 @@ import com.pitheguy.magicmod.container.itemhandlers.SingleItemSlotItemHandler; import com.pitheguy.magicmod.init.ModContainerTypes; -import com.pitheguy.magicmod.tileentity.MagicInfuserTileEntity; +import com.pitheguy.magicmod.blockentity.MagicInfuserBlockEntity; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IWorldPosCallable; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; import javax.annotation.Nonnull; import java.util.Objects; -public class MagicInfuserContainer extends Container { +public class MagicInfuserContainer extends AbstractContainerMenu { - private final IWorldPosCallable canInteractWithCallable; + private final ContainerLevelAccess canInteractWithCallable; //Server constructor - public MagicInfuserContainer(final int windowID, final PlayerInventory playerInv, final MagicInfuserTileEntity tile) { + public MagicInfuserContainer(final int windowID, final Inventory playerInv, final MagicInfuserBlockEntity tile) { super(ModContainerTypes.MAGIC_INFUSER.get(), windowID); - this.canInteractWithCallable = IWorldPosCallable.of(tile.getWorld(), tile.getPos()); + this.canInteractWithCallable = ContainerLevelAccess.create(tile.getLevel(), tile.getBlockPos()); final int slotSizePlus2 = 18; final int startX = 8; @@ -51,46 +51,46 @@ public MagicInfuserContainer(final int windowID, final PlayerInventory playerInv } //Client constructor - public MagicInfuserContainer(final int windowID, final PlayerInventory playerInv, final PacketBuffer data) { + public MagicInfuserContainer(final int windowID, final Inventory playerInv, final FriendlyByteBuf data) { this(windowID, playerInv, getTileEntity(playerInv, data)); } - private static MagicInfuserTileEntity getTileEntity(final PlayerInventory playerInv, final PacketBuffer data) { + private static MagicInfuserBlockEntity getTileEntity(final Inventory playerInv, final FriendlyByteBuf data) { Objects.requireNonNull(playerInv, "playerInv cannot be null"); Objects.requireNonNull(data, "data cannot be null"); - final TileEntity tileAtPos = playerInv.player.world.getTileEntity(data.readBlockPos()); - if (tileAtPos instanceof MagicInfuserTileEntity) { - return (MagicInfuserTileEntity) tileAtPos; + final BlockEntity tileAtPos = playerInv.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicInfuserBlockEntity) { + return (MagicInfuserBlockEntity) tileAtPos; } throw new IllegalStateException("TileEntity is not correct " + tileAtPos); } @Override - public boolean canInteractWith(PlayerEntity playerIn) { - return isWithinUsableDistance(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_INFUSER.get()); + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_INFUSER.get()); } @Nonnull @Override - public ItemStack transferStackInSlot(final PlayerEntity player, final int index) { + public ItemStack quickMoveStack(final Player player, final int index) { ItemStack returnStack = ItemStack.EMPTY; - final Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) { - final ItemStack slotStack = slot.getStack(); + final Slot slot = this.slots.get(index); + if (slot != null && slot.hasItem()) { + final ItemStack slotStack = slot.getItem(); returnStack = slotStack.copy(); - final int containerSlots = this.inventorySlots.size() - player.inventory.mainInventory.size(); + final int containerSlots = this.slots.size() - player.getInventory().items.size(); if (index < containerSlots) { - if (!mergeItemStack(slotStack, containerSlots, this.inventorySlots.size(), true)) { + if (!moveItemStackTo(slotStack, containerSlots, this.slots.size(), true)) { return ItemStack.EMPTY; } - } else if (!mergeItemStack(slotStack, 0, containerSlots, false)) { + } else if (!moveItemStackTo(slotStack, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (slotStack.getCount() == 0) { - slot.putStack(ItemStack.EMPTY); + slot.set(ItemStack.EMPTY); } else { - slot.onSlotChanged(); + slot.setChanged(); } if (slotStack.getCount() == returnStack.getCount()) { return ItemStack.EMPTY; diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicLoggerContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicLoggerContainer.java new file mode 100644 index 0000000..0d537b4 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/MagicLoggerContainer.java @@ -0,0 +1,39 @@ +package com.pitheguy.magicmod.container; + +import com.pitheguy.magicmod.init.ModContainerTypes; +import com.pitheguy.magicmod.blockentity.MagicLoggerBlockEntity; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; + +import java.util.Objects; + +public class MagicLoggerContainer extends AutoActionContainer { + + + //Server constructor + public MagicLoggerContainer(final int windowID, final Inventory playerInv, final MagicLoggerBlockEntity tile) { + super(windowID, playerInv, tile, ModContainerTypes.MAGIC_LOGGER.get()); + } + //Client constructor + public MagicLoggerContainer(final int windowID, final Inventory playerInv, final FriendlyByteBuf data) { + this(windowID, playerInv, getTileEntity(playerInv, data)); + } + + private static MagicLoggerBlockEntity getTileEntity(final Inventory playerInv, final FriendlyByteBuf data) { + Objects.requireNonNull(playerInv, "playerInv cannot be null"); + Objects.requireNonNull(data, "data cannot be null"); + final BlockEntity tileAtPos = playerInv.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicLoggerBlockEntity) { + return (MagicLoggerBlockEntity) tileAtPos; + } + throw new IllegalStateException("TileEntity is not correct " + tileAtPos); + } + + @Override + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_LOGGER.get()); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicMinerContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicMinerContainer.java new file mode 100644 index 0000000..4f9dd29 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/MagicMinerContainer.java @@ -0,0 +1,39 @@ +package com.pitheguy.magicmod.container; + +import com.pitheguy.magicmod.init.ModContainerTypes; +import com.pitheguy.magicmod.blockentity.MagicMinerBlockEntity; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.block.entity.BlockEntity; + +import java.util.Objects; + +public class MagicMinerContainer extends AutoActionContainer { + + + //Server constructor + public MagicMinerContainer(final int windowID, final Inventory playerInv, final MagicMinerBlockEntity tile) { + super(windowID, playerInv, tile, ModContainerTypes.MAGIC_MINER.get()); + } + //Client constructor + public MagicMinerContainer(final int windowID, final Inventory playerInv, final FriendlyByteBuf data) { + this(windowID, playerInv, getTileEntity(playerInv, data)); + } + + private static MagicMinerBlockEntity getTileEntity(final Inventory playerInv, final FriendlyByteBuf data) { + Objects.requireNonNull(playerInv, "playerInv cannot be null"); + Objects.requireNonNull(data, "data cannot be null"); + final BlockEntity tileAtPos = playerInv.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicMinerBlockEntity) { + return (MagicMinerBlockEntity) tileAtPos; + } + throw new IllegalStateException("TileEntity is not correct " + tileAtPos); + } + + @Override + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_MINER.get()); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/container/MagicPressContainer.java b/src/main/java/com/pitheguy/magicmod/container/MagicPressContainer.java index ff2dbac..89308b4 100644 --- a/src/main/java/com/pitheguy/magicmod/container/MagicPressContainer.java +++ b/src/main/java/com/pitheguy/magicmod/container/MagicPressContainer.java @@ -3,17 +3,17 @@ import com.pitheguy.magicmod.container.itemhandlers.MultiItemSlotItemHandler; import com.pitheguy.magicmod.container.itemhandlers.SingleItemSlotItemHandler; import com.pitheguy.magicmod.init.ModContainerTypes; -import com.pitheguy.magicmod.tileentity.MagicPressTileEntity; -import com.pitheguy.magicmod.util.FunctionalIntReferenceHolder; +import com.pitheguy.magicmod.blockentity.MagicPressBlockEntity; +import com.pitheguy.magicmod.util.FunctionalIntDataSlot; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.container.Container; -import net.minecraft.inventory.container.Slot; -import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IWorldPosCallable; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ContainerLevelAccess; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -23,16 +23,16 @@ import static com.pitheguy.magicmod.util.RegistryHandler.*; -public class MagicPressContainer extends Container { +public class MagicPressContainer extends AbstractContainerMenu { - public MagicPressTileEntity tileEntity; - private final IWorldPosCallable canInteractWithCallable; - public FunctionalIntReferenceHolder fuel; + public MagicPressBlockEntity tileEntity; + private final ContainerLevelAccess canInteractWithCallable; + public FunctionalIntDataSlot fuel; //Server constructor - public MagicPressContainer(final int windowID, final PlayerInventory playerInv, final MagicPressTileEntity tile) { + public MagicPressContainer(final int windowID, final Inventory playerInv, final MagicPressBlockEntity tile) { super(ModContainerTypes.MAGIC_PRESS.get(), windowID); - this.canInteractWithCallable = IWorldPosCallable.of(tile.getWorld(), tile.getPos()); + this.canInteractWithCallable = ContainerLevelAccess.create(tile.getLevel(), tile.getBlockPos()); this.tileEntity = tile; final int slotSizePlus2 = 18; final int startX = 8; @@ -54,51 +54,51 @@ public MagicPressContainer(final int windowID, final PlayerInventory playerInv, this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 2, 134,19, Arrays.asList(OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_PICKAXE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_AXE.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_SHOVEL.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_SWORD.get(), OBSIDIAN_PLATED_REINFORCED_MAGIC_HOE.get()))); this.addSlot(new MultiItemSlotItemHandler(tile.getInventory(), 3,15,53, Arrays.asList(MAGIC_GEM.get(), MAGIC_BLOCK_ITEM.get()))); - this.trackInt(fuel = new FunctionalIntReferenceHolder(() -> this.tileEntity.fuel, + this.addDataSlot(fuel = new FunctionalIntDataSlot(() -> this.tileEntity.fuel, value -> this.tileEntity.fuel = value)); } //Client constructor - public MagicPressContainer(final int windowID, final PlayerInventory playerInv, final PacketBuffer data) { + public MagicPressContainer(final int windowID, final Inventory playerInv, final FriendlyByteBuf data) { this(windowID, playerInv, getTileEntity(playerInv, data)); } - private static MagicPressTileEntity getTileEntity(final PlayerInventory playerInv, final PacketBuffer data) { + private static MagicPressBlockEntity getTileEntity(final Inventory playerInv, final FriendlyByteBuf data) { Objects.requireNonNull(playerInv, "playerInv cannot be null"); Objects.requireNonNull(data, "data cannot be null"); - final TileEntity tileAtPos = playerInv.player.world.getTileEntity(data.readBlockPos()); - if (tileAtPos instanceof MagicPressTileEntity) { - return (MagicPressTileEntity) tileAtPos; + final BlockEntity tileAtPos = playerInv.player.level.getBlockEntity(data.readBlockPos()); + if (tileAtPos instanceof MagicPressBlockEntity) { + return (MagicPressBlockEntity) tileAtPos; } throw new IllegalStateException("TileEntity is not correct " + tileAtPos); } @Override - public boolean canInteractWith(PlayerEntity playerIn) { - return isWithinUsableDistance(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_PRESS.get()); + public boolean stillValid(Player playerIn) { + return stillValid(canInteractWithCallable, playerIn, RegistryHandler.MAGIC_PRESS.get()); } @Nonnull @Override - public ItemStack transferStackInSlot(final PlayerEntity player, final int index) { + public ItemStack quickMoveStack(final Player player, final int index) { ItemStack returnStack = ItemStack.EMPTY; - final Slot slot = this.inventorySlots.get(index); - if (slot != null && slot.getHasStack()) { - final ItemStack slotStack = slot.getStack(); + final Slot slot = this.slots.get(index); + if (slot != null && slot.hasItem()) { + final ItemStack slotStack = slot.getItem(); returnStack = slotStack.copy(); - final int containerSlots = this.inventorySlots.size() - player.inventory.mainInventory.size(); + final int containerSlots = this.slots.size() - player.getInventory().items.size(); if (index < containerSlots) { - if (!mergeItemStack(slotStack, containerSlots, this.inventorySlots.size(), true)) { + if (!moveItemStackTo(slotStack, containerSlots, this.slots.size(), true)) { return ItemStack.EMPTY; } - } else if (!mergeItemStack(slotStack, 0, containerSlots, false)) { + } else if (!moveItemStackTo(slotStack, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (slotStack.getCount() == 0) { - slot.putStack(ItemStack.EMPTY); + slot.set(ItemStack.EMPTY); } else { - slot.onSlotChanged(); + slot.setChanged(); } if (slotStack.getCount() == returnStack.getCount()) { return ItemStack.EMPTY; diff --git a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/ExcludeUpgradesSlotItemHandler.java b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/ExcludeUpgradesSlotItemHandler.java new file mode 100644 index 0000000..875e814 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/ExcludeUpgradesSlotItemHandler.java @@ -0,0 +1,19 @@ +package com.pitheguy.magicmod.container.itemhandlers; + +import com.pitheguy.magicmod.items.UpgradeItem; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.SlotItemHandler; + +import javax.annotation.Nonnull; + +public class ExcludeUpgradesSlotItemHandler extends SlotItemHandler { + public ExcludeUpgradesSlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition) { + super(itemHandler, index, xPosition, yPosition); + } + + @Override + public boolean mayPlace(@Nonnull ItemStack stack) { + return !(stack.getItem() instanceof UpgradeItem) && super.mayPlace(stack); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/MultiItemSlotItemHandler.java b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/MultiItemSlotItemHandler.java index 2dcce5e..0acc3ad 100644 --- a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/MultiItemSlotItemHandler.java +++ b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/MultiItemSlotItemHandler.java @@ -1,11 +1,11 @@ package com.pitheguy.magicmod.container.itemhandlers; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; -import org.jetbrains.annotations.NotNull; +import javax.annotation.Nonnull; import java.util.List; public class MultiItemSlotItemHandler extends SlotItemHandler { @@ -16,7 +16,7 @@ public MultiItemSlotItemHandler(IItemHandler itemHandler, int index, int xPositi } @Override - public boolean isItemValid(@NotNull ItemStack stack) { - return validItem.contains(stack.getItem()) && super.isItemValid(stack); + public boolean mayPlace(@Nonnull ItemStack stack) { + return validItem.contains(stack.getItem()) && super.mayPlace(stack); } } diff --git a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/SingleItemSlotItemHandler.java b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/SingleItemSlotItemHandler.java index 67f39e1..c1b172c 100644 --- a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/SingleItemSlotItemHandler.java +++ b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/SingleItemSlotItemHandler.java @@ -1,10 +1,11 @@ package com.pitheguy.magicmod.container.itemhandlers; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; -import org.jetbrains.annotations.NotNull; + +import javax.annotation.Nonnull; public class SingleItemSlotItemHandler extends SlotItemHandler { final Item validItem; @@ -14,11 +15,7 @@ public SingleItemSlotItemHandler(IItemHandler itemHandler, int index, int xPosit } @Override - public boolean isItemValid(@NotNull ItemStack stack) { - if (stack.getItem() == validItem) { - return super.isItemValid(stack); - } else { - return false; - } + public boolean mayPlace(@Nonnull ItemStack stack) { + return stack.getItem() == validItem && super.mayPlace(stack); } } diff --git a/src/main/java/com/pitheguy/magicmod/container/itemhandlers/UpgradeSlotItemHandler.java b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/UpgradeSlotItemHandler.java new file mode 100644 index 0000000..053ca47 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/container/itemhandlers/UpgradeSlotItemHandler.java @@ -0,0 +1,57 @@ +package com.pitheguy.magicmod.container.itemhandlers; + +import com.pitheguy.magicmod.items.UpgradeItem; +import com.pitheguy.magicmod.blockentity.AutoActionBlockEntity; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.SlotItemHandler; + +import javax.annotation.Nonnull; +import java.util.stream.IntStream; + +public class UpgradeSlotItemHandler extends SlotItemHandler { + private final AutoActionBlockEntity tileEntity; + public UpgradeSlotItemHandler(IItemHandler itemHandler, int index, int xPosition, int yPosition, AutoActionBlockEntity tileEntity) { + super(itemHandler, index, xPosition, yPosition); + this.tileEntity = tileEntity; + } + + @Override + public boolean mayPlace(@Nonnull ItemStack stack) { + return super.mayPlace(stack) && stack.getItem() instanceof UpgradeItem && (stack.getItem() != RegistryHandler.FILTER_UPGRADE.get() || IntStream.range(0, this.tileEntity.getInventory().getSlots()).noneMatch(i -> this.tileEntity.getInventory().getStackInSlot(i).getItem() == RegistryHandler.FILTER_UPGRADE.get())); + } + + @Override + public int getMaxStackSize() { + return 1; + } + + @Override + public int getMaxStackSize(@Nonnull ItemStack stack) { + ItemStack maxAdd = stack.copy(); + int maxInput = 1; + maxAdd.setCount(maxInput); + + IItemHandler handler = this.getItemHandler(); + ItemStack currentStack = handler.getStackInSlot(this.getSlotIndex()); + if (handler instanceof IItemHandlerModifiable) { + IItemHandlerModifiable handlerModifiable = (IItemHandlerModifiable) handler; + + handlerModifiable.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY); + + ItemStack remainder = handlerModifiable.insertItem(this.getSlotIndex(), maxAdd, true); + + handlerModifiable.setStackInSlot(this.getSlotIndex(), currentStack); + + return maxInput - remainder.getCount(); + } else { + ItemStack remainder = handler.insertItem(this.getSlotIndex(), maxAdd, true); + + int current = currentStack.getCount(); + int added = maxInput - remainder.getCount(); + return current + added; + } + } +} diff --git a/src/main/java/com/pitheguy/magicmod/enchantments/MagicFinderEnchantment.java b/src/main/java/com/pitheguy/magicmod/enchantments/MagicFinderEnchantment.java index 425494a..152575e 100644 --- a/src/main/java/com/pitheguy/magicmod/enchantments/MagicFinderEnchantment.java +++ b/src/main/java/com/pitheguy/magicmod/enchantments/MagicFinderEnchantment.java @@ -3,15 +3,15 @@ import com.pitheguy.magicmod.tools.MagicAxe; import com.pitheguy.magicmod.tools.MagicPickaxe; import com.pitheguy.magicmod.tools.MagicShovel; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.item.enchantment.Enchantments; public class MagicFinderEnchantment extends Enchantment { - public MagicFinderEnchantment(Rarity rarityIn, EnchantmentType typeIn, EquipmentSlotType[] slots) { + public MagicFinderEnchantment(Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot[] slots) { super(rarityIn, typeIn, slots); } @@ -21,18 +21,18 @@ public int getMaxLevel() { } @Override - public boolean isTreasureEnchantment() { + public boolean isTreasureOnly() { return true; } @Override - protected boolean canApplyTogether(Enchantment ench) { - return super.canApplyTogether(ench) && ench != Enchantments.SILK_TOUCH; + protected boolean checkCompatibility(Enchantment ench) { + return super.checkCompatibility(ench) && ench != Enchantments.SILK_TOUCH; } @Override - public boolean canApply(ItemStack stack) { + public boolean canEnchant(ItemStack stack) { Item item = stack.getItem(); - return super.canApply(stack) && (item instanceof MagicShovel || item instanceof MagicPickaxe || item instanceof MagicAxe); + return super.canEnchant(stack) && (item instanceof MagicShovel || item instanceof MagicPickaxe || item instanceof MagicAxe); } } diff --git a/src/main/java/com/pitheguy/magicmod/enchantments/VeinminerEnchantment.java b/src/main/java/com/pitheguy/magicmod/enchantments/VeinminerEnchantment.java index cd49288..3da9f83 100644 --- a/src/main/java/com/pitheguy/magicmod/enchantments/VeinminerEnchantment.java +++ b/src/main/java/com/pitheguy/magicmod/enchantments/VeinminerEnchantment.java @@ -4,15 +4,15 @@ import com.pitheguy.magicmod.tools.MagicPickaxe; import com.pitheguy.magicmod.tools.MagicShovel; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.enchantment.Enchantments; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.item.enchantment.Enchantments; public class VeinminerEnchantment extends Enchantment { - public VeinminerEnchantment(Rarity rarityIn, EnchantmentType typeIn, EquipmentSlotType[] slots) { + public VeinminerEnchantment(Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot[] slots) { super(rarityIn, typeIn, slots); } @@ -22,18 +22,18 @@ public int getMaxLevel() { } @Override - public boolean isTreasureEnchantment() { + public boolean isTreasureOnly() { return true; } @Override - protected boolean canApplyTogether(Enchantment ench) { - return super.canApplyTogether(ench) && ench != Enchantments.EFFICIENCY && ench != RegistryHandler.MAGIC_FINDER.get(); + protected boolean checkCompatibility(Enchantment ench) { + return super.checkCompatibility(ench) && ench != Enchantments.BLOCK_EFFICIENCY && ench != RegistryHandler.MAGIC_FINDER.get(); } @Override - public boolean canApply(ItemStack stack) { + public boolean canEnchant(ItemStack stack) { Item item = stack.getItem(); - return super.canApply(stack) && (item instanceof MagicShovel || item instanceof MagicPickaxe || item instanceof MagicAxe); + return super.canEnchant(stack) && (item instanceof MagicShovel || item instanceof MagicPickaxe || item instanceof MagicAxe); } } diff --git a/src/main/java/com/pitheguy/magicmod/entities/FluffyMagician.java b/src/main/java/com/pitheguy/magicmod/entities/FluffyMagician.java index a5a4494..f97b519 100644 --- a/src/main/java/com/pitheguy/magicmod/entities/FluffyMagician.java +++ b/src/main/java/com/pitheguy/magicmod/entities/FluffyMagician.java @@ -2,101 +2,105 @@ import com.pitheguy.magicmod.init.ModEntityTypes; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.AgeableEntity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SharedMonsterAttributes; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.ai.goal.SwimGoal; -import net.minecraft.entity.ai.goal.TemptGoal; -import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.AgeableMob; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.goal.FloatGoal; +import net.minecraft.world.entity.ai.goal.TemptGoal; +import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; -public class FluffyMagician extends AnimalEntity { +import javax.annotation.Nullable; + +public class FluffyMagician extends Animal { public boolean hasPowder = true; - public int powderRegrowTime = 0; + public int powderRegrowTime = 2400; - public FluffyMagician(EntityType type, World worldIn) { + public FluffyMagician(EntityType type, Level worldIn) { super(type, worldIn); } @Nullable @Override - public AgeableEntity createChild(AgeableEntity ageable) { - FluffyMagician entity = new FluffyMagician(ModEntityTypes.FLUFFY_MAGICIAN.get(), this.world); - entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.BREEDING, null, null); + public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob ageable) { + FluffyMagician entity = new FluffyMagician(ModEntityTypes.FLUFFY_MAGICIAN.get(), this.level); + entity.finalizeSpawn(world, this.level.getCurrentDifficultyAt(new BlockPos(entity.getPosition(0))), MobSpawnType.BREEDING, null, null); return entity; } @Override protected void registerGoals() { super.registerGoals(); - this.goalSelector.addGoal(0, new SwimGoal(this)); - this.goalSelector.addGoal(1, new TemptGoal(this, 1.2, Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()), false)); - this.goalSelector.addGoal(2, new WaterAvoidingRandomWalkingGoal(this, 1.0)); + this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(1, new TemptGoal(this, 1.2, Ingredient.of(RegistryHandler.MAGIC_GEM.get()), false)); + this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0)); } - @Override - protected void registerAttributes() { - super.registerAttributes(); - this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20); - this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23); + public static AttributeSupplier createAttributes() { + return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20).add(Attributes.MOVEMENT_SPEED, 0.23).build(); } @Override - public boolean processInteract(PlayerEntity player, Hand hand) { - ItemStack itemstack = player.getHeldItem(hand); + public InteractionResult mobInteract(Player player, InteractionHand hand) { + ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == RegistryHandler.MAGIC_SHEARS.get() && this.hasPowder) { - if (!this.world.isRemote) { + if (!this.level.isClientSide) { this.hasPowder = false; this.powderRegrowTime = 2400; - int i = 1 + this.rand.nextInt(1); + int i = 1 + this.getRandom().nextInt(1); for(int j = 0; j < i; ++j) { - ItemEntity itementity = this.entityDropItem(RegistryHandler.MAGIC_POWDER.get(), 1); + ItemEntity itementity = this.spawnAtLocation(RegistryHandler.MAGIC_POWDER.get(), 1); if (itementity != null) { - itementity.setMotion(itementity.getMotion().add((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F, this.rand.nextFloat() * 0.05F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F)); + itementity.setDeltaMovement(itementity.getDeltaMovement().add((this.getRandom().nextFloat() - this.getRandom().nextFloat()) * 0.1F, this.getRandom().nextFloat() * 0.05F, (this.getRandom().nextFloat() - this.getRandom().nextFloat()) * 0.1F)); } } - itemstack.damageItem(1, player, (p_213613_1_) -> p_213613_1_.sendBreakAnimation(hand)); + itemstack.hurtAndBreak(1, player, (p_213613_1_) -> p_213613_1_.broadcastBreakEvent(hand)); } - this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F); + this.playSound(SoundEvents.SHEEP_SHEAR, 1.0F, 1.0F); this.recreate(); - return true; + return InteractionResult.SUCCESS; } - return super.processInteract(player, hand); + return super.mobInteract(player, hand); } + //TODO Test powder regrow @Override - public void writeAdditional(CompoundNBT compound) { - super.writeAdditional(compound); + public CompoundTag saveWithoutId(CompoundTag compound) { + super.saveWithoutId(compound); compound.putBoolean("Powder", hasPowder); compound.putInt("PowderRegrowCooldown", powderRegrowTime); + return compound; } @Override - public void readAdditional(CompoundNBT compound) { - super.readAdditional(compound); + public void load(CompoundTag compound) { + super.load(compound); this.hasPowder = compound.getBoolean("Powder"); - this.powderRegrowTime = compound.getInt("PowderRegrowTime"); + this.powderRegrowTime = compound.getInt("PowderRegrowCooldown"); } public void recreate() { - if (!this.world.isRemote && !hasPowder) { + if (!this.level.isClientSide && !hasPowder) { //LOGGER.info("Converting to Bare Fluffy Magician"); - FluffyMagicianBare newEntity = ModEntityTypes.FLUFFY_MAGICIAN_BARE.get().spawn(this.world, null, null, null, this.getPosition(), SpawnReason.CONVERSION, true, true); - newEntity.copyDataFromOld(this); - this.remove(); + FluffyMagicianBare newEntity = ModEntityTypes.FLUFFY_MAGICIAN_BARE.get().spawn(this.getServer().overworld(), null, null, null, new BlockPos(this.getPosition(0)), MobSpawnType.CONVERSION, true, true); + newEntity.restoreFrom(this); + this.discard(); } } } diff --git a/src/main/java/com/pitheguy/magicmod/entities/FluffyMagicianBare.java b/src/main/java/com/pitheguy/magicmod/entities/FluffyMagicianBare.java index 1814dcf..6447b6a 100644 --- a/src/main/java/com/pitheguy/magicmod/entities/FluffyMagicianBare.java +++ b/src/main/java/com/pitheguy/magicmod/entities/FluffyMagicianBare.java @@ -2,16 +2,17 @@ import com.pitheguy.magicmod.init.ModEntityTypes; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.level.Level; public class FluffyMagicianBare extends FluffyMagician { - public static final int POWDER_REGROW_INTERVAL = 4800; + public static final int POWDER_REGROW_INTERVAL = 2400; - public FluffyMagicianBare(EntityType type, World worldIn) { + public FluffyMagicianBare(EntityType type, Level worldIn) { super(type, worldIn); this.hasPowder = false; this.powderRegrowTime = 2400; @@ -19,21 +20,22 @@ public FluffyMagicianBare(EntityType type, World worldIn @Override public void recreate() { - if (!this.world.isRemote && hasPowder) { + if (!this.level.isClientSide && hasPowder) { //LOGGER.info("Converting to regular Fluffy Magician"); - FluffyMagician newEntity = ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(this.world, null, null, null, this.getPosition(), SpawnReason.CONVERSION, true, true); - newEntity.copyDataFromOld(this); - this.remove(); + FluffyMagician newEntity = ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(this.getServer().overworld(), null, null, null, new BlockPos(this.getPosition(0)), MobSpawnType.CONVERSION, true, true); + newEntity.restoreFrom(this); + this.remove(RemovalReason.DISCARDED); } } @Override - public void livingTick() { - if (powderRegrowTime <= -POWDER_REGROW_INTERVAL && this.world.getBlockState(this.getPosition().down()).getBlock() == RegistryHandler.MAGIC_BLOCK.get()) { + public void tick() { + if (powderRegrowTime <= -POWDER_REGROW_INTERVAL && this.level.getBlockState(new BlockPos(this.getPosition(0)).below()).getBlock() == RegistryHandler.MAGIC_BLOCK.get()) { this.hasPowder = true; + this.powderRegrowTime = 2400; this.recreate(); } powderRegrowTime = Math.max(-POWDER_REGROW_INTERVAL, powderRegrowTime - 1); - super.livingTick(); + super.tick(); } } diff --git a/src/main/java/com/pitheguy/magicmod/entities/MagicFriend.java b/src/main/java/com/pitheguy/magicmod/entities/MagicFriend.java index 49e4efd..6f31031 100644 --- a/src/main/java/com/pitheguy/magicmod/entities/MagicFriend.java +++ b/src/main/java/com/pitheguy/magicmod/entities/MagicFriend.java @@ -2,51 +2,53 @@ import com.pitheguy.magicmod.init.ModEntityTypes; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.goal.SwimGoal; -import net.minecraft.entity.ai.goal.TemptGoal; -import net.minecraft.entity.ai.goal.WaterAvoidingRandomWalkingGoal; -import net.minecraft.entity.passive.AnimalEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.item.crafting.Ingredient; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; -import org.jetbrains.annotations.Nullable; - -public class MagicFriend extends AnimalEntity { - - public MagicFriend(EntityType type, World worldIn) { +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.Mth; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.*; +import net.minecraft.world.entity.ai.attributes.AttributeSupplier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.goal.FloatGoal; +import net.minecraft.world.entity.ai.goal.TemptGoal; +import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; + +import javax.annotation.Nullable; + +public class MagicFriend extends Animal { + + public MagicFriend(EntityType type, Level worldIn) { super(type, worldIn); } @Nullable @Override - public AgeableEntity createChild(AgeableEntity ageable) { - MagicFriend entity = new MagicFriend(ModEntityTypes.MAGIC_FRIEND.get(), this.world); - entity.onInitialSpawn(this.world, this.world.getDifficultyForLocation(new BlockPos(entity)), SpawnReason.BREEDING, null, null); + public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob ageable) { + MagicFriend entity = new MagicFriend(ModEntityTypes.MAGIC_FRIEND.get(), this.level); + entity.finalizeSpawn(world, this.level.getCurrentDifficultyAt(new BlockPos(entity.getPosition(0))), MobSpawnType.BREEDING, null, null); return entity; } @Override protected void registerGoals() { super.registerGoals(); - this.goalSelector.addGoal(0, new SwimGoal(this)); - this.goalSelector.addGoal(1, new TemptGoal(this, 1.2, Ingredient.fromItems(RegistryHandler.MAGIC_CARROT.get()), false)); - this.goalSelector.addGoal(2, new WaterAvoidingRandomWalkingGoal(this, 1.0)); + this.goalSelector.addGoal(0, new FloatGoal(this)); + this.goalSelector.addGoal(1, new TemptGoal(this, 1.2, Ingredient.of(RegistryHandler.MAGIC_CARROT.get()), false)); + this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0)); } - @Override - protected void registerAttributes() { - super.registerAttributes(); - this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20); - this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23); + public static AttributeSupplier createAttributes() { + return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 20).add(Attributes.MOVEMENT_SPEED, 0.23).build(); } @Nullable @@ -54,96 +56,89 @@ public Entity getControllingPassenger() { return this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); } - public void travel(Vec3d vector) { + public void travel(Vec3 vector) { if (this.isAlive()) { Entity entity = this.getPassengers().isEmpty() ? null : this.getPassengers().get(0); - if (this.isBeingRidden() && this.canBeSteered()) { - this.rotationYaw = entity.rotationYaw; - this.prevRotationYaw = this.rotationYaw; - this.rotationPitch = entity.rotationPitch * 0.5F; - this.setRotation(this.rotationYaw, this.rotationPitch); - this.renderYawOffset = this.rotationYaw; - this.rotationYawHead = this.rotationYaw; - this.stepHeight = 1.0F; - this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F; - - if (this.canPassengerSteer()) { - this.setAIMoveSpeed((float) this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getValue() * 1.5f); - super.travel(new Vec3d(0.0D, 0.0D, 1.0D)); - this.newPosRotationIncrements = 0; + if (this.isVehicle() && this.canBeControlledByRider()) { + this.setYRot(entity.getYRot()); + this.yRotO = this.getYRot(); + this.setXRot(entity.getXRot() * 0.5F); + this.setRot(this.getYRot(), this.getXRot()); + this.yBodyRot = this.getYRot(); + this.yHeadRot = this.getYRot(); + this.maxUpStep = 1.0F; + this.flyingSpeed = this.getSpeed() * 0.1F; + + if (this.isControlledByLocalInstance()) { + this.setSpeed((float) this.getAttribute(Attributes.MOVEMENT_SPEED).getValue() * 1.5f); + super.travel(new Vec3(0.0D, 0.0D, 1.0D)); + this.lerpSteps = 0; } else { - this.setMotion(Vec3d.ZERO); + this.setDeltaMovement(Vec3.ZERO); } - this.prevLimbSwingAmount = this.limbSwingAmount; - double d1 = this.getPosX() - this.prevPosX; - double d0 = this.getPosZ() - this.prevPosZ; - float f1 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F; - if (f1 > 1.0F) { - f1 = 1.0F; - } + this.animationSpeedOld = this.animationSpeed; + double d1 = this.getX() - this.xo; + double d0 = this.getZ() - this.zo; + float f1 = Mth.sqrt((float) (d1 * d1 + d0 * d0)) * 4.0F; + f1 = Math.min(f1, 1.0F); - this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F; - this.limbSwing += this.limbSwingAmount; + this.animationSpeed += (f1 - this.animationSpeed) * 0.4F; + this.animationPosition += this.animationSpeed; } else { - this.stepHeight = 0.5F; - this.jumpMovementFactor = 0.02F; + this.maxUpStep = 0.5F; + this.flyingSpeed = 0.02F; super.travel(vector); } } } - public boolean processInteract(PlayerEntity player, Hand hand) { - if (super.processInteract(player, hand)) { - return true; + public InteractionResult mobInteract(Player player, InteractionHand hand) { + if (super.mobInteract(player, hand) == InteractionResult.SUCCESS) { + return InteractionResult.SUCCESS; } else { - ItemStack itemstack = player.getHeldItem(hand); + ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.NAME_TAG) { - itemstack.interactWithEntity(player, this, hand); - return true; - } else if (!this.isBeingRidden()) { - if (!this.world.isRemote) { + itemstack.interactLivingEntity(player, this, hand); + return InteractionResult.SUCCESS; + } else if (!this.isVehicle()) { + if (!this.level.isClientSide) { player.startRiding(this); } - - return true; + return InteractionResult.SUCCESS; } else { - return false; + return InteractionResult.PASS; } } } - @Override - public boolean canBeSteered() { + public boolean canBeControlledByRider() { Entity entity = this.getControllingPassenger(); - if (entity instanceof PlayerEntity) { - PlayerEntity playerentity = (PlayerEntity)entity; - return playerentity.getHeldItemMainhand().getItem() == RegistryHandler.MAGIC_CARROT.get() || playerentity.getHeldItemOffhand().getItem() == RegistryHandler.MAGIC_CARROT.get(); - } else return false; + return entity instanceof Player player && (player.getMainHandItem().getItem() == RegistryHandler.MAGIC_CARROT.get() || player.getOffhandItem().getItem() == RegistryHandler.MAGIC_CARROT.get()); } - public boolean onLivingFall(float distance, float damageMultiplier) { + public boolean causeFallDamage(float distance, float damageMultiplier) { if (distance > 1.0F) { - this.playSound(SoundEvents.ENTITY_HORSE_LAND, 0.4F, 1.0F); + this.playSound(SoundEvents.HORSE_LAND, 0.4F, 1.0F); } int i = this.calculateFallDamage(distance, damageMultiplier); if (i <= 0) { return false; } else { - this.attackEntityFrom(DamageSource.FALL, i); - if (this.isBeingRidden()) { - for(Entity entity : this.getRecursivePassengers()) { - entity.attackEntityFrom(DamageSource.FALL, i); + this.hurt(DamageSource.FALL, i); + if (this.isVehicle()) { + for(Entity entity : this.getIndirectPassengers()) { + entity.hurt(DamageSource.FALL, i); } } - this.playFallSound(); + this.playBlockFallSound(); return true; } } protected int calculateFallDamage(float distance, float damageMultiplier) { - return MathHelper.ceil((distance * 0.15F - 7.0F) * damageMultiplier); + return Mth.ceil((distance * 0.15F - 7.0F) * damageMultiplier); } } diff --git a/src/main/java/com/pitheguy/magicmod/entities/MagicPearlEntity.java b/src/main/java/com/pitheguy/magicmod/entities/MagicPearlEntity.java index 0c5b35a..b282593 100644 --- a/src/main/java/com/pitheguy/magicmod/entities/MagicPearlEntity.java +++ b/src/main/java/com/pitheguy/magicmod/entities/MagicPearlEntity.java @@ -1,94 +1,55 @@ package com.pitheguy.magicmod.entities; -import net.minecraft.advancements.CriteriaTriggers; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.EnderPearlEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.particles.ParticleTypes; -import net.minecraft.tileentity.EndGatewayTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.DamageSource; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; - -public class MagicPearlEntity extends EnderPearlEntity { - private LivingEntity pearlThrower; - - public MagicPearlEntity(EntityType p_i50153_1_, World p_i50153_2_) { +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.HitResult; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.entity.EntityTeleportEvent; + +public class MagicPearlEntity extends ThrownEnderpearl { + + public MagicPearlEntity(EntityType p_i50153_1_, Level p_i50153_2_) { super(p_i50153_1_, p_i50153_2_); } - public MagicPearlEntity(World worldIn, LivingEntity throwerIn) { + public MagicPearlEntity(Level worldIn, LivingEntity throwerIn) { super(worldIn, throwerIn); - pearlThrower = throwerIn; } - public MagicPearlEntity(World worldIn, double x, double y, double z) { - super(worldIn, x, y, z); - } - - protected void onImpact(RayTraceResult result) { - LivingEntity livingentity = this.getThrower(); - if (result.getType() == RayTraceResult.Type.ENTITY) { - Entity entity = ((EntityRayTraceResult)result).getEntity(); - if (entity == this.pearlThrower) { - return; - } - - entity.attackEntityFrom(DamageSource.causeThrownDamage(this, livingentity), 0.0F); - } - - if (result.getType() == RayTraceResult.Type.BLOCK) { - BlockPos blockpos = ((BlockRayTraceResult)result).getPos(); - TileEntity tileentity = this.world.getTileEntity(blockpos); - if (tileentity instanceof EndGatewayTileEntity) { - EndGatewayTileEntity endgatewaytileentity = (EndGatewayTileEntity)tileentity; - if (livingentity != null) { - if (livingentity instanceof ServerPlayerEntity) { - CriteriaTriggers.ENTER_BLOCK.trigger((ServerPlayerEntity)livingentity, this.world.getBlockState(blockpos)); - } - - endgatewaytileentity.teleportEntity(livingentity); - this.remove(); - return; - } - - endgatewaytileentity.teleportEntity(this); - return; - } - } + @Override + protected void onHit(HitResult result) { + super.onHit(result); + Entity entity = this.getOwner(); for(int i = 0; i < 32; ++i) { - this.world.addParticle(ParticleTypes.PORTAL, this.getPosX(), this.getPosY() + this.rand.nextDouble() * 2.0D, this.getPosZ(), this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian()); + this.level.addParticle(ParticleTypes.PORTAL, this.getX(), this.getY() + this.random.nextDouble() * 2.0D, this.getZ(), this.random.nextGaussian(), 0.0D, this.random.nextGaussian()); } - if (!this.world.isRemote) { - if (livingentity instanceof ServerPlayerEntity) { - ServerPlayerEntity serverplayerentity = (ServerPlayerEntity)livingentity; - if (serverplayerentity.connection.getNetworkManager().isChannelOpen() && serverplayerentity.world == this.world && !serverplayerentity.isSleeping()) { - net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(serverplayerentity, this.getPosX(), this.getPosY(), this.getPosZ(), 1.0F); - if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) { // Don't indent to lower patch size - - if (livingentity.isPassenger()) { - livingentity.stopRiding(); + if (!this.level.isClientSide && !this.isRemoved()) { + if (entity instanceof ServerPlayer serverPlayer) { + if (serverPlayer.connection.getConnection().isConnected() && serverPlayer.level == this.level && !serverPlayer.isSleeping()) { + EntityTeleportEvent.EnderPearl event = ForgeEventFactory.onEnderPearlLand(serverPlayer, this.getX(), this.getY(), this.getZ(), this, 1.0F); + if (!event.isCanceled()) { + if (entity.isPassenger()) { + entity.stopRiding(); } - - livingentity.setPositionAndUpdate(event.getTargetX(), event.getTargetY(), event.getTargetZ()); - livingentity.fallDistance = 0.0F; - livingentity.attackEntityFrom(DamageSource.FALL, event.getAttackDamage()); - } //Forge: End + entity.teleportTo(event.getTargetX(), event.getTargetY(), event.getTargetZ()); + entity.fallDistance = 0.0F; + entity.hurt(DamageSource.FALL, event.getAttackDamage()); + } } - } else if (livingentity != null) { - livingentity.setPositionAndUpdate(this.getPosX(), this.getPosY(), this.getPosZ()); - livingentity.fallDistance = 0.0F; + } else if (entity != null) { + entity.teleportTo(this.getX(), this.getY(), this.getZ()); + entity.fallDistance = 0.0F; } - this.remove(); + this.discard(); } } diff --git a/src/main/java/com/pitheguy/magicmod/events/ModClientEvents.java b/src/main/java/com/pitheguy/magicmod/events/ModClientEvents.java index a1d7242..733e96f 100644 --- a/src/main/java/com/pitheguy/magicmod/events/ModClientEvents.java +++ b/src/main/java/com/pitheguy/magicmod/events/ModClientEvents.java @@ -1,9 +1,12 @@ package com.pitheguy.magicmod.events; import com.pitheguy.magicmod.util.ArmorHandler; -import net.minecraft.entity.player.PlayerEntity; +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.PickaxeItem; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.entity.living.LivingDamageEvent; +import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @@ -11,8 +14,7 @@ public class ModClientEvents { @SubscribeEvent public static void onDamageWithMagicArmor(LivingDamageEvent event) { - if (event.getEntityLiving() instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) event.getEntityLiving(); + if (event.getEntityLiving() instanceof Player player) { if (ArmorHandler.isWearingMagicArmor(player)) { event.setAmount(event.getAmount() * 0.6f); } else if (ArmorHandler.isWearingReinforcedMagicArmor(player)) { @@ -22,4 +24,11 @@ public static void onDamageWithMagicArmor(LivingDamageEvent event) { } } } + + @SubscribeEvent + public static void harvestCheck(PlayerEvent.HarvestCheck event) { + if (event.getTargetBlock().getBlock() == RegistryHandler.MAGIC_OBSIDIAN.get() && event.getPlayer().getMainHandItem().getItem() instanceof PickaxeItem pickaxe && pickaxe.getTier().getLevel() < 5) { + event.setCanHarvest(false); + } + } } diff --git a/src/main/java/com/pitheguy/magicmod/init/ModContainerTypes.java b/src/main/java/com/pitheguy/magicmod/init/ModContainerTypes.java index 82b25f4..9a6c1eb 100644 --- a/src/main/java/com/pitheguy/magicmod/init/ModContainerTypes.java +++ b/src/main/java/com/pitheguy/magicmod/init/ModContainerTypes.java @@ -1,21 +1,23 @@ package com.pitheguy.magicmod.init; -import com.pitheguy.magicmod.container.MagicCrateContainer; -import com.pitheguy.magicmod.container.MagicInfuserContainer; -import com.pitheguy.magicmod.container.MagicPressContainer; -import net.minecraft.inventory.container.ContainerType; -import net.minecraftforge.common.extensions.IForgeContainerType; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; +import com.pitheguy.magicmod.container.*; +import net.minecraft.world.inventory.MenuType; +import net.minecraftforge.common.extensions.IForgeMenuType; +import net.minecraftforge.registries.*; public class ModContainerTypes { - public static final DeferredRegister> CONTAINER_TYPES = new DeferredRegister<>( + public static final DeferredRegister> CONTAINER_TYPES = DeferredRegister.create( ForgeRegistries.CONTAINERS, "magicmod"); - public static final RegistryObject> MAGIC_INFUSER = CONTAINER_TYPES - .register("magic_infuser", () -> IForgeContainerType.create(MagicInfuserContainer::new)); - public static final RegistryObject> MAGIC_CRATE = CONTAINER_TYPES - .register("magic_crate", () -> IForgeContainerType.create(MagicCrateContainer::new)); - public static final RegistryObject> MAGIC_PRESS = CONTAINER_TYPES - .register("magic_press", () -> IForgeContainerType.create(MagicPressContainer::new)); + public static final RegistryObject> MAGIC_INFUSER = CONTAINER_TYPES + .register("magic_infuser", () -> IForgeMenuType.create(MagicInfuserContainer::new)); + public static final RegistryObject> MAGIC_CRATE = CONTAINER_TYPES + .register("magic_crate", () -> IForgeMenuType.create(MagicCrateContainer::new)); + public static final RegistryObject> MAGIC_PRESS = CONTAINER_TYPES + .register("magic_press", () -> IForgeMenuType.create(MagicPressContainer::new)); + public static final RegistryObject> MAGIC_ENERGIZER = CONTAINER_TYPES + .register("magic_energizer", () -> IForgeMenuType.create(MagicEnergizerContainer::new)); + public static final RegistryObject> MAGIC_MINER = CONTAINER_TYPES + .register("magic_miner", () -> IForgeMenuType.create(MagicMinerContainer::new)); + public static final RegistryObject> MAGIC_LOGGER = CONTAINER_TYPES + .register("magic_logger", () -> IForgeMenuType.create(MagicLoggerContainer::new)); } diff --git a/src/main/java/com/pitheguy/magicmod/init/ModEntityTypes.java b/src/main/java/com/pitheguy/magicmod/init/ModEntityTypes.java index e65e07f..d4d6aa5 100644 --- a/src/main/java/com/pitheguy/magicmod/init/ModEntityTypes.java +++ b/src/main/java/com/pitheguy/magicmod/init/ModEntityTypes.java @@ -1,30 +1,25 @@ package com.pitheguy.magicmod.init; -import com.pitheguy.magicmod.entities.FluffyMagician; -import com.pitheguy.magicmod.entities.FluffyMagicianBare; -import com.pitheguy.magicmod.entities.MagicFriend; -import com.pitheguy.magicmod.entities.MagicPearlEntity; -import net.minecraft.entity.EntityClassification; -import net.minecraft.entity.EntityType; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; +import com.pitheguy.magicmod.entities.*; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; +import net.minecraftforge.registries.*; public class ModEntityTypes { - public static final DeferredRegister> ENTITY_TYPES = new DeferredRegister<>(ForgeRegistries.ENTITIES, + public static final DeferredRegister> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, "magicmod"); public static final RegistryObject> MAGIC_FRIEND = ENTITY_TYPES - .register("magic_friend", () -> EntityType.Builder.create(MagicFriend::new, EntityClassification.CREATURE) - .size(1.6f, 1.4f).build(new ResourceLocation("magicmod", "magic_friend").toString())); + .register("magic_friend", () -> EntityType.Builder.of(MagicFriend::new, MobCategory.CREATURE) + .sized(1.6f, 1.4f).build(new ResourceLocation("magicmod", "magic_friend").toString())); public static final RegistryObject> FLUFFY_MAGICIAN = ENTITY_TYPES - .register("fluffy_magician", () -> EntityType.Builder.create(FluffyMagician::new, EntityClassification.CREATURE) - .size(1f, 0.8f).build(new ResourceLocation("magicmod", "fluffy_magician").toString())); + .register("fluffy_magician", () -> EntityType.Builder.of(FluffyMagician::new, MobCategory.CREATURE) + .sized(1f, 0.8f).build(new ResourceLocation("magicmod", "fluffy_magician").toString())); public static final RegistryObject> FLUFFY_MAGICIAN_BARE = ENTITY_TYPES - .register("fluffy_magician_bare", () -> EntityType.Builder.create(FluffyMagicianBare::new, EntityClassification.CREATURE) - .size(0.8f, 0.8f).build(new ResourceLocation("magicmod", "fluffy_magician_bare").toString())); + .register("fluffy_magician_bare", () -> EntityType.Builder.of(FluffyMagicianBare::new, MobCategory.CREATURE) + .sized(0.8f, 0.8f).build(new ResourceLocation("magicmod", "fluffy_magician_bare").toString())); public static final RegistryObject> MAGIC_PEARL = ENTITY_TYPES - .register("magic_pearl", () -> EntityType.Builder.create(MagicPearlEntity::new, EntityClassification.MISC) - .size(0.25f, 0.25f).build(new ResourceLocation("magicmod", "magic_pearl").toString())); + .register("magic_pearl", () -> EntityType.Builder.of(MagicPearlEntity::new, MobCategory.MISC) + .sized(0.25f, 0.25f).build(new ResourceLocation("magicmod", "magic_pearl").toString())); } diff --git a/src/main/java/com/pitheguy/magicmod/init/ModTileEntityTypes.java b/src/main/java/com/pitheguy/magicmod/init/ModTileEntityTypes.java index a9d70f4..53432ec 100644 --- a/src/main/java/com/pitheguy/magicmod/init/ModTileEntityTypes.java +++ b/src/main/java/com/pitheguy/magicmod/init/ModTileEntityTypes.java @@ -1,18 +1,16 @@ package com.pitheguy.magicmod.init; -import com.pitheguy.magicmod.tileentity.MagicCrateTileEntity; -import com.pitheguy.magicmod.tileentity.MagicInfuserTileEntity; -import com.pitheguy.magicmod.tileentity.MagicPressTileEntity; +import com.pitheguy.magicmod.blockentity.*; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.tileentity.TileEntityType; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraftforge.registries.*; public class ModTileEntityTypes { - public static final DeferredRegister> TILE_ENTITY_TYPES = new DeferredRegister<>( - ForgeRegistries.TILE_ENTITIES, "magicmod"); - public static final RegistryObject> MAGIC_INFUSER = TILE_ENTITY_TYPES.register("magic_infuser",() -> TileEntityType.Builder.create(MagicInfuserTileEntity::new, RegistryHandler.MAGIC_INFUSER.get()).build(null)); - public static final RegistryObject> MAGIC_CRATE = TILE_ENTITY_TYPES.register("magic_crate",() -> TileEntityType.Builder.create(MagicCrateTileEntity::new, RegistryHandler.MAGIC_CRATE.get()).build(null)); - public static final RegistryObject> MAGIC_PRESS = TILE_ENTITY_TYPES.register("magic_press",() -> TileEntityType.Builder.create(MagicPressTileEntity::new, RegistryHandler.MAGIC_PRESS.get()).build(null)); + public static final DeferredRegister> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, "magicmod"); + public static final RegistryObject> MAGIC_INFUSER = BLOCK_ENTITY_TYPES.register("magic_infuser",() -> BlockEntityType.Builder.of(MagicInfuserBlockEntity::new, RegistryHandler.MAGIC_INFUSER.get()).build(null)); + public static final RegistryObject> MAGIC_CRATE = BLOCK_ENTITY_TYPES.register("magic_crate",() -> BlockEntityType.Builder.of(MagicCrateBlockEntity::new, RegistryHandler.MAGIC_CRATE.get()).build(null)); + public static final RegistryObject> MAGIC_PRESS = BLOCK_ENTITY_TYPES.register("magic_press",() -> BlockEntityType.Builder.of(MagicPressBlockEntity::new, RegistryHandler.MAGIC_PRESS.get()).build(null)); + public static final RegistryObject> MAGIC_ENERGIZER = BLOCK_ENTITY_TYPES.register("magic_energizer",() -> BlockEntityType.Builder.of(MagicEnergizerBlockEntity::new, RegistryHandler.MAGIC_ENERGIZER.get()).build(null)); + public static final RegistryObject> MAGIC_MINER = BLOCK_ENTITY_TYPES.register("magic_miner",() -> BlockEntityType.Builder.of(MagicMinerBlockEntity::new, RegistryHandler.MAGIC_MINER.get()).build(null)); + public static final RegistryObject> MAGIC_LOGGER = BLOCK_ENTITY_TYPES.register("magic_logger",() -> BlockEntityType.Builder.of(MagicLoggerBlockEntity::new, RegistryHandler.MAGIC_LOGGER.get()).build(null)); } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/items/FilterUpgradeItem.java b/src/main/java/com/pitheguy/magicmod/items/FilterUpgradeItem.java new file mode 100644 index 0000000..b2c6dda --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/items/FilterUpgradeItem.java @@ -0,0 +1,52 @@ +package com.pitheguy.magicmod.items; + +import com.pitheguy.magicmod.MagicMod; +import net.minecraft.ChatFormatting; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Pose; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; + +import javax.annotation.Nullable; +import java.util.List; + +public class FilterUpgradeItem extends UpgradeItem { + public FilterUpgradeItem() { + super(new Item.Properties().tab(MagicMod.TAB).stacksTo(1)); + } + + @Override + public InteractionResult useOn(UseOnContext context) { + if (context.getPlayer().getPose() == Pose.CROUCHING) { + ItemStack itemStack = context.getItemInHand(); + CompoundTag currentData = itemStack.hasTag() ? itemStack.getTag() : new CompoundTag(); + BlockState targetBlock = context.getLevel().getBlockState(context.getClickedPos()); + if (!currentData.contains("Filter") || NbtUtils.readBlockState(currentData.getCompound("Filter")) != targetBlock) { + currentData.put("Filter", NbtUtils.writeBlockState(targetBlock)); + itemStack.setTag(currentData); + context.getPlayer().displayClientMessage(new TextComponent("Filter block set!").withStyle(ChatFormatting.GREEN), true); + return InteractionResult.SUCCESS; + } else if (NbtUtils.readBlockState(currentData.getCompound("Filter")) != targetBlock) { + context.getPlayer().displayClientMessage(new TextComponent("Filter block already set to this!").withStyle(ChatFormatting.RED), true); + } + return InteractionResult.PASS; + } else return super.useOn(context); + } + + @Override + public void appendHoverText(ItemStack stack, @Nullable Level worldIn, List tooltip, TooltipFlag flagIn) { + super.appendHoverText(stack, worldIn, tooltip, flagIn); + String filterBlock = stack.hasTag() && stack.getTag().contains("Filter") ? new TranslatableComponent(NbtUtils.readBlockState(stack.getTag().getCompound("Filter")).getBlock().getDescriptionId()).getString() : "None"; + tooltip.add(new TextComponent("Current Filter: " + filterBlock).withStyle(ChatFormatting.GRAY)); + tooltip.add(new TextComponent("Shift-click a block to change").withStyle(ChatFormatting.GRAY)); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/items/FluffBall.java b/src/main/java/com/pitheguy/magicmod/items/FluffBall.java index b710b10..d448ad3 100644 --- a/src/main/java/com/pitheguy/magicmod/items/FluffBall.java +++ b/src/main/java/com/pitheguy/magicmod/items/FluffBall.java @@ -2,78 +2,70 @@ import com.pitheguy.magicmod.MagicMod; import com.pitheguy.magicmod.init.ModEntityTypes; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.stats.Stats; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; import java.util.Objects; public class FluffBall extends Item { public FluffBall() { - super(new Properties().group(MagicMod.TAB)); + super(new Properties().tab(MagicMod.TAB)); } - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - if (!world.isRemote) { - ItemStack itemstack = context.getItem(); - BlockPos blockpos = context.getPos(); - Direction direction = context.getFace(); - BlockState blockstate = world.getBlockState(blockpos); - - BlockPos blockpos1; - if (blockstate.getCollisionShape(world, blockpos).isEmpty()) { - blockpos1 = blockpos; - } else { - blockpos1 = blockpos.offset(direction); - } - - if (ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(world, itemstack, context.getPlayer(), blockpos1, SpawnReason.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) { + public InteractionResult useOn(UseOnContext context) { + Level level = context.getLevel(); + if (!level.isClientSide) { + ItemStack itemstack = context.getItemInHand(); + BlockPos blockpos = context.getClickedPos(); + Direction direction = context.getClickedFace(); + BlockState blockstate = level.getBlockState(blockpos); + BlockPos blockpos1 = blockstate.getCollisionShape(level, blockpos).isEmpty() ? blockpos : blockpos.relative(direction); + if (ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(level.getServer().overworld(), itemstack, context.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) { itemstack.shrink(1); } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); - RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.SOURCE_ONLY); - if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) { - return ActionResult.resultPass(itemstack); - } else if (worldIn.isRemote) { - return ActionResult.resultSuccess(itemstack); + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + ItemStack itemstack = playerIn.getItemInHand(handIn); + BlockHitResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, ClipContext.Fluid.SOURCE_ONLY); + if (raytraceresult.getType() != HitResult.Type.BLOCK) { + return InteractionResultHolder.pass(itemstack); + } else if (worldIn.isClientSide) { + return InteractionResultHolder.success(itemstack); } else { - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)raytraceresult; - BlockPos blockpos = blockraytraceresult.getPos(); - if (!(worldIn.getBlockState(blockpos).getBlock() instanceof FlowingFluidBlock)) { - return ActionResult.resultPass(itemstack); - } else if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) { - if (ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(worldIn, itemstack, playerIn, blockpos, SpawnReason.SPAWN_EGG, false, false) == null) { - return ActionResult.resultPass(itemstack); + BlockPos blockpos = raytraceresult.getBlockPos(); + if (!(worldIn.getBlockState(blockpos).getBlock() instanceof LiquidBlock)) { + return InteractionResultHolder.pass(itemstack); + } else if (worldIn.mayInteract(playerIn, blockpos) && playerIn.mayUseItemAt(blockpos, raytraceresult.getDirection(), itemstack)) { + if (ModEntityTypes.FLUFFY_MAGICIAN.get().spawn(worldIn.getServer().overworld(), itemstack, playerIn, blockpos, MobSpawnType.SPAWN_EGG, false, false) == null) { + return InteractionResultHolder.pass(itemstack); } else { - if (!playerIn.abilities.isCreativeMode) { + if (!playerIn.getAbilities().instabuild) { itemstack.shrink(1); } - playerIn.addStat(Stats.ITEM_USED.get(this)); - return ActionResult.resultSuccess(itemstack); + playerIn.awardStat(Stats.ITEM_USED.get(this)); + return InteractionResultHolder.success(itemstack); } } else { - return ActionResult.resultFail(itemstack); + return InteractionResultHolder.fail(itemstack); } } } diff --git a/src/main/java/com/pitheguy/magicmod/items/ItemBase.java b/src/main/java/com/pitheguy/magicmod/items/ItemBase.java index 12e5f28..2574e6a 100644 --- a/src/main/java/com/pitheguy/magicmod/items/ItemBase.java +++ b/src/main/java/com/pitheguy/magicmod/items/ItemBase.java @@ -1,10 +1,10 @@ package com.pitheguy.magicmod.items; import com.pitheguy.magicmod.MagicMod; -import net.minecraft.item.Item; +import net.minecraft.world.item.Item; public class ItemBase extends Item { public ItemBase() { - super(new Item.Properties().group(MagicMod.TAB)); + super(new Item.Properties().tab(MagicMod.TAB)); } } diff --git a/src/main/java/com/pitheguy/magicmod/items/MagicPearl.java b/src/main/java/com/pitheguy/magicmod/items/MagicPearl.java index 9658c7a..4ff2a29 100644 --- a/src/main/java/com/pitheguy/magicmod/items/MagicPearl.java +++ b/src/main/java/com/pitheguy/magicmod/items/MagicPearl.java @@ -2,34 +2,34 @@ import com.pitheguy.magicmod.MagicMod; import com.pitheguy.magicmod.entities.MagicPearlEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; import net.minecraft.stats.Stats; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.world.World; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; public class MagicPearl extends Item { public MagicPearl() { - super(new Properties().group(MagicMod.TAB)); + super(new Properties().tab(MagicMod.TAB)); } - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); - worldIn.playSound(null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_ENDER_PEARL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F)); - playerIn.getCooldownTracker().setCooldown(this, 45); - if (!worldIn.isRemote) { + + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + ItemStack itemstack = playerIn.getItemInHand(handIn); + worldIn.playSound(null, playerIn.getX(), playerIn.getY(), playerIn.getZ(), SoundEvents.ENDER_PEARL_THROW, SoundSource.NEUTRAL, 0.5F, 0.4F / (worldIn.getRandom().nextFloat() * 0.4F + 0.8F)); + playerIn.getCooldowns().addCooldown(this, 45); + if (!worldIn.isClientSide) { MagicPearlEntity magicPearlEntity = new MagicPearlEntity(worldIn, playerIn); magicPearlEntity.setItem(itemstack); - magicPearlEntity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 2.0F, 0.5F); - worldIn.addEntity(magicPearlEntity); + magicPearlEntity.shootFromRotation(playerIn, playerIn.getXRot(), playerIn.getYRot(), 0.0F, 2.0F, 0.5F); + worldIn.addFreshEntity(magicPearlEntity); } - playerIn.addStat(Stats.ITEM_USED.get(this)); + playerIn.awardStat(Stats.ITEM_USED.get(this)); - return ActionResult.resultSuccess(itemstack); + return InteractionResultHolder.success(itemstack); } - } diff --git a/src/main/java/com/pitheguy/magicmod/items/MagicShears.java b/src/main/java/com/pitheguy/magicmod/items/MagicShears.java index 4c00869..e465c09 100644 --- a/src/main/java/com/pitheguy/magicmod/items/MagicShears.java +++ b/src/main/java/com/pitheguy/magicmod/items/MagicShears.java @@ -1,11 +1,11 @@ package com.pitheguy.magicmod.items; import com.pitheguy.magicmod.MagicMod; -import net.minecraft.item.Item; -import net.minecraft.item.ShearsItem; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ShearsItem; public class MagicShears extends ShearsItem { public MagicShears() { - super(new Item.Properties().maxDamage(2000).group(MagicMod.TAB)); + super(new Item.Properties().durability(2000).tab(MagicMod.TAB)); } } diff --git a/src/main/java/com/pitheguy/magicmod/items/MagicShelter.java b/src/main/java/com/pitheguy/magicmod/items/MagicShelter.java index 9450b53..619e848 100644 --- a/src/main/java/com/pitheguy/magicmod/items/MagicShelter.java +++ b/src/main/java/com/pitheguy/magicmod/items/MagicShelter.java @@ -2,25 +2,27 @@ import com.google.common.collect.ImmutableMap; import com.pitheguy.magicmod.MagicMod; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.tileentity.LockableLootTileEntity; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; +import net.minecraft.ChatFormatting; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.chunk.LevelChunk; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; +import java.util.*; import java.util.stream.IntStream; import static com.pitheguy.magicmod.util.RegistryHandler.*; @@ -30,14 +32,14 @@ public class MagicShelter extends Item { public static final Block[] MAGIC_LAMPS = {MAGIC_LAMP_RED.get(), MAGIC_LAMP_ORANGE.get(), MAGIC_LAMP_YELLOW.get(), MAGIC_LAMP_GREEN.get(), MAGIC_LAMP_BLUE.get(), MAGIC_LAMP_PURPLE.get(), MAGIC_LAMP_MAGENTA.get(), MAGIC_LAMP_BLACK.get(), MAGIC_LAMP_WHITE.get()}; private static final Random RANDOM = new Random(); public static final Map BLOCK_KEY = new HashMap<>(new ImmutableMap.Builder() - .put("O", Blocks.OBSIDIAN.getDefaultState()) - .put("R", MAGIC_OBSIDIAN.get().getDefaultState()) - .put("B", Blocks.STONE_BUTTON.getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH)) - .put("u", Blocks.IRON_DOOR.getDefaultState().with(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)) - .put("l", Blocks.IRON_DOOR.getDefaultState().with(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.UPPER)) - .put("C", Blocks.CHEST.getDefaultState().with(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH)) - .put("L", Blocks.LADDER.getDefaultState()) - .put("M", MAGIC_LAMPS[RANDOM.nextInt(MAGIC_LAMPS.length)].getDefaultState()) + .put("O", Blocks.OBSIDIAN.defaultBlockState()) + .put("R", MAGIC_OBSIDIAN.get().defaultBlockState()) + .put("B", Blocks.STONE_BUTTON.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH)) + .put("u", Blocks.IRON_DOOR.defaultBlockState().setValue(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.LOWER)) + .put("l", Blocks.IRON_DOOR.defaultBlockState().setValue(BlockStateProperties.DOUBLE_BLOCK_HALF, DoubleBlockHalf.UPPER)) + .put("C", Blocks.CHEST.defaultBlockState().setValue(BlockStateProperties.HORIZONTAL_FACING, Direction.SOUTH)) + .put("L", Blocks.LADDER.defaultBlockState()) + .put("M", MAGIC_LAMPS[RANDOM.nextInt(MAGIC_LAMPS.length)].defaultBlockState()) .build()); public static String[][] STRUCTURE_1 = { @@ -51,20 +53,20 @@ public class MagicShelter extends Item { {"OOOOO", "OOOOO", "OOMOO", "OOOOO", "OOOOO"}}; //Layer 8 public MagicShelter() { - super(new Item.Properties().group(MagicMod.TAB)); + super(new Properties().tab(MagicMod.TAB)); } @Override - public ActionResultType onItemUse(ItemUseContext context) { + public InteractionResult useOn(UseOnContext context) { boolean placedBlock = false; - BlockPos pos = context.getPlayer().getPosition().add(0,-1,0); - if (!hasEnoughSpace(context.getPlayer(), context.getWorld())) { - context.getPlayer().sendStatusMessage(new StringTextComponent("Not enough space!").applyTextStyle(TextFormatting.RED), true); - return ActionResultType.FAIL; + BlockPos pos = new BlockPos(context.getPlayer().getPosition(0).add(0,-1,0)); + if (!hasEnoughSpace(context.getPlayer(), context.getLevel())) { + context.getPlayer().displayClientMessage(new TextComponent("Not enough space!").withStyle(ChatFormatting.RED), true); + return InteractionResult.FAIL; } - if (!hasGroundUnderneath(context.getPlayer(), context.getWorld())) { - context.getPlayer().sendStatusMessage(new StringTextComponent("Not enough ground to place!").applyTextStyle(TextFormatting.RED), true); - return ActionResultType.FAIL; + if (!hasGroundUnderneath(context.getPlayer(), context.getLevel())) { + context.getPlayer().displayClientMessage(new TextComponent("Not enough ground to place!").withStyle(ChatFormatting.RED), true); + return InteractionResult.FAIL; } for (int x = -2; x <= 2; x++) { for (int y = 0; y < STRUCTURE_1.length; y++) { @@ -72,12 +74,12 @@ public ActionResultType onItemUse(ItemUseContext context) { String key = STRUCTURE_1[y][z + 2].substring(x + 2, x + 3); if (key.equals("M")) rerollRandomBlocks(); BlockState blockState = BLOCK_KEY.get(key); - BlockPos placePos = pos.add(x, y + 1, z); - if (blockState != null && context.getWorld().getBlockState(placePos).isAir()) { - context.getWorld().setBlockState(placePos, blockState); + BlockPos placePos = pos.offset(x, y + 1, z); + if (blockState != null && context.getLevel().getBlockState(placePos).getMaterial().isReplaceable()) { + context.getLevel().setBlock(placePos, blockState, 0); if (key.equals("C")) { - Chunk chunk = context.getWorld().getChunkAt(placePos); - LockableLootTileEntity.setLootTable(context.getWorld().getBlockReader(chunk.getPos().x, chunk.getPos().z), new Random(), placePos, new ResourceLocation("magicmod", "chests/magic_shelter_chest")); + LevelChunk chunk = context.getLevel().getChunkAt(placePos); + RandomizableContainerBlockEntity.setLootTable(context.getLevel().getChunkForCollisions(chunk.getPos().x, chunk.getPos().z), new Random(), placePos, new ResourceLocation("magicmod", "chests/magic_shelter_chest")); } placedBlock = true; } @@ -85,24 +87,24 @@ public ActionResultType onItemUse(ItemUseContext context) { } } if (placedBlock) { - context.getWorld().playSound(context.getPlayer(), pos.getX(), pos.getY(), pos.getZ(), SoundEvents.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, context.getWorld().rand.nextFloat() * 0.1f + 0.9f); - if (!context.getPlayer().abilities.isCreativeMode) { - context.getPlayer().getHeldItem(context.getHand()).shrink(1); + context.getLevel().playSound(context.getPlayer(), pos.getX(), pos.getY(), pos.getZ(), SoundEvents.STONE_PLACE, SoundSource.BLOCKS, 1, context.getLevel().getRandom().nextFloat() * 0.1f + 0.9f); + if (!context.getPlayer().getAbilities().instabuild) { + context.getPlayer().getItemInHand(context.getHand()).shrink(1); } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - return ActionResultType.PASS; + return InteractionResult.PASS; } - private boolean hasGroundUnderneath(PlayerEntity player, World world) { - return IntStream.rangeClosed(-1, 1).noneMatch(x -> IntStream.rangeClosed(-1, 1).anyMatch(z -> world.getBlockState(player.getPosition().add(x, -2, z)).isAir())); + private boolean hasGroundUnderneath(Player player, Level world) { + return IntStream.rangeClosed(-1, 1).noneMatch(x -> IntStream.rangeClosed(-1, 1).anyMatch(z -> world.getBlockState(new BlockPos(player.getPosition(0).add(x, -2, z))).isAir())); } - private boolean hasEnoughSpace(PlayerEntity player, World world) { + private boolean hasEnoughSpace(Player player, Level world) { for (int x = -2; x <= 2; x++) { for (int y = 0; y < STRUCTURE_1.length; y++) { for (int z = -2; z <= 2; z++) { - if (!world.getBlockState(player.getPosition().add(x, y, z)).isAir()) { + if (!world.getBlockState(new BlockPos(player.getPosition(0).add(x, y, z))).getMaterial().isReplaceable()) { return false; } } @@ -112,7 +114,7 @@ private boolean hasEnoughSpace(PlayerEntity player, World world) { } private void rerollRandomBlocks() { - BLOCK_KEY.replace("M", MAGIC_LAMPS[RANDOM.nextInt(MAGIC_LAMPS.length)].getDefaultState()); + BLOCK_KEY.replace("M", MAGIC_LAMPS[RANDOM.nextInt(MAGIC_LAMPS.length)].defaultBlockState()); } } diff --git a/src/main/java/com/pitheguy/magicmod/items/ModSpawnEggItem.java b/src/main/java/com/pitheguy/magicmod/items/ModSpawnEggItem.java deleted file mode 100644 index 16cd11a..0000000 --- a/src/main/java/com/pitheguy/magicmod/items/ModSpawnEggItem.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.pitheguy.magicmod.items; - -import net.minecraft.block.DispenserBlock; -import net.minecraft.dispenser.DefaultDispenseItemBehavior; -import net.minecraft.dispenser.IBlockSource; -import net.minecraft.entity.EntityType; -import net.minecraft.entity.SpawnReason; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SpawnEggItem; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.Direction; -import net.minecraftforge.common.util.Lazy; -import net.minecraftforge.common.util.NonNullSupplier; -import net.minecraftforge.fml.RegistryObject; -import net.minecraftforge.fml.common.ObfuscationReflectionHelper; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class ModSpawnEggItem extends SpawnEggItem { - - protected static final List UNADDED_EGGS = new ArrayList(); - private final Lazy> entityTypeSupplier; - - public ModSpawnEggItem(final NonNullSupplier> entityTypeSupplier, final int primaryColour, - final int secondaryColour, final Item.Properties properties) { - super(null, primaryColour, secondaryColour, properties); - this.entityTypeSupplier = Lazy.of(entityTypeSupplier::get); - UNADDED_EGGS.add(this); - } - - public ModSpawnEggItem(final RegistryObject> entityTypeSupplier, final int primaryColour, - final int secondaryColour, final Item.Properties properties) { - super(null, primaryColour, secondaryColour, properties); - this.entityTypeSupplier = Lazy.of(entityTypeSupplier); - UNADDED_EGGS.add(this); - } - - public ModSpawnEggItem(final RegistryObject> entityTypeSupplier, final Item.Properties properties) { - super(null, 0, 0, properties); - this.entityTypeSupplier = Lazy.of(entityTypeSupplier); - UNADDED_EGGS.add(this); - } - - public static void initSpawnEggs() { - final Map, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, - null, "field_195987_b"); - DefaultDispenseItemBehavior dispenseBehaviour = new DefaultDispenseItemBehavior() { - @Override - protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) { - Direction direction = source.getBlockState().get(DispenserBlock.FACING); - EntityType type = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); - type.spawn(source.getWorld(), stack, null, source.getBlockPos().offset(direction), - SpawnReason.DISPENSER, direction != Direction.UP, false); - stack.shrink(1); - return stack; - } - }; - - for (final SpawnEggItem spawnEgg : UNADDED_EGGS) { - EGGS.put(spawnEgg.getType(null), spawnEgg); - DispenserBlock.registerDispenseBehavior(spawnEgg, dispenseBehaviour); - } - UNADDED_EGGS.clear(); - } - - @Override - public EntityType getType(CompoundNBT nbt) { - return this.entityTypeSupplier.get(); - } -} diff --git a/src/main/java/com/pitheguy/magicmod/items/PopularityOrb.java b/src/main/java/com/pitheguy/magicmod/items/PopularityOrb.java index 373de11..0ab80e7 100644 --- a/src/main/java/com/pitheguy/magicmod/items/PopularityOrb.java +++ b/src/main/java/com/pitheguy/magicmod/items/PopularityOrb.java @@ -2,78 +2,71 @@ import com.pitheguy.magicmod.MagicMod; import com.pitheguy.magicmod.init.ModEntityTypes; -import net.minecraft.block.BlockState; -import net.minecraft.block.FlowingFluidBlock; -import net.minecraft.entity.SpawnReason; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.stats.Stats; -import net.minecraft.util.ActionResult; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceContext; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.World; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.MobSpawnType; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; + import java.util.Objects; public class PopularityOrb extends Item { public PopularityOrb() { - super(new Item.Properties().group(MagicMod.TAB)); + super(new Item.Properties().tab(MagicMod.TAB)); } - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - if (!world.isRemote) { - ItemStack itemstack = context.getItem(); - BlockPos blockpos = context.getPos(); - Direction direction = context.getFace(); + public InteractionResult useOn(UseOnContext context) { + Level world = context.getLevel(); + if (!world.isClientSide) { + ItemStack itemstack = context.getItemInHand(); + BlockPos blockpos = context.getClickedPos(); + Direction direction = context.getClickedFace(); BlockState blockstate = world.getBlockState(blockpos); - - BlockPos blockpos1; - if (blockstate.getCollisionShape(world, blockpos).isEmpty()) { - blockpos1 = blockpos; - } else { - blockpos1 = blockpos.offset(direction); - } - - if (ModEntityTypes.MAGIC_FRIEND.get().spawn(world, itemstack, context.getPlayer(), blockpos1, SpawnReason.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) { + BlockPos blockpos1 = blockstate.getCollisionShape(world, blockpos).isEmpty() ? blockpos : blockpos.relative(direction); + if (ModEntityTypes.MAGIC_FRIEND.get().spawn(world.getServer().overworld(), itemstack, context.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP) != null) { itemstack.shrink(1); } } - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } - public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { - ItemStack itemstack = playerIn.getHeldItem(handIn); - RayTraceResult raytraceresult = rayTrace(worldIn, playerIn, RayTraceContext.FluidMode.SOURCE_ONLY); - if (raytraceresult.getType() != RayTraceResult.Type.BLOCK) { - return ActionResult.resultPass(itemstack); - } else if (worldIn.isRemote) { - return ActionResult.resultSuccess(itemstack); + public InteractionResultHolder use(Level worldIn, Player playerIn, InteractionHand handIn) { + ItemStack itemstack = playerIn.getItemInHand(handIn); + BlockHitResult raytraceresult = getPlayerPOVHitResult(worldIn, playerIn, ClipContext.Fluid.SOURCE_ONLY); + if (raytraceresult.getType() != HitResult.Type.BLOCK) { + return InteractionResultHolder.pass(itemstack); + } else if (worldIn.isClientSide) { + return InteractionResultHolder.success(itemstack); } else { - BlockRayTraceResult blockraytraceresult = (BlockRayTraceResult)raytraceresult; - BlockPos blockpos = blockraytraceresult.getPos(); - if (!(worldIn.getBlockState(blockpos).getBlock() instanceof FlowingFluidBlock)) { - return ActionResult.resultPass(itemstack); - } else if (worldIn.isBlockModifiable(playerIn, blockpos) && playerIn.canPlayerEdit(blockpos, blockraytraceresult.getFace(), itemstack)) { - if (ModEntityTypes.MAGIC_FRIEND.get().spawn(worldIn, itemstack, playerIn, blockpos, SpawnReason.SPAWN_EGG, false, false) == null) { - return ActionResult.resultPass(itemstack); + BlockPos blockpos = raytraceresult.getBlockPos(); + if (!(worldIn.getBlockState(blockpos).getBlock() instanceof LiquidBlock)) { + return InteractionResultHolder.pass(itemstack); + } else if (worldIn.mayInteract(playerIn, blockpos) && playerIn.mayUseItemAt(blockpos, raytraceresult.getDirection(), itemstack)) { + if (ModEntityTypes.MAGIC_FRIEND.get().spawn(worldIn.getServer().overworld(), itemstack, playerIn, blockpos, MobSpawnType.SPAWN_EGG, false, false) == null) { + return InteractionResultHolder.pass(itemstack); } else { - if (!playerIn.abilities.isCreativeMode) { + if (!playerIn.getAbilities().instabuild) { itemstack.shrink(1); } - playerIn.addStat(Stats.ITEM_USED.get(this)); - return ActionResult.resultSuccess(itemstack); + playerIn.awardStat(Stats.ITEM_USED.get(this)); + return InteractionResultHolder.success(itemstack); } } else { - return ActionResult.resultFail(itemstack); + return InteractionResultHolder.fail(itemstack); } } } diff --git a/src/main/java/com/pitheguy/magicmod/items/UpgradeItem.java b/src/main/java/com/pitheguy/magicmod/items/UpgradeItem.java new file mode 100644 index 0000000..22275fb --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/items/UpgradeItem.java @@ -0,0 +1,14 @@ +package com.pitheguy.magicmod.items; + +import com.pitheguy.magicmod.MagicMod; +import net.minecraft.world.item.Item; + +public class UpgradeItem extends Item { + public UpgradeItem() { + this(new Item.Properties().tab(MagicMod.TAB)); + } + + public UpgradeItem(Item.Properties properties) { + super(properties); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/tileentity/MagicCrateTileEntity.java b/src/main/java/com/pitheguy/magicmod/tileentity/MagicCrateTileEntity.java deleted file mode 100644 index afbad51..0000000 --- a/src/main/java/com/pitheguy/magicmod/tileentity/MagicCrateTileEntity.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.pitheguy.magicmod.tileentity; - -import com.pitheguy.magicmod.blocks.MagicCrate; -import com.pitheguy.magicmod.container.MagicCrateContainer; -import com.pitheguy.magicmod.init.ModTileEntityTypes; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.inventory.ItemStackHelper; -import net.minecraft.inventory.container.Container; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.CompoundNBT; -import net.minecraft.tileentity.LockableLootTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import net.minecraft.util.*; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.IBlockReader; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.util.LazyOptional; -import net.minecraftforge.items.CapabilityItemHandler; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.wrapper.InvWrapper; - -import javax.annotation.Nonnull; - -public class MagicCrateTileEntity extends LockableLootTileEntity { - private NonNullList crateContents = NonNullList.withSize(88, ItemStack.EMPTY); - protected int numPlayersUsing; - private final IItemHandlerModifiable items = createHandler(); - private LazyOptional itemHandler = LazyOptional.of(() -> items); - - public MagicCrateTileEntity(TileEntityType typeIn) { - super(typeIn); - } - - public MagicCrateTileEntity() { - this(ModTileEntityTypes.MAGIC_CRATE.get()); - } - - @Override - public int getSizeInventory() { - return 88; - } - - @Override - public NonNullList getItems() { - return this.crateContents; - } - - @Override - public void setItems(NonNullList itemsIn) { - this.crateContents = itemsIn; - } - - @Override - protected ITextComponent getDefaultName() { - return new TranslationTextComponent("container.magicmod.magic_crate"); - } - - @Override - protected Container createMenu(int id, PlayerInventory player) { - return new MagicCrateContainer(id, player, this); - } - - @Override - public CompoundNBT write(CompoundNBT compound) { - super.write(compound); - if (!this.checkLootAndWrite(compound)) { - ItemStackHelper.saveAllItems(compound, this.crateContents); - } - return compound; - } - - @Override - public void read(CompoundNBT compound) { - super.read(compound); - this.crateContents = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); - if (!this.checkLootAndRead(compound)) { - ItemStackHelper.loadAllItems(compound, this.crateContents); - } - } - - private void playSound(SoundEvent sound) { - double dx = (double) this.pos.getX() + 0.5D; - double dy = (double) this.pos.getY() + 0.5D; - double dz = (double) this.pos.getZ() + 0.5D; - this.world.playSound(null, dx, dy, dz, sound, SoundCategory.BLOCKS, 0.5f, - this.world.rand.nextFloat() * 0.1f + 0.9f); - } - - @Override - public boolean receiveClientEvent(int id, int type) { - if (id == 1) { - this.numPlayersUsing = type; - return true; - } else { - return super.receiveClientEvent(id, type); - } - } - - @Override - public void openInventory(PlayerEntity player) { - if (!player.isSpectator()) { - if (this.numPlayersUsing < 0) { - this.numPlayersUsing = 0; - } - - ++this.numPlayersUsing; - this.onOpenOrClose(); - } - } - - @Override - public void closeInventory(PlayerEntity player) { - if (!player.isSpectator()) { - --this.numPlayersUsing; - this.onOpenOrClose(); - } - } - - protected void onOpenOrClose() { - Block block = this.getBlockState().getBlock(); - if (block instanceof MagicCrate) { - this.world.addBlockEvent(this.pos, block, 1, this.numPlayersUsing); - this.world.notifyNeighborsOfStateChange(this.pos, block); - } - } - - public static int getPlayersUsing(IBlockReader reader, BlockPos pos) { - BlockState blockstate = reader.getBlockState(pos); - if (blockstate.hasTileEntity()) { - TileEntity tileentity = reader.getTileEntity(pos); - if (tileentity instanceof MagicCrateTileEntity) { - return ((MagicCrateTileEntity) tileentity).numPlayersUsing; - } - } - return 0; - } - - public static void swapContents(MagicCrateTileEntity te, MagicCrateTileEntity otherTe) { - NonNullList list = te.getItems(); - te.setItems(otherTe.getItems()); - otherTe.setItems(list); - } - - @Override - public void updateContainingBlockInfo() { - super.updateContainingBlockInfo(); - if (this.itemHandler != null) { - this.itemHandler.invalidate(); - this.itemHandler = null; - } - } - - @Override - public LazyOptional getCapability(@Nonnull Capability cap, @Nonnull Direction side) { - if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - return itemHandler.cast(); - } - return super.getCapability(cap, side); - } - - private IItemHandlerModifiable createHandler() { - return new InvWrapper(this); - } - - @Override - public void remove() { - super.remove(); - if(itemHandler != null) { - itemHandler.invalidate(); - } - } - -} diff --git a/src/main/java/com/pitheguy/magicmod/tools/MagicAxe.java b/src/main/java/com/pitheguy/magicmod/tools/MagicAxe.java index bb76b7e..abb9b01 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/MagicAxe.java +++ b/src/main/java/com/pitheguy/magicmod/tools/MagicAxe.java @@ -1,32 +1,30 @@ package com.pitheguy.magicmod.tools; -import com.pitheguy.magicmod.MagicMod; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.AxeItem; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.AxeItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public class MagicAxe extends AxeItem { - public MagicAxe(IItemTier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { + public MagicAxe(Tier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { - if (entityLiving instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entityLiving; - if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player.getHeldItemMainhand()) * 0.1) { - World world = player.getEntityWorld(); - world.addEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + if (entityLiving instanceof Player player) { + if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player) * 0.1) { + Level world = player.level; + world.addFreshEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/MagicHoe.java b/src/main/java/com/pitheguy/magicmod/tools/MagicHoe.java index e9ebfeb..3a54ad3 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/MagicHoe.java +++ b/src/main/java/com/pitheguy/magicmod/tools/MagicHoe.java @@ -1,84 +1,88 @@ package com.pitheguy.magicmod.tools; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.HoeItem; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import com.mojang.datafixers.util.Pair; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.HoeItem; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.context.UseOnContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraftforge.event.ForgeEventFactory; import java.util.Arrays; import java.util.List; +import java.util.function.Consumer; +import java.util.function.Predicate; public class MagicHoe extends HoeItem { - public MagicHoe(IItemTier tier, float attackSpeedIn, Properties builder) { - super(tier, attackSpeedIn, builder); + private final int abilityRange; + public MagicHoe(Tier tier, int attackDamage, float attackSpeedIn, Properties builder, int abilityRange) { + super(tier, attackDamage, attackSpeedIn, builder); + this.abilityRange = abilityRange; } @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - BlockPos blockpos = context.getPos(); - int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(context); - if (hook != 0) return hook > 0 ? ActionResultType.SUCCESS : ActionResultType.FAIL; - BlockState blockstate = HOE_LOOKUP.get(world.getBlockState(blockpos).getBlock()); - if (context.getFace() != Direction.DOWN && blockstate != null && world.isAirBlock(blockpos.up())) { - int tillX = -1; + public InteractionResult useOn(UseOnContext context) { + Level level = context.getLevel(); + BlockPos blockpos = context.getClickedPos(); + int hook = ForgeEventFactory.onHoeUse(context); + if (hook != 0) return hook > 0 ? InteractionResult.SUCCESS : InteractionResult.FAIL; + Pair, Consumer> pair = TILLABLES.get(level.getBlockState(blockpos).getBlock()); + if (context.getClickedFace() != Direction.DOWN && level.isEmptyBlock(blockpos.above())) { + if (pair == null) return InteractionResult.PASS; int blocksTilled = 0; - int tillZ; - while (tillX <= 1) { - tillZ = -1; - while (tillZ <= 1) { - BlockPos tillpos = blockpos.add(tillX,0,tillZ); - blockstate = HOE_LOOKUP.get(world.getBlockState(tillpos).getBlock()); - if (blockstate != null && world.isAirBlock(tillpos.up())) { - PlayerEntity playerentity = context.getPlayer(); - world.playSound(playerentity, tillpos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isRemote) { - world.setBlockState(tillpos, blockstate, 11); - blocksTilled++; - if (playerentity != null && blocksTilled == 1) { - context.getItem().damageItem(1, playerentity, (p_220043_1_) -> { - p_220043_1_.sendBreakAnimation(context.getHand()); - }); + for (int tillX = -abilityRange; tillX <= abilityRange; tillX++) { + for (int tillZ = -abilityRange; tillZ <= abilityRange; tillZ++) { + BlockPos tillpos = blockpos.offset(tillX,0,tillZ); + pair = TILLABLES.get(level.getBlockState(tillpos).getBlock()); + if (pair != null) { + Predicate predicate = pair.getFirst(); + Consumer consumer = pair.getSecond(); + if (predicate.test(context)) { + Player player = context.getPlayer(); + level.playSound(player, tillpos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F); + if (!level.isClientSide) { + consumer.accept(context); + blocksTilled++; + if (player != null && blocksTilled == 1) { + context.getItemInHand().hurtAndBreak(1, player, (p_220043_1_) -> p_220043_1_.broadcastBreakEvent(context.getHand())); + } } } } - tillZ++; } - tillX++; } if (blocksTilled > 0) { - return ActionResultType.SUCCESS; + return InteractionResult.SUCCESS; } } - return ActionResultType.PASS; + return InteractionResult.PASS; } private static final List CROP_BLOCKS_AGE_7 = Arrays.asList(Blocks.WHEAT, Blocks.CARROTS, Blocks.POTATOES); private static final List CROP_BLOCKS_AGE_3 = Arrays.asList(Blocks.BEETROOTS, Blocks.NETHER_WART); @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { - BlockState currBlock = worldIn.getBlockState(pos.add(x, 0, z)); - if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_3) == 3)) { - worldIn.destroyBlock(pos.add(x, 0, z), true); + BlockState currBlock = worldIn.getBlockState(pos.offset(x, 0, z)); + if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_3) == 3)) { + worldIn.destroyBlock(pos.offset(x, 0, z), true); } } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/MagicPickaxe.java b/src/main/java/com/pitheguy/magicmod/tools/MagicPickaxe.java index cee8378..18986e6 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/MagicPickaxe.java +++ b/src/main/java/com/pitheguy/magicmod/tools/MagicPickaxe.java @@ -1,41 +1,41 @@ package com.pitheguy.magicmod.tools; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.PickaxeItem; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.PickaxeItem; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public class MagicPickaxe extends PickaxeItem { - public MagicPickaxe(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { + public MagicPickaxe(Tier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { int blocksBroken = 1; - if (entityLiving instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entityLiving; - IBlockReader reader = player.world.getBlockReader(player.world.getChunkAt(pos).getPos().x, player.world.getChunkAt(pos).getPos().z); - double d = state.getPlayerRelativeBlockHardness(player, reader, pos) >= 1 ? 0.02 : 0.1; - if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player.getHeldItemMainhand()) * d) { - player.world.addEntity(new ItemEntity(player.world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); + if (entityLiving instanceof Player player) { + BlockGetter reader = player.level.getChunkForCollisions(player.level.getChunkAt(pos).getPos().x, player.level.getChunkAt(pos).getPos().z); + double d = player.getDigSpeed(state, pos) >= 1 ? 0.02 : 0.1; + if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player) * d) { + player.level.addFreshEntity(new ItemEntity(player.level, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); } - int veinminerLevel = EnchantmentHelper.getEnchantmentLevel(RegistryHandler.VEINMINER.get(), player.getHeldItemMainhand()); + int veinminerLevel = EnchantmentHelper.getEnchantmentLevel(RegistryHandler.VEINMINER.get(), player); if (veinminerLevel > 0 && state.canHarvestBlock(reader, pos, player)) { for (int x = -veinminerLevel; x <= veinminerLevel; x++) { for (int y = -veinminerLevel; y <= veinminerLevel; y++) { for (int z = -veinminerLevel; z <= veinminerLevel; z++) { - if (worldIn.getBlockState(pos.add(x, y, z)).getBlock() == state.getBlock()) { - worldIn.destroyBlock(pos.add(x,y,z), true, player); + BlockPos currBlock = pos.offset(x, y, z); + if (worldIn.getBlockState(currBlock).getBlock() == state.getBlock()) { + worldIn.destroyBlock(currBlock, true, player); blocksBroken++; } } @@ -43,8 +43,8 @@ public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state } } } - if (!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0F) { - stack.damageItem(blocksBroken, entityLiving, entity -> entity.sendBreakAnimation(EquipmentSlotType.MAINHAND)); + if (!worldIn.isClientSide && state.getDestroySpeed(worldIn, pos) != 0.0F) { + stack.hurtAndBreak(blocksBroken, entityLiving, entity -> entity.broadcastBreakEvent(EquipmentSlot.MAINHAND)); } return true; diff --git a/src/main/java/com/pitheguy/magicmod/tools/MagicShovel.java b/src/main/java/com/pitheguy/magicmod/tools/MagicShovel.java index 2419f8e..7cad77c 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/MagicShovel.java +++ b/src/main/java/com/pitheguy/magicmod/tools/MagicShovel.java @@ -1,32 +1,30 @@ package com.pitheguy.magicmod.tools; -import com.pitheguy.magicmod.MagicMod; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.block.BlockState; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ShovelItem; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.ShovelItem; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; public class MagicShovel extends ShovelItem { - public MagicShovel(IItemTier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { + public MagicShovel(Tier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { - if (entityLiving instanceof PlayerEntity) { - PlayerEntity player = (PlayerEntity) entityLiving; - if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player.getHeldItemMainhand()) * 0.1) { - World world = player.getEntityWorld(); - world.addEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + if (entityLiving instanceof Player player) { + if (Math.random() < EnchantmentHelper.getEnchantmentLevel(RegistryHandler.MAGIC_FINDER.get(), player) * 0.1) { + Level world = player.level; + world.addFreshEntity(new ItemEntity(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(RegistryHandler.MAGIC_POWDER.get()))); } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/MagicSword.java b/src/main/java/com/pitheguy/magicmod/tools/MagicSword.java index 0a1dd8a..8dbd261 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/MagicSword.java +++ b/src/main/java/com/pitheguy/magicmod/tools/MagicSword.java @@ -1,29 +1,30 @@ package com.pitheguy.magicmod.tools; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.material.Material; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.SwordItem; import net.minecraft.tags.BlockTags; -import org.jetbrains.annotations.NotNull; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.SwordItem; +import net.minecraft.world.item.Tier; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.Material; + +import javax.annotation.Nonnull; public class MagicSword extends SwordItem { - public MagicSword(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { + public MagicSword(Tier tier, int attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public float getDestroySpeed(@NotNull ItemStack stack, BlockState state) { + public float getDestroySpeed(@Nonnull ItemStack stack, BlockState state) { Block block = state.getBlock(); if (block == Blocks.COBWEB || block == RegistryHandler.MAGIC_WEB.get()) { return 15.0F; } else { Material material = state.getMaterial(); - return material != Material.PLANTS && material != Material.TALL_PLANTS && material != Material.CORAL && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F; + return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.WATER_PLANT && !state.is(BlockTags.LEAVES) && material != Material.VEGETABLE ? 1.0F : 1.5F; } } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/ModItemTiers.java b/src/main/java/com/pitheguy/magicmod/tools/ModItemTiers.java index b98b3f1..50d1e00 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/ModItemTiers.java +++ b/src/main/java/com/pitheguy/magicmod/tools/ModItemTiers.java @@ -1,60 +1,59 @@ package com.pitheguy.magicmod.tools; import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.item.IItemTier; -import net.minecraft.item.crafting.Ingredient; -import org.jetbrains.annotations.NotNull; +import net.minecraft.world.item.Tier; +import net.minecraft.world.item.crafting.Ingredient; +import javax.annotation.Nonnull; import java.util.function.Supplier; -public enum ModItemTiers implements IItemTier { - MAGIC(() -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()), 5, 75000, 42, 0, 40), - REINFORCED_MAGIC(() -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()), 6, 200000, 75, 0, 60), - OBSIDIAN_PLATED_REINFORCED_MAGIC(() -> Ingredient.fromItems(RegistryHandler.MAGIC_GEM.get()), 7, 550000, 135, 0, 80); - - private final int harvestLevel; - private final int maxUses; - private final float efficiency; - private final float attackDamage; - private final int enchantability; - private final Supplier repairMaterial; - - ModItemTiers(Supplier repairMaterial, int harvestLevel, int maxUses, float efficiency, float attackDamage, int enchantability) { - this.harvestLevel = harvestLevel; - this.maxUses = maxUses; - this.efficiency = efficiency; - this.attackDamage = attackDamage; - this.enchantability = enchantability; - this.repairMaterial = repairMaterial; +public enum ModItemTiers implements Tier { + MAGIC(() -> Ingredient.of(RegistryHandler.MAGIC_GEM.get()), 5, 75000, 42, 0, 40), + REINFORCED_MAGIC(() -> Ingredient.of(RegistryHandler.MAGIC_GEM.get()), 6, 200000, 75, 0, 60), + OBSIDIAN_PLATED_REINFORCED_MAGIC(() -> Ingredient.of(RegistryHandler.MAGIC_GEM.get()), 7, 550000, 135, 0, 80); + + private final int level; + private final int uses; + private final float speed; + private final float attackDamageBonus; + private final int enchantmentValue; + private final Supplier repairIngredient; + + ModItemTiers(Supplier repairIngredient, int level, int uses, float speed, float attackDamageBonus, int enchantmentValue) { + this.level = level; + this.uses = uses; + this.speed = speed; + this.attackDamageBonus = attackDamageBonus; + this.enchantmentValue = enchantmentValue; + this.repairIngredient = repairIngredient; } @Override - public int getMaxUses() { - return maxUses; + public int getUses() { + return uses; } @Override - public float getEfficiency() { - return efficiency; + public float getSpeed() { + return speed; } @Override - public float getAttackDamage() { - return attackDamage; + public float getAttackDamageBonus() { + return attackDamageBonus; } @Override - public int getHarvestLevel() { - return harvestLevel; + public int getLevel() { + return level; } @Override - public int getEnchantability() { - return enchantability; + public int getEnchantmentValue() { + return enchantmentValue; } - @Override - public @NotNull Ingredient getRepairMaterial() { - return repairMaterial.get(); + public @Nonnull Ingredient getRepairIngredient() { + return repairIngredient.get(); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicAxe.java b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicAxe.java new file mode 100644 index 0000000..5f80e79 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicAxe.java @@ -0,0 +1,37 @@ +package com.pitheguy.magicmod.tools; + + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.Arrays; +import java.util.List; + +import static net.minecraft.world.level.block.Blocks.*; + +public class ObsidianPlatedReinforcedMagicAxe extends MagicAxe{ + public static final List WOOD_BLOCKS = Arrays.asList(OAK_LOG, OAK_LEAVES, BIRCH_LOG, BIRCH_LEAVES, SPRUCE_LOG, SPRUCE_LEAVES, DARK_OAK_LOG, DARK_OAK_LEAVES, JUNGLE_LOG, JUNGLE_LEAVES, ACACIA_LOG, ACACIA_LEAVES); + public ObsidianPlatedReinforcedMagicAxe(Tier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { + super(tier, attackDamageIn, attackSpeedIn, builder); + } + + @Override + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + if (WOOD_BLOCKS.contains(state.getBlock())) recursivelyMineTree(worldIn, pos, entityLiving, 0); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); + } + + public void recursivelyMineTree(Level worldIn, BlockPos pos, LivingEntity entity, int depth) { + if (!WOOD_BLOCKS.contains(worldIn.getBlockState(pos).getBlock()) || depth > 1000) return; + worldIn.destroyBlock(pos, true, entity); + for (Direction direction : Direction.values()) { + this.recursivelyMineTree(worldIn, pos.relative(direction), entity, depth + 1); + } + } +} diff --git a/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicHoe.java b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicHoe.java index a8b2ce5..0a6fa6b 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicHoe.java +++ b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicHoe.java @@ -1,76 +1,36 @@ package com.pitheguy.magicmod.tools; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.HoeItem; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import java.util.Arrays; import java.util.List; -public class ObsidianPlatedReinforcedMagicHoe extends HoeItem { - public ObsidianPlatedReinforcedMagicHoe(IItemTier tier, float attackSpeedIn, Properties builder) { - super(tier, attackSpeedIn, builder); +public class ObsidianPlatedReinforcedMagicHoe extends ReinforcedMagicHoe { + public ObsidianPlatedReinforcedMagicHoe(Tier tier, int attackDamage, float attackSpeedIn, Properties builder, int abilityRange) { + super(tier, attackDamage, attackSpeedIn, builder, abilityRange); } - @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - BlockPos blockpos = context.getPos(); - int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(context); - if (hook != 0) return hook > 0 ? ActionResultType.SUCCESS : ActionResultType.FAIL; - BlockState blockstate = HOE_LOOKUP.get(world.getBlockState(blockpos).getBlock()); - if (context.getFace() != Direction.DOWN && blockstate != null && world.isAirBlock(blockpos.up())) { - int blocksTilled = 0; - for (int tillX = -5; tillX <= 5; tillX++) { - for (int tillZ = -5; tillZ <= 5; tillZ++) { - BlockPos tillpos = blockpos.add(tillX,0,tillZ); - blockstate = HOE_LOOKUP.get(world.getBlockState(tillpos).getBlock()); - if (blockstate != null && world.isAirBlock(tillpos.up())) { - PlayerEntity playerentity = context.getPlayer(); - world.playSound(playerentity, tillpos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isRemote) { - world.setBlockState(tillpos, blockstate, 11); - blocksTilled++; - if (playerentity != null && blocksTilled == 1) { - context.getItem().damageItem(1, playerentity, (p_220043_1_) -> p_220043_1_.sendBreakAnimation(context.getHand())); - } - } - } - } - } - if (blocksTilled > 0) { - return ActionResultType.SUCCESS; - } - } - - return ActionResultType.PASS; - } private static final List CROP_BLOCKS_AGE_7 = Arrays.asList(Blocks.WHEAT, Blocks.CARROTS, Blocks.POTATOES); private static final List CROP_BLOCKS_AGE_3 = Arrays.asList(Blocks.BEETROOTS, Blocks.NETHER_WART); @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { for (int x = -3; x <= 3; x++) { for (int z = -3; z <= 3; z++) { - BlockState currBlock = worldIn.getBlockState(pos.add(x, 0, z)); - if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_3) == 3)) { - worldIn.destroyBlock(pos.add(x, 0, z), true); + BlockState currBlock = worldIn.getBlockState(pos.offset(x, 0, z)); + if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_3) == 3)) { + worldIn.destroyBlock(pos.offset(x, 0, z), true); } } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicShovel.java b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicShovel.java index 04073d9..ddf72de 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicShovel.java +++ b/src/main/java/com/pitheguy/magicmod/tools/ObsidianPlatedReinforcedMagicShovel.java @@ -1,29 +1,29 @@ package com.pitheguy.magicmod.tools; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; +import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.LivingEntity; +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; public class ObsidianPlatedReinforcedMagicShovel extends ReinforcedMagicShovel { - public ObsidianPlatedReinforcedMagicShovel(IItemTier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { + public ObsidianPlatedReinforcedMagicShovel(Tier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { for (int x = -2; x <= 2; x++) { for (int y = -2; y <= 2; y++) { for (int z = -2; z <= 2; z++) { - if (worldIn.getBlockState(pos.add(x, y, z)).getBlock().getHarvestTool(null) == ToolType.SHOVEL) { - worldIn.destroyBlock(pos.add(x, y, z), true); + if (worldIn.getBlockState(pos.offset(x, y, z)).is(BlockTags.MINEABLE_WITH_SHOVEL)) { + worldIn.destroyBlock(pos.offset(x, y, z), true); } } } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicHoe.java b/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicHoe.java index aec340d..dacdc82 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicHoe.java +++ b/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicHoe.java @@ -1,81 +1,36 @@ package com.pitheguy.magicmod.tools; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.HoeItem; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemUseContext; -import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.util.ActionResultType; -import net.minecraft.util.Direction; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.SoundEvents; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Tier; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import java.util.Arrays; import java.util.List; -public class ReinforcedMagicHoe extends HoeItem { - public ReinforcedMagicHoe(IItemTier tier, float attackSpeedIn, Properties builder) { - super(tier, attackSpeedIn, builder); +public class ReinforcedMagicHoe extends MagicHoe { + public ReinforcedMagicHoe(Tier tier, int attackDamage, float attackSpeedIn, Properties builder, int abilityRange) { + super(tier, attackDamage, attackSpeedIn, builder, abilityRange); } - @Override - public ActionResultType onItemUse(ItemUseContext context) { - World world = context.getWorld(); - BlockPos blockpos = context.getPos(); - int hook = net.minecraftforge.event.ForgeEventFactory.onHoeUse(context); - if (hook != 0) return hook > 0 ? ActionResultType.SUCCESS : ActionResultType.FAIL; - BlockState blockstate = HOE_LOOKUP.get(world.getBlockState(blockpos).getBlock()); - if (context.getFace() != Direction.DOWN && blockstate != null && world.isAirBlock(blockpos.up())) { - int tillX = -3; - int blocksTilled = 0; - int tillZ; - while (tillX <= 3) { - tillZ = -3; - while (tillZ <= 3) { - BlockPos tillpos = blockpos.add(tillX,0,tillZ); - blockstate = HOE_LOOKUP.get(world.getBlockState(tillpos).getBlock()); - if (blockstate != null && world.isAirBlock(tillpos.up())) { - PlayerEntity playerentity = context.getPlayer(); - world.playSound(playerentity, tillpos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F); - if (!world.isRemote) { - world.setBlockState(tillpos, blockstate, 11); - blocksTilled++; - if (playerentity != null && blocksTilled == 1) { - context.getItem().damageItem(1, playerentity, (p_220043_1_) -> p_220043_1_.sendBreakAnimation(context.getHand())); - } - } - } - tillZ++; - } - tillX++; - } - if (blocksTilled > 0) { - return ActionResultType.SUCCESS; - } - } - - return ActionResultType.PASS; - } private static final List CROP_BLOCKS_AGE_7 = Arrays.asList(Blocks.WHEAT, Blocks.CARROTS, Blocks.POTATOES); private static final List CROP_BLOCKS_AGE_3 = Arrays.asList(Blocks.BEETROOTS, Blocks.NETHER_WART); @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { for (int x = -2; x <= 2; x++) { for (int z = -2; z <= 2; z++) { - BlockState currBlock = worldIn.getBlockState(pos.add(x, 0, z)); - if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.get(BlockStateProperties.AGE_0_3) == 3)) { - worldIn.destroyBlock(pos.add(x, 0, z), true); + BlockState currBlock = worldIn.getBlockState(pos.offset(x, 0, z)); + if((CROP_BLOCKS_AGE_7.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_7) == 7) || (CROP_BLOCKS_AGE_3.contains(currBlock.getBlock()) && currBlock.getValue(BlockStateProperties.AGE_3) == 3)) { + worldIn.destroyBlock(pos.offset(x, 0, z), true); } } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicShovel.java b/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicShovel.java index 990e90e..db06964 100644 --- a/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicShovel.java +++ b/src/main/java/com/pitheguy/magicmod/tools/ReinforcedMagicShovel.java @@ -1,29 +1,29 @@ package com.pitheguy.magicmod.tools; -import net.minecraft.block.BlockState; -import net.minecraft.entity.LivingEntity; -import net.minecraft.item.IItemTier; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import net.minecraftforge.common.ToolType; +import net.minecraft.core.BlockPos; +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.LivingEntity; +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; public class ReinforcedMagicShovel extends MagicShovel { - public ReinforcedMagicShovel(IItemTier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { + public ReinforcedMagicShovel(Tier tier, float attackDamageIn, float attackSpeedIn, Properties builder) { super(tier, attackDamageIn, attackSpeedIn, builder); } @Override - public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { + public boolean mineBlock(ItemStack stack, Level worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) { for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { for (int z = -1; z <= 1; z++) { - if (worldIn.getBlockState(pos.add(x, y, z)).getBlock().getHarvestTool(null) == ToolType.SHOVEL) { - worldIn.destroyBlock(pos.add(x, y, z), true); + if (worldIn.getBlockState(pos.offset(x, y, z)).is(BlockTags.MINEABLE_WITH_SHOVEL)) { + worldIn.destroyBlock(pos.offset(x, y, z), true); } } } } - return super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving); + return super.mineBlock(stack, worldIn, state, pos, entityLiving); } } diff --git a/src/main/java/com/pitheguy/magicmod/util/ArmorHandler.java b/src/main/java/com/pitheguy/magicmod/util/ArmorHandler.java index 81f8f5e..fcfe6ba 100644 --- a/src/main/java/com/pitheguy/magicmod/util/ArmorHandler.java +++ b/src/main/java/com/pitheguy/magicmod/util/ArmorHandler.java @@ -1,25 +1,25 @@ package com.pitheguy.magicmod.util; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; public class ArmorHandler { - public static boolean isWearingMagicArmor (PlayerEntity player) { - return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == RegistryHandler.MAGIC_HELMET.get() && - player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == RegistryHandler.MAGIC_CHESTPLATE.get() && - player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == RegistryHandler.MAGIC_LEGGINGS.get() && - player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == RegistryHandler.MAGIC_BOOTS.get(); + public static boolean isWearingMagicArmor (Player player) { + return player.getItemBySlot(EquipmentSlot.HEAD).getItem() == RegistryHandler.MAGIC_HELMET.get() && + player.getItemBySlot(EquipmentSlot.CHEST).getItem() == RegistryHandler.MAGIC_CHESTPLATE.get() && + player.getItemBySlot(EquipmentSlot.LEGS).getItem() == RegistryHandler.MAGIC_LEGGINGS.get() && + player.getItemBySlot(EquipmentSlot.FEET).getItem() == RegistryHandler.MAGIC_BOOTS.get(); } - public static boolean isWearingReinforcedMagicArmor (PlayerEntity player) { - return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == RegistryHandler.REINFORCED_MAGIC_HELMET.get() && - player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == RegistryHandler.REINFORCED_MAGIC_CHESTPLATE.get() && - player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == RegistryHandler.REINFORCED_MAGIC_LEGGINGS.get() && - player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == RegistryHandler.REINFORCED_MAGIC_BOOTS.get(); + public static boolean isWearingReinforcedMagicArmor (Player player) { + return player.getItemBySlot(EquipmentSlot.HEAD).getItem() == RegistryHandler.REINFORCED_MAGIC_HELMET.get() && + player.getItemBySlot(EquipmentSlot.CHEST).getItem() == RegistryHandler.REINFORCED_MAGIC_CHESTPLATE.get() && + player.getItemBySlot(EquipmentSlot.LEGS).getItem() == RegistryHandler.REINFORCED_MAGIC_LEGGINGS.get() && + player.getItemBySlot(EquipmentSlot.FEET).getItem() == RegistryHandler.REINFORCED_MAGIC_BOOTS.get(); } - public static boolean isWearingObsidianPlatedReinforcedMagicArmor (PlayerEntity player) { - return player.getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get() && - player.getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get() && - player.getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get() && - player.getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get(); + public static boolean isWearingObsidianPlatedReinforcedMagicArmor (Player player) { + return player.getItemBySlot(EquipmentSlot.HEAD).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET.get() && + player.getItemBySlot(EquipmentSlot.CHEST).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE.get() && + player.getItemBySlot(EquipmentSlot.LEGS).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS.get() && + player.getItemBySlot(EquipmentSlot.FEET).getItem() == RegistryHandler.OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS.get(); } } diff --git a/src/main/java/com/pitheguy/magicmod/util/FunctionalIntReferenceHolder.java b/src/main/java/com/pitheguy/magicmod/util/FunctionalIntDataSlot.java similarity index 67% rename from src/main/java/com/pitheguy/magicmod/util/FunctionalIntReferenceHolder.java rename to src/main/java/com/pitheguy/magicmod/util/FunctionalIntDataSlot.java index 073cded..be6ed9a 100644 --- a/src/main/java/com/pitheguy/magicmod/util/FunctionalIntReferenceHolder.java +++ b/src/main/java/com/pitheguy/magicmod/util/FunctionalIntDataSlot.java @@ -1,16 +1,16 @@ package com.pitheguy.magicmod.util; -import net.minecraft.util.IntReferenceHolder; +import net.minecraft.world.inventory.DataSlot; import java.util.function.IntConsumer; import java.util.function.IntSupplier; -public class FunctionalIntReferenceHolder extends IntReferenceHolder { +public class FunctionalIntDataSlot extends DataSlot { private final IntSupplier getter; private final IntConsumer setter; - public FunctionalIntReferenceHolder(final IntSupplier getter, final IntConsumer setter) { + public FunctionalIntDataSlot(final IntSupplier getter, final IntConsumer setter) { this.getter = getter; this.setter = setter; } diff --git a/src/main/java/com/pitheguy/magicmod/util/ModItemHandler.java b/src/main/java/com/pitheguy/magicmod/util/ModItemHandler.java index 0083505..375d7dd 100644 --- a/src/main/java/com/pitheguy/magicmod/util/ModItemHandler.java +++ b/src/main/java/com/pitheguy/magicmod/util/ModItemHandler.java @@ -1,8 +1,8 @@ package com.pitheguy.magicmod.util; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.util.NonNullList; +import net.minecraft.core.NonNullList; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; import net.minecraftforge.items.ItemStackHandler; public class ModItemHandler extends ItemStackHandler { @@ -20,12 +20,7 @@ public void clear() { } } public boolean isEmpty() { - for (ItemStack stack : this.stacks) { - if (stack.isEmpty() || stack.getItem() == Items.AIR) { - return true; - } - } - return false; + return this.stacks.stream().anyMatch(stack -> stack.isEmpty() || stack.getItem() == Items.AIR); } public void decrStackSize(int index, int count) { diff --git a/src/main/java/com/pitheguy/magicmod/util/RegistryHandler.java b/src/main/java/com/pitheguy/magicmod/util/RegistryHandler.java index 68725c2..036aca9 100644 --- a/src/main/java/com/pitheguy/magicmod/util/RegistryHandler.java +++ b/src/main/java/com/pitheguy/magicmod/util/RegistryHandler.java @@ -6,31 +6,25 @@ import com.pitheguy.magicmod.blocks.*; import com.pitheguy.magicmod.enchantments.MagicFinderEnchantment; import com.pitheguy.magicmod.enchantments.VeinminerEnchantment; -import com.pitheguy.magicmod.init.ModEntityTypes; import com.pitheguy.magicmod.items.*; import com.pitheguy.magicmod.tools.*; -import net.minecraft.block.Block; -import net.minecraft.block.SlabBlock; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.Enchantment.Rarity; -import net.minecraft.enchantment.EnchantmentType; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.*; -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.Effects; -import net.minecraftforge.common.ToolType; -import net.minecraftforge.fml.RegistryObject; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.*; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; +import net.minecraft.world.level.block.*; +import net.minecraft.world.level.material.Material; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.*; @SuppressWarnings("unused") public class RegistryHandler { - public static final DeferredRegister ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MagicMod.MOD_ID); - public static final DeferredRegister BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MagicMod.MOD_ID); - public static final DeferredRegister ENCHANTMENTS = new DeferredRegister<>(ForgeRegistries.ENCHANTMENTS, MagicMod.MOD_ID); + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MagicMod.MOD_ID); + public static final DeferredRegister BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MagicMod.MOD_ID); + public static final DeferredRegister ENCHANTMENTS = DeferredRegister.create(ForgeRegistries.ENCHANTMENTS, MagicMod.MOD_ID); public static void init() { ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus()); @@ -49,9 +43,17 @@ public static void init() { public static final RegistryObject MAGIC_CRYSTAL = ITEMS.register("magic_crystal", ItemBase::new); public static final RegistryObject MAGIC_NUGGET = ITEMS.register("magic_nugget", ItemBase::new); public static final RegistryObject MAGIC_PEARL = ITEMS.register("magic_pearl", MagicPearl::new); - public static final RegistryObject POPULARITY_ORB = ITEMS.register("popularity_orb", PopularityOrb::new); - public static final RegistryObject MAGIC_CARROT = ITEMS.register("magic_carrot", () -> new Item(new Item.Properties().group(MagicMod.TAB).food(new Food.Builder().hunger(12).saturation(1.8F).effect(new EffectInstance(Effects.REGENERATION, 100, 2), 1).effect(new EffectInstance(Effects.RESISTANCE, 2400, 2), 1).setAlwaysEdible().build()))); + public static final RegistryObject MAGIC_CARROT = ITEMS.register("magic_carrot", () -> new Item(new Item.Properties().tab(MagicMod.TAB).food(new FoodProperties.Builder().nutrition(12).saturationMod(1.8F).effect(() -> new MobEffectInstance(MobEffects.REGENERATION, 100, 2), 1).effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 2400, 2), 1).alwaysEat().build()))); public static final RegistryObject MAGIC_SHELTER = ITEMS.register("magic_shelter", MagicShelter::new); + public static final RegistryObject MAGIC_FUEL = ITEMS.register("magic_fuel", ItemBase::new); + public static final RegistryObject MAGIC_GEAR = ITEMS.register("magic_gear", ItemBase::new); + + //Upgrades + public static final RegistryObject SPEED_UPGRADE = ITEMS.register("speed_upgrade", UpgradeItem::new); + public static final RegistryObject RANGE_UPGRADE = ITEMS.register("range_upgrade", UpgradeItem::new); + public static final RegistryObject FILTER_UPGRADE = ITEMS.register("filter_upgrade", FilterUpgradeItem::new); + public static final RegistryObject OBSIDIAN_PLATED_SPEED_UPGRADE = ITEMS.register("obsidian_plated_speed_upgrade", UpgradeItem::new); + public static final RegistryObject OBSIDIAN_PLATED_RANGE_UPGRADE = ITEMS.register("obsidian_plated_range_upgrade", UpgradeItem::new); //Magic Shears public static final RegistryObject MAGIC_SHEARS = ITEMS.register("magic_shears", MagicShears::new); @@ -79,88 +81,92 @@ public static void init() { public static final RegistryObject MAGIC_ORB_WHITE = ITEMS.register("magic_orb_white", ItemBase::new); //Spawn Eggs - public static final RegistryObject MAGIC_FRIEND_SPAWN_EGG = ITEMS.register("magic_friend_spawn_egg", () -> new ModSpawnEggItem(ModEntityTypes.MAGIC_FRIEND, 0xFF0000, 0x00FF00, new Item.Properties().group(MagicMod.TAB))); + public static final RegistryObject POPULARITY_ORB = ITEMS.register("popularity_orb", PopularityOrb::new); public static final RegistryObject FLUFF_BALL = ITEMS.register("fluff_ball", FluffBall::new); //Magic Tools public static final RegistryObject MAGIC_SWORD = ITEMS.register("magic_sword", () -> - new MagicSword(ModItemTiers.MAGIC, 70, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicSword(ModItemTiers.MAGIC, 70, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_PICKAXE = ITEMS.register("magic_pickaxe", () -> - new MagicPickaxe(ModItemTiers.MAGIC, 50, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicPickaxe(ModItemTiers.MAGIC, 50, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_AXE = ITEMS.register("magic_axe", () -> - new MagicAxe(ModItemTiers.MAGIC, 80, -1.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicAxe(ModItemTiers.MAGIC, 80, -1.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_SHOVEL = ITEMS.register("magic_shovel", () -> - new MagicShovel(ModItemTiers.MAGIC, 55, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicShovel(ModItemTiers.MAGIC, 55, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_HOE = ITEMS.register("magic_hoe", () -> - new MagicHoe(ModItemTiers.MAGIC, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicHoe(ModItemTiers.MAGIC, 50, 0.0f, new Item.Properties().tab(MagicMod.TAB), 1)); //Reinforced Magic Tools public static final RegistryObject REINFORCED_MAGIC_SWORD = ITEMS.register("reinforced_magic_sword", () -> - new MagicSword(ModItemTiers.REINFORCED_MAGIC, 200, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicSword(ModItemTiers.REINFORCED_MAGIC, 200, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_PICKAXE = ITEMS.register("reinforced_magic_pickaxe", () -> - new MagicPickaxe(ModItemTiers.REINFORCED_MAGIC, 150, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicPickaxe(ModItemTiers.REINFORCED_MAGIC, 150, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_AXE = ITEMS.register("reinforced_magic_axe", () -> - new MagicAxe(ModItemTiers.REINFORCED_MAGIC, 225, -1.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicAxe(ModItemTiers.REINFORCED_MAGIC, 225, -1.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_SHOVEL = ITEMS.register("reinforced_magic_shovel", () -> - new ReinforcedMagicShovel(ModItemTiers.REINFORCED_MAGIC, 160, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new ReinforcedMagicShovel(ModItemTiers.REINFORCED_MAGIC, 160, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_HOE = ITEMS.register("reinforced_magic_hoe", () -> - new ReinforcedMagicHoe(ModItemTiers.REINFORCED_MAGIC, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new ReinforcedMagicHoe(ModItemTiers.REINFORCED_MAGIC, 150, 0.0f, new Item.Properties().tab(MagicMod.TAB), 3)); //Obsidian Plated Reinforced Magic Tools public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_SWORD = ITEMS.register("obsidian_plated_reinforced_magic_sword", () -> - new MagicSword(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 450, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicSword(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 450, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_PICKAXE = ITEMS.register("obsidian_plated_reinforced_magic_pickaxe", () -> - new MagicPickaxe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 350, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new MagicPickaxe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 350, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_AXE = ITEMS.register("obsidian_plated_reinforced_magic_axe", () -> - new MagicAxe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 480, -0.5f, new Item.Properties().group(MagicMod.TAB))); + new ObsidianPlatedReinforcedMagicAxe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 480, -0.5f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_SHOVEL = ITEMS.register("obsidian_plated_reinforced_magic_shovel", () -> - new ObsidianPlatedReinforcedMagicShovel(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 350, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new ObsidianPlatedReinforcedMagicShovel(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 350, 0.0f, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_HOE = ITEMS.register("obsidian_plated_reinforced_magic_hoe", () -> - new ObsidianPlatedReinforcedMagicHoe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 0.0f, new Item.Properties().group(MagicMod.TAB))); + new ObsidianPlatedReinforcedMagicHoe(ModItemTiers.OBSIDIAN_PLATED_REINFORCED_MAGIC, 350, 0.0f, new Item.Properties().tab(MagicMod.TAB), 5)); //Magic Armor public static final RegistryObject MAGIC_HELMET = ITEMS.register("magic_helmet", () -> - new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlotType.HEAD, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlot.HEAD, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_CHESTPLATE = ITEMS.register("magic_chestplate", () -> - new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlotType.CHEST, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlot.CHEST, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_LEGGINGS = ITEMS.register("magic_leggings", () -> - new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlotType.LEGS, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlot.LEGS, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject MAGIC_BOOTS = ITEMS.register("magic_boots", () -> - new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlotType.FEET, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.MAGIC, EquipmentSlot.FEET, new Item.Properties().tab(MagicMod.TAB))); //Reinforced Magic Armor public static final RegistryObject REINFORCED_MAGIC_HELMET = ITEMS.register("reinforced_magic_helmet", () -> - new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlotType.HEAD, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlot.HEAD, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_CHESTPLATE = ITEMS.register("reinforced_magic_chestplate", () -> - new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlotType.CHEST, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlot.CHEST, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_LEGGINGS = ITEMS.register("reinforced_magic_leggings", () -> - new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlotType.LEGS, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlot.LEGS, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject REINFORCED_MAGIC_BOOTS = ITEMS.register("reinforced_magic_boots", () -> - new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlotType.FEET, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.REINFORCED_MAGIC, EquipmentSlot.FEET, new Item.Properties().tab(MagicMod.TAB))); //Obsidian Plated Reinforced Magic Armor public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_HELMET = ITEMS.register("obsidian_plated_reinforced_magic_helmet", () -> - new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlotType.HEAD, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlot.HEAD, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_CHESTPLATE = ITEMS.register("obsidian_plated_reinforced_magic_chestplate", () -> - new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlotType.CHEST, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlot.CHEST, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_LEGGINGS = ITEMS.register("obsidian_plated_reinforced_magic_leggings", () -> - new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlotType.LEGS, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlot.LEGS, new Item.Properties().tab(MagicMod.TAB))); public static final RegistryObject OBSIDIAN_PLATED_REINFORCED_MAGIC_BOOTS = ITEMS.register("obsidian_plated_reinforced_magic_boots", () -> - new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlotType.FEET, new Item.Properties().group(MagicMod.TAB))); + new CustomArmorMagic(ModArmorMaterials.OBSIDIAN_PLATED_REINFORCED_MAGIC, EquipmentSlot.FEET, new Item.Properties().tab(MagicMod.TAB))); //Blocks - public static final RegistryObject MAGIC_ORE = BLOCKS.register("magic_ore", () -> new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(4.0f,5.0f).sound(SoundType.STONE).harvestLevel(3).harvestTool(ToolType.PICKAXE))); - public static final RegistryObject MAGIC_OBSIDIAN = BLOCKS.register("magic_obsidian", () -> new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(110.0f,2500.0f).sound(SoundType.METAL).harvestLevel(5).harvestTool(ToolType.PICKAXE))); - public static final RegistryObject MAGIC_BLOCK = BLOCKS.register("magic_block", () -> new Block (Block.Properties.create(Material.IRON).hardnessAndResistance(6.5f, 8.0f).sound(SoundType.METAL).harvestLevel(4).harvestTool(ToolType.PICKAXE))); - public static final RegistryObject MAGIC_SLAB = BLOCKS.register("magic_slab", () -> new SlabBlock(Block.Properties.create(Material.IRON).hardnessAndResistance(6.5f,8.0f).sound(SoundType.METAL).harvestLevel(4).harvestTool(ToolType.PICKAXE))); - public static final RegistryObject MAGIC_GLUE_BLOCK = BLOCKS.register("magic_glue_block", () -> new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(4.5f, 6.5f).sound(SoundType.SLIME).harvestLevel(3).harvestTool(ToolType.PICKAXE).jumpFactor(0.0f).speedFactor(0.1f))); - public static final RegistryObject MAGIC_INFUSER = BLOCKS.register("magic_infuser", MagicInfuser::new); - public static final RegistryObject MAGIC_CRATE = BLOCKS.register("magic_crate", MagicCrate::new); - public static final RegistryObject MAGIC_PRESS = BLOCKS.register("magic_press", MagicPress::new); + public static final RegistryObject MAGIC_ORE = BLOCKS.register("magic_ore", () -> new Block(Block.Properties.of(Material.METAL).strength(4.0f,5.0f).sound(SoundType.STONE).requiresCorrectToolForDrops())); + public static final RegistryObject DEEPSLATE_MAGIC_ORE = BLOCKS.register("deepslate_magic_ore", () -> new Block(Block.Properties.of(Material.METAL).strength(8.0f,10.0f).sound(SoundType.STONE).requiresCorrectToolForDrops().lootFrom(RegistryHandler.MAGIC_ORE))); + public static final RegistryObject MAGIC_OBSIDIAN = BLOCKS.register("magic_obsidian", () -> new Block(Block.Properties.of(Material.METAL).strength(110.0f,2500.0f).sound(SoundType.METAL).requiresCorrectToolForDrops())); + public static final RegistryObject MAGIC_BLOCK = BLOCKS.register("magic_block", () -> new Block (Block.Properties.of(Material.METAL).strength(6.5f, 8.0f).sound(SoundType.METAL).requiresCorrectToolForDrops())); + public static final RegistryObject MAGIC_SLAB = BLOCKS.register("magic_slab", () -> new SlabBlock(Block.Properties.of(Material.METAL).strength(6.5f,8.0f).sound(SoundType.METAL).requiresCorrectToolForDrops())); + public static final RegistryObject MAGIC_GLUE_BLOCK = BLOCKS.register("magic_glue_block", () -> new Block(Block.Properties.of(Material.METAL).strength(4.5f, 6.5f).sound(SoundType.SLIME_BLOCK).requiresCorrectToolForDrops().jumpFactor(0.0f).speedFactor(0.1f))); public static final RegistryObject MAGIC_VEIN = BLOCKS.register("magic_vein", MagicVein::new); - public static final RegistryObject MAGIC_INFUSED_STONE = BLOCKS.register("magic_infused_stone", () -> new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 8.0f).sound(SoundType.STONE).harvestLevel(1).harvestTool(ToolType.PICKAXE))); + public static final RegistryObject MAGIC_INFUSED_STONE = BLOCKS.register("magic_infused_stone", () -> new Block(Block.Properties.of(Material.METAL).strength(2.0f, 8.0f).sound(SoundType.STONE).requiresCorrectToolForDrops())); public static final RegistryObject MAGIC_WEB = BLOCKS.register("magic_web", MagicWeb::new); public static final RegistryObject MAGIC_SPIKE = BLOCKS.register("magic_spike", MagicSpike::new); + public static final RegistryObject MAGIC_INFUSER = BLOCKS.register("magic_infuser", MagicInfuser::new); + public static final RegistryObject MAGIC_CRATE = BLOCKS.register("magic_crate", MagicCrate::new); + public static final RegistryObject MAGIC_PRESS = BLOCKS.register("magic_press", MagicPress::new); + public static final RegistryObject MAGIC_ENERGIZER = BLOCKS.register("magic_energizer", MagicEnergizer::new); + public static final RegistryObject MAGIC_MINER = BLOCKS.register("magic_miner", MagicMiner::new); + public static final RegistryObject MAGIC_LOGGER = BLOCKS.register("magic_logger", MagicLogger::new); //Magic Lamps public static final RegistryObject MAGIC_LAMP_RED = BLOCKS.register("magic_lamp_red", MagicLamp::new); @@ -176,17 +182,21 @@ public static void init() { //Block Items public static final RegistryObject MAGIC_ORE_ITEM = ITEMS.register("magic_ore", () -> new BlockItemBase(MAGIC_ORE.get())); + public static final RegistryObject DEEPSLATE_MAGIC_ORE_ITEM = ITEMS.register("deepslate_magic_ore", () -> new BlockItemBase(DEEPSLATE_MAGIC_ORE.get())); public static final RegistryObject MAGIC_OBSIDIAN_ITEM = ITEMS.register("magic_obsidian", () -> new BlockItemBase(MAGIC_OBSIDIAN.get())); public static final RegistryObject MAGIC_BLOCK_ITEM = ITEMS.register("magic_block", () -> new BlockItemBase(MAGIC_BLOCK.get())); public static final RegistryObject MAGIC_SLAB_ITEM = ITEMS.register("magic_slab", () -> new BlockItemBase(MAGIC_SLAB.get())); public static final RegistryObject MAGIC_GLUE_BLOCK_ITEM = ITEMS.register("magic_glue_block", () -> new BlockItemBase(MAGIC_GLUE_BLOCK.get())); - public static final RegistryObject MAGIC_INFUSER_ITEM = ITEMS.register("magic_infuser", () -> new BlockItemBase(MAGIC_INFUSER.get())); - public static final RegistryObject MAGIC_CRATE_ITEM = ITEMS.register("magic_crate", () -> new BlockItemBase(MAGIC_CRATE.get())); - public static final RegistryObject MAGIC_PRESS_ITEM = ITEMS.register("magic_press", () -> new BlockItemBase(MAGIC_PRESS.get())); public static final RegistryObject MAGIC_VEIN_ITEM = ITEMS.register("magic_vein", () -> new BlockItemBase(MAGIC_VEIN.get())); public static final RegistryObject MAGIC_INFUSED_STONE_ITEM = ITEMS.register("magic_infused_stone", () -> new BlockItemBase(MAGIC_INFUSED_STONE.get())); public static final RegistryObject MAGIC_WEB_ITEM = ITEMS.register("magic_web", () -> new BlockItemBase(MAGIC_WEB.get())); public static final RegistryObject MAGIC_SPIKE_ITEM = ITEMS.register("magic_spike", () -> new BlockItemBase(MAGIC_SPIKE.get())); + public static final RegistryObject MAGIC_INFUSER_ITEM = ITEMS.register("magic_infuser", () -> new BlockItemBase(MAGIC_INFUSER.get())); + public static final RegistryObject MAGIC_CRATE_ITEM = ITEMS.register("magic_crate", () -> new BlockItemBase(MAGIC_CRATE.get())); + public static final RegistryObject MAGIC_PRESS_ITEM = ITEMS.register("magic_press", () -> new BlockItemBase(MAGIC_PRESS.get())); + public static final RegistryObject MAGIC_ENERGIZER_ITEM = ITEMS.register("magic_energizer", () -> new BlockItemBase(MAGIC_ENERGIZER.get())); + public static final RegistryObject MAGIC_MINER_ITEM = ITEMS.register("magic_miner", () -> new BlockItemBase(MAGIC_MINER.get())); + public static final RegistryObject MAGIC_LOGGER_ITEM = ITEMS.register("magic_logger", () -> new BlockItemBase(MAGIC_LOGGER.get())); //Magic Lamps public static final RegistryObject MAGIC_LAMP_RED_ITEM = ITEMS.register("magic_lamp_red", () -> new BlockItemBase(MAGIC_LAMP_RED.get())); @@ -200,6 +210,6 @@ public static void init() { public static final RegistryObject MAGIC_LAMP_WHITE_ITEM = ITEMS.register("magic_lamp_white", () -> new BlockItemBase(MAGIC_LAMP_WHITE.get())); //Enchantments - public static final RegistryObject MAGIC_FINDER = ENCHANTMENTS.register("magic_finder", () -> new MagicFinderEnchantment(Rarity.VERY_RARE, EnchantmentType.create("magic_tool", item -> item instanceof MagicPickaxe || item instanceof MagicAxe || item instanceof MagicShovel), new EquipmentSlotType[]{EquipmentSlotType.MAINHAND})); - public static final RegistryObject VEINMINER = ENCHANTMENTS.register("veinminer", () -> new VeinminerEnchantment(Rarity.VERY_RARE, EnchantmentType.create("pickaxe", item -> item instanceof MagicPickaxe), new EquipmentSlotType[]{EquipmentSlotType.MAINHAND})); + public static final RegistryObject MAGIC_FINDER = ENCHANTMENTS.register("magic_finder", () -> new MagicFinderEnchantment(Enchantment.Rarity.VERY_RARE, EnchantmentCategory.create("magic_tool", item -> item instanceof MagicPickaxe || item instanceof MagicAxe || item instanceof MagicShovel), new EquipmentSlot[]{EquipmentSlot.MAINHAND})); + public static final RegistryObject VEINMINER = ENCHANTMENTS.register("veinminer", () -> new VeinminerEnchantment(Enchantment.Rarity.VERY_RARE, EnchantmentCategory.create("pickaxe", item -> item instanceof MagicPickaxe), new EquipmentSlot[]{EquipmentSlot.MAINHAND})); } \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/world/ModWorldEvents.java b/src/main/java/com/pitheguy/magicmod/world/ModWorldEvents.java new file mode 100644 index 0000000..e4cb055 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/world/ModWorldEvents.java @@ -0,0 +1,14 @@ +package com.pitheguy.magicmod.world; + +import com.pitheguy.magicmod.world.gen.oregen.ModOreGen; +import net.minecraftforge.event.world.BiomeLoadingEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; + +@Mod.EventBusSubscriber(modid = "magicmod") +public class ModWorldEvents { + @SubscribeEvent + public static void onBiomeLoad(BiomeLoadingEvent event) { + ModOreGen.generateOres(event); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/world/gen/ModOreGen.java b/src/main/java/com/pitheguy/magicmod/world/gen/ModOreGen.java deleted file mode 100644 index fa583fd..0000000 --- a/src/main/java/com/pitheguy/magicmod/world/gen/ModOreGen.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pitheguy.magicmod.world.gen; - -import com.pitheguy.magicmod.util.RegistryHandler; -import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.GenerationStage; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.OreFeatureConfig; -import net.minecraft.world.gen.placement.ConfiguredPlacement; -import net.minecraft.world.gen.placement.CountRangeConfig; -import net.minecraft.world.gen.placement.Placement; -import net.minecraftforge.registries.ForgeRegistries; - -public class ModOreGen { - public static void generateOre() { - for (Biome biome : ForgeRegistries.BIOMES) { - ConfiguredPlacement customConfig = Placement.COUNT_RANGE.configure(new CountRangeConfig(2,4,4,12)); - biome.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, RegistryHandler.MAGIC_ORE.get().getDefaultState(), 4)).withPlacement(customConfig)); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModConfiguredFeatures.java b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModConfiguredFeatures.java new file mode 100644 index 0000000..5994465 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModConfiguredFeatures.java @@ -0,0 +1,20 @@ +package com.pitheguy.magicmod.world.gen.oregen; + +import com.pitheguy.magicmod.util.RegistryHandler; +import net.minecraft.core.Holder; +import net.minecraft.data.worldgen.features.FeatureUtils; +import net.minecraft.data.worldgen.features.OreFeatures; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import net.minecraft.world.level.levelgen.feature.Feature; +import net.minecraft.world.level.levelgen.feature.configurations.OreConfiguration; + +import java.util.List; + +public class ModConfiguredFeatures { + public static final List OVERWORLD_MAGIC_ORES = List.of( + OreConfiguration.target(OreFeatures.STONE_ORE_REPLACEABLES, RegistryHandler.MAGIC_ORE.get().defaultBlockState()), + OreConfiguration.target(OreFeatures.DEEPSLATE_ORE_REPLACEABLES, RegistryHandler.DEEPSLATE_MAGIC_ORE.get().defaultBlockState())); + + public static final Holder> MAGIC_ORE = FeatureUtils.register("magic_ore", + Feature.ORE, new OreConfiguration(OVERWORLD_MAGIC_ORES, 4)); +} diff --git a/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOreGen.java b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOreGen.java new file mode 100644 index 0000000..8211401 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOreGen.java @@ -0,0 +1,18 @@ +package com.pitheguy.magicmod.world.gen.oregen; + +import net.minecraft.core.Holder; +import net.minecraft.world.level.biome.Biome.BiomeCategory; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; +import net.minecraftforge.event.world.BiomeLoadingEvent; + +import java.util.List; + +public class ModOreGen { + public static void generateOres(final BiomeLoadingEvent event) { + if (event.getCategory() != BiomeCategory.THEEND && event.getCategory() != BiomeCategory.NETHER) { + List> base = event.getGeneration().getFeatures(GenerationStep.Decoration.UNDERGROUND_ORES); + base.add(ModPlacedFeatures.MAGIC_ORE_PLACED); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOrePlacement.java b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOrePlacement.java new file mode 100644 index 0000000..91dbd61 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModOrePlacement.java @@ -0,0 +1,19 @@ +package com.pitheguy.magicmod.world.gen.oregen; + +import net.minecraft.world.level.levelgen.placement.*; + +import java.util.List; + +public class ModOrePlacement { + public static List orePlacement(PlacementModifier p_195347_, PlacementModifier p_195348_) { + return List.of(p_195347_, InSquarePlacement.spread(), p_195348_, BiomeFilter.biome()); + } + + public static List commonOrePlacement(int p_195344_, PlacementModifier p_195345_) { + return orePlacement(CountPlacement.of(p_195344_), p_195345_); + } + + public static List rareOrePlacement(int p_195350_, PlacementModifier p_195351_) { + return orePlacement(RarityFilter.onAverageOnceEvery(p_195350_), p_195351_); + } +} diff --git a/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModPlacedFeatures.java b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModPlacedFeatures.java new file mode 100644 index 0000000..a948e47 --- /dev/null +++ b/src/main/java/com/pitheguy/magicmod/world/gen/oregen/ModPlacedFeatures.java @@ -0,0 +1,13 @@ +package com.pitheguy.magicmod.world.gen.oregen; + +import net.minecraft.core.Holder; +import net.minecraft.data.worldgen.placement.PlacementUtils; +import net.minecraft.world.level.levelgen.VerticalAnchor; +import net.minecraft.world.level.levelgen.placement.HeightRangePlacement; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; + +public class ModPlacedFeatures { + public static final Holder MAGIC_ORE_PLACED = PlacementUtils.register("magic_ore_placed", + ModConfiguredFeatures.MAGIC_ORE, ModOrePlacement.commonOrePlacement(4, // VeinsPerChunk + HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-32), VerticalAnchor.aboveBottom(32)))); +} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index cf32b4b..bc55aff 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -4,6 +4,8 @@ # 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 + +license="GNU GPL v3" modLoader="javafml" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version loaderVersion="[31,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. @@ -12,7 +14,7 @@ loaderVersion="[31,)" #mandatory This is typically bumped every Minecraft versio # The modid of the mod modId="magicmod" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -version="1.15.2-2.0" #mandatory +version="1.16.5-2.10" #mandatory # A display name for the mod displayName="Magic Mod" #mandatory # A file name (in the root of the mod JAR) containing a logo for display diff --git a/src/main/resources/assets/magicmod/blockstates/deepslate_magic_ore.json b/src/main/resources/assets/magicmod/blockstates/deepslate_magic_ore.json new file mode 100644 index 0000000..9bb73f3 --- /dev/null +++ b/src/main/resources/assets/magicmod/blockstates/deepslate_magic_ore.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "magicmod:block/deepslate_magic_ore" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/blockstates/magic_energizer.json b/src/main/resources/assets/magicmod/blockstates/magic_energizer.json new file mode 100644 index 0000000..c9884d3 --- /dev/null +++ b/src/main/resources/assets/magicmod/blockstates/magic_energizer.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "magicmod:block/magic_energizer" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/blockstates/magic_logger.json b/src/main/resources/assets/magicmod/blockstates/magic_logger.json new file mode 100644 index 0000000..d2a66f3 --- /dev/null +++ b/src/main/resources/assets/magicmod/blockstates/magic_logger.json @@ -0,0 +1,5 @@ +{ + "variants": { + "": { "model": "magicmod:block/magic_logger" } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/blockstates/magic_miner.json b/src/main/resources/assets/magicmod/blockstates/magic_miner.json new file mode 100644 index 0000000..5ca6d7d --- /dev/null +++ b/src/main/resources/assets/magicmod/blockstates/magic_miner.json @@ -0,0 +1,10 @@ +{ + "variants": { + "running=false": { + "model": "magicmod:block/magic_miner" + }, + "running=true": { + "model": "magicmod:block/magic_miner_running" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/lang/en_us.json b/src/main/resources/assets/magicmod/lang/en_us.json index c4056a8..8a7ed50 100644 --- a/src/main/resources/assets/magicmod/lang/en_us.json +++ b/src/main/resources/assets/magicmod/lang/en_us.json @@ -29,7 +29,13 @@ "item.magicmod.magic_carrot": "Magic Carrot", "item.magicmod.nether_shard": "Nether Shard", "item.magicmod.popularity_orb": "Orb of Popularity", + "item.magicmod.magic_fuel": "Magic Fuel", "item.magicmod.magic_shelter": "Magic Shelter", + "item.magicmod.magic_gear": "Magic Gear", + "item.magicmod.speed_upgrade": "Speed Upgrade", + "item.magicmod.filter_upgrade": "Filter Upgrade", + "item.magicmod.obsidian_plated_speed_upgrade": "Obsidian Plated Speed Upgrade", + "item.magicmod.obsidian_plated_range_upgrade": "Obsidian Plated Range Upgrade", "item.magicmod.magic_shears": "Magic Shears", "item.magicmod.magic_sword": "Magic Sword", "item.magicmod.magic_axe": "Magic Axe", @@ -62,6 +68,7 @@ "item.magicmod.fluff_ball": "Ball of Fluff", "itemGroup.magicTab": "Magic Mod", "block.magicmod.magic_ore": "Magic Ore", + "block.magicmod.deepslate_magic_ore": "Deepslate Magic Ore", "block.magicmod.magic_block": "Magic Block", "block.magicmod.magic_obsidian": "Magic Obsidian", "block.magicmod.magic_slab": "Magic Slab", @@ -69,6 +76,9 @@ "block.magicmod.magic_infuser": "Magic Infuser", "block.magicmod.magic_crate": "Magic Crate", "block.magicmod.magic_press": "Magic Press", + "block.magicmod.magic_energizer": "Magic Energizer", + "block.magicmod.magic_miner": "Magic Miner", + "block.magicmod.magic_logger": "Magic Logger", "block.magicmod.magic_vein": "Magic Vein", "block.magicmod.magic_infused_stone": "Magic Infused Stone", "block.magicmod.magic_lamp_red": "Magic Lamp (Red)", @@ -85,6 +95,9 @@ "container.magicmod.magic_infuser": "Magic Infuser", "container.magicmod.magic_crate": "Magic Crate", "container.magicmod.magic_press": "Magic Press", + "container.magicmod.magic_energizer": "Magic Energizer", + "container.magicmod.magic_logger": "Magic Logger", + "container.magicmod.magic_miner": "Magic Miner", "entity.magicmod.magic_friend": "Magic Friend", "entity.magicmod.fluffy_magician": "Fluffy Magician", "entity.magicmod.fluffy_magician_bare": "Fluffy Magician", diff --git a/src/main/resources/assets/magicmod/models/block/deepslate_magic_ore.json b/src/main/resources/assets/magicmod/models/block/deepslate_magic_ore.json new file mode 100644 index 0000000..4743e0e --- /dev/null +++ b/src/main/resources/assets/magicmod/models/block/deepslate_magic_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "magicmod:blocks/deepslate_magic_ore" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/block/magic_energizer.json b/src/main/resources/assets/magicmod/models/block/magic_energizer.json new file mode 100644 index 0000000..a4c76fc --- /dev/null +++ b/src/main/resources/assets/magicmod/models/block/magic_energizer.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "magicmod:blocks/magic_energizer" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/block/magic_logger.json b/src/main/resources/assets/magicmod/models/block/magic_logger.json new file mode 100644 index 0000000..7ca9d7f --- /dev/null +++ b/src/main/resources/assets/magicmod/models/block/magic_logger.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "magicmod:blocks/magic_logger" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/block/magic_miner.json b/src/main/resources/assets/magicmod/models/block/magic_miner.json new file mode 100644 index 0000000..4cc0066 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/block/magic_miner.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "magicmod:blocks/magic_miner" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/block/magic_miner_running.json b/src/main/resources/assets/magicmod/models/block/magic_miner_running.json new file mode 100644 index 0000000..0963217 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/block/magic_miner_running.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "magicmod:blocks/magic_miner_running" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/deepslate_magic_ore.json b/src/main/resources/assets/magicmod/models/item/deepslate_magic_ore.json new file mode 100644 index 0000000..6d589d3 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/deepslate_magic_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "magicmod:block/deepslate_magic_ore" +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/filter_upgrade.json b/src/main/resources/assets/magicmod/models/item/filter_upgrade.json new file mode 100644 index 0000000..f32ecbf --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/filter_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/filter_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/magic_energizer.json b/src/main/resources/assets/magicmod/models/item/magic_energizer.json new file mode 100644 index 0000000..2ba8e23 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/magic_energizer.json @@ -0,0 +1,3 @@ +{ + "parent": "magicmod:block/magic_energizer" +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/magic_fuel.json b/src/main/resources/assets/magicmod/models/item/magic_fuel.json new file mode 100644 index 0000000..7351b19 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/magic_fuel.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/magic_fuel" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/magic_gear.json b/src/main/resources/assets/magicmod/models/item/magic_gear.json new file mode 100644 index 0000000..c6ac989 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/magic_gear.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/magic_gear" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/magic_logger.json b/src/main/resources/assets/magicmod/models/item/magic_logger.json new file mode 100644 index 0000000..2f09ac8 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/magic_logger.json @@ -0,0 +1,3 @@ +{ + "parent": "magicmod:block/magic_logger" +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/magic_miner.json b/src/main/resources/assets/magicmod/models/item/magic_miner.json new file mode 100644 index 0000000..d228316 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/magic_miner.json @@ -0,0 +1,3 @@ +{ + "parent": "magicmod:block/magic_miner" +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/obsidian_plated_range_upgrade.json b/src/main/resources/assets/magicmod/models/item/obsidian_plated_range_upgrade.json new file mode 100644 index 0000000..0cbeffb --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/obsidian_plated_range_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/obsidian_plated_range_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/obsidian_plated_speed_upgrade.json b/src/main/resources/assets/magicmod/models/item/obsidian_plated_speed_upgrade.json new file mode 100644 index 0000000..6a13983 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/obsidian_plated_speed_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/obsidian_plated_speed_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/range_upgrade.json b/src/main/resources/assets/magicmod/models/item/range_upgrade.json new file mode 100644 index 0000000..460ea38 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/range_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/range_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/models/item/speed_upgrade.json b/src/main/resources/assets/magicmod/models/item/speed_upgrade.json new file mode 100644 index 0000000..f41d372 --- /dev/null +++ b/src/main/resources/assets/magicmod/models/item/speed_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/handheld", + "textures": { + "layer0": "magicmod:items/speed_upgrade" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/magicmod/textures/blocks/deepslate_magic_ore.png b/src/main/resources/assets/magicmod/textures/blocks/deepslate_magic_ore.png new file mode 100644 index 0000000..1e9e20c Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/blocks/deepslate_magic_ore.png differ diff --git a/src/main/resources/assets/magicmod/textures/blocks/magic_energizer.png b/src/main/resources/assets/magicmod/textures/blocks/magic_energizer.png new file mode 100644 index 0000000..6ea742f Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/blocks/magic_energizer.png differ diff --git a/src/main/resources/assets/magicmod/textures/blocks/magic_logger.png b/src/main/resources/assets/magicmod/textures/blocks/magic_logger.png new file mode 100644 index 0000000..85b8914 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/blocks/magic_logger.png differ diff --git a/src/main/resources/assets/magicmod/textures/blocks/magic_miner.png b/src/main/resources/assets/magicmod/textures/blocks/magic_miner.png new file mode 100644 index 0000000..9139754 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/blocks/magic_miner.png differ diff --git a/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png b/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png new file mode 100644 index 0000000..b7e8e4e Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png differ diff --git a/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png.mcmeta b/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png.mcmeta new file mode 100644 index 0000000..1cc12dc --- /dev/null +++ b/src/main/resources/assets/magicmod/textures/blocks/magic_miner_running.png.mcmeta @@ -0,0 +1,6 @@ +{ + "animation": { + "interpolate": true, + "frametime": 3 + } +} diff --git a/src/main/resources/assets/magicmod/textures/gui/magic_energizer.png b/src/main/resources/assets/magicmod/textures/gui/magic_energizer.png new file mode 100644 index 0000000..d42ea8d Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/gui/magic_energizer.png differ diff --git a/src/main/resources/assets/magicmod/textures/gui/magic_miner.png b/src/main/resources/assets/magicmod/textures/gui/magic_miner.png new file mode 100644 index 0000000..297cba5 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/gui/magic_miner.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/filter_upgrade.png b/src/main/resources/assets/magicmod/textures/items/filter_upgrade.png new file mode 100644 index 0000000..026b462 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/filter_upgrade.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/magic_fuel.png b/src/main/resources/assets/magicmod/textures/items/magic_fuel.png new file mode 100644 index 0000000..a9a7a4e Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/magic_fuel.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/magic_gear.png b/src/main/resources/assets/magicmod/textures/items/magic_gear.png new file mode 100644 index 0000000..bc8da5e Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/magic_gear.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/obsidian_plated_range_upgrade.png b/src/main/resources/assets/magicmod/textures/items/obsidian_plated_range_upgrade.png new file mode 100644 index 0000000..0215ab0 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/obsidian_plated_range_upgrade.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/obsidian_plated_speed_upgrade.png b/src/main/resources/assets/magicmod/textures/items/obsidian_plated_speed_upgrade.png new file mode 100644 index 0000000..3386ace Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/obsidian_plated_speed_upgrade.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/range_upgrade.png b/src/main/resources/assets/magicmod/textures/items/range_upgrade.png new file mode 100644 index 0000000..e8ec211 Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/range_upgrade.png differ diff --git a/src/main/resources/assets/magicmod/textures/items/speed_upgrade.png b/src/main/resources/assets/magicmod/textures/items/speed_upgrade.png new file mode 100644 index 0000000..6cb6ccb Binary files /dev/null and b/src/main/resources/assets/magicmod/textures/items/speed_upgrade.png differ diff --git a/src/main/resources/data/forge/tags/blocks/needs_diamond_tool.json b/src/main/resources/data/forge/tags/blocks/needs_diamond_tool.json new file mode 100644 index 0000000..968e527 --- /dev/null +++ b/src/main/resources/data/forge/tags/blocks/needs_diamond_tool.json @@ -0,0 +1,12 @@ +{ + "replace": false, + "values": [ + "magicmod:magic_block", + "magicmod:magic_slab", + "magicmod:magic_infuser", + "magicmod:magic_ore", + "magicmod:deepslate_magic_ore", + "magicmod:magic_press", + "magicmod:magic_energizer" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/forge/tags/blocks/needs_iron_tool.json b/src/main/resources/data/forge/tags/blocks/needs_iron_tool.json new file mode 100644 index 0000000..90a9913 --- /dev/null +++ b/src/main/resources/data/forge/tags/blocks/needs_iron_tool.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "magicmod:magic_glue_block" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/forge/tags/blocks/needs_stone_tool.json b/src/main/resources/data/forge/tags/blocks/needs_stone_tool.json new file mode 100644 index 0000000..dd3b2fc --- /dev/null +++ b/src/main/resources/data/forge/tags/blocks/needs_stone_tool.json @@ -0,0 +1,10 @@ +{ + "replace": false, + "values": [ + "magicmod:magic_crate", + "magicmod:magic_infused_stone", + "magicmod:magic_logger", + "magicmod:magic_miner", + "magicmod:magic_vein" + ] +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/advancements/collect_all_dust.json b/src/main/resources/data/magicmod/advancements/collect_all_dust.json index 3dcba93..2294c80 100644 --- a/src/main/resources/data/magicmod/advancements/collect_all_dust.json +++ b/src/main/resources/data/magicmod/advancements/collect_all_dust.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_red" + "items": [ + "magicmod:magic_dust_red" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_orange" + "items": [ + "magicmod:magic_dust_orange" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_yellow" + "items": [ + "magicmod:magic_dust_yellow" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_green" + "items": [ + "magicmod:magic_dust_green" + ] } ] } @@ -57,7 +65,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_blue" + "items": [ + "magicmod:magic_dust_blue" + ] } ] } @@ -67,7 +77,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_purple" + "items": [ + "magicmod:magic_dust_purple" + ] } ] } @@ -77,7 +89,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_magenta" + "items": [ + "magicmod:magic_dust_magenta" + ] } ] } @@ -87,7 +101,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_black" + "items": [ + "magicmod:magic_dust_black" + ] } ] } @@ -97,7 +113,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_white" + "item": [ + "magicmod:magic_dust_white" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_armor.json b/src/main/resources/data/magicmod/advancements/craft_magic_armor.json index 91b9d84..4209342 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_armor.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_armor.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_helmet" + "items": [ + "magicmod:magic_helmet" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_chestplate" + "items": [ + "magicmod:magic_chestplate" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_leggings" + "items": [ + "magicmod:magic_leggings" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_boots" + "items": [ + "magicmod:magic_boots" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_armor_set.json b/src/main/resources/data/magicmod/advancements/craft_magic_armor_set.json index 9b99b62..4edc7af 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_armor_set.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_armor_set.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_helmet" + "items": [ + "magicmod:magic_helmet" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_chestplate" + "items": [ + "magicmod:magic_chestplate" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_leggings" + "items": [ + "magicmod:magic_leggings" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_boots" + "items": [ + "magicmod:magic_boots" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_core.json b/src/main/resources/data/magicmod/advancements/craft_magic_core.json index c8b75cc..f236751 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_core.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_core.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_core" + "items": [ + "magicmod:magic_core" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_gem.json b/src/main/resources/data/magicmod/advancements/craft_magic_gem.json index 0f70ee3..4237392 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_gem.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_gem.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_gem" + "items": [ + "magicmod:magic_gem" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_infuser.json b/src/main/resources/data/magicmod/advancements/craft_magic_infuser.json index 949a49a..8e20915 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_infuser.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_infuser.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_infuser" + "items": [ + "magicmod:magic_infuser" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_plate.json b/src/main/resources/data/magicmod/advancements/craft_magic_plate.json index c790a53..f80232b 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_plate.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_plate.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_plate" + "items": [ + "magicmod:magic_plate" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/craft_magic_sword.json b/src/main/resources/data/magicmod/advancements/craft_magic_sword.json index 90103ea..d0068a7 100644 --- a/src/main/resources/data/magicmod/advancements/craft_magic_sword.json +++ b/src/main/resources/data/magicmod/advancements/craft_magic_sword.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_sword" + "items": [ + "magicmod:magic_sword" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/recipes/magic_action_blocks.json b/src/main/resources/data/magicmod/advancements/recipes/magic_action_blocks.json new file mode 100644 index 0000000..a03f707 --- /dev/null +++ b/src/main/resources/data/magicmod/advancements/recipes/magic_action_blocks.json @@ -0,0 +1,27 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "magicmod:magic_miner", + "magicmod:magic_logger", + "magicmod:magic_energizer" + ] + }, + "criteria": { + "has_magic_gear": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "magicmod:magic_gear" + } + ] + } + } + }, + "requirements": [ + [ + "has_magic_gear" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/advancements/recipes/magic_fuel.json b/src/main/resources/data/magicmod/advancements/recipes/magic_fuel.json new file mode 100644 index 0000000..d3fefcc --- /dev/null +++ b/src/main/resources/data/magicmod/advancements/recipes/magic_fuel.json @@ -0,0 +1,25 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "magicmod:magic_fuel" + ] + }, + "criteria": { + "has_magic_nugget": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "magicmod:magic_nugget" + } + ] + } + } + }, + "requirements": [ + [ + "has_magic_nugget" + ] + ] +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/advancements/reinforce_magic_armor.json b/src/main/resources/data/magicmod/advancements/reinforce_magic_armor.json index 05a4c62..ed7b777 100644 --- a/src/main/resources/data/magicmod/advancements/reinforce_magic_armor.json +++ b/src/main/resources/data/magicmod/advancements/reinforce_magic_armor.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_helmet" + "items": [ + "magicmod:reinforced_magic_helmet" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_chestplate" + "items": [ + "magicmod:reinforced_magic_chestplate" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_leggings" + "items": [ + "magicmod:reinforced_magic_leggings" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_boots" + "items": [ + "magicmod:reinforced_magic_boots" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/reinforce_magic_armor_set.json b/src/main/resources/data/magicmod/advancements/reinforce_magic_armor_set.json index 9664863..2cbbac1 100644 --- a/src/main/resources/data/magicmod/advancements/reinforce_magic_armor_set.json +++ b/src/main/resources/data/magicmod/advancements/reinforce_magic_armor_set.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_helmet" + "items": [ + "magicmod:reinforced_magic_helmet" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_chestplate" + "items": [ + "magicmod:reinforced_magic_chestplate" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_leggings" + "items": [ + "magicmod:reinforced_magic_leggings" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_boots" + "items": [ + "magicmod:reinforced_magic_boots" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/reinforce_magic_sword.json b/src/main/resources/data/magicmod/advancements/reinforce_magic_sword.json index 0face78..69123cb 100644 --- a/src/main/resources/data/magicmod/advancements/reinforce_magic_sword.json +++ b/src/main/resources/data/magicmod/advancements/reinforce_magic_sword.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:reinforced_magic_sword" + "items": [ + "magicmod:reinforced_magic_sword" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/root.json b/src/main/resources/data/magicmod/advancements/root.json index 29b1d94..8ca1b59 100644 --- a/src/main/resources/data/magicmod/advancements/root.json +++ b/src/main/resources/data/magicmod/advancements/root.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_red" + "items": [ + "magicmod:magic_dust_red" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_orange" + "items": [ + "magicmod:magic_dust_orange" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_yellow" + "items": [ + "magicmod:magic_dust_yellow" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_green" + "items": [ + "magicmod:magic_dust_green" + ] } ] } @@ -57,7 +65,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_blue" + "items": [ + "magicmod:magic_dust_blue" + ] } ] } @@ -67,7 +77,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_purple" + "items": [ + "magicmod:magic_dust_purple" + ] } ] } @@ -77,7 +89,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_magenta" + "items": [ + "magicmod:magic_dust_magenta" + ] } ] } @@ -87,7 +101,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_black" + "items": [ + "magicmod:magic_dust_black" + ] } ] } @@ -97,7 +113,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_dust_white" + "items": [ + "magicmod:magic_dust_white" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/smelt_all_dust.json b/src/main/resources/data/magicmod/advancements/smelt_all_dust.json index 2531a17..076adf6 100644 --- a/src/main/resources/data/magicmod/advancements/smelt_all_dust.json +++ b/src/main/resources/data/magicmod/advancements/smelt_all_dust.json @@ -22,7 +22,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_red" + "items": [ + "magicmod:magic_orb_red" + ] } ] } @@ -32,7 +34,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_orange" + "items": [ + "magicmod:magic_orb_orange" + ] } ] } @@ -42,7 +46,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_yellow" + "items": [ + "magicmod:magic_orb_yellow" + ] } ] } @@ -52,7 +58,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_green" + "items": [ + "magicmod:magic_orb_green" + ] } ] } @@ -62,7 +70,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_blue" + "items": [ + "magicmod:magic_orb_blue" + ] } ] } @@ -72,7 +82,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_purple" + "items": [ + "magicmod:magic_orb_purple" + ] } ] } @@ -82,7 +94,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_magenta" + "items": [ + "magicmod:magic_orb_magenta" + ] } ] } @@ -92,7 +106,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_black" + "items": [ + "magicmod:magic_orb_black" + ] } ] } @@ -102,7 +118,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_white" + "item": [ + "magicmod:magic_orb_white" + ] } ] } diff --git a/src/main/resources/data/magicmod/advancements/smelt_dust.json b/src/main/resources/data/magicmod/advancements/smelt_dust.json index 4616158..0a6bd56 100644 --- a/src/main/resources/data/magicmod/advancements/smelt_dust.json +++ b/src/main/resources/data/magicmod/advancements/smelt_dust.json @@ -17,7 +17,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_red" + "items": [ + "magicmod:magic_orb_red" + ] } ] } @@ -27,7 +29,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_orange" + "items": [ + "magicmod:magic_orb_orange" + ] } ] } @@ -37,7 +41,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_yellow" + "items": [ + "magicmod:magic_orb_yellow" + ] } ] } @@ -47,7 +53,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_green" + "items": [ + "magicmod:magic_orb_green" + ] } ] } @@ -57,7 +65,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_blue" + "items": [ + "magicmod:magic_orb_blue" + ] } ] } @@ -67,7 +77,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_purple" + "items": [ + "magicmod:magic_orb_purple" + ] } ] } @@ -77,7 +89,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_magenta" + "items": [ + "magicmod:magic_orb_magenta" + ] } ] } @@ -87,7 +101,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_black" + "items": [ + "magicmod:magic_orb_black" + ] } ] } @@ -97,7 +113,9 @@ "conditions": { "items": [ { - "item": "magicmod:magic_orb_white" + "item": [ + "magicmod:magic_orb_white" + ] } ] } diff --git a/src/main/resources/data/magicmod/loot_tables/blocks/magic_logger.json b/src/main/resources/data/magicmod/loot_tables/blocks/magic_logger.json new file mode 100644 index 0000000..1949ae3 --- /dev/null +++ b/src/main/resources/data/magicmod/loot_tables/blocks/magic_logger.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "magicmod:magic_logger" + } + ] + } + ] +} diff --git a/src/main/resources/data/magicmod/loot_tables/blocks/magic_miner.json b/src/main/resources/data/magicmod/loot_tables/blocks/magic_miner.json new file mode 100644 index 0000000..b682e2a --- /dev/null +++ b/src/main/resources/data/magicmod/loot_tables/blocks/magic_miner.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "magicmod:magic_miner" + } + ] + } + ] +} diff --git a/src/main/resources/data/magicmod/loot_tables/chests/magic_shelter_chest.json b/src/main/resources/data/magicmod/loot_tables/chests/magic_shelter_chest.json index e1f7b7e..acde0d7 100644 --- a/src/main/resources/data/magicmod/loot_tables/chests/magic_shelter_chest.json +++ b/src/main/resources/data/magicmod/loot_tables/chests/magic_shelter_chest.json @@ -9,7 +9,7 @@ "entries": [ { "type": "minecraft:item", - "weight": 2, + "weight": 4, "name": "magicmod:magic_powder", "functions": [ { @@ -23,7 +23,7 @@ }, { "type": "minecraft:item", - "weight": 2, + "weight": 4, "name": "magicmod:magic_crystal", "functions": [ { @@ -37,7 +37,7 @@ }, { "type": "minecraft:item", - "weight": 1, + "weight": 2, "name": "magicmod:magic_nugget", "functions": [ { @@ -51,7 +51,7 @@ }, { "type": "minecraft:item", - "weight": 1, + "weight": 2, "name": "magicmod:magic_core", "functions": [ { @@ -67,6 +67,20 @@ "type": "minecraft:item", "weight": 1, "name": "magicmod:magic_gem" + }, + { + "type": "minecraft:item", + "weight": 3, + "name": "magicmod:magic_gear", + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 2, + "max": 3 + } + } + ] } ] }, diff --git a/src/main/resources/data/magicmod/recipes/magic_energizer.json b/src/main/resources/data/magicmod/recipes/magic_energizer.json new file mode 100644 index 0000000..4688926 --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/magic_energizer.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + " G ", + "GFG", + " G " + ], + + "key": + { + "G": + { + "item": "magicmod:magic_gear" + }, + "F": + { + "item": "magicmod:magic_fuel" + } + }, + + "result": + { + "item": "magicmod:magic_energizer", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/recipes/magic_fuel.json b/src/main/resources/data/magicmod/recipes/magic_fuel.json new file mode 100644 index 0000000..e68eb0d --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/magic_fuel.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + "NCN", + "C C", + "NCN" + ], + + "key": + { + "N": + { + "item": "magicmod:magic_nugget" + }, + "C": + { + "item": "minecraft:coal" + } + }, + + "result": + { + "item": "magicmod:magic_fuel", + "count": 16 + } +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/recipes/magic_logger.json b/src/main/resources/data/magicmod/recipes/magic_logger.json new file mode 100644 index 0000000..98cb988 --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/magic_logger.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + " G ", + "GAG", + " G " + ], + + "key": + { + "G": + { + "item": "magicmod:magic_gear" + }, + "A": + { + "item": "magicmod:magic_axe" + } + }, + + "result": + { + "item": "magicmod:magic_logger", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/recipes/magic_miner.json b/src/main/resources/data/magicmod/recipes/magic_miner.json new file mode 100644 index 0000000..fdfbcbf --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/magic_miner.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + " G ", + "GPG", + " G " + ], + + "key": + { + "G": + { + "item": "magicmod:magic_gear" + }, + "P": + { + "item": "magicmod:magic_pickaxe" + } + }, + + "result": + { + "item": "magicmod:magic_miner", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/recipes/obsidian_plated_range_upgrade.json b/src/main/resources/data/magicmod/recipes/obsidian_plated_range_upgrade.json new file mode 100644 index 0000000..2586756 --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/obsidian_plated_range_upgrade.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + "PPP", + "PRP", + "PPP" + ], + + "key": + { + "P": + { + "item": "magicmod:obsidian_plate" + }, + "R": + { + "item": "magicmod:range_upgrade" + } + }, + + "result": + { + "item": "magicmod:obsidian_plated_range_upgrade", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/magicmod/recipes/obsidian_plated_speed_upgrade.json b/src/main/resources/data/magicmod/recipes/obsidian_plated_speed_upgrade.json new file mode 100644 index 0000000..ef311d8 --- /dev/null +++ b/src/main/resources/data/magicmod/recipes/obsidian_plated_speed_upgrade.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + + "pattern": + [ + "PPP", + "PSP", + "PPP" + ], + + "key": + { + "P": + { + "item": "magicmod:obsidian_plate" + }, + "S": + { + "item": "magicmod:speed_upgrade" + } + }, + + "result": + { + "item": "magicmod:obsidian_plated_speed_upgrade", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json new file mode 100644 index 0000000..36a79ae --- /dev/null +++ b/src/main/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -0,0 +1,20 @@ +{ + "replace": false, + "values": [ + "magicmod:magic_ore", + "magicmod:deepslate_magic_ore", + "magicmod:magic_obsidian", + "magicmod:magic_block", + "magicmod:magic_slab", + "magicmod:magic_glue_block", + "magicmod:magic_vein", + "magicmod:magic_spike", + "magicmod:magic_infuser", + "magicmod:magic_crate", + "magicmod:magic_press", + "magicmod:magic_energizer", + "magicmod:magic_miner", + "magicmod:magic_logger" + ] + +} \ No newline at end of file