diff --git a/CHANGELOG.md b/CHANGELOG.md index 1774d71d..05c3ac79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,69 +1,129 @@ # Mining Gadgets Changelog + The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +## 1.16.5 + +### [1.7.5] - 2021-04-17 + +## Added + +- All new and amazing textures for the gadgets, modification table, and upgrades courtesy of the one and + only [Ridanisaurus Rid](https://github.com/Ridanisaurus) +- All new laser gadgets models! They're all amazing and yes, *they're* you now have 3 amazing lasers to pick from! +- A new and fancy Modification table + - You can hold shift whilst looking at the table to see what upgrades are on a gadget! It's super nice + - We've also added a super fancy render of the laser on the outside of the block. You'll see what I'm talking + about... + +### Changed + +- Changed the strength of the `render block` to stop players being able to hit the block and void its + drops. [#130](https://github.com/Direwolf20-MC/MiningGadgets/issues/130) +- Modified the gadgets recipes slightly to allow for multiple lasers. + +### Fixed + +- Added blocking area on JEI to stop the modification gadgets slot overlapping a deletion area when in cheat + mode. [#142](https://github.com/Direwolf20-MC/MiningGadgets/issues/142) +- Fixed a checking error allowing the freezing mode to replace waterlogged blocks... We now remove its water logged + state as long as it's not a tile entity. [#139](https://github.com/Direwolf20-MC/MiningGadgets/issues/139) +- Fixed an issue where you could delete upgrades if you attempted to place a different tier of an upgrade into the + modification table. [#137](https://github.com/Direwolf20-MC/MiningGadgets/issues/137) + ## 1.16.4 + ### [1.7.1] - 2020-11-23 #### Changed -- Removed Paver upgrade as it was half done, it'll be re-added later on [#119](https://github.com/Direwolf20-MC/MiningGadgets/issues/119) + +- Removed Paver upgrade as it was half done, it'll be re-added later + on [#119](https://github.com/Direwolf20-MC/MiningGadgets/issues/119) #### Fixed -- Fixed crashing when another mod blocks our render block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) -- Added bypass to right click event to allow mining redstone when close [#114](https://github.com/Direwolf20-MC/MiningGadgets/issues/114) -- Fixed a client crashing when scrolling on an un-upgraded gadgets settings screen [#113](https://github.com/Direwolf20-MC/MiningGadgets/issues/113) -- Fixed a compatibility issue with IE when right clicking to charge the gadget [#105](https://github.com/Direwolf20-MC/MiningGadgets/issues/105) -- Finally fixed the issue with 'invalid key' on custom button binds [#108](https://github.com/Direwolf20-MC/MiningGadgets/issues/108) [#101](https://github.com/Direwolf20-MC/MiningGadgets/issues/101) -- Fixed a lot of issues related to the filter screen voiding blocks, messing with sorter mods and more. [#123](https://github.com/Direwolf20-MC/MiningGadgets/issues/123) + +- Fixed crashing when another mod blocks our render + block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) +- Added bypass to right click event to allow mining redstone when + close [#114](https://github.com/Direwolf20-MC/MiningGadgets/issues/114) +- Fixed a client crashing when scrolling on an un-upgraded gadgets settings + screen [#113](https://github.com/Direwolf20-MC/MiningGadgets/issues/113) +- Fixed a compatibility issue with IE when right clicking to charge the + gadget [#105](https://github.com/Direwolf20-MC/MiningGadgets/issues/105) +- Finally fixed the issue with 'invalid key' on custom button + binds [#108](https://github.com/Direwolf20-MC/MiningGadgets/issues/108) [#101](https://github.com/Direwolf20-MC/MiningGadgets/issues/101) +- Fixed a lot of issues related to the filter screen voiding blocks, messing with sorter mods and + more. [#123](https://github.com/Direwolf20-MC/MiningGadgets/issues/123) ## [1.7.0] - 2020-11-14 + - Updated to 1.6.4 ## 1.16.3 + ### [1.6.0] - 2020-09-12 + > note: Lots has been ported up from `1.16.1` since our first `1.16.2 ` release see: > https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md#142---2020-09-12 and > https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md#141---2020-08-21 for more info #### Changed + - Ported to 1.16.3 ## 1.16.2 + ### [1.5.1] - 2020-09-12 + > note: Lots has been ported up from `1.16.1` since our first `1.16.2 ` release see: > https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md#142---2020-09-12 and > https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md#141---2020-08-21 for more info #### Changed + - Re-ported to 1.16.2... :+1: ### [1.5.0] - 2020-08-14 #### Changed + - Updated to 1.16 :+1: ## 1.16.1 + ### [1.4.2] - 2020-09-12 + #### Added + - A new render for when the Item is in your hand thanks to [ItsTheBdoge](https://github.com/ItsTheBdoge) :heart: - Added `hold shift` for full energy reading aka: `1M/1M FE` to `1,000,000/1,000,000 FE` It's nice! :D - Updated Modification table textures a bit #### Changed -- You can now use right click on TileEntities with the Gadget in your hand again. The blocker on this operation has been modified to only apply to things you might have in your offhand like torches. It's not perfect, but the perfect option requires a PR to Forge... + +- You can now use right click on TileEntities with the Gadget in your hand again. The blocker on this operation has been + modified to only apply to things you might have in your offhand like torches. It's not perfect, but the perfect option + requires a PR to Forge... #### Fixed -- Fixed the Mining Gadget going into negative energy due to a issue with freezing upgrade + +- Fixed the Mining Gadget going into negative energy due to a issue with freezing upgrade ### [1.4.1] - 2020-08-21 + #### Added -- Added a (disabled by default) key binding to open the Gadgets settings screen. (When enabled, it will disable the shift right click action) + +- Added a (disabled by default) key binding to open the Gadgets settings screen. (When enabled, it will disable the + shift right click action) - Added a Laser Beam preview to the Mining Gadget Visual Screen -- Added `Paver` upgrade which will place cobble (cost of 10FE per block) to create a path as you mine to cover up any holes. It will not place above your player's height, and we plan on changing it from cobble :D +- Added `Paver` upgrade which will place cobble (cost of 10FE per block) to create a path as you mine to cover up any + holes. It will not place above your player's height, and we plan on changing it from cobble :D - Modification table can now have upgrades dropped into it's upgrade area (pick up and drop down) - Modification table now has an `empty state` to show helper text on how to use the table. - Modification table now has a title :eyes: #### Changed + - Improved the look of the Mining Gadget Visual Screen - The modification table will now show the full tooltip for you upgrades - Bumped forge version @@ -75,65 +135,92 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed laser rendering through walls when another player is using the gadget ### [1.4.0] - 2020-08-03 + #### Changed + - Updated the mod to 1.16.1 :+1: ## 1.15.2 + ### [1.3.6] - 2020-11-26 + #### Fixed -- Scrolling in the Mining Gadget menu crashing the game [#112](https://github.com/Direwolf20-MC/MiningGadgets/issues/112) -- An issue where custom mouse buttons would crash the game [#92](https://github.com/Direwolf20-MC/MiningGadgets/issues/92) + +- Scrolling in the Mining Gadget menu crashing the + game [#112](https://github.com/Direwolf20-MC/MiningGadgets/issues/112) +- An issue where custom mouse buttons would crash the + game [#92](https://github.com/Direwolf20-MC/MiningGadgets/issues/92) - Issues with the filter screen causing item voiding [#80](https://github.com/Direwolf20-MC/MiningGadgets/issues/80) -- Fixed crashing when another mod blocks our render block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) -- Fixed crashing when another mod blocks our render block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) +- Fixed crashing when another mod blocks our render + block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) +- Fixed crashing when another mod blocks our render + block [#120](https://github.com/Direwolf20-MC/MiningGadgets/issues/120) ### [1.3.5] - 2020-03-29 + #### Added + - Support for all (if they respect events) items that pick up items (dank storage, pocket storage, etc) -- Added the `E` key as a way to get out the Mining Gadget shift-click screen -- Added support for both the Silk touch and Fortune upgrades to be applied to the same gadget but only one can be active at a time +- Added the `E` key as a way to get out the Mining Gadget shift-click screen +- Added support for both the Silk touch and Fortune upgrades to be applied to the same gadget but only one can be active + at a time - Added support for break ice blocks and placing water back in it's place (like vanilla does) - Added support for spawning additional drops (silver fish and others) -- Added the ability to reduce freeze particles by adding a slight delay per tick (configurable in the gadget menu) (You're welcome Soaryn) +- Added the ability to reduce freeze particles by adding a slight delay per tick (configurable in the gadget menu) ( + You're welcome Soaryn) - Added a charged variant of the gadget to the creative and JEI (1.3.3) - Added RU translations (Thanks to @Smollet777) #### Changed + - Disabled the default overlay when using the gadget to stop showing two highlights at the same time -- There is no longer a middle man slot for upgrades in the upgrade table. You can now shift click upgrades right into the gadget and click the upgrade to remove it +- There is no longer a middle man slot for upgrades in the upgrade table. You can now shift click upgrades right into + the gadget and click the upgrade to remove it - Slightly improved the light particle - The Mining Gadget can now ray trace through non-collidable blocks meaning it can now shoot though the Miners Light! - The Mining Gadget now adds to your break block stats :D #### Fixed + - Fixed Mining gadget being voided when left in a Modification table and breaking the table - Fixed an issue with OneProbe on RenderBlock look at - Fixed typo in tooltips - Pushed the laser render to the right spot when running - We now respect the break block event being cancelled - Fixed voiding upgrades when normal clicking them in the modification table. -- Allowing the Gadget to be used for infinite energy (1.3.3) +- Allowing the Gadget to be used for infinite energy (1.3.3) ### [1.3.1] - 2020-03-08 + #### Fixed + - Beta release now. Fixed a few bugs reporting in 1.3.0 ### [1.3.0] - 2020-03-03 + #### Added + - The first release for 1.15.2 - I think its pretty stable? :) ## 1.14.4 + ### [1.2.5] + #### Fixed -- Fixed an issue causing the game to crash with the custom render blocks [#49](https://github.com/Direwolf20-MC/MiningGadgets/issues/49) + +- Fixed an issue causing the game to crash with the custom render + blocks [#49](https://github.com/Direwolf20-MC/MiningGadgets/issues/49) ### [1.2.4] + #### Added + - Added `ru` translations thanks to @Smollet777 - You can now use the scroll wheel to change the sliders :D - You can now shift click into the filter #### Fixed + - Fixed the filters not working #42 - Fixed blacklist filtering system - Added checking to make sure the dimention also allows for block breaking @@ -141,27 +228,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed edgecase crashing on the render block #### Changed + - Optimised images and json files for a smaller mod build size - Took the time to bump Forge up to `28.2.4` ### [1.2.3] + #### Added + - Added Precision Mode (A Soaryn request!) ### [1.2.2] + #### Fixed + - Fixed a dupe bug - Thanks Soaryn. ### [1.2.1] + #### Added + - Added a tooltip to the upgrades and gadget to show RF costs. ### [1.2.0] - ? + #### Added + - The whole mod! # Example + ## [MC-Verion, VERSION] - Date of release + ### Added - ### Changed diff --git a/build.gradle b/build.gradle index 59042cb7..e6d1b5e7 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,8 @@ archivesBaseName = 'mininggadgets' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly. minecraft { + hideOfficialWarningUntilChanged + // 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. @@ -91,28 +93,26 @@ minecraft { sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { + // JEI maven { - // JEI name = "Progwml6 maven" url = "https://dvs1.progwml6.com/files/maven/" } + //JEI fallback maven { - //JEI fallback name = "ModMaven" url = "https://modmaven.k-4u.nl" } + maven { url 'https://www.dogforce-games.com/maven/' } maven { - url 'https://www.dogforce-games.com/maven/' - } - maven { - url 'https://www.cursemaven.com' + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } } } dependencies { - // 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:${mc_version}-${forge_version}" //JEI @@ -120,25 +120,9 @@ dependencies { runtimeOnly fg.deobf("mezz.jei:jei-${jei_version}") // runtimeOnly fg.deobf("curse.maven:inventory-tweaks-renewed:3102237") - - // 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" - - // 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 - - // 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' - - // These dependencies get remapped to your current MCP mappings - // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' - - // For more info... - // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html - // http://www.gradle.org/docs/current/userguide/dependency_management.html - + runtimeOnly fg.deobf("curse.maven:lollipop-347954:3232534") + runtimeOnly fg.deobf("curse.maven:powah-352656:352656") + runtimeOnly fg.deobf("curse.maven:mekanism-268560:268560") } processResources { diff --git a/gradle.properties b/gradle.properties index fd8e85bf..75626dc7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,8 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false #Mod Info -mod_version=1.8.0 +mod_version=1.7.5 #Dependencies mc_version=1.16.5 forge_version=36.1.4 -mcp_version=20210309-1.16.5 jei_version=1.16.5:7.6.4.86 diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index b1da854a..9ba7bb3c 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -1,7 +1,7 @@ b7013e95c0f001eefb22e978563099d6af098f17 assets/mininggadgets/blockstates/minerslight.json c439c311ccd1a6a67fddc2eb5db3f7fc0e0af1e0 assets/mininggadgets/blockstates/modificationtable.json 17f3e42d932950bb56cf0f43004c2badcef8cdc0 assets/mininggadgets/blockstates/renderblock.json -61af57252e09709859d6eb45b59d252b02f6ad64 assets/mininggadgets/lang/en_us.json +851095a3ca57fb651a2eabd0b99544bb67be4499 assets/mininggadgets/lang/en_us.json 973359b4f13b4c70416dd8b3e68a3a4d8886f14f assets/mininggadgets/models/block/minerslight.json c4536a15fbe5781f373148363151ccc6f6686f48 assets/mininggadgets/models/block/modificationtable.json 30eb13c57d2684c6de2f1d2edfb7e535599b3a61 assets/mininggadgets/models/block/renderblock.json @@ -29,6 +29,8 @@ cb0c341c014dd44118b38cd3e92ee791868411b1 assets/mininggadgets/models/item/upgrad 874d2494436b644dd14a7fd929681b977f611e4f assets/mininggadgets/models/item/upgrade_three_by_three.json 78c4ab195fe9b83b63edfaef11c9c2819947bc90 assets/mininggadgets/models/item/upgrade_void_junk.json a4843d0fda4ad7b586ea116b9bce8718d7f84c4d data/mininggadgets/advancements/recipes/mininggadgets/mininggadget.json +405d3a6ca01b5f819a5253b6e58fcaa1639d8758 data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_fancy.json +ad30bcb230535f85142d3d05a9cb388dc4b9c1ff data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_simple.json 3e054d08ee649172d7f210b913d870fe1db1371e data/mininggadgets/advancements/recipes/mininggadgets/modificationtable.json 0fcaaf2f4b432fd60d54449fefdd5706db990acd data/mininggadgets/advancements/recipes/mininggadgets/upgrade_battery_1.json ff15676166a05c33049860b34a6f67a5ccaed1e1 data/mininggadgets/advancements/recipes/mininggadgets/upgrade_battery_2.json @@ -52,7 +54,9 @@ f807888493861b3ee63ed74a2bddf997b216a7cd data/mininggadgets/advancements/recipes a1eb419ef54621feac41d3d41e53f6be7ac73aa1 data/mininggadgets/advancements/recipes/mininggadgets/upgrade_three_by_three.json 29c96f292475ac42dd7ee0e64f8403aaea513a79 data/mininggadgets/advancements/recipes/mininggadgets/upgrade_void_junk.json 047033da6a4d6cef5bff96be21354484e5f876ce data/mininggadgets/loot_tables/blocks/modificationtable.json -7fa522bdf73ad78d311527fca1267048d8ed8361 data/mininggadgets/recipes/mininggadget.json +2d5e4999b2376faf91c606306c51fc97a79e94f2 data/mininggadgets/recipes/mininggadget.json +01290e079fa59bd5c154b7fc905caa356eb9d3c8 data/mininggadgets/recipes/mininggadget_fancy.json +ac137f1a51b69d50a90757c9aa829162c57cde41 data/mininggadgets/recipes/mininggadget_simple.json 79e18311eaeb844f790480126735f839947e713e data/mininggadgets/recipes/modificationtable.json 761e4b325f80ac475236082738093ade67438a42 data/mininggadgets/recipes/upgrade_battery_1.json a0f15250de5ca2ef051e240f590446acd9be3623 data/mininggadgets/recipes/upgrade_battery_2.json diff --git a/src/generated/resources/assets/mininggadgets/lang/en_us.json b/src/generated/resources/assets/mininggadgets/lang/en_us.json index 6d19ee5e..e0ccd72c 100644 --- a/src/generated/resources/assets/mininggadgets/lang/en_us.json +++ b/src/generated/resources/assets/mininggadgets/lang/en_us.json @@ -3,7 +3,9 @@ "block.mininggadgets.modificationtable": "Modification Table", "block.mininggadgets.renderblock": "Render Block (Don't use)", "block.mininggadgets.renderblock.name": "What ever it wants to be!", - "item.mininggadgets.mininggadget": "Mining Gadget", + "item.mininggadgets.mininggadget": "Mining Gadget MK3", + "item.mininggadgets.mininggadget_fancy": "Mining Gadget MK2", + "item.mininggadgets.mininggadget_simple": "Mining Gadget MK1", "item.mininggadgets.upgrade_battery_1": "Upgrade: Battery, Tier 1", "item.mininggadgets.upgrade_battery_2": "Upgrade: Battery, Tier 2", "item.mininggadgets.upgrade_battery_3": "Upgrade: Battery, Tier 3", diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_fancy.json b/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_fancy.json new file mode 100644 index 00000000..647365de --- /dev/null +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_fancy.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mininggadgets:mininggadget_fancy" + ] + }, + "criteria": { + "has_upgrade": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "mininggadgets:upgrade_empty" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mininggadgets:mininggadget_fancy" + } + } + }, + "requirements": [ + [ + "has_upgrade", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_simple.json b/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_simple.json new file mode 100644 index 00000000..072d6bb4 --- /dev/null +++ b/src/generated/resources/data/mininggadgets/advancements/recipes/mininggadgets/mininggadget_simple.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "rewards": { + "recipes": [ + "mininggadgets:mininggadget_simple" + ] + }, + "criteria": { + "has_upgrade": { + "trigger": "minecraft:inventory_changed", + "conditions": { + "items": [ + { + "item": "mininggadgets:upgrade_empty" + } + ] + } + }, + "has_the_recipe": { + "trigger": "minecraft:recipe_unlocked", + "conditions": { + "recipe": "mininggadgets:mininggadget_simple" + } + } + }, + "requirements": [ + [ + "has_upgrade", + "has_the_recipe" + ] + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget.json index c031a6a1..79a66ad3 100644 --- a/src/generated/resources/data/mininggadgets/recipes/mininggadget.json +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget.json @@ -1,9 +1,9 @@ { "type": "minecraft:crafting_shaped", "pattern": [ - "dii", + "dig", "dur", - "dii" + "dig" ], "key": { "u": { @@ -17,6 +17,9 @@ }, "d": { "tag": "forge:gems/diamond" + }, + "g": { + "tag": "forge:ingots/gold" } }, "result": { diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json new file mode 100644 index 00000000..c3430fc4 --- /dev/null +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget_fancy.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "dii", + "dur", + "dig" + ], + "key": { + "u": { + "item": "mininggadgets:upgrade_empty" + }, + "r": { + "tag": "forge:dusts/redstone" + }, + "i": { + "tag": "forge:ingots/iron" + }, + "d": { + "tag": "forge:gems/diamond" + }, + "g": { + "tag": "forge:ingots/gold" + } + }, + "result": { + "item": "mininggadgets:mininggadget_fancy" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json b/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json new file mode 100644 index 00000000..6ae1904d --- /dev/null +++ b/src/generated/resources/data/mininggadgets/recipes/mininggadget_simple.json @@ -0,0 +1,28 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "dig", + "dur", + "dii" + ], + "key": { + "u": { + "item": "mininggadgets:upgrade_empty" + }, + "r": { + "tag": "forge:dusts/redstone" + }, + "i": { + "tag": "forge:ingots/iron" + }, + "d": { + "tag": "forge:gems/diamond" + }, + "g": { + "tag": "forge:ingots/gold" + } + }, + "result": { + "item": "mininggadgets:mininggadget_simple" + } +} \ No newline at end of file diff --git a/src/main/java/com/direwolf20/mininggadgets/client/ClientEvents.java b/src/main/java/com/direwolf20/mininggadgets/client/ClientEvents.java index e3c94002..dd3479cf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/ClientEvents.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/ClientEvents.java @@ -1,9 +1,9 @@ package com.direwolf20.mininggadgets.client; import com.direwolf20.mininggadgets.client.renderer.BlockOverlayRender; -import com.direwolf20.mininggadgets.client.renderer.RenderMiningLaser2; +import com.direwolf20.mininggadgets.client.renderer.ModificationShiftOverlay; +import com.direwolf20.mininggadgets.client.renderer.RenderMiningLaser; import com.direwolf20.mininggadgets.client.screens.ModScreens; -import com.direwolf20.mininggadgets.common.MiningGadgets; import com.direwolf20.mininggadgets.common.items.MiningGadget; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.AbstractClientPlayerEntity; @@ -35,6 +35,10 @@ static void renderWorldLastEvent(RenderWorldLastEvent evt) { if (myItem.getItem() instanceof MiningGadget) BlockOverlayRender.render(evt, myItem); + if (myplayer.isShiftKeyDown()) { + ModificationShiftOverlay.render(evt, myplayer); + } + for (PlayerEntity player : players) { if (player.distanceToSqr(myplayer) > 500) continue; @@ -42,7 +46,7 @@ static void renderWorldLastEvent(RenderWorldLastEvent evt) { ItemStack heldItem = MiningGadget.getGadget(player); if (player.isUsingItem() && heldItem.getItem() instanceof MiningGadget) { if (MiningGadget.canMine(heldItem)) { - RenderMiningLaser2.renderLaser(evt, player, Minecraft.getInstance().getFrameTime()); + RenderMiningLaser.renderLaser(evt, player, Minecraft.getInstance().getFrameTime()); } } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/ClientSetup.java b/src/main/java/com/direwolf20/mininggadgets/client/ClientSetup.java index 6b32c1ab..4309e256 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/ClientSetup.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/ClientSetup.java @@ -1,14 +1,13 @@ package com.direwolf20.mininggadgets.client; +import com.direwolf20.mininggadgets.client.renderer.ModificationTableTER; import com.direwolf20.mininggadgets.client.renderer.RenderBlockTER; import com.direwolf20.mininggadgets.client.screens.FilterScreen; import com.direwolf20.mininggadgets.client.screens.ModificationTableScreen; import com.direwolf20.mininggadgets.common.blocks.ModBlocks; import com.direwolf20.mininggadgets.common.containers.ModContainers; -import com.direwolf20.mininggadgets.common.tiles.RenderBlockTileEntity; import net.minecraft.client.gui.ScreenManager; import net.minecraftforge.fml.client.registry.ClientRegistry; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; /** * Only put client code here plz. @@ -32,7 +31,8 @@ private static void registerContainerScreens() { */ private static void registerRenderers() { //FMLJavaModLoadingContext.get().getModEventBus().addListener(event -> - ClientRegistry.bindTileEntityRenderer(ModBlocks.RENDERBLOCK_TILE.get(), RenderBlockTER::new); - //); + ClientRegistry.bindTileEntityRenderer(ModBlocks.RENDERBLOCK_TILE.get(), RenderBlockTER::new); + ClientRegistry.bindTileEntityRenderer(ModBlocks.MODIFICATIONTABLE_TILE.get(), ModificationTableTER::new); + //); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java b/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java index 9e4b78cf..01b67293 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/MiningGadgetsJEI.java @@ -1,15 +1,24 @@ package com.direwolf20.mininggadgets.client; +import com.direwolf20.mininggadgets.client.screens.ModificationTableScreen; import com.direwolf20.mininggadgets.common.Config; import com.direwolf20.mininggadgets.common.MiningGadgets; import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.ModItems; import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; -import mezz.jei.api.ingredients.subtypes.ISubtypeInterpreter; +import mezz.jei.api.gui.handlers.IGuiContainerHandler; +import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; +import mezz.jei.api.registration.IGuiHandlerRegistration; import mezz.jei.api.registration.ISubtypeRegistration; +import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + @JeiPlugin public class MiningGadgetsJEI implements IModPlugin { @Override @@ -19,17 +28,35 @@ public ResourceLocation getPluginUid() { @Override public void registerItemSubtypes(ISubtypeRegistration registration) { - registration.registerSubtypeInterpreter(ModItems.MININGGADGET.get(), itemStack -> { - if(!(itemStack.getItem() instanceof MiningGadget)) - return ISubtypeInterpreter.NONE; + IIngredientSubtypeInterpreter chargedProvider = (stack, uid) -> { + if (!(stack.getItem() instanceof MiningGadget)) { + return IIngredientSubtypeInterpreter.NONE; + } - double energy = itemStack.getOrCreateTag().getDouble("energy"); - if (energy == 0) + double energy = stack.getOrCreateTag().getDouble("energy"); + if (energy == 0) { return "empty"; - else if (energy == Config.MININGGADGET_MAXPOWER.get()) + } else if (energy == Config.MININGGADGET_MAXPOWER.get()) { return "charged"; + } + + return IIngredientSubtypeInterpreter.NONE; + }; + + registration.registerSubtypeInterpreter(ModItems.MININGGADGET.get(), chargedProvider); + registration.registerSubtypeInterpreter(ModItems.MININGGADGET_SIMPLE.get(), chargedProvider); + registration.registerSubtypeInterpreter(ModItems.MININGGADGET_FANCY.get(), chargedProvider); + } + + @Override + public void registerGuiHandlers(IGuiHandlerRegistration registration) { + registration.addGuiContainerHandler(ModificationTableScreen.class, new ModificationTableContainerHandler()); + } - return ISubtypeInterpreter.NONE; - }); + private static class ModificationTableContainerHandler implements IGuiContainerHandler { + @Override + public List getGuiExtraAreas(ModificationTableScreen containerScreen) { + return new ArrayList<>(Collections.singleton(new Rectangle2d((containerScreen.width / 2) - 120, (containerScreen.height / 2) - 5, 25, 35))); + } } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java b/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java index ef483a92..7fc439e0 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/events/EventRenderGadget.java @@ -1,6 +1,7 @@ package com.direwolf20.mininggadgets.client.events; import com.direwolf20.mininggadgets.common.MiningGadgets; +import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.ModItems; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.Minecraft; @@ -19,16 +20,16 @@ import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = MiningGadgets.MOD_ID, value = Dist.CLIENT) -public class EventRenderGadget -{ - +public class EventRenderGadget { + @SubscribeEvent - static void renderGadget(RenderHandEvent event) - { - if (!ModItems.MININGGADGET.get().equals(event.getItemStack().getItem())) { + public static void renderGadget(RenderHandEvent event) { + if (!(event.getItemStack().getItem() instanceof MiningGadget)) { return; } + boolean isFancyGadget = ModItems.MININGGADGET_FANCY.get().equals(event.getItemStack().getItem()); + Minecraft mc = Minecraft.getInstance(); MatrixStack matrixStackIn = event.getMatrixStack(); IRenderTypeBuffer buffer = event.getBuffers(); @@ -76,7 +77,7 @@ static void renderGadget(RenderHandEvent event) // renders gadget matrixStackIn.pushPose(); - matrixStackIn.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.71999997F - 0.1f); + matrixStackIn.translate(f * (f2 + 0.64000005F - .1f), f3 + -0.4F + equipProgress * -0.6F, f4 + -0.71999997F - 0.1f + (isFancyGadget ? -.10f : 0)); matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(f * f6 * 70.0F)); matrixStackIn.mulPose(Vector3f.ZP.rotationDegrees(f * f5 * -20.0F)); matrixStackIn.translate(rightHand ? .13f:-.1f, -.25f, -.35f); diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationShiftOverlay.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationShiftOverlay.java new file mode 100644 index 00000000..af9cc32e --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationShiftOverlay.java @@ -0,0 +1,99 @@ +package com.direwolf20.mininggadgets.client.renderer; + +import com.direwolf20.mininggadgets.common.blocks.ModBlocks; +import com.direwolf20.mininggadgets.common.items.MiningGadget; +import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; +import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; +import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraftforge.client.event.RenderWorldLastEvent; + +import java.util.List; + +public class ModificationShiftOverlay { + + public static void render(RenderWorldLastEvent evt, PlayerEntity player) { + RayTraceResult pick = player.pick(5, 0, false); + if (pick.getType() != RayTraceResult.Type.BLOCK) { + return; + } + + BlockRayTraceResult trace = (BlockRayTraceResult) pick; + if (player.level.getBlockState(trace.getBlockPos()).getBlock() != ModBlocks.MODIFICATION_TABLE.get()) { + return; + } + + TileEntity blockEntity = player.level.getBlockEntity(trace.getBlockPos()); + if (!(blockEntity instanceof ModificationTableTileEntity)) { + return; + } + + // Finally, lets try and render something if we have a gadget in the main slot + ItemStack stack = ((ModificationTableTileEntity) blockEntity).handler.map(e -> e.getStackInSlot(0)).orElse(ItemStack.EMPTY); + if (stack.isEmpty() || !(stack.getItem() instanceof MiningGadget)) { + return; + } + + List upgrades = UpgradeTools.getUpgrades(stack); + if (upgrades.isEmpty()) { + return; + } + + Vector3d view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + BlockPos blockPos = ((BlockRayTraceResult) pick).getBlockPos(); + + double distance = player.getPosition(evt.getPartialTicks()).distanceTo(new Vector3d(blockPos.getX(), blockPos.getY(), blockPos.getZ())); + float scaleFactor = Math.max(.2f, ((float) distance / 10) + .1f); + + MatrixStack matrix = evt.getMatrixStack(); + matrix.pushPose(); + matrix.translate(-view.x, -view.y, -view.z); + matrix.translate(blockPos.getX() + .5f, blockPos.getY() + 1, blockPos.getZ() + .5f); + matrix.scale(scaleFactor, scaleFactor, scaleFactor); + matrix.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation()); + + IRenderTypeBuffer.Impl outlineLayerBuffer = Minecraft.getInstance().renderBuffers().bufferSource(); + + int x = 0, y = 0; + + // Fixes centering issues with 1 or 2 upgrades + float offset = upgrades.size() / 3 > 0 + ? -1.15f + : (upgrades.size() > 1 + ? -(upgrades.size() / 3f) + : -.2f); + + for (Upgrade upgrade : upgrades) { + matrix.pushPose(); + matrix.translate(offset + x, y, 0); + matrix.mulPose(Vector3f.YP.rotationDegrees(90)); + matrix.mulPose(Vector3f.XP.rotationDegrees(26)); + ItemStack upgradeStack = upgrade.getStack(); + IBakedModel model = Minecraft.getInstance().getItemRenderer().getModel(upgradeStack, Minecraft.getInstance().level, null); + Minecraft.getInstance().getItemRenderer().render(upgradeStack, ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, false, matrix, outlineLayerBuffer, 15728880, OverlayTexture.NO_OVERLAY, model); + x += 1; + if (x > 2) { + x = 0; + y += 1; + } + matrix.popPose(); + } + + outlineLayerBuffer.endBatch(); + + matrix.popPose(); + } +} diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationTableTER.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationTableTER.java new file mode 100644 index 00000000..0678656d --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/client/renderer/ModificationTableTER.java @@ -0,0 +1,63 @@ +package com.direwolf20.mininggadgets.client.renderer; + +import com.direwolf20.mininggadgets.common.items.ModItems; +import com.direwolf20.mininggadgets.common.tiles.ModificationTableTileEntity; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.model.IBakedModel; +import net.minecraft.client.renderer.model.ItemCameraTransforms; +import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.item.ItemStack; +import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.Direction; +import net.minecraft.util.math.vector.Vector3f; +import net.minecraftforge.items.CapabilityItemHandler; + +public class ModificationTableTER extends TileEntityRenderer { + public ModificationTableTER(TileEntityRendererDispatcher dispatcher) { + super(dispatcher); + } + + @Override + public void render(ModificationTableTileEntity tile, float partialTicks, MatrixStack matrix, IRenderTypeBuffer buffer, int combinedLights, int combinedOverlay) { + ItemStack stack = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(e -> e.getStackInSlot(0)).orElse(ItemStack.EMPTY); + if (stack.isEmpty()) { + return; + } + + boolean isSimple = stack.getItem().equals(ModItems.MININGGADGET_SIMPLE.get()); + boolean isFancy = stack.getItem().equals(ModItems.MININGGADGET_FANCY.get()); + boolean isCool = !isSimple && !isFancy; + + Direction facing = tile.getBlockState().getValue(BlockStateProperties.HORIZONTAL_FACING); + matrix.pushPose(); + matrix.translate(0, .81f, 0); + + float leftModifier = isCool ? 0 : (isFancy ? .15f : .2f); + if (facing == Direction.SOUTH) { + matrix.translate(.7f - leftModifier, 0, .85f); + matrix.mulPose(Vector3f.YP.rotationDegrees(90)); + } else if (facing == Direction.EAST) { + matrix.translate(.85f, 0, .3f + leftModifier); + matrix.mulPose(Vector3f.YP.rotationDegrees(180)); + } else if (facing == Direction.NORTH) { + matrix.translate(.3f + leftModifier, 0, .15f); + matrix.mulPose(Vector3f.YP.rotationDegrees(270)); + } else { + matrix.translate(.15f, 0, .7f - leftModifier); + } + matrix.mulPose(Vector3f.ZN.rotationDegrees(90)); + + if (isCool) { + matrix.scale(.65f, .65f, .65f); + } else { + matrix.scale(.8f, .8f, .8f); + } + + IBakedModel model = Minecraft.getInstance().getItemRenderer().getModel(stack, Minecraft.getInstance().level, null); + Minecraft.getInstance().getItemRenderer().render(stack, ItemCameraTransforms.TransformType.FIRST_PERSON_LEFT_HAND, false, matrix,buffer, combinedLights, combinedOverlay, model); + matrix.popPose(); + } +} diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java index 5c7a7fcb..511d6f03 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser.java @@ -2,16 +2,16 @@ import com.direwolf20.mininggadgets.common.MiningGadgets; import com.direwolf20.mininggadgets.common.items.MiningGadget; +import com.direwolf20.mininggadgets.common.items.ModItems; import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.renderer.IRenderTypeBuffer; +import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Hand; @@ -19,10 +19,10 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.math.vector.*; import net.minecraftforge.client.event.RenderWorldLastEvent; -import static org.lwjgl.opengl.GL11.*; +import java.util.Locale; public class RenderMiningLaser { @@ -44,7 +44,7 @@ public static void renderLaser(RenderWorldLastEvent event, PlayerEntity player, // parse data from item float speedModifier = getSpeedModifier(stack); - drawLasers(event, playerPos, trace, 0, 0, 0, MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f, 0.02f, player, ticks, speedModifier); + drawLasers(stack, event, playerPos, trace, 0, 0, 0, MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f, 0.02f, player, ticks, speedModifier); } private static float getSpeedModifier(ItemStack stack) { @@ -57,7 +57,7 @@ private static float getSpeedModifier(ItemStack stack) { } } - private static void drawLasers(RenderWorldLastEvent event, Vector3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) { + private static void drawLasers(ItemStack stack, RenderWorldLastEvent event, Vector3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) { Hand activeHand; if (player.getMainHandItem().getItem() instanceof MiningGadget) { activeHand = Hand.MAIN_HAND; @@ -67,90 +67,115 @@ private static void drawLasers(RenderWorldLastEvent event, Vector3d from, RayTra return; } - ItemStack stack = player.getItemInHand(activeHand); - - double distance = from.subtract(trace.getLocation()).length(); + IVertexBuilder builder; + double distance = Math.max(1, from.subtract(trace.getLocation()).length()); long gameTime = player.level.getGameTime(); double v = gameTime * speedModifier; float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime); - BufferBuilder wr = Tessellator.getInstance().getBuilder(); + + float beam2r = MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f; + float beam2g = MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f; + float beam2b = MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f; Vector3d view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().renderBuffers().bufferSource(); MatrixStack matrix = event.getMatrixStack(); - matrix.translate(view.x(), view.y(), view.z()); - if( trace.getType() == RayTraceResult.Type.MISS ) - matrix.translate(-from.x, -from.y, -from.z); - - RenderSystem.pushMatrix(); - RenderSystem.multMatrix(matrix.last().pose()); - - RenderSystem.enableColorMaterial(); - // This makes it so we don't clip into the world, we're effectively drawing on it - RenderSystem.disableDepthTest(); - RenderSystem.enableBlend(); - //This makes it so multiplayer doesn't matter which side the player is standing on to see someone elses laser - RenderSystem.disableCull(); - RenderSystem.enableTexture(); - - RenderSystem.rotatef(MathHelper.lerp(ticks, -player.yRot, -player.yRotO), 0, 1, 0); - RenderSystem.rotatef(MathHelper.lerp(ticks, player.xRot, player.xRotO), 1, 0, 0); - - // additive laser beam - RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - RenderSystem.color4f(r, g, b, 0.7f); - Minecraft.getInstance().getTextureManager().bind(laserBeamGlow); - drawBeam(xOffset, yOffset, zOffset, additiveThickness, activeHand, distance, wr, 0.5, 1, ticks); - - // main laser, colored part - RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - RenderSystem.color4f(r, g, b, 1.0f); - Minecraft.getInstance().getTextureManager().bind(laserBeam2); - drawBeam(xOffset, yOffset, zOffset, thickness, activeHand, distance, wr, v, v + distance * 1.5, ticks); - // white core - RenderSystem.color4f(MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f, 1.0f); - Minecraft.getInstance().getTextureManager().bind(laserBeam); - drawBeam(xOffset, yOffset, zOffset, thickness / 2, activeHand, distance, wr, v, v + distance * 1.5, ticks); - - RenderSystem.enableDepthTest(); - RenderSystem.enableCull(); - RenderSystem.popMatrix(); + + matrix.pushPose(); + + matrix.translate(-view.x(), -view.y(), -view.z()); + matrix.translate(from.x, from.y, from.z); + matrix.mulPose(Vector3f.YP.rotationDegrees(MathHelper.lerp(ticks, -player.yRot, -player.yRotO))); + matrix.mulPose(Vector3f.XP.rotationDegrees(MathHelper.lerp(ticks, player.xRot, player.xRotO))); + + MatrixStack.Entry matrixstack$entry = matrix.last(); + Matrix3f matrixNormal = matrixstack$entry.normal(); + Matrix4f positionMatrix = matrixstack$entry.pose(); + + //additive laser beam + builder = buffer.getBuffer(MyRenderType.LASER_MAIN_ADDITIVE); + drawBeam(stack, xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, additiveThickness, activeHand, distance, 0.5, 1, ticks, r,g,b,0.7f); + + //main laser, colored part + builder = buffer.getBuffer(MyRenderType.LASER_MAIN_BEAM); + drawBeam(stack, xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, thickness, activeHand, distance, v, v + distance * 1.5, ticks, r,g,b,1f); + + //core + builder = buffer.getBuffer(MyRenderType.LASER_MAIN_CORE); + drawBeam(stack, xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, thickness/2, activeHand, distance, v, v + distance * 1.5, ticks, beam2r,beam2g,beam2b,1f); + matrix.popPose(); +// RenderSystem.disableDepthTest(); + buffer.endBatch(); } private static float calculateLaserFlickerModifier(long gameTime) { return 0.9f + 0.1f * MathHelper.sin(gameTime * 0.99f) * MathHelper.sin(gameTime * 0.3f) * MathHelper.sin(gameTime * 0.1f); } - private static void drawBeam(double xOffset, double yOffset, double zOffset, float thickness, Hand hand, double distance, BufferBuilder wr, double v1, double v2, float ticks) { - ClientPlayerEntity player = Minecraft.getInstance().player; - - float startXOffset = -0.25f; - float startYOffset = -.115f; - float startZOffset = 0.65f + (1 - player.getFieldOfViewModifier()); - - float f = (MathHelper.lerp(ticks, player.xRotO, player.xRot) - MathHelper.lerp(ticks, player.xBobO, player.xBob)); - float f1 = (MathHelper.lerp(ticks, player.yRotO, player.yRot) - MathHelper.lerp(ticks, player.yBobO, player.yBob)); - startXOffset = startXOffset + (f1 / 1000); - startYOffset = startYOffset + (f / 1000); + private static void drawBeam(ItemStack stack, double xOffset, double yOffset, double zOffset, IVertexBuilder builder, Matrix4f positionMatrix, Matrix3f matrixNormalIn, float thickness, Hand hand, double distance, double v1, double v2, float ticks, float r, float g, float b, float alpha) { + boolean isFancy = stack.getItem().equals(ModItems.MININGGADGET_FANCY.get()); + boolean isSimple = stack.getItem().equals(ModItems.MININGGADGET_SIMPLE.get()); + Vector3f vector3f = new Vector3f(0.0f, 1.0f, 0.0f); + vector3f.transform(matrixNormalIn); + ClientPlayerEntity player = Minecraft.getInstance().player; // Support for hand sides remembering to take into account of Skin options if( Minecraft.getInstance().options.mainHand != HandSide.RIGHT ) hand = hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; + float startXOffset = -0.20f; + float startYOffset = -.108f; + float startZOffset = 0.60f; + // Adjust for different gadgets + if (isFancy) { + startYOffset += .02f; + } + if (isSimple) { + startXOffset -= .02f; + startZOffset += .05f; + startYOffset -= .005f; + } + // Adjust for fov changing + startZOffset += (1 - player.getFieldOfViewModifier()); + if (hand == Hand.OFF_HAND) { + startYOffset = -.120f; + startXOffset = 0.25f; + } + float f = (MathHelper.lerp(ticks, player.xRotO, player.xRot) - MathHelper.lerp(ticks, player.xBobO, player.xBob)); + float f1 = (MathHelper.lerp(ticks, player.yRotO, player.yRot) - MathHelper.lerp(ticks, player.yBobO, player.yBob)); + startXOffset = startXOffset + (f1 / 750); + startYOffset = startYOffset + (f / 750); + + Vector4f vec1 = new Vector4f(startXOffset, -thickness + startYOffset, startZOffset, 1.0F); + vec1.transform(positionMatrix); + Vector4f vec2 = new Vector4f((float) xOffset, -thickness + (float) yOffset, (float) distance + (float) zOffset, 1.0F); + vec2.transform(positionMatrix); + Vector4f vec3 = new Vector4f((float) xOffset, thickness + (float) yOffset, (float) distance + (float) zOffset, 1.0F); + vec3.transform(positionMatrix); + Vector4f vec4 = new Vector4f(startXOffset, thickness + startYOffset, startZOffset, 1.0F); + vec4.transform(positionMatrix); - wr.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX); if (hand == Hand.MAIN_HAND) { - wr.vertex(startXOffset, -thickness + startYOffset, startZOffset).uv(1, (float) v1).endVertex(); - wr.vertex(xOffset, -thickness + yOffset, distance + zOffset).uv(1, (float) v2).endVertex(); - wr.vertex(xOffset, thickness + yOffset, distance + zOffset).uv(0, (float) v2).endVertex(); - wr.vertex(startXOffset, thickness + startYOffset, startZOffset).uv(0, (float) v1).endVertex(); + builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + //Rendering a 2nd time to allow you to see both sides in multiplayer, shouldn't be necessary with culling disabled but here we are.... + builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); } else { - startYOffset = -.120f; - wr.vertex(-startXOffset, thickness + startYOffset, startZOffset).uv(0, (float) v1).endVertex(); - wr.vertex(xOffset, thickness + yOffset, distance + zOffset).uv(0, (float) v2).endVertex(); - wr.vertex(xOffset, -thickness + yOffset, distance + zOffset).uv(1, (float) v2).endVertex(); - wr.vertex(-startXOffset, -thickness + startYOffset, startZOffset).uv(1, (float) v1).endVertex(); + builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + //Rendering a 2nd time to allow you to see both sides in multiplayer, shouldn't be necessary with culling disabled but here we are.... + builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); + builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); } - Tessellator.getInstance().end(); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser2.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser2.java deleted file mode 100644 index dee35050..00000000 --- a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaser2.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.direwolf20.mininggadgets.client.renderer; - -import com.direwolf20.mininggadgets.common.MiningGadgets; -import com.direwolf20.mininggadgets.common.items.MiningGadget; -import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; -import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; -import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.vertex.IVertexBuilder; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Hand; -import net.minecraft.util.HandSide; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.*; -import net.minecraftforge.client.event.RenderWorldLastEvent; - -import java.util.Locale; - -public class RenderMiningLaser2 { - - private final static ResourceLocation laserBeam = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser.png"); - private final static ResourceLocation laserBeam2 = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser2.png"); - private final static ResourceLocation laserBeamGlow = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser_glow.png"); - - public static void renderLaser(RenderWorldLastEvent event, PlayerEntity player, float ticks) { - ItemStack stack = MiningGadget.getGadget(player); - - if (!MiningProperties.getCanMine(stack)) - return; - - int range = MiningProperties.getBeamRange(stack); - - Vector3d playerPos = player.getEyePosition(ticks); - RayTraceResult trace = player.pick(range, 0.0F, false); - - // parse data from item - float speedModifier = getSpeedModifier(stack); - - drawLasers(event, playerPos, trace, 0, 0, 0, MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f, 0.02f, player, ticks, speedModifier); - } - - private static float getSpeedModifier(ItemStack stack) { - if (UpgradeTools.containsUpgrade(stack, Upgrade.EFFICIENCY_1)) { - double efficiency = UpgradeTools.getUpgradeFromGadget(stack, Upgrade.EFFICIENCY_1).get().getTier() / 5f; - double speedModifier = MathHelper.lerp(efficiency, 0.02, 0.05); - return (float) -speedModifier; - } else { - return -0.02f; - } - } - - private static void drawLasers(RenderWorldLastEvent event, Vector3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) { - Hand activeHand; - if (player.getMainHandItem().getItem() instanceof MiningGadget) { - activeHand = Hand.MAIN_HAND; - } else if (player.getOffhandItem().getItem() instanceof MiningGadget) { - activeHand = Hand.OFF_HAND; - } else { - return; - } - - IVertexBuilder builder; - ItemStack stack = player.getItemInHand(activeHand); - double distance = Math.max(1, from.subtract(trace.getLocation()).length()); - long gameTime = player.level.getGameTime(); - double v = gameTime * speedModifier; - float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime); - - float beam2r = MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f; - float beam2g = MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f; - float beam2b = MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f; - - Vector3d view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); - IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().renderBuffers().bufferSource(); - - MatrixStack matrix = event.getMatrixStack(); - - matrix.pushPose(); - - matrix.translate(-view.x(), -view.y(), -view.z()); - matrix.translate(from.x, from.y, from.z); - matrix.mulPose(Vector3f.YP.rotationDegrees(MathHelper.lerp(ticks, -player.yRot, -player.yRotO))); - matrix.mulPose(Vector3f.XP.rotationDegrees(MathHelper.lerp(ticks, player.xRot, player.xRotO))); - - MatrixStack.Entry matrixstack$entry = matrix.last(); - Matrix3f matrixNormal = matrixstack$entry.normal(); - Matrix4f positionMatrix = matrixstack$entry.pose(); - - //additive laser beam - builder = buffer.getBuffer(MyRenderType.LASER_MAIN_ADDITIVE); - drawBeam(xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, additiveThickness, activeHand, distance, 0.5, 1, ticks, r,g,b,0.7f); - - //main laser, colored part - builder = buffer.getBuffer(MyRenderType.LASER_MAIN_BEAM); - drawBeam(xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, thickness, activeHand, distance, v, v + distance * 1.5, ticks, r,g,b,1f); - - //core - builder = buffer.getBuffer(MyRenderType.LASER_MAIN_CORE); - drawBeam(xOffset, yOffset, zOffset, builder, positionMatrix, matrixNormal, thickness/2, activeHand, distance, v, v + distance * 1.5, ticks, beam2r,beam2g,beam2b,1f); - matrix.popPose(); -// RenderSystem.disableDepthTest(); - buffer.endBatch(); - } - - private static float calculateLaserFlickerModifier(long gameTime) { - return 0.9f + 0.1f * MathHelper.sin(gameTime * 0.99f) * MathHelper.sin(gameTime * 0.3f) * MathHelper.sin(gameTime * 0.1f); - } - - private static void drawBeam(double xOffset, double yOffset, double zOffset, IVertexBuilder builder, Matrix4f positionMatrix, Matrix3f matrixNormalIn, float thickness, Hand hand, double distance, double v1, double v2, float ticks, float r, float g, float b, float alpha) { - Vector3f vector3f = new Vector3f(0.0f, 1.0f, 0.0f); - vector3f.transform(matrixNormalIn); - ClientPlayerEntity player = Minecraft.getInstance().player; - // Support for hand sides remembering to take into account of Skin options - if( Minecraft.getInstance().options.mainHand != HandSide.RIGHT ) - hand = hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; - float startXOffset = -0.25f; - float startYOffset = -.115f; - float startZOffset = 0.65f + (1 - player.getFieldOfViewModifier()); - if (hand == Hand.OFF_HAND) { - startYOffset = -.120f; - startXOffset = 0.25f; - } - float f = (MathHelper.lerp(ticks, player.xRotO, player.xRot) - MathHelper.lerp(ticks, player.xBobO, player.xBob)); - float f1 = (MathHelper.lerp(ticks, player.yRotO, player.yRot) - MathHelper.lerp(ticks, player.yBobO, player.yBob)); - startXOffset = startXOffset + (f1 / 750); - startYOffset = startYOffset + (f / 750); - - Vector4f vec1 = new Vector4f(startXOffset, -thickness + startYOffset, startZOffset, 1.0F); - vec1.transform(positionMatrix); - Vector4f vec2 = new Vector4f((float) xOffset, -thickness + (float) yOffset, (float) distance + (float) zOffset, 1.0F); - vec2.transform(positionMatrix); - Vector4f vec3 = new Vector4f((float) xOffset, thickness + (float) yOffset, (float) distance + (float) zOffset, 1.0F); - vec3.transform(positionMatrix); - Vector4f vec4 = new Vector4f(startXOffset, thickness + startYOffset, startZOffset, 1.0F); - vec4.transform(positionMatrix); - - if (hand == Hand.MAIN_HAND) { - builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - //Rendering a 2nd time to allow you to see both sides in multiplayer, shouldn't be necessary with culling disabled but here we are.... - builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - } else { - builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - //Rendering a 2nd time to allow you to see both sides in multiplayer, shouldn't be necessary with culling disabled but here we are.... - builder.vertex(vec4.x(), vec4.y(), vec4.z(), r, g, b, alpha, 0, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec3.x(), vec3.y(), vec3.z(), r, g, b, alpha, 0, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec2.x(), vec2.y(), vec2.z(), r, g, b, alpha, 1, (float) v2, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - builder.vertex(vec1.x(), vec1.y(), vec1.z(), r, g, b, alpha, 1, (float) v1, OverlayTexture.NO_OVERLAY, 15728880, vector3f.x(), vector3f.y(), vector3f.z()); - } - } - -} diff --git a/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaserOld.java b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaserOld.java new file mode 100644 index 00000000..64cfc678 --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/client/renderer/RenderMiningLaserOld.java @@ -0,0 +1,156 @@ +//package com.direwolf20.mininggadgets.client.renderer; +// +//import com.direwolf20.mininggadgets.common.MiningGadgets; +//import com.direwolf20.mininggadgets.common.items.MiningGadget; +//import com.direwolf20.mininggadgets.common.items.gadget.MiningProperties; +//import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; +//import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; +//import com.mojang.blaze3d.matrix.MatrixStack; +//import com.mojang.blaze3d.systems.RenderSystem; +//import net.minecraft.client.Minecraft; +//import net.minecraft.client.entity.player.ClientPlayerEntity; +//import net.minecraft.client.renderer.BufferBuilder; +//import net.minecraft.client.renderer.Tessellator; +//import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +//import net.minecraft.entity.player.PlayerEntity; +//import net.minecraft.item.ItemStack; +//import net.minecraft.util.Hand; +//import net.minecraft.util.HandSide; +//import net.minecraft.util.ResourceLocation; +//import net.minecraft.util.math.MathHelper; +//import net.minecraft.util.math.RayTraceResult; +//import net.minecraft.util.math.vector.Vector3d; +//import net.minecraftforge.client.event.RenderWorldLastEvent; +// +//import static org.lwjgl.opengl.GL11.*; +// +//public class RenderMiningLaser { +// +// private final static ResourceLocation laserBeam = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser.png"); +// private final static ResourceLocation laserBeam2 = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser2.png"); +// private final static ResourceLocation laserBeamGlow = new ResourceLocation(MiningGadgets.MOD_ID + ":textures/misc/laser_glow.png"); +// +// public static void renderLaser(RenderWorldLastEvent event, PlayerEntity player, float ticks) { +// ItemStack stack = MiningGadget.getGadget(player); +// +// if (!MiningProperties.getCanMine(stack)) +// return; +// +// int range = MiningProperties.getBeamRange(stack); +// +// Vector3d playerPos = player.getEyePosition(ticks); +// RayTraceResult trace = player.pick(range, 0.0F, false); +// +// // parse data from item +// float speedModifier = getSpeedModifier(stack); +// +// drawLasers(event, playerPos, trace, 0, 0, 0, MiningProperties.getColor(stack, MiningProperties.COLOR_RED) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE) / 255f, 0.02f, player, ticks, speedModifier); +// } +// +// private static float getSpeedModifier(ItemStack stack) { +// if (UpgradeTools.containsUpgrade(stack, Upgrade.EFFICIENCY_1)) { +// double efficiency = UpgradeTools.getUpgradeFromGadget(stack, Upgrade.EFFICIENCY_1).get().getTier() / 5f; +// double speedModifier = MathHelper.lerp(efficiency, 0.02, 0.05); +// return (float) -speedModifier; +// } else { +// return -0.02f; +// } +// } +// +// private static void drawLasers(RenderWorldLastEvent event, Vector3d from, RayTraceResult trace, double xOffset, double yOffset, double zOffset, float r, float g, float b, float thickness, PlayerEntity player, float ticks, float speedModifier) { +// Hand activeHand; +// if (player.getMainHandItem().getItem() instanceof MiningGadget) { +// activeHand = Hand.MAIN_HAND; +// } else if (player.getOffhandItem().getItem() instanceof MiningGadget) { +// activeHand = Hand.OFF_HAND; +// } else { +// return; +// } +// +// ItemStack stack = player.getItemInHand(activeHand); +// +// double distance = from.subtract(trace.getLocation()).length(); +// long gameTime = player.level.getGameTime(); +// double v = gameTime * speedModifier; +// float additiveThickness = (thickness * 3.5f) * calculateLaserFlickerModifier(gameTime); +// BufferBuilder wr = Tessellator.getInstance().getBuilder(); +// +// Vector3d view = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); +// +// MatrixStack matrix = event.getMatrixStack(); +// matrix.translate(view.x(), view.y(), view.z()); +// if( trace.getType() == RayTraceResult.Type.MISS ) +// matrix.translate(-from.x, -from.y, -from.z); +// +// RenderSystem.pushMatrix(); +// RenderSystem.multMatrix(matrix.last().pose()); +// +// RenderSystem.enableColorMaterial(); +// // This makes it so we don't clip into the world, we're effectively drawing on it +// RenderSystem.disableDepthTest(); +// RenderSystem.enableBlend(); +// //This makes it so multiplayer doesn't matter which side the player is standing on to see someone elses laser +// RenderSystem.disableCull(); +// RenderSystem.enableTexture(); +// +// RenderSystem.rotatef(MathHelper.lerp(ticks, -player.yRot, -player.yRotO), 0, 1, 0); +// RenderSystem.rotatef(MathHelper.lerp(ticks, player.xRot, player.xRotO), 1, 0, 0); +// +// // additive laser beam +// RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +// RenderSystem.color4f(r, g, b, 0.7f); +// Minecraft.getInstance().getTextureManager().bind(laserBeamGlow); +// drawBeam(xOffset, yOffset, zOffset, additiveThickness, activeHand, distance, wr, 0.5, 1, ticks); +// +// // main laser, colored part +// RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +// RenderSystem.color4f(r, g, b, 1.0f); +// Minecraft.getInstance().getTextureManager().bind(laserBeam2); +// drawBeam(xOffset, yOffset, zOffset, thickness, activeHand, distance, wr, v, v + distance * 1.5, ticks); +// // white core +// RenderSystem.color4f(MiningProperties.getColor(stack, MiningProperties.COLOR_RED_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_GREEN_INNER) / 255f, MiningProperties.getColor(stack, MiningProperties.COLOR_BLUE_INNER) / 255f, 1.0f); +// Minecraft.getInstance().getTextureManager().bind(laserBeam); +// drawBeam(xOffset, yOffset, zOffset, thickness / 2, activeHand, distance, wr, v, v + distance * 1.5, ticks); +// +// RenderSystem.enableDepthTest(); +// RenderSystem.enableCull(); +// RenderSystem.popMatrix(); +// } +// +// private static float calculateLaserFlickerModifier(long gameTime) { +// return 0.9f + 0.1f * MathHelper.sin(gameTime * 0.99f) * MathHelper.sin(gameTime * 0.3f) * MathHelper.sin(gameTime * 0.1f); +// } +// +// private static void drawBeam(double xOffset, double yOffset, double zOffset, float thickness, Hand hand, double distance, BufferBuilder wr, double v1, double v2, float ticks) { +// ClientPlayerEntity player = Minecraft.getInstance().player; +// +// float startXOffset = -0.25f; +// float startYOffset = -.115f; +// float startZOffset = 0.65f + (1 - player.getFieldOfViewModifier()); +// +// float f = (MathHelper.lerp(ticks, player.xRotO, player.xRot) - MathHelper.lerp(ticks, player.xBobO, player.xBob)); +// float f1 = (MathHelper.lerp(ticks, player.yRotO, player.yRot) - MathHelper.lerp(ticks, player.yBobO, player.yBob)); +// startXOffset = startXOffset + (f1 / 1000); +// startYOffset = startYOffset + (f / 1000); +// +// // Support for hand sides remembering to take into account of Skin options +// if( Minecraft.getInstance().options.mainHand != HandSide.RIGHT ) +// hand = hand == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND; +// +// wr.begin(GL_QUADS, DefaultVertexFormats.POSITION_TEX); +// if (hand == Hand.MAIN_HAND) { +// wr.vertex(startXOffset, -thickness + startYOffset, startZOffset).uv(1, (float) v1).endVertex(); +// wr.vertex(xOffset, -thickness + yOffset, distance + zOffset).uv(1, (float) v2).endVertex(); +// wr.vertex(xOffset, thickness + yOffset, distance + zOffset).uv(0, (float) v2).endVertex(); +// wr.vertex(startXOffset, thickness + startYOffset, startZOffset).uv(0, (float) v1).endVertex(); +// } else { +// startYOffset = -.120f; +// wr.vertex(-startXOffset, thickness + startYOffset, startZOffset).uv(0, (float) v1).endVertex(); +// wr.vertex(xOffset, thickness + yOffset, distance + zOffset).uv(0, (float) v2).endVertex(); +// wr.vertex(xOffset, -thickness + yOffset, distance + zOffset).uv(1, (float) v2).endVertex(); +// wr.vertex(-startXOffset, -thickness + startYOffset, startZOffset).uv(1, (float) v1).endVertex(); +// } +// Tessellator.getInstance().end(); +// } +// +//} diff --git a/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java b/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java index a121ec5c..14e7b6f4 100644 --- a/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java +++ b/src/main/java/com/direwolf20/mininggadgets/client/screens/ModificationTableScreen.java @@ -5,6 +5,7 @@ import com.direwolf20.mininggadgets.common.items.MiningGadget; import com.direwolf20.mininggadgets.common.items.UpgradeCard; import com.direwolf20.mininggadgets.common.items.upgrade.Upgrade; +import com.direwolf20.mininggadgets.common.items.upgrade.UpgradeTools; import com.direwolf20.mininggadgets.common.network.PacketHandler; import com.direwolf20.mininggadgets.common.network.packets.PacketExtractUpgrade; import com.direwolf20.mininggadgets.common.network.packets.PacketInsertUpgrade; @@ -55,7 +56,7 @@ public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks int relX = (this.width) / 2; int relY = (this.height) / 2; - drawCenteredString(stack, font, ForgeI18n.getPattern(String.format("%s.%s", MiningGadgets.MOD_ID, "text.modification_table")), relX, relY - 105, 0xFFFFFF); + drawCenteredString(stack, font, ForgeI18n.getPattern(String.format("%s.%s", MiningGadgets.MOD_ID, "text.modification_table")), relX, relY - 100, 0xFFFFFF); if (this.container.getUpgradesCache().size() == 0) { String string = ForgeI18n.getPattern(String.format("%s.%s", MiningGadgets.MOD_ID, "text.empty_table_helper")); @@ -102,6 +103,10 @@ public boolean mouseClicked(double mouseXIn, double mouseYIn, int p_231044_5_) { if (!gadget.isEmpty() && gadget.getItem() instanceof MiningGadget && !heldStack.isEmpty() && heldStack.getItem() instanceof UpgradeCard) { if (scrollingUpgrades.isMouseOver(mouseXIn, mouseYIn)) { // Send packet to remove the item from the inventory and add it to the table + if (UpgradeTools.containsUpgrade(gadget, ((UpgradeCard) heldStack.getItem()).getUpgrade())) { + return false; + } + PacketHandler.sendToServer(new PacketInsertUpgrade(this.tePos, heldStack)); playerInventory.setCarried(ItemStack.EMPTY); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java b/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java index fe9a8828..8cb11a8c 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/MiningGadgets.java @@ -36,7 +36,9 @@ public class MiningGadgets public static ItemGroup itemGroup = new ItemGroup(MiningGadgets.MOD_ID) { @Override public ItemStack makeIcon() { - return new ItemStack(ModItems.MININGGADGET.get()); + ItemStack itemStack = new ItemStack(ModItems.MININGGADGET.get()); + itemStack.getOrCreateTag().putInt("energy", Integer.MAX_VALUE); + return itemStack; } }; diff --git a/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java b/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java index 6ae5b37d..5f1db948 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/blocks/RenderBlock.java @@ -4,6 +4,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; import net.minecraft.block.material.PushReaction; import net.minecraft.tileentity.TileEntity; @@ -23,7 +24,7 @@ public class RenderBlock extends Block { public RenderBlock() { super( Properties.of(Material.METAL) - .strength(2.0f) + .strength(50.0F, 1200.0F) .noOcclusion() .noDrops() .isRedstoneConductor((a, b, c) -> false) // @mcp: setOpaque seems to replace isNormalBlock diff --git a/src/main/java/com/direwolf20/mininggadgets/common/collectors/AoeCollector.java b/src/main/java/com/direwolf20/mininggadgets/common/collectors/AoeCollector.java new file mode 100644 index 00000000..67b48f53 --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/common/collectors/AoeCollector.java @@ -0,0 +1,7 @@ +package com.direwolf20.mininggadgets.common.collectors; + +/** + * Collects blocks within an AreaOfEffect + */ +public class AoeCollector { +} diff --git a/src/main/java/com/direwolf20/mininggadgets/common/collectors/ShapelessWalker.java b/src/main/java/com/direwolf20/mininggadgets/common/collectors/ShapelessWalker.java new file mode 100644 index 00000000..cf508fa7 --- /dev/null +++ b/src/main/java/com/direwolf20/mininggadgets/common/collectors/ShapelessWalker.java @@ -0,0 +1,83 @@ +package com.direwolf20.mininggadgets.common.collectors; + +import com.direwolf20.mininggadgets.common.blocks.ModBlocks; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.*; + +// Not used yet +// Provided by LatvianModder with express permission, original code found here https://github.com/FTBTeam/FTB-Ultimine/blob/ea9fc0c812e66c7852e05f6e63ce077bcd48594f/common/src/main/java/com/feed_the_beast/mods/ftbultimine/shape/ShapelessShape.java +public class ShapelessWalker { + public static final BlockPos[] NEIGHBOR_POSITIONS = new BlockPos[26]; + + static { + NEIGHBOR_POSITIONS[0] = new BlockPos(1, 0, 0); + NEIGHBOR_POSITIONS[1] = new BlockPos(-1, 0, 0); + NEIGHBOR_POSITIONS[2] = new BlockPos(0, 0, 1); + NEIGHBOR_POSITIONS[3] = new BlockPos(0, 0, -1); + NEIGHBOR_POSITIONS[4] = new BlockPos(0, 1, 0); + NEIGHBOR_POSITIONS[5] = new BlockPos(0, -1, 0); + + NEIGHBOR_POSITIONS[6] = new BlockPos(1, 0, 1); + NEIGHBOR_POSITIONS[7] = new BlockPos(1, 0, -1); + NEIGHBOR_POSITIONS[8] = new BlockPos(-1, 0, 1); + NEIGHBOR_POSITIONS[9] = new BlockPos(-1, 0, -1); + + NEIGHBOR_POSITIONS[10] = new BlockPos(1, 1, 0); + NEIGHBOR_POSITIONS[11] = new BlockPos(-1, 1, 0); + NEIGHBOR_POSITIONS[12] = new BlockPos(0, 1, 1); + NEIGHBOR_POSITIONS[13] = new BlockPos(0, 1, -1); + + NEIGHBOR_POSITIONS[14] = new BlockPos(1, -1, 0); + NEIGHBOR_POSITIONS[15] = new BlockPos(-1, -1, 0); + NEIGHBOR_POSITIONS[16] = new BlockPos(0, -1, 1); + NEIGHBOR_POSITIONS[17] = new BlockPos(0, -1, -1); + + NEIGHBOR_POSITIONS[18] = new BlockPos(1, 1, 1); + NEIGHBOR_POSITIONS[19] = new BlockPos(1, 1, -1); + NEIGHBOR_POSITIONS[20] = new BlockPos(-1, 1, 1); + NEIGHBOR_POSITIONS[21] = new BlockPos(-1, 1, -1); + + NEIGHBOR_POSITIONS[22] = new BlockPos(1, -1, 1); + NEIGHBOR_POSITIONS[23] = new BlockPos(1, -1, -1); + NEIGHBOR_POSITIONS[24] = new BlockPos(-1, -1, 1); + NEIGHBOR_POSITIONS[25] = new BlockPos(-1, -1, -1); + } + + public List getBlocks(World level, BlockPos pos) { + HashSet known = new HashSet<>(); + this.walk(level, pos, known); + + return new ArrayList<>(known); + } + + private void walk(World level, BlockPos pos, HashSet known) { + Set traversed = new HashSet<>(); + Deque openSet = new ArrayDeque<>(); + openSet.add(pos); + traversed.add(pos); + + while (!openSet.isEmpty()) { + BlockPos ptr = openSet.pop(); + + Block block = level.getBlockState(ptr).getBlock(); + if ((block == Blocks.OAK_LOG || block == ModBlocks.RENDER_BLOCK.get()) && known.add(ptr)) { + System.out.println(block); + if (known.size() >= 60) { + return; + } + + for (BlockPos side : NEIGHBOR_POSITIONS) { + BlockPos offset = ptr.offset(side); + + if (traversed.add(offset)) { + openSet.add(offset); + } + } + } + } + } +} diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java index f93a353b..75bb0380 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorLanguage.java @@ -14,7 +14,9 @@ public GeneratorLanguage(DataGenerator gen) { @Override protected void addTranslations() { add("itemGroup.mininggadgets", "Mining Gadgets"); - addItem(ModItems.MININGGADGET, "Mining Gadget"); + addItem(ModItems.MININGGADGET, "Mining Gadget MK3"); + addItem(ModItems.MININGGADGET_SIMPLE, "Mining Gadget MK1"); + addItem(ModItems.MININGGADGET_FANCY, "Mining Gadget MK2"); addItem(ModItems.UPGRADE_EMPTY, "Blank Upgrade Module"); // This should always match the start of below upgrade names. I use this diff --git a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java index 04a71757..45fa6179 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/data/GeneratorRecipes.java @@ -1,5 +1,7 @@ package com.direwolf20.mininggadgets.common.data; +import static com.direwolf20.mininggadgets.common.items.ModItems.*; + import com.direwolf20.mininggadgets.common.blocks.ModBlocks; import net.minecraft.block.Blocks; import net.minecraft.data.DataGenerator; @@ -11,8 +13,6 @@ import java.util.function.Consumer; -import static com.direwolf20.mininggadgets.common.items.ModItems.*; - public class GeneratorRecipes extends RecipeProvider { public GeneratorRecipes(DataGenerator generator) { super(generator); @@ -27,268 +27,293 @@ public GeneratorRecipes(DataGenerator generator) { @Override protected void buildShapelessRecipes(Consumer consumer) { ShapedRecipeBuilder.shaped(UPGRADE_EMPTY.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('g', Tags.Items.GLASS_PANES) - .define('l', Tags.Items.GEMS_LAPIS) - .define('d', Tags.Items.GEMS_DIAMOND) - .pattern("rlr") - .pattern("dgd") - .pattern("rlr") - .unlockedBy("has_diamonds", has(Tags.Items.GEMS_DIAMOND)) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('g', Tags.Items.GLASS_PANES) + .define('l', Tags.Items.GEMS_LAPIS) + .define('d', Tags.Items.GEMS_DIAMOND) + .pattern("rlr") + .pattern("dgd") + .pattern("rlr") + .unlockedBy("has_diamonds", has(Tags.Items.GEMS_DIAMOND)) + .save(consumer); ShapedRecipeBuilder.shaped(MININGGADGET.get()) - .define('u', UPGRADE_EMPTY.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('i', Tags.Items.INGOTS_IRON) - .define('d', Tags.Items.GEMS_DIAMOND) - .pattern("dii") - .pattern("dur") - .pattern("dii") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('u', UPGRADE_EMPTY.get()) + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('i', Tags.Items.INGOTS_IRON) + .define('d', Tags.Items.GEMS_DIAMOND) + .define('g', Tags.Items.INGOTS_GOLD) + .pattern("dig") + .pattern("dur") + .pattern("dig") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); + + ShapedRecipeBuilder.shaped(MININGGADGET_SIMPLE.get()) + .define('u', UPGRADE_EMPTY.get()) + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('i', Tags.Items.INGOTS_IRON) + .define('d', Tags.Items.GEMS_DIAMOND) + .define('g', Tags.Items.INGOTS_GOLD) + .pattern("dig") + .pattern("dur") + .pattern("dii") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); + + ShapedRecipeBuilder.shaped(MININGGADGET_FANCY.get()) + .define('u', UPGRADE_EMPTY.get()) + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('i', Tags.Items.INGOTS_IRON) + .define('d', Tags.Items.GEMS_DIAMOND) + .define('g', Tags.Items.INGOTS_GOLD) + .pattern("dii") + .pattern("dur") + .pattern("dig") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(ModBlocks.MODIFICATION_TABLE.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', UPGRADE_EMPTY.get()) - .define('i', Tags.Items.INGOTS_IRON) - .pattern("iii") - .pattern("rur") - .pattern("iii") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', UPGRADE_EMPTY.get()) + .define('i', Tags.Items.INGOTS_IRON) + .pattern("iii") + .pattern("rur") + .pattern("iii") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(BATTERY_1.get()) - .define('q', Items.QUARTZ) - .define('u', UPGRADE_EMPTY.get()) - .pattern("qqq") - .pattern("quq") - .pattern("qqq") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('q', Items.QUARTZ) + .define('u', UPGRADE_EMPTY.get()) + .pattern("qqq") + .pattern("quq") + .pattern("qqq") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(BATTERY_2.get()) - .define('q', Items.QUARTZ) - .define('b', Items.QUARTZ_BLOCK) - .define('g', Tags.Items.INGOTS_IRON) - .define('u', BATTERY_1.get()) - .pattern("qbq") - .pattern("gug") - .pattern("qbq") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .unlockedBy("has_battery_1", has(BATTERY_1.get())) - .save(consumer); + .define('q', Items.QUARTZ) + .define('b', Items.QUARTZ_BLOCK) + .define('g', Tags.Items.INGOTS_IRON) + .define('u', BATTERY_1.get()) + .pattern("qbq") + .pattern("gug") + .pattern("qbq") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .unlockedBy("has_battery_1", has(BATTERY_1.get())) + .save(consumer); ShapedRecipeBuilder.shaped(BATTERY_3.get()) - .define('q', Items.QUARTZ) - .define('b', Items.QUARTZ_BLOCK) - .define('g', Tags.Items.INGOTS_GOLD) - .define('u', BATTERY_2.get()) - .pattern("bqb") - .pattern("gug") - .pattern("bqb") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .unlockedBy("has_battery_2", has(BATTERY_2.get())) - .save(consumer); + .define('q', Items.QUARTZ) + .define('b', Items.QUARTZ_BLOCK) + .define('g', Tags.Items.INGOTS_GOLD) + .define('u', BATTERY_2.get()) + .pattern("bqb") + .pattern("gug") + .pattern("bqb") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .unlockedBy("has_battery_2", has(BATTERY_2.get())) + .save(consumer); ShapedRecipeBuilder.shaped(EFFICIENCY_1.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', UPGRADE_EMPTY.get()) - .pattern("rrr") - .pattern("rur") - .pattern("rrr") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', UPGRADE_EMPTY.get()) + .pattern("rrr") + .pattern("rur") + .pattern("rrr") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(EFFICIENCY_2.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', EFFICIENCY_1.get()) - .define('b', Items.REDSTONE_BLOCK) - .pattern("rbr") - .pattern("rur") - .pattern("rbr") - .unlockedBy("has_efficiency_1", has(EFFICIENCY_1.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', EFFICIENCY_1.get()) + .define('b', Items.REDSTONE_BLOCK) + .pattern("rbr") + .pattern("rur") + .pattern("rbr") + .unlockedBy("has_efficiency_1", has(EFFICIENCY_1.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(EFFICIENCY_3.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', EFFICIENCY_2.get()) - .define('b', Items.REDSTONE_BLOCK) - .pattern("rbr") - .pattern("bub") - .pattern("rbr") - .unlockedBy("has_efficiency_2", has(EFFICIENCY_2.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', EFFICIENCY_2.get()) + .define('b', Items.REDSTONE_BLOCK) + .pattern("rbr") + .pattern("bub") + .pattern("rbr") + .unlockedBy("has_efficiency_2", has(EFFICIENCY_2.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(EFFICIENCY_4.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', EFFICIENCY_3.get()) - .define('b', Items.REDSTONE_BLOCK) - .pattern("brb") - .pattern("bub") - .pattern("brb") - .unlockedBy("has_efficiency_3", has(EFFICIENCY_3.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', EFFICIENCY_3.get()) + .define('b', Items.REDSTONE_BLOCK) + .pattern("brb") + .pattern("bub") + .pattern("brb") + .unlockedBy("has_efficiency_3", has(EFFICIENCY_3.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(EFFICIENCY_5.get()) - .define('u', EFFICIENCY_4.get()) - .define('b', Items.REDSTONE_BLOCK) - .pattern("bbb") - .pattern("bub") - .pattern("bbb") - .unlockedBy("has_efficiency_4", has(EFFICIENCY_4.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('u', EFFICIENCY_4.get()) + .define('b', Items.REDSTONE_BLOCK) + .pattern("bbb") + .pattern("bub") + .pattern("bbb") + .unlockedBy("has_efficiency_4", has(EFFICIENCY_4.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(FORTUNE_1.get()) - .define('l', Items.LAPIS_BLOCK) - .define('g', Items.IRON_BLOCK) - .define('u', UPGRADE_EMPTY.get()) - .pattern("lgl") - .pattern("lul") - .pattern("lgl") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_BLOCK) + .define('g', Items.IRON_BLOCK) + .define('u', UPGRADE_EMPTY.get()) + .pattern("lgl") + .pattern("lul") + .pattern("lgl") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(FORTUNE_2.get()) - .define('l', Items.LAPIS_BLOCK) - .define('g', Items.GOLD_BLOCK) - .define('u', FORTUNE_1.get()) - .pattern("lgl") - .pattern("lul") - .pattern("lgl") - .unlockedBy("has_fortune_1", has(FORTUNE_1.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_BLOCK) + .define('g', Items.GOLD_BLOCK) + .define('u', FORTUNE_1.get()) + .pattern("lgl") + .pattern("lul") + .pattern("lgl") + .unlockedBy("has_fortune_1", has(FORTUNE_1.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(FORTUNE_3.get()) - .define('l', Items.LAPIS_BLOCK) - .define('d', Items.DIAMOND) - .define('u', FORTUNE_2.get()) - .pattern("ldl") - .pattern("lul") - .pattern("ldl") - .unlockedBy("has_fortune_2", has(FORTUNE_2.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_BLOCK) + .define('d', Items.DIAMOND) + .define('u', FORTUNE_2.get()) + .pattern("ldl") + .pattern("lul") + .pattern("ldl") + .unlockedBy("has_fortune_2", has(FORTUNE_2.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(RANGE_1.get()) - .define('l', Items.LAPIS_LAZULI) - .define('g', Items.GLASS) - .define('d', Items.DIAMOND) - .define('u', UPGRADE_EMPTY.get()) - .pattern("lgl") - .pattern("dud") - .pattern("lgl") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_LAZULI) + .define('g', Items.GLASS) + .define('d', Items.DIAMOND) + .define('u', UPGRADE_EMPTY.get()) + .pattern("lgl") + .pattern("dud") + .pattern("lgl") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(RANGE_2.get()) - .define('l', Items.LAPIS_LAZULI) - .define('g', Items.GLASS) - .define('e', Items.EMERALD) - .define('u', RANGE_1.get()) - .pattern("lgl") - .pattern("eue") - .pattern("lgl") - .unlockedBy("has_range_1", has(RANGE_1.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_LAZULI) + .define('g', Items.GLASS) + .define('e', Items.EMERALD) + .define('u', RANGE_1.get()) + .pattern("lgl") + .pattern("eue") + .pattern("lgl") + .unlockedBy("has_range_1", has(RANGE_1.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(RANGE_3.get()) - .define('l', Items.LAPIS_BLOCK) - .define('g', Items.GLASS) - .define('d', Items.DIAMOND_BLOCK) - .define('e', Items.EMERALD_BLOCK) - .define('u', RANGE_2.get()) - .pattern("lgl") - .pattern("eud") - .pattern("lgl") - .unlockedBy("has_range_2", has(RANGE_2.get())) - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('l', Items.LAPIS_BLOCK) + .define('g', Items.GLASS) + .define('d', Items.DIAMOND_BLOCK) + .define('e', Items.EMERALD_BLOCK) + .define('u', RANGE_2.get()) + .pattern("lgl") + .pattern("eud") + .pattern("lgl") + .unlockedBy("has_range_2", has(RANGE_2.get())) + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(FREEZING.get()) - .define('s', Items.SNOWBALL) - .define('u', UPGRADE_EMPTY.get()) - .pattern("sss") - .pattern("sus") - .pattern("sss") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('s', Items.SNOWBALL) + .define('u', UPGRADE_EMPTY.get()) + .pattern("sss") + .pattern("sus") + .pattern("sss") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(LIGHT_PLACER.get()) - .define('g', Items.GLOWSTONE_DUST) - .define('b', Items.GLOWSTONE) - .define('r', Items.REDSTONE_LAMP) - .define('a', Items.LANTERN) - .define('u', UPGRADE_EMPTY.get()) - .pattern("ara") - .pattern("bub") - .pattern("grg") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('g', Items.GLOWSTONE_DUST) + .define('b', Items.GLOWSTONE) + .define('r', Items.REDSTONE_LAMP) + .define('a', Items.LANTERN) + .define('u', UPGRADE_EMPTY.get()) + .pattern("ara") + .pattern("bub") + .pattern("grg") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(MAGNET.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', UPGRADE_EMPTY.get()) - .define('i', Tags.Items.INGOTS_IRON) - .define('g', Tags.Items.INGOTS_GOLD) - .pattern("rgr") - .pattern("iui") - .pattern("rgr") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', UPGRADE_EMPTY.get()) + .define('i', Tags.Items.INGOTS_IRON) + .define('g', Tags.Items.INGOTS_GOLD) + .pattern("rgr") + .pattern("iui") + .pattern("rgr") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(SILK.get()) - .define('d', Items.GOLDEN_APPLE) - .define('s', Tags.Items.SLIMEBALLS) - .define('g', Tags.Items.INGOTS_GOLD) - .define('u', UPGRADE_EMPTY.get()) - .pattern("sds") - .pattern("gug") - .pattern("sss") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('d', Items.GOLDEN_APPLE) + .define('s', Tags.Items.SLIMEBALLS) + .define('g', Tags.Items.INGOTS_GOLD) + .define('u', UPGRADE_EMPTY.get()) + .pattern("sds") + .pattern("gug") + .pattern("sss") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(THREE_BY_THREE.get()) - .define('r', Items.REDSTONE_BLOCK) - .define('u', UPGRADE_EMPTY.get()) - .define('d', Items.DIAMOND_BLOCK) - .define('p', Items.DIAMOND_PICKAXE) - .define('e', Tags.Items.ENDER_PEARLS) - .pattern("rdr") - .pattern("eue") - .pattern("rpr") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Items.REDSTONE_BLOCK) + .define('u', UPGRADE_EMPTY.get()) + .define('d', Items.DIAMOND_BLOCK) + .define('p', Items.DIAMOND_PICKAXE) + .define('e', Tags.Items.ENDER_PEARLS) + .pattern("rdr") + .pattern("eue") + .pattern("rpr") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); ShapedRecipeBuilder.shaped(VOID_JUNK.get()) - .define('r', Tags.Items.DUSTS_REDSTONE) - .define('u', UPGRADE_EMPTY.get()) - .define('o', Blocks.OBSIDIAN) - .define('e', Tags.Items.ENDER_PEARLS) - .pattern("ror") - .pattern("eue") - .pattern("ror") - .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) - .save(consumer); + .define('r', Tags.Items.DUSTS_REDSTONE) + .define('u', UPGRADE_EMPTY.get()) + .define('o', Blocks.OBSIDIAN) + .define('e', Tags.Items.ENDER_PEARLS) + .pattern("ror") + .pattern("eue") + .pattern("ror") + .unlockedBy("has_upgrade", has(UPGRADE_EMPTY.get())) + .save(consumer); -// ShapedRecipeBuilder.shapedRecipe(PAVER.get()) -// .key('r', Tags.Items.DUSTS_REDSTONE) -// .key('c', Tags.Items.COBBLESTONE) -// .key('u', UPGRADE_EMPTY.get()) -// .key('g', Tags.Items.NUGGETS_GOLD) -// .key('l', Items.LAVA_BUCKET) -// .key('p', Blocks.PISTON) -// .key('w', Items.WATER_BUCKET) -// .patternLine("rgr") -// .patternLine("cuc") -// .patternLine("lpw") -// .addCriterion("has_upgrade", hasItem(UPGRADE_EMPTY.get())) -// .build(consumer); + // ShapedRecipeBuilder.shapedRecipe(PAVER.get()) + // .key('r', Tags.Items.DUSTS_REDSTONE) + // .key('c', Tags.Items.COBBLESTONE) + // .key('u', UPGRADE_EMPTY.get()) + // .key('g', Tags.Items.NUGGETS_GOLD) + // .key('l', Items.LAVA_BUCKET) + // .key('p', Blocks.PISTON) + // .key('w', Items.WATER_BUCKET) + // .patternLine("rgr") + // .patternLine("cuc") + // .patternLine("lpw") + // .addCriterion("has_upgrade", hasItem(UPGRADE_EMPTY.get())) + // .build(consumer); } } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java index 536cda5c..38e226e8 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/MiningGadget.java @@ -502,7 +502,13 @@ private static float getHardness(List coords, PlayerEntity player, int int hasteLevel = hasteEffect.getAmplifier() + 1; toolSpeed = toolSpeed + (toolSpeed * ((hasteLevel * 20f) / 100)); } - World world = player.getCommandSenderWorld(); + + EffectInstance miningFatigue = player.getEffect(Effects.DIG_SLOWDOWN); + if (miningFatigue != null) { + toolSpeed = toolSpeed / 3f; + } + + World world = player.level; for (BlockPos coord : coords) { BlockState state = world.getBlockState(coord); float temphardness = state.getDestroySpeed(world, coord); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java b/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java index addec753..ba4f1b81 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/items/ModItems.java @@ -18,6 +18,8 @@ public class ModItems { public static final DeferredRegister UPGRADE_ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MiningGadgets.MOD_ID); // Items + public static final RegistryObject MININGGADGET_SIMPLE = ITEMS.register("mininggadget_simple", MiningGadget::new); + public static final RegistryObject MININGGADGET_FANCY = ITEMS.register("mininggadget_fancy", MiningGadget::new); public static final RegistryObject MININGGADGET = ITEMS.register("mininggadget", MiningGadget::new); // Block items @@ -28,26 +30,26 @@ public class ModItems { * Upgrades are a bit ugly.. Soz * This one is actually kinda */ - public static final RegistryObject UPGRADE_EMPTY = UPGRADE_ITEMS.register("upgrade_empty", Upgrade.EMPTY::getCard); - public static final RegistryObject SILK = UPGRADE_ITEMS.register("upgrade_silk", Upgrade.SILK::getCard); - public static final RegistryObject VOID_JUNK = UPGRADE_ITEMS.register("upgrade_void_junk", Upgrade.VOID_JUNK::getCard); - public static final RegistryObject MAGNET = UPGRADE_ITEMS.register("upgrade_magnet", Upgrade.MAGNET::getCard); - public static final RegistryObject THREE_BY_THREE = UPGRADE_ITEMS.register("upgrade_three_by_three", Upgrade.THREE_BY_THREE::getCard); - public static final RegistryObject LIGHT_PLACER = UPGRADE_ITEMS.register("upgrade_light_placer", Upgrade.LIGHT_PLACER::getCard); - public static final RegistryObject FREEZING = UPGRADE_ITEMS.register("upgrade_freezing", Upgrade.FREEZING::getCard); - public static final RegistryObject FORTUNE_1 = UPGRADE_ITEMS.register("upgrade_fortune_1", Upgrade.FORTUNE_1::getCard); - public static final RegistryObject FORTUNE_2 = UPGRADE_ITEMS.register("upgrade_fortune_2", Upgrade.FORTUNE_2::getCard); - public static final RegistryObject FORTUNE_3 = UPGRADE_ITEMS.register("upgrade_fortune_3", Upgrade.FORTUNE_3::getCard); - public static final RegistryObject RANGE_1 = UPGRADE_ITEMS.register("upgrade_range_1", Upgrade.RANGE_1::getCard); - public static final RegistryObject RANGE_2 = UPGRADE_ITEMS.register("upgrade_range_2", Upgrade.RANGE_2::getCard); - public static final RegistryObject RANGE_3 = UPGRADE_ITEMS.register("upgrade_range_3", Upgrade.RANGE_3::getCard); - public static final RegistryObject BATTERY_1 = UPGRADE_ITEMS.register("upgrade_battery_1", Upgrade.BATTERY_1::getCard); - public static final RegistryObject BATTERY_2 = UPGRADE_ITEMS.register("upgrade_battery_2", Upgrade.BATTERY_2::getCard); - public static final RegistryObject BATTERY_3 = UPGRADE_ITEMS.register("upgrade_battery_3", Upgrade.BATTERY_3::getCard); - public static final RegistryObject EFFICIENCY_1 = UPGRADE_ITEMS.register("upgrade_efficiency_1", Upgrade.EFFICIENCY_1::getCard); - public static final RegistryObject EFFICIENCY_2 = UPGRADE_ITEMS.register("upgrade_efficiency_2", Upgrade.EFFICIENCY_2::getCard); - public static final RegistryObject EFFICIENCY_3 = UPGRADE_ITEMS.register("upgrade_efficiency_3", Upgrade.EFFICIENCY_3::getCard); - public static final RegistryObject EFFICIENCY_4 = UPGRADE_ITEMS.register("upgrade_efficiency_4", Upgrade.EFFICIENCY_4::getCard); - public static final RegistryObject EFFICIENCY_5 = UPGRADE_ITEMS.register("upgrade_efficiency_5", Upgrade.EFFICIENCY_5::getCard); -// public static final RegistryObject PAVER = UPGRADE_ITEMS.register("upgrade_paver", Upgrade.PAVER::getCard); + public static final RegistryObject UPGRADE_EMPTY = UPGRADE_ITEMS.register("upgrade_empty", Upgrade.EMPTY::getCard); + public static final RegistryObject SILK = UPGRADE_ITEMS.register("upgrade_silk", Upgrade.SILK::getCard); + public static final RegistryObject VOID_JUNK = UPGRADE_ITEMS.register("upgrade_void_junk", Upgrade.VOID_JUNK::getCard); + public static final RegistryObject MAGNET = UPGRADE_ITEMS.register("upgrade_magnet", Upgrade.MAGNET::getCard); + public static final RegistryObject THREE_BY_THREE = UPGRADE_ITEMS.register("upgrade_three_by_three", Upgrade.THREE_BY_THREE::getCard); + public static final RegistryObject LIGHT_PLACER = UPGRADE_ITEMS.register("upgrade_light_placer", Upgrade.LIGHT_PLACER::getCard); + public static final RegistryObject FREEZING = UPGRADE_ITEMS.register("upgrade_freezing", Upgrade.FREEZING::getCard); + public static final RegistryObject FORTUNE_1 = UPGRADE_ITEMS.register("upgrade_fortune_1", Upgrade.FORTUNE_1::getCard); + public static final RegistryObject FORTUNE_2 = UPGRADE_ITEMS.register("upgrade_fortune_2", Upgrade.FORTUNE_2::getCard); + public static final RegistryObject FORTUNE_3 = UPGRADE_ITEMS.register("upgrade_fortune_3", Upgrade.FORTUNE_3::getCard); + public static final RegistryObject RANGE_1 = UPGRADE_ITEMS.register("upgrade_range_1", Upgrade.RANGE_1::getCard); + public static final RegistryObject RANGE_2 = UPGRADE_ITEMS.register("upgrade_range_2", Upgrade.RANGE_2::getCard); + public static final RegistryObject RANGE_3 = UPGRADE_ITEMS.register("upgrade_range_3", Upgrade.RANGE_3::getCard); + public static final RegistryObject BATTERY_1 = UPGRADE_ITEMS.register("upgrade_battery_1", Upgrade.BATTERY_1::getCard); + public static final RegistryObject BATTERY_2 = UPGRADE_ITEMS.register("upgrade_battery_2", Upgrade.BATTERY_2::getCard); + public static final RegistryObject BATTERY_3 = UPGRADE_ITEMS.register("upgrade_battery_3", Upgrade.BATTERY_3::getCard); + public static final RegistryObject EFFICIENCY_1 = UPGRADE_ITEMS.register("upgrade_efficiency_1", Upgrade.EFFICIENCY_1::getCard); + public static final RegistryObject EFFICIENCY_2 = UPGRADE_ITEMS.register("upgrade_efficiency_2", Upgrade.EFFICIENCY_2::getCard); + public static final RegistryObject EFFICIENCY_3 = UPGRADE_ITEMS.register("upgrade_efficiency_3", Upgrade.EFFICIENCY_3::getCard); + public static final RegistryObject EFFICIENCY_4 = UPGRADE_ITEMS.register("upgrade_efficiency_4", Upgrade.EFFICIENCY_4::getCard); + public static final RegistryObject EFFICIENCY_5 = UPGRADE_ITEMS.register("upgrade_efficiency_5", Upgrade.EFFICIENCY_5::getCard); + // public static final RegistryObject PAVER = UPGRADE_ITEMS.register("upgrade_paver", Upgrade.PAVER::getCard); } diff --git a/src/main/java/com/direwolf20/mininggadgets/common/network/packets/PacketInsertUpgrade.java b/src/main/java/com/direwolf20/mininggadgets/common/network/packets/PacketInsertUpgrade.java index 27068883..c5ac2fdf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/network/packets/PacketInsertUpgrade.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/network/packets/PacketInsertUpgrade.java @@ -49,8 +49,9 @@ public void handler(Supplier ctx) { return; } - ModificationTableCommands.insertButton(container, this.upgrade); - player.inventory.setCarried(ItemStack.EMPTY); + if (ModificationTableCommands.insertButton(container, this.upgrade)) { + player.inventory.setCarried(ItemStack.EMPTY); + } }); ctx.get().setPacketHandled(true); diff --git a/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java b/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java index ded7f0d5..8c4e2dbf 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/tiles/ModificationTableTileEntity.java @@ -1,8 +1,9 @@ package com.direwolf20.mininggadgets.common.tiles; +import static com.direwolf20.mininggadgets.common.blocks.ModBlocks.MODIFICATIONTABLE_TILE; + import com.direwolf20.mininggadgets.common.containers.ModificationTableContainer; import com.direwolf20.mininggadgets.common.items.MiningGadget; -import com.direwolf20.mininggadgets.common.items.UpgradeCard; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; @@ -10,6 +11,8 @@ 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.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.text.ITextComponent; @@ -24,16 +27,30 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import static com.direwolf20.mininggadgets.common.blocks.ModBlocks.MODIFICATIONTABLE_TILE; - public class ModificationTableTileEntity extends TileEntity implements INamedContainerProvider { - - private LazyOptional handler = LazyOptional.of(this::createHandler); + public final LazyOptional handler = LazyOptional.of(this::createHandler); public ModificationTableTileEntity() { super(MODIFICATIONTABLE_TILE.get()); } + @Override + public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) { + this.load(this.getBlockState(), packet.getTag()); + } + + @Override + public SUpdateTileEntityPacket getUpdatePacket() { + CompoundNBT nbt = new CompoundNBT(); + this.save(nbt); + return new SUpdateTileEntityPacket(this.getBlockPos(), 0, nbt); + } + + @Override + public CompoundNBT getUpdateTag() { + return this.save(new CompoundNBT()); + } + @Override public void load(BlockState state, CompoundNBT tag) { CompoundNBT invTag = tag.getCompound("inv"); @@ -60,7 +77,6 @@ protected void onContentsChanged(int slot) { @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { if (slot == 0 && stack.getItem() instanceof MiningGadget) return true; - if (slot == 1 && stack.getItem() instanceof UpgradeCard) return true; return false; } }; diff --git a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java index d8d1da15..9902a2e2 100644 --- a/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java +++ b/src/main/java/com/direwolf20/mininggadgets/common/tiles/RenderBlockTileEntity.java @@ -1,5 +1,7 @@ package com.direwolf20.mininggadgets.common.tiles; +import static com.direwolf20.mininggadgets.common.blocks.ModBlocks.RENDERBLOCK_TILE; + import com.direwolf20.mininggadgets.client.particles.laserparticle.LaserParticleData; import com.direwolf20.mininggadgets.common.Config; import com.direwolf20.mininggadgets.common.events.ServerTickHandler; @@ -21,6 +23,7 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SUpdateTileEntityPacket; +import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.stats.Stats; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.TileEntity; @@ -38,18 +41,15 @@ import java.util.Random; import java.util.UUID; -import static com.direwolf20.mininggadgets.common.blocks.ModBlocks.RENDERBLOCK_TILE; - public class RenderBlockTileEntity extends TileEntity implements ITickableTileEntity { + private final Random rand = new Random(); private BlockState renderBlock; - private int priorDurability = 9999; private int clientPrevDurability; private int clientDurability; private int durability; private UUID playerUUID; private int originalDurability; - private final Random rand = new Random(); private int ticksSinceMine = 0; private List gadgetUpgrades; private List gadgetFilters; @@ -66,8 +66,9 @@ public RenderBlockTileEntity() { public static boolean blockAllowed(List drops, List filters, boolean isWhiteList) { boolean blockAllowed = false; for (ItemStack dropStack : drops) { - if (filters.size() == 0) + if (filters.size() == 0) { return true; + } boolean contains = false; for (ItemStack filter : filters) { @@ -79,23 +80,24 @@ public static boolean blockAllowed(List drops, List filter blockAllowed = (isWhiteList && contains) || (!isWhiteList && !contains); - if (blockAllowed) + if (blockAllowed) { break; + } } return blockAllowed; } public BlockState getRenderBlock() { - return renderBlock; + return this.renderBlock; } public void setRenderBlock(BlockState state) { - renderBlock = state; + this.renderBlock = state; } public MiningProperties.BreakTypes getBreakType() { - return breakType; + return this.breakType; } public void setBreakType(MiningProperties.BreakTypes breakType) { @@ -103,25 +105,26 @@ public void setBreakType(MiningProperties.BreakTypes breakType) { } public void justSetDurability(int durability) { - priorDurability = this.durability; + this.priorDurability = this.durability; this.durability = durability; //System.out.println("Got:"+ " Prior: " + priorDurability + " Dur: " + durability); } public void setDurability(int dur, ItemStack stack) { - ticksSinceMine = 0; - if (durability != 0) - priorDurability = durability; - durability = dur; + this.ticksSinceMine = 0; + if (this.durability != 0) { + this.priorDurability = this.durability; + } + this.durability = dur; if (dur <= 0) { - removeBlock(); - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.FREEZING)) { - freeze(stack); + this.removeBlock(); + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.FREEZING)) { + this.freeze(stack); } } - if (!(level.isClientSide)) { - setChanged(); - ServerTickHandler.addToList(worldPosition, durability, level); + if (!(this.level.isClientSide)) { + this.setChanged(); + ServerTickHandler.addToList(this.worldPosition, this.durability, this.level); //PacketHandler.sendToAll(new PacketDurabilitySync(pos, dur), world); //System.out.println("Sent: "+ " Prior: " + priorDurability + " Dur: " + dur); } @@ -136,14 +139,15 @@ private void freeze(ItemStack stack) { } for (Direction side : Direction.values()) { - BlockPos sidePos = worldPosition.relative(side); - FluidState state = level.getFluidState(sidePos); + BlockPos sidePos = this.worldPosition.relative(side); + FluidState state = this.level.getFluidState(sidePos); + if (state.getType().isSame(Fluids.LAVA) && state.getType().isSource(state)) { - energy -= this.replaceBlockWithAlternative(level, sidePos, Blocks.OBSIDIAN.defaultBlockState(), stack, freezeCost, energy); + energy -= this.replaceBlockWithAlternative(this.level, sidePos, Blocks.OBSIDIAN.defaultBlockState(), stack, freezeCost, energy); } else if (state.getType().isSame(Fluids.WATER) && state.getType().isSource(state)) { - energy -= this.replaceBlockWithAlternative(level, sidePos, Blocks.PACKED_ICE.defaultBlockState(), stack, freezeCost, energy); + energy -= this.replaceBlockWithAlternative(this.level, sidePos, Blocks.PACKED_ICE.defaultBlockState(), stack, freezeCost, energy); } else if ((state.getType().isSame(Fluids.WATER) || state.getType().isSame(Fluids.LAVA)) && !state.getType().isSource(state)) { - energy -= this.replaceBlockWithAlternative(level, sidePos, Blocks.COBBLESTONE.defaultBlockState(), stack, freezeCost, energy); + energy -= this.replaceBlockWithAlternative(this.level, sidePos, Blocks.COBBLESTONE.defaultBlockState(), stack, freezeCost, energy); } } } @@ -154,32 +158,42 @@ private int replaceBlockWithAlternative(World world, BlockPos pos, BlockState st } stack.getCapability(CapabilityEnergy.ENERGY).ifPresent(e -> e.receiveEnergy(costOfOperation, false)); + + // If the block is just water logged, remove the fluid + BlockState blockState = world.getBlockState(pos); + if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED) && world.getBlockEntity(pos) == null) { + world.setBlockAndUpdate(pos, blockState.setValue(BlockStateProperties.WATERLOGGED, false)); + return costOfOperation; + } + world.setBlockAndUpdate(pos, state); return costOfOperation; } public void spawnParticle() { - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.MAGNET) && originalDurability > 0) { - int PartCount = 20 / originalDurability; - if (PartCount <= 1) PartCount = 1; + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.MAGNET) && this.originalDurability > 0) { + int PartCount = 20 / this.originalDurability; + if (PartCount <= 1) { + PartCount = 1; + } for (int i = 0; i <= PartCount; i++) { - double randomPartSize = 0.125 + rand.nextDouble() * 0.5; - double randomX = rand.nextDouble(); - double randomY = rand.nextDouble(); - double randomZ = rand.nextDouble(); + double randomPartSize = 0.125 + this.rand.nextDouble() * 0.5; + double randomX = this.rand.nextDouble(); + double randomY = this.rand.nextDouble(); + double randomZ = this.rand.nextDouble(); - LaserParticleData data = LaserParticleData.laserparticle(renderBlock, (float) randomPartSize, 1f, 1f, 1f, 200); - getLevel().addParticle(data, this.getBlockPos().getX() + randomX, this.getBlockPos().getY() + randomY, this.getBlockPos().getZ() + randomZ, 0, 0.0f, 0); + LaserParticleData data = LaserParticleData.laserparticle(this.renderBlock, (float) randomPartSize, 1f, 1f, 1f, 200); + this.getLevel().addParticle(data, this.getBlockPos().getX() + randomX, this.getBlockPos().getY() + randomY, this.getBlockPos().getZ() + randomZ, 0, 0.0f, 0); } } } public int getDurability() { - return durability; + return this.durability; } public int getOriginalDurability() { - return originalDurability; + return this.originalDurability; } public void setOriginalDurability(int originalDurability) { @@ -187,10 +201,11 @@ public void setOriginalDurability(int originalDurability) { } public PlayerEntity getPlayer() { - if (getLevel() == null) + if (this.getLevel() == null) { return null; + } - return this.getLevel().getPlayerByUUID(playerUUID); + return this.getLevel().getPlayerByUUID(this.playerUUID); } public void setPlayer(PlayerEntity player) { @@ -202,7 +217,7 @@ public UUID getPlayerUUID() { } public int getTicksSinceMine() { - return ticksSinceMine; + return this.ticksSinceMine; } public void setTicksSinceMine(int ticksSinceMine) { @@ -210,7 +225,7 @@ public void setTicksSinceMine(int ticksSinceMine) { } public int getPriorDurability() { - return priorDurability; + return this.priorDurability; } public void setPriorDurability(int priorDurability) { @@ -218,20 +233,21 @@ public void setPriorDurability(int priorDurability) { } public int getClientDurability() { - return clientDurability; + return this.clientDurability; } public void setClientDurability(int clientDurability) { - if (this.durability == 0) + if (this.durability == 0) { this.clientPrevDurability = clientDurability; - else + } else { this.clientPrevDurability = this.durability; + } this.clientDurability = clientDurability; - packetReceived = true; + this.packetReceived = true; } public List getGadgetUpgrades() { - return gadgetUpgrades; + return this.gadgetUpgrades; } public void setGadgetUpgrades(List gadgetUpgrades) { @@ -239,7 +255,7 @@ public void setGadgetUpgrades(List gadgetUpgrades) { } public List getGadgetFilters() { - return gadgetFilters; + return this.gadgetFilters; } public void setGadgetFilters(List gadgetFilters) { @@ -247,7 +263,7 @@ public void setGadgetFilters(List gadgetFilters) { } public boolean isGadgetIsWhitelist() { - return gadgetIsWhitelist; + return this.gadgetIsWhitelist; } public void setGadgetIsWhitelist(boolean gadgetIsWhitelist) { @@ -257,73 +273,77 @@ public void setGadgetIsWhitelist(boolean gadgetIsWhitelist) { @Override public SUpdateTileEntityPacket getUpdatePacket() { // Vanilla uses the type parameter to indicate which type of tile entity (command block, skull, or beacon?) is receiving the packet, but it seems like Forge has overridden this behavior - return new SUpdateTileEntityPacket(worldPosition, 0, getUpdateTag()); + return new SUpdateTileEntityPacket(this.worldPosition, 0, this.getUpdateTag()); } @Override public void handleUpdateTag(BlockState state, CompoundNBT tag) { - load(state, tag); + this.load(state, tag); } @Override public CompoundNBT getUpdateTag() { - return save(new CompoundNBT()); + return this.save(new CompoundNBT()); } @Override public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) { - load(this.getBlockState(), pkt.getTag()); + this.load(this.getBlockState(), pkt.getTag()); } public void markDirtyClient() { - setChanged(); - if (getLevel() != null) { - BlockState state = getLevel().getBlockState(getBlockPos()); - getLevel().sendBlockUpdated(getBlockPos(), state, state, 3); + this.setChanged(); + if (this.getLevel() != null) { + BlockState state = this.getLevel().getBlockState(this.getBlockPos()); + this.getLevel().sendBlockUpdated(this.getBlockPos(), state, state, 3); } } @Override public void load(BlockState state, CompoundNBT tag) { super.load(state, tag); - renderBlock = NBTUtil.readBlockState(tag.getCompound("renderBlock")); - originalDurability = tag.getInt("originalDurability"); - priorDurability = tag.getInt("priorDurability"); - durability = tag.getInt("durability"); - ticksSinceMine = tag.getInt("ticksSinceMine"); - playerUUID = tag.getUUID("playerUUID"); - gadgetUpgrades = UpgradeTools.getUpgradesFromTag(tag); - breakType = MiningProperties.BreakTypes.values()[tag.getByte("breakType")]; - gadgetFilters = MiningProperties.deserializeItemStackList(tag.getCompound("gadgetFilters")); - gadgetIsWhitelist = tag.getBoolean("gadgetIsWhitelist"); - blockAllowed = tag.getBoolean("blockAllowed"); + this.renderBlock = NBTUtil.readBlockState(tag.getCompound("renderBlock")); + this.originalDurability = tag.getInt("originalDurability"); + this.priorDurability = tag.getInt("priorDurability"); + this.durability = tag.getInt("durability"); + this.ticksSinceMine = tag.getInt("ticksSinceMine"); + this.playerUUID = tag.getUUID("playerUUID"); + this.gadgetUpgrades = UpgradeTools.getUpgradesFromTag(tag); + this.breakType = MiningProperties.BreakTypes.values()[tag.getByte("breakType")]; + this.gadgetFilters = MiningProperties.deserializeItemStackList(tag.getCompound("gadgetFilters")); + this.gadgetIsWhitelist = tag.getBoolean("gadgetIsWhitelist"); + this.blockAllowed = tag.getBoolean("blockAllowed"); } @Override public CompoundNBT save(CompoundNBT tag) { - if (renderBlock != null) - tag.put("renderBlock", NBTUtil.writeBlockState(renderBlock)); - tag.putInt("originalDurability", originalDurability); - tag.putInt("priorDurability", priorDurability); - tag.putInt("durability", durability); - tag.putInt("ticksSinceMine", ticksSinceMine); - if (playerUUID != null) - tag.putUUID("playerUUID", playerUUID); - tag.put("upgrades", UpgradeTools.setUpgradesNBT(gadgetUpgrades).getList("upgrades", Constants.NBT.TAG_COMPOUND)); - tag.putByte("breakType", (byte) breakType.ordinal()); - tag.put("gadgetFilters", MiningProperties.serializeItemStackList(getGadgetFilters())); - tag.putBoolean("gadgetIsWhitelist", isGadgetIsWhitelist()); - tag.putBoolean("blockAllowed", blockAllowed); + if (this.renderBlock != null) { + tag.put("renderBlock", NBTUtil.writeBlockState(this.renderBlock)); + } + tag.putInt("originalDurability", this.originalDurability); + tag.putInt("priorDurability", this.priorDurability); + tag.putInt("durability", this.durability); + tag.putInt("ticksSinceMine", this.ticksSinceMine); + if (this.playerUUID != null) { + tag.putUUID("playerUUID", this.playerUUID); + } + tag.put("upgrades", UpgradeTools.setUpgradesNBT(this.gadgetUpgrades).getList("upgrades", Constants.NBT.TAG_COMPOUND)); + tag.putByte("breakType", (byte) this.breakType.ordinal()); + tag.put("gadgetFilters", MiningProperties.serializeItemStackList(this.getGadgetFilters())); + tag.putBoolean("gadgetIsWhitelist", this.isGadgetIsWhitelist()); + tag.putBoolean("blockAllowed", this.blockAllowed); return super.save(tag); } private void removeBlock() { - if (level == null || level.isClientSide || playerUUID == null) + if (this.level == null || this.level.isClientSide || this.playerUUID == null) { return; + } - PlayerEntity player = level.getPlayerByUUID(playerUUID); - if (player == null) + PlayerEntity player = this.level.getPlayerByUUID(this.playerUUID); + if (player == null) { return; + } int silk = 0; int fortune = 0; @@ -331,166 +351,178 @@ private void removeBlock() { ItemStack tempTool = new ItemStack(ModItems.MININGGADGET.get()); // If silk is in the upgrades, apply it without a tier. - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.SILK)) { + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.SILK)) { tempTool.enchant(Enchantments.SILK_TOUCH, 1); silk = 1; } // FORTUNE_1 is eval'd against the basename so this'll support all fortune upgrades - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1)) { - Optional upgrade = UpgradeTools.getUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1); + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1)) { + Optional upgrade = UpgradeTools.getUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1); if (upgrade.isPresent()) { fortune = upgrade.get().getTier(); tempTool.enchant(Enchantments.BLOCK_FORTUNE, fortune); } } - List drops = Block.getDrops(renderBlock, (ServerWorld) level, this.worldPosition, null, player, tempTool); + List drops = Block.getDrops(this.renderBlock, (ServerWorld) this.level, this.worldPosition, null, player, tempTool); - if (blockAllowed) { - int exp = renderBlock.getExpDrop(level, worldPosition, fortune, silk); - boolean magnetMode = (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.MAGNET)); + if (this.blockAllowed) { + int exp = this.renderBlock.getExpDrop(this.level, this.worldPosition, fortune, silk); + boolean magnetMode = (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.MAGNET)); for (ItemStack drop : drops) { if (drop != null) { if (magnetMode) { - int wasPickedUp = ForgeEventFactory.onItemPickup(new ItemEntity(level, worldPosition.getX(), worldPosition.getY(), worldPosition.getZ(), drop), player); + int wasPickedUp = ForgeEventFactory.onItemPickup(new ItemEntity(this.level, this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ(), drop), player); // 1 = someone allowed the event meaning it's handled, // -1 = someone blocked the event and thus we shouldn't drop it nor insert it // 0 = no body captured the event and we should handle it by hand. if (wasPickedUp == 0) { - if (!player.addItem(drop)) - Block.popResource(level, worldPosition, drop); + if (!player.addItem(drop)) { + Block.popResource(this.level, this.worldPosition, drop); + } } } else { - Block.popResource(level, worldPosition, drop); + Block.popResource(this.level, this.worldPosition, drop); } } } if (magnetMode) { - if (exp > 0) + if (exp > 0) { player.giveExperiencePoints(exp); + } } else { - if (exp > 0) - renderBlock.getBlock().popExperience((ServerWorld) level, worldPosition, exp); + if (exp > 0) { + this.renderBlock.getBlock().popExperience((ServerWorld) this.level, this.worldPosition, exp); + } } - renderBlock.spawnAfterBreak((ServerWorld) level, worldPosition, tempTool); // Fixes silver fish basically... + this.renderBlock.spawnAfterBreak((ServerWorld) this.level, this.worldPosition, tempTool); // Fixes silver fish basically... } -// BlockState underState = world.getBlockState(this.pos.down()); + // BlockState underState = world.getBlockState(this.pos.down()); + this.level.removeBlockEntity(this.worldPosition); + this.level.setBlockAndUpdate(this.worldPosition, Blocks.AIR.defaultBlockState()); - level.removeBlockEntity(this.worldPosition); - level.setBlockAndUpdate(this.worldPosition, Blocks.AIR.defaultBlockState()); - -// if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.PAVER)) { -// if (this.pos.getY() <= player.getPosY() && underState == Blocks.AIR.getDefaultState()) { -// world.setBlockState(this.pos.down(), Blocks.COBBLESTONE.getDefaultState()); -// } -// } + // if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.PAVER)) { + // if (this.pos.getY() <= player.getPosY() && underState == Blocks.AIR.getDefaultState()) { + // world.setBlockState(this.pos.down(), Blocks.COBBLESTONE.getDefaultState()); + // } + // } // Add to the break stats - player.awardStat(Stats.BLOCK_MINED.get(renderBlock.getBlock())); + player.awardStat(Stats.BLOCK_MINED.get(this.renderBlock.getBlock())); // Handle special cases - if (SpecialBlockActions.getRegister().containsKey(renderBlock.getBlock())) - SpecialBlockActions.getRegister().get(renderBlock.getBlock()).accept(level, worldPosition, renderBlock); + if (SpecialBlockActions.getRegister().containsKey(this.renderBlock.getBlock())) { + SpecialBlockActions.getRegister().get(this.renderBlock.getBlock()).accept(this.level, this.worldPosition, this.renderBlock); + } } private void resetBlock() { - if (level == null) + if (this.level == null) { return; + } - if (!level.isClientSide) { - if (renderBlock != null) - level.setBlockAndUpdate(this.worldPosition, renderBlock); - else - level.setBlockAndUpdate(this.worldPosition, Blocks.AIR.defaultBlockState()); + if (!this.level.isClientSide) { + if (this.renderBlock != null) { + this.level.setBlockAndUpdate(this.worldPosition, this.renderBlock); + } else { + this.level.setBlockAndUpdate(this.worldPosition, Blocks.AIR.defaultBlockState()); + } } } @Override public void tick() { - totalAge++; + this.totalAge++; //Client and server - spawn a 'block break' particle if the player is actively mining - if (ticksSinceMine == 0) { - spawnParticle(); + if (this.ticksSinceMine == 0) { + this.spawnParticle(); } //Client only - if (level.isClientSide) { + if (this.level.isClientSide) { //Update ticks since last mine on client side for particle renders - if (playerUUID != null) { - if (getPlayer() != null && !getPlayer().isUsingItem()) ticksSinceMine++; - else ticksSinceMine = 0; + if (this.playerUUID != null) { + if (this.getPlayer() != null && !this.getPlayer().isUsingItem()) { + this.ticksSinceMine++; + } else { + this.ticksSinceMine = 0; + } } //The packet with new durability arrives between ticks. Update it on tick. - if (packetReceived) { + if (this.packetReceived) { //System.out.println("PreChange: " + this.durability + ":" + this.priorDurability); this.priorDurability = this.durability; this.durability = this.clientDurability; //System.out.println("PostChange: " + this.durability + ":" + this.priorDurability); - packetReceived = false; + this.packetReceived = false; } else { - if (durability != 0) + if (this.durability != 0) { this.priorDurability = this.durability; + } } } //Server Only - if (!level.isClientSide) { - if (ticksSinceMine == 1) { + if (!this.level.isClientSide) { + if (this.ticksSinceMine == 1) { //Immediately after player stops mining, stability the shrinking effects and notify players - priorDurability = durability; - ServerTickHandler.addToList(worldPosition, durability, level); + this.priorDurability = this.durability; + ServerTickHandler.addToList(this.worldPosition, this.durability, this.level); } - if (ticksSinceMine >= 10) { + if (this.ticksSinceMine >= 10) { //After half a second, start 'regrowing' blocks that haven't been mined. - priorDurability = durability; - durability++; - ServerTickHandler.addToList(worldPosition, durability, level); + this.priorDurability = this.durability; + this.durability++; + ServerTickHandler.addToList(this.worldPosition, this.durability, this.level); } - if (durability >= originalDurability) { + if (this.durability >= this.originalDurability) { //Once we reach the original durability value set the block back to its original blockstate. - resetBlock(); + this.resetBlock(); } - ticksSinceMine++; + this.ticksSinceMine++; } } public void setBlockAllowed() { - if (!UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.VOID_JUNK)) { + if (!UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.VOID_JUNK)) { this.blockAllowed = true; return; } - PlayerEntity player = level.getPlayerByUUID(playerUUID); - if (player == null) return; + PlayerEntity player = this.level.getPlayerByUUID(this.playerUUID); + if (player == null) { + return; + } int silk = 0; int fortune = 0; ItemStack tempTool = new ItemStack(ModItems.MININGGADGET.get()); // If silk is in the upgrades, apply it without a tier. - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.SILK)) { + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.SILK)) { tempTool.enchant(Enchantments.SILK_TOUCH, 1); silk = 1; } // FORTUNE_1 is eval'd against the basename so this'll support all fortune upgrades - if (UpgradeTools.containsActiveUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1)) { - Optional upgrade = UpgradeTools.getUpgradeFromList(gadgetUpgrades, Upgrade.FORTUNE_1); + if (UpgradeTools.containsActiveUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1)) { + Optional upgrade = UpgradeTools.getUpgradeFromList(this.gadgetUpgrades, Upgrade.FORTUNE_1); if (upgrade.isPresent()) { fortune = upgrade.get().getTier(); tempTool.enchant(Enchantments.BLOCK_FORTUNE, fortune); } } - List drops = Block.getDrops(renderBlock, (ServerWorld) level, this.worldPosition, null, player, tempTool); + List drops = Block.getDrops(this.renderBlock, (ServerWorld) this.level, this.worldPosition, null, player, tempTool); - this.blockAllowed = blockAllowed(drops, getGadgetFilters(), isGadgetIsWhitelist()); + this.blockAllowed = blockAllowed(drops, this.getGadgetFilters(), this.isGadgetIsWhitelist()); } public boolean getBlockAllowed() { - return blockAllowed; + return this.blockAllowed; } + } diff --git a/src/main/resources/assets/mininggadgets/models/item/mininggadget_2.json b/src/main/resources/assets/mininggadgets/models/item/mininggadget_fancy.json similarity index 100% rename from src/main/resources/assets/mininggadgets/models/item/mininggadget_2.json rename to src/main/resources/assets/mininggadgets/models/item/mininggadget_fancy.json diff --git a/src/main/resources/assets/mininggadgets/models/item/mininggadget_3.json b/src/main/resources/assets/mininggadgets/models/item/mininggadget_simple.json similarity index 100% rename from src/main/resources/assets/mininggadgets/models/item/mininggadget_3.json rename to src/main/resources/assets/mininggadgets/models/item/mininggadget_simple.json diff --git a/update.json b/update.json index 9433b8a4..a9958f1e 100644 --- a/update.json +++ b/update.json @@ -1,5 +1,8 @@ { "homepage": "https://github.com/Direwolf20-MC/MiningGadgets", + "1.16.5": { + "1.7.5": "Changelog: https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md" + }, "1.16.4": { "1.7.1": "Changelog: https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md", "1.7.0": "Changelog: https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md" @@ -32,6 +35,8 @@ "1.0.0": "Changelog: https://github.com/Direwolf20-MC/MiningGadgets/blob/master/CHANGELOG.md" }, "promos": { + "1.16.5-latest": "1.7.5", + "1.16.5-recommended": "1.7.5", "1.16.4-latest": "1.7.1", "1.16.4-recommended": "1.7.1", "1.16.3-latest": "1.6.0",