diff --git a/.gitattributes b/.gitattributes index cc5dfffec..5c267e7c9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,20 +1,20 @@ -# Windows files (CRLF) -*.bat text eol=crlf - -# Text -*.properties text - -# Java -*.java text diff=java -*.gradle text diff=java -*.gradle.kts text diff=kotlin - -# Binary -*.class binary -*.dll binary -*.ear binary -*.jar binary -*.so binary -*.war binary - -**/.cache/* linguist-generated=true +# Windows files (CRLF) +*.bat text eol=crlf + +# Text +*.properties text + +# Java +*.java text diff=java +*.gradle text diff=java +*.gradle.kts text diff=kotlin + +# Binary +*.class binary +*.dll binary +*.ear binary +*.jar binary +*.so binary +*.war binary + +**/.cache/* linguist-generated=true diff --git a/.gitignore b/.gitignore index a8cf67018..c0afb43b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,221 +1,222 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/java,gradle,jetbrains+all,eclipse,visualstudiocode -# Edit at https://www.toptal.com/developers/gitignore?templates=java,gradle,jetbrains+all,eclipse,visualstudiocode - -### Eclipse ### -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# CDT- autotools -.autotools - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - -# Annotation Processing -.apt_generated/ -.apt_generated_test/ - -# Scala IDE specific (Scala & Java development for Eclipse) -.cache-main -.scala_dependencies -.worksheet - -# Uncomment this line if you wish to ignore the project description file. -# Typically, this file would be tracked if it contains build/dependency configurations: -#.project - -### Eclipse Patch ### -# Spring Boot Tooling -.sts4-cache/ - -### Java ### -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -### JetBrains+all ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### JetBrains+all Patch ### -# Ignores the whole .idea folder and all .iml files -# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 - -.idea/ - -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -# Sonarlint plugin -.idea/sonarlint - -### VisualStudioCode ### -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -### VisualStudioCode Patch ### -# Ignore all local history of files -.history - -### Gradle ### -.gradle -build/ - -# Ignore Gradle GUI config -gradle-app.setting - -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar - -# Cache of project -.gradletasknamecache - -# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 -# gradle/wrapper/gradle-wrapper.properties - -### Gradle Patch ### -**/build/ - -# End of https://www.toptal.com/developers/gitignore/api/java,gradle,jetbrains+all,eclipse,visualstudiocode - -# FabricMC -run/ -remappedSrc/ -src/main/generated/.cache/ + +# Created by https://www.toptal.com/developers/gitignore/api/java,gradle,jetbrains+all,eclipse,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=java,gradle,jetbrains+all,eclipse,visualstudiocode + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Eclipse Patch ### +# Spring Boot Tooling +.sts4-cache/ + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### JetBrains+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history + +### Gradle ### +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +# End of https://www.toptal.com/developers/gitignore/api/java,gradle,jetbrains+all,eclipse,visualstudiocode + +# FabricMC +run/ +remappedSrc/ +src/main/generated/.cache/ +src/main/generated/* diff --git a/build.gradle.kts b/build.gradle.kts index 4e2dff3e1..792041415 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -47,6 +47,7 @@ val jeiVersion = project.property("jei.version").toString() val badpacketsVersion = project.property("badpackets.version").toString() val wthitVersion = project.property("wthit.version").toString() val architecturyVersion = project.property("architectury.version").toString() +val appleskinVersion = project.property("appleskin.version").toString() val objVersion = project.property("obj.version").toString() plugins { @@ -194,6 +195,11 @@ repositories { includeGroup("mezz.jei") } } + maven("https://maven.ryanliptak.com/") { + content { + includeGroup("squeek.appleskin") + } + } } configurations { @@ -233,6 +239,7 @@ dependencies { "compat"("me.shedaniel.cloth:cloth-config-fabric:$clothConfigVersion") "compat"("mcp.mobius.waila:wthit:fabric-$wthitVersion") "compat"("dev.architectury:architectury-fabric:$architecturyVersion") // required for REI fluid support + "compat"("squeek.appleskin:appleskin-fabric:$appleskinVersion") multicompat(group = "me.shedaniel", api = "RoughlyEnoughItems-api-fabric", diff --git a/gradle.properties b/gradle.properties index 6c0c78f35..2af1f80db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,4 +22,5 @@ machinelib.version=0.7.0+76 badpackets.version=0.8.1 wthit.version=12.3.0 obj.version=0.4.0 +appleskin.version=mc1.21-3.0.5 architectury.version=13.0.6 diff --git a/src/main/generated/assets/galacticraft/blockstates/air_lock_seal.json b/src/main/generated/assets/galacticraft/blockstates/air_lock_seal.json deleted file mode 100644 index e710442b0..000000000 --- a/src/main/generated/assets/galacticraft/blockstates/air_lock_seal.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "variants": { - "": { - "model": "galacticraft:block/air_lock_seal" - } - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/asteroid_aluminum_ore.json b/src/main/generated/assets/galacticraft/blockstates/asteroid_aluminum_ore.json new file mode 100644 index 000000000..21c818c7d --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/asteroid_aluminum_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/asteroid_aluminum_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/asteroid_iron_ore.json b/src/main/generated/assets/galacticraft/blockstates/asteroid_iron_ore.json new file mode 100644 index 000000000..d13396345 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/asteroid_iron_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/asteroid_iron_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/asteroid_silicon_ore.json b/src/main/generated/assets/galacticraft/blockstates/asteroid_silicon_ore.json new file mode 100644 index 000000000..e64d21c76 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/asteroid_silicon_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/asteroid_silicon_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/dense_ice.json b/src/main/generated/assets/galacticraft/blockstates/dense_ice.json new file mode 100644 index 000000000..184107d4c --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/dense_ice.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/dense_ice" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/food_canner.json b/src/main/generated/assets/galacticraft/blockstates/food_canner.json new file mode 100644 index 000000000..695c92fb0 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/food_canner.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:machine/food_canner" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/mars_copper_ore.json b/src/main/generated/assets/galacticraft/blockstates/mars_copper_ore.json new file mode 100644 index 000000000..c416a59f6 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/mars_copper_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/mars_copper_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/mars_iron_ore.json b/src/main/generated/assets/galacticraft/blockstates/mars_iron_ore.json new file mode 100644 index 000000000..b3bf4bdb2 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/mars_iron_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/mars_iron_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/mars_tin_ore.json b/src/main/generated/assets/galacticraft/blockstates/mars_tin_ore.json new file mode 100644 index 000000000..ed3e42255 --- /dev/null +++ b/src/main/generated/assets/galacticraft/blockstates/mars_tin_ore.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "galacticraft:block/mars_tin_ore" + } + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/blockstates/rocket_workbench.json b/src/main/generated/assets/galacticraft/blockstates/rocket_workbench.json index 64cb5e5f0..46a3012c9 100644 --- a/src/main/generated/assets/galacticraft/blockstates/rocket_workbench.json +++ b/src/main/generated/assets/galacticraft/blockstates/rocket_workbench.json @@ -1,7 +1,7 @@ { "variants": { "": { - "model": "galacticraft:block/rocket_workbench" + "model": "galacticraft:machine/rocket_workbench" } } } \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/lang/en_us.json b/src/main/generated/assets/galacticraft/lang/en_us.json index 4211f9154..98241d200 100644 --- a/src/main/generated/assets/galacticraft/lang/en_us.json +++ b/src/main/generated/assets/galacticraft/lang/en_us.json @@ -1,5 +1,6 @@ { "banner_pattern.galacticraft.rocket": "Rocket", + "biome.galacticraft.asteroid_field": "Asteroid Field", "biome.galacticraft.basaltic_mare": "Basaltic Mare", "biome.galacticraft.comet_tundra": "Comet Tundra", "biome.galacticraft.lunar_highlands": "Lunar Highlands", @@ -27,9 +28,12 @@ "block.galacticraft.aluminum_decoration_wall": "Aluminum Decoration Wall", "block.galacticraft.aluminum_ore": "Aluminum Ore", "block.galacticraft.aluminum_wire": "Aluminum Wire", + "block.galacticraft.asteroid_aluminum_ore": "Asteroid Aluminum Ore", + "block.galacticraft.asteroid_iron_ore": "Asteroid Iron Ore", "block.galacticraft.asteroid_rock": "Asteroid Rock", "block.galacticraft.asteroid_rock_block_1": "Asteroid Rock", "block.galacticraft.asteroid_rock_block_2": "Asteroid Rock", + "block.galacticraft.asteroid_silicon_ore": "Asteroid Silicon Ore", "block.galacticraft.basic_solar_panel": "Basic Solar Panel", "block.galacticraft.basic_solar_panel.description": "Basic Solar Panels collect energy from the sun, and store it for further use. Collects most energy at mid-day (non-adjustable).", "block.galacticraft.black_candle_moon_cheese_wheel": "Moon Cheese Wheel with Black Candle", @@ -82,6 +86,7 @@ "block.galacticraft.deepslate_aluminum_ore": "Deepslate Aluminum Ore", "block.galacticraft.deepslate_silicon_ore": "Deepslate Silicon Ore", "block.galacticraft.deepslate_tin_ore": "Deepslate Tin Ore", + "block.galacticraft.dense_ice": "Dense Ice", "block.galacticraft.desh_block": "Block of Desh", "block.galacticraft.desh_ore": "Desh Ore", "block.galacticraft.detailed_aluminum_decoration": "Detailed Aluminum Decoration", @@ -129,6 +134,7 @@ "block.galacticraft.energy_storage_module.description": "Energy Storage Module is used to store large amounts of energy for later use.", "block.galacticraft.fallen_meteor": "Fallen Meteor", "block.galacticraft.fluid_pipe_walkway": "Fluid Pipe Walkway", + "block.galacticraft.food_canner": "Food Canner", "block.galacticraft.fuel": "Fuel", "block.galacticraft.fuel_loader": "Fuel Loader", "block.galacticraft.fueling_pad": "Fueling Pad", @@ -164,12 +170,15 @@ "block.galacticraft.mars_cobblestone_slab": "Mars Cobblestone Slab", "block.galacticraft.mars_cobblestone_stairs": "Mars Cobblestone Stairs", "block.galacticraft.mars_cobblestone_wall": "Mars Cobblestone Wall", + "block.galacticraft.mars_copper_ore": "Mars Copper Ore", + "block.galacticraft.mars_iron_ore": "Mars Iron Ore", "block.galacticraft.mars_stone": "Mars Stone", "block.galacticraft.mars_stone_slab": "Mars Stone Slab", "block.galacticraft.mars_stone_stairs": "Mars Stone Stairs", "block.galacticraft.mars_stone_wall": "Mars Stone Wall", "block.galacticraft.mars_sub_surface_rock": "Mars Sub-Surface Rock", "block.galacticraft.mars_surface_rock": "Mars Surface Rock", + "block.galacticraft.mars_tin_ore": "Mars Tin Ore", "block.galacticraft.meteoric_iron_block": "Block of Meteoric Iron", "block.galacticraft.meteoric_iron_decoration": "Meteoric Iron Decoration", "block.galacticraft.meteoric_iron_decoration_slab": "Meteoric Iron Decoration Slab", @@ -299,6 +308,7 @@ "config.galacticraft.energy.machines.electric_furnace_energy_consumption_rate": "Electric Furnace Energy Consumption Rate/t", "config.galacticraft.energy.machines.energy_storage_module_storage_size": "Energy Storage Module Energy Storage Size", "config.galacticraft.energy.machines.energy_storage_size": "Default Machine Energy Storage Size", + "config.galacticraft.energy.machines.food_canner_energy_consumption_rate": "Food Canner Energy Consumption Rate/t", "config.galacticraft.energy.machines.oxygen_collector_energy_consumption_rate": "Oxygen Collector Energy Consumption Rate/t", "config.galacticraft.energy.machines.oxygen_compressor_energy_consumption_rate": "Oxygen Compressor Energy Consumption Rate/t", "config.galacticraft.energy.machines.oxygen_decompressor_energy_consumption_rate": "Oxygen Decompressor Energy Consumption Rate/t", @@ -376,11 +386,7 @@ "item.galacticraft.brown_parachute": "Brown Parachute", "item.galacticraft.buggy": "Buggy", "item.galacticraft.burger_bun": "Burger Bun", - "item.galacticraft.canned_beef": "Canned Beef", - "item.galacticraft.canned_dehydrated_apple": "Canned Dehydrated Apple", - "item.galacticraft.canned_dehydrated_carrot": "Canned Dehydrated Carrot", - "item.galacticraft.canned_dehydrated_melon": "Canned Dehydrated Melon", - "item.galacticraft.canned_dehydrated_potato": "Canned Dehydrated Potato", + "item.galacticraft.canned_food": "Canned ", "item.galacticraft.canvas": "Canvas", "item.galacticraft.carbon_fragments": "Carbon Fragments", "item.galacticraft.cargo_rocket_schematic": "Cargo Rocket Schematic", @@ -411,6 +417,8 @@ "item.galacticraft.desh_shovel": "Desh Shovel", "item.galacticraft.desh_stick": "Desh Stick", "item.galacticraft.desh_sword": "Desh Sword", + "item.galacticraft.empty_can": "Empty Can", + "item.galacticraft.empty_canned_food": "Empty Canned Food", "item.galacticraft.fluid_manipulator": "Fluid Manipulator", "item.galacticraft.frequency_module": "Frequency Module", "item.galacticraft.fuel_bucket": "Fuel Bucket", @@ -502,15 +510,17 @@ "item.galacticraft.titanium_shovel": "Titanium Shovel", "item.galacticraft.titanium_sword": "Titanium Sword", "item.galacticraft.titanium_upgrade_smithing_template": "Smithing Template", + "item.galacticraft.total_nutrition": "Total Nutrition: ", "item.galacticraft.white_parachute": "Parachute", "item.galacticraft.yellow_parachute": "Yellow Parachute", "itemGroup.galacticraft.blocks": "Galacticraft Blocks", + "itemGroup.galacticraft.canned_food": "Canned Food", "itemGroup.galacticraft.items": "Galacticraft Items", "itemGroup.galacticraft.machines": "Galacticraft Machines", "key.galacticraft.open_celestial_screen": "Open Celestial Map", "key.galacticraft.rocket.inventory": "Open Rocket Inventory", - "planet.galacticraft.asteroids": "Asteroids", - "planet.galacticraft.asteroids.description": "", + "planet.galacticraft.asteroid": "Asteroid", + "planet.galacticraft.asteroid.description": "", "planet.galacticraft.earth": "Earth", "planet.galacticraft.earth.description": "The Overworld", "planet.galacticraft.jupiter": "Jupiter", @@ -641,6 +651,7 @@ "ui.galacticraft.status.already_sealed": "Already Sealed", "ui.galacticraft.status.area_too_large": "Area Too Large", "ui.galacticraft.status.blocked": "Blocked", + "ui.galacticraft.status.canning": "Canning", "ui.galacticraft.status.collecting": "Collecting", "ui.galacticraft.status.compressing": "Compressing", "ui.galacticraft.status.cooling_down": "Cooling Down", @@ -651,9 +662,11 @@ "ui.galacticraft.status.fuel_tank_full": "Fuel Tank Full", "ui.galacticraft.status.generating": "Generating", "ui.galacticraft.status.loading": "Loading", + "ui.galacticraft.status.missing_empty_can": "Missing Empty Can", "ui.galacticraft.status.missing_oil": "Missing Oil", "ui.galacticraft.status.missing_oxygen_tank": "Missing Oxygen Tank", "ui.galacticraft.status.night": "Night", + "ui.galacticraft.status.no_food": "No Food", "ui.galacticraft.status.no_fuel": "No Fuel", "ui.galacticraft.status.no_rocket": "No rocket", "ui.galacticraft.status.not_enough_fuel": "Not enough fuel", @@ -663,6 +676,7 @@ "ui.galacticraft.status.rain": "Rain", "ui.galacticraft.status.rocket_is_full": "Rocket is full", "ui.galacticraft.status.sealed": "Sealed", + "ui.galacticraft.status.transferring_can": "Transferring Can", "ui.galacticraft.status.warming_up": "Warming up", "ui.galacticraft.travelling_to": "Travelling to: ", "ui.galacticraft.upgrade": "Upgrade", diff --git a/src/main/generated/assets/galacticraft/models/block/asteroid_aluminum_ore.json b/src/main/generated/assets/galacticraft/models/block/asteroid_aluminum_ore.json new file mode 100644 index 000000000..60727c1e4 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/asteroid_aluminum_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/asteroid_aluminum_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/asteroid_iron_ore.json b/src/main/generated/assets/galacticraft/models/block/asteroid_iron_ore.json new file mode 100644 index 000000000..1ba99904b --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/asteroid_iron_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/asteroid_iron_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/asteroid_silicon_ore.json b/src/main/generated/assets/galacticraft/models/block/asteroid_silicon_ore.json new file mode 100644 index 000000000..7168e8486 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/asteroid_silicon_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/asteroid_silicon_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/dense_ice.json b/src/main/generated/assets/galacticraft/models/block/dense_ice.json new file mode 100644 index 000000000..699b88a5f --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/dense_ice.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/dense_ice" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/mars_copper_ore.json b/src/main/generated/assets/galacticraft/models/block/mars_copper_ore.json new file mode 100644 index 000000000..226f812c0 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/mars_copper_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/mars_copper_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/mars_iron_ore.json b/src/main/generated/assets/galacticraft/models/block/mars_iron_ore.json new file mode 100644 index 000000000..bc485b0d7 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/mars_iron_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/mars_iron_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/block/mars_tin_ore.json b/src/main/generated/assets/galacticraft/models/block/mars_tin_ore.json new file mode 100644 index 000000000..4658b67c1 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/block/mars_tin_ore.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "galacticraft:block/mars_tin_ore" + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/asteroid_aluminum_ore.json b/src/main/generated/assets/galacticraft/models/item/asteroid_aluminum_ore.json new file mode 100644 index 000000000..4a2f82dd6 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/asteroid_aluminum_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/asteroid_aluminum_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/asteroid_iron_ore.json b/src/main/generated/assets/galacticraft/models/item/asteroid_iron_ore.json new file mode 100644 index 000000000..7307597b2 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/asteroid_iron_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/asteroid_iron_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/asteroid_silicon_ore.json b/src/main/generated/assets/galacticraft/models/item/asteroid_silicon_ore.json new file mode 100644 index 000000000..e7b981947 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/asteroid_silicon_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/asteroid_silicon_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/canned_beef.json b/src/main/generated/assets/galacticraft/models/item/canned_beef.json deleted file mode 100644 index 1adb6b36c..000000000 --- a/src/main/generated/assets/galacticraft/models/item/canned_beef.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "galacticraft:item/canned_beef" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_apple.json b/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_apple.json deleted file mode 100644 index 4fb438ca7..000000000 --- a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_apple.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "galacticraft:item/canned_dehydrated_apple" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_carrot.json b/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_carrot.json deleted file mode 100644 index 7313bcbd1..000000000 --- a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_carrot.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "galacticraft:item/canned_dehydrated_carrot" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_melon.json b/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_melon.json deleted file mode 100644 index 2926a2db4..000000000 --- a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_melon.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "galacticraft:item/canned_dehydrated_melon" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_potato.json b/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_potato.json deleted file mode 100644 index 3ff71bf5d..000000000 --- a/src/main/generated/assets/galacticraft/models/item/canned_dehydrated_potato.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/generated", - "textures": { - "layer0": "galacticraft:item/canned_dehydrated_potato" - } -} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/dense_ice.json b/src/main/generated/assets/galacticraft/models/item/dense_ice.json new file mode 100644 index 000000000..a6de3557d --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/dense_ice.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/dense_ice" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/food_canner.json b/src/main/generated/assets/galacticraft/models/item/food_canner.json new file mode 100644 index 000000000..e5bea2f4e --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/food_canner.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/food_canner" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/mars_copper_ore.json b/src/main/generated/assets/galacticraft/models/item/mars_copper_ore.json new file mode 100644 index 000000000..df33c244f --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/mars_copper_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/mars_copper_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/mars_iron_ore.json b/src/main/generated/assets/galacticraft/models/item/mars_iron_ore.json new file mode 100644 index 000000000..cf75d390d --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/mars_iron_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/mars_iron_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/mars_tin_ore.json b/src/main/generated/assets/galacticraft/models/item/mars_tin_ore.json new file mode 100644 index 000000000..8d6ed6830 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/item/mars_tin_ore.json @@ -0,0 +1,3 @@ +{ + "parent": "galacticraft:block/mars_tin_ore" +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/item/oxygen_sealer.json b/src/main/generated/assets/galacticraft/models/item/oxygen_sealer.json deleted file mode 100644 index da43dc10a..000000000 --- a/src/main/generated/assets/galacticraft/models/item/oxygen_sealer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "galacticraft:block/oxygen_sealer" -} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/machine/circuit_fabricator.json b/src/main/generated/assets/galacticraft/models/machine/circuit_fabricator.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/circuit_fabricator.json rename to src/main/generated/assets/galacticraft/models/machine/circuit_fabricator.json diff --git a/src/main/resources/assets/galacticraft/models/machine/coal_generator.json b/src/main/generated/assets/galacticraft/models/machine/coal_generator.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/coal_generator.json rename to src/main/generated/assets/galacticraft/models/machine/coal_generator.json diff --git a/src/main/resources/assets/galacticraft/models/machine/compressor.json b/src/main/generated/assets/galacticraft/models/machine/compressor.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/compressor.json rename to src/main/generated/assets/galacticraft/models/machine/compressor.json diff --git a/src/main/resources/assets/galacticraft/models/machine/electric_arc_furnace.json b/src/main/generated/assets/galacticraft/models/machine/electric_arc_furnace.json similarity index 99% rename from src/main/resources/assets/galacticraft/models/machine/electric_arc_furnace.json rename to src/main/generated/assets/galacticraft/models/machine/electric_arc_furnace.json index 90f71b8fd..65d7a9b14 100644 --- a/src/main/resources/assets/galacticraft/models/machine/electric_arc_furnace.json +++ b/src/main/generated/assets/galacticraft/models/machine/electric_arc_furnace.json @@ -5,4 +5,4 @@ "base": "galacticraft:block/machine", "side": "galacticraft:block/machine_side" } -} +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/machine/electric_compressor.json b/src/main/generated/assets/galacticraft/models/machine/electric_compressor.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/electric_compressor.json rename to src/main/generated/assets/galacticraft/models/machine/electric_compressor.json diff --git a/src/main/resources/assets/galacticraft/models/machine/electric_furnace.json b/src/main/generated/assets/galacticraft/models/machine/electric_furnace.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/electric_furnace.json rename to src/main/generated/assets/galacticraft/models/machine/electric_furnace.json diff --git a/src/main/resources/assets/galacticraft/models/machine/energy_storage_module.json b/src/main/generated/assets/galacticraft/models/machine/energy_storage_module.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/energy_storage_module.json rename to src/main/generated/assets/galacticraft/models/machine/energy_storage_module.json diff --git a/src/main/generated/assets/galacticraft/models/machine/food_canner.json b/src/main/generated/assets/galacticraft/models/machine/food_canner.json new file mode 100644 index 000000000..75f5f54bb --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/machine/food_canner.json @@ -0,0 +1,8 @@ +{ + "machinelib:generate": "machinelib:z_axis", + "sprites": { + "back": "galacticraft:block/food_canner_back", + "front": "galacticraft:block/food_canner", + "sided": true + } +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/machine/fuel_loader.json b/src/main/generated/assets/galacticraft/models/machine/fuel_loader.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/fuel_loader.json rename to src/main/generated/assets/galacticraft/models/machine/fuel_loader.json diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_bubble_distributor.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_bubble_distributor.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_bubble_distributor.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_bubble_distributor.json diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_bubble_distributor_active.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_bubble_distributor_active.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_bubble_distributor_active.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_bubble_distributor_active.json diff --git a/src/main/generated/assets/galacticraft/models/machine/oxygen_collector.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_collector.json new file mode 100644 index 000000000..ef1623e42 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/machine/oxygen_collector.json @@ -0,0 +1,7 @@ +{ + "machinelib:generate": "machinelib:single", + "sprites": { + "particle": "galacticraft:block/oxygen_collector", + "sprite": "galacticraft:block/oxygen_collector" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_collector_active.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_collector_active.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_collector_active.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_collector_active.json diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_compressor.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_compressor.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_compressor.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_compressor.json diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_decompressor.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_decompressor.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_decompressor.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_decompressor.json diff --git a/src/main/resources/assets/galacticraft/models/machine/oxygen_sealer.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_sealer.json similarity index 100% rename from src/main/resources/assets/galacticraft/models/machine/oxygen_sealer.json rename to src/main/generated/assets/galacticraft/models/machine/oxygen_sealer.json diff --git a/src/main/generated/assets/galacticraft/models/machine/oxygen_storage_module.json b/src/main/generated/assets/galacticraft/models/machine/oxygen_storage_module.json new file mode 100644 index 000000000..4ef24116e --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/machine/oxygen_storage_module.json @@ -0,0 +1,8 @@ +{ + "machinelib:generate": "machinelib:z_axis", + "sprites": { + "back": "galacticraft:block/oxygen_storage_model_8", + "front": "galacticraft:block/oxygen_storage_model_8", + "sided": false + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/machine/refinery.json b/src/main/generated/assets/galacticraft/models/machine/refinery.json new file mode 100644 index 000000000..f4e4b2da4 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/machine/refinery.json @@ -0,0 +1,8 @@ +{ + "machinelib:generate": "machinelib:z_axis", + "sprites": { + "back": "galacticraft:block/refinery_back", + "front": "galacticraft:block/refinery_front", + "sided": true + } +} \ No newline at end of file diff --git a/src/main/generated/assets/galacticraft/models/machine/rocket_workbench.json b/src/main/generated/assets/galacticraft/models/machine/rocket_workbench.json new file mode 100644 index 000000000..bb71976f3 --- /dev/null +++ b/src/main/generated/assets/galacticraft/models/machine/rocket_workbench.json @@ -0,0 +1,15 @@ +{ + "machinelib:generate": "machinelib:front_face", + "sprites": { + "sprite": "galacticraft:block/refinery_front" + }, + "textures": { + "down": "galacticraft:block/machine_side", + "east": "galacticraft:block/machine_side", + "north": "galacticraft:block/machine_side", + "particle": "galacticraft:block/machine_side", + "south": "galacticraft:block/machine_side", + "up": "galacticraft:block/machine_side", + "west": "galacticraft:block/machine_side" + } +} \ No newline at end of file diff --git a/src/main/generated/data/c/tags/block/ores.json b/src/main/generated/data/c/tags/block/ores.json index 22dbb137f..ec49ac103 100644 --- a/src/main/generated/data/c/tags/block/ores.json +++ b/src/main/generated/data/c/tags/block/ores.json @@ -10,6 +10,9 @@ "galacticraft:deepslate_tin_ore", "galacticraft:moon_tin_ore", "galacticraft:lunaslate_tin_ore", + "galacticraft:asteroid_aluminum_ore", + "galacticraft:asteroid_iron_ore", + "galacticraft:asteroid_silicon_ore", "galacticraft:aluminum_ore", "galacticraft:deepslate_aluminum_ore", "galacticraft:desh_ore", diff --git a/src/main/generated/data/c/tags/item/foods.json b/src/main/generated/data/c/tags/item/foods.json new file mode 100644 index 000000000..1f9ac8577 --- /dev/null +++ b/src/main/generated/data/c/tags/item/foods.json @@ -0,0 +1,10 @@ +{ + "values": [ + "galacticraft:cheese_curd", + "galacticraft:cheese_slice", + "galacticraft:burger_bun", + "galacticraft:ground_beef", + "galacticraft:beef_patty", + "galacticraft:cheeseburger" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/c/tags/item/ores.json b/src/main/generated/data/c/tags/item/ores.json index 22dbb137f..f63a851d9 100644 --- a/src/main/generated/data/c/tags/item/ores.json +++ b/src/main/generated/data/c/tags/item/ores.json @@ -12,6 +12,9 @@ "galacticraft:lunaslate_tin_ore", "galacticraft:aluminum_ore", "galacticraft:deepslate_aluminum_ore", + "galacticraft:asteroid_aluminum_ore", + "galacticraft:asteroid_iron_ore", + "galacticraft:asteroid_silicon_ore", "galacticraft:desh_ore", "galacticraft:ilmenite_ore", "galacticraft:galena_ore" diff --git a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_apple.json b/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_apple.json deleted file mode 100644 index 60d40fa10..000000000 --- a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_apple.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "galacticraft:canned_dehydrated_apple" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "has_tin_canister": { - "conditions": { - "items": [ - { - "items": "galacticraft:tin_canister" - } - ] - }, - "trigger": "minecraft:inventory_changed" - } - }, - "requirements": [ - [ - "has_the_recipe", - "has_tin_canister" - ] - ], - "rewards": { - "recipes": [ - "galacticraft:canned_dehydrated_apple" - ] - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_carrot.json b/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_carrot.json deleted file mode 100644 index 1c21f4b96..000000000 --- a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_carrot.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "galacticraft:canned_dehydrated_carrot" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "has_tin_canister": { - "conditions": { - "items": [ - { - "items": "galacticraft:tin_canister" - } - ] - }, - "trigger": "minecraft:inventory_changed" - } - }, - "requirements": [ - [ - "has_the_recipe", - "has_tin_canister" - ] - ], - "rewards": { - "recipes": [ - "galacticraft:canned_dehydrated_carrot" - ] - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_melon.json b/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_melon.json deleted file mode 100644 index 46ecea262..000000000 --- a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_melon.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "galacticraft:canned_dehydrated_melon" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "has_tin_canister": { - "conditions": { - "items": [ - { - "items": "galacticraft:tin_canister" - } - ] - }, - "trigger": "minecraft:inventory_changed" - } - }, - "requirements": [ - [ - "has_the_recipe", - "has_tin_canister" - ] - ], - "rewards": { - "recipes": [ - "galacticraft:canned_dehydrated_melon" - ] - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_potato.json b/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_potato.json deleted file mode 100644 index b1c0a90b7..000000000 --- a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_dehydrated_potato.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "parent": "minecraft:recipes/root", - "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "galacticraft:canned_dehydrated_potato" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "has_tin_canister": { - "conditions": { - "items": [ - { - "items": "galacticraft:tin_canister" - } - ] - }, - "trigger": "minecraft:inventory_changed" - } - }, - "requirements": [ - [ - "has_the_recipe", - "has_tin_canister" - ] - ], - "rewards": { - "recipes": [ - "galacticraft:canned_dehydrated_potato" - ] - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_beef.json b/src/main/generated/data/galacticraft/advancement/recipes/misc/food_canner.json similarity index 67% rename from src/main/generated/data/galacticraft/advancement/recipes/food/canned_beef.json rename to src/main/generated/data/galacticraft/advancement/recipes/misc/food_canner.json index 4494daa07..2d3d1b126 100644 --- a/src/main/generated/data/galacticraft/advancement/recipes/food/canned_beef.json +++ b/src/main/generated/data/galacticraft/advancement/recipes/misc/food_canner.json @@ -1,32 +1,32 @@ { "parent": "minecraft:recipes/root", "criteria": { - "has_the_recipe": { - "conditions": { - "recipe": "galacticraft:canned_beef" - }, - "trigger": "minecraft:recipe_unlocked" - }, - "has_tin_canister": { + "has_oxygen_concentrator": { "conditions": { "items": [ { - "items": "galacticraft:tin_canister" + "items": "galacticraft:oxygen_concentrator" } ] }, "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "galacticraft:food_canner" + }, + "trigger": "minecraft:recipe_unlocked" } }, "requirements": [ [ "has_the_recipe", - "has_tin_canister" + "has_oxygen_concentrator" ] ], "rewards": { "recipes": [ - "galacticraft:canned_beef" + "galacticraft:food_canner" ] } } \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/dimension/asteroid.json b/src/main/generated/data/galacticraft/dimension/asteroid.json new file mode 100644 index 000000000..12d6f6fdb --- /dev/null +++ b/src/main/generated/data/galacticraft/dimension/asteroid.json @@ -0,0 +1,12 @@ +{ + "type": "galacticraft:asteroid", + "generator": { + "type": "galacticraft:asteroid_chunk_generator", + "biomeSource": { + "type": "minecraft:multi_noise", + "preset": "galacticraft:asteroid" + }, + "dimensionKey": "galacticraft:asteroid", + "par2": 1000 + } +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/dimension_type/asteroid.json b/src/main/generated/data/galacticraft/dimension_type/asteroid.json new file mode 100644 index 000000000..0f1792058 --- /dev/null +++ b/src/main/generated/data/galacticraft/dimension_type/asteroid.json @@ -0,0 +1,23 @@ +{ + "ambient_light": 0.0, + "bed_works": false, + "coordinate_scale": 1.0, + "effects": "galacticraft:asteroid", + "has_ceiling": false, + "has_raids": false, + "has_skylight": false, + "height": 384, + "infiniburn": "#galacticraft:infiniburn_asteroid", + "logical_height": 384, + "min_y": -64, + "monster_spawn_block_light_limit": 0, + "monster_spawn_light_level": { + "type": "minecraft:uniform", + "max_inclusive": 7, + "min_inclusive": 0 + }, + "natural": false, + "piglin_safe": false, + "respawn_anchor_works": false, + "ultrawarm": false +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroid.json b/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroid.json new file mode 100644 index 000000000..bd2119f9f --- /dev/null +++ b/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroid.json @@ -0,0 +1,49 @@ +{ + "type": "galacticraft:planet", + "config": { + "parent": "galacticraft:sol", + "access_weight": 2, + "atmosphere": { + "composition": {}, + "pressure": 0.0, + "temperature": -2.0 + }, + "celestial_handler": "galacticraft:default", + "day_length": 99999999, + "day_temperature": -2, + "description": { + "translate": "planet.galacticraft.asteroid.description" + }, + "display": { + "type": "galacticraft:icon", + "config": { + "height": 16, + "scale": 1.0, + "texture": "galacticraft:textures/gui/celestialbodies/asteroid.png", + "u": 0, + "v": 0, + "width": 16 + } + }, + "gravity": 0.1, + "name": { + "translate": "planet.galacticraft.asteroid" + }, + "night_temperature": -2, + "position": { + "type": "galacticraft:orbital", + "config": { + "distance": 0.75, + "orbit_time": 0.6152793169021606, + "phase_shift": 2.0, + "planet": false + } + }, + "ring": { + "type": "galacticraft:default", + "config": {} + }, + "teleporter": "galacticraft:lander", + "world": "galacticraft:asteroid" + } +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroids.json b/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroids.json deleted file mode 100644 index 79402cfd6..000000000 --- a/src/main/generated/data/galacticraft/galacticraft/celestial_body/asteroids.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "type": "galacticraft:decorative_planet", - "config": { - "parent": "galacticraft:sol", - "atmosphere": { - "composition": {}, - "pressure": 3.0E-15, - "temperature": 23.0 - }, - "description": { - "translate": "planet.galacticraft.asteroids.description" - }, - "display": { - "type": "galacticraft:spinning_icon", - "config": { - "height": 16, - "scale": 1.0, - "texture": "galacticraft:textures/gui/celestialbodies/asteroid.png", - "u": 0, - "v": 0, - "width": 16 - } - }, - "gravity": 0.166, - "name": { - "translate": "planet.galacticraft.asteroids" - }, - "position": { - "type": "galacticraft:orbital", - "config": { - "distance": 1.375, - "orbit_time": 45.0, - "phase_shift": 0.0, - "planet": true - } - }, - "ring": { - "type": "galacticraft:asteroid", - "config": {} - } - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_aluminum_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_aluminum_ore.json new file mode 100644 index 000000000..8e26a078a --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_aluminum_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:asteroid_aluminum_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "galacticraft:raw_aluminum" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_iron_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_iron_ore.json new file mode 100644 index 000000000..2e3fc42d3 --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_iron_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:asteroid_iron_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:raw_iron" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_silicon_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_silicon_ore.json new file mode 100644 index 000000000..349d60235 --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/asteroid_silicon_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:asteroid_silicon_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "galacticraft:raw_silicon" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/dense_ice.json b/src/main/generated/data/galacticraft/loot_table/blocks/dense_ice.json new file mode 100644 index 000000000..9d74c64cf --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/dense_ice.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "galacticraft:dense_ice" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/food_canner.json b/src/main/generated/data/galacticraft/loot_table/blocks/food_canner.json new file mode 100644 index 000000000..16dfecdee --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/food_canner.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "entries": [ + { + "type": "minecraft:item", + "name": "galacticraft:food_canner" + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/mars_copper_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/mars_copper_ore.json new file mode 100644 index 000000000..8d46e701e --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/mars_copper_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:mars_copper_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:raw_copper" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/mars_iron_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/mars_iron_ore.json new file mode 100644 index 000000000..0b0ff1e1c --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/mars_iron_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:mars_iron_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:raw_iron" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/loot_table/blocks/mars_tin_ore.json b/src/main/generated/data/galacticraft/loot_table/blocks/mars_tin_ore.json new file mode 100644 index 000000000..8ec0be6a5 --- /dev/null +++ b/src/main/generated/data/galacticraft/loot_table/blocks/mars_tin_ore.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ], + "name": "galacticraft:mars_tin_ore" + }, + { + "type": "minecraft:item", + "functions": [ + { + "enchantment": "minecraft:fortune", + "formula": "minecraft:ore_drops", + "function": "minecraft:apply_bonus" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "galacticraft:raw_tin" + } + ] + } + ], + "rolls": 1.0 + } + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/canned_beef.json b/src/main/generated/data/galacticraft/recipe/canned_beef.json deleted file mode 100644 index 59ddc185b..000000000 --- a/src/main/generated/data/galacticraft/recipe/canned_beef.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "galacticraft:tin_canister" - }, - { - "item": "galacticraft:ground_beef" - }, - { - "item": "galacticraft:ground_beef" - } - ], - "result": { - "count": 1, - "id": "galacticraft:canned_beef" - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_apple.json b/src/main/generated/data/galacticraft/recipe/canned_dehydrated_apple.json deleted file mode 100644 index e279e33b0..000000000 --- a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_apple.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "galacticraft:tin_canister" - }, - { - "item": "minecraft:apple" - }, - { - "item": "minecraft:apple" - } - ], - "result": { - "count": 1, - "id": "galacticraft:canned_dehydrated_apple" - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_carrot.json b/src/main/generated/data/galacticraft/recipe/canned_dehydrated_carrot.json deleted file mode 100644 index a2d9a2cdc..000000000 --- a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_carrot.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "galacticraft:tin_canister" - }, - { - "item": "minecraft:carrot" - }, - { - "item": "minecraft:carrot" - } - ], - "result": { - "count": 1, - "id": "galacticraft:canned_dehydrated_carrot" - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_melon.json b/src/main/generated/data/galacticraft/recipe/canned_dehydrated_melon.json deleted file mode 100644 index 999071afe..000000000 --- a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_melon.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "galacticraft:tin_canister" - }, - { - "item": "minecraft:melon_slice" - }, - { - "item": "minecraft:melon_slice" - } - ], - "result": { - "count": 1, - "id": "galacticraft:canned_dehydrated_melon" - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_potato.json b/src/main/generated/data/galacticraft/recipe/canned_dehydrated_potato.json deleted file mode 100644 index bdebc20f3..000000000 --- a/src/main/generated/data/galacticraft/recipe/canned_dehydrated_potato.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "galacticraft:tin_canister" - }, - { - "item": "minecraft:potato" - }, - { - "item": "minecraft:potato" - } - ], - "result": { - "count": 1, - "id": "galacticraft:canned_dehydrated_potato" - } -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/recipe/food_canner.json b/src/main/generated/data/galacticraft/recipe/food_canner.json new file mode 100644 index 000000000..2f2634f13 --- /dev/null +++ b/src/main/generated/data/galacticraft/recipe/food_canner.json @@ -0,0 +1,27 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "misc", + "key": { + "A": { + "item": "galacticraft:compressed_aluminum" + }, + "B": { + "item": "galacticraft:compressed_bronze" + }, + "C": { + "item": "galacticraft:oxygen_concentrator" + }, + "S": { + "item": "galacticraft:compressed_steel" + } + }, + "pattern": [ + "SAS", + "ACA", + "SBS" + ], + "result": { + "count": 1, + "id": "galacticraft:food_canner" + } +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/tags/block/machines.json b/src/main/generated/data/galacticraft/tags/block/machines.json index fcac30126..4f99685ee 100644 --- a/src/main/generated/data/galacticraft/tags/block/machines.json +++ b/src/main/generated/data/galacticraft/tags/block/machines.json @@ -15,7 +15,9 @@ "galacticraft:oxygen_bubble_distributor", "galacticraft:oxygen_decompressor", "galacticraft:oxygen_compressor", + "galacticraft:food_canner", "galacticraft:oxygen_storage_module", - "galacticraft:fuel_loader" + "galacticraft:fuel_loader", + "galacticraft:rocket_workbench" ] } \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/tags/dimension_type/space.json b/src/main/generated/data/galacticraft/tags/dimension_type/space.json index 1da6e9a7f..ab25c8d9b 100644 --- a/src/main/generated/data/galacticraft/tags/dimension_type/space.json +++ b/src/main/generated/data/galacticraft/tags/dimension_type/space.json @@ -1,6 +1,7 @@ { "values": [ "galacticraft:moon", - "galacticraft:venus" + "galacticraft:venus", + "galacticraft:asteroid" ] } \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/tags/worldgen/biome/asteroid.json b/src/main/generated/data/galacticraft/tags/worldgen/biome/asteroid.json new file mode 100644 index 000000000..9dcaf92d9 --- /dev/null +++ b/src/main/generated/data/galacticraft/tags/worldgen/biome/asteroid.json @@ -0,0 +1,5 @@ +{ + "values": [ + "galacticraft:asteroid_field" + ] +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/tags/worldgen/biome/has_structure/moon_boss.json b/src/main/generated/data/galacticraft/tags/worldgen/biome/has_structure/moon_boss.json deleted file mode 100644 index e43fd436f..000000000 --- a/src/main/generated/data/galacticraft/tags/worldgen/biome/has_structure/moon_boss.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "values": [ - "#galacticraft:moon" - ] -} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/worldgen/biome/asteroid_field.json b/src/main/generated/data/galacticraft/worldgen/biome/asteroid_field.json new file mode 100644 index 000000000..b24e8f59d --- /dev/null +++ b/src/main/generated/data/galacticraft/worldgen/biome/asteroid_field.json @@ -0,0 +1,61 @@ +{ + "carvers": {}, + "downfall": 0.5, + "effects": { + "fog_color": 0, + "mood_sound": { + "block_search_extent": 8, + "offset": 2.0, + "sound": "minecraft:ambient.cave", + "tick_delay": 6000 + }, + "music": { + "max_delay": 24000, + "min_delay": 12000, + "replace_current_music": false, + "sound": "galacticraft:music.music_orbit" + }, + "sky_color": 0, + "water_color": 0, + "water_fog_color": 0 + }, + "features": [], + "has_precipitation": false, + "spawn_costs": {}, + "spawners": { + "ambient": [], + "axolotls": [], + "creature": [], + "misc": [], + "monster": [ + { + "type": "galacticraft:evolved_spider", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "galacticraft:evolved_zombie", + "maxCount": 4, + "minCount": 4, + "weight": 95 + }, + { + "type": "galacticraft:evolved_skeleton", + "maxCount": 4, + "minCount": 4, + "weight": 100 + }, + { + "type": "galacticraft:evolved_creeper", + "maxCount": 4, + "minCount": 4, + "weight": 100 + } + ], + "underground_water_creature": [], + "water_ambient": [], + "water_creature": [] + }, + "temperature": 2.0 +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/worldgen/density_function/asteroid/final_density.json b/src/main/generated/data/galacticraft/worldgen/density_function/asteroid/final_density.json new file mode 100644 index 000000000..feb1cdbd3 --- /dev/null +++ b/src/main/generated/data/galacticraft/worldgen/density_function/asteroid/final_density.json @@ -0,0 +1,18 @@ +{ + "type": "minecraft:add", + "argument1": { + "type": "minecraft:y_clamped_gradient", + "from_value": 1.0, + "from_y": 0, + "to_value": -1.0, + "to_y": 90 + }, + "argument2": { + "type": "minecraft:old_blended_noise", + "smear_scale_multiplier": 8.0, + "xz_factor": 80.0, + "xz_scale": 0.25, + "y_factor": 160.0, + "y_scale": 0.375 + } +} \ No newline at end of file diff --git a/src/main/generated/data/galacticraft/worldgen/multi_noise_biome_source_parameter_list/asteroid.json b/src/main/generated/data/galacticraft/worldgen/multi_noise_biome_source_parameter_list/asteroid.json new file mode 100644 index 000000000..0d5076475 --- /dev/null +++ b/src/main/generated/data/galacticraft/worldgen/multi_noise_biome_source_parameter_list/asteroid.json @@ -0,0 +1,3 @@ +{ + "preset": "galacticraft:asteroid" +} \ No newline at end of file diff --git a/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json b/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json index ba185703c..fa43f63b4 100644 --- a/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json +++ b/src/main/generated/data/minecraft/tags/block/mineable/pickaxe.json @@ -11,6 +11,9 @@ "galacticraft:deepslate_tin_ore", "galacticraft:moon_tin_ore", "galacticraft:lunaslate_tin_ore", + "galacticraft:asteroid_aluminum_ore", + "galacticraft:asteroid_iron_ore", + "galacticraft:asteroid_silicon_ore", "galacticraft:aluminum_ore", "galacticraft:deepslate_aluminum_ore", "galacticraft:desh_ore", @@ -90,6 +93,7 @@ "galacticraft:asteroid_rock", "galacticraft:asteroid_rock_block_1", "galacticraft:asteroid_rock_block_2", + "galacticraft:dense_ice", "galacticraft:tin_decoration", "galacticraft:copper_decoration", "galacticraft:bronze_decoration", diff --git a/src/main/generated/data/minecraft/tags/block/needs_stone_tool.json b/src/main/generated/data/minecraft/tags/block/needs_stone_tool.json index 90b3eeac7..10ce45e62 100644 --- a/src/main/generated/data/minecraft/tags/block/needs_stone_tool.json +++ b/src/main/generated/data/minecraft/tags/block/needs_stone_tool.json @@ -10,6 +10,9 @@ "galacticraft:deepslate_tin_ore", "galacticraft:moon_tin_ore", "galacticraft:lunaslate_tin_ore", + "galacticraft:asteroid_aluminum_ore", + "galacticraft:asteroid_iron_ore", + "galacticraft:asteroid_silicon_ore", "galacticraft:raw_tin_block", "galacticraft:tin_block", "galacticraft:aluminum_ore", diff --git a/src/main/java/dev/galacticraft/api/perlin/FishyNoise.java b/src/main/java/dev/galacticraft/api/perlin/FishyNoise.java new file mode 100644 index 000000000..d2d109aac --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/FishyNoise.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin; + +import java.util.Random; + +public class FishyNoise +{ + int[] perm = new int[512]; + + public float[][] grad2d = new float[][] { { 1, 0 }, { .9239F, .3827F }, { .707107F, 0.707107F }, { .3827F, .9239F }, { 0, 1 }, { -.3827F, .9239F }, { -.707107F, 0.707107F }, { -.9239F, .3827F }, { -1, 0 }, { -.9239F, -.3827F }, { -.707107F, -0.707107F }, { -.3827F, -.9239F }, { 0, -1 }, { .3827F, -.9239F }, { .707107F, -0.707107F }, { .9239F, -.3827F } }; + + public int[][] grad3d = new int[][] { { 1, 1, 0 }, { -1, 1, 0 }, { 1, -1, 0 }, { -1, -1, 0 }, { 1, 0, 1 }, { -1, 0, 1 }, { 1, 0, -1 }, { -1, 0, -1 }, { 0, 1, 1 }, { 0, -1, 1 }, { 0, 1, -1 }, { 0, -1, -1 }, { 1, 1, 0 }, { -1, 1, 0 }, { 0, -1, 1 }, { 0, -1, -1 } }; + + public FishyNoise(long seed) + { + final Random rand = new Random(seed); + for (int i = 0; i < 256; i++) + { + this.perm[i] = i; //fills array with 0 - 256 + } + + for (int i = 0; i < 256; i++) // Shuffle those numbers for the random effect + { + final int j = rand.nextInt(256); + this.perm[i] = this.perm[i] ^ this.perm[j]; + this.perm[j] = this.perm[i] ^ this.perm[j]; + this.perm[i] = this.perm[i] ^ this.perm[j]; + } + + System.arraycopy(this.perm, 0, this.perm, 256, 256); + } + + private static float lerp(float x, float y, float n) + { + return x + n * (y - x); + } + + private static int fastFloor(float x) + { + return x > 0 ? (int) x : (int) x - 1; + } + + private static float fade(float n) + { + return n * n * n * (n * (n * 6 - 15) + 10); + } + + private static float dot2(float[] grad2, float x, float y) + { + return grad2[0] * x + grad2[1] * y; + } + + private static float dot3(int[] grad3, float x, float y, float z) + { + return grad3[0] * x + grad3[1] * y + grad3[2] * z; + } + + public float noise2d(float x, float y) + { + int largeX = x > 0 ? (int) x : (int) x - 1; + int largeY = y > 0 ? (int) y : (int) y - 1; + x -= largeX; + y -= largeY; + largeX &= 255; + largeY &= 255; + + final float u = x * x * x * (x * (x * 6 - 15) + 10); + final float v = y * y * y * (y * (y * 6 - 15) + 10); + + int randY = this.perm[largeY] + largeX; + int randY1 = this.perm[largeY + 1] + largeX; + float[] grad2 = this.grad2d[this.perm[randY] & 15]; + final float grad00 = grad2[0] * x + grad2[1] * y; + grad2 = this.grad2d[this.perm[randY1] & 15]; + final float grad01 = grad2[0] * x + grad2[1] * (y - 1); + grad2 = this.grad2d[this.perm[1 + randY1] & 15]; + final float grad11 = grad2[0] * (x - 1) + grad2[1] * (y - 1); + grad2 = this.grad2d[this.perm[1 + randY] & 15]; + final float grad10 = grad2[0] * (x - 1) + grad2[1] * y; + + final float lerpX0 = grad00 + u * (grad10 - grad00); + return lerpX0 + v * (grad01 + u * (grad11 - grad01) - lerpX0); + } + + public float noise3d(float x, float y, float z) + { + int unitX = x > 0 ? (int) x : (int) x - 1; + int unitY = y > 0 ? (int) y : (int) y - 1; + int unitZ = z > 0 ? (int) z : (int) z - 1; + + x -= unitX; + y -= unitY; + z -= unitZ; + + unitX &= 255; + unitY &= 255; + unitZ &= 255; + + final float u = x * x * x * (x * (x * 6 - 15) + 10); + final float v = y * y * y * (y * (y * 6 - 15) + 10); + final float w = z * z * z * (z * (z * 6 - 15) + 10); + + int randZ = this.perm[unitZ] + unitY; + int randZ1 = this.perm[unitZ + 1] + unitY; + int randYZ = this.perm[randZ] + unitX; + int randY1Z = this.perm[1 + randZ] + unitX; + int randYZ1 = this.perm[randZ1] + unitX; + int randY1Z1 = this.perm[1 + randZ1] + unitX; + int[] grad3 = this.grad3d[this.perm[randYZ] & 15]; + final float grad000 = grad3[0] * x + grad3[1] * y + grad3[2] * z; + grad3 = this.grad3d[this.perm[1 + randYZ] & 15]; + final float grad100 = grad3[0] * (x - 1) + grad3[1] * y + grad3[2] * z; + grad3 = this.grad3d[this.perm[randY1Z] & 15]; + final float grad010 = grad3[0] * x + grad3[1] * (y - 1) + grad3[2] * z; + grad3 = this.grad3d[this.perm[1 + randY1Z] & 15]; + final float grad110 = grad3[0] * (x - 1) + grad3[1] * (y - 1) + grad3[2] * z; + z--; + grad3 = this.grad3d[this.perm[randYZ1] & 15]; + final float grad001 = grad3[0] * x + grad3[1] * y + grad3[2] * z; + grad3 = this.grad3d[this.perm[1 + randYZ1] & 15]; + final float grad101 = grad3[0] * (x - 1) + grad3[1] * y + grad3[2] * z; + grad3 = this.grad3d[this.perm[randY1Z1] & 15]; + final float grad011 = grad3[0] * x + grad3[1] * (y - 1) + grad3[2] * z; + grad3 = this.grad3d[this.perm[1 + randY1Z1] & 15]; + final float grad111 = grad3[0] * (x - 1) + grad3[1] * (y - 1) + grad3[2] * z; + + float f1 = grad000 + u * (grad100 - grad000); + float f2 = grad010 + u * (grad110 - grad010); + float f3 = grad001 + u * (grad101 - grad001); + float f4 = grad011 + u * (grad111 - grad011); + float lerp1 = f1 + v * (f2 - f1); + return lerp1 + w * (f3 + v * (f4 - f3) - lerp1); + } +} diff --git a/src/main/java/dev/galacticraft/api/perlin/NoiseModule.java b/src/main/java/dev/galacticraft/api/perlin/NoiseModule.java new file mode 100644 index 000000000..fafaa8e1c --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/NoiseModule.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin; + +public abstract class NoiseModule +{ + public float frequencyX = 1; + public float frequencyY = 1; + public float frequencyZ = 1; + public float amplitude = 1; + + public abstract float getNoise(float i); + + public abstract float getNoise(float i, float j); + + public abstract float getNoise(float i, float j, float k); + + public void setFrequency(float frequency) + { + this.frequencyX = frequency; + this.frequencyY = frequency; + this.frequencyZ = frequency; + } +} diff --git a/src/main/java/dev/galacticraft/api/perlin/SimplexNoise.java b/src/main/java/dev/galacticraft/api/perlin/SimplexNoise.java new file mode 100644 index 000000000..4a10482e3 --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/SimplexNoise.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin; + +import java.util.Random; + +public class SimplexNoise +{ + int[] perm = new int[512]; + + public int[][] grad2d = new int[][] { { 0, 0 }, { 0, 1 }, { 1, 1 }, { 1, 0 } }; + + public SimplexNoise(long seed) + { + final Random rand = new Random(seed); + for (int i = 0; i < 256; i++) + { + this.perm[i] = i; // Fill up the random array with numbers 0-256 + } + + for (int i = 0; i < 256; i++) // Shuffle those numbers for the random + // effect + { + final int j = rand.nextInt(256); + this.perm[i] = this.perm[i] ^ this.perm[j]; + this.perm[j] = this.perm[i] ^ this.perm[j]; + this.perm[i] = this.perm[i] ^ this.perm[j]; + } + + System.arraycopy(this.perm, 0, this.perm, 256, 256); + } +} diff --git a/src/main/java/dev/galacticraft/api/perlin/generator/Billowed.java b/src/main/java/dev/galacticraft/api/perlin/generator/Billowed.java new file mode 100644 index 000000000..0e4090c09 --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/generator/Billowed.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin.generator; + +import dev.galacticraft.api.perlin.FishyNoise; +import dev.galacticraft.api.perlin.NoiseModule; + +import java.util.Random; + +public class Billowed extends NoiseModule { + private final FishyNoise noiseGen; + private final float offsetX; + private final float offsetY; + private final float offsetZ; + private final int numOctaves; + private final float persistance; + + public Billowed(long seed, int nOctaves, float p) + { + this.numOctaves = nOctaves; + this.persistance = p; + final Random rand = new Random(seed); + this.offsetX = rand.nextFloat() / 2 + 0.01F; + this.offsetY = rand.nextFloat() / 2 + 0.01F; + this.offsetZ = rand.nextFloat() / 2 + 0.01F; + this.noiseGen = new FishyNoise(seed); + } + + @Override + public float getNoise(float i) + { + i *= this.frequencyX; + float val = 0; + float curAmplitude = this.amplitude; + for (int n = 0; n < this.numOctaves; n++) + { + val += Math.abs(this.noiseGen.noise2d(i + this.offsetX, this.offsetY) * curAmplitude); + i *= 2; + curAmplitude *= this.persistance; + } + return val; + } + + @Override + public float getNoise(float i, float j) + { + i *= this.frequencyX; + j *= this.frequencyY; + if (this.numOctaves == 2) + { + return Math.abs(this.noiseGen.noise2d(i + this.offsetX, j + this.offsetY) * this.amplitude) + Math.abs(this.noiseGen.noise2d(i + i + this.offsetX, j + j + this.offsetY) * this.amplitude * this.persistance); + } + + float val = 0; + float curAmplitude = this.amplitude; + for (int n = 0; n < this.numOctaves; n++) + { + val += Math.abs(this.noiseGen.noise2d(i + this.offsetX, j + this.offsetY) * curAmplitude); + i += i; + j += j; + curAmplitude *= this.persistance; + } + return val; + } + + @Override + public float getNoise(float i, float j, float k) + { + i *= this.frequencyX; + j *= this.frequencyY; + k *= this.frequencyZ; + float val = 0; + for (int n = 0; n < this.numOctaves; n++) + { + val += Math.abs(this.noiseGen.noise3d(i + this.offsetX, j + this.offsetY, k + this.offsetZ) * this.amplitude); + i *= 2; + j *= 2; + k *= 2; + } + return val; + } +} diff --git a/src/main/java/dev/galacticraft/api/perlin/generator/Gradient.java b/src/main/java/dev/galacticraft/api/perlin/generator/Gradient.java new file mode 100644 index 000000000..011fe4f65 --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/generator/Gradient.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin.generator; + +import dev.galacticraft.api.perlin.FishyNoise; +import dev.galacticraft.api.perlin.NoiseModule; + +import java.util.Random; + +public class Gradient extends NoiseModule +{ + private final FishyNoise noiseGen; + private final float offsetX; + private final float offsetY; + private final float offsetZ; + private final int numOctaves; + private final float persistance; + + public Gradient(long seed, int nOctaves, float p) + { + this.numOctaves = nOctaves; + this.persistance = p; + final Random rand = new Random(seed); + this.offsetX = rand.nextFloat() / 2 + 0.01F; + this.offsetY = rand.nextFloat() / 2 + 0.01F; + this.offsetZ = rand.nextFloat() / 2 + 0.01F; + this.noiseGen = new FishyNoise(seed); + } + + @Override + public float getNoise(float i) + { + i *= this.frequencyX; + float val = 0; + float curAmplitude = this.amplitude; + for (int n = 0; n < this.numOctaves; n++) + { + val += this.noiseGen.noise2d(i + this.offsetX, this.offsetY) * curAmplitude; + i *= 2; + curAmplitude *= this.persistance; + } + return val; + } + + @Override + public float getNoise(float i, float j) + { + if (this.numOctaves == 1) + { + return this.noiseGen.noise2d(i * this.frequencyX + this.offsetX, j * this.frequencyY + this.offsetY) * this.amplitude; + } + + i *= this.frequencyX; + j *= this.frequencyY; + float val = 0; + float curAmplitude = this.amplitude; + for (int n = 0; n < this.numOctaves; n++) + { + val += this.noiseGen.noise2d(i + this.offsetX, j + this.offsetY) * curAmplitude; + i *= 2; + j *= 2; + curAmplitude *= this.persistance; + } + return val; + } + + @Override + public float getNoise(float i, float j, float k) + { + if (this.numOctaves == 1) + { + return this.noiseGen.noise3d(i * this.frequencyX + this.offsetX, j * this.frequencyY + this.offsetY, k * this.frequencyZ + this.offsetZ) * this.amplitude; + } + + i *= this.frequencyX; + j *= this.frequencyY; + k *= this.frequencyZ; + float val = 0; + float curAmplitude = this.amplitude; + for (int n = 0; n < this.numOctaves; n++) + { + val += this.noiseGen.noise3d(i + this.offsetX, j + this.offsetY, k + this.offsetZ) * curAmplitude; + i *= 2; + j *= 2; + k *= 2; + curAmplitude *= this.persistance; + } + return val; + } +} diff --git a/src/main/java/dev/galacticraft/api/perlin/generator/RidgedMulti.java b/src/main/java/dev/galacticraft/api/perlin/generator/RidgedMulti.java new file mode 100644 index 000000000..8527ed426 --- /dev/null +++ b/src/main/java/dev/galacticraft/api/perlin/generator/RidgedMulti.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.perlin.generator; + +import dev.galacticraft.api.perlin.FishyNoise; +import dev.galacticraft.api.perlin.NoiseModule; + +import java.util.Random; + +public class RidgedMulti extends NoiseModule +{ + private final FishyNoise noiseGen; + private final float offsetX; + private final float offsetY; + private final float offsetZ; + private final int numOctaves; + + public RidgedMulti(long seed, int nOctaves) + { + this.numOctaves = nOctaves; + final Random rand = new Random(seed); + this.offsetX = rand.nextFloat() / 2 + 0.01F; + this.offsetY = rand.nextFloat() / 2 + 0.01F; + this.offsetZ = rand.nextFloat() / 2 + 0.01F; + this.noiseGen = new FishyNoise(seed); + } + + @Override + public float getNoise(float i) + { + i *= this.frequencyX; + float val = 0; + float weight = 1.0F; + final float offset = 1.0F; + final float gain = 2.0F; + for (int n = 0; n < this.numOctaves; n++) + { + float noise = this.absolute(this.noiseGen.noise2d(i + this.offsetX, this.offsetY)); + noise = offset - noise; + noise *= noise; + noise *= weight; + + weight = noise * gain; + + if (weight > 1F) + { + weight = 1F; + } + + if (weight < 0F) + { + weight = 0F; + } + + val += noise; + + i *= 2; + } + return val; + } + + @Override + public float getNoise(float i, float j) + { + i *= this.frequencyX; + j *= this.frequencyY; + float val = 0; + float weight = 1.0F; + final float offset = 1.0F; + final float gain = 2.0F; + for (int n = 0; n < this.numOctaves; n++) + { + float noise = this.absolute(this.noiseGen.noise2d(i + this.offsetX, j + this.offsetY)); + noise = offset - noise; + noise *= noise; + noise *= weight; + + weight = noise * gain; + + if (weight > 1F) + { + weight = 1F; + } + + if (weight < 0F) + { + weight = 0F; + } + + val += noise; + + i *= 2; + j *= 2; + } + return val; + } + + @Override + public float getNoise(float i, float j, float k) + { + i *= this.frequencyX; + j *= this.frequencyY; + k *= this.frequencyZ; + float val = 0F; + float weight = 1.0F; + final float offset = 1.0F; + final float gain = 2.0F; + for (int n = 0; n < this.numOctaves; n++) + { + float noise = this.absolute(this.noiseGen.noise3d(i + this.offsetX, j + this.offsetY, k + this.offsetZ)); + noise = offset - noise; + noise *= noise; + noise *= weight; + + weight = noise * gain; + + if (weight > 1F) + { + weight = 1F; + } + + if (weight < 0F) + { + weight = 0F; + } + + val += noise; + + i *= 2; + j *= 2; + k *= 2; + } + return val; + } + + private float absolute(float d) + { + if (d < 0) + { + d = -d; + } + return d; + } +} diff --git a/src/main/java/dev/galacticraft/api/vector/BlockVec3.java b/src/main/java/dev/galacticraft/api/vector/BlockVec3.java new file mode 100644 index 000000000..7d3d637c8 --- /dev/null +++ b/src/main/java/dev/galacticraft/api/vector/BlockVec3.java @@ -0,0 +1,698 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.api.vector; +import dev.galacticraft.mod.world.dimension.GCDimensions; +import net.minecraft.CrashReport; +import net.minecraft.CrashReportCategory; +import net.minecraft.ReportedException; +import net.minecraft.commands.arguments.NbtTagArgument; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.contents.NbtContents; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.commands.data.BlockDataAccessor; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.DirectionProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.storage.loot.providers.nbt.NbtProvider; +import org.jetbrains.annotations.Nullable; +import org.joml.Vector3d; + +import static net.minecraft.util.Mth.floor; + + +public class BlockVec3 implements Cloneable +{ + public int x; + public int y; + public int z; + public int sideDoneBits = 0; + private static ChunkAccess chunkCached; + public static ResourceKey chunkCacheDim = Level.OVERWORLD; + private static int chunkCacheX = 1876000; // outside the world edge + private static int chunkCacheZ = 1876000; // outside the world edge + private static ChunkAccess chunkCached_Client; + public static ResourceKey chunkCacheDim_Client = Level.OVERWORLD; + private static int chunkCacheX_Client = 1876000; // outside the world edge + private static int chunkCacheZ_Client = 1876000; // outside the world edge + // INVALID_VECTOR is used in cases where a null vector cannot be used + public static final BlockVec3 INVALID_VECTOR = new BlockVec3(-1, -1, -1); + + public BlockVec3() + { + this(0, 0, 0); + } + + public BlockVec3(BlockPos pos) + { + this(pos.getX(), pos.getY(), pos.getZ()); + } + + public BlockVec3(int x, int y, int z) + { + this.x = x; + this.y = y; + this.z = z; + } + + public BlockVec3(Entity par1) + { + this.x = (int) Math.floor(par1.position().x); + this.y = (int) Math.floor(par1.position().y); + this.z = (int) Math.floor(par1.position().z); + } + + public BlockVec3(BlockEntity par1) + { + this.x = par1.getBlockPos().getX(); + this.y = par1.getBlockPos().getY(); + this.z = par1.getBlockPos().getZ(); + } + + /** + * Makes a new copy of this Vector. Prevents variable referencing problems. + */ + @Override + public final BlockVec3 clone() + { + return new BlockVec3(this.x, this.y, this.z); + } + + public BlockPos toBlockPos() + { + return new BlockPos(this.x, this.y, this.z); + } + + /** + * Get block ID at the BlockVec3 coordinates, with a forced chunk load if + * the coordinates are unloaded. + * + * @param world + * @return the block ID, or null if the y-coordinate is less than 0 or + * greater than 256 or the x or z is outside the Minecraft worldmap. + */ + public BlockState getBlockState(Level world) + { + if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) + { + return null; + } + + int chunkx = this.x >> 4; + int chunkz = this.z >> 4; + try + { + if (!world.isClientSide()) + { + if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.dimension() && BlockVec3.chunkCached_Client != null) + { + return BlockVec3.chunkCached_Client.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached_Client = chunk; + BlockVec3.chunkCacheDim_Client = world.dimension(); + BlockVec3.chunkCacheX_Client = chunkx; + BlockVec3.chunkCacheZ_Client = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + else + { + // In a typical inner loop, 80% of the time consecutive calls to + // this will be within the same chunk + if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.dimension() && BlockVec3.chunkCached instanceof LevelChunk) + { + return BlockVec3.chunkCached.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached = chunk; + BlockVec3.chunkCacheDim = world.dimension(); + BlockVec3.chunkCacheX = chunkx; + BlockVec3.chunkCacheZ = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Oxygen Sealer thread: Exception getting block type in world"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Requested block coordinates"); + crashreportcategory.setDetail("Location", CrashReportCategory.formatLocation(world, new BlockPos(this.x, this.y, this.z))); + throw new ReportedException(crashreport); + } + } + + /** + * Get block ID at the BlockVec3 coordinates without forcing a chunk load. + * + * @param world + * @return the block ID, or null if the y-coordinate is less than 0 or + * greater than 256 or the x or z is outside the Minecraft worldmap. + * Returns Blocks.BEDROCK if the coordinates being checked are in an + * unloaded chunk + */ + public BlockState getBlockState_noChunkLoad(Level world) + { + if (this.y < 0 || this.y >= 256 || this.x < -30000000 || this.z < -30000000 || this.x >= 30000000 || this.z >= 30000000) + { + return null; + } + + int chunkx = this.x >> 4; + int chunkz = this.z >> 4; + try + { + if (world.isLoaded(new BlockPos(chunkx, this.y ,chunkz))) + { + if (!world.isClientSide()) + { + if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.dimension() && BlockVec3.chunkCached_Client != null) + { + return BlockVec3.chunkCached_Client.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached_Client = chunk; + BlockVec3.chunkCacheDim_Client = world.dimension(); + BlockVec3.chunkCacheX_Client = chunkx; + BlockVec3.chunkCacheZ_Client = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + else + { + // In a typical inner loop, 80% of the time consecutive calls to + // this will be within the same chunk + if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.dimension() && BlockVec3.chunkCached instanceof LevelChunk) + { + return BlockVec3.chunkCached.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached = chunk; + BlockVec3.chunkCacheDim = world.dimension(); + BlockVec3.chunkCacheX = chunkx; + BlockVec3.chunkCacheZ = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + } + //Chunk doesn't exist - meaning, it is not loaded + return Blocks.BEDROCK.defaultBlockState(); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Oxygen Sealer thread: Exception getting block type in world"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Requested block coordinates"); + crashreportcategory.setDetail("Location", CrashReportCategory.formatLocation(world, new BlockPos(this.x, this.y, this.z))); + throw new ReportedException(crashreport); + } + } + + public BlockState getBlockState(BlockGetter par1iBlockAccess) + { + return par1iBlockAccess.getBlockState(new BlockPos(this.x, this.y, this.z)); + } + + /** + * Get block ID at the BlockVec3 coordinates without forcing a chunk load. + * Only call this 'safe' version if x and z coordinates are within the + * Minecraft world map (-30m to +30m) + * + * @param world + * @return the block ID, or null if the y-coordinate is less than 0 or + * greater than 256. Returns Blocks.BEDROCK if the coordinates being + * checked are in an unloaded chunk + */ + @Nullable + public BlockState getBlockStateSafe_noChunkLoad(Level world) + { + if (this.y < 0 || this.y >= 256) + { + return null; + } + + int chunkx = this.x >> 4; + int chunkz = this.z >> 4; + try + { + if (world.isLoaded(new BlockPos(chunkx, this.y ,chunkz))) + { + if (!world.isClientSide()) + { + if (BlockVec3.chunkCacheX_Client == chunkx && BlockVec3.chunkCacheZ_Client == chunkz && BlockVec3.chunkCacheDim_Client == world.dimension() && BlockVec3.chunkCached_Client != null) + { + return BlockVec3.chunkCached_Client.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached_Client = chunk; + BlockVec3.chunkCacheDim_Client = world.dimension(); + BlockVec3.chunkCacheX_Client = chunkx; + BlockVec3.chunkCacheZ_Client = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + else + { + // In a typical inner loop, 80% of the time consecutive calls to + // this will be within the same chunk + if (BlockVec3.chunkCacheX == chunkx && BlockVec3.chunkCacheZ == chunkz && BlockVec3.chunkCacheDim == world.dimension() && BlockVec3.chunkCached instanceof LevelChunk) + { + return BlockVec3.chunkCached.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + else + { + final ChunkAccess chunk = world.getChunk(chunkx, chunkz); + BlockVec3.chunkCached = chunk; + BlockVec3.chunkCacheDim = world.dimension(); + BlockVec3.chunkCacheX = chunkx; + BlockVec3.chunkCacheZ = chunkz; + return chunk.getBlockState(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + } + } + //Chunk doesn't exist - meaning, it is not loaded + return Blocks.BEDROCK.defaultBlockState(); + } + catch (Throwable throwable) + { + CrashReport crashreport = CrashReport.forThrowable(throwable, "Oxygen Sealer thread: Exception getting block type in world"); + CrashReportCategory crashreportcategory = crashreport.addCategory("Requested block coordinates"); + crashreportcategory.setDetail("Location", CrashReportCategory.formatLocation(world, new BlockPos(this.x, this.y, this.z))); + throw new ReportedException(crashreport); + } + } + + public BlockVec3 translate(BlockVec3 par1) + { + this.x += par1.x; + this.y += par1.y; + this.z += par1.z; + return this; + } + + public BlockVec3 translate(int par1x, int par1y, int par1z) + { + this.x += par1x; + this.y += par1y; + this.z += par1z; + return this; + } + + public static BlockVec3 add(BlockVec3 par1, BlockVec3 a) + { + return new BlockVec3(par1.x + a.x, par1.y + a.y, par1.z + a.z); + } + + public BlockVec3 subtract(BlockVec3 par1) + { + this.x -= par1.x; + this.y -= par1.y; + this.z -= par1.z; + + return this; + } + + public BlockVec3 scale(int par1) + { + this.x *= par1; + this.y *= par1; + this.z *= par1; + + return this; + } + + public BlockVec3 modifyPositionFromSide(Direction side, int amount) + { + switch (side.ordinal()) + { + case 0: + this.y -= amount; + break; + case 1: + this.y += amount; + break; + case 2: + this.z -= amount; + break; + case 3: + this.z += amount; + break; + case 4: + this.x -= amount; + break; + case 5: + this.x += amount; + break; + } + return this; + } + + public BlockVec3 newVecSide(int side) + { + final BlockVec3 vec = new BlockVec3(this.x, this.y, this.z); + vec.sideDoneBits = (1 << (side ^ 1)) + (side << 6); + switch (side) + { + case 0: + vec.y--; + return vec; + case 1: + vec.y++; + return vec; + case 2: + vec.z--; + return vec; + case 3: + vec.z++; + return vec; + case 4: + vec.x--; + return vec; + case 5: + vec.x++; + return vec; + } + return vec; + } + + public BlockVec3 modifyPositionFromSide(Direction side) + { + return this.modifyPositionFromSide(side, 1); + } + + @Override + public int hashCode() + { + // Upgraded hashCode calculation from the one in VecDirPair to something + // a bit stronger and faster + return ((this.y * 379 + this.x) * 373 + this.z) * 7; + } + + @Override + public boolean equals(Object o) + { + if (o instanceof BlockVec3) + { + final BlockVec3 vector = (BlockVec3) o; + return this.x == vector.x && this.y == vector.y && this.z == vector.z; + } + + return false; + } + + @Override + public String toString() + { + return "[" + this.x + "," + this.y + "," + this.z + "]"; + } + + /** + * This will load the chunk. + */ + public BlockEntity getTileEntity(BlockGetter world) + { + return world.getBlockEntity(new BlockPos(this.x, this.y, this.z)); + } + + /** + * No chunk load: returns null if chunk to side is unloaded + */ + public BlockEntity getTileEntityOnSide(Level world, Direction side) + { + if (side == null) + { + return null; + } + + int x = this.x; + int y = this.y; + int z = this.z; + switch (side.ordinal()) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return null; + } + final BlockPos pos = new BlockPos(x, y, z); + return world.isLoaded(pos) ? world.getBlockEntity(pos) : null; + } + + /** + * No chunk load: returns null if chunk to side is unloaded + */ + public BlockEntity getTileEntityOnSide(Level world, int side) + { + int x = this.x; + int y = this.y; + int z = this.z; + switch (side) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return null; + } + final BlockPos pos = new BlockPos(x, y, z); + return world.isLoaded(pos) ? world.getBlockEntity(pos) : null; + } + + /** + * This will load the chunk to the side. + */ + public boolean blockOnSideHasSolidFace(Level world, int side) + { + int x = this.x; + int y = this.y; + int z = this.z; + switch (side) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return false; + } + final BlockPos pos = new BlockPos(x, y, z); + return world.getBlockState(pos).isFaceSturdy(world.getChunkForCollisions(pos.getX(), pos.getZ()), pos, Direction.from3DDataValue(side ^ 1)); + } + + /** + * No chunk load: returns null if chunk is unloaded + */ + public Block getBlockOnSide(Level world, int side) + { + int x = this.x; + int y = this.y; + int z = this.z; + switch (side) + { + case 0: + y--; + break; + case 1: + y++; + break; + case 2: + z--; + break; + case 3: + z++; + break; + case 4: + x--; + break; + case 5: + x++; + break; + default: + return null; + } + final BlockPos pos = new BlockPos(x, y, z); + return world.isLoaded(pos) ? world.getBlockState(pos).getBlock() : null; + } + + public static BlockVec3 readFromNBT(CompoundTag nbtCompound) + { + final BlockVec3 tempVector = new BlockVec3(); + tempVector.x = nbtCompound.getInt("x"); + tempVector.y = nbtCompound.getInt("y"); + tempVector.z = nbtCompound.getInt("z"); + return tempVector; + } + + public int distanceTo(BlockVec3 vector) + { + int var2 = vector.x - this.x; + int var4 = vector.y - this.y; + int var6 = vector.z - this.z; + return floor(Math.sqrt(var2 * var2 + var4 * var4 + var6 * var6)); + } + + public int distanceSquared(BlockVec3 vector) + { + int var2 = vector.x - this.x; + int var4 = vector.y - this.y; + int var6 = vector.z - this.z; + return var2 * var2 + var4 * var4 + var6 * var6; + } + + public CompoundTag writeToNBT(CompoundTag par1NBTTagCompound) + { + par1NBTTagCompound.putInt("x", this.x); + par1NBTTagCompound.putInt("y", this.y); + par1NBTTagCompound.putInt("z", this.z); + return par1NBTTagCompound; + } + + public BlockVec3(CompoundTag par1NBTTagCompound) + { + this.x = par1NBTTagCompound.getInt("x"); + this.y = par1NBTTagCompound.getInt("y"); + this.z = par1NBTTagCompound.getInt("z"); + } + + public CompoundTag writeToNBT(CompoundTag par1NBTTagCompound, String prefix) + { + par1NBTTagCompound.putInt(prefix + "_x", this.x); + par1NBTTagCompound.putInt(prefix + "_y", this.y); + par1NBTTagCompound.putInt(prefix + "_z", this.z); + return par1NBTTagCompound; + } + + public static BlockVec3 readFromNBT(CompoundTag par1NBTTagCompound, String prefix) + { + Integer readX = par1NBTTagCompound.getInt(prefix + "_x"); + if (readX == null) return null; + Integer readY = par1NBTTagCompound.getInt(prefix + "_y"); + if (readY == null) return null; + Integer readZ = par1NBTTagCompound.getInt(prefix + "_z"); + if (readZ == null) return null; + return new BlockVec3(readX, readY, readZ); + } + + public double getMagnitude() + { + return Math.sqrt(this.getMagnitudeSquared()); + } + + public int getMagnitudeSquared() + { + return this.x * this.x + this.y * this.y + this.z * this.z; + } + + public void setBlock(Level worldObj, BlockState block) + { + worldObj.setBlock(new BlockPos(x, y, z), block, 3); + } + + public boolean blockExists(Level world) + { + return world.isLoaded(new BlockPos(this.x, this.y, this.z)); + } + + public void setSideDone(int side) + { + this.sideDoneBits |= 1 << side; + } + + public BlockEntity getTileEntityForce(Level world) + { + int chunkx = this.x >> 4; + int chunkz = this.z >> 4; + + ChunkAccess chunk = world.getChunk(chunkx, chunkz); + return chunk.getBlockEntity(new BlockPos(this.x & 15, this.y, this.z & 15)); + } + + public Vector3d midPoint() + { + return new Vector3d(this.x + 0.5, this.y + 0.5, this.z + 0.5); + } +} diff --git a/src/main/java/dev/galacticraft/impl/internal/fabric/GalacticraftAPI.java b/src/main/java/dev/galacticraft/impl/internal/fabric/GalacticraftAPI.java index f4f65dee5..2e02222af 100644 --- a/src/main/java/dev/galacticraft/impl/internal/fabric/GalacticraftAPI.java +++ b/src/main/java/dev/galacticraft/impl/internal/fabric/GalacticraftAPI.java @@ -32,6 +32,7 @@ import dev.galacticraft.api.universe.celestialbody.CelestialBody; import dev.galacticraft.api.universe.celestialbody.landable.teleporter.CelestialTeleporter; import dev.galacticraft.api.universe.galaxy.Galaxy; +import dev.galacticraft.dynamicdimensions.api.DynamicDimensionRegistry; import dev.galacticraft.dynamicdimensions.api.event.DynamicDimensionLoadCallback; import dev.galacticraft.impl.internal.command.GCApiCommands; import dev.galacticraft.impl.network.GCApiPackets; @@ -42,14 +43,29 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.event.registry.DynamicRegistries; import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.client.Minecraft; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.SimpleContainer; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.storage.LevelResource; +import net.minecraft.world.level.storage.LevelStorageSource; import org.jetbrains.annotations.ApiStatus; +import javax.swing.event.ChangeEvent; +import java.io.File; +import java.nio.file.Path; + @ApiStatus.Internal public class GalacticraftAPI implements ModInitializer { public static final SimpleContainer EMPTY_INV = new SimpleContainer(0); + //don't know if this is the best way to get file path, but it works + public static Path currentWorldSaveDirectory; @Override public void onInitialize() { @@ -72,6 +88,7 @@ public void onInitialize() { BuiltinObjects.register(); BuiltInRocketRegistries.initialize(); GcApiEntityAttributes.init(); + ServerLifecycleEvents.SERVER_STARTED.register(this::onServerStarted); DynamicDimensionLoadCallback.register((minecraftServer, dynamicDimensionLoader) -> { ((SatelliteAccessor) minecraftServer).galacticraft$loadSatellites(dynamicDimensionLoader); @@ -88,4 +105,21 @@ public void onInitialize() { GCApiServerPacketReceivers.register(); Constant.LOGGER.info("API Initialization Complete. (Took {}ms).", System.currentTimeMillis() - startInitTime); } + + private void onServerStarted(MinecraftServer server) { + // Update the directory when the server starts + updateWorldSaveDirectory(server); + } + + private void updateWorldSaveDirectory(MinecraftServer server) { + // Get the main (overworld) level from the server + ServerLevel overworld = server.getLevel(net.minecraft.world.level.Level.OVERWORLD); + + if (overworld != null) { + currentWorldSaveDirectory = overworld.getServer().getWorldPath(LevelResource.ROOT); + System.out.println("World Save Directory: " + currentWorldSaveDirectory.toString()); + } else { + System.err.println("Error: Overworld level is null"); + } + } } diff --git a/src/main/java/dev/galacticraft/mod/Constant.java b/src/main/java/dev/galacticraft/mod/Constant.java index 532ebcd68..05d8558c4 100644 --- a/src/main/java/dev/galacticraft/mod/Constant.java +++ b/src/main/java/dev/galacticraft/mod/Constant.java @@ -27,6 +27,8 @@ import net.minecraft.ChatFormatting; import net.minecraft.core.Direction; import net.minecraft.core.Registry; +import net.minecraft.data.models.model.ModelTemplate; +import net.minecraft.data.models.model.TextureSlot; import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; import net.minecraft.resources.ResourceKey; @@ -39,6 +41,7 @@ public interface Constant { String MOD_ID = "galacticraft"; + public static final String GCDATAFOLDER = "../galacticraft/"; String COMMON_NAMESPACE = "c"; Logger LOGGER = LogManager.getLogger("Galacticraft"); @@ -136,6 +139,7 @@ interface Block { String ASTEROID_ROCK = "asteroid_rock"; String ASTEROID_ROCK_1 = "asteroid_rock_block_1"; String ASTEROID_ROCK_2 = "asteroid_rock_block_2"; + String DENSE_ICE = "dense_ice"; String SOFT_VENUS_ROCK = "soft_venus_rock"; String HARD_VENUS_ROCK = "hard_venus_rock"; @@ -145,6 +149,9 @@ interface Block { String VAPOR_SPOUT = "vapor_spout"; // Ore + String MARS_IRON_ORE = "mars_iron_ore"; + String MARS_TIN_ORE = "mars_tin_ore"; + String MARS_COPPER_ORE = "mars_copper_ore"; String MOON_COPPER_ORE = "moon_copper_ore"; String LUNASLATE_COPPER_ORE = "lunaslate_copper_ore"; String DESH_ORE = "desh_ore"; @@ -155,6 +162,9 @@ interface Block { String DEEPSLATE_TIN_ORE = "deepslate_tin_ore"; String MOON_TIN_ORE = "moon_tin_ore"; String LUNASLATE_TIN_ORE = "lunaslate_tin_ore"; + String ASTEROID_ALUMINUM_ORE = "asteroid_aluminum_ore"; + String ASTEROID_IRON_ORE = "asteroid_iron_ore"; + String ASTEROID_SILICON_ORE = "asteroid_silicon_ore"; String ALUMINUM_ORE = "aluminum_ore"; String DEEPSLATE_ALUMINUM_ORE = "deepslate_aluminum_ore"; String GALENA_ORE = "galena_ore"; @@ -258,6 +268,7 @@ interface Block { String OXYGEN_BUBBLE_DISTRIBUTOR = "oxygen_bubble_distributor"; String OXYGEN_COLLECTOR = "oxygen_collector"; String OXYGEN_COMPRESSOR = "oxygen_compressor"; + String FOOD_CANNER = "food_canner"; String OXYGEN_DECOMPRESSOR = "oxygen_decompressor"; String OXYGEN_DETECTOR = "oxygen_detector"; String OXYGEN_SEALER = "oxygen_sealer"; @@ -338,8 +349,12 @@ static ResourceLocation getId(String s) { } interface Item { + String ITEM_GROUP_CANS = "cans"; String ITEM_GROUP = "items"; String SILICON = "silicon"; + String CANNED_FOOD = "canned_food"; + String EMPTY_CANNED_FOOD = "empty_can"; + String RAW_SILICON = "raw_silicon"; String RAW_METEORIC_IRON = "raw_meteoric_iron"; String METEORIC_IRON_INGOT = "meteoric_iron_ingot"; String METEORIC_IRON_NUGGET = "meteoric_iron_nugget"; @@ -402,12 +417,6 @@ interface Item { String GROUND_BEEF = "ground_beef"; String BEEF_PATTY = "beef_patty"; String CHEESEBURGER = "cheeseburger"; - //CANNED FOOD - String CANNED_DEHYDRATED_APPLE = "canned_dehydrated_apple"; - String CANNED_DEHYDRATED_CARROT = "canned_dehydrated_carrot"; - String CANNED_DEHYDRATED_MELON = "canned_dehydrated_melon"; - String CANNED_DEHYDRATED_POTATO = "canned_dehydrated_potato"; - String CANNED_BEEF = "canned_beef"; //ROCKET PARTS String TIER_1_HEAVY_DUTY_PLATE = "heavy_plating"; String TIER_2_HEAVY_DUTY_PLATE = "heavy_plating_t2"; @@ -552,6 +561,7 @@ interface ScreenTexture { ResourceLocation PLANET_ICONS = id("textures/gui/planet_icons.png"); ResourceLocation BUBBLE_DISTRIBUTOR_SCREEN = id("textures/gui/oxygen_bubble_distributor_screen.png"); ResourceLocation OXYGEN_COMPRESSOR_SCREEN = id("textures/gui/oxygen_compressor_screen.png"); + ResourceLocation FOOD_CANNER_SCREEN = id("textures/gui/food_canner_screen.png"); ResourceLocation OXYGEN_STORAGE_MODULE_SCREEN = id("textures/gui/oxygen_storage_module_screen.png"); ResourceLocation OXYGEN_SEALER_SCREEN = id("textures/gui/oxygen_sealer_screen.png"); ResourceLocation FUEL_LOADER_SCREEN = id("textures/gui/fuel_loader_screen.png"); @@ -672,6 +682,7 @@ interface Menu { String OXYGEN_COLLECTOR_MENU = "oxygen_collector_menu"; String BUBBLE_DISTRIBUTOR_MENU = "bubble_distributor_menu"; String OXYGEN_COMPRESSOR_MENU = "oxygen_compressor_menu"; + String FOOD_CANNER_MENU = "food_canner_menu"; String OXYGEN_DECOMPRESSOR_MENU = "oxygen_decompressor_menu"; String OXYGEN_STORAGE_MODULE_MENU = "oxygen_storage_module_menu"; String OXYGEN_SEALER_MENU = "oxygen_sealer_menu"; diff --git a/src/main/java/dev/galacticraft/mod/Galacticraft.java b/src/main/java/dev/galacticraft/mod/Galacticraft.java index 89a2c5de2..f459621c4 100644 --- a/src/main/java/dev/galacticraft/mod/Galacticraft.java +++ b/src/main/java/dev/galacticraft/mod/Galacticraft.java @@ -53,8 +53,13 @@ import dev.galacticraft.mod.world.poi.GCPointOfInterestTypes; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.packs.PackType; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.item.Item; public class Galacticraft implements ModInitializer { public static final Config CONFIG = new ConfigImpl(FabricLoader.getInstance().getConfigDir().resolve("galacticraft.json").toFile()); @@ -63,6 +68,7 @@ public class Galacticraft implements ModInitializer { public void onInitialize() { long startInitTime = System.currentTimeMillis(); Constant.LOGGER.info("Starting initialization."); + GCChunkGenerator.register(); GCTags.register(); GCFluids.register(); GCBlocks.register(); diff --git a/src/main/java/dev/galacticraft/mod/GalacticraftClient.java b/src/main/java/dev/galacticraft/mod/GalacticraftClient.java index 5fafff4c8..fe75b4ee8 100644 --- a/src/main/java/dev/galacticraft/mod/GalacticraftClient.java +++ b/src/main/java/dev/galacticraft/mod/GalacticraftClient.java @@ -47,6 +47,7 @@ import dev.galacticraft.mod.content.GCEntityTypes; import dev.galacticraft.mod.content.block.environment.FallenMeteorBlock; import dev.galacticraft.mod.content.entity.orbital.RocketEntity; +import dev.galacticraft.mod.content.item.CannedFoodItem; import dev.galacticraft.mod.content.item.GCItems; import dev.galacticraft.mod.events.ClientEventHandler; import dev.galacticraft.mod.misc.cape.CapesLoader; @@ -60,6 +61,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; @@ -72,11 +74,25 @@ import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.entity.ThrownItemRenderer; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.server.packs.PackType; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.material.Fluids; +import java.util.*; +import java.util.List; + +import static dev.galacticraft.mod.content.item.CannedFoodItem.registerCan; +import static dev.galacticraft.mod.content.item.GCItems.CANNED_FOOD_ITEMS; +import static dev.galacticraft.mod.util.TextureUtils.getAverageColor; + @Environment(EnvType.CLIENT) public class GalacticraftClient implements ClientModInitializer { + + private boolean colorsInitialized = false; + @Override public void onInitializeClient() { long startInitTime = System.currentTimeMillis(); @@ -96,6 +112,7 @@ public void onInitializeClient() { MenuScreens.register(GCMenuTypes.ENERGY_STORAGE_MODULE, EnergyStorageModuleScreen::new); MenuScreens.register(GCMenuTypes.OXYGEN_COLLECTOR, OxygenCollectorScreen::new); MenuScreens.register(GCMenuTypes.OXYGEN_COMPRESSOR, OxygenCompressorScreen::new); + MenuScreens.register(GCMenuTypes.FOOD_CANNER, FoodCannerScreen::new); MenuScreens.register(GCMenuTypes.OXYGEN_DECOMPRESSOR, OxygenDecompressorScreen::new); MenuScreens.register(GCMenuTypes.PLAYER_INV_GC, GCPlayerInventoryScreen::new); MenuScreens.register(GCMenuTypes.OXYGEN_BUBBLE_DISTRIBUTOR, OxygenBubbleDistributorScreen::new); @@ -179,11 +196,56 @@ public void onInitializeClient() { LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> { }); - + GCRenderTypes.init(); + //couldn't be bothered finding a better way to get the texture of the items so overrides exists now + List nameOverride = new ArrayList<>(); + nameOverride.add(new String[]{"enchanted_golden_apple", "golden_apple"}); + nameOverride.add(new String[]{"air", "lime_dye"}); ModelLoadingPlugin.register(GCModelLoader.INSTANCE); - GCRenderTypes.init(); + //Todo: make fix for the color of the labels based of component nbt +// ClientTickEvents.END_CLIENT_TICK.register(client -> { +// if (!colorsInitialized) +// { +// if (client.player != null && client.level != null) +// { +// CANNED_FOOD_ITEMS.forEach(cannedFoodItem -> { +// Optional cannedItem = CannedFoodItem.getContents(cannedFoodItem.getDefaultInstance()).stream().findFirst(); +// if (cannedItem.isPresent()) { +// String nameComponent = cannedItem.toString(); +// String itemName = extractInsideBrackets(nameComponent); +// assert itemName != null; +// String[] parts = itemName.split(":"); +// String namespace = parts[0]; +// String item = parts[1]; +// for (String[] element: nameOverride) +// { +// if (parts[1].equals(element[0])) +// { +// item = element[1]; +// } +// } +// ResourceLocation textureLocation = new ResourceLocation(namespace, "textures/item/" + item + ".png"); +// int avgColor = getAverageColor(textureLocation); +// cannedFoodItem.setColor(avgColor); +// } +// }); +// colorsInitialized = true; +// } +// } +// }); + //For every edible food create a creative item of that canned food type + for (Item item : BuiltInRegistries.ITEM) + { + if (item.components().has(DataComponents.FOOD)) + { + if (!(item instanceof CannedFoodItem)) + { + registerCan(item.getDefaultInstance()); + } + } + } Constant.LOGGER.info("Client initialization complete. (Took {}ms.)", System.currentTimeMillis() - startInitTime); } @@ -201,4 +263,13 @@ public static void init() { GCDimensionEffects.register(); } + + public static String extractInsideBrackets(String input) { + int startIndex = input.indexOf('{'); + int endIndex = input.indexOf('}'); + if (startIndex != -1 && endIndex != -1 && startIndex < endIndex) { + return input.substring(startIndex + 1, endIndex); + } + return null; + } } diff --git a/src/main/java/dev/galacticraft/mod/accessor/ServerLevelAccessor.java b/src/main/java/dev/galacticraft/mod/accessor/ServerLevelAccessor.java index 91d11fa03..6a6100a0c 100644 --- a/src/main/java/dev/galacticraft/mod/accessor/ServerLevelAccessor.java +++ b/src/main/java/dev/galacticraft/mod/accessor/ServerLevelAccessor.java @@ -23,9 +23,10 @@ package dev.galacticraft.mod.accessor; import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import net.minecraft.server.level.ServerLevel; public interface ServerLevelAccessor { - void addSealer(OxygenSealerBlockEntity sealer); + void addSealer(OxygenSealerBlockEntity sealer, ServerLevel world); - void removeSealer(OxygenSealerBlockEntity sealer); + void removeSealer(OxygenSealerBlockEntity sealer, ServerLevel world); } diff --git a/src/main/java/dev/galacticraft/mod/api/config/Config.java b/src/main/java/dev/galacticraft/mod/api/config/Config.java index 6b5728278..5c70bad59 100644 --- a/src/main/java/dev/galacticraft/mod/api/config/Config.java +++ b/src/main/java/dev/galacticraft/mod/api/config/Config.java @@ -52,6 +52,7 @@ public interface Config { long machineEnergyStorageSize(); long oxygenCompressorEnergyConsumptionRate(); + long foodCannerEnergyConsumptionRate(); long oxygenDecompressorEnergyConsumptionRate(); diff --git a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/FoodCannerScreen.java b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/FoodCannerScreen.java new file mode 100644 index 000000000..a619f7c57 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/FoodCannerScreen.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.client.gui.screen.ingame; + +import com.mojang.blaze3d.vertex.PoseStack; +import dev.galacticraft.machinelib.client.api.screen.MachineScreen; +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.content.block.entity.machine.FoodCannerBlockEntity; +import dev.galacticraft.mod.screen.FoodCannerMenu; +import dev.galacticraft.mod.util.DrawableUtil; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Inventory; + +@Environment(EnvType.CLIENT) +public class FoodCannerScreen extends MachineScreen { + public FoodCannerScreen(FoodCannerMenu handler, Inventory inv, Component title) { + super(handler, title, Constant.ScreenTexture.FOOD_CANNER_SCREEN); + this.imageHeight = 171; + this.capacitorX = 8; + this.capacitorY = 13; + this.titleLabelY = 4; + } + + private void drawProgressBar(PoseStack matrices) { + if (this.menu.state.isActive()) { + int progress = this.menu.getProgress(); + System.out.println(progress); + if (inBounds(progress, 1, 9)) + { + //transferring can + draw(68, 30, 36, 189, 4, progress, matrices); + } + if (this.menu.getFirstRowConsumed() == 1) + { + if (inBounds(progress, 10, 36)) + { + if (inBounds(progress, 10, 17)) + { + draw(97, 19, 65, 178, 9 - progress, 4, matrices); + } + if (progress > 17) + { + draw(89, 19, 57, 178, 8, 4, matrices); + } + if (inBounds(progress, 18, 19)) + { + draw(89, 19, 57, 178, 17 - progress, 3, matrices); + } + if (progress > 19) + { + draw(86, 19, 54, 178, 3, 3, matrices); + } + if (inBounds(progress, 20, 36)) + { + draw(86, 22, 54, 181, 4, progress - 19, matrices); + } + } + if (inBounds(progress, 37, 106)) + { + draw(86, 19, 54, 178, 11, 20, matrices); + } + } + if (this.menu.getSecondRowConsumed() == 1) + { + if (inBounds(progress, 37, 44)) + { + draw(97, 39, 65, 198, 36 - progress, 2, matrices); + } + if (inBounds(progress, 45, 106)) + { + draw(89, 39, 57, 198, 8, 2, matrices); + } + } + if (this.menu.getThirdRowConsumed() == 1) + { + if (inBounds(progress, 79, 86)) + { + draw(97, 57, 65, 216, 78 - progress, 2, matrices); + } + if (inBounds(progress, 87, 106)) + { + draw(89, 57, 57, 216, 8, 2, matrices); + } + if (inBounds(progress, 87, 96)) + { + draw(87, 59, 55, 218, 2, 86 - progress, matrices); + } + if (inBounds(progress, 97, 106)) + { + draw(87, 59, 55, 218, 2, -10, matrices); + } + } + if (this.menu.getForthRowConsumed() == 1) + { + if (inBounds(progress, 53, 62)) + { + draw(97, 75, 65, 234, 52 - progress, 2, matrices); + } + if (inBounds(progress, 63, 106)) + { + draw(87, 75, 55, 234, 10, 2, matrices); + } + if (inBounds(progress, 63, 78)) + { + draw(87, 75, 55, 234, 2, 62 - progress, matrices); + } + if (inBounds(progress, 79, 106)) + { + draw(87, 75, 55, 234, 2, -16, matrices); + } + if (inBounds(progress, 87, 96)) + { + draw(87, 59, 55, 218, 2, 86 - progress, matrices); + } + if (inBounds(progress, 97, 106)) + { + draw(87, 59, 55, 218, 2, -10, matrices); + } + } + if (inBounds(progress, 45, 52)) + { + draw(87, 39, 55, 198, 2, progress - 44, matrices); + } + if (this.menu.getFirstRowConsumed() == 1 || this.menu.getSecondRowConsumed() == 1) + { + if (inBounds(progress, 52, 106)) + { + draw(87, 39, 55, 198, 2, 8, matrices); + } + } + if (inBounds(progress, 97, 106)) + { + draw(89, 47, 57, 206, 96 - progress, 2, matrices); + } + if (progress > 106) + { + //transferring full can + draw(68, 57, 36, 216, 4, progress - 106 ,matrices); + } + } + } + @Override + protected void renderMachineBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta) { + super.renderMachineBackground(graphics, mouseX, mouseY, delta); + this.drawProgressBar(graphics.pose()); + } + + private boolean inBounds(int value, int min, int max) + { + return (value >= min && value <= max); + } + + private void draw(int x, int y, int drawX, int drawY, int width, int height, PoseStack matrices) + { + if (width < 0) + { + if (height < 0) + { + DrawableUtil.drawProgressTexture(matrices, this.leftPos + x + width, this.topPos + y + height, drawX + width, drawY + height, -width, -height); + }else + { + DrawableUtil.drawProgressTexture(matrices, this.leftPos + x + width, this.topPos + y, drawX + width, drawY, -width, height); + } + } else if (height < 0) + { + DrawableUtil.drawProgressTexture(matrices, this.leftPos + x, this.topPos + y + height, drawX, drawY + height, width, -height); + }else + { + DrawableUtil.drawProgressTexture(matrices, this.leftPos + x, this.topPos + y, drawX, drawY, width, height); + } + } +} diff --git a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java index 588dfbcbc..05ccdd579 100644 --- a/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java +++ b/src/main/java/dev/galacticraft/mod/client/gui/screen/ingame/OxygenSealerScreen.java @@ -27,6 +27,7 @@ import dev.galacticraft.machinelib.client.api.screen.MachineScreen; import dev.galacticraft.mod.Constant; import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import dev.galacticraft.mod.machine.GCMachineStatuses; import dev.galacticraft.mod.util.Translations; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -47,5 +48,11 @@ protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, fl MachineStatus status = this.menu.state.getStatus(); graphics.drawString(this.font, Component.translatable(Translations.Ui.MACHINE_STATUS).append(status != null ? status.getText() : Component.empty()), this.leftPos + 50, this.topPos + 30, ChatFormatting.DARK_GRAY.getColor(), false); + if (!status.equals(GCMachineStatuses.BLOCKED)) { + int insideArea = this.menu.be.getInsideArea(); + int outsideArea = this.menu.be.getOutsideArea(); + graphics.drawString(this.font, Component.literal("INSIDE AREA: ").append(String.valueOf(insideArea)), this.leftPos + 50, this.topPos + 50, ChatFormatting.DARK_GRAY.getColor(), false); + graphics.drawString(this.font, Component.literal("OUTSIDE AREA: ").append(String.valueOf(outsideArea)), this.leftPos + 50, this.topPos + 70, ChatFormatting.DARK_GRAY.getColor(), false); + } } } diff --git a/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidDimensionEffects.java b/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidDimensionEffects.java new file mode 100644 index 000000000..b2cc65bda --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidDimensionEffects.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.client.render.dimension; + +import dev.galacticraft.mod.api.dimension.GalacticDimensionEffects; +import dev.galacticraft.mod.particle.ScaleParticleType; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.client.ParticleStatus; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.DimensionSpecialEffects; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.CubicSampler; +import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.CampfireBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; + +@Environment(EnvType.CLIENT) +public class AsteroidDimensionEffects extends DimensionSpecialEffects { + private static final float[] FOG_COLOR = {0.0F, 0.0F, 0.0F, 0.0F}; + public static final AsteroidDimensionEffects INSTANCE = new AsteroidDimensionEffects(); + + private AsteroidDimensionEffects() { + super(Float.NaN, false, SkyType.NORMAL, false, false); + } + + @Override + public Vec3 getBrightnessDependentFogColor(Vec3 color, float sunHeight) { + return Vec3.ZERO; + } + + @Override + public boolean isFoggyAt(int camX, int camY) { + return false; + } + + @Override + public float[] getSunriseColor(float skyAngle, float tickDelta) { + return FOG_COLOR; + } +} diff --git a/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidSkyRenderer.java b/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidSkyRenderer.java new file mode 100644 index 000000000..8be3deb56 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/client/render/dimension/AsteroidSkyRenderer.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.client.render.dimension; + +import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.*; +import com.mojang.math.Axis; +import dev.galacticraft.mod.Constant; +import net.fabricmc.fabric.api.client.rendering.v1.DimensionRenderingRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.FogRenderer; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.ShaderInstance; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4f; +import org.lwjgl.opengl.GL11; + +public class AsteroidSkyRenderer extends SpaceSkyRenderer { + public static final AsteroidSkyRenderer INSTANCE = new AsteroidSkyRenderer(); + private static final ResourceLocation EARTH_TEXTURE = Constant.id("textures/gui/celestialbodies/earth.png"); + private static final ResourceLocation SUN_TEXTURE = Constant.id("textures/gui/celestialbodies/sun.png"); + + @Override + public void render(WorldRenderContext context) { + context.profiler().push("asteroid_sky_renderer"); + RenderSystem.disableBlend(); + RenderSystem.depthMask(false); + + PoseStack matrices = new PoseStack(); + matrices.mulPose(context.positionMatrix()); + + context.profiler().push("stars"); + matrices.pushPose(); + matrices.mulPose(Axis.YP.rotationDegrees((context.world().getTimeOfDay(context.tickCounter().getRealtimeDeltaTicks()) * 360.0f) - 90F)); + matrices.mulPose(Axis.XP.rotationDegrees((context.world().getTimeOfDay(context.tickCounter().getRealtimeDeltaTicks())) * 360.0f)); + matrices.mulPose(Axis.YP.rotationDegrees(-19.0F)); + + this.starManager.render(matrices, context.projectionMatrix(), context.world(), context.tickCounter().getRealtimeDeltaTicks()); + + matrices.popPose(); + context.profiler().pop(); + + context.profiler().push("sun"); + matrices.pushPose(); + + matrices.mulPose(Axis.YP.rotationDegrees(-90.0F)); + matrices.mulPose(Axis.XP.rotationDegrees(context.world().getTimeOfDay(context.tickCounter().getRealtimeDeltaTicks()) * 360.0f)); + + Matrix4f matrix = matrices.last().pose(); + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); + float size = 6.0F; + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.setShaderTexture(0, SUN_TEXTURE); + BufferBuilder buffer = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + buffer.addVertex(matrix, -size, 100.0F, -size).setUv(0.0F, 0.0F) + .addVertex(matrix, size, 100.0F, -size).setUv(1.0F, 0.0F) + .addVertex(matrix, size, 100.0F, size).setUv(1.0F, 1.0F) + .addVertex(matrix, -size, 100.0F, size).setUv(0.0F, 1.0F); + BufferUploader.drawWithShader(buffer.buildOrThrow()); + + matrices.popPose(); + context.profiler().pop(); + + context.profiler().push("earth"); + matrices.pushPose(); + matrix = matrices.last().pose(); + + size = 1.0F; + assert Minecraft.getInstance().player != null; + float earthRotation = (float) (context.world().getSharedSpawnPos().getZ() - Minecraft.getInstance().player.getZ()) * 0.01F; + matrices.scale(0.6F, 0.6F, 0.6F); + matrices.mulPose(Axis.XP.rotationDegrees((context.world().getTimeOfDay(context.tickCounter().getRealtimeDeltaTicks()) * 360.0F) * 0.001F)); + matrices.mulPose(Axis.XP.rotationDegrees(earthRotation + 200.0F)); + + RenderSystem.setShaderTexture(0, EARTH_TEXTURE); + + buffer = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX); + buffer.addVertex(matrix, -size, -100.0F, size).setUv(0.0F, 1.0F) + .addVertex(matrix, size, -100.0F, size).setUv(1.0F, 1.0F) + .addVertex(matrix, size, -100.0F, -size).setUv(1.0F, 0.0F) + .addVertex(matrix, -size, -100.0F, -size).setUv(0.0F, 0.0F); + BufferUploader.drawWithShader(buffer.buildOrThrow()); + + context.profiler().pop(); + matrices.popPose(); + + RenderSystem.depthMask(true); + context.profiler().pop(); + } +} diff --git a/src/main/java/dev/galacticraft/mod/client/render/dimension/GCDimensionEffects.java b/src/main/java/dev/galacticraft/mod/client/render/dimension/GCDimensionEffects.java index d94269393..773b02f93 100644 --- a/src/main/java/dev/galacticraft/mod/client/render/dimension/GCDimensionEffects.java +++ b/src/main/java/dev/galacticraft/mod/client/render/dimension/GCDimensionEffects.java @@ -30,6 +30,7 @@ public class GCDimensionEffects { public static final ResourceLocation MOON = Constant.id("moon"); public static final ResourceLocation VENUS = Constant.id("venus"); + public static final ResourceLocation ASTEROID = Constant.id("asteroid"); public static void register() { DimensionRenderingRegistry.registerDimensionEffects(MOON, MoonDimensionEffects.INSTANCE); @@ -41,5 +42,10 @@ public static void register() { DimensionRenderingRegistry.registerCloudRenderer(GCDimensions.VENUS, EmptyCloudRenderer.INSTANCE); DimensionRenderingRegistry.registerWeatherRenderer(GCDimensions.VENUS, VenusWeatherRenderer.INSTANCE); DimensionRenderingRegistry.registerSkyRenderer(GCDimensions.VENUS, VenusSkyRenderer.INSTANCE); + + DimensionRenderingRegistry.registerDimensionEffects(ASTEROID, AsteroidDimensionEffects.INSTANCE); + DimensionRenderingRegistry.registerCloudRenderer(GCDimensions.ASTEROID, EmptyCloudRenderer.INSTANCE); + DimensionRenderingRegistry.registerWeatherRenderer(GCDimensions.ASTEROID, EmptyWeatherRenderer.INSTANCE); + DimensionRenderingRegistry.registerSkyRenderer(GCDimensions.ASTEROID, AsteroidSkyRenderer.INSTANCE); } } diff --git a/src/main/java/dev/galacticraft/mod/compat/AppleSkinEventHandler.java b/src/main/java/dev/galacticraft/mod/compat/AppleSkinEventHandler.java new file mode 100644 index 000000000..ae4c88b23 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/compat/AppleSkinEventHandler.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.compat; + +import net.minecraft.world.food.FoodProperties; +import squeek.appleskin.api.AppleSkinApi; +import squeek.appleskin.api.event.FoodValuesEvent; + +import static dev.galacticraft.mod.content.item.CannedFoodItem.getCanFoodProperties; +import static dev.galacticraft.mod.content.item.CannedFoodItem.isCannedFoodItem; + +public class AppleSkinEventHandler implements AppleSkinApi +{ + + @Override + public void registerEvents() { + FoodValuesEvent.EVENT.register(foodValuesEvent -> { + if (isCannedFoodItem(foodValuesEvent.itemStack)) + { + FoodProperties foodProperties = getCanFoodProperties(foodValuesEvent.itemStack); + if (foodProperties != null) + { + foodValuesEvent.modifiedFoodComponent = foodProperties; + } + } + }); + } +} diff --git a/src/main/java/dev/galacticraft/mod/config/ConfigImpl.java b/src/main/java/dev/galacticraft/mod/config/ConfigImpl.java index 63c1d24ff..7903c52a2 100644 --- a/src/main/java/dev/galacticraft/mod/config/ConfigImpl.java +++ b/src/main/java/dev/galacticraft/mod/config/ConfigImpl.java @@ -56,6 +56,7 @@ public class ConfigImpl implements Config { private long electricCompressorEnergyConsumptionRate = Constant.Energy.T2_MACHINE_ENERGY_USAGE; private long electricArcFurnaceEnergyConsumptionRate = Constant.Energy.T2_MACHINE_ENERGY_USAGE; private long oxygenCollectorEnergyConsumptionRate = Constant.Energy.T1_MACHINE_ENERGY_USAGE; + private long foodCannerEnergyConsumptionRate = Constant.Energy.T1_MACHINE_ENERGY_USAGE; private long refineryEnergyConsumptionRate = Constant.Energy.T2_MACHINE_ENERGY_USAGE; private long electricFurnaceEnergyConsumptionRate = Constant.Energy.T2_MACHINE_ENERGY_USAGE; private long energyStorageModuleStorageSize = 300_000; @@ -209,10 +210,20 @@ public long oxygenCompressorEnergyConsumptionRate() { return oxygenCompressorEnergyConsumptionRate; } + public void setOxygenCompressorEnergyConsumptionRate(long amount) { this.oxygenCompressorEnergyConsumptionRate = amount; } + @Override + public long foodCannerEnergyConsumptionRate() { + return foodCannerEnergyConsumptionRate; + } + + public void setFoodCannerEnergyConsumptionRate(long amount) { + this.foodCannerEnergyConsumptionRate = amount; + } + @Override public long oxygenDecompressorEnergyConsumptionRate() { return oxygenDecompressorEnergyConsumptionRate; @@ -422,6 +433,16 @@ public Screen create(Screen parent) { .build() ); + machines.add(new LongFieldBuilder( + Component.translatable(Translations.Config.RESET), + Component.translatable(Translations.Config.FOOD_CANNER_ENERGY_CONSUMPTION_RATE), + config.foodCannerEnergyConsumptionRate()) + .setSaveConsumer(config::setFoodCannerEnergyConsumptionRate) + .setDefaultValue(15) + .requireRestart() + .build() + ); + machines.add(new LongFieldBuilder( Component.translatable(Translations.Config.RESET), Component.translatable(Translations.Config.OXYGEN_DECOMPRESSOR_ENERGY_CONSUMPTION_RATE), diff --git a/src/main/java/dev/galacticraft/mod/content/CannedFoodTooltip.java b/src/main/java/dev/galacticraft/mod/content/CannedFoodTooltip.java new file mode 100644 index 000000000..5bed9ce90 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/CannedFoodTooltip.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content; + +import net.minecraft.core.NonNullList; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; + +public class CannedFoodTooltip implements TooltipComponent { + private final NonNullList items; + + public CannedFoodTooltip(NonNullList nonNullList) + { + this.items = nonNullList; + } + + public NonNullList getItems() { + return this.items; + } +} diff --git a/src/main/java/dev/galacticraft/mod/content/ClientCannedFoodTooltip.java b/src/main/java/dev/galacticraft/mod/content/ClientCannedFoodTooltip.java new file mode 100644 index 000000000..f8365f552 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/ClientCannedFoodTooltip.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content; + +import dev.galacticraft.mod.Constant; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientBundleTooltip; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.core.NonNullList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.inventory.tooltip.BundleTooltip; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.BundleContents; +import org.apache.commons.lang3.math.Fraction; + +@Environment(EnvType.CLIENT) +public class ClientCannedFoodTooltip implements ClientTooltipComponent { + private static final ResourceLocation BACKGROUND_SPRITE = ResourceLocation.withDefaultNamespace("container/bundle/background"); + private static final int MARGIN_Y = 4; + private static final int BORDER_WIDTH = 1; + private static final int SLOT_SIZE_X = 18; + private static final int SLOT_SIZE_Y = 20; + private final NonNullList contents; + + public ClientCannedFoodTooltip(CannedFoodTooltip cannedFoodTooltip) { + this.contents = cannedFoodTooltip.getItems(); + } + + public int getHeight() { + return this.backgroundHeight() + 4; + } + + public int getWidth(Font textRenderer) { + return this.backgroundWidth(); + } + + private int backgroundWidth() { + return this.gridSizeX() * 18 + 2; + } + + private int backgroundHeight() { + return this.gridSizeY() * 20 + 2; + } + + public void renderImage(Font textRenderer, int x, int y, GuiGraphics context) { + int i = this.gridSizeX(); + int j = this.gridSizeY(); + //context.blitSprite(BACKGROUND_SPRITE, x, y, this.backgroundWidth(), this.backgroundHeight()); + boolean bl = true; + int k = 0; + + for(int l = 0; l < j; ++l) { + for(int m = 0; m < i; ++m) { + int n = x + m * 18 + 1; + int o = y + l * 20 + 1; + this.renderSlot(n, o, k++, bl, context, textRenderer); + } + } + + } + + private void renderSlot(int x, int y, int index, boolean shouldBlock, GuiGraphics context, Font textRenderer) { + if (index >= this.contents.size()) { + //creates a ending slot used for bundle not items contained + //this.blit(context, x, y, shouldBlock ? ClientCannedFoodTooltip.Texture.BLOCKED_SLOT : ClientCannedFoodTooltip.Texture.SLOT); + } else { + ItemStack itemStack = this.contents.get(index); + this.blit(context, x, y, Texture.SLOT); + context.renderItem(itemStack, x + 1, y + 1, index); + context.renderItemDecorations(textRenderer, itemStack, x + 1, y + 1); + //used to highlight the item slot + //not needed +// if (index == 0) { +// AbstractContainerScreen.renderSlotHighlight(context, x + 1, y + 1, 0); +// } + } + } + + private void blit(GuiGraphics context, int x, int y, Texture sprite) { + context.blitSprite(sprite.sprite, x, y, 0, sprite.w, sprite.h); + } + + private int gridSizeX() { + return Math.max(2, (int)Math.ceil(Math.sqrt((double)this.contents.size() + 1.0))); + } + + private int gridSizeY() { + return (int)Math.ceil(((double)this.contents.size() + 1.0) / (double)this.gridSizeX()); + } + + @Environment(EnvType.CLIENT) + private static enum Texture { + BLOCKED_SLOT(ResourceLocation.withDefaultNamespace("container/bundle/blocked_slot"), 18, 20), + SLOT(ResourceLocation.withDefaultNamespace("container/bundle/slot"), 18, 20); + + public final ResourceLocation sprite; + public final int w; + public final int h; + + private Texture(final ResourceLocation resourceLocation, final int j, final int k) { + this.sprite = resourceLocation; + this.w = j; + this.h = k; + } + + } +} diff --git a/src/main/java/dev/galacticraft/mod/content/GCBlockEntityTypes.java b/src/main/java/dev/galacticraft/mod/content/GCBlockEntityTypes.java index 9f7c4a190..a23822407 100644 --- a/src/main/java/dev/galacticraft/mod/content/GCBlockEntityTypes.java +++ b/src/main/java/dev/galacticraft/mod/content/GCBlockEntityTypes.java @@ -57,6 +57,7 @@ public class GCBlockEntityTypes { public static final BlockEntityType ELECTRIC_FURNACE = BlockEntityType.Builder.of(ElectricFurnaceBlockEntity::new, GCBlocks.ELECTRIC_FURNACE).build(); public static final BlockEntityType ELECTRIC_ARC_FURNACE = BlockEntityType.Builder.of(ElectricArcFurnaceBlockEntity::new, GCBlocks.ELECTRIC_ARC_FURNACE).build(); public static final BlockEntityType REFINERY = BlockEntityType.Builder.of(RefineryBlockEntity::new, GCBlocks.REFINERY).build(); + public static final BlockEntityType FOOD_CANNER = BlockEntityType.Builder.of(FoodCannerBlockEntity::new, GCBlocks.FOOD_CANNER).build(); // OXYGEN MACHINES public static final BlockEntityType OXYGEN_COLLECTOR = BlockEntityType.Builder.of(OxygenCollectorBlockEntity::new, GCBlocks.OXYGEN_COLLECTOR).build(); @@ -105,6 +106,7 @@ public static void register() { Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.OXYGEN_COLLECTOR), OXYGEN_COLLECTOR); Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.OXYGEN_COMPRESSOR), OXYGEN_COMPRESSOR); + Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.FOOD_CANNER), FOOD_CANNER); Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.OXYGEN_DECOMPRESSOR), OXYGEN_DECOMPRESSOR); Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.OXYGEN_SEALER), OXYGEN_SEALER); Registry.register(BuiltInRegistries.BLOCK_ENTITY_TYPE, Constant.id(Constant.Block.OXYGEN_BUBBLE_DISTRIBUTOR), OXYGEN_BUBBLE_DISTRIBUTOR); diff --git a/src/main/java/dev/galacticraft/mod/content/GCBlocks.java b/src/main/java/dev/galacticraft/mod/content/GCBlocks.java index ce7c6bdb7..de7f498a3 100644 --- a/src/main/java/dev/galacticraft/mod/content/GCBlocks.java +++ b/src/main/java/dev/galacticraft/mod/content/GCBlocks.java @@ -179,9 +179,10 @@ public class GCBlocks { public static final Block MARS_COBBLESTONE_WALL = BLOCKS.register(Constant.Block.MARS_COBBLESTONE_WALL, new WallBlock(BlockBehaviour.Properties.ofFullCopy(MARS_COBBLESTONE))); // ASTEROID NATURAL - public static final Block ASTEROID_ROCK = BLOCKS.register(Constant.Block.ASTEROID_ROCK, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F).requiresCorrectToolForDrops())); - public static final Block ASTEROID_ROCK_1 = BLOCKS.register(Constant.Block.ASTEROID_ROCK_1, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F).requiresCorrectToolForDrops())); // todo naming - public static final Block ASTEROID_ROCK_2 = BLOCKS.register(Constant.Block.ASTEROID_ROCK_2, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F).requiresCorrectToolForDrops())); + public static final Block ASTEROID_ROCK = BLOCKS.register(Constant.Block.ASTEROID_ROCK, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F))); + public static final Block ASTEROID_ROCK_1 = BLOCKS.register(Constant.Block.ASTEROID_ROCK_1, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F))); // todo naming + public static final Block ASTEROID_ROCK_2 = BLOCKS.register(Constant.Block.ASTEROID_ROCK_2, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BROWN).instrument(NoteBlockInstrument.BASEDRUM).destroyTime(3.0F))); + public static final Block DENSE_ICE = BLOCKS.register(Constant.Block.DENSE_ICE, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLUE).instrument(NoteBlockInstrument.BASS).destroyTime(1.0F))); // VENUS NATURAL public static final Block SOFT_VENUS_ROCK = BLOCKS.register(Constant.Block.SOFT_VENUS_ROCK, new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).instrument(NoteBlockInstrument.BASEDRUM).strength(1.5F, 6.0F))); @@ -232,11 +233,19 @@ public class GCBlocks { public static final Block MOON_TIN_ORE = BLOCKS.register(Constant.Block.MOON_TIN_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 5.0F, false))); public static final Block LUNASLATE_TIN_ORE = BLOCKS.register(Constant.Block.LUNASLATE_TIN_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(5.0F, 5.0F, true))); + public static final Block ASTEROID_ALUMINUM_ORE = BLOCKS.register(Constant.Block.ASTEROID_ALUMINUM_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block ASTEROID_IRON_ORE = BLOCKS.register(Constant.Block.ASTEROID_IRON_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block ASTEROID_SILICON_ORE = BLOCKS.register(Constant.Block.ASTEROID_SILICON_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block ALUMINUM_ORE = BLOCKS.register(Constant.Block.ALUMINUM_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); public static final Block DEEPSLATE_ALUMINUM_ORE = BLOCKS.register(Constant.Block.DEEPSLATE_ALUMINUM_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.5F, 3.0F, true))); public static final Block DESH_ORE = BLOCKS.register(Constant.Block.DESH_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 5.0F, false))); + public static final Block MARS_IRON_ORE = BLOCKS.register(Constant.Block.MARS_IRON_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block MARS_TIN_ORE = BLOCKS.register(Constant.Block.MARS_TIN_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block MARS_COPPER_ORE = BLOCKS.register(Constant.Block.MARS_COPPER_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 3.0F, false))); + public static final Block ILMENITE_ORE = BLOCKS.register(Constant.Block.ILMENITE_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 5.0F, false))); public static final Block GALENA_ORE = BLOCKS.register(Constant.Block.GALENA_ORE, new DropExperienceBlock(ConstantInt.of(0), oreSettings(3.0F, 5.0F, false))); @@ -318,10 +327,11 @@ public class GCBlocks { public static final Block OXYGEN_COMPRESSOR = BLOCKS.register(Constant.Block.OXYGEN_COMPRESSOR, new SimpleMachineBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(3.0F, 5.0F).sound(SoundType.METAL).requiresCorrectToolForDrops(), Constant.id(Constant.Block.OXYGEN_COMPRESSOR))); public static final Block OXYGEN_STORAGE_MODULE = BLOCKS.register(Constant.Block.OXYGEN_STORAGE_MODULE, new SimpleMachineBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(3.0F, 5.0F).sound(SoundType.METAL).requiresCorrectToolForDrops(), Constant.id(Constant.Block.OXYGEN_STORAGE_MODULE))); public static final Block FUEL_LOADER = BLOCKS.register(Constant.Block.FUEL_LOADER, new FuelLoaderBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(3.0F, 5.0F).sound(SoundType.METAL).requiresCorrectToolForDrops())); + public static final Block FOOD_CANNER = BLOCKS.register(Constant.Block.FOOD_CANNER, new SimpleMachineBlock(BlockBehaviour.Properties.of().mapColor(MapColor.METAL).strength(3.0F, 5.0F).sound(SoundType.METAL), Constant.id(Constant.Block.FOOD_CANNER))); public static final AirlockBlock AIR_LOCK_FRAME = BLOCKS.register(Constant.Block.AIR_LOCK_FRAME, new AirlockBlock(false, BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK))); public static final AirlockBlock AIR_LOCK_CONTROLLER = BLOCKS.register(Constant.Block.AIR_LOCK_CONTROLLER, new AirlockBlock(true, BlockBehaviour.Properties.ofFullCopy(Blocks.IRON_BLOCK))); - public static final Block AIR_LOCK_SEAL = BLOCKS.register(Constant.Block.AIR_LOCK_SEAL, new Block(BlockBehaviour.Properties.ofFullCopy(AIR_LOCK_FRAME))); + public static final Block AIR_LOCK_SEAL = BLOCKS.register(Constant.Block.AIR_LOCK_SEAL, new AirlockSealBlock(BlockBehaviour.Properties.ofFullCopy(AIR_LOCK_FRAME))); public static Block register(String id, Block block) { return Registry.register(BuiltInRegistries.BLOCK, Constant.id(id), block); diff --git a/src/main/java/dev/galacticraft/mod/content/GCCelestialBodies.java b/src/main/java/dev/galacticraft/mod/content/GCCelestialBodies.java index 8b9b68ed3..4d69b7d65 100644 --- a/src/main/java/dev/galacticraft/mod/content/GCCelestialBodies.java +++ b/src/main/java/dev/galacticraft/mod/content/GCCelestialBodies.java @@ -73,7 +73,7 @@ public class GCCelestialBodies { public static final ResourceKey> MERCURY = key("mercury"); public static final ResourceKey> VENUS = key("venus"); public static final ResourceKey> MARS = key("mars"); - public static final ResourceKey> ASTEROIDS = key("asteroids"); + public static final ResourceKey> ASTEROID = key("asteroid"); public static final ResourceKey> JUPITER = key("jupiter"); public static final ResourceKey> SATURN = key("saturn"); public static final ResourceKey> URANUS = key("uranus"); @@ -218,18 +218,25 @@ public static void bootstrapRegistries(BootstrapContext> con null ))); - context.register(ASTEROIDS, DecorativePlanet.INSTANCE.configure(new DecorativePlanetConfig( - Component.translatable(Translations.CelestialBody.ASTEROIDS), - Component.translatable(Translations.CelestialBody.ASTEROIDS_DESC), + context.register(ASTEROID, PlanetType.INSTANCE.configure(new PlanetConfig( + Component.translatable(Translations.CelestialBody.ASTEROID), + Component.translatable(Translations.CelestialBody.ASTEROID_DESC), sol, - OrbitalCelestialPositionType.INSTANCE.configure(new OrbitalCelestialPositionConfig(45.0F, 1.375F, 0.0F, true)), - SpinningIconCelestialDisplayType.INSTANCE.configure(new IconCelestialDisplayConfig(Constant.id("textures/gui/celestialbodies/asteroid.png"), 0, 0, 16, 16)), - AsteroidCelestialRingDisplayType.INSTANCE.configure(new DefaultCelestialRingDisplayConfig()), + OrbitalCelestialPositionType.INSTANCE.configure(new OrbitalCelestialPositionConfig(0.61527929901423877327491785323111F, 0.75F, 2.0F, false)), + IconCelestialDisplayType.INSTANCE.configure(new IconCelestialDisplayConfig(Constant.id("textures/gui/celestialbodies/asteroid.png"), 0, 0, 16, 16)), + DefaultCelestialRingDisplayType.INSTANCE.configure(new DefaultCelestialRingDisplayConfig()), + GCDimensions.ASTEROID, + teleporters.getOrThrow(GCTeleporterTypes.LANDER_CELESTIAL_TELEPORTER), new GasComposition.Builder() - .temperature(23.0) - .pressure(3.0E-15F) + .temperature(-2.0) + .pressure(0) .build(), - 0.166F, + 0.1f, + GCCelestialHandlers.DEFAULT, + 2, + -2, + -2, + 99999999L, // 30 times longer than earth null ))); diff --git a/src/main/java/dev/galacticraft/mod/content/GCChunkGenerator.java b/src/main/java/dev/galacticraft/mod/content/GCChunkGenerator.java new file mode 100644 index 000000000..40b47d9ec --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/GCChunkGenerator.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.world.gen.custom.AsteroidChunkGenerator; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.chunk.ChunkGenerator; + + +public class GCChunkGenerator { + public static final GCChunkGeneratorRegistry CHUNK_GENERATOR = new GCChunkGeneratorRegistry(); + + + public static final MapCodec ASTEROID = CHUNK_GENERATOR.register("asteroid_chunk_generator", AsteroidChunkGenerator.CODEC); + + public static MapCodec register(String id, MapCodec codec) { + return Registry.register(BuiltInRegistries.CHUNK_GENERATOR, Constant.id(id), codec); + } + + public static void register() { + + } + +} diff --git a/src/main/java/dev/galacticraft/mod/content/GCChunkGeneratorRegistry.java b/src/main/java/dev/galacticraft/mod/content/GCChunkGeneratorRegistry.java new file mode 100644 index 000000000..e4a830249 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/GCChunkGeneratorRegistry.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.world.level.chunk.ChunkGenerator; + +public class GCChunkGeneratorRegistry extends GCRegistry> { + public GCChunkGeneratorRegistry() { + super(BuiltInRegistries.CHUNK_GENERATOR); + } +} diff --git a/src/main/java/dev/galacticraft/mod/content/block/entity/AirlockControllerBlockEntity.java b/src/main/java/dev/galacticraft/mod/content/block/entity/AirlockControllerBlockEntity.java index 108249638..eb3a19dfc 100644 --- a/src/main/java/dev/galacticraft/mod/content/block/entity/AirlockControllerBlockEntity.java +++ b/src/main/java/dev/galacticraft/mod/content/block/entity/AirlockControllerBlockEntity.java @@ -26,6 +26,7 @@ import dev.galacticraft.mod.content.GCBlocks; import dev.galacticraft.mod.screen.AirlockControllerMenu; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.player.Inventory; @@ -40,6 +41,8 @@ import java.util.List; +import static dev.galacticraft.mod.content.block.special.AirlockSealBlock.FACING; + public class AirlockControllerBlockEntity extends BlockEntity implements MenuProvider { public boolean redstoneActivation; public boolean playerDistanceActivation = true; @@ -63,7 +66,7 @@ public AirlockControllerBlockEntity(BlockPos blockPos, BlockState blockState) { super(GCBlockEntityTypes.AIRLOCK_CONTROLLER, blockPos, blockState); } - + public static void tick(Level level, BlockPos blockPos, BlockState blockState, AirlockControllerBlockEntity blockEntity) { blockEntity.tick(); } @@ -170,6 +173,8 @@ private void sealAirLock() int y = (this.lastProtocol.maxY + this.lastProtocol.minY) / 2; int z = (this.lastProtocol.maxZ + this.lastProtocol.minZ) / 2; + boolean facingNorth = (this.lastProtocol.maxX - this.lastProtocol.minX) == 0; + if (!this.getLevel().getBlockState(new BlockPos(x, y, z)).is(GCBlocks.AIR_LOCK_SEAL)) { // this.getLevel().playSound(null, x, y, z, GCSounds.openAirLock, SoundSource.BLOCKS, 1.0F, 1.0F); @@ -186,7 +191,13 @@ private void sealAirLock() BlockPos pos = new BlockPos(x, y, z); if (this.getLevel().getBlockState(pos).isAir()) { - this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState(), 3); + if (facingNorth) + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.EAST), 3); + }else + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.NORTH), 3); + } } } } @@ -202,7 +213,13 @@ private void sealAirLock() BlockPos pos = new BlockPos(x, y, z); if (this.getLevel().getBlockState(pos).isAir()) { - this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState(), 3); + if (facingNorth) + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.EAST), 3); + }else + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.NORTH), 3); + } } } } @@ -215,7 +232,13 @@ private void sealAirLock() BlockPos pos = new BlockPos(x, y, z); if (this.getLevel().getBlockState(pos).isAir()) { - this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState(), 3); + if (facingNorth) + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.EAST), 3); + }else + { + this.getLevel().setBlock(pos, GCBlocks.AIR_LOCK_SEAL.defaultBlockState().setValue(FACING, Direction.NORTH), 3); + } } } } @@ -247,7 +270,7 @@ public void unsealAirLock() { if (this.protocol.minY == this.protocol.maxY && this.protocol.minX != this.protocol.maxX && this.protocol.minZ != this.protocol.maxZ) { - // First test if there is sealed air to either side + // First test if there is getSealed air to either side for (x = this.protocol.minX + 1; x <= this.protocol.maxX - 1; x++) { for (z = this.protocol.minZ + 1; z <= this.protocol.maxZ - 1; z++) @@ -276,7 +299,7 @@ public void unsealAirLock() if (sealedSide) break; } - // Now replace the airlock blocks with either air, or sealed air + // Now replace the airlock blocks with either air, or getSealed air for (x = this.protocol.minX + 1; x <= this.protocol.maxX - 1; x++) { for (z = this.protocol.minZ + 1; z <= this.protocol.maxZ - 1; z++) @@ -296,7 +319,7 @@ public void unsealAirLock() { if (this.lastProtocol.minX != this.lastProtocol.maxX) { - // First test if there is sealed air to either side + // First test if there is getSealed air to either side for (x = this.lastProtocol.minX + 1; x <= this.lastProtocol.maxX - 1; x++) { for (y = this.lastProtocol.minY + 1; y <= this.lastProtocol.maxY - 1; y++) @@ -325,7 +348,7 @@ public void unsealAirLock() if (sealedSide) break; } - // Now replace the airlock blocks with either air, or sealed air + // Now replace the airlock blocks with either air, or getSealed air for (x = this.lastProtocol.minX + 1; x <= this.lastProtocol.maxX - 1; x++) { for (y = this.lastProtocol.minY + 1; y <= this.lastProtocol.maxY - 1; y++) @@ -342,7 +365,7 @@ public void unsealAirLock() } } else if (this.lastProtocol.minZ != this.lastProtocol.maxZ) { - // First test if there is sealed air to either side + // First test if there is getSealed air to either side for (z = this.lastProtocol.minZ + 1; z <= this.lastProtocol.maxZ - 1; z++) { for (y = this.lastProtocol.minY + 1; y <= this.lastProtocol.maxY - 1; y++) @@ -371,7 +394,7 @@ public void unsealAirLock() if (sealedSide) break; } - // Now replace the airlock blocks with either air, or sealed air + // Now replace the airlock blocks with either air, or getSealed air for (z = this.lastProtocol.minZ + 1; z <= this.lastProtocol.maxZ - 1; z++) { for (y = this.lastProtocol.minY + 1; y <= this.lastProtocol.maxY - 1; y++) diff --git a/src/main/java/dev/galacticraft/mod/content/block/entity/machine/FoodCannerBlockEntity.java b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/FoodCannerBlockEntity.java new file mode 100644 index 000000000..aae4a87bb --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/FoodCannerBlockEntity.java @@ -0,0 +1,814 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content.block.entity.machine; + +import dev.galacticraft.api.component.GCDataComponents; +import dev.galacticraft.api.gas.Gases; +import dev.galacticraft.machinelib.api.block.entity.MachineBlockEntity; +import dev.galacticraft.machinelib.api.filter.ResourceFilters; +import dev.galacticraft.machinelib.api.machine.MachineStatus; +import dev.galacticraft.machinelib.api.machine.MachineStatuses; +import dev.galacticraft.machinelib.api.menu.MachineMenu; +import dev.galacticraft.machinelib.api.storage.MachineEnergyStorage; +import dev.galacticraft.machinelib.api.storage.MachineFluidStorage; +import dev.galacticraft.machinelib.api.storage.MachineItemStorage; +import dev.galacticraft.machinelib.api.storage.StorageSpec; +import dev.galacticraft.machinelib.api.storage.slot.FluidResourceSlot; +import dev.galacticraft.machinelib.api.storage.slot.ItemResourceSlot; +import dev.galacticraft.machinelib.api.transfer.TransferType; +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.Galacticraft; +import dev.galacticraft.mod.content.GCBlockEntityTypes; +import dev.galacticraft.mod.content.item.CannedFoodItem; +import dev.galacticraft.mod.content.item.GCItems; +import dev.galacticraft.mod.machine.GCMachineStatuses; +import dev.galacticraft.mod.network.s2c.BubbleUpdatePayload; +import dev.galacticraft.mod.screen.FoodCannerMenu; +import dev.galacticraft.mod.screen.GCMenuTypes; +import dev.galacticraft.mod.screen.OxygenBubbleDistributorMenu; +import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.component.DataComponentPatch; +import net.minecraft.core.component.DataComponents; +import net.minecraft.nbt.*; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static dev.galacticraft.mod.content.item.CannedFoodItem.*; + +public class FoodCannerBlockEntity extends MachineBlockEntity { + public static final int CHARGE_SLOT = 0; + public static final int INPUT_SLOT = 1; + public static final int STORAGE_SLOT = 2; + public static final int OUTPUT_SLOT = 3; + //x0 -> x3 && y0 -> y3 x0 and y0 top left x3 and y3 bottom right + public static final int FOOD_INPUT_SLOT_1 = 4; + public static final int FOOD_INPUT_SLOT_2 = 5; + public static final int FOOD_INPUT_SLOT_3 = 6; + public static final int FOOD_INPUT_SLOT_4 = 7; + public static final int FOOD_INPUT_SLOT_5 = 8; + public static final int FOOD_INPUT_SLOT_6 = 9; + public static final int FOOD_INPUT_SLOT_7 = 10; + public static final int FOOD_INPUT_SLOT_8 = 11; + public static final int FOOD_INPUT_SLOT_9 = 12; + public static final int FOOD_INPUT_SLOT_10 = 13; + public static final int FOOD_INPUT_SLOT_11 = 14; + public static final int FOOD_INPUT_SLOT_12 = 15; + public static final int FOOD_INPUT_SLOT_13 = 16; + public static final int FOOD_INPUT_SLOT_14 = 17; + public static final int FOOD_INPUT_SLOT_15 = 18; + public static final int FOOD_INPUT_SLOT_16 = 19; + + private int progress = 1; + + private int firstRowConsumed = 0; + private int secondRowConsumed = 0; + private int thirdRowConsumed = 0; + private int forthRowConsumed = 0; + private final int maxProgress = 115; + private boolean transferring_can = false; + private boolean transferring_food = false; + + private ItemStack storage; + + private static final StorageSpec SPEC = StorageSpec.of( + MachineItemStorage.spec( + ItemResourceSlot.builder(TransferType.TRANSFER) + .pos(8, 67) + .filter(ResourceFilters.CAN_EXTRACT_ENERGY), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(62, 13) + .filter(ResourceFilters.ofResource(GCItems.EMPTY_CANNED_FOOD)), + ItemResourceSlot.builder(TransferType.STORAGE) + .pos(62, 40) + .capacity(1) + .filter(ResourceFilters.ofResource(GCItems.EMPTY_CANNED_FOOD)), + ItemResourceSlot.builder(TransferType.OUTPUT) + .pos(62, 67), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(98, 13) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(116, 13) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(134, 13) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(152, 13) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(98, 31) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(116, 31) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(134, 31) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(152, 31) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(98, 49) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(116, 49) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(134, 49) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(152, 49) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(98, 67) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(116, 67) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(134, 67) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)), + ItemResourceSlot.builder(TransferType.INPUT) + .pos(152, 67) + .filter((item, tag) -> item != null && item.components().has(DataComponents.FOOD) && !(item instanceof CannedFoodItem)) + ), + MachineEnergyStorage.spec( + Galacticraft.CONFIG.machineEnergyStorageSize(), + Galacticraft.CONFIG.oxygenCollectorEnergyConsumptionRate() * 2, + 0 + ) + ); + + public FoodCannerBlockEntity(BlockPos pos, BlockState state) { + super(GCBlockEntityTypes.FOOD_CANNER, pos, state, SPEC); + this.storage = GCItems.CANNED_FOOD.getDefaultInstance(); + } + + @Override + protected void tickConstant(@NotNull ServerLevel world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { + super.tickConstant(world, pos, state, profiler); + profiler.push("extract_resources"); + this.chargeFromSlot(CHARGE_SLOT); + profiler.pop(); + } + + @Override + protected @NotNull MachineStatus tick(@NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { + progress(); + if (noEnergy()) + { + return MachineStatuses.NOT_ENOUGH_ENERGY; + } + if (inputSlotEmpty()) + { + if (!transferring_can && storageSlotEmpty()) + { + setProgress(1); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + } + if (storageSlotEmpty()) + { + if (getProgress() == 1 && !transferring_can) + { + this.transferring_can = true; + this.itemStorage().slot(INPUT_SLOT).extractOne(); + return GCMachineStatuses.TRANSFERRING_CAN; + } + if (getProgress() == 10) + { + if (transferring_can) + { + if (transferring_food) + { + this.transferring_can = false; + this.itemStorage().slot(STORAGE_SLOT).insert(this.storage.getItem(), this.storage.getComponentsPatch(), 1); + } + else + { + this.transferring_can = false; + this.itemStorage().slot(STORAGE_SLOT).insert(GCItems.CANNED_FOOD, 1); + this.storage = GCItems.CANNED_FOOD.getDefaultInstance(); + } + } + else + { + setProgress(1); + resetConsumedRows(); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + } + } + boolean row0 = !checkRowItems(0).isEmpty(); + boolean row1 = !checkRowItems(1).isEmpty(); + boolean row2 = !checkRowItems(2).isEmpty(); + boolean row3 = !checkRowItems(3).isEmpty(); + if (progress < 107 && getSize(this.storage) == MAX_FOOD && !transferring_can && !transferring_food) + { + setProgress(107); + } + if (!(row0 || row1 || row2 || row3) && !transferring_can && !transferring_food) + { + if (storageContainsFood()) + { + setProgress(107); + } + else + { + return GCMachineStatuses.NO_FOOD; + } + } + if (getProgress() == 10) + { + transferring_food = false; + if (row0) + { + if (getSize(this.storage) < MAX_FOOD) + { + transferring_food = true; + setFirstRowConsumed(1); + List leftover = addToCan(checkRow(0), this.storage); + clearRow(0, leftover); + return GCMachineStatuses.CANNING; + } + + } + else + { + setProgress(37); + } + } + if (getProgress() == 37) + { + if (this.itemStorage().slot(STORAGE_SLOT).isEmpty() && transferring_food) + { + setProgress(1); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + transferring_food = false; + if (row1) + { + if (getSize(this.storage) < MAX_FOOD) + { + transferring_food = true; + setSecondRowConsumed(1); + List leftover = addToCan(checkRow(1), this.storage); + clearRow(1, leftover); + return GCMachineStatuses.CANNING; + } + + } + else + { + if (getFirstRowConsumed() == 1) + { + transferring_food = true; + setProgress(46); + } + else + { + setProgress(53); + } + + } + } + if (getProgress() == 53) + { + if (this.itemStorage().slot(STORAGE_SLOT).isEmpty() && transferring_food) + { + setProgress(1); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + transferring_food = false; + if (row3) + { + if (getSize(this.storage) < MAX_FOOD) + { + transferring_food = true; + setForthRowConsumed(1); + List leftover = addToCan(checkRow(3), this.storage); + clearRow(3, leftover); + return GCMachineStatuses.CANNING; + } + + } + else + { + setProgress(79); + } + } + if (getProgress() == 79) + { + if (this.itemStorage().slot(STORAGE_SLOT).isEmpty() && transferring_food) + { + setProgress(1); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + transferring_food = false; + if (row2) + { + if (getSize(this.storage) < MAX_FOOD) + { + transferring_food = true; + setThirdRowConsumed(1); + List leftover = addToCan(checkRow(2), this.storage); + clearRow(2, leftover); + return GCMachineStatuses.CANNING; + } + + } + else + { + if (getFirstRowConsumed() == 1 || getSecondRowConsumed() == 1) + { + transferring_food = true; + setProgress(97); + if (getForthRowConsumed() == 1) + { + transferring_food = true; + setProgress(87); + } + }else if (getForthRowConsumed() == 1) + { + transferring_food = true; + setProgress(87); + }else + { + setProgress(107); + } + + } + } + + if (getProgress() == 107) + { + if (this.itemStorage().slot(STORAGE_SLOT).isEmpty() && transferring_food) + { + setProgress(1); + resetConsumedRows(); + return GCMachineStatuses.MISSING_EMPTY_CAN; + } + transferring_food = false; + if (outputFull()) + { + if (storageSlotEmpty()) + { + this.storage = GCItems.CANNED_FOOD.getDefaultInstance(); + resetConsumedRows(); + setProgress(1); + return MachineStatuses.OUTPUT_FULL; + } + if (this.itemStorage().getItem(STORAGE_SLOT) != this.storage) + { + this.itemStorage().slot(STORAGE_SLOT).extractOne(); + this.itemStorage().slot(STORAGE_SLOT).insert(this.storage.getItem(), this.storage.getComponentsPatch(), 1); + } + if (getSize(this.storage) < MAX_FOOD && (row0 || row1 || row2 || row3)) + { + setProgress(10); + resetConsumedRows(); + return MachineStatuses.OUTPUT_FULL ; + } + return MachineStatuses.OUTPUT_FULL; + } + transferring_can = true; + this.itemStorage().slot(STORAGE_SLOT).extractOne(); + return GCMachineStatuses.TRANSFERRING_CAN; + } + if (getProgress() == 115 && transferring_can) + { + transferring_can = false; + this.itemStorage().slot(OUTPUT_SLOT).insert(this.storage.getItem(), this.storage.getComponentsPatch(), 1); + this.storage = GCItems.CANNED_FOOD.getDefaultInstance(); + resetConsumedRows(); + setProgress(1); + return MachineStatuses.OUTPUT_FULL; + } + + return GCMachineStatuses.CANNING; + } + + private void resetConsumedRows() { + setFirstRowConsumed(0); + setSecondRowConsumed(0); + setThirdRowConsumed(0); + setForthRowConsumed(0); + } + + private boolean storageContainsFood() { + return !getContents(this.storage).isEmpty(); + } + + private boolean inputSlotEmpty() { + return this.itemStorage().slot(INPUT_SLOT).isEmpty(); + } + + private boolean storageSlotEmpty() { + return this.itemStorage().slot(STORAGE_SLOT).isEmpty(); + } + + private boolean noEnergy() { + return !this.energyStorage().canExtract(Galacticraft.CONFIG.foodCannerEnergyConsumptionRate()); + } + + private boolean outputFull() { + return this.itemStorage().slot(OUTPUT_SLOT).isFull(); + } + + + private void clearRow(int row) { + if (row == 0) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_1).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_1).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_2).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_2).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_3).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_3).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_4).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_4).getCount()); + } + if (row == 1) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_5).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_5).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_6).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_6).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_7).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_7).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_8).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_8).getCount()); + } + if (row == 2) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_9).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_9).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_10).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_10).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_11).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_11).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_12).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_12).getCount()); + } + if (row == 3) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_13).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_13).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_14).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_14).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_15).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_15).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_16).extract(this.itemStorage().getItem(FOOD_INPUT_SLOT_16).getCount()); + } + } + private void clearRow(int row, List stacks) { + clearRow(row); + if (row == 0) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_1).insert(stacks.get(0).getItem(), stacks.get(0).getComponentsPatch(), stacks.get(0).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_2).insert(stacks.get(1).getItem(), stacks.get(1).getComponentsPatch(), stacks.get(1).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_3).insert(stacks.get(2).getItem(), stacks.get(2).getComponentsPatch(), stacks.get(2).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_4).insert(stacks.get(3).getItem(), stacks.get(3).getComponentsPatch(), stacks.get(3).getCount()); + } + if (row == 1) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_5).insert(stacks.get(0).getItem(), stacks.get(0).getComponentsPatch(), stacks.get(0).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_6).insert(stacks.get(1).getItem(), stacks.get(1).getComponentsPatch(), stacks.get(1).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_7).insert(stacks.get(2).getItem(), stacks.get(2).getComponentsPatch(), stacks.get(2).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_8).insert(stacks.get(3).getItem(), stacks.get(3).getComponentsPatch(), stacks.get(3).getCount()); + } + if (row == 2) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_9).insert(stacks.get(0).getItem(), stacks.get(0).getComponentsPatch(), stacks.get(0).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_10).insert(stacks.get(1).getItem(), stacks.get(1).getComponentsPatch(), stacks.get(1).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_11).insert(stacks.get(2).getItem(), stacks.get(2).getComponentsPatch(), stacks.get(2).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_12).insert(stacks.get(3).getItem(), stacks.get(3).getComponentsPatch(), stacks.get(3).getCount()); + } + if (row == 3) + { + this.itemStorage().slot(FOOD_INPUT_SLOT_13).insert(stacks.get(0).getItem(), stacks.get(0).getComponentsPatch(), stacks.get(0).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_14).insert(stacks.get(1).getItem(), stacks.get(1).getComponentsPatch(), stacks.get(1).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_15).insert(stacks.get(2).getItem(), stacks.get(2).getComponentsPatch(), stacks.get(2).getCount()); + this.itemStorage().slot(FOOD_INPUT_SLOT_16).insert(stacks.get(3).getItem(), stacks.get(3).getComponentsPatch(), stacks.get(3).getCount()); + } + } + + private List checkRow(int row) + { + List stacks = new ArrayList<>(); + if (row == 0) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_1).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_1)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_2).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_2)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_3).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_3)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_4).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_4)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + } + if (row == 1) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_5).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_5)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_6).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_6)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_7).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_7)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_8).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_8)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + } + if (row == 2) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_9).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_9)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_10).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_10)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_11).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_11)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_12).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_12)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + } + if (row == 3) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_13).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_13)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_14).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_14)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_15).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_15)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_16).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_16)); + }else + { + stacks.add(Items.AIR.getDefaultInstance()); + } + } + return stacks; + } + + private List checkRowItems(int row) + { + List stacks = new ArrayList<>(); + if (row == 0) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_1).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_1)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_2).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_2)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_3).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_3)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_4).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_4)); + } + } + if (row == 1) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_5).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_5)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_6).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_6)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_7).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_7)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_8).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_8)); + } + } + if (row == 2) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_9).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_9)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_10).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_10)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_11).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_11)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_12).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_12)); + } + } + if (row == 3) + { + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_13).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_13)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_14).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_14)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_15).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_15)); + } + if (!this.itemStorage().slot(FOOD_INPUT_SLOT_16).isEmpty()) + { + stacks.add(this.itemStorage().getItem(FOOD_INPUT_SLOT_16)); + } + } + return stacks; + } + + private void progress() + { + if (this.isActive()) + { + this.progress += 1; + } + if (this.progress > this.maxProgress) setProgress(1); + } + + public int getProgress() { + return this.progress; + } + + public void setProgress(int progress) { + this.progress = progress; + } + + @Override + public @Nullable MachineMenu createMenu(int syncId, Inventory inv, Player player) { + if (this.getSecurity().hasAccess(player)) return new FoodCannerMenu(syncId, (ServerPlayer) player, this); + return null; + } + + @Override + public void loadAdditional(CompoundTag tag, HolderLookup.Provider lookup) { + super.loadAdditional(tag, lookup); + setProgress(tag.getInt(Constant.Nbt.PROGRESS)); + this.transferring_can = tag.getBoolean("TRANSFERRING_CAN"); + this.transferring_food = tag.getBoolean("TRANSFERRING_FOOD"); + ItemStack itemStack = GCItems.CANNED_FOOD.getDefaultInstance(); + itemStack.set(DataComponents.BLOCK_ENTITY_DATA, CustomData.of(listTagToCompoundTag(tag.getList("STORAGE", ListTag.TAG_COMPOUND)))); + this.storage = itemStack; + + } + + + @Override + public void saveAdditional(CompoundTag tag, HolderLookup.Provider lookup) { + super.saveAdditional(tag, lookup); + tag.putInt(Constant.Nbt.PROGRESS, this.progress); + tag.putBoolean("TRANSFERRING_CAN", this.transferring_can); + tag.putBoolean("TRANSFERRING_FOOD", this.transferring_food); + tag.put("STORAGE", compoundTagToListTag(Objects.requireNonNull(this.storage.get(DataComponents.BLOCK_ENTITY_DATA)).copyTag())); + } + + public static CompoundTag listTagToCompoundTag(ListTag listTag) { + CompoundTag compoundTag = new CompoundTag(); + compoundTag.put("Items", listTag); // Store the ListTag under the key "Items" + return compoundTag; + } + + public static ListTag compoundTagToListTag(CompoundTag compoundTag){ + if (compoundTag != null) { + return compoundTag.getList("Items", ListTag.TAG_COMPOUND); // Retrieve the ListTag stored under the key "Items" + } else { + return new ListTag(); // Return an empty ListTag if the key doesn't exist + } + } + + public int getFirstRowConsumed() { + return firstRowConsumed; + } + public void setFirstRowConsumed(int value) { + this.firstRowConsumed = value; + } + public int getSecondRowConsumed() { + return secondRowConsumed; + } + public void setSecondRowConsumed(int value) { + this.secondRowConsumed = value; + } + public int getThirdRowConsumed() { + return thirdRowConsumed; + } + public void setThirdRowConsumed(int value) { + this.thirdRowConsumed = value; + } + public int getForthRowConsumed() { + return forthRowConsumed; + } + public void setForthRowConsumed(int value) { + this.forthRowConsumed = value; + } +} \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java index 2c6828450..8d3fa7f40 100644 --- a/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java +++ b/src/main/java/dev/galacticraft/mod/content/block/entity/machine/OxygenSealerBlockEntity.java @@ -42,25 +42,26 @@ import dev.galacticraft.mod.content.GCBlockEntityTypes; import dev.galacticraft.mod.machine.GCMachineStatuses; import dev.galacticraft.mod.screen.GCMenuTypes; +import dev.galacticraft.mod.machine.SealerManager; import dev.galacticraft.mod.util.FluidUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.Holder; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.particles.SimpleParticleType; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Tuple; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashSet; -import java.util.LinkedList; -import java.util.Queue; +import java.util.Objects; import java.util.Set; public class OxygenSealerBlockEntity extends MachineBlockEntity { @@ -96,11 +97,9 @@ public class OxygenSealerBlockEntity extends MachineBlockEntity { private final Set breathablePositions = new HashSet<>(); private final Set watching = new HashSet<>(); private int sealCheckTime; - private boolean updateQueued = true; - private boolean disabled = false; private boolean oxygenWorld = false; - private boolean sealed = false; - private boolean oxygenUnloaded = true; + private boolean outputBlocked; + public OxygenSealerBlockEntity(BlockPos pos, BlockState state) { super(GCBlockEntityTypes.OXYGEN_SEALER, pos, state, SPEC); @@ -112,13 +111,13 @@ public void setLevel(Level world) { this.sealCheckTime = SEAL_CHECK_TIME; Holder> holder = world.galacticraft$getCelestialBody(); this.oxygenWorld = holder == null || holder.value().atmosphere().breathable(); - if (!world.isClientSide) ((ServerLevelAccessor) world).addSealer(this); + if (!world.isClientSide) ((ServerLevelAccessor) world).addSealer(this, Objects.requireNonNull(world.getServer()).getLevel(world.dimension())); + this.outputBlocked = false; } @Override protected void tickConstant(@NotNull ServerLevel world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { super.tickConstant(world, pos, state, profiler); - this.oxygenUnloaded = false; profiler.push("extract_resources"); this.chargeFromSlot(CHARGE_SLOT); this.takeFluidFromSlot(OXYGEN_INPUT_SLOT, OXYGEN_TANK, Gases.OXYGEN); @@ -128,125 +127,51 @@ protected void tickConstant(@NotNull ServerLevel world, @NotNull BlockPos pos, @ @Override protected @NotNull MachineStatus tick(@NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { assert level != null; - // if (this.disabled != (this.disabled = false)) { - // ((ServerLevelAccessor) level).addSealer(this); - // } - if (this.energyStorage().canExtract(Galacticraft.CONFIG.oxygenCompressorEnergyConsumptionRate())) { if (!this.fluidStorage().slot(OXYGEN_TANK).isEmpty()) { if (this.sealCheckTime > 0) this.sealCheckTime--; - if (this.updateQueued && this.sealCheckTime == 0) { - profiler.push("check_seal"); - this.updateQueued = false; - this.sealCheckTime = SEAL_CHECK_TIME; - BlockPos pos1 = pos.relative(Direction.UP); - if (this.oxygenWorld || (this.breathablePositions.isEmpty() && level.isBreathable(pos1))) { - profiler.pop(); - return GCMachineStatuses.ALREADY_SEALED; - } - for (BlockPos pos2 : this.breathablePositions) { - level.setBreathable(pos2, false); - } - this.breathablePositions.clear(); - this.watching.clear(); - Queue> queue = new LinkedList<>(); - Set> checked = new HashSet<>(); - Set added = new HashSet<>(); - BlockState state1; - Tuple pair; - BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos(); - queue.add(new Tuple<>(pos1, Direction.UP)); - checked.add(new Tuple<>(pos1, Direction.UP)); - while (!queue.isEmpty()) { - pair = queue.poll(); - pos1 = pair.getA(); - state1 = level.getBlockState(pos1); - if (state1.isAir() || (!Block.isFaceFull(state1.getCollisionShape(level, pos1), pair.getB().getOpposite()))) { - this.breathablePositions.add(pos1); - if (this.breathablePositions.size() > 1024) { - this.breathablePositions.clear(); - this.watching.clear(); - this.updateQueued = true; - this.sealCheckTime = SEAL_CHECK_TIME * 5; - this.sealed = false; - profiler.pop(); - return GCMachineStatuses.AREA_TOO_LARGE; - } - added.add(pos1); - final BlockPos finalPos = pos1; - queue.removeIf(blockPosDirectionPair -> blockPosDirectionPair.getA().equals(finalPos)); - for (Direction direction : Constant.Misc.DIRECTIONS) { - final Tuple e = new Tuple<>(mutable.set(pos1).move(direction).immutable(), direction); - if (!added.contains(e.getA()) && checked.add(e)) { - if (!Block.isFaceFull(state1.getCollisionShape(level, pos1), e.getB())) { - queue.add(e); - } - } - } - } else { - this.watching.add(pos1); - } + if (this.sealCheckTime == 0) + { + this.sealCheckTime = 20; + if (this.outputBlocked) + { + return GCMachineStatuses.BLOCKED; } - this.sealed = true; // if escaped queue then set sealed - for (BlockPos pos2 : this.breathablePositions) { - level.setBreathable(pos2, true); + RenderOxygenSealedArea(SealerManager.INSTANCE.getInsideSealerGroupings(pos.above(), level.dimensionType()).getCalculatedArea(), level, ParticleTypes.FLAME); + RenderOxygenSealedArea(SealerManager.INSTANCE.getInsideSealerGroupings(pos.above(), level.dimensionType()).getUncalculatedArea(), level, ParticleTypes.DRAGON_BREATH); + //checks if the block above the sealer is sealed or not + if (SealerManager.INSTANCE.getInsideSealerGroupings(pos.above(), level.dimensionType()).getBreathable()) + { + return GCMachineStatuses.SEALED; } - profiler.pop(); - } - - if (!this.sealed) { return GCMachineStatuses.AREA_TOO_LARGE; } - - profiler.push("extract"); - this.energyStorage().extract(Galacticraft.CONFIG.oxygenCompressorEnergyConsumptionRate()); - this.fluidStorage().slot(OXYGEN_TANK).extract(Gases.OXYGEN, breathablePositions.size() * 2L); - profiler.pop(); - return GCMachineStatuses.SEALED; + return this.getState().getStatus(); } else { - this.tryClearSeal(level); return GCMachineStatuses.NOT_ENOUGH_OXYGEN; } } else { - this.tryClearSeal(level); return MachineStatuses.NOT_ENOUGH_ENERGY; } } - private void tryClearSeal(@NotNull ServerLevel world) { - if (this.sealed) { - for (BlockPos pos1 : this.breathablePositions) { - world.setBreathable(pos1, false); - } - this.breathablePositions.clear(); - this.watching.clear(); - - this.sealed = false; + private void RenderOxygenSealedArea(Set calculatedArea, @NotNull ServerLevel level, SimpleParticleType type) { + for (BlockPos pos : calculatedArea) + { + spawnParticlesAtCenter(level, pos, type); } - this.updateQueued = true; - this.sealCheckTime = 0; } @Override protected void tickDisabled(@NotNull ServerLevel world, @NotNull BlockPos pos, @NotNull BlockState state, @NotNull ProfilerFiller profiler) { - this.tryClearSeal(world); super.tickDisabled(world, pos, state, profiler); } @Override public void setRemoved() { if (!this.level.isClientSide) { - ((ServerLevelAccessor) this.level).removeSealer(this); - } - if (!this.oxygenUnloaded) { - this.oxygenUnloaded = true; - for (BlockPos pos : this.breathablePositions) { - this.level.setBreathable(pos, false); - } + ((ServerLevelAccessor) this.level).removeSealer(this, (ServerLevel) this.level); } - this.breathablePositions.clear(); - this.watching.clear(); - super.setRemoved(); } @@ -261,9 +186,33 @@ public MachineMenu createMenu(int syncId, Inventor ); } - public void enqueueUpdate(BlockPos pos, VoxelShape voxelShape2) { - if ((this.watching.contains(pos) && !Block.isShapeFullBlock(voxelShape2)) || (this.breathablePositions.contains(pos) && !voxelShape2.isEmpty())) { - this.updateQueued = true; - } + public static void spawnParticlesAtCenter(ServerLevel level, BlockPos pos, SimpleParticleType type) { + double centerX = pos.getX() + 0.5; + double centerY = pos.getY() + 0.5; + double centerZ = pos.getZ() + 0.5; + + // Spawn the particle at the center + level.sendParticles(type, centerX, centerY, centerZ, 1, 0, 0, 0, 0); + + } + + public void setBlocked(boolean b) { + this.outputBlocked = b; + } + + public boolean isBlocked() { + return outputBlocked; + } + + public int getSealingPower() { + return 1024; + } + + public int getInsideArea() { + return SealerManager.INSTANCE.getInsideSealerGroupings(this.getBlockPos().above(), this.level.dimensionType()).getTotalInsideBlocks(); + } + + public int getOutsideArea() { + return SealerManager.INSTANCE.getInsideSealerGroupings(this.getBlockPos().above(), this.level.dimensionType()).getTotalOutsideBlocks(); } } \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/block/machine/OxygenSealerBlock.java b/src/main/java/dev/galacticraft/mod/content/block/machine/OxygenSealerBlock.java new file mode 100644 index 000000000..486c2d152 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/block/machine/OxygenSealerBlock.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content.block.machine; + +import com.mojang.serialization.MapCodec; +import dev.galacticraft.machinelib.api.block.MachineBlock; +import dev.galacticraft.machinelib.api.block.entity.MachineBlockEntity; +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.content.block.entity.machine.CoalGeneratorBlockEntity; +import dev.galacticraft.mod.content.block.entity.machine.OxygenCollectorBlockEntity; +import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.DustParticleOptions; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.joml.Vector3f; + +public class OxygenSealerBlock extends MachineBlock { + private static final MapCodec CODEC = simpleCodec(OxygenSealerBlock::new); + + + + public OxygenSealerBlock(Properties settings) { + super(settings); + } + + @Override + protected @NotNull MapCodec codec() { + return CODEC; + } + + + @Override + public @NotNull MachineBlockEntity newBlockEntity(BlockPos pos, BlockState state) { + return new OxygenSealerBlockEntity(pos, state); + } + + @Override + public void animateTick(BlockState state, Level world, BlockPos pos, RandomSource random) { + + } +} \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/block/special/AirlockSealBlock.java b/src/main/java/dev/galacticraft/mod/content/block/special/AirlockSealBlock.java new file mode 100644 index 000000000..e6dadc2e5 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/content/block/special/AirlockSealBlock.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.content.block.special; + +import com.mojang.serialization.MapCodec; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.HorizontalDirectionalBlock; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.state.BlockBehaviour; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.*; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; + +public class AirlockSealBlock extends Block { + public static final MapCodec CODEC = simpleCodec(AirlockSealBlock::new); + public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; + + + @Override + public MapCodec codec() { + return CODEC; + } + public AirlockSealBlock(Properties properties) { + super(properties); + this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.NORTH)); + } + + + + protected static final VoxelShape SHAPE_NORTH = Block.box(0.0, 0.0, 4.0, 16.0, 16.0, 12.0); + protected static final VoxelShape SHAPE_EAST = Block.box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0); + + @Override + public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { + if (state.getValue(FACING) == Direction.NORTH || state.getValue(FACING) == Direction.SOUTH) + { + return SHAPE_NORTH; + }else + { + return SHAPE_EAST; + } + } + + @Override + public BlockState rotate(BlockState blockState, Rotation rotation) { + return blockState.setValue(FACING, rotation.rotate(blockState.getValue(FACING))); + } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + builder.add(FACING); + } + + @Override + public BlockState getStateForPlacement(BlockPlaceContext blockPlaceContext) { + return this.defaultBlockState().setValue(FACING, blockPlaceContext.getHorizontalDirection().getOpposite()); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/item/CannedFoodItem.java b/src/main/java/dev/galacticraft/mod/content/item/CannedFoodItem.java index 381b36c94..0c78aa231 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/CannedFoodItem.java +++ b/src/main/java/dev/galacticraft/mod/content/item/CannedFoodItem.java @@ -22,32 +22,435 @@ package dev.galacticraft.mod.content.item; +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.content.CannedFoodTooltip; +import dev.galacticraft.mod.util.Translations; +import net.fabricmc.fabric.api.item.v1.FabricItemStack; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.ChatFormatting; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.advancements.critereon.ItemContainerPredicate; +import net.minecraft.client.Minecraft; +import net.minecraft.core.NonNullList; +import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.Tag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.stats.Stats; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.component.ItemContainerContents; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.BinaryOperator; +import java.util.function.Function; +import java.util.function.Supplier; +import java.util.stream.Collector; +import java.util.stream.Stream; + +import static dev.galacticraft.mod.content.item.GCItems.CANNED_FOOD; +import static dev.galacticraft.mod.content.item.GCItems.EMPTY_CANNED_FOOD; + +public class CannedFoodItem extends Item implements FabricItemStack { + private int color; + + public static final int MAX_FOOD = 16; + + + @Override + public @NotNull ItemStack finishUsingItem(ItemStack itemStack, Level level, LivingEntity livingEntity) { + if (!level.isClientSide) + { + int consumingItems = getItemsToBeConsumed(itemStack); + DataComponentMap components = itemStack.getComponents(); + super.finishUsingItem(itemStack, level, livingEntity); + if (livingEntity instanceof ServerPlayer serverPlayer) { + CriteriaTriggers.CONSUME_ITEM.trigger(serverPlayer, itemStack); + serverPlayer.awardStat(Stats.ITEM_USED.get(this)); + } + ItemStack can = new ItemStack(CANNED_FOOD); + can.applyComponents(components); + for (int i = 0; i < consumingItems; i++) { + removeOne(can); + } + if (itemStack.isEmpty()) { + if (getContents(can).isEmpty()) + { + can = new ItemStack(EMPTY_CANNED_FOOD); + } + return can; + }else + { + if (livingEntity instanceof Player player) { + if (!player.getAbilities().instabuild) { + + if (getContents(can).isEmpty()) + { + can = new ItemStack(EMPTY_CANNED_FOOD); + } + if (!player.getInventory().add(can)) { + player.drop(can, false); + } + } + } + } + } + return itemStack; + } -public class CannedFoodItem extends Item { public CannedFoodItem(Properties settings) { super(settings); + this.color = 0; + } + + @Override + public void onCraftedBy(ItemStack stack, Level world, Player player) { + super.onCraftedBy(stack, world, player); + // Add functionality when the item is crafted (optional) + } + + public static void registerCan(ItemStack cannedFoodType) + { + ItemGroupEvents.modifyEntriesEvent(ResourceKey.create(Registries.CREATIVE_MODE_TAB, Constant.id(Constant.Item.ITEM_GROUP_CANS))).register(entries -> { + ItemStack cannedFoodItem = CANNED_FOOD.getDefaultInstance(); + add(cannedFoodItem, cannedFoodType); + entries.accept(cannedFoodItem); + }); } @Override - public ItemStack finishUsingItem(ItemStack itemStack, Level level, LivingEntity livingEntity) { - super.finishUsingItem(itemStack, level, livingEntity); - if (itemStack.isEmpty()) { - return new ItemStack(GCItems.TIN_CANISTER); + public @NotNull Component getName(ItemStack stack) { + if (getContents(stack).isEmpty()) + { + return Component.translatable(Translations.Items.EMPTY_CANNED_FOOD); + }else + { + String result = getContents(stack).stream() + .map(CannedFoodItem::getItemDisplayName) + .collect(new TopNCollector<>(3)); + return Component.translatable(Translations.Items.CANNED_FOOD).append(Component.literal(result)); + } + } + + public void setColor(int color) + { + this.color = color; + } + + public int getColor(int layer) { + // Specify color for each layer, you can add more layers and their colors + if (layer == 1) { + return this.color; + } else { + return 0xFFFFFF; // Default color (no tint) + } + } + + @Override + public @NotNull Optional getTooltipImage(ItemStack stack) + { + if (!getContents(stack).isEmpty()) + { + NonNullList nonNullList = NonNullList.create(); + Stream stream = getContents(stack).stream(); + Objects.requireNonNull(nonNullList); + stream.forEach(nonNullList::add); + return Optional.of(new CannedFoodTooltip(nonNullList)); + }else + { + return Optional.empty(); + } + } + + @Override + public void appendHoverText(ItemStack stack, TooltipContext context, List tooltip, TooltipFlag type) { + if (!getContents(stack).isEmpty()) { + tooltip.add(Component.translatable(Translations.Items.TOTAL_NUTRITION).append(Component.literal(String.valueOf(getTotalNutrition(stack)))).withColor(ChatFormatting.DARK_GRAY.getColor())); + } + } + + public static List getContents(ItemStack stack) { + DataComponentMap components = stack.getComponents(); + if (components.isEmpty()) { + return List.of(); + } else { + ItemContainerContents contents = components.get(DataComponents.CONTAINER); + if (contents == null) { + return List.of(); + } + return contents.stream().toList(); + } + } + + public static boolean isCannedFoodItem(ItemStack stack) { + return stack.getItem() instanceof CannedFoodItem; + } + + private static void removeOne(ItemStack stack) { + ItemContainerContents itemContainerContents = stack.get(DataComponents.CONTAINER); + + assert itemContainerContents != null; + List items = new ArrayList<>(itemContainerContents.stream().toList()); + if (!items.isEmpty()) + { + ItemStack itemStack = items.getFirst(); + int itemCount = itemStack.getCount(); + if (itemCount != 1) + { + itemStack.shrink(1); + items.set(0, itemStack); + }else + { + items.removeFirst(); + } + stack.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(items)); + } + } + + public static void add(ItemStack cannedFood, ItemStack stack) { + if (!stack.isEmpty() && stack.getItem().canFitInsideContainerItems()) { + if (!cannedFood.has(DataComponents.CONTAINER)) { + cannedFood.set(DataComponents.CONTAINER, ItemContainerContents.EMPTY); + } + ItemContainerContents cannedFoodContainer = cannedFood.get(DataComponents.CONTAINER); + assert cannedFoodContainer != null; + List cannedFoodItems = new ArrayList<>(cannedFoodContainer.stream().toList()); + + //the max food items that the canned food item can hold + int k = Math.min(stack.getCount(), MAX_FOOD); + if (k != 0) + { + ItemStack itemStack2 = stack.copyWithCount(k); + int iter = -1; + for (int i = 0; i < cannedFoodItems.size(); i++) { + if (cannedFoodItems.get(i).getItem().toString().equals(itemStack2.getItem().toString())) + { + iter = i; + } + } + if (iter == -1) + { + cannedFoodItems.add(itemStack2); + }else + { + itemStack2.setCount(cannedFoodItems.get(iter).getCount() + 1); + cannedFoodItems.set(iter, itemStack2); + } + cannedFood.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(cannedFoodItems)); + } } + } - if (livingEntity instanceof Player player) { - if (!player.getAbilities().instabuild) { - ItemStack canStack = new ItemStack(GCItems.TIN_CANISTER); - if (!player.getInventory().add(canStack)) { - player.drop(canStack, false); + public static List addToCan(List items, ItemStack can) + { + int size = getSize(can); + int iter = 0; + if (size < MAX_FOOD) + { + for (int i = 0; i < MAX_FOOD - size; i++) { + if (!items.isEmpty()) + { + if (iter > 3) + { + return items; + } + if (items.get(iter).getCount() == 0) + { + ++iter; + i--; + }else if (items.get(iter).getCount() > 1) + { + add(can,items.get(iter).copyWithCount(1)); + items.set(iter, items.get(iter).copyWithCount(items.get(iter).getCount() - 1)); + } + else + { + add(can,items.get(iter).copyWithCount(1)); + items.set(iter, Items.AIR.getDefaultInstance()); + ++iter; + } } } } - return itemStack; + return items; + } + + public static int getSize(ItemStack can) + { + int size = 0; + List contents = getContents(can); + if (!contents.isEmpty()) + { + //can has something inside it + for (ItemStack content : contents) { + size += content.getCount(); + } + } + return size; + } + + private static String getItemDisplayName(ItemStack itemStack) { + Component displayName = itemStack.getDisplayName(); + return stripControlCodes(displayName.getString()); + } + + private static String stripControlCodes(String input) { + return input.replaceAll("]", "").replaceAll("\\[", ""); + } + + public static class TopNCollector implements Collector, String> { + private final int n; + + public TopNCollector(int n) { + this.n = n; + } + + @Override + public Supplier> supplier() { + return ArrayList::new; + } + + @Override + public BiConsumer, T> accumulator() { + return (list, item) -> { + if (list.size() < n) { + list.add(item); + } else if (list.size() == n) { + list.add((T)"..."); + } + }; + } + + @Override + public BinaryOperator> combiner() { + return (list1, list2) -> { + list1.addAll(list2); + if (list1.size() > n) { + list1 = list1.subList(0, n); + list1.add((T) "..."); + } + return list1; + }; + } + + @Override + public Function, String> finisher() { + return list -> { + boolean greaterThanN = false; + if (list.size() > n) { + greaterThanN = true; + list.remove(3); + } + String string = String.join(", ", list.toArray(new String[0])); + if (greaterThanN) + { + string = string + "..."; + } + return string; + }; + } + + @Override + public Set characteristics() { + return new HashSet<>(); + } + } + + public static FoodProperties getCanFoodProperties(ItemStack stack) { + int playerHunger = 0; + if (Minecraft.getInstance().player != null) { + playerHunger = Minecraft.getInstance().player.getFoodData().getFoodLevel(); + } + int nutritionRequired = 20 - playerHunger; + int canNutrition = 0; + float canSaturation = 0f; + if (nutritionRequired != 0) + { + List stream = getContents(stack); + for (ItemStack foodItem : stream) + { + FoodProperties foodProperties = foodItem.get(DataComponents.FOOD); + assert foodProperties != null; + int itemCount = foodItem.getCount(); + for (int i = 0; i < itemCount; i++) + { + canNutrition += foodProperties.nutrition(); + canSaturation += foodProperties.saturation(); + if (canNutrition >= nutritionRequired) + { + return new FoodProperties.Builder().nutrition(canNutrition).saturationModifier(canSaturation).build(); + } + } + } + if (canNutrition == 0) + { + return null; + }else + { + return new FoodProperties.Builder().nutrition(canNutrition).saturationModifier(canSaturation).build(); + } + } + return null; + } + + public static int getTotalNutrition(ItemStack stack) { + int canNutrition = 0; + List stream = getContents(stack); + for (ItemStack foodItem : stream) + { + FoodProperties foodProperties = foodItem.get(DataComponents.FOOD); + assert foodProperties != null; + int itemCount = foodItem.getCount(); + for (int i = 0; i < itemCount; i++) + { + canNutrition += foodProperties.nutrition(); + } + } + return canNutrition; + } + + public static int getItemsToBeConsumed(ItemStack stack) { + int playerHunger = 0; + if (Minecraft.getInstance().player != null) { + playerHunger = Minecraft.getInstance().player.getFoodData().getFoodLevel(); + } + int nutritionRequired = 20 - playerHunger; + int canNutrition = 0; + int itemsToBeConsumed = 0; + if (nutritionRequired != 0) + { + List stream = getContents(stack); + for (ItemStack foodItem : stream) + { + FoodProperties foodProperties = foodItem.get(DataComponents.FOOD); + int itemCount = foodItem.getCount(); + for (int i = 0; i < itemCount; i++) + { + itemsToBeConsumed += 1; + canNutrition += foodProperties.nutrition(); + if (canNutrition >= nutritionRequired) + { + return itemsToBeConsumed; + } + } + } + } + return itemsToBeConsumed; } } \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/item/GCCreativeModeTabs.java b/src/main/java/dev/galacticraft/mod/content/item/GCCreativeModeTabs.java index 35c577421..46171e1fb 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/GCCreativeModeTabs.java +++ b/src/main/java/dev/galacticraft/mod/content/item/GCCreativeModeTabs.java @@ -42,6 +42,7 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; +import static dev.galacticraft.mod.content.GCBlocks.FOOD_CANNER; import static dev.galacticraft.mod.content.item.GCItems.*; public class GCCreativeModeTabs { @@ -187,11 +188,7 @@ public class GCCreativeModeTabs { output.accept(BEEF_PATTY); output.accept(CHEESEBURGER); - output.accept(CANNED_DEHYDRATED_APPLE); - output.accept(CANNED_DEHYDRATED_CARROT); - output.accept(CANNED_DEHYDRATED_MELON); - output.accept(CANNED_DEHYDRATED_POTATO); - output.accept(CANNED_BEEF); + output.accept(THROWABLE_METEOR_CHUNK); output.accept(HOT_THROWABLE_METEOR_CHUNK); @@ -364,6 +361,7 @@ public class GCCreativeModeTabs { output.accept(ASTEROID_ROCK); output.accept(ASTEROID_ROCK_1); output.accept(ASTEROID_ROCK_2); + output.accept(DENSE_ICE); // VENUS NATURAL output.accept(SOFT_VENUS_ROCK); @@ -418,6 +416,11 @@ public class GCCreativeModeTabs { output.accept(MOON_TIN_ORE); output.accept(LUNASLATE_TIN_ORE); + output.accept(ASTEROID_ALUMINUM_ORE); + output.accept(ASTEROID_IRON_ORE); + output.accept(ASTEROID_SILICON_ORE); + + output.accept(ALUMINUM_ORE); output.accept(DEEPSLATE_ALUMINUM_ORE); @@ -462,6 +465,14 @@ public class GCCreativeModeTabs { // MACHINES }).build(); + public static final CreativeModeTab CANNED_FOOD_GROUP = FabricItemGroup + .builder() + .icon(() -> new ItemStack(CANNED_FOOD)) + .title(Component.translatable(Translations.ItemGroup.CANNED_FOOD)) + .displayItems((parameters, output) -> { + output.accept(EMPTY_CANNED_FOOD); + }).build(); + public static final CreativeModeTab MACHINES_GROUP = FabricItemGroup .builder() .icon(() -> new ItemStack(GCItems.COAL_GENERATOR)) @@ -482,6 +493,7 @@ public class GCCreativeModeTabs { output.accept(OXYGEN_BUBBLE_DISTRIBUTOR); output.accept(OXYGEN_DECOMPRESSOR); output.accept(OXYGEN_COMPRESSOR); + output.accept(FOOD_CANNER); output.accept(OXYGEN_STORAGE_MODULE); output.accept(FUEL_LOADER); }).build(); @@ -490,5 +502,6 @@ public static void register() { Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, Constant.id(Constant.Item.ITEM_GROUP), ITEMS_GROUP); Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, Constant.id(Constant.Block.ITEM_GROUP_BLOCKS), BLOCKS_GROUP); Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, Constant.id(Constant.Block.ITEM_GROUP_MACHINES), MACHINES_GROUP); + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, Constant.id(Constant.Item.ITEM_GROUP_CANS), CANNED_FOOD_GROUP); } } \ No newline at end of file diff --git a/src/main/java/dev/galacticraft/mod/content/item/GCFoodComponent.java b/src/main/java/dev/galacticraft/mod/content/item/GCFoodComponent.java index 4c5efb50c..55a0dd51b 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/GCFoodComponent.java +++ b/src/main/java/dev/galacticraft/mod/content/item/GCFoodComponent.java @@ -32,9 +32,5 @@ public class GCFoodComponent { public static final FoodProperties BEEF_PATTY = new FoodProperties.Builder().nutrition(4).saturationModifier(0.8F).build(); public static final FoodProperties CHEESEBURGER = new FoodProperties.Builder().nutrition(14).saturationModifier(4.0F).build(); - public static final FoodProperties DEHYDRATED_APPLE = new FoodProperties.Builder().nutrition(8).saturationModifier(0.3F).build(); - public static final FoodProperties DEHYDRATED_CARROT = new FoodProperties.Builder().nutrition(8).saturationModifier(0.6F).build(); - public static final FoodProperties DEHYDRATED_MELON = new FoodProperties.Builder().nutrition(4).saturationModifier(0.3F).build(); - public static final FoodProperties DEHYDRATED_POTATO = new FoodProperties.Builder().nutrition(2).saturationModifier(0.3F).build(); - public static final FoodProperties CANNED_BEEF = new FoodProperties.Builder().nutrition(8).saturationModifier(0.6F).build(); + } diff --git a/src/main/java/dev/galacticraft/mod/content/item/GCItems.java b/src/main/java/dev/galacticraft/mod/content/item/GCItems.java index f886372bd..fac3be01c 100644 --- a/src/main/java/dev/galacticraft/mod/content/item/GCItems.java +++ b/src/main/java/dev/galacticraft/mod/content/item/GCItems.java @@ -34,6 +34,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.*; import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.block.DispenserBlock; @@ -46,6 +47,8 @@ public class GCItems { public static final GCRegistry ITEMS = new GCRegistry<>(BuiltInRegistries.ITEM); public static final List HIDDEN_ITEMS = new ArrayList<>(1); + public static final List CANNED_FOOD_ITEMS = new ArrayList<>(); + // === START BLOCKS === // TORCHES public static final Item GLOWSTONE_TORCH = ITEMS.register(Constant.Block.GLOWSTONE_TORCH, new StandingAndWallBlockItem(GCBlocks.GLOWSTONE_TORCH, GCBlocks.GLOWSTONE_WALL_TORCH, new Item.Properties(), Direction.DOWN)); @@ -132,6 +135,7 @@ public class GCItems { public static final Item ASTEROID_ROCK = new BlockItem(GCBlocks.ASTEROID_ROCK, new Item.Properties()); public static final Item ASTEROID_ROCK_1 = new BlockItem(GCBlocks.ASTEROID_ROCK_1, new Item.Properties()); public static final Item ASTEROID_ROCK_2 = new BlockItem(GCBlocks.ASTEROID_ROCK_2, new Item.Properties()); + public static final Item DENSE_ICE = new BlockItem(GCBlocks.DENSE_ICE, new Item.Properties()); // VENUS NATURAL public static final Item SOFT_VENUS_ROCK = new BlockItem(GCBlocks.SOFT_VENUS_ROCK, new Item.Properties()); @@ -180,7 +184,15 @@ public class GCItems { public static final Item MOON_TIN_ORE = new BlockItem(GCBlocks.MOON_TIN_ORE, new Item.Properties()); public static final Item LUNASLATE_TIN_ORE = new BlockItem(GCBlocks.LUNASLATE_TIN_ORE, new Item.Properties()); + public static final Item ASTEROID_ALUMINUM_ORE = new BlockItem(GCBlocks.ASTEROID_ALUMINUM_ORE, new Item.Properties()); + public static final Item ASTEROID_IRON_ORE = new BlockItem(GCBlocks.ASTEROID_IRON_ORE, new Item.Properties()); + public static final Item ASTEROID_SILICON_ORE = new BlockItem(GCBlocks.ASTEROID_SILICON_ORE, new Item.Properties()); + + public static final Item ALUMINUM_ORE = new BlockItem(GCBlocks.ALUMINUM_ORE, new Item.Properties()); + public static final Item MARS_TIN_ORE = new BlockItem(GCBlocks.MARS_TIN_ORE, new Item.Properties()); + public static final Item MARS_IRON_ORE = new BlockItem(GCBlocks.MARS_IRON_ORE, new Item.Properties()); + public static final Item MARS_COPPER_ORE = new BlockItem(GCBlocks.MARS_COPPER_ORE, new Item.Properties()); public static final Item DEEPSLATE_ALUMINUM_ORE = new BlockItem(GCBlocks.DEEPSLATE_ALUMINUM_ORE, new Item.Properties()); public static final Item DESH_ORE = new BlockItem(GCBlocks.DESH_ORE, new Item.Properties()); @@ -229,6 +241,7 @@ public class GCItems { public static final Item OXYGEN_BUBBLE_DISTRIBUTOR = new BlockItem(GCBlocks.OXYGEN_BUBBLE_DISTRIBUTOR, new Item.Properties()); public static final Item OXYGEN_DECOMPRESSOR = new BlockItem(GCBlocks.OXYGEN_DECOMPRESSOR, new Item.Properties()); public static final Item OXYGEN_COMPRESSOR = new BlockItem(GCBlocks.OXYGEN_COMPRESSOR, new Item.Properties()); + public static final Item FOOD_CANNER = new BlockItem(GCBlocks.FOOD_CANNER, new Item.Properties()); public static final Item OXYGEN_STORAGE_MODULE = new BlockItem(GCBlocks.OXYGEN_STORAGE_MODULE, new Item.Properties()); public static final Item FUEL_LOADER = new BlockItem(GCBlocks.FUEL_LOADER, new Item.Properties()); public static final Item ROCKET_WORKBENCH = new BlockItem(GCBlocks.ROCKET_WORKBENCH, new Item.Properties()); @@ -308,13 +321,7 @@ public class GCItems { public static final Item GROUND_BEEF = ITEMS.register(Constant.Item.GROUND_BEEF, new Item(new Item.Properties().food(GCFoodComponent.GROUND_BEEF))); public static final Item BEEF_PATTY = ITEMS.register(Constant.Item.BEEF_PATTY, new Item(new Item.Properties().food(GCFoodComponent.BEEF_PATTY))); public static final Item CHEESEBURGER = ITEMS.register(Constant.Item.CHEESEBURGER, new Item(new Item.Properties().food(GCFoodComponent.CHEESEBURGER))); - - public static final Item CANNED_DEHYDRATED_APPLE = new CannedFoodItem(new Item.Properties().food(GCFoodComponent.DEHYDRATED_APPLE)); - public static final Item CANNED_DEHYDRATED_CARROT = new CannedFoodItem(new Item.Properties().food(GCFoodComponent.DEHYDRATED_CARROT)); - public static final Item CANNED_DEHYDRATED_MELON = new CannedFoodItem(new Item.Properties().food(GCFoodComponent.DEHYDRATED_MELON)); - public static final Item CANNED_DEHYDRATED_POTATO = new CannedFoodItem(new Item.Properties().food(GCFoodComponent.DEHYDRATED_POTATO)); - public static final Item CANNED_BEEF = new CannedFoodItem(new Item.Properties().food(GCFoodComponent.CANNED_BEEF)); - + // ROCKET PLATES public static final Item TIER_1_HEAVY_DUTY_PLATE = ITEMS.register(Constant.Item.TIER_1_HEAVY_DUTY_PLATE, new Item(new Item.Properties())); public static final Item TIER_2_HEAVY_DUTY_PLATE = ITEMS.register(Constant.Item.TIER_2_HEAVY_DUTY_PLATE, new Item(new Item.Properties())); @@ -441,12 +448,17 @@ public class GCItems { public static final Item TIER_3_ROCKET_SCHEMATIC = new SchematicItem(new Item.Properties()); public static final Item ASTRO_MINER_SCHEMATIC = new SchematicItem(new Item.Properties()); + public static final CannedFoodItem CANNED_FOOD = new CannedFoodItem(new Item.Properties().food(new FoodProperties.Builder().nutrition(0).saturationModifier(0).build()).stacksTo(1)); + public static final CannedFoodItem EMPTY_CANNED_FOOD = new CannedFoodItem(new Item.Properties().food(null).stacksTo(64)); + public static Item registerItem(String id, Item item) { return Registry.register(BuiltInRegistries.ITEM, Constant.id(id), item); } - + public static void register() { // === START BLOCKS === + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.EMPTY_CANNED_FOOD), EMPTY_CANNED_FOOD); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_FOOD), CANNED_FOOD); // MOON NATURAL Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.MOON_TURF), MOON_TURF); @@ -525,6 +537,7 @@ public static void register() { Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_ROCK), ASTEROID_ROCK); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_ROCK_1), ASTEROID_ROCK_1); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_ROCK_2), ASTEROID_ROCK_2); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.DENSE_ICE), DENSE_ICE); // VENUS NATURAL Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.SOFT_VENUS_ROCK), SOFT_VENUS_ROCK); @@ -560,6 +573,10 @@ public static void register() { Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.STRONG_VACUUM_GLASS), STRONG_VACUUM_GLASS); // ORES + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_ALUMINUM_ORE), ASTEROID_ALUMINUM_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_IRON_ORE), ASTEROID_IRON_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ASTEROID_SILICON_ORE), ASTEROID_SILICON_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.SILICON_ORE), SILICON_ORE); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.DEEPSLATE_SILICON_ORE), DEEPSLATE_SILICON_ORE); @@ -574,6 +591,9 @@ public static void register() { Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ALUMINUM_ORE), ALUMINUM_ORE); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.DEEPSLATE_ALUMINUM_ORE), DEEPSLATE_ALUMINUM_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.MARS_IRON_ORE), MARS_IRON_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.MARS_TIN_ORE), MARS_TIN_ORE); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.MARS_COPPER_ORE), MARS_COPPER_ORE); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.DESH_ORE), DESH_ORE); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.ILMENITE_ORE), ILMENITE_ORE); @@ -617,6 +637,7 @@ public static void register() { Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.OXYGEN_BUBBLE_DISTRIBUTOR), OXYGEN_BUBBLE_DISTRIBUTOR); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.OXYGEN_DECOMPRESSOR), OXYGEN_DECOMPRESSOR); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.OXYGEN_COMPRESSOR), OXYGEN_COMPRESSOR); + Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.FOOD_CANNER), FOOD_CANNER); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.OXYGEN_STORAGE_MODULE), OXYGEN_STORAGE_MODULE); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Block.FUEL_LOADER), FUEL_LOADER); @@ -688,12 +709,6 @@ public static void register() { // FOOD Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CHEESE_CURD), CHEESE_CURD); - Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_DEHYDRATED_APPLE), CANNED_DEHYDRATED_APPLE); - Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_DEHYDRATED_CARROT), CANNED_DEHYDRATED_CARROT); - Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_DEHYDRATED_MELON), CANNED_DEHYDRATED_MELON); - Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_DEHYDRATED_POTATO), CANNED_DEHYDRATED_POTATO); - Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.CANNED_BEEF), CANNED_BEEF); - // THROWABLE METEOR CHUNKS Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.THROWABLE_METEOR_CHUNK), THROWABLE_METEOR_CHUNK); Registry.register(BuiltInRegistries.ITEM, Constant.id(Constant.Item.HOT_THROWABLE_METEOR_CHUNK), HOT_THROWABLE_METEOR_CHUNK); diff --git a/src/main/java/dev/galacticraft/mod/data/GCBlockLootTableProvider.java b/src/main/java/dev/galacticraft/mod/data/GCBlockLootTableProvider.java index bd1133224..aac9c7aed 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCBlockLootTableProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/GCBlockLootTableProvider.java @@ -33,6 +33,7 @@ import net.minecraft.core.HolderLookup; import net.minecraft.core.registries.Registries; import net.minecraft.data.loot.BlockLootSubProvider; +import net.minecraft.world.item.Items; import net.minecraft.tags.ItemTags; import net.minecraft.world.item.Item; import net.minecraft.world.item.enchantment.Enchantment; @@ -159,6 +160,7 @@ public void generate() { this.dropSelf(GCBlocks.ASTEROID_ROCK); this.dropSelf(GCBlocks.ASTEROID_ROCK_1); this.dropSelf(GCBlocks.ASTEROID_ROCK_2); + this.dropSelf(GCBlocks.DENSE_ICE); this.dropSelf(GCBlocks.SOFT_VENUS_ROCK); this.dropSelf(GCBlocks.HARD_VENUS_ROCK); @@ -198,6 +200,14 @@ public void generate() { this.add(GCBlocks.MOON_TIN_ORE, this.createOreDrop(GCBlocks.MOON_TIN_ORE, GCItems.RAW_TIN)); this.add(GCBlocks.LUNASLATE_TIN_ORE, this.createOreDrop(GCBlocks.LUNASLATE_TIN_ORE, GCItems.RAW_TIN)); + this.add(GCBlocks.ASTEROID_ALUMINUM_ORE, this.createOreDrop(GCBlocks.ASTEROID_ALUMINUM_ORE, GCItems.RAW_ALUMINUM)); + this.add(GCBlocks.ASTEROID_IRON_ORE, this.createOreDrop(GCBlocks.ASTEROID_IRON_ORE, Items.RAW_IRON)); + this.add(GCBlocks.ASTEROID_SILICON_ORE, this.createOreDrop(GCBlocks.ASTEROID_SILICON_ORE, GCItems.RAW_SILICON)); + + this.add(GCBlocks.MARS_COPPER_ORE, this.createOreDrop(GCBlocks.MARS_COPPER_ORE, Items.RAW_COPPER)); + this.add(GCBlocks.MARS_TIN_ORE, this.createOreDrop(GCBlocks.MARS_TIN_ORE, GCItems.RAW_TIN)); + this.add(GCBlocks.MARS_IRON_ORE, this.createOreDrop(GCBlocks.MARS_IRON_ORE, Items.RAW_IRON)); + this.add(GCBlocks.ALUMINUM_ORE, this.createOreDrop(GCBlocks.ALUMINUM_ORE, GCItems.RAW_ALUMINUM)); this.add(GCBlocks.DEEPSLATE_ALUMINUM_ORE, this.createOreDrop(GCBlocks.ALUMINUM_ORE, GCItems.RAW_ALUMINUM)); @@ -274,6 +284,7 @@ public void generate() { this.dropSelf(GCBlocks.OXYGEN_BUBBLE_DISTRIBUTOR); this.dropSelf(GCBlocks.OXYGEN_DECOMPRESSOR); this.dropSelf(GCBlocks.OXYGEN_COMPRESSOR); + this.dropSelf(GCBlocks.FOOD_CANNER); this.dropSelf(GCBlocks.OXYGEN_STORAGE_MODULE); this.dropSelf(GCBlocks.FUEL_LOADER); diff --git a/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java b/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java index 0742b376d..7f4a8c46c 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java +++ b/src/main/java/dev/galacticraft/mod/data/GCDataGenerator.java @@ -27,9 +27,7 @@ import dev.galacticraft.api.registry.RocketRegistries; import dev.galacticraft.impl.universe.galaxy.GalaxyImpl; import dev.galacticraft.mod.Constant; -import dev.galacticraft.mod.content.GCCelestialBodies; -import dev.galacticraft.mod.content.GCRocketParts; -import dev.galacticraft.mod.content.GCTeleporterTypes; +import dev.galacticraft.mod.content.*; import dev.galacticraft.mod.content.entity.damage.GCDamageTypes; import dev.galacticraft.mod.data.content.BootstrapDataProvider; import dev.galacticraft.mod.data.model.GCModelProvider; diff --git a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java index d7604385b..6a3416f30 100644 --- a/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/GCTranslationProvider.java @@ -51,6 +51,7 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(ItemGroup.BLOCKS, "Galacticraft Blocks"); this.add(ItemGroup.ITEMS, "Galacticraft Items"); this.add(ItemGroup.MACHINES, "Galacticraft Machines"); + this.add(ItemGroup.CANNED_FOOD, "Canned Food"); this.block(GCBlocks.ASTEROID_ROCK_1, "Asteroid Rock"); this.block(GCBlocks.ASTEROID_ROCK_2, "Asteroid Rock"); @@ -107,6 +108,11 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.item(GCItems.THERMAL_PADDING_HELMET, "Thermal Padding Helm"); this.item(GCItems.TITANTIUM_UPGRADE_SMITHING_TEMPLATE, "Smithing Template"); this.item(GCItems.PARACHUTE.get(DyeColor.WHITE), "Parachute"); + this.item(GCItems.CANNED_FOOD, "Canned "); + + this.add("item.galacticraft.empty_canned_food", "Empty Canned Food"); + this.add("item.galacticraft.total_nutrition", "Total Nutrition: "); + // Block Descriptions this.blockDesc(GCBlocks.ADVANCED_SOLAR_PANEL, "Advanced Solar Panels collect energy from the sun, and store it for further use. Adjusts position to face the sun, to collect more electricity."); @@ -167,6 +173,7 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(Config.ENERGY_STORAGE_SIZE, "Default Machine Energy Storage Size"); this.add(Config.OXYGEN_COLLECTOR_ENERGY_CONSUMPTION_RATE, "Oxygen Collector Energy Consumption Rate/t"); this.add(Config.OXYGEN_COMPRESSOR_ENERGY_CONSUMPTION_RATE, "Oxygen Compressor Energy Consumption Rate/t"); + this.add(Config.FOOD_CANNER_ENERGY_CONSUMPTION_RATE, "Food Canner Energy Consumption Rate/t"); this.add(Config.OXYGEN_DECOMPRESSOR_ENERGY_CONSUMPTION_RATE, "Oxygen Decompressor Energy Consumption Rate/t"); this.add(Config.REFINERY_ENERGY_CONSUMPTION_RATE, "Refinery Energy Consumption Rate/t"); this.add(Config.SOLAR_PANEL_ENERGY_PRODUCTION_RATE, "Solar Panel Energy Production Rate/t"); @@ -192,8 +199,8 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(CelestialBody.SOL_DESC, ""); this.add(CelestialBody.SOL, "Sol"); - this.add(CelestialBody.ASTEROIDS_DESC, ""); - this.add(CelestialBody.ASTEROIDS, "Asteroids"); + this.add(CelestialBody.ASTEROID_DESC, ""); + this.add(CelestialBody.ASTEROID, "Asteroid"); this.add(CelestialBody.EARTH_DESC, "The Overworld"); this.add(CelestialBody.EARTH, "Earth"); this.add(CelestialBody.JUPITER_DESC, ""); @@ -295,6 +302,10 @@ protected void generateTranslations(HolderLookup.@NotNull Provider registries) { this.add(MachineStatus.ALREADY_SEALED, "Already Sealed"); this.add(MachineStatus.AREA_TOO_LARGE, "Area Too Large"); + this.add(MachineStatus.MISSING_EMPTY_CAN, "Missing Empty Can"); + this.add(MachineStatus.NO_FOOD, "No Food"); + this.add(MachineStatus.TRANSFERRING_CAN, "Transferring Can"); + this.add(MachineStatus.CANNING, "Canning"); this.add(MachineStatus.BLOCKED, "Blocked"); this.add(MachineStatus.COLLECTING, "Collecting"); this.add(MachineStatus.COMPRESSING, "Compressing"); diff --git a/src/main/java/dev/galacticraft/mod/data/model/GCModelProvider.java b/src/main/java/dev/galacticraft/mod/data/model/GCModelProvider.java index 79927b441..735b512e3 100644 --- a/src/main/java/dev/galacticraft/mod/data/model/GCModelProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/model/GCModelProvider.java @@ -23,6 +23,8 @@ package dev.galacticraft.mod.data.model; import com.google.common.collect.Maps; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import dev.galacticraft.mod.Constant; import dev.galacticraft.mod.content.GCBlockRegistry; import dev.galacticraft.mod.content.GCBlocks; @@ -50,6 +52,7 @@ import org.jetbrains.annotations.Contract; import java.util.List; +import java.util.function.Supplier; public class GCModelProvider extends FabricModelProvider { private static final TexturedModel.Provider DETAILED_DECORATION = TexturedModel.createDefault(GCModelProvider::detailedTexture, ModelTemplates.CUBE_BOTTOM_TOP); @@ -106,6 +109,7 @@ public void generateBlockStateModels(BlockModelGenerators generator) { generator.createTrivialCube(GCBlocks.ASTEROID_ROCK); generator.createTrivialCube(GCBlocks.ASTEROID_ROCK_1); generator.createTrivialCube(GCBlocks.ASTEROID_ROCK_2); + generator.createTrivialCube(GCBlocks.DENSE_ICE); // VENUS NATURAL generator.createTrivialCube(GCBlocks.SOFT_VENUS_ROCK); @@ -134,7 +138,6 @@ public void generateBlockStateModels(BlockModelGenerators generator) { generator.createTrivialCube(GCBlocks.HEAVY_SEALABLE_ALUMINUM_WIRE); createLaunchPadBlock(GCBlocks.FUELING_PAD, generator); createLaunchPadBlock(GCBlocks.ROCKET_LAUNCH_PAD, generator); - generator.createNonTemplateModelBlock(GCBlocks.ROCKET_WORKBENCH); generator.createNonTemplateModelBlock(GCBlocks.FALLEN_METEOR); // LIGHT PANELS @@ -161,10 +164,18 @@ public void generateBlockStateModels(BlockModelGenerators generator) { generator.createTrivialCube(GCBlocks.MOON_TIN_ORE); generator.createTrivialCube(GCBlocks.LUNASLATE_TIN_ORE); + generator.createTrivialCube(GCBlocks.ASTEROID_ALUMINUM_ORE); + generator.createTrivialCube(GCBlocks.ASTEROID_IRON_ORE); + generator.createTrivialCube(GCBlocks.ASTEROID_SILICON_ORE); + generator.createTrivialCube(GCBlocks.ALUMINUM_ORE); generator.createTrivialCube(GCBlocks.DEEPSLATE_ALUMINUM_ORE); generator.createTrivialCube(GCBlocks.DESH_ORE); + generator.createTrivialCube(GCBlocks.MARS_COPPER_ORE); + generator.createTrivialCube(GCBlocks.MARS_IRON_ORE); + generator.createTrivialCube(GCBlocks.MARS_TIN_ORE); + generator.createTrivialCube(GCBlocks.ILMENITE_ORE); @@ -223,24 +234,25 @@ public void generateBlockStateModels(BlockModelGenerators generator) { // generator.createNonTemplateModelBlock(GCBlocks.CRYOGENIC_CHAMBER); generator.createNonTemplateModelBlock(GCBlocks.PLAYER_TRANSPORT_TUBE); - //todo gen models (not just blockstates) - createMachineDelegate(generator, GCBlocks.CIRCUIT_FABRICATOR); - createMachineDelegate(generator, GCBlocks.COMPRESSOR); - createMachineDelegate(generator, GCBlocks.ELECTRIC_COMPRESSOR); - createMachineDelegate(generator, GCBlocks.COAL_GENERATOR); + createMachineDelegateFrontFace(generator, GCBlocks.CIRCUIT_FABRICATOR); + createMachineDelegateFrontFace(generator, GCBlocks.COMPRESSOR); + createMachineDelegateFrontFace(generator, GCBlocks.ELECTRIC_COMPRESSOR); + createMachineDelegateFrontFace(generator, GCBlocks.COAL_GENERATOR); + createMachineDelegateFrontFace(generator, GCBlocks.ROCKET_WORKBENCH, "refinery_front", "machine_side"); //Todo not sure if its supposed to be a multiblock model? createMachineDelegate(generator, GCBlocks.BASIC_SOLAR_PANEL); createMachineDelegate(generator, GCBlocks.ADVANCED_SOLAR_PANEL); - createMachineDelegate(generator, GCBlocks.ENERGY_STORAGE_MODULE); - createMachineDelegate(generator, GCBlocks.ELECTRIC_FURNACE); - createMachineDelegate(generator, GCBlocks.ELECTRIC_ARC_FURNACE); - createMachineDelegate(generator, GCBlocks.REFINERY); - createMachineDelegate(generator, GCBlocks.OXYGEN_COLLECTOR); - createMachineDelegate(generator, GCBlocks.OXYGEN_SEALER); - createMachineDelegate(generator, GCBlocks.OXYGEN_BUBBLE_DISTRIBUTOR); - createMachineDelegate(generator, GCBlocks.OXYGEN_DECOMPRESSOR); - createMachineDelegate(generator, GCBlocks.OXYGEN_COMPRESSOR); - createMachineDelegate(generator, GCBlocks.OXYGEN_STORAGE_MODULE); - createMachineDelegate(generator, GCBlocks.FUEL_LOADER); + createMachineDelegateFrontFace(generator, GCBlocks.ENERGY_STORAGE_MODULE, "energy_storage_module_0"); + createMachineDelegateFrontFace(generator, GCBlocks.ELECTRIC_FURNACE); + createMachineDelegateFrontFace(generator, GCBlocks.ELECTRIC_ARC_FURNACE); + createMachineDelegateZAxis(generator, GCBlocks.REFINERY, "refinery_front", "refinery_back"); + createMachineDelegateSingle(generator, GCBlocks.OXYGEN_COLLECTOR, "oxygen_collector"); + createMachineDelegateColumn(generator, GCBlocks.OXYGEN_SEALER, "oxygen_sealer", "oxygen_sealer_top", "machine", "machine_side"); //column with particle + createMachineDelegateSingle(generator, GCBlocks.OXYGEN_BUBBLE_DISTRIBUTOR, "oxygen_bubble_distributor"); + createMachineDelegateZAxis(generator, GCBlocks.OXYGEN_DECOMPRESSOR, "oxygen_decompressor", "oxygen_decompressor_back"); + createMachineDelegateZAxis(generator, GCBlocks.OXYGEN_COMPRESSOR, "oxygen_compressor", "oxygen_compressor_back"); + createMachineDelegateZAxis(generator, GCBlocks.FOOD_CANNER, "food_canner", "food_canner_back"); + createMachineDelegateZAxis(generator, GCBlocks.OXYGEN_STORAGE_MODULE, "oxygen_storage_model_8"); + createMachineDelegateZAxis(generator, GCBlocks.FUEL_LOADER, "fuel_loader_controls"); generator.createNonTemplateModelBlock(GCBlocks.CRUDE_OIL); generator.createNonTemplateModelBlock(GCBlocks.FUEL); @@ -248,7 +260,6 @@ public void generateBlockStateModels(BlockModelGenerators generator) { generator.createTrivialCube(GCBlocks.AIR_LOCK_FRAME); this.createAirLockController(generator); - generator.createNonTemplateModelBlock(GCBlocks.AIR_LOCK_SEAL); var para = MultiPartGenerator.multiPart(GCBlocks.PARACHEST); GCBlocks.PARACHEST.getStateDefinition().getPossibleStates().forEach(state -> { @@ -335,10 +346,123 @@ public static ResourceLocation getMachineModelLocation(Block block) { return resourceLocation.withPrefix("machine/"); } - private static void createMachineDelegate(BlockModelGenerators generator, Block block) { //todo: look into why we need this prefix + private static void createMachineDelegateFrontFace(BlockModelGenerators generator, Block block) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:front_face"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("sprite", getMachineModelLocation(block).toString().replace("machine", "block")); + + customJson.add("sprites", sprites); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegate(BlockModelGenerators generator, Block block) { + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegateFrontFace(BlockModelGenerators generator, Block block, String id) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:front_face"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("sprite", "galacticraft:block/" + id); + + customJson.add("sprites", sprites); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegateFrontFace(BlockModelGenerators generator, Block block, String id, String sides) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:front_face"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("sprite", "galacticraft:block/" + id); + customJson.add("sprites", sprites); + JsonObject textures = new JsonObject(); + textures.addProperty("up", "galacticraft:block/" + sides); + textures.addProperty("down", "galacticraft:block/" + sides); + textures.addProperty("north", "galacticraft:block/" + sides); + textures.addProperty("east", "galacticraft:block/" + sides); + textures.addProperty("south", "galacticraft:block/" + sides); + textures.addProperty("west", "galacticraft:block/" + sides); + textures.addProperty("particle", "galacticraft:block/" + sides); + customJson.add("textures", textures); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegateZAxis(BlockModelGenerators generator, Block block, String id) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:z_axis"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("front", "galacticraft:block/" + id); + sprites.addProperty("back", "galacticraft:block/" + id); + sprites.addProperty("sided", false); + + + customJson.add("sprites", sprites); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegateZAxis(BlockModelGenerators generator, Block block, String id, String id2) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:z_axis"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("front", "galacticraft:block/" + id); + sprites.addProperty("back", "galacticraft:block/" + id2); + sprites.addProperty("sided", true); + + + customJson.add("sprites", sprites); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); } + private static void createMachineDelegateSingle(BlockModelGenerators generator, Block block, String id) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "machinelib:single"); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("sprite", "galacticraft:block/" + id); + sprites.addProperty("particle", "galacticraft:block/" + id); + + customJson.add("sprites", sprites); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + generator.blockStateOutput.accept(BlockModelGenerators.createSimpleBlock(block, getMachineModelLocation(block))); + } + + private static void createMachineDelegateColumn(BlockModelGenerators generator, Block block, String id, String top, String bottom, String side) { + JsonObject customJson = new JsonObject(); + customJson.addProperty("machinelib:generate", "galacticraft:" + id); + + JsonObject sprites = new JsonObject(); + sprites.addProperty("top", "galacticraft:block/" + top); + customJson.add("sprites", sprites); + JsonObject textures = new JsonObject(); + textures.addProperty("up", "galacticraft:block/" + top); + textures.addProperty("down", "galacticraft:block/" + bottom); + textures.addProperty("north", "galacticraft:block/" + side); + textures.addProperty("east", "galacticraft:block/" + side); + textures.addProperty("south", "galacticraft:block/" + side); + textures.addProperty("west", "galacticraft:block/" + side); + textures.addProperty("particle", "galacticraft:block/" + bottom); + customJson.add("textures", textures); + Supplier jsonSupplier = () -> customJson; + generator.modelOutput.accept(getMachineModelLocation(block), jsonSupplier); + } + @Override public void generateItemModels(ItemModelGenerators generator) { // MATERIALS @@ -415,12 +539,6 @@ public void generateItemModels(ItemModelGenerators generator) { generator.generateFlatItem(GCItems.BEEF_PATTY, ModelTemplates.FLAT_ITEM); generator.generateFlatItem(GCItems.CHEESEBURGER, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.CANNED_DEHYDRATED_APPLE, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.CANNED_DEHYDRATED_CARROT, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.CANNED_DEHYDRATED_MELON, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.CANNED_DEHYDRATED_POTATO, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.CANNED_BEEF, ModelTemplates.FLAT_ITEM); - generator.generateFlatItem(GCItems.NOSE_CONE, ModelTemplates.FLAT_ITEM); generator.generateFlatItem(GCItems.HEAVY_NOSE_CONE, "_joined", ModelTemplates.FLAT_ITEM); @@ -442,6 +560,7 @@ public void generateItemModels(ItemModelGenerators generator) { } } + generator.generateFlatItem(GCItems.SENSOR_GLASSES, ModelTemplates.FLAT_ITEM); // TOOLS + WEAPONS diff --git a/src/main/java/dev/galacticraft/mod/data/recipes/GCMachineRecipes.java b/src/main/java/dev/galacticraft/mod/data/recipes/GCMachineRecipes.java index 47d52dc2f..f75035f05 100644 --- a/src/main/java/dev/galacticraft/mod/data/recipes/GCMachineRecipes.java +++ b/src/main/java/dev/galacticraft/mod/data/recipes/GCMachineRecipes.java @@ -197,6 +197,17 @@ public void buildRecipes(RecipeOutput output) { .unlockedBy(getHasName(GCItems.OXYGEN_CONCENTRATOR), has(GCItems.OXYGEN_CONCENTRATOR)) .save(output); + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, GCItems.FOOD_CANNER) + .define('S', GCItems.COMPRESSED_STEEL) + .define('B', GCItems.COMPRESSED_BRONZE) + .define('C', GCItems.OXYGEN_CONCENTRATOR) + .define('A', GCItems.COMPRESSED_ALUMINUM) + .pattern("SAS") + .pattern("ACA") + .pattern("SBS") + .unlockedBy(getHasName(GCItems.OXYGEN_CONCENTRATOR), has(GCItems.OXYGEN_CONCENTRATOR)) + .save(output); + ShapedRecipeBuilder.shaped(RecipeCategory.MISC, GCItems.OXYGEN_DECOMPRESSOR) .define('S', GCItems.COMPRESSED_STEEL) .define('R', Items.REDSTONE_TORCH) diff --git a/src/main/java/dev/galacticraft/mod/data/recipes/GCMiscRecipeProvider.java b/src/main/java/dev/galacticraft/mod/data/recipes/GCMiscRecipeProvider.java index 8794882bd..e6dd183ea 100644 --- a/src/main/java/dev/galacticraft/mod/data/recipes/GCMiscRecipeProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/recipes/GCMiscRecipeProvider.java @@ -376,41 +376,6 @@ public void buildRecipes(RecipeOutput output) { .pattern("CCC") .unlockedBy(getHasName(GCItems.CHEESE_CURD), has(GCItems.CHEESE_CURD)) .save(output); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GCItems.CANNED_DEHYDRATED_APPLE) - .requires(GCItems.TIN_CANISTER) - .requires(Items.APPLE) - .requires(Items.APPLE) - .unlockedBy(getHasName(GCItems.TIN_CANISTER), has(GCItems.TIN_CANISTER)) - .save(output); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GCItems.CANNED_DEHYDRATED_POTATO) - .requires(GCItems.TIN_CANISTER) - .requires(Items.POTATO) - .requires(Items.POTATO) - .unlockedBy(getHasName(GCItems.TIN_CANISTER), has(GCItems.TIN_CANISTER)) - .save(output); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GCItems.CANNED_DEHYDRATED_CARROT) - .requires(GCItems.TIN_CANISTER) - .requires(Items.CARROT) - .requires(Items.CARROT) - .unlockedBy(getHasName(GCItems.TIN_CANISTER), has(GCItems.TIN_CANISTER)) - .save(output); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GCItems.CANNED_DEHYDRATED_MELON) - .requires(GCItems.TIN_CANISTER) - .requires(Items.MELON_SLICE) - .requires(Items.MELON_SLICE) - .unlockedBy(getHasName(GCItems.TIN_CANISTER), has(GCItems.TIN_CANISTER)) - .save(output); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.FOOD, GCItems.CANNED_BEEF) - .requires(GCItems.TIN_CANISTER) - .requires(GCItems.GROUND_BEEF) - .requires(GCItems.GROUND_BEEF) - .unlockedBy(getHasName(GCItems.TIN_CANISTER), has(GCItems.TIN_CANISTER)) - .save(output); } @Override diff --git a/src/main/java/dev/galacticraft/mod/data/tag/GCBiomeTagProvider.java b/src/main/java/dev/galacticraft/mod/data/tag/GCBiomeTagProvider.java index c3c5903c4..b671d5404 100644 --- a/src/main/java/dev/galacticraft/mod/data/tag/GCBiomeTagProvider.java +++ b/src/main/java/dev/galacticraft/mod/data/tag/GCBiomeTagProvider.java @@ -39,25 +39,26 @@ public GCBiomeTagProvider(FabricDataOutput output, CompletableFuture.FabricTagBuilder tag(TagKey tag) { diff --git a/src/main/java/dev/galacticraft/mod/events/GCEventHandlers.java b/src/main/java/dev/galacticraft/mod/events/GCEventHandlers.java index bb67b99e0..f0cda4d33 100644 --- a/src/main/java/dev/galacticraft/mod/events/GCEventHandlers.java +++ b/src/main/java/dev/galacticraft/mod/events/GCEventHandlers.java @@ -26,30 +26,43 @@ import dev.galacticraft.api.universe.celestialbody.landable.Landable; import dev.galacticraft.api.universe.celestialbody.landable.teleporter.CelestialTeleporter; import dev.galacticraft.mod.content.block.special.CryogenicChamberBlock; +import dev.galacticraft.mod.content.item.CannedFoodItem; +import dev.galacticraft.mod.content.item.GCItems; +import dev.galacticraft.mod.machine.SealerManager; import dev.galacticraft.mod.misc.footprint.FootprintManager; import dev.galacticraft.mod.network.s2c.FootprintRemovedPacket; import dev.galacticraft.mod.util.Translations; import net.fabricmc.fabric.api.entity.event.v1.EntitySleepEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents; +import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.fabricmc.fabric.api.networking.v1.PlayerLookup; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.GlobalPos; import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BedBlock; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.dimension.DimensionType; import org.jetbrains.annotations.Nullable; +import java.awt.*; + public class GCEventHandlers { public static void init() { EntitySleepEvents.ALLOW_BED.register(GCEventHandlers::allowCryogenicSleep); @@ -58,6 +71,31 @@ public static void init() { EntitySleepEvents.ALLOW_SLEEP_TIME.register(GCEventHandlers::canCryoSleep); EntitySleepEvents.STOP_SLEEPING.register(GCEventHandlers::onWakeFromCryoSleep); ServerTickEvents.END_WORLD_TICK.register(GCEventHandlers::onWorldTick); + UseItemCallback.EVENT.register(GCEventHandlers::onPlayerUseItem); + } + + private static InteractionResultHolder onPlayerUseItem(Player player, Level world, InteractionHand hand) { + Holder> body = world.galacticraft$getCelestialBody(); + boolean oxygenWorld = body.value().atmosphere().breathable(); + + if (!oxygenWorld) + { + ItemStack itemStack = player.getItemInHand(hand); + + if (itemStack.getComponents().has(DataComponents.FOOD)) + { + if (itemStack.getItem() instanceof CannedFoodItem) + { + return InteractionResultHolder.pass(itemStack); + } else { + player.displayClientMessage(Component.literal("You cannot eat this here!").withColor(Color.RED.getRGB()), true); + player.playNotifySound(SoundEvents.GENERIC_EAT, player.getSoundSource(), 1.0F, 1.0F); + + return InteractionResultHolder.fail(itemStack); + } + } + } + return InteractionResultHolder.pass(player.getItemInHand(hand)); } public static InteractionResult allowCryogenicSleep(LivingEntity entity, BlockPos sleepingPos, BlockState state, boolean vanillaResult) { diff --git a/src/main/java/dev/galacticraft/mod/lookup/GCApiLookupProviders.java b/src/main/java/dev/galacticraft/mod/lookup/GCApiLookupProviders.java index 51c17d215..40f47f1ef 100644 --- a/src/main/java/dev/galacticraft/mod/lookup/GCApiLookupProviders.java +++ b/src/main/java/dev/galacticraft/mod/lookup/GCApiLookupProviders.java @@ -28,10 +28,12 @@ import dev.galacticraft.mod.api.pipe.Pipe; import dev.galacticraft.mod.api.wire.Wire; import dev.galacticraft.mod.content.GCBlockEntityTypes; +import dev.galacticraft.mod.content.GCBlocks; import dev.galacticraft.mod.content.item.GCItems; import dev.galacticraft.mod.content.item.OxygenTankItem; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; import team.reborn.energy.api.EnergyStorage; @@ -54,6 +56,7 @@ public class GCApiLookupProviders { GCBlockEntityTypes.OXYGEN_SEALER, GCBlockEntityTypes.OXYGEN_BUBBLE_DISTRIBUTOR, GCBlockEntityTypes.ENERGY_STORAGE_MODULE, + GCBlockEntityTypes.FOOD_CANNER, GCBlockEntityTypes.OXYGEN_STORAGE_MODULE }; @SuppressWarnings("rawtypes") diff --git a/src/main/java/dev/galacticraft/mod/machine/BlockCheck.java b/src/main/java/dev/galacticraft/mod/machine/BlockCheck.java new file mode 100644 index 000000000..940096edd --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/BlockCheck.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; + +interface BlockCheck { + boolean checkSolid(BlockPos block, ServerLevel world); + SealerGroupings checkCalculated(BlockPos block, ServerLevel world); +} diff --git a/src/main/java/dev/galacticraft/mod/machine/FloodSearch.java b/src/main/java/dev/galacticraft/mod/machine/FloodSearch.java new file mode 100644 index 000000000..e40f1519b --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/FloodSearch.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.Nullable; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Queue; + +public class FloodSearch { + + @Nullable + public static Region Flood(BlockPos startPosition, ServerLevel world, BlockCheck checker, SealerGroupings initialSealerGroup) + { + Queue outsideBlocks = new LinkedList<>(); + Queue insideBlocks = new LinkedList<>(); + Queue otherSealersInsideBlocks = new LinkedList<>(); + //checks if start position is solid + if (!checker.checkSolid(startPosition, world)) + { + //start position is not solid + //checks if start position has any sealer group attached + SealerGroupings startingPositionSealerGroup = checker.checkCalculated(startPosition, world); + if (startingPositionSealerGroup != null) + { + //there is a sealer group attached to the block + //make sure the current sealer group for the area does not contain the starting positions sealer group + if (!initialSealerGroup.sealers.containsAll(startingPositionSealerGroup.sealers)) + { + //the initial starting sealers do not contain the starting positions sealers + //add them to the current floods sealer group + initialSealerGroup.add(startingPositionSealerGroup.sealers); + //the floods outside blocks is appended to by the leftover outside blocks of the other sealer group + outsideBlocks.addAll(startingPositionSealerGroup.getUncalculatedArea()); + otherSealersInsideBlocks.addAll(startingPositionSealerGroup.getCalculatedArea()); + } + } else { + //there is no sealer group attached to the block + //add the current start position to the inside blocks + insideBlocks.add(startPosition); + //iterate over all 6 directions + for (Direction direction : Direction.values()) { + //check if relative direction block has a sealer group attached to it + SealerGroupings relativeSealerGroupings = checker.checkCalculated(startPosition.relative(direction), world); + if (relativeSealerGroupings != null) + { + //relative block has a sealer group attached to it + //make sure the current sealer group for the area does not contain the relative positions sealer group + if (!initialSealerGroup.sealers.containsAll(relativeSealerGroupings.sealers)) + { + //the initial starting sealers do not contain the starting positions sealers + //add them to the current floods sealer group + initialSealerGroup.add(relativeSealerGroupings.sealers); + //the floods outside blocks is appended to by the leftover outside blocks of the other sealer group + outsideBlocks.addAll(relativeSealerGroupings.getUncalculatedArea()); + otherSealersInsideBlocks.addAll(relativeSealerGroupings.getCalculatedArea()); + } + } else { + //relative block does not have a sealer group attached to it + //check if relative block is solid or not + if (checker.checkSolid(startPosition.relative(direction), world)) + { + //block in relative direction is solid so do nothing + }else { + //block in relative direction is not solid so check if its been calculated already + if (!insideBlocks.contains(startPosition.relative(direction)) && !outsideBlocks.contains(startPosition.relative(direction)) && !otherSealersInsideBlocks.contains(startPosition.relative(direction))) { + outsideBlocks.add(startPosition.relative(direction)); + } + } + } + } + } + } else + { + //start position blocked + return null; + } + + //make sure that the max sealing power isnt being exceeded already + if (insideBlocks.size() + outsideBlocks.size() + otherSealersInsideBlocks.size() > initialSealerGroup.sealingPower) + { + insideBlocks.remove(); + for (Direction direction : Direction.values()) + { + if (otherSealersInsideBlocks.contains(startPosition.relative(direction))) + { + outsideBlocks.add(startPosition.relative(direction)); + otherSealersInsideBlocks.remove(startPosition.relative(direction)); + } + } + } + + //while the outside blocks queue is not empty and the inside blocks queue + the outside blocks queue is smaller than the sealing power of the sealer manager + while (!outsideBlocks.isEmpty() && insideBlocks.size() + outsideBlocks.size() + otherSealersInsideBlocks.size() < initialSealerGroup.sealingPower) + { + //poll the first most position from the outside block queue + BlockPos position = outsideBlocks.poll(); + //add the current position to the inside blocks + insideBlocks.add(position); + //iterate over all 6 directions + for (Direction direction : Direction.values()) { + //check if relative direction block has a sealer group attached to it + SealerGroupings relativeSealerGroupings = checker.checkCalculated(position.relative(direction), world); + if (relativeSealerGroupings != null) + { + //relative block has a sealer group attached to it + //make sure the current sealer group for the area does not contain the relative positions sealer group + if (!initialSealerGroup.sealers.containsAll(relativeSealerGroupings.sealers)) + { + //the initial starting sealers do not contain the starting positions sealers + //add them to the current floods sealer group + initialSealerGroup.add(relativeSealerGroupings.sealers); + //the floods outside blocks is appended to by the leftover outside blocks of the other sealer group + outsideBlocks.addAll(relativeSealerGroupings.getUncalculatedArea()); + otherSealersInsideBlocks.addAll(relativeSealerGroupings.getCalculatedArea()); + } + } else { + //relative block does not have a sealer group attached to it + //check if relative block is solid or not + if (checker.checkSolid(position.relative(direction), world)) + { + //block in relative direction is solid so do nothing + }else { + //block in relative direction is not solid so check if its been calculated already + if (!insideBlocks.contains(position.relative(direction)) && !outsideBlocks.contains(position.relative(direction)) && !otherSealersInsideBlocks.contains(position.relative(direction))) { + outsideBlocks.add(position.relative(direction)); + } + } + } + } + } + //sets total blocks for reference + initialSealerGroup.setTotalSealedBlocks(insideBlocks.size() + otherSealersInsideBlocks.size()); + initialSealerGroup.setTotalOutsideBlocks(outsideBlocks.size()); + + //sets sealer groups calculated blocks and uncalculated blocks + initialSealerGroup.setCalculatedArea(new HashSet<>(insideBlocks)); + initialSealerGroup.addCalculatedArea(new HashSet<>(otherSealersInsideBlocks)); + initialSealerGroup.setUncalculatedArea(new HashSet<>(outsideBlocks)); + + //sets sealed based of if outside blocks is empty or not + initialSealerGroup.setSealed(outsideBlocks.isEmpty()); + + //returns + return new Region(initialSealerGroup.getCalculatedArea(), outsideBlocks, outsideBlocks.isEmpty(), initialSealerGroup); + } +} diff --git a/src/main/java/dev/galacticraft/mod/machine/GCMachineStatuses.java b/src/main/java/dev/galacticraft/mod/machine/GCMachineStatuses.java index 50896a047..7449a1759 100644 --- a/src/main/java/dev/galacticraft/mod/machine/GCMachineStatuses.java +++ b/src/main/java/dev/galacticraft/mod/machine/GCMachineStatuses.java @@ -28,8 +28,12 @@ public final class GCMachineStatuses { public static final MachineStatus COLLECTING = MachineStatus.create(Translations.MachineStatus.COLLECTING, ChatFormatting.GREEN, MachineStatus.Type.WORKING); + public static final MachineStatus CANNING = MachineStatus.create(Translations.MachineStatus.CANNING, ChatFormatting.GREEN, MachineStatus.Type.WORKING); + public static final MachineStatus TRANSFERRING_CAN = MachineStatus.create(Translations.MachineStatus.TRANSFERRING_CAN, ChatFormatting.GREEN, MachineStatus.Type.PARTIALLY_WORKING); + public static final MachineStatus NO_FOOD = MachineStatus.create(Translations.MachineStatus.NO_FOOD, ChatFormatting.RED, MachineStatus.Type.MISSING_ITEMS); public static final MachineStatus PARTIALLY_BLOCKED = MachineStatus.create(Translations.MachineStatus.PARTIALLY_BLOCKED, ChatFormatting.GRAY, MachineStatus.Type.PARTIALLY_WORKING); public static final MachineStatus BLOCKED = MachineStatus.create(Translations.MachineStatus.BLOCKED, ChatFormatting.RED, MachineStatus.Type.OTHER); + public static final MachineStatus MISSING_EMPTY_CAN = MachineStatus.create(Translations.MachineStatus.MISSING_EMPTY_CAN, ChatFormatting.RED, MachineStatus.Type.MISSING_ITEMS); public static final MachineStatus NIGHT = MachineStatus.create(Translations.MachineStatus.NIGHT, ChatFormatting.DARK_BLUE, MachineStatus.Type.PARTIALLY_WORKING); public static final MachineStatus RAIN = MachineStatus.create(Translations.MachineStatus.RAIN, ChatFormatting.BLUE, MachineStatus.Type.PARTIALLY_WORKING); public static final MachineStatus FABRICATING = MachineStatus.create(Translations.MachineStatus.FABRICATING, ChatFormatting.GREEN, MachineStatus.Type.WORKING); diff --git a/src/main/java/dev/galacticraft/mod/machine/Region.java b/src/main/java/dev/galacticraft/mod/machine/Region.java new file mode 100644 index 000000000..bb892df1f --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/Region.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; + +import net.minecraft.core.BlockPos; + +import java.util.HashSet; +import java.util.Queue; +import java.util.Set; + +public class Region { + + boolean sealed; + Set insideBlocks; + Set outsideBlocks; + SealerGroupings sealers; + + public Region(Set insideBlocks, Queue outsideBlocks, boolean sealed, SealerGroupings sealers) { + this.insideBlocks = insideBlocks; + this.outsideBlocks = new HashSet<>(outsideBlocks); + this.sealed = sealed; + this.sealers = sealers; + } + + public Set getInsideBlocks() { + return this.insideBlocks; + } + + public Set getOutsideBlocks() { + return this.outsideBlocks; + } + + public boolean isSealed() { + return sealed; + } + + public SealerGroupings getSealerGroups() { + return this.sealers; + } +} diff --git a/src/main/java/dev/galacticraft/mod/machine/SealerGroupings.java b/src/main/java/dev/galacticraft/mod/machine/SealerGroupings.java new file mode 100644 index 000000000..9a19f1925 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/SealerGroupings.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; + +import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import net.minecraft.core.BlockPos; + +import java.util.HashSet; +import java.util.Set; + +public class SealerGroupings { + Set sealers; + int sealingPower; + int totalSealedBlocks; + int totalOutsideBlocks; + + Set calculatedArea; + Set uncalculatedArea; + + boolean sealed; + + public SealerGroupings() + { + sealers = new HashSet<>(); + calculatedArea = new HashSet<>(); + uncalculatedArea = new HashSet<>(); + sealingPower = 0; + totalSealedBlocks = 0; + totalOutsideBlocks = 0; + sealed = false; + } + + public void add(OxygenSealerBlockEntity sealer) { + sealers.add(sealer); + sealingPower += sealer.getSealingPower(); + } + + public void add(Set newSealers) { + for (OxygenSealerBlockEntity sealer : newSealers) + { + sealers.add(sealer); + sealingPower += sealer.getSealingPower(); + } + } + + public void remove(OxygenSealerBlockEntity sealer) { + sealers.remove(sealer); + sealingPower -= sealer.getSealingPower(); + } + + public void setTotalSealedBlocks(int totalSealedBlocks) { + this.totalSealedBlocks = totalSealedBlocks; + } + + public void setTotalOutsideBlocks(int totalOutsideBlocks) { + this.totalOutsideBlocks = totalOutsideBlocks; + } + + public int getTotalInsideBlocks() { + return totalSealedBlocks; + } + + public int getTotalOutsideBlocks() { + return totalOutsideBlocks; + } + + public void changeTotalSealedBlocks(int i) { + this.totalSealedBlocks += i; + } + + public void changeTotalOutsideBlocks(int i) { + this.totalOutsideBlocks += i; + } + + public void setCalculatedArea(Set calculatedArea) { + this.calculatedArea = calculatedArea; + } + + public void addCalculatedArea(Set calculatedArea) { + this.calculatedArea.addAll(calculatedArea); + } + + public void addCalculatedArea(BlockPos calculatedArea) { + this.calculatedArea.add(calculatedArea); + } + + public void removeCalculatedArea(Set calculatedArea) { + this.calculatedArea.removeAll(calculatedArea); + } + + public void removeCalculatedArea(BlockPos calculatedArea) { + this.calculatedArea.remove(calculatedArea); + } + + + public void setUncalculatedArea(Set uncalculatedArea) { + this.uncalculatedArea = uncalculatedArea; + } + + public void addUncalculatedArea(Set uncalculatedArea) { + this.uncalculatedArea.addAll(uncalculatedArea); + } + + public void removeUncalculatedArea(Set uncalculatedArea) { + this.uncalculatedArea.removeAll(uncalculatedArea); + } + + public void removeUncalculatedArea(BlockPos uncalculatedArea) { + this.uncalculatedArea.remove(uncalculatedArea); + } + + public Set getCalculatedArea() { + return this.calculatedArea; + } + + public Set getUncalculatedArea() { + return this.uncalculatedArea; + } + + public void set(SealerGroupings sealerGroup) { + this.sealers = sealerGroup.sealers; + this.sealingPower = sealerGroup.sealingPower; + this.totalSealedBlocks = sealerGroup.totalSealedBlocks; + this.totalOutsideBlocks = sealerGroup.totalOutsideBlocks; + this.calculatedArea = sealerGroup.calculatedArea; + this.uncalculatedArea = sealerGroup.uncalculatedArea; + this.sealed = sealerGroup.sealed; + } + + public void setSealed(boolean sealed) { + this.sealed = sealed; + } + + public boolean getSealed() { + return this.sealed; + } + + public Set getSealers() { + return this.sealers; + } + + public boolean getBreathable() { + if (this.totalOutsideBlocks == 0 && this.totalSealedBlocks <= this.sealingPower) + { + return true; + } + return false; + } +} diff --git a/src/main/java/dev/galacticraft/mod/machine/SealerManager.java b/src/main/java/dev/galacticraft/mod/machine/SealerManager.java new file mode 100644 index 000000000..df97e5bfa --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/SealerManager.java @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; +import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.dimension.DimensionType; + +import java.util.*; + +public class SealerManager { + public static final SealerManager INSTANCE = new SealerManager(); + + private static HashMap> insideBlocks = new HashMap<>(); + private static HashMap> outsideBlocks = new HashMap<>(); + + private SealerManager() {} + + static String RESET = "\u001B[0m"; + static String RED = "\u001B[31m"; + static String GREEN = "\u001B[32m"; + static String YELLOW = "\u001B[33m"; + + + public void onBlockChange(BlockPos pos, BlockState newState, ServerLevel world) { + //creates a new solid check + BlockCheck solidCheck = new SolidCheck(); + + //gets the dimension type of the world + DimensionType dimensionType = world.dimensionType(); + + //gets the inside blocks from the dimension + Map localInsideBlocks = insideBlocks.get(dimensionType); + //gets the outside blocks from the dimension + Map localOutsideBlocks = outsideBlocks.get(dimensionType); + //checks if local inside blocks is null + if (localInsideBlocks != null) { + //checks for if the block is in a calculated area + if (localInsideBlocks.containsKey(pos)) { + //checks if the new state of the changed block is solid + if (!solidCheck.checkSolid(pos, world)) { + //because block did not become air blocking block leave as is + System.out.println( YELLOW + "Block changed from non solid to non solid"); + return; + } else { + //check all sealers in the positions sealer group + for (OxygenSealerBlockEntity sealerBlockEntity : insideBlocks.get(dimensionType).get(pos).sealers) + { + //if sealer block is below placed block then remove sealer block from sealer group + if (sealerBlockEntity.getBlockPos().equals(pos.below())) + { + System.out.println( RED + "Block placed on sealer. Removing sealer from sealer group"); + insideBlocks.get(dimensionType).get(pos).sealers.remove(sealerBlockEntity); + sealerBlockEntity.setBlocked(true); + //fixme: Recheck getSealed area smaller than sealers max sealing power + } else { + System.out.println("2"); + } + } + //block placed is solid therefore should be removed from inside blocks + //change amount of total sealed blocks by 1 + insideBlocks.get(dimensionType).get(pos).changeTotalSealedBlocks(-1); + insideBlocks.get(dimensionType).get(pos).removeCalculatedArea(pos); + //remove block from inside blocks + removeBlockFrom(pos, world, insideBlocks); + return; + //fixme: Check if block has blocked an unreachable room + } + } else if (positionAdjacent(pos, localInsideBlocks)) + { + //block is adjacent to a local inside block but is not a part of inside blocks making it a wall block that was broken if its not solid + if (!solidCheck.checkSolid(pos, world)) { + //block was broken + System.out.println(YELLOW + "Block broken adjacent to inside block at position: " + pos); + //do a flood search out from the broken block to check for empty gaps + Region region = FloodSearch.Flood(pos, world, solidCheck, new SealerGroupings()); + if (region == null) { + System.out.println(RED + "SEALER ERROR CHECK CODE!!!!"); + } else { + //gets the sealer grouping + SealerGroupings sealerGroupings = region.getSealerGroups(); + addBlocksTo(sealerGroupings.calculatedArea, sealerGroupings, world, insideBlocks); + addBlocksTo(sealerGroupings.uncalculatedArea, sealerGroupings, world, outsideBlocks); + //for each sealer block entity get sealed area above and set its groupings + for (OxygenSealerBlockEntity sealerBlockEntity : sealerGroupings.sealers) + { + getInsideSealerGroupings(sealerBlockEntity.getBlockPos().above(), world.dimensionType()).set(sealerGroupings); + } + System.out.println(GREEN + "Replaced sealer grouping"); + } + } else { + //this should only occur when a block is placed adjacent to a wall position + System.out.println(GREEN + "Block placed adjacent to outside block at " + pos); + for (Direction direction : Direction.values()) + { + BlockPos relativePos = pos.relative(direction); + if (localOutsideBlocks.containsKey(relativePos)) { + addBlockTo(relativePos, getOutsideSealerGroupings(relativePos, dimensionType), world, insideBlocks); + outsideBlocks.get(dimensionType).get(relativePos).changeTotalOutsideBlocks(-1); + outsideBlocks.get(dimensionType).get(relativePos).changeTotalSealedBlocks(1); + outsideBlocks.get(dimensionType).get(relativePos).removeUncalculatedArea(relativePos); + outsideBlocks.get(dimensionType).get(relativePos).addCalculatedArea(relativePos); + removeBlockFrom(relativePos, world, outsideBlocks); + //remove block from inside blocks + } else { + System.out.println("4"); + } + } + } + } else { + System.out.println("3"); + } + } else { + System.out.println("1"); + } + } + + private boolean positionAdjacent(BlockPos pos, Map array) { + for (Direction direction : Direction.values()) + { + if (array.containsKey(pos.relative(direction))) { + return true; + } + } + return false; + } + + private boolean arrayContains(BlockPos pos, ServerLevel world, HashMap> array) { + if (array.containsKey(world.dimensionType())) + { + return array.get(world.dimensionType()).containsKey(pos); + } + return false; + } + + + public static void addSealer(OxygenSealerBlockEntity sealer, ServerLevel world) { + //gets the dimension type of the world + DimensionType dimensionType = world.dimensionType(); + //gets the block pos above the sealer + BlockPos aboveSealer = sealer.getBlockPos().above(); + //print to system that sealer is placed + System.out.println(GREEN + "Sealer placed at " + RESET + sealer.getBlockPos() + GREEN + " in dimension " + RESET + dimensionType); + //creates a new sealer group for flooding + SealerGroupings sealerGroupings = new SealerGroupings(); + sealerGroupings.add(sealer); + //performs a flood search + Region region = FloodSearch.Flood(aboveSealer, world, new SolidCheck(), sealerGroupings); + //makes sure region is not null + if (region == null) + { + //region is null therefore the flood search was canceled due to starting position being blocked + System.out.println(RED + "Sealer is blocked" + RESET); + //set the sealer state to blocked + sealer.setBlocked(true); + } else + { + //region returned not null therefore the flood search returned with an area + //gets the sealer group from the region + SealerGroupings sealers = region.getSealerGroups(); + //prints to system to say the amount of inside blocks sealed + System.out.println(YELLOW + "inside blocks " + RESET + sealers.totalSealedBlocks); + //prints to system to say the amount of outside blocks sealed + System.out.println(YELLOW + "outside blocks " + RESET + sealers.totalOutsideBlocks); + //adds the outside and inside blocks to the sealer manager hashmaps + addBlocksTo(region.getInsideBlocks(), sealers, world, insideBlocks); + addBlocksTo(region.getOutsideBlocks(), sealers, world, outsideBlocks); + //if the region is sealed then print sealable else not sealable + if (region.isSealed()) + { + System.out.println(GREEN + "Room calculated as sealable" + RESET); + } else { + System.out.println(RED + "Room calculated as unsealable" + RESET); + } + } + } + + private static void addBlocksTo(Set blocks, SealerGroupings sealerGroup, ServerLevel world, HashMap> array) { + if (!array.containsKey(world.dimensionType())) { + array.put(world.dimensionType(), new HashMap<>()); + } + for (BlockPos pos : blocks) { + array.get(world.dimensionType()).put(pos, sealerGroup); + } + } + + private void addBlockTo(BlockPos pos, SealerGroupings sealerGroup, ServerLevel world, HashMap> array) { + if (array.containsKey(world.dimensionType())) { + //dimension created + array.get(world.dimensionType()).put(pos, sealerGroup); + } else { + //dimension hasn't been created + array.put(world.dimensionType(), new HashMap<>()); + array.get(world.dimensionType()).put(pos, sealerGroup); + } + } + + private void removeBlockFrom(BlockPos pos, ServerLevel world, HashMap> array) { + //dimension check to make sure it exists already + if (array.containsKey(world.dimensionType())) { + //dimension exists so remove entry + array.get(world.dimensionType()).remove(pos); + } + } + + private void removeBlocksFrom(Set blocks, ServerLevel world, HashMap> array) { + if (array.containsKey(world.dimensionType())) { + //dimension exists so remove entrys + for (BlockPos pos : blocks) { + //dimension check to make sure it exists already + array.get(world.dimensionType()).remove(pos); + } + } + } + + private SealerGroupings getSealersFrom(BlockPos pos, ServerLevel world, HashMap> array) { + if (array.containsKey(world.dimensionType())) { + return array.get(world.dimensionType()).get(pos); + } + return null; + } + + public void removeSealer(OxygenSealerBlockEntity sealer, ServerLevel world) { + DimensionType dimensionType = world.dimensionType(); + System.out.println(RED + "Sealer removed at " + sealer.getBlockPos() + " in dimension " + dimensionType); + } + + public SealerGroupings getInsideSealerGroupings(BlockPos pos, DimensionType dimensionType) + { + if (insideBlocks.containsKey(dimensionType)) + { + if (insideBlocks.get(dimensionType).containsKey(pos)) + { + return insideBlocks.get(dimensionType).get(pos); + } + } + return null; + } + + public SealerGroupings getOutsideSealerGroupings(BlockPos pos, DimensionType dimensionType) + { + if (outsideBlocks.containsKey(dimensionType)) + { + if (outsideBlocks.get(dimensionType).containsKey(pos)) + { + return outsideBlocks.get(dimensionType).get(pos); + } + } + return null; + } + + + + +} diff --git a/src/main/java/dev/galacticraft/mod/machine/SolidCheck.java b/src/main/java/dev/galacticraft/mod/machine/SolidCheck.java new file mode 100644 index 000000000..1bcab56ae --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/machine/SolidCheck.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.machine; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.Block; + +public class SolidCheck implements BlockCheck { + @Override + public boolean checkSolid(BlockPos block, ServerLevel world) { + if (Block.isShapeFullBlock(world.getBlockState(block).getShape(world, block))) { + return true; + } + return false; + } + + @Override + public SealerGroupings checkCalculated(BlockPos block, ServerLevel world) { + if (SealerManager.INSTANCE.getInsideSealerGroupings(block, world.dimensionType()) != null) + { + return SealerManager.INSTANCE.getInsideSealerGroupings(block, world.dimensionType()); + } else if (SealerManager.INSTANCE.getOutsideSealerGroupings(block, world.dimensionType()) != null) { + return SealerManager.INSTANCE.getOutsideSealerGroupings(block, world.dimensionType()); + } + return null; + } +} diff --git a/src/main/java/dev/galacticraft/mod/mixin/ServerLevelMixin.java b/src/main/java/dev/galacticraft/mod/mixin/ServerLevelMixin.java index f01d609c4..15cebc623 100644 --- a/src/main/java/dev/galacticraft/mod/mixin/ServerLevelMixin.java +++ b/src/main/java/dev/galacticraft/mod/mixin/ServerLevelMixin.java @@ -26,10 +26,13 @@ import dev.galacticraft.mod.accessor.LevelAccessor; import dev.galacticraft.mod.accessor.ServerLevelAccessor; import dev.galacticraft.mod.content.block.entity.machine.OxygenSealerBlockEntity; +import dev.galacticraft.mod.machine.SealerManager; import dev.galacticraft.mod.misc.footprint.FootprintManager; import dev.galacticraft.mod.misc.footprint.ServerFootprintManager; +import dev.galacticraft.mod.util.Translations; import dev.galacticraft.mod.world.dimension.GCDimensions; import dev.galacticraft.mod.world.gen.spawner.EvolvedPillagerSpawner; +import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.RegistryAccess; @@ -37,6 +40,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; +import net.minecraft.tags.BlockTags; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.RandomSequences; import net.minecraft.world.level.CustomSpawner; @@ -54,6 +58,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import javax.naming.Context; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -64,7 +69,9 @@ @Mixin(ServerLevel.class) public abstract class ServerLevelMixin extends Level implements LevelAccessor, ServerLevelAccessor { @Shadow @Final @Mutable private List customSpawners; - private final @Unique Set sealers = new HashSet<>(); + + @Shadow public abstract ServerLevel getLevel(); + private final @Unique FootprintManager footprintManager = new ServerFootprintManager(); protected ServerLevelMixin(WritableLevelData levelData, ResourceKey dimension, RegistryAccess registryAccess, Holder dimensionTypeRegistration, Supplier profiler, boolean isClientSide, boolean isDebug, long biomeZoomSeed, int maxChainedNeighborUpdates) { @@ -79,26 +86,29 @@ private void setSpawnersGC(MinecraftServer server, Executor workerExecutor, Leve } @Inject(method = "sendBlockUpdated", at = @At(value = "INVOKE", target = "Ljava/util/Set;iterator()Ljava/util/Iterator;", remap = false)) - private void updateSealerListeners_gc(BlockPos pos, BlockState oldState, BlockState newState, int flags, CallbackInfo ci) { - List queueRemove = new LinkedList<>(); - for (OxygenSealerBlockEntity sealer : this.sealers) { - if (sealer.isRemoved()) { - queueRemove.add(sealer); - assert false : "this shouldn't happen! Oxygen sealer was removed but nothing called #markRemoved"; - } - sealer.enqueueUpdate(pos, newState.getCollisionShape(((Level)(Object) this), pos)); + private void onBlockChanges(BlockPos pos, BlockState oldState, BlockState newState, int flags, CallbackInfo ci) { + System.out.println("old: " + oldState.getBlock().toString() + "new: " + newState.getBlock().toString()); + //make sure old state and new state aren't both solid blocks + //if they are both solid blocks then nothing would have changed + if (oldState.isSolid() && newState.isSolid()) { + //nothing will have changed + return; + } + if (newState.is(BlockTags.LEAVES)) + { + //oxygen collector code update? } - this.sealers.removeAll(queueRemove); + SealerManager.INSTANCE.onBlockChange(pos, newState, this.getLevel()); } @Override - public void addSealer(OxygenSealerBlockEntity sealer) { - this.sealers.add(sealer); + public void addSealer(OxygenSealerBlockEntity sealer, ServerLevel world) { + SealerManager.INSTANCE.addSealer(sealer, world); } @Override - public void removeSealer(OxygenSealerBlockEntity sealer) { - this.sealers.remove(sealer); + public void removeSealer(OxygenSealerBlockEntity sealer, ServerLevel world) { + SealerManager.INSTANCE.removeSealer(sealer, world); } @Inject(method = "tickChunk", at = @At("HEAD")) diff --git a/src/main/java/dev/galacticraft/mod/mixin/client/ClientTooltipMixin.java b/src/main/java/dev/galacticraft/mod/mixin/client/ClientTooltipMixin.java new file mode 100644 index 000000000..ca4a106da --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/mixin/client/ClientTooltipMixin.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.mixin.client; + +import dev.galacticraft.mod.content.CannedFoodTooltip; +import dev.galacticraft.mod.content.ClientCannedFoodTooltip; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientBundleTooltip; +import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent; +import net.minecraft.world.inventory.tooltip.BundleTooltip; +import net.minecraft.world.inventory.tooltip.TooltipComponent; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(ClientTooltipComponent.class) +public interface ClientTooltipMixin { + @Overwrite + static ClientTooltipComponent create(TooltipComponent data) { + if (data instanceof BundleTooltip) { + return new ClientBundleTooltip(((BundleTooltip)data).contents()); + } else if (data instanceof CannedFoodTooltip){ + return new ClientCannedFoodTooltip((CannedFoodTooltip)data); + } else { + throw new IllegalArgumentException("Unknown TooltipComponent"); + } + } +} diff --git a/src/main/java/dev/galacticraft/mod/mixin/client/FabricItemMixin.java b/src/main/java/dev/galacticraft/mod/mixin/client/FabricItemMixin.java new file mode 100644 index 000000000..e7504c568 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/mixin/client/FabricItemMixin.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.mixin.client; + +import dev.galacticraft.mod.content.item.CannedFoodItem; +import net.fabricmc.fabric.api.item.v1.FabricItem; +import net.minecraft.core.component.DataComponentHolder; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.food.FoodProperties; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.lang.reflect.Field; + +import static dev.galacticraft.mod.content.item.CannedFoodItem.getCanFoodProperties; +import static dev.galacticraft.mod.content.item.CannedFoodItem.isCannedFoodItem; + +@Mixin(DataComponentHolder.class) +public interface FabricItemMixin { + + @Inject(method = "get", at = @At("HEAD"), cancellable = true) + private void get(DataComponentType type, CallbackInfoReturnable cir) { + DataComponentHolder holder = (DataComponentHolder) (Object) this; + ItemStack stack = getItemStack(holder); + if (isCannedFoodItem(stack)) { + //data component holder has parent of canned food item + if (type.equals(DataComponents.FOOD)) + { + FoodProperties foodProperties = getCanFoodProperties(stack); + cir.setReturnValue((T) foodProperties); + } + } + } + + private ItemStack getItemStack(DataComponentHolder holder) { + if (holder instanceof ItemStack) { + return (ItemStack) holder; + } + + try { + Field itemStackField = holder.getClass().getDeclaredField("itemStack"); + itemStackField.setAccessible(true); + return (ItemStack) itemStackField.get(holder); + } catch (NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + } + + return ItemStack.EMPTY; + } +} diff --git a/src/main/java/dev/galacticraft/mod/screen/FoodCannerMenu.java b/src/main/java/dev/galacticraft/mod/screen/FoodCannerMenu.java new file mode 100644 index 000000000..f31b15afc --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/screen/FoodCannerMenu.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.screen; + +import dev.galacticraft.machinelib.api.menu.MachineMenu; +import dev.galacticraft.machinelib.api.menu.MenuData; +import dev.galacticraft.mod.content.block.entity.machine.FoodCannerBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Inventory; +import org.jetbrains.annotations.NotNull; + +public class FoodCannerMenu extends MachineMenu { + private int progress; + + private int firstRowConsumed; + private int secondRowConsumed; + private int thirdRowConsumed; + private int forthRowConsumed; + + public FoodCannerMenu(int syncId, @NotNull ServerPlayer player, @NotNull FoodCannerBlockEntity machine) { + super(GCMenuTypes.FOOD_CANNER, syncId, player, machine); + } + + public FoodCannerMenu(int syncId, Inventory inventory, BlockPos pos) { + super(GCMenuTypes.FOOD_CANNER, syncId, inventory, pos, 8, 89); + } + + @Override + public void registerData(@NotNull MenuData data){ + super.registerData(data); + + data.registerInt(this.be::getProgress, this::setProgress); + data.registerInt(this.be::getFirstRowConsumed, this::setFirstRowConsumed); + data.registerInt(this.be::getSecondRowConsumed, this::setSecondRowConsumed); + data.registerInt(this.be::getThirdRowConsumed, this::setThirdRowConsumed); + data.registerInt(this.be::getForthRowConsumed, this::setForthRowConsumed); + + } + + + public int getProgress() { + return progress; + } + + public void setProgress(int value) { + this.progress = value; + } + + public int getFirstRowConsumed() { + return firstRowConsumed; + } + public void setFirstRowConsumed(int value) { + this.firstRowConsumed = value; + } + public int getSecondRowConsumed() { + return secondRowConsumed; + } + public void setSecondRowConsumed(int value) { + this.secondRowConsumed = value; + } + public int getThirdRowConsumed() { + return thirdRowConsumed; + } + public void setThirdRowConsumed(int value) { + this.thirdRowConsumed = value; + } + public int getForthRowConsumed() { + return forthRowConsumed; + } + public void setForthRowConsumed(int value) { + this.forthRowConsumed = value; + } + +} diff --git a/src/main/java/dev/galacticraft/mod/screen/GCMenuTypes.java b/src/main/java/dev/galacticraft/mod/screen/GCMenuTypes.java index ec8270c79..862b38be7 100644 --- a/src/main/java/dev/galacticraft/mod/screen/GCMenuTypes.java +++ b/src/main/java/dev/galacticraft/mod/screen/GCMenuTypes.java @@ -55,6 +55,7 @@ public class GCMenuTypes { public static final MenuType> OXYGEN_COMPRESSOR = SynchronizedMenuType.createSimple(MachineMenu::new); public static final MenuType> OXYGEN_DECOMPRESSOR = SynchronizedMenuType.createSimple(MachineMenu::new); + public static final MenuType FOOD_CANNER = SynchronizedMenuType.create(FoodCannerMenu::new); public static final MenuType> OXYGEN_SEALER = SynchronizedMenuType.createSimple(MachineMenu::new); @@ -88,6 +89,7 @@ public static void register() { Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.OXYGEN_COLLECTOR_MENU), OXYGEN_COLLECTOR); Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.OXYGEN_COMPRESSOR_MENU), OXYGEN_COMPRESSOR); + Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.FOOD_CANNER_MENU), FOOD_CANNER); Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.OXYGEN_DECOMPRESSOR_MENU), OXYGEN_DECOMPRESSOR); Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.BUBBLE_DISTRIBUTOR_MENU), OXYGEN_BUBBLE_DISTRIBUTOR); Registry.register(BuiltInRegistries.MENU, Constant.id(Constant.Menu.OXYGEN_SEALER_MENU), OXYGEN_SEALER); diff --git a/src/main/java/dev/galacticraft/mod/tag/GCTags.java b/src/main/java/dev/galacticraft/mod/tag/GCTags.java index 61ab871dc..65db9611a 100644 --- a/src/main/java/dev/galacticraft/mod/tag/GCTags.java +++ b/src/main/java/dev/galacticraft/mod/tag/GCTags.java @@ -43,6 +43,7 @@ public class GCTags { public static final TagKey INFINIBURN_MOON = TagKey.create(Registries.BLOCK, Constant.id("infiniburn_moon")); public static final TagKey INFINIBURN_VENUS = TagKey.create(Registries.BLOCK, Constant.id("infiniburn_venus")); + public static final TagKey INFINIBURN_ASTEROID = TagKey.create(Registries.BLOCK, Constant.id("infiniburn_asteroid")); public static final TagKey BASE_STONE_MOON = TagKey.create(Registries.BLOCK, Constant.id("base_stone_moon")); public static final TagKey MOON_CARVER_REPLACEABLES = TagKey.create(Registries.BLOCK, Constant.id("moon_carver_replaceables")); public static final TagKey MOON_CRATER_CARVER_REPLACEABLES = TagKey.create(Registries.BLOCK, Constant.id("moon_crater_carver_replaceables")); @@ -53,6 +54,7 @@ public class GCTags { public static final TagKey MOON = TagKey.create(Registries.BIOME, Constant.id("moon")); public static final TagKey VENUS = TagKey.create(Registries.BIOME, Constant.id("venus")); + public static final TagKey ASTEROID = TagKey.create(Registries.BIOME, Constant.id("asteroid")); public static final TagKey MOON_PILLAGER_BASE_HAS_STRUCTURE = TagKey.create(Registries.BIOME, Constant.id("has_structure/moon_pillager_base")); public static final TagKey MOON_VILLAGE_HIGHLANDS_HAS_STRUCTURE = TagKey.create(Registries.BIOME, Constant.id("has_structure/moon_village_highlands")); diff --git a/src/main/java/dev/galacticraft/mod/util/TextureUtils.java b/src/main/java/dev/galacticraft/mod/util/TextureUtils.java new file mode 100644 index 000000000..fd82a42f3 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/util/TextureUtils.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.Material; +import net.minecraft.client.resources.model.ModelManager; +import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; +import java.util.Optional; + +public class TextureUtils { + public static int getAverageColor(ResourceLocation textureLocation) { + Optional resourceOptional = Minecraft.getInstance().getResourceManager().getResource(textureLocation); + if (resourceOptional.isEmpty()) { + throw new RuntimeException("Failed to find resource: " + textureLocation); + } + + try (InputStream is = resourceOptional.get().open()) { + BufferedImage image = ImageIO.read(is); + return calculateAverageColor(image); + } catch (IOException e) { + throw new RuntimeException("Failed to load image: " + textureLocation, e); + } + } + + private static int calculateAverageColor(BufferedImage image) { + long sumRed = 0; + long sumGreen = 0; + long sumBlue = 0; + int pixelCount = 0; + + for (int y = 0; y < image.getHeight(); y++) { + for (int x = 0; x < image.getWidth(); x++) { + + int rgb = image.getRGB(x, y); + if (rgb != 0) + { + int red = (rgb >> 16) & 0xFF; + int green = (rgb >> 8) & 0xFF; + int blue = rgb & 0xFF; + + sumRed += red; + sumGreen += green; + sumBlue += blue; + pixelCount++; + } + } + } + + int avgRed = (int) (sumRed / pixelCount); + int avgGreen = (int) (sumGreen / pixelCount); + int avgBlue = (int) (sumBlue / pixelCount); + + return (avgRed << 16) | (avgGreen << 8) | avgBlue; + } +} + diff --git a/src/main/java/dev/galacticraft/mod/util/Translations.java b/src/main/java/dev/galacticraft/mod/util/Translations.java index 85adfd927..6b3db9a74 100644 --- a/src/main/java/dev/galacticraft/mod/util/Translations.java +++ b/src/main/java/dev/galacticraft/mod/util/Translations.java @@ -23,10 +23,12 @@ package dev.galacticraft.mod.util; public interface Translations { + interface ItemGroup { String ITEMS = "itemGroup.galacticraft.items"; String BLOCKS = "itemGroup.galacticraft.blocks"; String MACHINES = "itemGroup.galacticraft.machines"; + String CANNED_FOOD = "itemGroup.galacticraft.canned_food"; } interface RecipeCategory { @@ -95,6 +97,7 @@ interface Config { String ENERGY_STORAGE_MODULE_STORAGE_SIZE = "config.galacticraft.energy.machines.energy_storage_module_storage_size"; String ENERGY_STORAGE_SIZE = "config.galacticraft.energy.machines.energy_storage_size"; String OXYGEN_COMPRESSOR_ENERGY_CONSUMPTION_RATE = "config.galacticraft.energy.machines.oxygen_compressor_energy_consumption_rate"; + String FOOD_CANNER_ENERGY_CONSUMPTION_RATE = "config.galacticraft.energy.machines.food_canner_energy_consumption_rate"; String OXYGEN_DECOMPRESSOR_ENERGY_CONSUMPTION_RATE = "config.galacticraft.energy.machines.oxygen_decompressor_energy_consumption_rate"; String CLIENT = "config.galacticraft.client"; @@ -120,12 +123,18 @@ interface Keybindings { String OPEN_CELESTIAL_SCREEN = "key.galacticraft.open_celestial_screen"; } + interface Items { + String EMPTY_CANNED_FOOD = "item.galacticraft.empty_canned_food"; + String CANNED_FOOD = "item.galacticraft.canned_food"; + String TOTAL_NUTRITION = "item.galacticraft.total_nutrition"; + } + interface CelestialBody { String SOL_DESC = "star.galacticraft.sol.description"; String SOL = "star.galacticraft.sol"; - String ASTEROIDS_DESC = "planet.galacticraft.asteroids.description"; - String ASTEROIDS = "planet.galacticraft.asteroids"; + String ASTEROID_DESC = "planet.galacticraft.asteroid.description"; + String ASTEROID = "planet.galacticraft.asteroid"; String EARTH_DESC = "planet.galacticraft.earth.description"; String EARTH = "planet.galacticraft.earth"; String JUPITER_DESC = "planet.galacticraft.jupiter.description"; @@ -224,7 +233,11 @@ interface MachineStatus { String ALREADY_SEALED = "ui.galacticraft.status.already_sealed"; String AREA_TOO_LARGE = "ui.galacticraft.status.area_too_large"; String BLOCKED = "ui.galacticraft.status.blocked"; + String MISSING_EMPTY_CAN = "ui.galacticraft.status.missing_empty_can"; String COLLECTING = "ui.galacticraft.status.collecting"; + String CANNING = "ui.galacticraft.status.canning"; + String TRANSFERRING_CAN = "ui.galacticraft.status.transferring_can"; + String NO_FOOD = "ui.galacticraft.status.no_food"; String COMPRESSING = "ui.galacticraft.status.compressing"; String COOLING_DOWN = "ui.galacticraft.status.cooling_down"; String DECOMPRESSING = "ui.galacticraft.status.decompressing"; diff --git a/src/main/java/dev/galacticraft/mod/world/biome/AsteroidBiomes.java b/src/main/java/dev/galacticraft/mod/world/biome/AsteroidBiomes.java new file mode 100644 index 000000000..3d2a33a4b --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/biome/AsteroidBiomes.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.biome; + +import dev.galacticraft.mod.content.GCEntityTypes; +import dev.galacticraft.mod.content.GCSounds; +import dev.galacticraft.mod.world.gen.feature.GCOrePlacedFeatures; +import net.minecraft.core.HolderGetter; +import net.minecraft.sounds.Musics; +import net.minecraft.world.entity.MobCategory; +import net.minecraft.world.level.biome.*; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; +import net.minecraft.world.level.levelgen.placement.PlacedFeature; + +import java.awt.*; + +public class AsteroidBiomes { + public static void monsters(MobSpawnSettings.Builder builder, int zombieWeight, int zombieVillagerWeight, int selektonWeight) { + builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_SPIDER, 100, 4, 4)); + builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_ZOMBIE, zombieWeight, 4, 4)); +// builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_ZOMBIE_VILLAGER, zombieVillagerWeight, 1, 1)); + builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_SKELETON, selektonWeight, 4, 4)); + builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_CREEPER, 100, 4, 4)); +// builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_SLIME, 100, 4, 4)); +// builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_ENDERMAN, 10, 1, 4)); +// builder.addSpawn(MobCategory.MONSTER, new MobSpawnSettings.SpawnerData(GCEntityTypes.EVOLVED_WITCH, 5, 1, 1)); + } + + public static Biome asteroid( + HolderGetter featureGetter, HolderGetter> carverGetter + ) { + MobSpawnSettings.Builder spawnBuilder = new MobSpawnSettings.Builder(); + BiomeGenerationSettings.Builder generation = new BiomeGenerationSettings.Builder(featureGetter, carverGetter); + BiomeSpecialEffects.Builder specialEffects = new BiomeSpecialEffects.Builder(); + specialEffects.waterColor(0) + .waterFogColor(0) + .fogColor(0) + .skyColor(0) + .ambientMoodSound(AmbientMoodSettings.LEGACY_CAVE_SETTINGS) + .backgroundMusic(Musics.createGameMusic(GCSounds.MUSIC_ORBIT)); + AsteroidBiomes.monsters(spawnBuilder, 95, 5, 100); + + return new Biome.BiomeBuilder() + .mobSpawnSettings(spawnBuilder.build()) + .hasPrecipitation(false) + .temperature(2.0F) + .downfall(0.5F) + .specialEffects(specialEffects.build()) + .generationSettings(generation.build()) + .build(); + } +} diff --git a/src/main/java/dev/galacticraft/mod/world/biome/GCBiomes.java b/src/main/java/dev/galacticraft/mod/world/biome/GCBiomes.java index cb5d4437a..22cbfe364 100644 --- a/src/main/java/dev/galacticraft/mod/world/biome/GCBiomes.java +++ b/src/main/java/dev/galacticraft/mod/world/biome/GCBiomes.java @@ -51,6 +51,10 @@ public static final class Venus { public static final ResourceKey VENUS_MOUNTAIN = key("venus_mountain"); } + public static final class Asteroid { + public static final ResourceKey ASTEROID_FIELD = key("asteroid_field"); + } + public static final ResourceKey SPACE = ResourceKey.create(Registries.BIOME, Constant.id("space")); public static Biome createSpaceBiome(HolderGetter holderGetter, HolderGetter> holderGetter2) { @@ -82,6 +86,8 @@ public static void bootstrapRegistries(BootstrapContext context) { // moj context.register(Venus.VENUS_VALLEY, VenusBiomes.venus(featureLookup, carverLookup)); context.register(Venus.VENUS_FLAT, VenusBiomes.venus(featureLookup, carverLookup)); context.register(Venus.VENUS_MOUNTAIN, VenusBiomes.venus(featureLookup, carverLookup)); + + context.register(Asteroid.ASTEROID_FIELD, AsteroidBiomes.asteroid(featureLookup, carverLookup)); } @Contract(pure = true) diff --git a/src/main/java/dev/galacticraft/mod/world/biome/source/GCMultiNoiseBiomeSourceParameterLists.java b/src/main/java/dev/galacticraft/mod/world/biome/source/GCMultiNoiseBiomeSourceParameterLists.java index 58b6d9473..d2282af76 100644 --- a/src/main/java/dev/galacticraft/mod/world/biome/source/GCMultiNoiseBiomeSourceParameterLists.java +++ b/src/main/java/dev/galacticraft/mod/world/biome/source/GCMultiNoiseBiomeSourceParameterLists.java @@ -86,15 +86,20 @@ public class GCMultiNoiseBiomeSourceParameterLists { public static final ResourceLocation MOON_PRESET_ID = Constant.id("moon"); public static final ResourceLocation VENUS_PRESET_ID = Constant.id("venus"); + public static final ResourceLocation ASTEROID_PRESET_ID = Constant.id("asteroid"); public static final MultiNoiseBiomeSourceParameterList.Preset MOON_PRESET = new MultiNoiseBiomeSourceParameterList.Preset( MOON_PRESET_ID, GCMultiNoiseBiomeSourceParameterLists::generateMoon ); public static final MultiNoiseBiomeSourceParameterList.Preset VENUS_PRESET = new MultiNoiseBiomeSourceParameterList.Preset( VENUS_PRESET_ID, GCMultiNoiseBiomeSourceParameterLists::generateVenus ); + public static final MultiNoiseBiomeSourceParameterList.Preset ASTEROID_PRESET = new MultiNoiseBiomeSourceParameterList.Preset( + ASTEROID_PRESET_ID, GCMultiNoiseBiomeSourceParameterLists::generateAsteroid + ); public static final ResourceKey MOON = Constant.key(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, "moon"); public static final ResourceKey VENUS = Constant.key(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, "venus"); + public static final ResourceKey ASTEROID = Constant.key(Registries.MULTI_NOISE_BIOME_SOURCE_PARAMETER_LIST, "asteroid"); @Contract("_ -> new") private static Climate.@NotNull ParameterList generateMoon(Function, T> biomeRegistry) { @@ -167,6 +172,21 @@ public class GCMultiNoiseBiomeSourceParameterLists { return new Climate.ParameterList<>(builder.build()); } + @Contract("_ -> new") + private static Climate.@NotNull ParameterList generateAsteroid(Function, T> biomeRegistry) { + ImmutableList.Builder> builder = ImmutableList.builder(); + writeBiomeParameters(builder::add, + HOT, // hot to prevent snow + DRY,// , + Parameter.span(SHORE_CONTINENTALNESS, MID_INLAND_CONTINENTALNESS), + MIN_EROSION, + WEIRDNESS_H_MIXED, + 0.0F, + biomeRegistry.apply(GCBiomes.Asteroid.ASTEROID_FIELD)); + + return new Climate.ParameterList<>(builder.build()); + } + private static void writeBiomeParameters( Consumer> parameters, Parameter temperature, @@ -194,12 +214,15 @@ private static void writeBiomeParameters( public static void register() { MultiNoiseBiomeSourceParameterListPresetAccessor.getByName().put(MOON_PRESET_ID, MOON_PRESET); MultiNoiseBiomeSourceParameterListPresetAccessor.getByName().put(VENUS_PRESET_ID, VENUS_PRESET); + MultiNoiseBiomeSourceParameterListPresetAccessor.getByName().put(ASTEROID_PRESET_ID, ASTEROID_PRESET); + } public static void bootstrapRegistries(BootstrapContext context) { HolderGetter lookup = context.lookup(Registries.BIOME); context.register(MOON, new MultiNoiseBiomeSourceParameterList(MOON_PRESET, lookup)); context.register(VENUS, new MultiNoiseBiomeSourceParameterList(VENUS_PRESET, lookup)); + context.register(ASTEROID, new MultiNoiseBiomeSourceParameterList(ASTEROID_PRESET, lookup)); } } diff --git a/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensionTypes.java b/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensionTypes.java index af9af75ad..a4ba5ccea 100644 --- a/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensionTypes.java +++ b/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensionTypes.java @@ -22,6 +22,7 @@ package dev.galacticraft.mod.world.dimension; +import com.google.common.base.Optional; import dev.galacticraft.mod.Constant; import dev.galacticraft.mod.tag.GCTags; import net.minecraft.core.registries.Registries; @@ -37,6 +38,7 @@ public class GCDimensionTypes { public static final ResourceKey MOON = key("moon"); public static final ResourceKey VENUS = key("venus"); + public static final ResourceKey ASTEROID = key("asteroid"); public static void bootstrapRegistries(BootstrapContext context) { context.register(MOON, new DimensionType( @@ -74,6 +76,23 @@ public static void bootstrapRegistries(BootstrapContext context) 0.1F, // ambientLight new DimensionType.MonsterSettings(false, false, UniformInt.of(0, 7), 0) )); + context.register(ASTEROID, new DimensionType( + OptionalLong.empty(), // fixedTime + false, // hasSkyLight + false, // hasCeiling + false, // ultraWarm + false, // natural + 1.0, // coordinateScale + false, // bedWorks + false, // respawnAnchorWorks + -64, // minY + 384, // height + 384, // logicalHeight + GCTags.INFINIBURN_ASTEROID, // infiniburn + Constant.id("asteroid"), // effectsLocation // fixme + 0.0F, // ambientLight + new DimensionType.MonsterSettings(false, false, UniformInt.of(0, 7), 0) + )); } @Contract(value = "_ -> new", pure = true) diff --git a/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensions.java b/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensions.java index ee30ea2e7..eafb8c6f5 100644 --- a/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensions.java +++ b/src/main/java/dev/galacticraft/mod/world/dimension/GCDimensions.java @@ -32,6 +32,7 @@ public class GCDimensions { public static final ResourceKey MOON = key("moon"); public static final ResourceKey VENUS = key("venus"); + public static final ResourceKey ASTEROID = key("asteroid"); @Contract(pure = true) private static @NotNull ResourceKey key(@NotNull String id) { diff --git a/src/main/java/dev/galacticraft/mod/world/dimension/GCLevelStems.java b/src/main/java/dev/galacticraft/mod/world/dimension/GCLevelStems.java index d274663a1..aa054d632 100644 --- a/src/main/java/dev/galacticraft/mod/world/dimension/GCLevelStems.java +++ b/src/main/java/dev/galacticraft/mod/world/dimension/GCLevelStems.java @@ -23,15 +23,16 @@ package dev.galacticraft.mod.world.dimension; import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.world.biome.GCBiomes; import dev.galacticraft.mod.world.biome.source.GCMultiNoiseBiomeSourceParameterLists; import dev.galacticraft.mod.world.gen.GCNoiseGeneratorSettings; +import dev.galacticraft.mod.world.gen.custom.AsteroidChunkGenerator; import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import net.minecraft.world.level.biome.Biome; -import net.minecraft.world.level.biome.MultiNoiseBiomeSource; -import net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.biome.*; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; @@ -42,6 +43,7 @@ public class GCLevelStems { public static final ResourceKey MOON = key("moon"); public static final ResourceKey VENUS = key("venus"); + public static final ResourceKey ASTEROID = key("asteroid"); public static void bootstrapRegistries(@NotNull BootstrapContext context) { HolderGetter typeLookup = context.lookup(Registries.DIMENSION_TYPE); @@ -52,6 +54,7 @@ public static void bootstrapRegistries(@NotNull BootstrapContext cont // the returned reference may be null // context.register(MOON, new LevelStem(typeLookup.getOrThrow(GCDimensionTypes.MOON), new NoiseBasedChunkGenerator(MultiNoiseBiomeSource.createFromPreset(biomeNoiseLookup.getOrThrow(GCMultiNoiseBiomeSourceParameterLists.MOON)), noiseLookup.getOrThrow(GCNoiseGeneratorSettings.MOON)))); context.register(VENUS, new LevelStem(typeLookup.getOrThrow(GCDimensionTypes.VENUS), new NoiseBasedChunkGenerator(MultiNoiseBiomeSource.createFromPreset(biomeNoiseLookup.getOrThrow(GCMultiNoiseBiomeSourceParameterLists.VENUS)), noiseLookup.getOrThrow(GCNoiseGeneratorSettings.VENUS)))); + context.register(ASTEROID, new LevelStem(typeLookup.getOrThrow(GCDimensionTypes.ASTEROID), new AsteroidChunkGenerator(MultiNoiseBiomeSource.createFromPreset(biomeNoiseLookup.getOrThrow(GCMultiNoiseBiomeSourceParameterLists.ASTEROID)), ResourceKey.create(Registries.DIMENSION, Constant.id("asteroid")), 1000))); } @Contract(value = "_ -> new", pure = true) diff --git a/src/main/java/dev/galacticraft/mod/world/gen/GCDensityFunctions.java b/src/main/java/dev/galacticraft/mod/world/gen/GCDensityFunctions.java index e9b8e049a..8bd60179b 100644 --- a/src/main/java/dev/galacticraft/mod/world/gen/GCDensityFunctions.java +++ b/src/main/java/dev/galacticraft/mod/world/gen/GCDensityFunctions.java @@ -44,6 +44,10 @@ public static final class Venus { // Final Density handles overall terrain shape public static final ResourceKey FINAL_DENSITY = createKey("venus/final_density"); } + public static final class Asteroid { + // Final Density handles overall terrain shape + public static final ResourceKey FINAL_DENSITY = createKey("asteroid/final_density"); + } private static ResourceKey createKey(String id) { return ResourceKey.create(Registries.DENSITY_FUNCTION, Constant.id(id)); @@ -129,6 +133,11 @@ public static void bootstrapRegistries(BootstrapContext context DensityFunctions.yClampedGradient(0, 90, 1, -1), BlendedNoise.createUnseeded(0.25, 0.375, 80.0, 160.0, 8.0) )); + + context.register(Asteroid.FINAL_DENSITY, DensityFunctions.add( + DensityFunctions.yClampedGradient(0, 90, 1, -1), + BlendedNoise.createUnseeded(0.25, 0.375, 80.0, 160.0, 8.0) + )); } private static DensityFunction registerAndWrap(BootstrapContext context, ResourceKey key, DensityFunction densityFunction) { diff --git a/src/main/java/dev/galacticraft/mod/world/gen/base/MapGenAbandonedBase.java b/src/main/java/dev/galacticraft/mod/world/gen/base/MapGenAbandonedBase.java new file mode 100644 index 000000000..ecb0bb9a5 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/gen/base/MapGenAbandonedBase.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.gen.base; + +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.block.Blocks; + +import java.util.Random; + +public class MapGenAbandonedBase { + public static void generateStructure(ServerLevel world, Random rand, BlockPos pos) { + // Example: Simple 3x3x3 cube of stone + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + for (int z = 0; z < 3; z++) { + world.setBlock(pos.offset(x, y, z), Blocks.STONE.defaultBlockState(), 0); + } + } + } + } +} diff --git a/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidChunkGenerator.java b/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidChunkGenerator.java new file mode 100644 index 000000000..1654f8aec --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidChunkGenerator.java @@ -0,0 +1,1093 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.gen.custom; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.galacticraft.api.perlin.NoiseModule; +import dev.galacticraft.api.perlin.generator.Billowed; +import dev.galacticraft.api.perlin.generator.Gradient; +import dev.galacticraft.api.vector.BlockVec3; +import dev.galacticraft.mod.content.GCBlocks; +import dev.galacticraft.mod.world.gen.base.MapGenAbandonedBase; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.world.level.*; +import net.minecraft.world.level.biome.BiomeManager; +import net.minecraft.world.level.biome.BiomeSource; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.*; +import net.minecraft.world.level.levelgen.*; +import net.minecraft.world.level.levelgen.blending.Blender; +import net.minecraft.world.level.storage.*; +import org.jetbrains.annotations.NotNull; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static dev.galacticraft.impl.internal.fabric.GalacticraftAPI.currentWorldSaveDirectory; +import static dev.galacticraft.mod.world.gen.custom.AsteroidSaveData.saveDataID; + + +public class AsteroidChunkGenerator extends ChunkGenerator { + + //from WorldAsteroidProvider + private HashSet asteroids = new HashSet<>(); + private boolean dataNotLoaded = true; + private AsteroidSaveData datafile; + private double solarMultiplier = -1D; + + private int largeCount = 0; + private final Random rand; + private final NoiseModule asteroidDensity; + private final NoiseModule asteroidTurbulance; + private final ResourceKey dimensionKey; + + private final NoiseModule asteroidSkewX; + private final NoiseModule asteroidSkewY; + private final NoiseModule asteroidSkewZ; + + private final SpecialAsteroidBlockHandler coreHandler; + private final SpecialAsteroidBlockHandler shellHandler; + //micdoodle8 says do not change but I did :) + private static final int CHUNK_SIZE_X = 16; + private static final int CHUNK_SIZE_Y = 384; + private static final int CHUNK_SIZE_Z = 16; + + private static final int MAX_ASTEROID_RADIUS = 25; + private static final int MIN_ASTEROID_RADIUS = 5; + + private static final int MAX_ASTEROID_SKEW = 8; + + //MIN_ASTEROID_Y is -64 + 48 + private static final int MIN_ASTEROID_Y = -16; + //MAX_ASTEROID_Y is 384 - 64 - 48 + private static final int MAX_ASTEROID_Y = AsteroidChunkGenerator.CHUNK_SIZE_Y - 64 - 48; + //default is 800 + private static final int ASTEROID_CHANCE = 800; + private static final int ASTEROID_CORE_CHANCE = 2; //1 / n chance per asteroid + private static final int ASTEROID_SHELL_CHANCE = 2; //1 / n chance per asteroid + + private static final int MIN_BLOCKS_PER_CHUNK = 50; + private static final int MAX_BLOCKS_PER_CHUNK = 200; + + private static final int ILMENITE_CHANCE = 400; + private static final int IRON_CHANCE = 300; + private static final int ALUMINUM_CHANCE = 250; + + private static final int RANDOM_BLOCK_FADE_SIZE = 32; + private static final int FADE_BLOCK_CHANCE = 5; //1 / n chance of a block being in the fade zone + + private static final int NOISE_OFFSET_SIZE = 256; + + private static final float MIN_HOLLOW_SIZE = .6F; + private static final float MAX_HOLLOW_SIZE = .8F; + private static final int HOLLOW_CHANCE = 10; //1 / n chance per asteroid + private static final int MIN_RADIUS_FOR_HOLLOW = 15; + private static final float HOLLOW_LAVA_SIZE = .12F; + + //Per chunk per asteroid + private static final int TREE_CHANCE = 2; + private static final int TALL_GRASS_CHANCE = 2; + private static final int FLOWER_CHANCE = 2; + private static final int WATER_CHANCE = 2; + private static final int LAVA_CHANCE = 2; + private static final int GLOWSTONE_CHANCE = 20; + + private LinkedList largeAsteroids = new LinkedList(); + private static HashSet chunksDone = new HashSet(); + private int largeAsteroidsLastChunkX; + private int largeAsteroidsLastChunkZ; + private final MapGenAbandonedBase dungeonGenerator = new MapGenAbandonedBase(); + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + BiomeSource.CODEC.fieldOf("biomeSource").forGetter(generator -> generator.biomeSource), + ServerLevel.RESOURCE_KEY_CODEC.fieldOf("dimensionKey").forGetter(generator -> generator.dimensionKey), + Codec.LONG.fieldOf("par2").forGetter(generator -> 1000L) + ).apply(instance, AsteroidChunkGenerator::new)); + private final Holder settings = null; + public AsteroidChunkGenerator(BiomeSource biomeSource, ResourceKey dimensionKey, long par2) { + super(biomeSource); + this.dimensionKey = dimensionKey; + this.rand = new Random(par2); + + this.asteroidDensity = new Billowed(this.rand.nextLong(), 2, .25F); + this.asteroidDensity.setFrequency(.009F); + this.asteroidDensity.amplitude = .6F; + + this.asteroidTurbulance = new Gradient(this.rand.nextLong(), 1, .2F); + this.asteroidTurbulance.setFrequency(.08F); + this.asteroidTurbulance.amplitude = .5F; + + this.asteroidSkewX = new Gradient(this.rand.nextLong(), 1, 1); + this.asteroidSkewX.amplitude = AsteroidChunkGenerator.MAX_ASTEROID_SKEW; + this.asteroidSkewX.frequencyX = 0.005F; + + this.asteroidSkewY = new Gradient(this.rand.nextLong(), 1, 1); + this.asteroidSkewY.amplitude = AsteroidChunkGenerator.MAX_ASTEROID_SKEW; + this.asteroidSkewY.frequencyY = 0.005F; + + this.asteroidSkewZ = new Gradient(this.rand.nextLong(), 1, 1); + this.asteroidSkewZ.amplitude = AsteroidChunkGenerator.MAX_ASTEROID_SKEW; + this.asteroidSkewZ.frequencyZ = 0.005F; + + this.coreHandler = new SpecialAsteroidBlockHandler(); + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK_2, 5, .3)); + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK_1, 7, .3)); + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK, 11, .25)); + + //!ConfigManagerAst.disableAluminumGen + if (true) + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ALUMINUM_ORE, 5, .2)); + //!ConfigManagerAsteroids.disableIlmeniteGen + if (true) + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ILMENITE_ORE, 4, .15)); + //!ConfigManagerAsteroids.disableIronGen + if (true) + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_IRON_ORE, 3, .2)); + //ConfigManagerCore.enableSiliconOreGen + if (true) + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_SILICON_ORE,2, .15)); + //Solid Meteoric Iron - has no config to disable + this.coreHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.METEORIC_IRON_BLOCK, 2, .13)); + //Diamond ore - has no config to disable + this.coreHandler.addBlock(new SpecialAsteroidBlock(Blocks.DIAMOND_ORE, 1, .1)); + + this.shellHandler = new SpecialAsteroidBlockHandler(); + this.shellHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK, 1, .15)); + this.shellHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK_1, 3, .15)); + this.shellHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.ASTEROID_ROCK_2, 1, .15)); + this.shellHandler.addBlock(new SpecialAsteroidBlock(GCBlocks.DENSE_ICE, 1, .15)); + } + + private ChunkAccess generateChunkData(Blender blender, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess) { + int heightLimit = chunkAccess.getHeight(); + int chunkX = chunkAccess.getPos().x; + int chunkZ = chunkAccess.getPos().z; + + this.largeAsteroids.clear(); + this.largeCount = 0; + final Random random = new Random(); + final int asteroidChance = AsteroidChunkGenerator.ASTEROID_CHANCE; + final int rangeY = AsteroidChunkGenerator.MAX_ASTEROID_Y - AsteroidChunkGenerator.MIN_ASTEROID_Y; + final int rangeSize = AsteroidChunkGenerator.MAX_ASTEROID_RADIUS - AsteroidChunkGenerator.MIN_ASTEROID_RADIUS; + + //If asteroid centre is nearby might need to generate some asteroid parts in this chunk + for (int i = chunkX - 3; i < chunkX + 3; i++) + { + int minX = i * 16; + int maxX = minX + AsteroidChunkGenerator.CHUNK_SIZE_X; + for (int k = chunkZ - 3; k < chunkZ + 3; k++) + { + int minZ = k * 16; + int maxZ = minZ + AsteroidChunkGenerator.CHUNK_SIZE_Z; + + //something about redundant code in gc4's code + for (int x = minX; x < maxX; x += 2) + { + for (int z = minZ; z < maxZ; z += 2) + { + //the next line is called 3136 times per chunk generated apparently? saying something about slow getNoise + if (this.randFromPointPos(x, z) < (this.asteroidDensity.getNoise(x, z) + .4) / asteroidChance) + { + random.setSeed(x + z * 3067); + int y = random.nextInt(rangeY) + AsteroidChunkGenerator.MIN_ASTEROID_Y; + int size = random.nextInt(rangeSize) + AsteroidChunkGenerator.MIN_ASTEROID_RADIUS; + + //generate the parts of the asteroid which are in this chunk + this.generateAsteroid(random, x, y, z, chunkX << 4, chunkZ << 4, size, chunkAccess); + this.largeCount++; + } + } + } + } + } + + return chunkAccess; + } + + public DimensionDataStorage getDimensionDataStorage(MinecraftServer server) { + ServerLevel level = server.getLevel(dimensionKey); + if (level == null) { + throw new IllegalStateException("ServerLevel for the given dimensionKey does not exist."); + } + return level.getDataStorage(); + } + + private void generateAsteroid(Random rand, int asteroidX, int asteroidY, int asteroidZ, int chunkX, int chunkZ, int size, ChunkAccess primer) + { + SpecialAsteroidBlock core = this.coreHandler.getBlock(rand, size); + + SpecialAsteroidBlock shell = null; + if (rand.nextInt(AsteroidChunkGenerator.ASTEROID_SHELL_CHANCE) == 0) + { + shell = this.shellHandler.getBlock(rand, size); + } + + boolean isHollow = false; + final float hollowSize = rand.nextFloat() * (AsteroidChunkGenerator.MAX_HOLLOW_SIZE - AsteroidChunkGenerator.MIN_HOLLOW_SIZE) + AsteroidChunkGenerator.MIN_HOLLOW_SIZE; + if (rand.nextInt(AsteroidChunkGenerator.HOLLOW_CHANCE) == 0 && size >= AsteroidChunkGenerator.MIN_RADIUS_FOR_HOLLOW) + { + isHollow = true; + shell = new SpecialAsteroidBlock(GCBlocks.DENSE_ICE, 1, .15); + } + + //Add to the list of asteroids for external use + ((AsteroidChunkGenerator) this).addAsteroid(asteroidX, asteroidY, asteroidZ, size, isHollow ? -1 : core.index); + + final int xMin = this.clamp(Math.max(chunkX, asteroidX - size - AsteroidChunkGenerator.MAX_ASTEROID_SKEW - 2) - chunkX, 0, 16); + final int zMin = this.clamp(Math.max(chunkZ, asteroidZ - size - AsteroidChunkGenerator.MAX_ASTEROID_SKEW - 2) - chunkZ, 0, 16); + final int yMin = asteroidY - size - AsteroidChunkGenerator.MAX_ASTEROID_SKEW - 2; + final int yMax = asteroidY + size + AsteroidChunkGenerator.MAX_ASTEROID_SKEW + 2; + final int xMax = this.clamp(Math.min(chunkX + 16, asteroidX + size + AsteroidChunkGenerator.MAX_ASTEROID_SKEW + 2) - chunkX, 0, 16); + final int zMax = this.clamp(Math.min(chunkZ + 16, asteroidZ + size + AsteroidChunkGenerator.MAX_ASTEROID_SKEW + 2) - chunkZ, 0, 16); + final int xSize = xMax - xMin; + final int ySize = yMax - yMin; + final int zSize = zMax - zMin; + + if (xSize <= 0 || ySize <= 0 || zSize <= 0) + { + return; + } + + final float noiseOffsetX = this.randFromPoint(asteroidX, asteroidY, asteroidZ) * AsteroidChunkGenerator.NOISE_OFFSET_SIZE + chunkX; + final float noiseOffsetY = this.randFromPoint(asteroidX * 7, asteroidY * 11, asteroidZ * 13) * AsteroidChunkGenerator.NOISE_OFFSET_SIZE; + final float noiseOffsetZ = this.randFromPoint(asteroidX * 17, asteroidY * 23, asteroidZ * 29) * AsteroidChunkGenerator.NOISE_OFFSET_SIZE + chunkZ; + this.setOtherAxisFrequency(1F / (size * 2F / 2F)); + + float[] sizeXArray = new float[ySize * zSize]; + float[] sizeZArray = new float[xSize * ySize]; + float[] sizeYArray = new float[xSize * zSize]; + + for (int x = 0; x < xSize; x++) + { + int xx = x * zSize; + float xxx = x + noiseOffsetX; + for (int z = 0; z < zSize; z++) + { + sizeYArray[xx + z] = this.asteroidSkewY.getNoise(xxx, z + noiseOffsetZ); + } + } + + AsteroidData asteroidData = new AsteroidData(isHollow, sizeYArray, xMin, zMin, xMax, zMax, zSize, size, asteroidX, asteroidY, asteroidZ); + this.largeAsteroids.add(asteroidData); + this.largeAsteroidsLastChunkX = chunkX; + this.largeAsteroidsLastChunkZ = chunkZ; + + for (int y = 0; y < ySize; y++) + { + int yy = y * zSize; + float yyy = y + noiseOffsetY; + for (int z = 0; z < zSize; z++) + { + sizeXArray[yy + z] = this.asteroidSkewX.getNoise(yyy, z + noiseOffsetZ); + } + } + + for (int x = 0; x < xSize; x++) + { + int xx = x * ySize; + float xxx = x + noiseOffsetX; + for (int y = 0; y < ySize; y++) + { + sizeZArray[xx + y] = this.asteroidSkewZ.getNoise(xxx, y + noiseOffsetY); + } + } + + double shellThickness = 0; + int terrainY = 0; + int terrainYY = 0; + + BlockState asteroidShell = null; + if (shell != null) + { + asteroidShell = shell.block.defaultBlockState(); + shellThickness = 1.0 - shell.thickness; + } + + BlockState asteroidCore = core.block.defaultBlockState(); + BlockState asteroidRock0 = GCBlocks.ASTEROID_ROCK.defaultBlockState(); + BlockState asteroidRock1 = GCBlocks.ASTEROID_ROCK_1.defaultBlockState(); + + for (int x = xMax - 1; x >= xMin; x--) { + int indexXY = (x - xMin) * ySize - yMin; + int indexXZ = (x - xMin) * zSize - zMin; + int distanceX = asteroidX - (x + chunkX); + int indexBaseX = x * AsteroidChunkGenerator.CHUNK_SIZE_Y << 4; + float xx = x + chunkX; + + for (int z = zMin; z < zMax; z++) { + if (isHollow) { + float sizeModY = sizeYArray[indexXZ + z]; + terrainY = this.getTerrainHeightFor(sizeModY, asteroidY, size); + terrainYY = this.getTerrainHeightFor(sizeModY, asteroidY - 1, size); + } + + float sizeY = size + sizeYArray[indexXZ + z]; + sizeY *= sizeY; + int distanceZ = asteroidZ - (z + chunkZ); + int indexBase = indexBaseX | z * AsteroidChunkGenerator.CHUNK_SIZE_Y; + float zz = z + chunkZ; + + for (int y = yMin; y < yMax; y++) { + float dSizeX = distanceX / (size + sizeXArray[(y - yMin) * zSize + z - zMin]); + float dSizeZ = distanceZ / (size + sizeZArray[indexXY + y]); + dSizeX *= dSizeX; + dSizeZ *= dSizeZ; + int distanceY = asteroidY - y; + distanceY *= distanceY; + float distance = dSizeX + distanceY / sizeY + dSizeZ; + float distanceAbove = distance; + distance += this.asteroidTurbulance.getNoise(xx, y, zz); + + if (isHollow && distance <= hollowSize) { + distanceAbove += this.asteroidTurbulance.getNoise(xx, y + 1, zz); + if (distanceAbove <= 1) { + if ((y - 1) == terrainYY) { + int index = indexBase | (y + 1); + primer.setBlockState(new BlockPos(x, y + 1, z), Blocks.GLOWSTONE.defaultBlockState(), false); +// blockArray[index] = this.LIGHT; +// metaArray[index] = this.LIGHT_META; + } + } + } + + if (distance <= 1) { + int index = indexBase | y; + if (isHollow && distance <= hollowSize) { + if (y == terrainY) { + primer.setBlockState(new BlockPos(x, y, z), Blocks.GRASS_BLOCK.defaultBlockState(), false); +// blockArray[index] = this.GRASS; +// metaArray[index] = this.GRASS_META; + } else if (y < terrainY) { + primer.setBlockState(new BlockPos(x, y, z), Blocks.DIRT.defaultBlockState(), false); +// blockArray[index] = this.DIRT; +// metaArray[index] = this.DIRT_META; + } else { + primer.setBlockState(new BlockPos(x, y, z), Blocks.AIR.defaultBlockState(), false); +// blockArray[index] = Blocks.air; +// metaArray[index] = 0; + } + } else if (distance <= core.thickness) { + if (rand.nextBoolean()) { + primer.setBlockState(new BlockPos(x, y, z), asteroidCore, false); +// blockArray[index] = core.block; +// metaArray[index] = core.meta; + } else { + primer.setBlockState(new BlockPos(x, y, z), asteroidRock0, false); +// blockArray[index] = this.ASTEROID_STONE; +// metaArray[index] = this.ASTEROID_STONE_META_0; + } + } else if (shell != null && distance >= shellThickness) { + primer.setBlockState(new BlockPos(x, y, z), asteroidShell, false); +// blockArray[index] = shell.block; +// metaArray[index] = shell.meta; + } else { + primer.setBlockState(new BlockPos(x, y, z), asteroidRock1, false); +// blockArray[index] = this.ASTEROID_STONE; +// metaArray[index] = this.ASTEROID_STONE_META_1; + } + } + } + } + } + + if (isHollow) + { + shellThickness = 0; + if (shell != null) + { + shellThickness = 1.0 - shell.thickness; + } + for (int x = xMin; x < xMax; x++) + { + int indexXY = (x - xMin) * ySize - yMin; + int indexXZ = (x - xMin) * zSize - zMin; + int distanceX = asteroidX - (x + chunkX); + distanceX *= distanceX; + + for (int z = zMin; z < zMax; z++) + { + float sizeModY = sizeYArray[indexXZ + z]; + float sizeY = size + sizeYArray[indexXZ + z]; + sizeY *= sizeY; + int distanceZ = asteroidZ - (z + chunkZ); + distanceZ *= distanceZ; + + for (int y = yMin; y < yMax; y++) + { + float sizeX = size + sizeXArray[(y - yMin) * zSize + z - zMin]; + float sizeZ = size + sizeZArray[indexXY + y]; + sizeX *= sizeX; + sizeZ *= sizeZ; + int distanceY = asteroidY - y; + distanceY *= distanceY; + float distance = distanceX / sizeX + distanceY / sizeY + distanceZ / sizeZ; + distance += this.asteroidTurbulance.getNoise(x + chunkX, y, z + chunkZ); + + if (distance <= 1) + { + BlockState state = primer.getBlockState(new BlockPos(x, y, z)); + BlockState stateAbove = primer.getBlockState(new BlockPos(x, y + 1, z)); + if (Blocks.AIR == stateAbove.getBlock() && (state.getBlock() == GCBlocks.ASTEROID_ROCK || state.getBlock() == GCBlocks.ASTEROID_ROCK_1 || state.getBlock() == GCBlocks.ASTEROID_ROCK_2 || state.getBlock() == Blocks.GRASS_BLOCK)) + { + if (this.rand.nextInt(GLOWSTONE_CHANCE) == 0) + { + primer.setBlockState(new BlockPos(x, y, z), Blocks.GLOWSTONE.defaultBlockState(), false); +// blockArray[index] = this.LIGHT; +// metaArray[index] = this.LIGHT_META; + } + } + } + } + } + } + } + } + + private final int getTerrainHeightFor(float yMod, int asteroidY, int asteroidSize) + { + return (int) (asteroidY - asteroidSize / 4 + yMod * 1.5F); + } + + private final int getTerrainHeightAt(int x, int z, float[] yModArray, int xMin, int zMin, int zSize, int asteroidY, int asteroidSize) + { + final int index = (x - xMin) * zSize - zMin; + if (index < yModArray.length && index >= 0) + { + final float yMod = yModArray[index]; + return this.getTerrainHeightFor(yMod, asteroidY, asteroidSize); + } + return 1; + } + + @Override + protected @NotNull MapCodec codec() { + return CODEC; + } + + @Override + public void applyCarvers(WorldGenRegion region, long seed, RandomState randomState, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunkAccess, GenerationStep.Carving carving) { + int chunkX = chunkAccess.getPos().x; + int chunkZ = chunkAccess.getPos().z; + + int x = chunkX << 4; + int z = chunkZ << 4; + if (!AsteroidChunkGenerator.chunksDone.add(new BlockVec3(x, 0, z))) + { + return; + } + +// BlockFalling.fallInstantly = true; +// this.world.getBiome(new BlockPos(x + 16, 0, z + 16)); +// BlockFalling.fallInstantly = false; + + this.rand.setSeed(seed); + long var7 = this.rand.nextLong() / 2L * 2L + 1L; + long var9 = this.rand.nextLong() / 2L * 2L + 1L; + this.rand.setSeed(chunkX * var7 + chunkZ * var9 ^ seed); + + //50:50 chance to include small blocks each chunk + if (this.rand.nextBoolean()) { + double density = this.asteroidDensity.getNoise(chunkX * 16, chunkZ * 16) * 0.54; + double numOfBlocks = this.clamp(this.randFromPoint(chunkX, chunkZ), .4, 1) * AsteroidChunkGenerator.MAX_BLOCKS_PER_CHUNK * density + AsteroidChunkGenerator.MIN_BLOCKS_PER_CHUNK; + int y0 = this.rand.nextInt(2); + Block block; + int yRange = AsteroidChunkGenerator.MAX_ASTEROID_Y - AsteroidChunkGenerator.MIN_ASTEROID_Y; + x += 4; + z += 4; + + for (int i = 0; i < numOfBlocks; i++) { + int y = this.rand.nextInt(yRange) + AsteroidChunkGenerator.MIN_ASTEROID_Y; + + //50:50 chance vertically as well + if (y0 == (y / 16) % 2) { + int px = x + this.rand.nextInt(AsteroidChunkGenerator.CHUNK_SIZE_X); + int pz = z + this.rand.nextInt(AsteroidChunkGenerator.CHUNK_SIZE_Z); + + block = GCBlocks.ASTEROID_ROCK; + + if (this.rand.nextInt(ILMENITE_CHANCE) == 0) { + block = GCBlocks.ILMENITE_ORE; + } else if (this.rand.nextInt(IRON_CHANCE) == 0) { + block = GCBlocks.MARS_IRON_ORE; + } else if (this.rand.nextInt(ALUMINUM_CHANCE) == 0) { + block = GCBlocks.ALUMINUM_ORE; + } + + chunkAccess.setBlockState(new BlockPos(px, y, pz), block.defaultBlockState(), false); + int count = 9; + if (!(chunkAccess.getBlockState(new BlockPos(px - 1, y, pz)).isAir())) { + count = 1; + } else if (!(chunkAccess.getBlockState(new BlockPos(px - 2, y, pz)).isAir())) { + count = 3; + } else if (!(chunkAccess.getBlockState(new BlockPos(px - 3, y, pz)).isAir())) { + count = 5; + } else if (!(chunkAccess.getBlockState(new BlockPos(px - 4, y, pz)).isAir())) { + count = 7; + } + //world.setLightFor(EnumSkyBlock.BLOCK, new BlockPos(px - (count > 1 ? 1 : 0), y, pz), count); + } + } + } + + if (this.largeAsteroidsLastChunkX != chunkX || this.largeAsteroidsLastChunkZ != chunkZ) + { + this.generateChunkData(null, null, null, chunkAccess); + } + + this.rand.setSeed(chunkX * var7 + chunkZ * var9 ^ seed); + + //Look for hollow asteroids to populate + if (!this.largeAsteroids.isEmpty()) + { + for (AsteroidData asteroidIndex : new ArrayList(this.largeAsteroids)) + { + if (!asteroidIndex.isHollow) + { + continue; + } + + float[] sizeYArray = asteroidIndex.sizeYArray; + int xMin = asteroidIndex.xMinArray; + int zMin = asteroidIndex.zMinArray; + int zSize = asteroidIndex.zSizeArray; + int asteroidY = asteroidIndex.asteroidYArray; + int asteroidSize = asteroidIndex.asteroidSizeArray; + boolean treesdone = false; + + if (rand.nextInt(AsteroidChunkGenerator.TREE_CHANCE) == 0) + { + int treeType = rand.nextInt(3); + if (treeType == 1) + { + treeType = 0; + } + BlockState log = Blocks.OAK_LOG.defaultBlockState(); + BlockState leaves = Blocks.OAK_LEAVES.defaultBlockState(); + /**WorldGenTrees wg = new WorldGenTrees(false, 2, log, leaves, false); + for (int tries = 0; tries < 5; tries++) + { + int i = rand.nextInt(16) + x + 8; + int k = rand.nextInt(16) + z + 8; + if (wg.generate(world, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k))) + { + break; + } + }**/ + treesdone = true; + } + if (!treesdone || rand.nextInt(AsteroidChunkGenerator.TALL_GRASS_CHANCE) == 0) + { + int i = rand.nextInt(16) + x + 8; + int k = rand.nextInt(16) + z + 8; + //new WorldGenTallGrass(GRASS_TYPE).generate(world, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k)); + } + if (rand.nextInt(AsteroidChunkGenerator.FLOWER_CHANCE) == 0) + { + int i = rand.nextInt(16) + x + 8; + int k = rand.nextInt(16) + z + 8; + int[] types = new int[]{2, 4, 5, 7}; + //new WorldGenFlowers(this.FLOWER, Blocks.POPPY).generate(world, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k)); + } + if (rand.nextInt(AsteroidChunkGenerator.LAVA_CHANCE) == 0) + { + int i = rand.nextInt(16) + x + 8; + int k = rand.nextInt(16) + z + 8; + //new WorldGenLakes(this.LAVA).generate(world, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k)); + } + if (rand.nextInt(AsteroidChunkGenerator.WATER_CHANCE) == 0) + { + int i = rand.nextInt(16) + x + 8; + int k = rand.nextInt(16) + z + 8; + //new WorldGenLakes(this.WATER).generate(world, rand, new BlockPos(i, this.getTerrainHeightAt(i - x, k - z, sizeYArray, xMin, zMin, zSize, asteroidY, asteroidSize), k)); + } + } + } + + //Update all block lighting + for (int xx = 0; xx < 16; xx++) + { + int xPos = x + xx; + for (int zz = 0; zz < 16; zz++) + { + int zPos = z + zz; + + //Asteroid at min height 48, size 20, can't have lit blocks below 16 + for (int y = 16; y < 240; y++) + { +//LIGHTTEMP world.checkLightFor(EnumSkyBlock.BLOCK, new BlockPos(xPos, y, zPos)); + } + } + } + + //this.dungeonGenerator.generateStructure(chunkAccess, this.rand, new ChunkPos(chunkX, chunkZ)); + } + + @Override + public void buildSurface(WorldGenRegion region, StructureManager structureManager, RandomState randomState, ChunkAccess chunkAccess) { + + } + + @Override + public void spawnOriginalMobs(WorldGenRegion region) { + + } + + @Override + public int getGenDepth() { + return 0; + } + + @Override + public CompletableFuture fillFromNoise(Blender blender, RandomState noiseConfig, StructureManager structureAccessor, ChunkAccess chunk) { + CompletableFuture future = new CompletableFuture<>(); + + Minecraft.getInstance().submit(() -> { + try { + // This operation will now run on Minecraft's main thread + ChunkAccess result = generateChunkData(blender, noiseConfig, structureAccessor, chunk); + future.complete(result); + } catch (Exception e) { + future.completeExceptionally(e); + } + }); + + return future; + } + + public void resetBase() + { + //this.dungeonGenerator.reset(); + } + + + + @Override + public int getSeaLevel() { + return 0; + } + + @Override + public int getMinY() { + return 0; + } + + @Override + public int getBaseHeight(int i, int j, Heightmap.Types types, LevelHeightAccessor levelHeightAccessor, RandomState randomState) { + return 0; + } + + @Override + public NoiseColumn getBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, RandomState randomState) { + return null; + } + + @Override + public void addDebugScreenInfo(List list, RandomState randomState, BlockPos blockPos) { + + } + + private float randFromPointPos(int x, int z) + { + int n = x + z * 57; + n ^= n << 13; + n = n * (n * n * 15731 + 789221) + 1376312589 & 0x3fffffff; + return 1.0F - n / 1073741824.0F; + } + + private final void setOtherAxisFrequency(float frequency) + { + this.asteroidSkewX.frequencyY = frequency; + this.asteroidSkewX.frequencyZ = frequency; + + this.asteroidSkewY.frequencyX = frequency; + this.asteroidSkewY.frequencyZ = frequency; + + this.asteroidSkewZ.frequencyX = frequency; + this.asteroidSkewZ.frequencyY = frequency; + } + + private final int clamp(int x, int min, int max) + { + if (x < min) + { + x = min; + } + else if (x > max) + { + x = max; + } + return x; + } + + private final double clamp(double x, double min, double max) + { + if (x < min) + { + x = min; + } + else if (x > max) + { + x = max; + } + return x; + } + private float randFromPoint(int x, int y, int z) + { + int n = x + z * 57 + y * 571; + n ^= n << 13; + n = n * (n * n * 15731 + 789221) + 1376312589 & 0x7fffffff; + return 1.0F - n / 1073741824.0F; + } + + private float randFromPoint(int x, int z) + { + int n = x + z * 57; + n ^= n << 13; + n = n * (n * n * 15731 + 789221) + 1376312589 & 0x7fffffff; + return 1.0F - n / 1073741824.0F; + } + + public void addAsteroid(int x, int y, int z, int size, int core) + { + AsteroidData coords = new AsteroidData(x, y, z, size, core); + if (!this.asteroids.contains(coords)) + { + if (this.dataNotLoaded) + { + this.loadAsteroidSavedData(); + } + if (!this.asteroids.contains(coords)) + { + this.addToNBT(this.datafile.datacompound, coords); + this.asteroids.add(coords); + } + } + } + + private void addToNBT(CompoundTag nbt, AsteroidData coords) + { + ListTag coordList = nbt.getList("coords", 10); + CompoundTag tag = new CompoundTag(); + coords.writeToNBT(tag); + coordList.add(tag); + nbt.put("coords", coordList); + this.datafile.setDirty(); + Path dataPath = Path.of(currentWorldSaveDirectory.toString(), saveDataID); + Path dataFile = dataPath.resolve("data.dat"); + this.setData(dataFile, datafile); + } + + + private void writeToNBT(CompoundTag nbt) + { + ListTag coordList = new ListTag(); + for (AsteroidData coords : this.asteroids) + { + CompoundTag tag = new CompoundTag(); + coords.writeToNBT(tag); + coordList.add(tag); + } + nbt.put("coords", coordList); + this.datafile.setDirty(); + Path dataPath = Path.of(currentWorldSaveDirectory.toString(), saveDataID); + Path dataFile = dataPath.resolve("data.dat"); + this.setData(dataFile, datafile); + } + + private static class AsteroidData + { + public boolean isHollow; + public float[] sizeYArray; + public int xMinArray; + public int zMinArray; + public int xMax; + public int zMax; + public int zSizeArray; + public int asteroidSizeArray; + public int asteroidXArray; + public int asteroidYArray; + public int asteroidZArray; + + public AsteroidData(boolean hollow, float[] sizeYArray2, int xMin, int zMin, int xmax, int zmax, int zSize, int size, int asteroidX, int asteroidY, int asteroidZ) + { + this.isHollow = hollow; + this.sizeYArray = sizeYArray2.clone(); + this.xMinArray = xMin; + this.zMinArray = zMin; + this.xMax = xmax; + this.zMax = zmax; + this.zSizeArray = zSize; + this.asteroidSizeArray = size; + this.asteroidXArray = asteroidX; + this.asteroidYArray = asteroidY; + this.asteroidZArray = asteroidZ; + } + protected BlockVec3 centre; + protected int sizeAndLandedFlag = 15; + protected int coreAndSpawnedFlag = -2; + + public AsteroidData(int x, int y, int z) + { + this.centre = new BlockVec3(x, y, z); + } + + public AsteroidData(int x, int y, int z, int size, int core) + { + this.centre = new BlockVec3(x, y, z); + this.sizeAndLandedFlag = size; + this.coreAndSpawnedFlag = core; + } + + public AsteroidData(BlockVec3 bv) + { + this.centre = bv; + } + + @Override + public int hashCode() + { + if (this.centre != null) + { + return this.centre.hashCode(); + } + else + { + return 0; + } + } + + @Override + public boolean equals(Object o) + { + if (o instanceof AsteroidData) + { + BlockVec3 vector = ((AsteroidData) o).centre; + return this.centre.x == vector.x && this.centre.y == vector.y && this.centre.z == vector.z; + } + + if (o instanceof BlockVec3) + { + BlockVec3 vector = (BlockVec3) o; + return this.centre.x == vector.x && this.centre.y == vector.y && this.centre.z == vector.z; + } + + return false; + } + + public CompoundTag writeToNBT(CompoundTag tag) + { + tag.putInt("x", this.centre.x); + tag.putInt("y", this.centre.y); + tag.putInt("z", this.centre.z); + tag.putInt("coreAndFlag", this.coreAndSpawnedFlag); + tag.putInt("sizeAndFlag", this.sizeAndLandedFlag); + + return tag; + } + + public static AsteroidData readFromNBT(CompoundTag tag) + { + BlockVec3 tempVector = new BlockVec3(); + tempVector.x = tag.getInt("x"); + tempVector.y = tag.getInt("y"); + tempVector.z = tag.getInt("z"); + + AsteroidData roid = new AsteroidData(tempVector); + if (tag.hasUUID("coreAndFlag")) + { + roid.coreAndSpawnedFlag = tag.getInt("coreAndFlag"); + } + if (tag.hasUUID("sizeAndFlag")) + { + roid.sizeAndLandedFlag = tag.getInt("sizeAndFlag"); + } + + return roid; + } + } + + private int getIndex(int x, int y, int z) + { + return x * AsteroidChunkGenerator.CHUNK_SIZE_Y * 16 | z * AsteroidChunkGenerator.CHUNK_SIZE_Y | y; + } + + public void loadAsteroidSavedData() { + Path dataPath = Path.of(currentWorldSaveDirectory.toString(), saveDataID); + Path dataFile = dataPath.resolve("data.dat"); + + this.datafile = this.loadData(dataFile); + + if (this.datafile == null) + { + if (!Files.exists(dataFile)) + { + try { + Files.createDirectories(dataPath); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + Files.createFile(dataFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + this.datafile = new AsteroidSaveData(""); + this.writeToNBT(this.datafile.datacompound); + this.setData(dataFile, this.datafile); + } + else + { + this.readFromNBT(this.datafile.datacompound); + } + + this.dataNotLoaded = false; + + } + + public void setData(Path filePath, AsteroidSaveData data) { + try { + NbtIo.write(data.datacompound, filePath); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public AsteroidSaveData loadData(Path filePath) { + if (Files.exists(filePath)) + { + CompoundTag tag; + try { + tag = NbtIo.read(filePath); + } catch (IOException e) { + throw new RuntimeException(e); + } + AsteroidSaveData saveData = new AsteroidSaveData(""); + saveData.datacompound = tag; + return saveData; + } + else + { + return null; + } + } + + + private void readFromNBT(CompoundTag nbt) + { + ListTag coordList = nbt.getList("coords", 10); + if (coordList.size() > 0) + { + for (int j = 0; j < coordList.size(); j++) + { + CompoundTag tag1 = coordList.getCompound(j); + + if (tag1 != null) + { + this.asteroids.add(AsteroidData.readFromNBT(tag1)); + } + } + } + } + + public BlockVec3 isLargeAsteroidAt(int x0, int z0) + { + int xToCheck; + int zToCheck; + for (int i0 = 0; i0 <= 32; i0++) + { + for (int i1 = -i0; i1 <= i0; i1++) + { + xToCheck = (x0 >> 4) + i0; + zToCheck = (z0 >> 4) + i1; + + if (isLargeAsteroidAt0(xToCheck * 16, zToCheck * 16)) + { + return new BlockVec3(xToCheck * 16, 0, zToCheck * 16); + } + + xToCheck = (x0 >> 4) + i0; + zToCheck = (z0 >> 4) - i1; + + if (isLargeAsteroidAt0(xToCheck * 16, zToCheck * 16)) + { + return new BlockVec3(xToCheck * 16, 0, zToCheck * 16); + } + + xToCheck = (x0 >> 4) - i0; + zToCheck = (z0 >> 4) + i1; + + if (isLargeAsteroidAt0(xToCheck * 16, zToCheck * 16)) + { + return new BlockVec3(xToCheck * 16, 0, zToCheck * 16); + } + + xToCheck = (x0 >> 4) - i0; + zToCheck = (z0 >> 4) - i1; + + if (isLargeAsteroidAt0(xToCheck * 16, zToCheck * 16)) + { + return new BlockVec3(xToCheck * 16, 0, zToCheck * 16); + } + } + } + + return null; + } + + private boolean isLargeAsteroidAt0(int x0, int z0) + { + for (int x = x0; x < x0 + AsteroidChunkGenerator.CHUNK_SIZE_X; x += 2) + { + for (int z = z0; z < z0 + AsteroidChunkGenerator.CHUNK_SIZE_Z; z += 2) + { + if ((Math.abs(this.randFromPoint(x, z)) < (this.asteroidDensity.getNoise(x, z) + .4) / AsteroidChunkGenerator.ASTEROID_CHANCE)) + { + return true; + } + } + } + + return false; + } + +} diff --git a/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidSaveData.java b/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidSaveData.java new file mode 100644 index 000000000..7c03b9390 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/gen/custom/AsteroidSaveData.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.gen.custom; + +import dev.galacticraft.mod.Constant; +import dev.galacticraft.mod.data.GCDataGenerator; +import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.CachedOutput; +import net.minecraft.data.DataProvider; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.datafix.DataFixTypes; +import net.minecraft.world.level.saveddata.SavedData; +import net.minecraft.world.level.storage.DimensionDataStorage; +import net.minecraft.world.level.storage.LevelStorageSource; + +import java.io.*; +import java.nio.file.Path; +import java.util.concurrent.CompletableFuture; + +public class AsteroidSaveData extends SavedData{ + + public static final String saveDataID = "dimensions/galacticraft/asteroid/data"; + + public CompoundTag datacompound; + + public AsteroidSaveData(String s) + { + super(); + this.datacompound = new CompoundTag(); + } + + public void readFromNBT(CompoundTag nbt) + { + this.datacompound = nbt.getCompound("asteroids"); + } + + public static AsteroidSaveData load(CompoundTag compound) { + String value = compound.getString("someValue"); + return new AsteroidSaveData(value); + } + + @Override + public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { + nbt.put("asteroids", this.datacompound); + return nbt; + } +} diff --git a/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlock.java b/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlock.java new file mode 100644 index 000000000..dcc5ab266 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlock.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.gen.custom; + +import net.minecraft.world.level.block.Block; + +import java.util.ArrayList; +public class SpecialAsteroidBlock +{ + public Block block; + public int probability; + public double thickness; //Arbitrary scale from 0 to 1; + public int index; + public static ArrayList register = new ArrayList<>(); + + public SpecialAsteroidBlock(Block block, int probability, double thickness) + { + this.block = block; + this.probability = probability; + this.thickness = thickness; + this.index = register.size(); + register.add(this); + } +} diff --git a/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlockHandler.java b/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlockHandler.java new file mode 100644 index 000000000..dcfeeec11 --- /dev/null +++ b/src/main/java/dev/galacticraft/mod/world/gen/custom/SpecialAsteroidBlockHandler.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019-2024 Team Galacticraft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package dev.galacticraft.mod.world.gen.custom; + +import java.util.ArrayList; +import java.util.Random; +public class SpecialAsteroidBlockHandler +{ + ArrayList asteroidBlocks; + + public SpecialAsteroidBlockHandler(SpecialAsteroidBlock... asteroidBlocks) + { + this.asteroidBlocks = new ArrayList(); + for (SpecialAsteroidBlock asteroidBlock : this.asteroidBlocks) + { + for (int i = 0; i < asteroidBlock.probability; i++) + { + this.asteroidBlocks.add(asteroidBlock); + } + } + } + + public SpecialAsteroidBlockHandler() + { + this.asteroidBlocks = new ArrayList(); + } + + public void addBlock(SpecialAsteroidBlock asteroidBlock) + { + for (int i = 0; i < asteroidBlock.probability; i++) + { + this.asteroidBlocks.add(asteroidBlock); + } + } + + public SpecialAsteroidBlock getBlock(Random rand, int size) + { + int s = this.asteroidBlocks.size(); + if (s < 10) + { + return this.asteroidBlocks.get(rand.nextInt(s)); + } + + Double r = rand.nextDouble(); + int index = (int) (s * Math.pow(r, (size + 5) * 0.05D)); + return this.asteroidBlocks.get(index); + } +} diff --git a/src/main/resources/assets/galacticraft/blockstates/air_lock_seal.json b/src/main/resources/assets/galacticraft/blockstates/air_lock_seal.json new file mode 100644 index 000000000..9b6690ba3 --- /dev/null +++ b/src/main/resources/assets/galacticraft/blockstates/air_lock_seal.json @@ -0,0 +1,10 @@ +{ + "variants": { + "facing=north": { "model": "galacticraft:block/air_lock_seal", "y": 90, "uvlock": true }, + "facing=east": { "model": "galacticraft:block/air_lock_seal", "uvlock": true }, + "facing=south": { "model": "galacticraft:block/air_lock_seal", "y": 90, "uvlock": true }, + "facing=west": { "model": "galacticraft:block/air_lock_seal", "uvlock": true }, + "facing=up": { "model": "galacticraft:block/air_lock_seal", "x": 90, "uvlock": true }, + "facing=down": { "model": "galacticraft:block/air_lock_seal", "x": 90, "uvlock": true } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/block/air_lock_seal.json b/src/main/resources/assets/galacticraft/models/block/air_lock_seal.json new file mode 100644 index 000000000..4b7491646 --- /dev/null +++ b/src/main/resources/assets/galacticraft/models/block/air_lock_seal.json @@ -0,0 +1,22 @@ +{ + "parent": "block/block", + "textures": { + "particle": "galacticraft:block/tin_decoration", + "top": "galacticraft:block/tin_decoration", + "side": "galacticraft:block/tin_decoration", + "bottom": "galacticraft:block/tin_decoration" + }, + "elements": [ + { "from": [ 4, 0, 0 ], + "to": [ 12, 16, 16 ], + "faces": { + "down": {"texture": "#top"}, + "up": {"texture": "#bottom"}, + "north": {"texture": "#side"}, + "east": {"texture": "#side"}, + "south": {"texture": "#side"}, + "west": {"texture": "#side"} + } + } + ] +} diff --git a/src/main/generated/assets/galacticraft/models/item/air_lock_seal.json b/src/main/resources/assets/galacticraft/models/item/air_lock_seal.json similarity index 100% rename from src/main/generated/assets/galacticraft/models/item/air_lock_seal.json rename to src/main/resources/assets/galacticraft/models/item/air_lock_seal.json diff --git a/src/main/resources/assets/galacticraft/models/item/canned_food.json b/src/main/resources/assets/galacticraft/models/item/canned_food.json new file mode 100644 index 000000000..a2fc16bd0 --- /dev/null +++ b/src/main/resources/assets/galacticraft/models/item/canned_food.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "galacticraft:item/canned_food_template", + "layer1": "galacticraft:item/canned_food_label" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/models/item/empty_can.json b/src/main/resources/assets/galacticraft/models/item/empty_can.json new file mode 100644 index 000000000..a2fc16bd0 --- /dev/null +++ b/src/main/resources/assets/galacticraft/models/item/empty_can.json @@ -0,0 +1,7 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "galacticraft:item/canned_food_template", + "layer1": "galacticraft:item/canned_food_label" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/galacticraft/textures/block/lunaslate_top.png b/src/main/resources/assets/galacticraft/textures/block/lunaslate_top.png new file mode 100644 index 000000000..46f07be0f Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/block/lunaslate_top.png differ diff --git a/src/main/resources/assets/galacticraft/textures/block/vapor_spout.png b/src/main/resources/assets/galacticraft/textures/block/vapor_spout.png new file mode 100644 index 000000000..a136f44fd Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/block/vapor_spout.png differ diff --git a/src/main/resources/assets/galacticraft/textures/gui/food_canner_screen.png b/src/main/resources/assets/galacticraft/textures/gui/food_canner_screen.png new file mode 100644 index 000000000..6658031c6 Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/gui/food_canner_screen.png differ diff --git a/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png new file mode 100644 index 000000000..427b020e2 Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png differ diff --git a/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png.mcmeta b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png.mcmeta new file mode 100644 index 000000000..2d596bf66 --- /dev/null +++ b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/background.png.mcmeta @@ -0,0 +1,10 @@ +{ + "gui": { + "scaling": { + "type": "nine_slice", + "width": 32, + "height": 32, + "border": 4 + } + } +} diff --git a/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/blocked_slot.png b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/blocked_slot.png new file mode 100644 index 000000000..31f79622c Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/blocked_slot.png differ diff --git a/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/slot.png b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/slot.png new file mode 100644 index 000000000..ac45847e4 Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/gui/sprites/canned_food/slot.png differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_beef.png b/src/main/resources/assets/galacticraft/textures/item/canned_beef.png deleted file mode 100644 index 0152403b1..000000000 Binary files a/src/main/resources/assets/galacticraft/textures/item/canned_beef.png and /dev/null differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_apple.png b/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_apple.png deleted file mode 100644 index c9df0297b..000000000 Binary files a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_apple.png and /dev/null differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_carrot.png b/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_carrot.png deleted file mode 100644 index 12299d94d..000000000 Binary files a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_carrot.png and /dev/null differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_melon.png b/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_melon.png deleted file mode 100644 index 4ad74b814..000000000 Binary files a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_melon.png and /dev/null differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_potato.png b/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_potato.png deleted file mode 100644 index 503db6df6..000000000 Binary files a/src/main/resources/assets/galacticraft/textures/item/canned_dehydrated_potato.png and /dev/null differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_food_label.png b/src/main/resources/assets/galacticraft/textures/item/canned_food_label.png new file mode 100644 index 000000000..ffe7eab93 Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/item/canned_food_label.png differ diff --git a/src/main/resources/assets/galacticraft/textures/item/canned_food_template.png b/src/main/resources/assets/galacticraft/textures/item/canned_food_template.png new file mode 100644 index 000000000..f7a7745a5 Binary files /dev/null and b/src/main/resources/assets/galacticraft/textures/item/canned_food_template.png differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index eb081bbaa..55d3d4335 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -139,6 +139,9 @@ ], "jei_mod_plugin": [ "dev.galacticraft.mod.compat.jei.GCJEIPlugin" + ], + "appleskin": [ + "dev.galacticraft.mod.compat.AppleSkinEventHandler" ] }, "mixins": [ diff --git a/src/main/resources/galacticraft.mixins.json b/src/main/resources/galacticraft.mixins.json index 8dfb516ba..fc983b321 100644 --- a/src/main/resources/galacticraft.mixins.json +++ b/src/main/resources/galacticraft.mixins.json @@ -27,6 +27,8 @@ "client.ClientPacketListenerMixin" ], "client": [ + "client.ClientTooltipMixin", + "client.FabricItemMixin", "client.AbstractClientPlayerMixin", "client.AlphaWarningTitleScreenMixin", "client.AnimalModelAgeableListModel",