From 7a5a62729dbe0942d5365a6e2e88101096cf1592 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Fri, 7 Oct 2022 00:40:52 -0400 Subject: [PATCH 1/4] Ported to 1.19.2 (#60) * Start marking the mod as 1.19.1 compatible Dependencies are needed * Update gradle * Temporarily turn off Modrinth imports due to workspace issues * Port completed. * Update gradle.properties * Update gradle.properties * Update fabric.mod.json * Update gradle.properties * Update gradle.properties * Update gradle.properties * Update build.gradle * Try including our own implementation of Architectury * Revert "Try including our own implementation of Architectury" This reverts commit dd56795c8027e6361f198481df9f83dbaa7463d5. * FINALLY * Port to quilt * quilt 1.19.2 port Co-authored-by: DanikingRD Co-authored-by: Platymemo <67663207+Platymemo@users.noreply.github.com> --- README.md | 39 ++--- build.gradle | 42 +++--- gradle.properties | 15 +- gradle/libs.versions.toml | 22 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew.bat | 16 +- markdown/versions/1.4.7.md | 4 + settings.gradle | 4 + .../alaskanativecraft/AlaskaNativeCraft.java | 5 +- .../AlaskaNativeCraftClient.java | 21 +-- .../alaskanativecraft/block/AlaskaBlocks.java | 46 ++---- .../block/DryingRackBlock.java | 4 +- .../block/LabradorTeaBlock.java | 6 +- .../block/entity/DryingRackBlockEntity.java | 2 +- .../model/entity/DogsledEntityModel.java | 2 +- .../model/entity/PtarmiganEntityModel.java | 2 +- .../entity/DogsledEntityRenderer.java | 2 +- .../entity/HarpoonEntityRenderer.java | 2 +- .../feature/KuspukSkirtFeatureRenderer.java | 2 +- .../ShoulderPtarmiganFeatureRenderer.java | 2 +- .../feature/SnowshoeFeatureRenderer.java | 2 +- .../renderer/item/HarpoonItemRenderer.java | 2 +- .../renderer/item/SnowshoeItemRenderer.java | 2 +- .../entity/AlaskaEntities.java | 25 ++-- .../entity/DogsledEntity.java | 11 +- .../entity/HarpoonEntity.java | 3 +- .../entity/PtarmiganEntity.java | 11 +- .../alaskanativecraft/entity/SealEntity.java | 105 +++++-------- .../entity/ai/goal/GroundFoodMateGoal.java | 4 +- .../entity/effect/AlaskaEffects.java | 4 +- .../entity/effect/MedicinalStatusEffect.java | 6 +- .../alaskanativecraft/item/AlaskaItems.java | 139 +++++++++--------- .../alaskanativecraft/item/HarpoonItem.java | 4 +- .../material/AlaskaNativeArmorMaterials.java | 4 +- .../alaskanativecraft/mixin/FoxMixin.java | 4 +- .../mixin/IglooGeneratorMixin.java | 15 +- .../mixin/LivingEntityMixin.java | 4 +- .../mixin/PolarBearMixin.java | 4 +- .../mixin/SnowballEntityMixin.java | 8 +- .../mixin/client/ItemRendererMixin.java | 2 +- .../recipe/FishStripRecipe.java | 4 +- .../worldgen/feature/AlaskaFeatures.java | 42 +++--- .../worldgen/structure/AlaskaStructures.java | 2 +- .../worldgen/structure/FishCampStructure.java | 38 ++--- .../alaskanativecraft/tags/blocks/bushes.json | 9 ++ .../minecraft/block/flammable_block.json | 25 ++++ .../minecraft/item/compost_chance.json | 10 ++ .../attachments/minecraft/item/fuel_time.json | 8 + src/main/resources/fabric.mod.json | 47 ------ src/main/resources/quilt.mod.json | 42 ++++++ 50 files changed, 414 insertions(+), 412 deletions(-) create mode 100644 gradle/libs.versions.toml create mode 100644 markdown/versions/1.4.7.md create mode 100644 src/main/resources/data/alaskanativecraft/tags/blocks/bushes.json create mode 100644 src/main/resources/data/quilt_block_content_registry/attachments/minecraft/block/flammable_block.json create mode 100644 src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/compost_chance.json create mode 100644 src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/fuel_time.json delete mode 100644 src/main/resources/fabric.mod.json create mode 100644 src/main/resources/quilt.mod.json diff --git a/README.md b/README.md index 0b7943b2..430984dd 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # Alaska Native Craft -## Setup - -For setup instructions please see the [fabric wiki page](https://fabricmc.net/wiki/tutorial:setup) that relates to the -IDE that you are using. - ## License Creative Commons Zero v1.0 Universal @@ -15,42 +10,32 @@ As with the Unlicense and typical software licenses, CC0 disclaims warranties. ### Mobs -1. Harp Seal +1. Seal 2. Ptarmigan 3. Moose 4. Dogsleds ### Items -1. Respective meats for each Mob -2. Muktuk +1. Ulu +2. Berries 3. Harpoons - Combine with a lead in an anvil for long-range leashing (up to 48 blocks) 4. Dogsleds 5. Dyeable Kuspuks +6. Snow Goggles +7. Mukluks +8. Snowshoes +9. Driftwood, Antlers, and Ivory + - Replace sticks with these items in a crafting recipe to enhance the durability of the crafted item! ### Blocks 1. Whale Meat Block - -### Other - -1. Snowball Chickens or Parrots to make them Ptarmigans! - -## Upcoming Features - -### Content - -1. Whales - - Whale hunting - - On Death: Corpse floats to surface to be harvested - - Whale oil (fuel source) -2. Walruses - - Walrus tusk - - Walrus tools? -3. Make Whale Meat Blocks act like Mushroom Blocks -4. Change dogsled control scheme? +2. Bushes +3. Drying Rack + - Dry strips of fish into dry fish, or rotten flesh into leather! ## Thanks -A special thanks to Daimons for the Moose Texture and to everybody in The Fabric Project Discord Server +A special thanks to Daimons for the Moose Texture diff --git a/build.gradle b/build.gradle index 754bbab5..b96bbde2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,10 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' id "com.matthewprenger.cursegradle" version "1.4.0" id "com.modrinth.minotaur" version "1.2.1" id 'maven-publish' + alias libs.plugins.quilt.loom } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 - archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group @@ -26,24 +23,25 @@ repositories { dependencies { // To change the versions see the gradle.properties file - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - - // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + minecraft libs.minecraft + mappings loom.layered { + addLayer quiltMappings.mappings("org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:v2") + // officialMojangMappings() // Uncomment if you want to use Mojang mappings as your primary mappings, falling back on QM for parameters and Javadocs + } + modImplementation libs.quilt.loader + modImplementation libs.quilted.fabric.api // Mod Menu integration modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" // REI integration - modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + modCompileOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" // ClothConfig modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") { exclude(group: "net.fabricmc.fabric-api") } - + // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. } @@ -53,14 +51,16 @@ loom { } processResources { - inputs.property "version", project.version + inputs.property "version", project.mod_version - filesMatching("fabric.mod.json") { - expand "version": project.version + filesMatching('quilt.mod.json') { + expand "version": project.mod_version } } tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. it.options.release = 17 } @@ -106,10 +106,10 @@ task publishModrinth (type: TaskModrinthUpload) { versionNumber = "${project.mod_version}" uploadFile = remapJar changelog = new File("markdown/versions/${project.mod_version}.md").getText('UTF-8') - addGameVersion('1.19') - addDependency('fabric-api', Dependency.DependencyType.REQUIRED) + addGameVersion('1.19.2') + addDependency('qsl', Dependency.DependencyType.REQUIRED) addDependency('cloth-config', Dependency.DependencyType.REQUIRED) - addLoader('fabric') + addLoader('quilt') } curseforge { @@ -121,12 +121,12 @@ curseforge { changelogType = 'markdown' changelog = file("markdown/versions/${project.mod_version}.md") releaseType = 'release' - addGameVersion "1.19" + addGameVersion "1.19.2" addGameVersion "Java 17" - addGameVersion "Fabric" + addGameVersion "Quilt" relations { requiredDependency 'cloth-config' - requiredDependency 'fabric-api' + requiredDependency 'qsl' optionalDependency 'modmenu' } diff --git a/gradle.properties b/gradle.properties index 41823cef..20007757 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,20 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G +org.gradle.parallel = true # Fabric Properties # check these on https://fabricmc.net/versions.html - minecraft_version=1.19 - yarn_mappings=1.19+build.4 + minecraft_version=1.19.2 + yarn_mappings=1.19.2+build.1 loader_version=0.14.8 # Mod Properties - mod_version=1.4.6 + mod_version=1.4.7 maven_group=com.github.platymemo archives_base_name=alaskanativecraft # Dependencies - fabric_version=0.56.3+1.19 - clothconfig_version=7.0.72 - modmenu_version=4.0.0 - rei_version=9.0.493 + fabric_version=0.58.6+1.19.2 + clothconfig_version=8.0.75 + modmenu_version=4.0.6 + rei_version=9.1.530 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..15357014 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +# The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html +minecraft = "1.19.2" +quilt_mappings = "1.19.2+build.3" +quilt_loader = "0.17.5-beta.2" + +quilted_fabric_api = "4.0.0-beta.13+0.62.0-1.19.2" + +[libraries] +minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } +quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" } +quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" } + +quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" } +quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" } + +# If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". +[bundles] +quilted_fabric_api = ["quilted_fabric_api", "quilted_fabric_api_deprecated"] + +[plugins] +quilt_loom = { id = "org.quiltmc.loom", version = "0.12.+" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fe753c9d..2d2fd7c7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew.bat b/gradlew.bat index 107acd32..89d1d913 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,15 +75,17 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega +:omega \ No newline at end of file diff --git a/markdown/versions/1.4.7.md b/markdown/versions/1.4.7.md new file mode 100644 index 00000000..81a79b24 --- /dev/null +++ b/markdown/versions/1.4.7.md @@ -0,0 +1,4 @@ +### v1.4.7: Quiltified! + +1. Ported to 1.19.2 +2. Ported to Quilt diff --git a/settings.gradle b/settings.gradle index d6e33e28..c7a8245c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,9 @@ pluginManagement { repositories { + maven { + name = 'Quilt' + url = 'https://maven.quiltmc.org/repository/release' + } maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java index a57e295e..797f0543 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java @@ -8,13 +8,14 @@ import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import com.github.platymemo.alaskanativecraft.worldgen.feature.AlaskaFeatures; -import net.fabricmc.api.ModInitializer; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; public class AlaskaNativeCraft implements ModInitializer { public static final String MOD_ID = "alaskanativecraft"; @Override - public void onInitialize() { + public void onInitialize(ModContainer container) { AlaskaBlocks.register(); AlaskaItems.register(); AlaskaLootFunctionTypes.register(); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java index 473ab6c5..8b91f737 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java @@ -10,11 +10,8 @@ import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities; import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; @@ -29,6 +26,10 @@ import net.minecraft.entity.EntityType; import net.minecraft.item.DyeableItem; import net.minecraft.util.registry.Registry; +import org.quiltmc.loader.api.ModContainer; +import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer; +import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap; +import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; import java.util.UUID; @@ -78,7 +79,7 @@ public static void registerHarpoonPacket() { client.execute(() -> { if (entity != null) { entity.updateTrackedPositionAndAngles(x, y, z, yaw, pitch, 0, false); - entity.updateTrackedPosition(x, y, z); // The above does not do the same thing, for some weird reason + entity.syncPacketPositionCodec(x, y, z); entity.setId(entityID); entity.setUuid(entityUUID); assert world != null; @@ -96,11 +97,11 @@ public static void registerBlockEntityRenderers() { @Environment(EnvType.CLIENT) public static void registerBlockRenderLayers() { RenderLayer cutout = RenderLayer.getCutout(); - BlockRenderLayerMap.INSTANCE.putBlock(AlaskaBlocks.BLUEBERRY_BUSH, cutout); - BlockRenderLayerMap.INSTANCE.putBlock(AlaskaBlocks.CLOUDBERRY_BUSH, cutout); - BlockRenderLayerMap.INSTANCE.putBlock(AlaskaBlocks.RASPBERRY_BUSH, cutout); - BlockRenderLayerMap.INSTANCE.putBlock(AlaskaBlocks.SALMONBERRY_BUSH, cutout); - BlockRenderLayerMap.INSTANCE.putBlock(AlaskaBlocks.LABRADOR_TEA, cutout); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.BLUEBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.CLOUDBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.RASPBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.SALMONBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.LABRADOR_TEA); } @Environment(EnvType.CLIENT) @@ -109,7 +110,7 @@ public static void registerItemColors() { } @Override - public void onInitializeClient() { + public void onInitializeClient(ModContainer mod) { registerBlockEntityRenderers(); registerBlockRenderLayers(); registerItemColors(); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java index 4ab37fa8..efe058e6 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java @@ -2,10 +2,6 @@ import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity; -import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; -import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; -import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; -import net.fabricmc.fabric.api.registry.FuelRegistry; import net.minecraft.block.*; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.effect.StatusEffects; @@ -15,6 +11,8 @@ import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; +import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder; +import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings; public class AlaskaBlocks { public static final WhaleMeatBlock WHALE_MEAT_BLOCK; @@ -28,15 +26,15 @@ public class AlaskaBlocks { public static final BlockEntityType DRYING_RACK_BLOCK_ENTITY; static { - WHALE_MEAT_BLOCK = register("whale_meat_block", new WhaleMeatBlock(FabricBlockSettings.of(Material.ORGANIC_PRODUCT).requiresTool().sounds(BlockSoundGroup.HONEY).strength(1.0F, 1.0F)), ItemGroup.BREWING); - BLUEBERRY_BUSH = register("blueberry_bush", new BlueberryBushBlock(FabricBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - CLOUDBERRY_BUSH = register("cloudberry_bush", new CloudberryBushBlock(FabricBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - RASPBERRY_BUSH = register("raspberry_bush", new RaspberryBushBlock(FabricBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - SALMONBERRY_BUSH = register("salmonberry_bush", new SalmonberryBushBlock(FabricBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + WHALE_MEAT_BLOCK = register("whale_meat_block", new WhaleMeatBlock(QuiltBlockSettings.of(Material.ORGANIC_PRODUCT).requiresTool().sounds(BlockSoundGroup.HONEY).strength(1.0F, 1.0F)), ItemGroup.BREWING); + BLUEBERRY_BUSH = register("blueberry_bush", new BlueberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + CLOUDBERRY_BUSH = register("cloudberry_bush", new CloudberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + RASPBERRY_BUSH = register("raspberry_bush", new RaspberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + SALMONBERRY_BUSH = register("salmonberry_bush", new SalmonberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); LABRADOR_TEA = register("labrador_tea", new LabradorTeaBlock(StatusEffects.REGENERATION, 12, AbstractBlock.Settings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS))); - DRIFTWOOD_LOG = register("driftwood_log", new PillarBlock(FabricBlockSettings.copyOf(Blocks.OAK_LOG)), ItemGroup.BUILDING_BLOCKS); - DRYING_RACK = register("drying_rack", new DryingRackBlock(FabricBlockSettings.copyOf(Blocks.OAK_FENCE)), ItemGroup.DECORATIONS); - DRYING_RACK_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying_rack"), FabricBlockEntityTypeBuilder.create(DryingRackBlockEntity::new, DRYING_RACK).build(null)); + DRIFTWOOD_LOG = register("driftwood_log", new PillarBlock(QuiltBlockSettings.copyOf(Blocks.OAK_LOG)), ItemGroup.BUILDING_BLOCKS); + DRYING_RACK = register("drying_rack", new DryingRackBlock(QuiltBlockSettings.copyOf(Blocks.OAK_FENCE)), ItemGroup.DECORATIONS); + DRYING_RACK_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying_rack"), QuiltBlockEntityTypeBuilder.create(DryingRackBlockEntity::new, DRYING_RACK).build(null)); } /** @@ -70,27 +68,5 @@ private static B register(String name, B block) { return block; } - public static void register() { - addFuels(); - addFlammables(); - } - - private static void addFuels() { - FuelRegistry fuelRegistry = FuelRegistry.INSTANCE; - fuelRegistry.add(WHALE_MEAT_BLOCK, 800); - fuelRegistry.add(DRYING_RACK, 300); - } - - private static void addFlammables() { - FlammableBlockRegistry flammableRegistry = FlammableBlockRegistry.getDefaultInstance(); - flammableRegistry.add(WHALE_MEAT_BLOCK, 60, 100); - flammableRegistry.add(DRIFTWOOD_LOG, 5, 5); - flammableRegistry.add(DRYING_RACK, 5, 5); - flammableRegistry.add(BLUEBERRY_BUSH, 60, 100); - flammableRegistry.add(CLOUDBERRY_BUSH, 60, 100); - flammableRegistry.add(RASPBERRY_BUSH, 60, 100); - flammableRegistry.add(SALMONBERRY_BUSH, 60, 100); - flammableRegistry.add(LABRADOR_TEA, 60, 100); - } - + public static void register() {} } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java index af1f7037..536e0f37 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java @@ -144,7 +144,7 @@ private boolean canConnect(Direction direction, @NotNull BlockState otherState) @Override public BlockState getStateForNeighborUpdate(@NotNull BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { if (state.get(WATERLOGGED)) { - world.createAndScheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); } return state.get(AXIS) == direction.getAxis() ? @@ -166,7 +166,7 @@ public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, @NotNull BlockS } world.setBlockState(pos, state.with(WATERLOGGED, true), 3); - world.createAndScheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world)); + world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world)); return true; } else { return false; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java index d363ced2..93a35f71 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.BlockView; import net.minecraft.world.World; @@ -26,12 +26,12 @@ public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, b } @Override - public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) { + public boolean canGrow(World world, RandomGenerator random, BlockPos pos, BlockState state) { return true; } @Override - public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) { + public void grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state) { dropStack(world, pos, new ItemStack(this)); } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java index 61ecda53..6121117a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java @@ -71,7 +71,7 @@ public static void updateItemsBeingDried(World world, BlockPos pos, BlockState s @Nullable @Override public Packet toUpdatePacket() { - return BlockEntityUpdateS2CPacket.create(this); + return BlockEntityUpdateS2CPacket.of(this); } public DefaultedList getItemsBeingDried() { diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java index 9a50ebcb..4d3470a5 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java @@ -2,8 +2,8 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import com.google.common.collect.ImmutableList; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.model.*; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.CompositeEntityModel; import net.minecraft.client.util.math.MatrixStack; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java index 59a382a5..c8fcc3da 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java @@ -1,10 +1,10 @@ package com.github.platymemo.alaskanativecraft.client.model.entity; import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.model.*; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.SinglePartEntityModel; import net.minecraft.client.util.math.MatrixStack; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java index 30b88993..79bcf122 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java @@ -4,13 +4,13 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.DogsledEntityModel; import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java index 99ba8046..0ec49a63 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java @@ -4,8 +4,8 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.HarpoonEntityModel; import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java index 74d2cbbc..7dabec04 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java @@ -4,11 +4,11 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.feature.KuspukSkirtModel; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java index e5a9879a..3e5465c3 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java @@ -4,10 +4,10 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.PtarmiganEntityModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.PtarmiganEntityRenderer; import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.render.OverlayTexture; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java index 9d7b02da..d0c49e99 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java @@ -4,11 +4,11 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.feature.SnowshoeModel; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.FeatureRenderer; import net.minecraft.client.render.entity.feature.FeatureRendererContext; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java index 97067062..a825d502 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java @@ -3,9 +3,9 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.HarpoonEntityModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.HarpoonEntityRenderer; import com.github.platymemo.alaskanativecraft.item.HarpoonItem; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java index d011121f..362026b1 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java @@ -2,9 +2,9 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.feature.SnowshoeModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.SnowshoeFeatureRenderer; +import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java index 423a970c..666cfe74 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java @@ -5,16 +5,19 @@ import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.github.platymemo.alaskanativecraft.item.HarpoonItem; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; -import net.fabricmc.fabric.mixin.object.builder.SpawnRestrictionAccessor; -import net.minecraft.entity.*; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.SpawnGroup; +import net.minecraft.entity.SpawnRestriction; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; +import org.quiltmc.qsl.worldgen.biome.api.BiomeModifications; +import org.quiltmc.qsl.worldgen.biome.api.BiomeSelectors; import java.util.LinkedHashMap; import java.util.Map; @@ -45,11 +48,13 @@ public static void register() { } private static void initSpawnRestrictions() { - SpawnRestrictionAccessor.callRegister(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn); - SpawnRestrictionAccessor.callRegister(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn); - SpawnRestrictionAccessor.callRegister(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn); + SpawnRestriction.register(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn); + SpawnRestriction.register(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn); + SpawnRestriction.register(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn); } + // IntelliJ wrongly infers that the register call fails due to calling an accessor that throws an AssertionError + @SuppressWarnings("ConstantConditions") private static void initAttributes() { FabricDefaultAttributeRegistry.register(HARP_SEAL, SealEntity.createSealAttributes()); FabricDefaultAttributeRegistry.register(PTARMIGAN, PtarmiganEntity.createPtarmiganAttributes()); @@ -58,17 +63,17 @@ private static void initAttributes() { private static void initSpawns() { AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning; - BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_SEAL), + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_SEAL), SpawnGroup.WATER_CREATURE, HARP_SEAL, spawnOptions.sealOceanSettings.weight, spawnOptions.sealOceanSettings.minGroupSize, spawnOptions.sealOceanSettings.maxGroupSize); - BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_MOOSE), + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_MOOSE), SpawnGroup.CREATURE, MOOSE, spawnOptions.mooseSettings.weight, spawnOptions.mooseSettings.minGroupSize, spawnOptions.mooseSettings.maxGroupSize); - BiomeModifications.addSpawn(BiomeSelectors.tag(AlaskaTags.HAS_PTARMIGAN), + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_PTARMIGAN), SpawnGroup.AMBIENT, PTARMIGAN, spawnOptions.ptarmiganSettings.weight, spawnOptions.ptarmiganSettings.minGroupSize, diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java index 9491fa13..a001786b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java @@ -101,17 +101,12 @@ public DogsledEntity(EntityType entityType, World world) { public DogsledEntity(World world, double x, double y, double z) { this(AlaskaEntities.DOGSLED, world); this.setPosition(x, y, z); - this.updateTrackedPosition(x, y, z); this.setVelocity(Vec3d.ZERO); this.prevX = x; this.prevY = y; this.prevZ = z; } - public static boolean method_30959(Entity entity, @NotNull Entity entity2) { - return (entity2.isCollidable() || entity2.isPushable()) && !entity.isConnectedThroughVehicle(entity2); - } - @Override protected float getEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) { return dimensions.height; @@ -127,7 +122,7 @@ protected void initDataTracker() { @Override public boolean collidesWith(Entity other) { - return method_30959(this, other); + return BoatEntity.canCollide(this, other); } @Override @@ -260,7 +255,7 @@ public void tick() { private void clientInterpolation() { if (this.isLogicalSideForUpdatingMovement()) { this.clientInterpolationSteps = 0; - this.updateTrackedPosition(this.getX(), this.getY(), this.getZ()); + this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ()); } if (this.clientInterpolationSteps > 0) { @@ -353,7 +348,7 @@ private Location getUnderWaterLocation() { this.waterLevel = Math.max(f, this.waterLevel); bl |= box.minY < (double) f; if (d < (double) ((float) mutable.getY() + fluidState.getHeight(this.world, mutable))) { - if (!fluidState.isStill()) { + if (!fluidState.isSource()) { return Location.UNDER_FLOWING_WATER; } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java index 63cd044d..ede9434b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java @@ -5,7 +5,6 @@ import io.netty.buffer.Unpooled; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -38,6 +37,7 @@ import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.quiltmc.qsl.networking.api.ServerPlayNetworking; public class HarpoonEntity extends PersistentProjectileEntity { public static final Identifier SPAWN_PACKET = new Identifier(AlaskaNativeCraft.MOD_ID, "harpoon_entity"); @@ -343,7 +343,6 @@ protected float getDragInWater() { } @Override - @Environment(EnvType.CLIENT) public boolean shouldRender(double cameraX, double cameraY, double cameraZ) { return true; } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java index e511067f..0fc068ff 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java @@ -19,11 +19,10 @@ import net.minecraft.sound.SoundEvents; import net.minecraft.tag.BlockTags; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; -import net.minecraft.world.WorldAccess; import org.jetbrains.annotations.NotNull; public class PtarmiganEntity extends ParrotEntity { @@ -37,9 +36,9 @@ public PtarmiganEntity(EntityType entityType, World worl super(entityType, world); } - public static boolean isValidSpawn(EntityType type, @NotNull WorldAccess world, SpawnReason spawnReason, @NotNull BlockPos pos, Random random) { - BlockState blockState = world.getBlockState(pos.down()); - return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && world.getBaseLightLevel(pos, 0) > 8; + public static boolean isValidSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { + BlockState blockState = serverWorldAccess.getBlockState(blockPos.down()); + return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; } public static DefaultAttributeContainer.Builder createPtarmiganAttributes() { @@ -51,7 +50,7 @@ public static DefaultAttributeContainer.Builder createPtarmiganAttributes() { @Override public EntityData initialize(@NotNull ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) { - if (world.getBiome(getBlockPos()).isIn(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).isIn(ConventionalBiomeTags.CLIMATE_COLD)) { + if (world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.CLIMATE_COLD)) { this.setType(0); } else { this.setType(this.random.nextInt(2) + 1); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java index 14738824..f812381a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java @@ -6,15 +6,36 @@ import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; -import net.minecraft.entity.*; -import net.minecraft.entity.ai.TargetPredicate; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityData; +import net.minecraft.entity.EntityGroup; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.MovementType; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.ai.control.MoveControl; -import net.minecraft.entity.ai.goal.*; -import net.minecraft.entity.ai.pathing.*; +import net.minecraft.entity.ai.goal.AnimalMateGoal; +import net.minecraft.entity.ai.goal.EscapeDangerGoal; +import net.minecraft.entity.ai.goal.FleeEntityGoal; +import net.minecraft.entity.ai.goal.LookAtEntityGoal; +import net.minecraft.entity.ai.goal.MeleeAttackGoal; +import net.minecraft.entity.ai.goal.SwimAroundGoal; +import net.minecraft.entity.ai.goal.TargetGoal; +import net.minecraft.entity.ai.goal.TemptGoal; +import net.minecraft.entity.ai.goal.WanderAroundGoal; +import net.minecraft.entity.ai.pathing.AmphibiousPathNodeMaker; +import net.minecraft.entity.ai.pathing.EntityNavigation; +import net.minecraft.entity.ai.pathing.PathNodeNavigator; +import net.minecraft.entity.ai.pathing.PathNodeType; +import net.minecraft.entity.ai.pathing.SwimNavigation; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; -import net.minecraft.entity.passive.*; +import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.CodEntity; +import net.minecraft.entity.passive.PassiveEntity; +import net.minecraft.entity.passive.PolarBearEntity; +import net.minecraft.entity.passive.SalmonEntity; +import net.minecraft.entity.passive.SquidEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; @@ -26,7 +47,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; @@ -34,8 +55,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.EnumSet; - public class SealEntity extends AnimalEntity { public SealEntity(EntityType entityType, World world) { @@ -46,8 +65,8 @@ public SealEntity(EntityType entityType, World world) { } @SuppressWarnings({"deprecation", "unused"}) - public static boolean canSpawn(EntityType type, @NotNull ServerWorldAccess world, SpawnReason spawnReason, @NotNull BlockPos pos, Random random) { - return pos.getY() < world.getSeaLevel() + 2 && pos.getY() > world.getSeaLevel() - 10 && world.getBaseLightLevel(pos, 0) > 8; + public static boolean canSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { + return blockPos.getY() < serverWorldAccess.getSeaLevel() + 2 && blockPos.getY() > serverWorldAccess.getSeaLevel() - 10 && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; } public static DefaultAttributeContainer.Builder createSealAttributes() { @@ -73,16 +92,16 @@ protected void initGoals() { this.goalSelector.add(0, new FleeEntityGoal<>(this, PolarBearEntity.class, 8.0F, 1.0D, 1.5D)); this.goalSelector.add(0, new SealEntity.SealEscapeDangerGoal(this, 1.5D)); this.goalSelector.add(1, new AnimalMateGoal(this, 1.0D)); - this.goalSelector.add(2, new SealEntity.ApproachFoodHoldingPlayerGoal(this, 1.1D, Ingredient.fromTag(AlaskaTags.SEAL_FOOD))); + this.goalSelector.add(2, new TemptGoal(this, 1.1D, Ingredient.ofTag(AlaskaTags.SEAL_FOOD), true)); this.goalSelector.add(3, new FleeEntityGoal<>(this, PlayerEntity.class, 16.0F, 1.0D, 1.5D)); this.goalSelector.add(3, new SwimAroundGoal(this, this.isBaby() ? 2.0D : 1.0D, 40)); this.goalSelector.add(5, new SealEntity.WanderOnLandGoal(this, 1.0D, 100)); this.goalSelector.add(5, new GroundFoodMateGoal(this)); this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); this.goalSelector.add(7, new SealEntity.HuntFishGoal(this, 1.2D, true)); - this.targetSelector.add(0, new ActiveTargetGoal<>(this, SalmonEntity.class, true)); - this.targetSelector.add(0, new ActiveTargetGoal<>(this, CodEntity.class, true)); - this.targetSelector.add(1, new ActiveTargetGoal<>(this, SquidEntity.class, true)); + this.targetSelector.add(0, new TargetGoal<>(this, SalmonEntity.class, true)); + this.targetSelector.add(0, new TargetGoal<>(this, CodEntity.class, true)); + this.targetSelector.add(1, new TargetGoal<>(this, SquidEntity.class, true)); } @Override @@ -280,64 +299,6 @@ public boolean canStart() { } } - static class ApproachFoodHoldingPlayerGoal extends Goal { - private static final TargetPredicate CLOSE_ENTITY_PREDICATE = TargetPredicate.DEFAULT.setBaseMaxDistance(10.0D); - private final SealEntity seal; - private final double speed; - private final Ingredient food; - private PlayerEntity targetPlayer; - private int cooldown; - - ApproachFoodHoldingPlayerGoal(SealEntity seal, double speed, Ingredient food) { - this.seal = seal; - this.speed = speed; - this.food = food; - this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK)); - } - - @Override - public boolean canStart() { - if (this.cooldown > 0) { - --this.cooldown; - return false; - } else { - this.targetPlayer = this.seal.world.getClosestPlayer(CLOSE_ENTITY_PREDICATE, this.seal); - if (this.targetPlayer == null) { - return false; - } else { - return this.isAttractive(this.targetPlayer.getMainHandStack()) || this.isAttractive(this.targetPlayer.getOffHandStack()); - } - } - } - - private boolean isAttractive(ItemStack stack) { - return this.food.test(stack); - } - - @Override - public boolean shouldContinue() { - return this.canStart(); - } - - @Override - public void stop() { - this.targetPlayer = null; - this.seal.getNavigation().stop(); - this.cooldown = 100; - } - - @Override - public void tick() { - this.seal.getLookControl().lookAt(this.targetPlayer, (float) (this.seal.getMaxHeadRotation() + 20), (float) this.seal.getMaxLookPitchChange()); - if (this.seal.squaredDistanceTo(this.targetPlayer) < 6.25D) { - this.seal.getNavigation().stop(); - } else { - this.seal.getNavigation().startMovingTo(this.targetPlayer, this.speed); - } - - } - } - static class HuntFishGoal extends MeleeAttackGoal { private final AnimalEntity animal; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java index 2a17ad76..47238742 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java @@ -30,7 +30,7 @@ public boolean canStart() { return false; } - if (this.animal.getEntityWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { + if (this.animal.getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { this.foodEntity = this.findFood(); } @@ -54,7 +54,7 @@ public void stop() { @Override public void tick() { if (this.foodEntity != null) { - this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, (float) this.animal.getMaxLookPitchChange()); + this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, this.animal.getLookPitchSpeed()); this.animal.getNavigation().startMovingTo(this.foodEntity, 1.0f); if (this.animal.squaredDistanceTo(this.foodEntity) < 4.0D) { this.feed(); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java index 28ca0069..1aaf89e3 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java @@ -1,7 +1,7 @@ package com.github.platymemo.alaskanativecraft.entity.effect; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectCategory; +import net.minecraft.entity.effect.StatusEffectType; import net.minecraft.util.registry.Registry; public class AlaskaEffects { @@ -9,6 +9,6 @@ public class AlaskaEffects { Registry.register( Registry.STATUS_EFFECT, "medicinal", - new MedicinalStatusEffect(StatusEffectCategory.BENEFICIAL, 0x929D2A) + new MedicinalStatusEffect(StatusEffectType.BENEFICIAL, 0x929D2A) ); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java index 93a13a0a..daa64cb4 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java @@ -2,11 +2,11 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffect; -import net.minecraft.entity.effect.StatusEffectCategory; +import net.minecraft.entity.effect.StatusEffectType; public class MedicinalStatusEffect extends StatusEffect { - protected MedicinalStatusEffect(StatusEffectCategory category, int color) { + protected MedicinalStatusEffect(StatusEffectType category, int color) { super(category, color); } @@ -22,7 +22,7 @@ public boolean canApplyUpdateEffect(int duration, int amplifier) { public void applyUpdateEffect(LivingEntity entity, int amplifier) { // remove first negative status effect found for (StatusEffect type : entity.getActiveStatusEffects().keySet()) { - if (type.getCategory() == StatusEffectCategory.HARMFUL) { + if (type.getType() == StatusEffectType.HARMFUL) { entity.removeStatusEffect(type); break; } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java index 1ba9b5aa..338c5f03 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java @@ -6,15 +6,22 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import com.github.platymemo.alaskanativecraft.item.material.AlaskaNativeArmorMaterials; import com.github.platymemo.alaskanativecraft.mixin.BrewingRecipeRegistryAccessor; -import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; -import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; -import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; -import net.fabricmc.fabric.api.registry.FuelRegistry; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; -import net.minecraft.item.*; +import net.minecraft.item.AliasedBlockItem; +import net.minecraft.item.ArmorItem; +import net.minecraft.item.BlockItem; +import net.minecraft.item.DyeableArmorItem; +import net.minecraft.item.FoodComponent; +import net.minecraft.item.Item; +import net.minecraft.item.ItemGroup; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.item.SpawnEggItem; +import net.minecraft.item.SuspiciousStewItem; +import net.minecraft.item.ToolMaterials; import net.minecraft.loot.LootPool; import net.minecraft.loot.LootTables; import net.minecraft.loot.entry.ItemEntry; @@ -24,6 +31,8 @@ import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.registry.Registry; +import org.quiltmc.qsl.item.group.api.QuiltItemGroup; +import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; import java.util.List; @@ -70,57 +79,57 @@ public class AlaskaItems { public static final SpawnEggItem MOOSE_SPAWN_EGG; static { - MUKTUK = register("muktuk", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build()))); - SEAL = register("seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); - COOKED_SEAL = register("cooked_seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build()))); - DRY_SEAL = register("dry_seal", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build()))); - PTARMIGAN = register("ptarmigan", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build()))); - COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build()))); - VENISON = register("venison", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); - COOKED_VENISON = register("cooked_venison", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build()))); - - DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new FabricItemSettings().group(ItemGroup.MISC))); - ANTLER = register("antler", new Item(new FabricItemSettings().group(ItemGroup.MISC))); - IVORY = register("ivory", new Item(new FabricItemSettings().group(ItemGroup.MISC))); - - FISH_STRIP = register("fish_strip", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build()))); - DRY_FISH = register("dry_fish", new Item(new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build()))); - - BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new FabricItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - - LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new FabricItemSettings().group(ItemGroup.BREWING))); - - AKUTAQ = register("akutaq", new SuspiciousStewItem(new FabricItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build()))); - - ULU = register("ulu", new UluItem(new FabricItemSettings().group(ItemGroup.TOOLS).maxDamage(472))); - - WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT))); - STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT))); - IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT))); - GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT))); - DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT))); - NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new FabricItemSettings().group(ItemGroup.COMBAT).fireproof())); - - KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT))); - KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new FabricItemSettings().group(ItemGroup.COMBAT))); - MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT))); - - SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT))); - SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT))); - - OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new FabricItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - - SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new FabricItemSettings().group(ItemGroup.MISC))); - PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new FabricItemSettings().group(ItemGroup.MISC))); - MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new FabricItemSettings().group(ItemGroup.MISC))); + MUKTUK = register("muktuk", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build()))); + SEAL = register("seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); + COOKED_SEAL = register("cooked_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build()))); + DRY_SEAL = register("dry_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build()))); + PTARMIGAN = register("ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build()))); + COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build()))); + VENISON = register("venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); + COOKED_VENISON = register("cooked_venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build()))); + + DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + ANTLER = register("antler", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + IVORY = register("ivory", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + + FISH_STRIP = register("fish_strip", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build()))); + DRY_FISH = register("dry_fish", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build()))); + + BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + + LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new QuiltItemSettings().group(ItemGroup.BREWING))); + + AKUTAQ = register("akutaq", new SuspiciousStewItem(new QuiltItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build()))); + + ULU = register("ulu", new UluItem(new QuiltItemSettings().group(ItemGroup.TOOLS).maxDamage(472))); + + WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT).fireproof())); + + KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); + KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new QuiltItemSettings().group(ItemGroup.COMBAT))); + MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); + + SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); + SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); + + OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + + SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new QuiltItemSettings().group(ItemGroup.MISC))); + PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new QuiltItemSettings().group(ItemGroup.MISC))); + MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new QuiltItemSettings().group(ItemGroup.MISC))); } private static I register(String name, I item) { @@ -129,8 +138,6 @@ private static I register(String name, I item) { public static void register() { addPotionRecipes(); - addFuels(); - addCompostables(); addItemGroupEntries(); addSnowGogglesToLootTable(); } @@ -144,22 +151,8 @@ private static void addPotionRecipes() { BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.REDSTONE, AlaskaPotions.LONG_TUNDRA_TEA); } - private static void addFuels() { - FuelRegistry fuelRegistry = FuelRegistry.INSTANCE; - fuelRegistry.add(WOODEN_HARPOON, 200); - } - - private static void addCompostables() { - CompostingChanceRegistry compostingChanceRegistry = CompostingChanceRegistry.INSTANCE; - compostingChanceRegistry.add(BLUEBERRIES, 0.3F); - compostingChanceRegistry.add(CLOUDBERRIES, 0.3F); - compostingChanceRegistry.add(RASPBERRIES, 0.3F); - compostingChanceRegistry.add(SALMONBERRIES, 0.3F); - compostingChanceRegistry.add(LABRADOR_TEA, 0.3F); - } - private static void addItemGroupEntries() { - FabricItemGroupBuilder.create(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> { + QuiltItemGroup.builder(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> { if (Registry.ITEM.getId(item).getNamespace().equals(AlaskaNativeCraft.MOD_ID)) { item.appendStacks(item.getGroup(), (DefaultedList) stacks); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java index d637353e..9c62ff69 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java @@ -104,7 +104,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int if (!world.isClient && j == 0) { stack.damage(1, playerEntity, entity -> entity.sendToolBreakStatus(user.getActiveHand())); HarpoonEntity harpoonEntity = new HarpoonEntity(world, playerEntity, this, stack); - harpoonEntity.setVelocity(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F); + harpoonEntity.setProperties(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F); if (playerEntity.getAbilities().creativeMode) { harpoonEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY; } @@ -129,7 +129,7 @@ public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int k *= multiplier / length; l *= multiplier / length; playerEntity.addVelocity(h, k, l); - playerEntity.useRiptide(20); + playerEntity.startRiptideAttack(20); if (playerEntity.isOnGround()) { playerEntity.move(MovementType.SELF, new Vec3d(0.0D, 1.2D, 0.0D)); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java index 7474eff5..38891d0c 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java @@ -12,9 +12,9 @@ public enum AlaskaNativeArmorMaterials implements ArmorMaterial { - KUSPUK("kuspuk", 5, new int[]{1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.fromTag(ItemTags.WOOL)), + KUSPUK("kuspuk", 5, new int[]{1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.WOOL)), - SNOW_GEAR("snow_goggles", 5, new int[]{1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.fromTag(ItemTags.PLANKS)); + SNOW_GEAR("snow_goggles", 5, new int[]{1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.PLANKS)); private static final int[] BASE_DURABILITY = new int[]{13, 15, 16, 11}; private final String name; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java index ac861c5e..2e831bac 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java @@ -19,7 +19,9 @@ protected FoxMixin(EntityType type, World world) { throw new AssertionError("AlaskaNativeCraft's FoxMixin constructor called!"); } - @Inject(at = @At("HEAD"), method = "method_18262", cancellable = true, remap = false) + // Mixin to the lambdas for chicken and rabbit predicate + // There is some very weird stuff happening, but it works:tm: + @Inject(at = @At("HEAD"), method = {"m_hklcoapa", "m_clkjuklc", "method_18262", "method_18261"}, cancellable = true, require = 1, remap = false) private static void addPtarmiganTarget(LivingEntity entity, CallbackInfoReturnable cir) { if (entity instanceof PtarmiganEntity) { cir.setReturnValue(true); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java index b76a1f90..d5d61f77 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java @@ -3,15 +3,16 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import net.minecraft.loot.LootTables; import net.minecraft.structure.*; +import net.minecraft.structure.piece.SimpleStructurePiece; +import net.minecraft.structure.piece.StructurePieceType; import net.minecraft.text.Text; import net.minecraft.util.BlockRotation; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.gen.StructureAccessor; import net.minecraft.world.gen.chunk.ChunkGenerator; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -40,11 +41,11 @@ protected IglooGeneratorMixin(StructureTemplateManager manager, Identifier ident throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin constructor called!"); } - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER), - method = "generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/world/gen/StructureAccessor;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/math/random/Random;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", - locals = LocalCapture.CAPTURE_FAILSOFT) - private void addDogsleds(StructureWorldAccess world, StructureAccessor structureAccessor, ChunkGenerator chunkGenerator, Random random, BlockBox chunkBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier identifier, StructurePlacementData structurePlacementData) { - BlockPos chestLocation = this.pos.add(StructureTemplate.transform(structurePlacementData, new BlockPos(0, 1, 0))); + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/piece/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/structure/StructureManager;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/random/RandomGenerator;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER), + method = "generate", + locals = LocalCapture.CAPTURE_FAILHARD) + private void addDogsleds(StructureWorldAccess world, StructureManager structureManager, ChunkGenerator chunkGenerator, RandomGenerator random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier id, StructurePlacementData structurePlacementData) { + BlockPos chestLocation = this.pos.add(Structure.transform(structurePlacementData, new BlockPos(0, 1, 0))); if (lastPos == null || !lastPos.equals(chestLocation)) { DogsledEntity dogsled = new DogsledEntity(world.toServerWorld(), (double) chestLocation.getX() + 0.5D, (double) chestLocation.getY() + 0.5D, (double) chestLocation.getZ() + 0.5D); dogsled.setDogsledType(DogsledEntity.Type.SPRUCE); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java index 28869e91..378654ee 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java @@ -15,7 +15,7 @@ import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -46,7 +46,7 @@ protected LivingEntityMixin(EntityType type, World world) { public abstract ItemStack getEquippedStack(EquipmentSlot feet); @Shadow - public abstract Random getRandom(); + public abstract RandomGenerator getRandom(); @Shadow @Final private Map activeStatusEffects; diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java index ae684952..23104a5d 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java @@ -2,7 +2,7 @@ import com.github.platymemo.alaskanativecraft.entity.SealEntity; import net.minecraft.entity.EntityType; -import net.minecraft.entity.ai.goal.ActiveTargetGoal; +import net.minecraft.entity.ai.goal.TargetGoal; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.PolarBearEntity; @@ -21,6 +21,6 @@ protected PolarBearMixin(EntityType type, World world) { @Inject(at = @At("TAIL"), method = "initGoals()V") private void addSealTarget(CallbackInfo ci) { - targetSelector.add(3, new ActiveTargetGoal<>(this, SealEntity.class, true)); + targetSelector.add(3, new TargetGoal<>(this, SealEntity.class, true)); } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java index 38c5c629..c081c998 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java @@ -36,18 +36,18 @@ private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInf NbtCompound entityTag = new NbtCompound(); entityTag.putString("id", ptarmigan.toString()); - if (entity.getEntityWorld() instanceof ServerWorld world) { + if (entity.getWorld() instanceof ServerWorld world) { Entity newEntity = EntityType.loadEntityWithPassengers(entityTag, world, (entityMaker) -> { entityMaker.refreshPositionAndAngles(entity.getX(), entity.getY(), entity.getZ(), entityMaker.getYaw(), entityMaker.getPitch()); return entityMaker; }); + if (newEntity != null) { newEntity.setCustomName(entityName); } - if (world.spawnNewEntityAndPassengers(newEntity)) { - entity.discard(); - } + world.spawnEntityAndPassengers(newEntity); + entity.discard(); } } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java index 999bc165..575f3fef 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java @@ -29,7 +29,7 @@ public class ItemRendererMixin { method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", cancellable = true) public void renderHarpoons(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int k, CallbackInfo ci) { - BakedModel model = MinecraftClient.getInstance().getItemRenderer().getModel(stack, world, entity, k); + BakedModel model = MinecraftClient.getInstance().getItemRenderer().getHeldItemModel(stack, world, entity, k); if (stack.isIn(AlaskaTags.HARPOONS) && HarpoonItemRenderer.INSTANCE.render(entity, stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) { ci.cancel(); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java index 6eb933ab..c364c25c 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java @@ -8,7 +8,7 @@ import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; -import net.minecraft.util.math.random.Random; +import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; @@ -63,7 +63,7 @@ public DefaultedList getRemainder(@NotNull CraftingInventory inventor for (int i = 0; i < defaultedList.size(); ++i) { ItemStack stack = inventory.getStack(i); if (stack.isIn(AlaskaTags.ULUS)) { - if (!stack.damage(5, Random.create(), null)) { + if (!stack.damage(5, RandomGenerator.createLegacy(), null)) { defaultedList.set(i, stack.copy()); } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java index 01d2f27a..555782d2 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java @@ -4,6 +4,7 @@ import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; +import dev.architectury.event.events.common.BlockEvent; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; @@ -11,15 +12,19 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SweetBerryBushBlock; +import net.minecraft.util.Holder; import net.minecraft.util.Identifier; +import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryEntry; import net.minecraft.util.registry.RegistryKey; +import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.decorator.BiomePlacementModifier; +import net.minecraft.world.gen.decorator.InSquarePlacementModifier; +import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier; import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.placementmodifier.BiomePlacementModifier; -import net.minecraft.world.gen.placementmodifier.RarityFilterPlacementModifier; -import net.minecraft.world.gen.placementmodifier.SquarePlacementModifier; +import net.minecraft.world.gen.feature.util.ConfiguredFeatureUtil; +import net.minecraft.world.gen.feature.util.PlacedFeatureUtil; import net.minecraft.world.gen.stateprovider.BlockStateProvider; import org.jetbrains.annotations.NotNull; @@ -75,24 +80,21 @@ private static void registerPatch(BlockState blockState, String featureName, int new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_sparse") ); - //create and register configured feature - RegistryEntry> patchFeature = ConfiguredFeatures.register( + + Holder> patchFeature = ConfiguredFeatureUtil.register( sparsePatchKey.getValue().toString(), Feature.RANDOM_PATCH, - ConfiguredFeatures.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(blockState)), List.of(whitelist))); + ConfiguredFeatureUtil.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(blockState)), List.of(whitelist))); //create and register placed feature - PlacedFeatures.register( + PlacedFeatureUtil.register( sparsePatchKey.getValue().toString(), patchFeature, - List.of( - RarityFilterPlacementModifier.of(rarity), - SquarePlacementModifier.of(), - PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.of() - ) + RarityFilterPlacementModifier.create(rarity), + InSquarePlacementModifier.getInstance(), + PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.getInstance() ); - BiomeModifications.addFeature( selector, GenerationStep.Feature.VEGETAL_DECORATION, @@ -105,14 +107,14 @@ private static void registerPatch(BlockState blockState, String featureName, int new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_decorated") ); - PlacedFeatures.register( + PlacedFeatureUtil.register( decoratedPatchRegistryKey.getValue().toString(), patchFeature, List.of( - RarityFilterPlacementModifier.of(rarity * DECORATED_MULTIPLIER), - SquarePlacementModifier.of(), - PlacedFeatures.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.of() + RarityFilterPlacementModifier.create(rarity * DECORATED_MULTIPLIER), + InSquarePlacementModifier.getInstance(), + PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.getInstance() ) ); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java index 474c903c..a7f62a6f 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java @@ -1,9 +1,9 @@ package com.github.platymemo.alaskanativecraft.worldgen.structure; import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; +import net.minecraft.structure.StructureType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; -import net.minecraft.world.gen.structure.StructureType; public class AlaskaStructures { public static StructureType FISH_CAMP = Registry.register(Registry.STRUCTURE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "fish_camp"), () -> FishCampStructure.CODEC); diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java index 09a9d953..8958ee9f 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java @@ -2,24 +2,26 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.structure.Structure; +import net.minecraft.structure.StructureType; import net.minecraft.structure.pool.StructurePool; import net.minecraft.structure.pool.StructurePoolBasedGenerator; import net.minecraft.tag.BiomeTags; +import net.minecraft.util.Holder; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.RegistryEntry; +import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap; import net.minecraft.world.biome.Biome; +import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.heightprovider.HeightProvider; -import net.minecraft.world.gen.structure.Structure; -import net.minecraft.world.gen.structure.StructureType; import java.util.Optional; import java.util.Set; -public class FishCampStructure extends Structure { +public class FishCampStructure extends StructureFeature { public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> - instance.group(FishCampStructure.configCodecBuilder(instance), + instance.group(FishCampStructure.settingsCodec(instance), StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), @@ -28,20 +30,20 @@ public class FishCampStructure extends Structure { Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) ).apply(instance, FishCampStructure::new)).codec(); - private final RegistryEntry startPool; + private final Holder startPool; private final Optional startJigsawName; private final int size; private final HeightProvider startHeight; private final Optional projectStartToHeightmap; private final int maxDistanceFromCenter; - public FishCampStructure(Structure.Config config, - RegistryEntry startPool, - Optional startJigsawName, - int size, - HeightProvider startHeight, - Optional projectStartToHeightmap, - int maxDistanceFromCenter) + public FishCampStructure(StructureSettings config, + Holder startPool, + Optional startJigsawName, + int size, + HeightProvider startHeight, + Optional projectStartToHeightmap, + int maxDistanceFromCenter) { super(config); this.startPool = startPool; @@ -53,14 +55,14 @@ public FishCampStructure(Structure.Config config, } @Override - public Optional getStructurePosition(Structure.Context context) { + public Optional findGenerationPos(GenerationContext context) { BlockPos spawnXZPosition = context.chunkPos().getCenterAtY(0); - int landHeight = context.chunkGenerator().getHeightInGround(spawnXZPosition.getX(), spawnXZPosition.getZ(), Heightmap.Type.WORLD_SURFACE_WG, context.world(), context.noiseConfig()); + int landHeight = context.chunkGenerator().getHeightInGround(spawnXZPosition.getX(), spawnXZPosition.getZ(), Heightmap.Type.WORLD_SURFACE_WG, context.world(), context.randomState()); - Set> biomes = context.chunkGenerator().getBiomeSource().getBiomesInArea(spawnXZPosition.getX(), landHeight, spawnXZPosition.getZ(), 32, context.noiseConfig().getMultiNoiseSampler()); - if (biomes.stream().noneMatch(biome -> biome.isIn(BiomeTags.IS_RIVER) || biome.isIn(BiomeTags.IS_OCEAN))) return Optional.empty(); + var biomes = context.chunkGenerator().getBiomeSource().getBiomesInArea(spawnXZPosition.getX(), landHeight, spawnXZPosition.getZ(), 32, context.randomState().getSampler()); + if (biomes.stream().noneMatch(biome -> biome.hasTag(BiomeTags.IS_RIVER) || biome.hasTag(BiomeTags.IS_OCEAN))) return Optional.empty(); - return StructurePoolBasedGenerator.generate(context, this.startPool, this.startJigsawName, this.size, spawnXZPosition.up(landHeight), false, this.projectStartToHeightmap, this.maxDistanceFromCenter); + return StructurePoolBasedGenerator.m_drsiegyr(context, this.startPool, this.startJigsawName, this.size, spawnXZPosition.up(landHeight), false, this.projectStartToHeightmap, this.maxDistanceFromCenter); } @Override diff --git a/src/main/resources/data/alaskanativecraft/tags/blocks/bushes.json b/src/main/resources/data/alaskanativecraft/tags/blocks/bushes.json new file mode 100644 index 00000000..a0165cf9 --- /dev/null +++ b/src/main/resources/data/alaskanativecraft/tags/blocks/bushes.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + "alaskanativecraft:blueberry_bush", + "alaskanativecraft:cloudberry_bush", + "alaskanativecraft:raspberry_bush", + "alaskanativecraft:salmonberry_bush" + ] +} diff --git a/src/main/resources/data/quilt_block_content_registry/attachments/minecraft/block/flammable_block.json b/src/main/resources/data/quilt_block_content_registry/attachments/minecraft/block/flammable_block.json new file mode 100644 index 00000000..a6cc3b4d --- /dev/null +++ b/src/main/resources/data/quilt_block_content_registry/attachments/minecraft/block/flammable_block.json @@ -0,0 +1,25 @@ +{ + "replace": false, + "values": { + "alaskanativecraft:whale_meat_block": { + "burn": 60, + "spread": 100 + }, + "alaskanativecraft:driftwood_log": { + "burn": 5, + "spread": 5 + }, + "alaskanativecraft:drying_rack": { + "burn": 5, + "spread": 5 + }, + "#alaskanativecraft:bushes": { + "burn": 60, + "spread": 100 + }, + "alaskanativecraft:labrador_tea": { + "burn": 60, + "spread": 100 + } + } +} diff --git a/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/compost_chance.json b/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/compost_chance.json new file mode 100644 index 00000000..a1c54623 --- /dev/null +++ b/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/compost_chance.json @@ -0,0 +1,10 @@ +{ + "replace": false, + "values": { + "alaskanativecraft:blueberries": 0.3, + "alaskanativecraft:cloudberries": 0.3, + "alaskanativecraft:raspberries": 0.3, + "alaskanativecraft:salmonberries": 0.3, + "alaskanativecraft:labrador_tea": 0.3 + } +} diff --git a/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/fuel_time.json b/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/fuel_time.json new file mode 100644 index 00000000..f5e7e90d --- /dev/null +++ b/src/main/resources/data/quilt_item_content_registry/attachments/minecraft/item/fuel_time.json @@ -0,0 +1,8 @@ +{ + "replace": false, + "values": { + "alaskanativecraft:whale_meat_block": 800, + "alaskanativecraft:drying_rack": 300, + "alaskanativecraft:wooden_harpoon": 200 + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json deleted file mode 100644 index 1cd696c2..00000000 --- a/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "schemaVersion": 1, - "id": "alaskanativecraft", - "version": "${version}", - "name": "Alaska Native Craft", - "description": "This mod aims to add various parts of Alaska Native cultures to Minecraft!", - "authors": [ - "Platymemo", - "Sunconure11" - ], - "contact": { - "homepage": "https://github.com/Platymemo/alaskanativecraft", - "sources": "https://github.com/Platymemo/alaskanativecraft", - "issues": "https://github.com/Platymemo/alaskanativecraft/issues" - }, - "license": "CC0-1.0", - "icon": "assets/alaskanativecraft/icon.png", - "environment": "*", - "entrypoints": { - "main": [ - "com.github.platymemo.alaskanativecraft.AlaskaNativeCraft" - ], - "client": [ - "com.github.platymemo.alaskanativecraft.AlaskaNativeCraftClient" - ], - "modmenu": [ - "com.github.platymemo.alaskanativecraft.compat.AlaskaModMenu" - ], - "rei_common": [ - "com.github.platymemo.alaskanativecraft.compat.rei.AlaskaPlugin" - ] - }, - "mixins": [ - "alaskanativecraft.mixins.json" - ], - "accessWidener": "alaskanativecraft.accesswidener", - "depends": { - "fabricloader": ">=0.12.11", - "fabric": "*", - "minecraft": "1.19", - "java": ">=17", - "cloth-config": ">=7.0.0" - }, - "recommends": { - "modmenu": "*" - } -} diff --git a/src/main/resources/quilt.mod.json b/src/main/resources/quilt.mod.json new file mode 100644 index 00000000..86ae6133 --- /dev/null +++ b/src/main/resources/quilt.mod.json @@ -0,0 +1,42 @@ +{ + "schema_version": 1, + "quilt_loader": { + "group": "com.github.platymemo", + "id": "alaskanativecraft", + "version": "${version}", + "metadata": { + "name": "Alaska Native Craft", + "description": "This mod aims to add various parts of Alaska Native cultures to Minecraft!", + "contributors": { + "Platymemo": "Owner" + }, + "contact": { + "homepage": "https://github.com/Platymemo/alaskanativecraft/", + "issues": "https://github.com/Platymemo/alaskanativecraft/issues", + "sources": "https://github.com/Platymemo/alaskanativecraft/" + }, + "icon": "assets/alaskanativecraft/icon.png" + }, + "intermediate_mappings": "net.fabricmc:intermediary", + "entrypoints": { + "init": "com.github.platymemo.alaskanativecraft.AlaskaNativeCraft", + "client_init": "com.github.platymemo.alaskanativecraft.AlaskaNativeCraftClient" + }, + "depends": [ + { + "id": "quilt_loader", + "versions": ">=0.17.0-" + }, + { + "id": "quilted_fabric_api", + "versions": ">=4.0.0-" + }, + { + "id": "minecraft", + "versions": ">=1.19.2" + } + ] + }, + "mixin": "alaskanativecraft.mixins.json", + "access_widener": "alaskanativecraft.accesswidener" +} From 6cbb39c9416f6b240e5ecee593d2b871c0e5e72d Mon Sep 17 00:00:00 2001 From: Platymemo <67663207+Platymemo@users.noreply.github.com> Date: Thu, 6 Oct 2022 20:50:43 -0800 Subject: [PATCH 2/4] add checkstyle --- codeformat/checkstyle.xml | 168 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 codeformat/checkstyle.xml diff --git a/codeformat/checkstyle.xml b/codeformat/checkstyle.xml new file mode 100644 index 00000000..a67b8dcd --- /dev/null +++ b/codeformat/checkstyle.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 9add8623cc3deec450736ab734fd68beeba856a7 Mon Sep 17 00:00:00 2001 From: Platymemo <67663207+Platymemo@users.noreply.github.com> Date: Fri, 7 Oct 2022 00:35:43 -0800 Subject: [PATCH 3/4] apply checkstyle --- codeformat/checkstyle.xml | 17 +- gradle.properties | 7 - gradlew.bat | 2 +- markdown/MAINPAGE.md | 4 +- .../alaskanativecraft/AlaskaNativeCraft.java | 25 +- .../AlaskaNativeCraftClient.java | 163 +- .../alaskanativecraft/block/AlaskaBlocks.java | 110 +- .../block/BlueberryBushBlock.java | 15 +- .../alaskanativecraft/block/BushBlock.java | 60 +- .../block/CloudberryBushBlock.java | 49 +- .../block/DryingRackBlock.java | 363 ++-- .../block/LabradorTeaBlock.java | 44 +- .../block/RaspberryBushBlock.java | 15 +- .../block/SalmonberryBushBlock.java | 15 +- .../block/WhaleMeatBlock.java | 28 +- .../block/entity/DryingRackBlockEntity.java | 299 +-- .../client/model/entity/AlaskaModels.java | 47 +- .../model/entity/DogsledEntityModel.java | 193 +- .../model/entity/HarpoonEntityModel.java | 111 +- .../client/model/entity/MooseEntityModel.java | 342 ++-- .../model/entity/PtarmiganEntityModel.java | 409 ++-- .../client/model/entity/SealEntityModel.java | 152 +- .../entity/feature/KuspukSkirtModel.java | 166 +- .../model/entity/feature/SnowshoeModel.java | 77 +- .../entity/DryingRackBlockEntityRenderer.java | 57 +- .../entity/DogsledEntityRenderer.java | 102 +- .../entity/HarpoonEntityRenderer.java | 79 +- .../renderer/entity/MooseEntityRenderer.java | 29 +- .../entity/PtarmiganEntityRenderer.java | 35 +- .../renderer/entity/SealEntityRenderer.java | 19 +- .../feature/KuspukSkirtFeatureRenderer.java | 61 +- .../ShoulderPtarmiganFeatureRenderer.java | 46 +- .../feature/SnowshoeFeatureRenderer.java | 106 +- .../renderer/item/HarpoonItemRenderer.java | 70 +- .../renderer/item/SnowshoeItemRenderer.java | 65 +- .../compat/AlaskaModMenu.java | 8 +- .../compat/rei/AlaskaPlugin.java | 55 +- .../compat/rei/DryingCategory.java | 77 +- .../compat/rei/DryingDisplay.java | 90 +- .../config/AlaskaConfig.java | 122 +- .../entity/AlaskaEntities.java | 154 +- .../entity/DogsledEntity.java | 1681 +++++++++-------- .../entity/HarpoonEntity.java | 638 ++++--- .../alaskanativecraft/entity/MooseEntity.java | 371 ++-- .../entity/PtarmiganEntity.java | 186 +- .../alaskanativecraft/entity/SealEntity.java | 575 +++--- .../entity/ai/goal/AdultMeleeAttackGoal.java | 66 +- .../entity/ai/goal/ChildEscapeDangerGoal.java | 23 +- .../entity/ai/goal/GroundFoodMateGoal.java | 149 +- .../entity/effect/AlaskaEffects.java | 12 +- .../entity/effect/MedicinalStatusEffect.java | 41 +- .../alaskanativecraft/item/AlaskaItems.java | 272 +-- .../alaskanativecraft/item/AlaskaPotions.java | 7 +- .../alaskanativecraft/item/DogsledItem.java | 105 +- .../alaskanativecraft/item/HarpoonItem.java | 237 +-- .../alaskanativecraft/item/UluItem.java | 30 +- .../material/AlaskaNativeArmorMaterials.java | 113 +- .../function/AlaskaLootFunctionTypes.java | 9 +- .../SetAkutaqEffectsLootFunction.java | 259 +-- .../mixin/AnvilScreenHandlerMixin.java | 60 +- .../mixin/AxeItemAccessor.java | 15 +- .../mixin/BrewingRecipeRegistryAccessor.java | 13 +- .../mixin/EndermanEntityMixin.java | 40 +- .../alaskanativecraft/mixin/FoxMixin.java | 34 +- .../mixin/GrindstoneScreenHandlerMixin.java | 37 +- .../mixin/IglooGeneratorMixin.java | 75 +- .../mixin/IngredientMixin.java | 22 +- .../alaskanativecraft/mixin/ItemMixin.java | 34 +- .../mixin/ItemStackMixin.java | 34 +- .../mixin/LeadLengthMixin.java | 24 +- .../mixin/LivingEntityMixin.java | 134 +- .../mixin/MeleeAttackGoalAccessor.java | 7 +- .../mixin/PlayerEntityMixin.java | 40 +- .../mixin/PolarBearMixin.java | 24 +- .../mixin/PowderSnowBlockMixin.java | 30 +- .../mixin/RepairItemRecipeMixin.java | 46 +- .../mixin/ShapedRecipeMixin.java | 58 +- .../mixin/SnowballEntityMixin.java | 72 +- .../mixin/client/ClientPlayerEntityMixin.java | 44 +- .../mixin/client/ClientRecipeBookMixin.java | 19 +- .../mixin/client/InGameHudMixin.java | 35 +- .../mixin/client/ItemRendererMixin.java | 49 +- .../client/LivingEntityRendererMixin.java | 64 +- .../mixin/client/MinecraftClientMixin.java | 79 +- .../recipe/AkutaqRecipe.java | 225 +-- .../recipe/AlaskaRecipes.java | 22 +- .../recipe/DryingRecipe.java | 25 +- .../recipe/FishStripRecipe.java | 115 +- .../sound/AlaskaSoundEvents.java | 35 +- .../alaskanativecraft/tags/AlaskaTags.java | 39 +- .../tags/common/CommonBlockTags.java | 6 +- .../worldgen/feature/AlaskaFeatures.java | 206 +- .../worldgen/structure/AlaskaStructures.java | 3 +- .../worldgen/structure/FishCampStructure.java | 97 +- .../blockstates/blueberry_bush.json | 2 +- .../blockstates/cloudberry_bush.json | 2 +- .../blockstates/driftwood_log.json | 2 +- .../blockstates/driftwood_planks.json | 2 +- .../blockstates/drying_rack.json | 2 +- .../blockstates/raspberry_bush.json | 2 +- .../blockstates/salmonberry_bush.json | 2 +- .../blockstates/whale_meat_block.json | 2 +- .../blueberry_bush/blueberry_bush_stage2.json | 2 +- .../blueberry_bush/blueberry_bush_stage3.json | 2 +- .../cloudberry_bush_stage0.json | 2 +- .../cloudberry_bush_stage1.json | 2 +- .../cloudberry_bush_stage2.json | 2 +- .../cloudberry_bush_stage3.json | 2 +- .../models/block/driftwood_log.json | 2 +- .../block/driftwood_log_horizontal.json | 2 +- .../models/block/driftwood_planks.json | 2 +- .../models/block/drying_rack/drying_rack.json | 2 +- .../drying_rack/drying_rack_extension.json | 2 +- .../block/drying_rack/drying_rack_legs.json | 2 +- .../raspberry_bush/raspberry_bush_stage2.json | 2 +- .../raspberry_bush/raspberry_bush_stage3.json | 2 +- .../salmonberry_bush_stage2.json | 2 +- .../salmonberry_bush_stage3.json | 2 +- .../models/block/whale_meat_block.json | 2 +- .../models/item/acacia_dogsled.json | 2 +- .../alaskanativecraft/models/item/akutaq.json | 2 +- .../alaskanativecraft/models/item/antler.json | 2 +- .../models/item/birch_dogsled.json | 2 +- .../models/item/blueberries.json | 2 +- .../models/item/cloudberries.json | 2 +- .../models/item/cooked_ptarmigan.json | 2 +- .../models/item/cooked_seal.json | 2 +- .../models/item/cooked_venison.json | 2 +- .../models/item/dark_oak_dogsled.json | 2 +- .../models/item/diamond_harpoon.json | 2 +- .../models/item/driftwood_chunk.json | 2 +- .../models/item/dry_fish.json | 2 +- .../models/item/dry_seal.json | 2 +- .../models/item/fish_strip.json | 2 +- .../models/item/golden_harpoon.json | 2 +- .../models/item/iron_harpoon.json | 2 +- .../alaskanativecraft/models/item/ivory.json | 2 +- .../models/item/jungle_dogsled.json | 2 +- .../models/item/kuspuk_body.json | 2 +- .../models/item/kuspuk_hood.json | 2 +- .../models/item/mukluks.json | 2 +- .../alaskanativecraft/models/item/muktuk.json | 2 +- .../models/item/netherite_harpoon.json | 2 +- .../models/item/oak_dogsled.json | 2 +- .../models/item/ptarmigan.json | 2 +- .../models/item/raspberries.json | 2 +- .../models/item/salmonberries.json | 2 +- .../alaskanativecraft/models/item/seal.json | 2 +- .../models/item/snow_goggles.json | 2 +- .../models/item/snowshoes.json | 2 +- .../models/item/spruce_dogsled.json | 2 +- .../models/item/stone_harpoon.json | 2 +- .../alaskanativecraft/models/item/ulu.json | 2 +- .../models/item/venison.json | 2 +- .../models/item/wooden_harpoon.json | 2 +- .../assets/alaskanativecraft/sounds.json | 2 +- .../textures/misc/gogglesblur.png.mcmeta | 1 - .../advancements/recipes/akutaq.json | 2 +- .../advancements/recipes/diamond_harpoon.json | 2 +- .../advancements/recipes/dogsleds.json | 2 +- .../advancements/recipes/drying_rack.json | 2 +- .../advancements/recipes/golden_harpoon.json | 2 +- .../advancements/recipes/iron_harpoon.json | 2 +- .../advancements/recipes/kuspuk.json | 2 +- .../recipes/netherite_harpoon_smithing.json | 2 +- .../advancements/recipes/stone_harpoon.json | 2 +- .../advancements/recipes/ulu.json | 2 +- .../advancements/recipes/wooden_harpoon.json | 2 +- .../loot_tables/blocks/blueberry_bush.json | 2 +- .../loot_tables/blocks/cloudberry_bush.json | 2 +- .../loot_tables/blocks/driftwood_log.json | 2 +- .../loot_tables/blocks/drying_rack.json | 2 +- .../loot_tables/blocks/raspberry_bush.json | 2 +- .../loot_tables/blocks/salmonberry_bush.json | 2 +- .../loot_tables/blocks/whale_meat_block.json | 2 +- .../loot_tables/entities/harp_seal.json | 2 +- .../loot_tables/entities/moose.json | 2 +- .../loot_tables/entities/ptarmigan.json | 2 +- .../recipes/acacia_dogsled.json | 2 +- .../recipes/birch_dogsled.json | 2 +- .../alaskanativecraft/recipes/blue_dye.json | 2 +- .../recipes/cooked_ptarmigan.json | 2 +- ...ooked_ptarmigan_from_campfire_cooking.json | 2 +- .../cooked_ptarmigan_from_smoking.json | 2 +- .../recipes/cooked_seal.json | 2 +- .../cooked_seal_from_campfire_cooking.json | 2 +- .../recipes/cooked_seal_from_smoking.json | 2 +- .../recipes/cooked_venison.json | 2 +- .../cooked_venison_from_campfire_cooking.json | 2 +- .../recipes/cooked_venison_from_smoking.json | 2 +- .../recipes/dark_oak_dogsled.json | 2 +- .../recipes/diamond_harpoon.json | 2 +- .../alaskanativecraft/recipes/dried_kelp.json | 2 +- .../recipes/driftwood_chunk.json | 2 +- .../alaskanativecraft/recipes/dry_bush.json | 2 +- .../alaskanativecraft/recipes/dry_fish.json | 2 +- .../recipes/drying_rack.json | 2 +- .../recipes/golden_harpoon.json | 2 +- .../alaskanativecraft/recipes/green_dye.json | 2 +- .../recipes/iron_harpoon.json | 2 +- .../recipes/jungle_dogsled.json | 2 +- .../recipes/kuspuk_body.json | 2 +- .../recipes/kuspuk_hood.json | 2 +- .../alaskanativecraft/recipes/leather.json | 2 +- .../alaskanativecraft/recipes/lime_dye.json | 2 +- .../alaskanativecraft/recipes/mukluks.json | 2 +- .../recipes/netherite_harpoon_smithing.json | 2 +- .../recipes/oak_dogsled.json | 2 +- .../alaskanativecraft/recipes/red_dye.json | 2 +- .../alaskanativecraft/recipes/snowshoes.json | 2 +- .../alaskanativecraft/recipes/sponge.json | 2 +- .../recipes/spruce_dogsled.json | 2 +- .../recipes/stone_harpoon.json | 2 +- .../data/alaskanativecraft/recipes/ulu.json | 2 +- .../recipes/wooden_harpoon.json | 2 +- .../tags/blocks/mineable/ulu.json | 2 +- .../tags/blocks/snowshoe_speed_blocks.json | 2 +- .../tags/items/akutaq_berries.json | 2 +- .../tags/items/akutaq_meats.json | 2 +- .../tags/items/dogsleds.json | 2 +- .../tags/items/harpoons.json | 2 +- .../alaskanativecraft/tags/items/kuspuks.json | 2 +- .../tags/items/seal_food.json | 2 +- .../tags/items/sliceable_fish.json | 2 +- .../alaskanativecraft/tags/items/ulus.json | 2 +- .../resources/data/c/tags/blocks/chests.json | 2 +- .../data/c/tags/blocks/logs_with_bark.json | 2 +- .../data/c/tags/items/blueberries.json | 2 +- .../resources/data/c/tags/items/chests.json | 2 +- .../data/c/tags/items/cooked_venison.json | 2 +- .../resources/data/c/tags/items/leathers.json | 2 +- .../data/c/tags/items/logs_with_bark.json | 2 +- .../data/c/tags/items/raspberries.json | 2 +- .../resources/data/c/tags/items/raw_meat.json | 2 +- .../resources/data/c/tags/items/venison.json | 2 +- .../minecraft/tags/blocks/logs_that_burn.json | 2 +- .../minecraft/tags/items/logs_that_burn.json | 2 +- 237 files changed, 5489 insertions(+), 5320 deletions(-) diff --git a/codeformat/checkstyle.xml b/codeformat/checkstyle.xml index a67b8dcd..06ef03df 100644 --- a/codeformat/checkstyle.xml +++ b/codeformat/checkstyle.xml @@ -41,6 +41,12 @@ + + + + + + @@ -137,7 +143,7 @@ - + @@ -151,13 +157,16 @@ + + + + + + - - - diff --git a/gradle.properties b/gradle.properties index 20007757..44c646e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,19 +2,12 @@ org.gradle.jvmargs=-Xmx1G org.gradle.parallel = true -# Fabric Properties -# check these on https://fabricmc.net/versions.html - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.1 - loader_version=0.14.8 - # Mod Properties mod_version=1.4.7 maven_group=com.github.platymemo archives_base_name=alaskanativecraft # Dependencies - fabric_version=0.58.6+1.19.2 clothconfig_version=8.0.75 modmenu_version=4.0.6 rei_version=9.1.530 diff --git a/gradlew.bat b/gradlew.bat index 89d1d913..f127cfd4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -88,4 +88,4 @@ exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal -:omega \ No newline at end of file +:omega diff --git a/markdown/MAINPAGE.md b/markdown/MAINPAGE.md index 3df2aa8c..c6fd805b 100644 --- a/markdown/MAINPAGE.md +++ b/markdown/MAINPAGE.md @@ -8,7 +8,7 @@ Currently included features are described below. ## Features 1. Mobs - * Harp Seals + * Seals * These fellas spawn in ocean and river biomes and spend their time hunting fish * Ptarmigans * These guys can be tamed with seeds and rides your shoulder much like a parrot! @@ -70,4 +70,4 @@ Huge thanks to these artists for the textures they've provided! Huge thanks to these translators for the translations they've provided! -- Koelle25 for the German translation \ No newline at end of file +- Koelle25 for the German translation diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java index 797f0543..a8a6189e 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraft.java @@ -8,21 +8,22 @@ import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import com.github.platymemo.alaskanativecraft.worldgen.feature.AlaskaFeatures; + import org.quiltmc.loader.api.ModContainer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; public class AlaskaNativeCraft implements ModInitializer { - public static final String MOD_ID = "alaskanativecraft"; + public static final String MOD_ID = "alaskanativecraft"; - @Override - public void onInitialize(ModContainer container) { - AlaskaBlocks.register(); - AlaskaItems.register(); - AlaskaLootFunctionTypes.register(); - AlaskaEntities.register(); - AlaskaTags.register(); - AlaskaFeatures.register(); - AlaskaSoundEvents.register(); - AlaskaRecipes.register(); - } + @Override + public void onInitialize(ModContainer container) { + AlaskaBlocks.register(); + AlaskaItems.register(); + AlaskaLootFunctionTypes.register(); + AlaskaEntities.register(); + AlaskaTags.register(); + AlaskaFeatures.register(); + AlaskaSoundEvents.register(); + AlaskaRecipes.register(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java index 8b91f737..13366119 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/AlaskaNativeCraftClient.java @@ -1,9 +1,15 @@ package com.github.platymemo.alaskanativecraft; +import java.util.UUID; + import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.renderer.block.entity.DryingRackBlockEntityRenderer; -import com.github.platymemo.alaskanativecraft.client.renderer.entity.*; +import com.github.platymemo.alaskanativecraft.client.renderer.entity.DogsledEntityRenderer; +import com.github.platymemo.alaskanativecraft.client.renderer.entity.HarpoonEntityRenderer; +import com.github.platymemo.alaskanativecraft.client.renderer.entity.MooseEntityRenderer; +import com.github.platymemo.alaskanativecraft.client.renderer.entity.PtarmiganEntityRenderer; +import com.github.platymemo.alaskanativecraft.client.renderer.entity.SealEntityRenderer; import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.KuspukSkirtFeatureRenderer; import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.ShoulderPtarmiganFeatureRenderer; import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.SnowshoeFeatureRenderer; @@ -16,6 +22,7 @@ import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.entity.ArmorStandEntityRenderer; @@ -26,96 +33,94 @@ import net.minecraft.entity.EntityType; import net.minecraft.item.DyeableItem; import net.minecraft.util.registry.Registry; + import org.quiltmc.loader.api.ModContainer; import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer; import org.quiltmc.qsl.block.extensions.api.client.BlockRenderLayerMap; import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking; -import java.util.UUID; - @Environment(EnvType.CLIENT) public class AlaskaNativeCraftClient implements ClientModInitializer { + @SuppressWarnings({"unchecked", "rawtypes"}) + @Environment(EnvType.CLIENT) + public static void registerEntityRenderers() { + EntityRendererRegistry.register(AlaskaEntities.WOODEN_HARPOON, HarpoonEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.STONE_HARPOON, HarpoonEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.IRON_HARPOON, HarpoonEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.GOLDEN_HARPOON, HarpoonEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.DIAMOND_HARPOON, HarpoonEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.NETHERITE_HARPOON, HarpoonEntityRenderer::new); - @SuppressWarnings({"unchecked", "rawtypes"}) - @Environment(EnvType.CLIENT) - public static void registerEntityRenderers() { - EntityRendererRegistry.register(AlaskaEntities.WOODEN_HARPOON, HarpoonEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.STONE_HARPOON, HarpoonEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.IRON_HARPOON, HarpoonEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.GOLDEN_HARPOON, HarpoonEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.DIAMOND_HARPOON, HarpoonEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.NETHERITE_HARPOON, HarpoonEntityRenderer::new); - - EntityRendererRegistry.register(AlaskaEntities.HARP_SEAL, SealEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.PTARMIGAN, PtarmiganEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.MOOSE, MooseEntityRenderer::new); - EntityRendererRegistry.register(AlaskaEntities.DOGSLED, DogsledEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.HARP_SEAL, SealEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.PTARMIGAN, PtarmiganEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.MOOSE, MooseEntityRenderer::new); + EntityRendererRegistry.register(AlaskaEntities.DOGSLED, DogsledEntityRenderer::new); - LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> { - if (entityRenderer instanceof BipedEntityRenderer || entityRenderer instanceof ArmorStandEntityRenderer) { - registrationHelper.register(new KuspukSkirtFeatureRenderer<>(entityRenderer, context.getModelLoader())); - registrationHelper.register(new SnowshoeFeatureRenderer(entityRenderer, context.getModelLoader())); - } else if (entityRenderer instanceof PlayerEntityRenderer playerEntityRenderer) { - registrationHelper.register(new KuspukSkirtFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); - registrationHelper.register(new SnowshoeFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); - registrationHelper.register(new ShoulderPtarmiganFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); - } - }); - } + LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> { + if (entityRenderer instanceof BipedEntityRenderer || entityRenderer instanceof ArmorStandEntityRenderer) { + registrationHelper.register(new KuspukSkirtFeatureRenderer<>(entityRenderer, context.getModelLoader())); + registrationHelper.register(new SnowshoeFeatureRenderer(entityRenderer, context.getModelLoader())); + } else if (entityRenderer instanceof PlayerEntityRenderer playerEntityRenderer) { + registrationHelper.register(new KuspukSkirtFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); + registrationHelper.register(new SnowshoeFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); + registrationHelper.register(new ShoulderPtarmiganFeatureRenderer<>(playerEntityRenderer, context.getModelLoader())); + } + }); + } - @Environment(EnvType.CLIENT) - public static void registerHarpoonPacket() { - ClientPlayNetworking.registerGlobalReceiver(HarpoonEntity.SPAWN_PACKET, (client, handler, packet, responseSender) -> { - EntityType type = Registry.ENTITY_TYPE.get(packet.readVarInt()); - UUID entityUUID = packet.readUuid(); - int entityID = packet.readVarInt(); - double x = packet.readDouble(); - double y = packet.readDouble(); - double z = packet.readDouble(); - float pitch = (packet.readByte() * 360) / 256.0F; - float yaw = (packet.readByte() * 360) / 256.0F; - ClientWorld world = MinecraftClient.getInstance().world; - Entity entity = type.create(world); - client.execute(() -> { - if (entity != null) { - entity.updateTrackedPositionAndAngles(x, y, z, yaw, pitch, 0, false); - entity.syncPacketPositionCodec(x, y, z); - entity.setId(entityID); - entity.setUuid(entityUUID); - assert world != null; - world.addEntity(entityID, entity); - } - }); - }); - } + @Environment(EnvType.CLIENT) + public static void registerHarpoonPacket() { + ClientPlayNetworking.registerGlobalReceiver(HarpoonEntity.SPAWN_PACKET, (client, handler, packet, responseSender) -> { + EntityType type = Registry.ENTITY_TYPE.get(packet.readVarInt()); + UUID entityUUID = packet.readUuid(); + int entityID = packet.readVarInt(); + double x = packet.readDouble(); + double y = packet.readDouble(); + double z = packet.readDouble(); + float pitch = (packet.readByte() * 360) / 256.0F; + float yaw = (packet.readByte() * 360) / 256.0F; + ClientWorld world = MinecraftClient.getInstance().world; + Entity entity = type.create(world); + client.execute(() -> { + if (entity != null) { + entity.updateTrackedPositionAndAngles(x, y, z, yaw, pitch, 0, false); + entity.syncPacketPositionCodec(x, y, z); + entity.setId(entityID); + entity.setUuid(entityUUID); + assert world != null; + world.addEntity(entityID, entity); + } + }); + }); + } - @Environment(EnvType.CLIENT) - public static void registerBlockEntityRenderers() { - BlockEntityRendererRegistry.register(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntityRenderer::new); - } + @Environment(EnvType.CLIENT) + public static void registerBlockEntityRenderers() { + BlockEntityRendererRegistry.register(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntityRenderer::new); + } - @Environment(EnvType.CLIENT) - public static void registerBlockRenderLayers() { - RenderLayer cutout = RenderLayer.getCutout(); - BlockRenderLayerMap.put(cutout, AlaskaBlocks.BLUEBERRY_BUSH); - BlockRenderLayerMap.put(cutout, AlaskaBlocks.CLOUDBERRY_BUSH); - BlockRenderLayerMap.put(cutout, AlaskaBlocks.RASPBERRY_BUSH); - BlockRenderLayerMap.put(cutout, AlaskaBlocks.SALMONBERRY_BUSH); - BlockRenderLayerMap.put(cutout, AlaskaBlocks.LABRADOR_TEA); - } + @Environment(EnvType.CLIENT) + public static void registerBlockRenderLayers() { + RenderLayer cutout = RenderLayer.getCutout(); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.BLUEBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.CLOUDBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.RASPBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.SALMONBERRY_BUSH); + BlockRenderLayerMap.put(cutout, AlaskaBlocks.LABRADOR_TEA); + } - @Environment(EnvType.CLIENT) - public static void registerItemColors() { - ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableItem) stack.getItem()).getColor(stack), AlaskaItems.KUSPUK_HOOD, AlaskaItems.KUSPUK_BODY, AlaskaItems.MUKLUKS); - } + @Environment(EnvType.CLIENT) + public static void registerItemColors() { + ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((DyeableItem) stack.getItem()).getColor(stack), AlaskaItems.KUSPUK_HOOD, AlaskaItems.KUSPUK_BODY, AlaskaItems.MUKLUKS); + } - @Override - public void onInitializeClient(ModContainer mod) { - registerBlockEntityRenderers(); - registerBlockRenderLayers(); - registerItemColors(); - AlaskaModels.registerEntityModels(); - registerEntityRenderers(); - registerHarpoonPacket(); - } + @Override + public void onInitializeClient(ModContainer mod) { + registerBlockEntityRenderers(); + registerBlockRenderLayers(); + registerItemColors(); + AlaskaModels.registerEntityModels(); + registerEntityRenderers(); + registerHarpoonPacket(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java index efe058e6..05a8175d 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/AlaskaBlocks.java @@ -2,7 +2,13 @@ import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity; -import net.minecraft.block.*; + +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.block.FlowerBlock; +import net.minecraft.block.Material; +import net.minecraft.block.PillarBlock; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.BlockItem; @@ -11,62 +17,66 @@ import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; + import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder; import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings; public class AlaskaBlocks { - public static final WhaleMeatBlock WHALE_MEAT_BLOCK; - public static final BlueberryBushBlock BLUEBERRY_BUSH; - public static final CloudberryBushBlock CLOUDBERRY_BUSH; - public static final RaspberryBushBlock RASPBERRY_BUSH; - public static final SalmonberryBushBlock SALMONBERRY_BUSH; - public static final FlowerBlock LABRADOR_TEA; - public static final PillarBlock DRIFTWOOD_LOG; - public static final DryingRackBlock DRYING_RACK; - public static final BlockEntityType DRYING_RACK_BLOCK_ENTITY; + public static final WhaleMeatBlock WHALE_MEAT_BLOCK; + public static final BlueberryBushBlock BLUEBERRY_BUSH; + public static final CloudberryBushBlock CLOUDBERRY_BUSH; + public static final RaspberryBushBlock RASPBERRY_BUSH; + public static final SalmonberryBushBlock SALMONBERRY_BUSH; + public static final FlowerBlock LABRADOR_TEA; + public static final PillarBlock DRIFTWOOD_LOG; + public static final DryingRackBlock DRYING_RACK; + public static final BlockEntityType DRYING_RACK_BLOCK_ENTITY; + + static { + WHALE_MEAT_BLOCK = register("whale_meat_block", new WhaleMeatBlock(QuiltBlockSettings.of(Material.ORGANIC_PRODUCT).requiresTool().sounds(BlockSoundGroup.HONEY).strength(1.0F, 1.0F)), ItemGroup.BREWING); + BLUEBERRY_BUSH = register("blueberry_bush", new BlueberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + CLOUDBERRY_BUSH = register("cloudberry_bush", new CloudberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + RASPBERRY_BUSH = register("raspberry_bush", new RaspberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + SALMONBERRY_BUSH = register("salmonberry_bush", new SalmonberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); + LABRADOR_TEA = register("labrador_tea", new LabradorTeaBlock(StatusEffects.REGENERATION, 12, AbstractBlock.Settings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS))); + DRIFTWOOD_LOG = register("driftwood_log", new PillarBlock(QuiltBlockSettings.copyOf(Blocks.OAK_LOG)), ItemGroup.BUILDING_BLOCKS); + DRYING_RACK = register("drying_rack", new DryingRackBlock(QuiltBlockSettings.copyOf(Blocks.OAK_FENCE)), ItemGroup.DECORATIONS); + DRYING_RACK_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying_rack"), QuiltBlockEntityTypeBuilder.create(DryingRackBlockEntity::new, DRYING_RACK).build(null)); + } + + /** + * Registers the {@link Block} along with a {@link BlockItem} in the provided {@link ItemGroup}. + */ + private static B register(String name, B block, ItemGroup tab) { + Item.Settings settings = new Item.Settings(); + if (tab != null) { + settings.group(tab); + } - static { - WHALE_MEAT_BLOCK = register("whale_meat_block", new WhaleMeatBlock(QuiltBlockSettings.of(Material.ORGANIC_PRODUCT).requiresTool().sounds(BlockSoundGroup.HONEY).strength(1.0F, 1.0F)), ItemGroup.BREWING); - BLUEBERRY_BUSH = register("blueberry_bush", new BlueberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - CLOUDBERRY_BUSH = register("cloudberry_bush", new CloudberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - RASPBERRY_BUSH = register("raspberry_bush", new RaspberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - SALMONBERRY_BUSH = register("salmonberry_bush", new SalmonberryBushBlock(QuiltBlockSettings.of(Material.PLANT).ticksRandomly().noCollision().sounds(BlockSoundGroup.SWEET_BERRY_BUSH))); - LABRADOR_TEA = register("labrador_tea", new LabradorTeaBlock(StatusEffects.REGENERATION, 12, AbstractBlock.Settings.of(Material.PLANT).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS))); - DRIFTWOOD_LOG = register("driftwood_log", new PillarBlock(QuiltBlockSettings.copyOf(Blocks.OAK_LOG)), ItemGroup.BUILDING_BLOCKS); - DRYING_RACK = register("drying_rack", new DryingRackBlock(QuiltBlockSettings.copyOf(Blocks.OAK_FENCE)), ItemGroup.DECORATIONS); - DRYING_RACK_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying_rack"), QuiltBlockEntityTypeBuilder.create(DryingRackBlockEntity::new, DRYING_RACK).build(null)); - } + return register(name, block, new BlockItem(block, settings)); + } - /** - * registers the {@link Block} along with a {@link BlockItem} in the provided {@link ItemGroup} - */ - private static B register(String name, B block, ItemGroup tab) { - Item.Settings settings = new Item.Settings(); - if (tab != null) { - settings.group(tab); - } - return register(name, block, new BlockItem(block, settings)); - } + /** + * Registers the {@link Block} along with the provided {@link BlockItem}. + */ + private static B register(String name, B block, BlockItem item) { + register(name, block); + if (item != null) { + item.appendBlocks(Item.BLOCK_ITEMS, item); + Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item); + } - /** - * registers the {@link Block} along with the provided {@link BlockItem} - */ - private static B register(String name, B block, BlockItem item) { - register(name, block); - if (item != null) { - item.appendBlocks(Item.BLOCK_ITEMS, item); - Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item); - } - return block; - } + return block; + } - /** - * registers the {@link Block} - */ - private static B register(String name, B block) { - Registry.register(Registry.BLOCK, new Identifier(AlaskaNativeCraft.MOD_ID, name), block); - return block; - } + /** + * Registers the {@link Block}. + */ + private static B register(String name, B block) { + Registry.register(Registry.BLOCK, new Identifier(AlaskaNativeCraft.MOD_ID, name), block); + return block; + } - public static void register() {} + public static void register() { + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java index b4fd895e..f6d61cae 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/BlueberryBushBlock.java @@ -1,18 +1,19 @@ package com.github.platymemo.alaskanativecraft.block; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; + import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; public class BlueberryBushBlock extends BushBlock { - public BlueberryBushBlock(Settings settings) { - super(settings); - } + public BlueberryBushBlock(Settings settings) { + super(settings); + } - @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return AlaskaItems.BLUEBERRIES.getDefaultStack(); - } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return AlaskaItems.BLUEBERRIES.getDefaultStack(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java index e726e142..7df714be 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/BushBlock.java @@ -1,5 +1,7 @@ package com.github.platymemo.alaskanativecraft.block; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.BlockState; import net.minecraft.block.SweetBerryBushBlock; import net.minecraft.entity.Entity; @@ -17,41 +19,41 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.BlockView; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; /** - * base class for berry bushes, - * contains common code for berry harvesting and entity collision - *
when creating a new bush, always override {@link #getPickStack(BlockView, BlockPos, BlockState)} to associate the bush to a berry item + * Base class for berry bushes. + * Contains common code for berry harvesting and entity collision. + *

+ * When creating a new bush, always override {@link #getPickStack(BlockView, BlockPos, BlockState)} to associate the bush to a berry item * * @author Platymemo, ix0rai */ public class BushBlock extends SweetBerryBushBlock { - public BushBlock(Settings settings) { - super(settings); - } + public BushBlock(Settings settings) { + super(settings); + } - @Override - public ActionResult onUse(@NotNull BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - int i = state.get(AGE); - boolean bl = i == 3; - if (!bl && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) { - return ActionResult.PASS; - } else if (i > 1) { - int j = 1 + world.random.nextInt(2); - dropStack(world, pos, new ItemStack(this.getPickStack(world, pos, state).getItem(), j + (bl ? 1 : 0))); - world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); - world.setBlockState(pos, state.with(AGE, 1), 2); - return ActionResult.success(world.isClient); - } else { - return ActionResult.PASS; - } - } + @Override + public ActionResult onUse(@NotNull BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + int i = state.get(AGE); + boolean bl = i == 3; + if (!bl && player.getStackInHand(hand).isOf(Items.BONE_MEAL)) { + return ActionResult.PASS; + } else if (i > 1) { + int j = 1 + world.random.nextInt(2); + dropStack(world, pos, new ItemStack(this.getPickStack(world, pos, state).getItem(), j + (bl ? 1 : 0))); + world.playSound(null, pos, SoundEvents.BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); + world.setBlockState(pos, state.with(AGE, 1), 2); + return ActionResult.success(world.isClient); + } else { + return ActionResult.PASS; + } + } - @Override - public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { - if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) { - entity.slowMovement(state, new Vec3d(1.0D, 0.90D, 1.0D)); - } - } + @Override + public void onEntityCollision(BlockState state, World world, BlockPos pos, Entity entity) { + if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) { + entity.slowMovement(state, new Vec3d(1.0D, 0.90D, 1.0D)); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java index df7271ae..f1ca3807 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/CloudberryBushBlock.java @@ -1,6 +1,8 @@ package com.github.platymemo.alaskanativecraft.block; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.ShapeContext; @@ -8,34 +10,33 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.shape.VoxelShape; import net.minecraft.world.BlockView; -import org.jetbrains.annotations.NotNull; public class CloudberryBushBlock extends BushBlock { - private static final VoxelShape MID_SHAPE; - private static final VoxelShape FULL_SHAPE; + private static final VoxelShape MID_SHAPE; + private static final VoxelShape FULL_SHAPE; - static { - MID_SHAPE = Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 9.0D, 15.0D); - FULL_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D); - } + static { + MID_SHAPE = Block.createCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 9.0D, 15.0D); + FULL_SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 9.0D, 16.0D); + } - public CloudberryBushBlock(Settings settings) { - super(settings); - } + public CloudberryBushBlock(Settings settings) { + super(settings); + } - @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return AlaskaItems.CLOUDBERRIES.getDefaultStack(); - } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return AlaskaItems.CLOUDBERRIES.getDefaultStack(); + } - @Override - public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.get(AGE) > 0 && state.get(AGE) < 3) { - return MID_SHAPE; - } else if (state.get(AGE) == 3) { - return FULL_SHAPE; - } else { - return super.getOutlineShape(state, world, pos, context); - } - } + @Override + public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (state.get(AGE) > 0 && state.get(AGE) < 3) { + return MID_SHAPE; + } else if (state.get(AGE) == 3) { + return FULL_SHAPE; + } else { + return super.getOutlineShape(state, world, pos, context); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java index 536e0f37..9c972c78 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/DryingRackBlock.java @@ -1,8 +1,18 @@ package com.github.platymemo.alaskanativecraft.block; +import java.util.Optional; + import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity; import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe; -import net.minecraft.block.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRenderType; +import net.minecraft.block.BlockState; +import net.minecraft.block.BlockWithEntity; +import net.minecraft.block.ShapeContext; +import net.minecraft.block.Waterloggable; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityType; @@ -28,183 +38,182 @@ import net.minecraft.world.BlockView; import net.minecraft.world.World; import net.minecraft.world.WorldAccess; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Optional; @SuppressWarnings("deprecation") public class DryingRackBlock extends BlockWithEntity implements Waterloggable { - public static final BooleanProperty WATERLOGGED; - public static final BooleanProperty CONNECTED_POS; - public static final BooleanProperty CONNECTED_NEG; - public static final EnumProperty AXIS; - private static final VoxelShape X_SHAPE = Block.createCuboidShape(0, 0, 6, 16, 8, 10); - private static final VoxelShape Z_SHAPE = Block.createCuboidShape(6, 0, 0, 10, 8, 16); - - static { - WATERLOGGED = Properties.WATERLOGGED; - CONNECTED_POS = BooleanProperty.of("positive"); - CONNECTED_NEG = BooleanProperty.of("negative"); - AXIS = EnumProperty.of("axis", Direction.Axis.class, Direction.Axis::isHorizontal); - } - - public DryingRackBlock(Settings settings) { - super(settings); - this.setDefaultState(this.getStateManager().getDefaultState() - .with(WATERLOGGED, false) - .with(CONNECTED_POS, false) - .with(CONNECTED_NEG, false) - .with(AXIS, Direction.Axis.Z)); - } - - @Override - public ActionResult onUse(BlockState state, @NotNull World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { - BlockEntity blockEntity = world.getBlockEntity(pos); - if (!world.isClient && blockEntity instanceof DryingRackBlockEntity dryingRackBlockEntity) { - ItemStack itemStack = player.getStackInHand(hand); - Optional optional = dryingRackBlockEntity.getRecipeFor(itemStack); - if (optional.isPresent()) { - if (dryingRackBlockEntity.addItem(player.getAbilities().creativeMode ? itemStack.copy() : itemStack, (optional.get()).getCookTime())) { - // TODO Drying rack interaction stats - return ActionResult.SUCCESS; - } - return ActionResult.CONSUME; - } else { - ItemStack dryingRackItem = dryingRackBlockEntity.getDriedItem(); - ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), dryingRackItem); - return ActionResult.SUCCESS; - } - } - return ActionResult.SUCCESS; - } - - @Override - public void onStateReplaced(@NotNull BlockState state, World world, BlockPos pos, @NotNull BlockState newState, boolean moved) { - if (!state.isOf(newState.getBlock())) { - BlockEntity blockEntity = world.getBlockEntity(pos); - if (blockEntity instanceof DryingRackBlockEntity) { - ItemScatterer.spawn(world, pos, ((DryingRackBlockEntity) blockEntity).getItemsBeingDried()); - } - - super.onStateReplaced(state, world, pos, newState, moved); - } - } - - @Override - public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) { - if (state.get(AXIS) == Direction.Axis.X) { - return X_SHAPE; - } else { - return Z_SHAPE; - } - } - - @Nullable - @Override - public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) { - boolean bl = ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER; - World world = ctx.getWorld(); - BlockPos blockPos = ctx.getBlockPos(); - - BlockState state = this.getDefaultState(); - - Direction direction = ctx.getPlayerFacing(); - Direction.Axis axis = direction.getAxis() == Direction.Axis.X ? Direction.Axis.Z : Direction.Axis.X; - Direction left = Direction.get(Direction.AxisDirection.NEGATIVE, axis); - Direction right = Direction.get(Direction.AxisDirection.POSITIVE, axis); - return state.with(AXIS, axis) - .with(CONNECTED_NEG, this.canConnect(left, world.getBlockState(blockPos.offset(left)))) - .with(CONNECTED_POS, this.canConnect(right, world.getBlockState(blockPos.offset(right)))) - .with(WATERLOGGED, bl); - } - - @Override - public BlockState rotate(@NotNull BlockState state, BlockRotation rotation) { - return switch (rotation) { - case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) { - case X -> state.with(AXIS, Direction.Axis.Z); - case Z -> state.with(AXIS, Direction.Axis.X); - default -> state; - }; - default -> state; - }; - } - - private boolean canConnect(Direction direction, @NotNull BlockState otherState) { - if (otherState.isIn(BlockTags.LOGS) || otherState.isIn(BlockTags.WALLS) || otherState.isIn(BlockTags.FENCES) || otherState.isIn(BlockTags.FENCE_GATES)) { - return true; - } else if (otherState.isOf(this)) { - return otherState.get(AXIS) == direction.getAxis(); - } else { - return false; - } - } - - @Override - public BlockState getStateForNeighborUpdate(@NotNull BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { - if (state.get(WATERLOGGED)) { - world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); - } - - return state.get(AXIS) == direction.getAxis() ? - state.with(direction.getDirection() == Direction.AxisDirection.POSITIVE ? CONNECTED_POS : CONNECTED_NEG, this.canConnect(direction, newState)) - : super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom); - } - - @Override - public BlockRenderType getRenderType(BlockState state) { - return BlockRenderType.MODEL; - } - - @Override - public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, @NotNull BlockState state, FluidState fluidState) { - if (!(Boolean) state.get(Properties.WATERLOGGED) && fluidState.getFluid() == Fluids.WATER) { - BlockEntity blockEntity = world.getBlockEntity(pos); - if (blockEntity instanceof DryingRackBlockEntity) { - ((DryingRackBlockEntity) blockEntity).spawnItemsBeingDried(); - } - - world.setBlockState(pos, state.with(WATERLOGGED, true), 3); - world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world)); - return true; - } else { - return false; - } - } - - @Override - public FluidState getFluidState(@NotNull BlockState state) { - return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); - } - - @Override - public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { - return false; - } - - @Nullable - @Override - public BlockEntityTicker getTicker(@NotNull World world, BlockState state, BlockEntityType type) { - if (!world.isClient) { - if (state.get(WATERLOGGED) || world.isRaining()) { - return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::possiblyWetTick); - } else { - return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::updateItemsBeingDried); - } - } - return null; - } - - @Nullable - @Override - public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { - return new DryingRackBlockEntity(pos, state); - } - - @Override - protected void appendProperties(StateManager.Builder builder) { - super.appendProperties(builder); - builder.add(WATERLOGGED).add(CONNECTED_POS).add(CONNECTED_NEG).add(AXIS); - } + public static final BooleanProperty WATERLOGGED; + public static final BooleanProperty CONNECTED_POS; + public static final BooleanProperty CONNECTED_NEG; + public static final EnumProperty AXIS; + private static final VoxelShape X_SHAPE = Block.createCuboidShape(0, 0, 6, 16, 8, 10); + private static final VoxelShape Z_SHAPE = Block.createCuboidShape(6, 0, 0, 10, 8, 16); + + static { + WATERLOGGED = Properties.WATERLOGGED; + CONNECTED_POS = BooleanProperty.of("positive"); + CONNECTED_NEG = BooleanProperty.of("negative"); + AXIS = EnumProperty.of("axis", Direction.Axis.class, Direction.Axis::isHorizontal); + } + + public DryingRackBlock(Settings settings) { + super(settings); + this.setDefaultState(this.getStateManager().getDefaultState() + .with(WATERLOGGED, false) + .with(CONNECTED_POS, false) + .with(CONNECTED_NEG, false) + .with(AXIS, Direction.Axis.Z)); + } + + @Override + public ActionResult onUse(BlockState state, @NotNull World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { + BlockEntity blockEntity = world.getBlockEntity(pos); + if (!world.isClient && blockEntity instanceof DryingRackBlockEntity dryingRackBlockEntity) { + ItemStack itemStack = player.getStackInHand(hand); + Optional optional = dryingRackBlockEntity.getRecipeFor(itemStack); + if (optional.isPresent()) { + if (dryingRackBlockEntity.addItem(player.getAbilities().creativeMode ? itemStack.copy() : itemStack, (optional.get()).getCookTime())) { + // TODO Drying rack interaction stats + return ActionResult.SUCCESS; + } + + return ActionResult.CONSUME; + } else { + ItemStack dryingRackItem = dryingRackBlockEntity.getDriedItem(); + ItemScatterer.spawn(world, pos.getX(), pos.getY(), pos.getZ(), dryingRackItem); + return ActionResult.SUCCESS; + } + } + + return ActionResult.SUCCESS; + } + + @Override + public void onStateReplaced(@NotNull BlockState state, World world, BlockPos pos, @NotNull BlockState newState, boolean moved) { + if (!state.isOf(newState.getBlock())) { + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity instanceof DryingRackBlockEntity) { + ItemScatterer.spawn(world, pos, ((DryingRackBlockEntity) blockEntity).getItemsBeingDried()); + } + + super.onStateReplaced(state, world, pos, newState, moved); + } + } + + @Override + public VoxelShape getOutlineShape(@NotNull BlockState state, BlockView world, BlockPos pos, ShapeContext context) { + if (state.get(AXIS) == Direction.Axis.X) { + return X_SHAPE; + } else { + return Z_SHAPE; + } + } + + @Nullable + @Override + public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) { + boolean bl = ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER; + World world = ctx.getWorld(); + BlockPos blockPos = ctx.getBlockPos(); + + BlockState state = this.getDefaultState(); + + Direction direction = ctx.getPlayerFacing(); + Direction.Axis axis = direction.getAxis() == Direction.Axis.X ? Direction.Axis.Z : Direction.Axis.X; + Direction left = Direction.get(Direction.AxisDirection.NEGATIVE, axis); + Direction right = Direction.get(Direction.AxisDirection.POSITIVE, axis); + return state.with(AXIS, axis) + .with(CONNECTED_NEG, this.canConnect(left, world.getBlockState(blockPos.offset(left)))) + .with(CONNECTED_POS, this.canConnect(right, world.getBlockState(blockPos.offset(right)))) + .with(WATERLOGGED, bl); + } + + @Override + public BlockState rotate(@NotNull BlockState state, BlockRotation rotation) { + return switch (rotation) { + case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) { + case X -> state.with(AXIS, Direction.Axis.Z); + case Z -> state.with(AXIS, Direction.Axis.X); + default -> state; + }; + default -> state; + }; + } + + private boolean canConnect(Direction direction, @NotNull BlockState otherState) { + if (otherState.isIn(BlockTags.LOGS) || otherState.isIn(BlockTags.WALLS) || otherState.isIn(BlockTags.FENCES) || otherState.isIn(BlockTags.FENCE_GATES)) { + return true; + } else if (otherState.isOf(this)) { + return otherState.get(AXIS) == direction.getAxis(); + } else { + return false; + } + } + + @Override + public BlockState getStateForNeighborUpdate(@NotNull BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) { + if (state.get(WATERLOGGED)) { + world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); + } + + return state.get(AXIS) == direction.getAxis() + ? state.with(direction.getDirection() == Direction.AxisDirection.POSITIVE ? CONNECTED_POS : CONNECTED_NEG, this.canConnect(direction, newState)) + : super.getStateForNeighborUpdate(state, direction, newState, world, pos, posFrom); + } + + @Override + public BlockRenderType getRenderType(BlockState state) { + return BlockRenderType.MODEL; + } + + @Override + public boolean tryFillWithFluid(WorldAccess world, BlockPos pos, @NotNull BlockState state, FluidState fluidState) { + if (!(Boolean) state.get(Properties.WATERLOGGED) && fluidState.getFluid() == Fluids.WATER) { + BlockEntity blockEntity = world.getBlockEntity(pos); + if (blockEntity instanceof DryingRackBlockEntity) { + ((DryingRackBlockEntity) blockEntity).spawnItemsBeingDried(); + } + + world.setBlockState(pos, state.with(WATERLOGGED, true), 3); + world.scheduleFluidTick(pos, fluidState.getFluid(), fluidState.getFluid().getTickRate(world)); + return true; + } else { + return false; + } + } + + @Override + public FluidState getFluidState(@NotNull BlockState state) { + return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state); + } + + @Override + public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) { + return false; + } + + @Nullable + @Override + public BlockEntityTicker getTicker(@NotNull World world, BlockState state, BlockEntityType type) { + if (!world.isClient) { + if (state.get(WATERLOGGED) || world.isRaining()) { + return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::possiblyWetTick); + } else { + return checkType(type, AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, DryingRackBlockEntity::updateItemsBeingDried); + } + } + + return null; + } + + @Nullable + @Override + public BlockEntity createBlockEntity(BlockPos pos, BlockState state) { + return new DryingRackBlockEntity(pos, state); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(WATERLOGGED).add(CONNECTED_POS).add(CONNECTED_NEG).add(AXIS); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java index 93a35f71..031c243a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/LabradorTeaBlock.java @@ -1,7 +1,11 @@ package com.github.platymemo.alaskanativecraft.block; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import net.minecraft.block.*; + +import net.minecraft.block.AbstractBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.Fertilizable; +import net.minecraft.block.FlowerBlock; import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; @@ -11,27 +15,27 @@ import net.minecraft.world.World; public class LabradorTeaBlock extends FlowerBlock implements Fertilizable { - public LabradorTeaBlock(StatusEffect suspiciousStewEffect, int effectDuration, AbstractBlock.Settings settings) { - super(suspiciousStewEffect, effectDuration, settings); - } + public LabradorTeaBlock(StatusEffect suspiciousStewEffect, int effectDuration, AbstractBlock.Settings settings) { + super(suspiciousStewEffect, effectDuration, settings); + } - @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return AlaskaItems.LABRADOR_TEA.getDefaultStack(); - } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return AlaskaItems.LABRADOR_TEA.getDefaultStack(); + } - @Override - public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { - return true; - } + @Override + public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) { + return true; + } - @Override - public boolean canGrow(World world, RandomGenerator random, BlockPos pos, BlockState state) { - return true; - } + @Override + public boolean canGrow(World world, RandomGenerator random, BlockPos pos, BlockState state) { + return true; + } - @Override - public void grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state) { - dropStack(world, pos, new ItemStack(this)); - } + @Override + public void grow(ServerWorld world, RandomGenerator random, BlockPos pos, BlockState state) { + dropStack(world, pos, new ItemStack(this)); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java index 643ae6f3..ad291e3c 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/RaspberryBushBlock.java @@ -1,18 +1,19 @@ package com.github.platymemo.alaskanativecraft.block; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; + import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; public class RaspberryBushBlock extends BushBlock { - public RaspberryBushBlock(Settings settings) { - super(settings); - } + public RaspberryBushBlock(Settings settings) { + super(settings); + } - @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return AlaskaItems.RASPBERRIES.getDefaultStack(); - } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return AlaskaItems.RASPBERRIES.getDefaultStack(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java index 0a037367..c74fd20a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/SalmonberryBushBlock.java @@ -1,18 +1,19 @@ package com.github.platymemo.alaskanativecraft.block; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; + import net.minecraft.block.BlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; public class SalmonberryBushBlock extends BushBlock { - public SalmonberryBushBlock(Settings settings) { - super(settings); - } + public SalmonberryBushBlock(Settings settings) { + super(settings); + } - @Override - public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { - return AlaskaItems.SALMONBERRIES.getDefaultStack(); - } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return AlaskaItems.SALMONBERRIES.getDefaultStack(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java index b15ae83c..157d149b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/WhaleMeatBlock.java @@ -1,5 +1,7 @@ package com.github.platymemo.alaskanativecraft.block; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -7,22 +9,20 @@ import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; public class WhaleMeatBlock extends FacingBlock { + public WhaleMeatBlock(AbstractBlock.Settings settings) { + super(settings); + this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH)); + } - public WhaleMeatBlock(AbstractBlock.Settings settings) { - super(settings); - this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH)); - } - - @Override - public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) { - return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite()); - } + @Override + public BlockState getPlacementState(@NotNull ItemPlacementContext ctx) { + return this.getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite()); + } - @Override - protected void appendProperties(StateManager.@NotNull Builder builder) { - builder.add(FACING); - } + @Override + protected void appendProperties(StateManager.@NotNull Builder builder) { + builder.add(FACING); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java index 6121117a..52bd3420 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/block/entity/DryingRackBlockEntity.java @@ -1,8 +1,13 @@ package com.github.platymemo.alaskanativecraft.block.entity; +import java.util.Optional; + import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.recipe.AlaskaRecipes; import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; import net.minecraft.inventory.Inventories; @@ -19,155 +24,151 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Optional; public class DryingRackBlockEntity extends BlockEntity implements Clearable { - private final DefaultedList itemsBeingDried; - private final int[] dryingTimes; - private final int[] dryingTotalTimes; - - public DryingRackBlockEntity(BlockPos pos, BlockState state) { - super(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, pos, state); - this.itemsBeingDried = DefaultedList.ofSize(4, ItemStack.EMPTY); - this.dryingTimes = new int[4]; - this.dryingTotalTimes = new int[4]; - } - - public static void possiblyWetTick(@NotNull World world, BlockPos pos, BlockState state, DryingRackBlockEntity dryingRackBlockEntity) { - if (world.isSkyVisible(pos)) { - for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) { - if (dryingRackBlockEntity.dryingTimes[i] > 0) { - dryingRackBlockEntity.dryingTimes[i] = MathHelper.clamp(dryingRackBlockEntity.dryingTimes[i] - 2, 0, dryingRackBlockEntity.dryingTotalTimes[i]); - } - } - } else { - updateItemsBeingDried(world, pos, state, dryingRackBlockEntity); - } - } - - @SuppressWarnings("unused") - public static void updateItemsBeingDried(World world, BlockPos pos, BlockState state, @NotNull DryingRackBlockEntity dryingRackBlockEntity) { - for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) { - ItemStack itemStack = dryingRackBlockEntity.itemsBeingDried.get(i); - if (!itemStack.isEmpty()) { - dryingRackBlockEntity.dryingTimes[i]++; - if (dryingRackBlockEntity.dryingTimes[i] >= dryingRackBlockEntity.dryingTotalTimes[i]) { - - // Don't want it to keep counting up unnecessarily high - dryingRackBlockEntity.dryingTimes[i] = dryingRackBlockEntity.dryingTotalTimes[i]; - - Inventory inventory = new SimpleInventory(itemStack); - ItemStack itemStack2 = world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, inventory, world).map((dryingRecipe) -> dryingRecipe.craft(inventory)).orElse(itemStack); - dryingRackBlockEntity.itemsBeingDried.set(i, itemStack2); - dryingRackBlockEntity.updateListeners(); - } - } - } - } - - @Nullable - @Override - public Packet toUpdatePacket() { - return BlockEntityUpdateS2CPacket.of(this); - } - - public DefaultedList getItemsBeingDried() { - return this.itemsBeingDried; - } - - public ItemStack getDriedItem() { - ItemStack stack; - for (int i = 0; i < this.itemsBeingDried.size(); ++i) { - if (this.dryingTimes[i] >= this.dryingTotalTimes[i]) { - stack = this.itemsBeingDried.get(i); - if (!stack.isEmpty()) { - this.itemsBeingDried.set(i, ItemStack.EMPTY); - this.updateListeners(); - return stack; - } - } - } - for (int i = 0; i < this.itemsBeingDried.size(); ++i) { - stack = this.itemsBeingDried.get(i); - if (!stack.isEmpty()) { - this.itemsBeingDried.set(i, ItemStack.EMPTY); - this.updateListeners(); - return stack; - } - } - return ItemStack.EMPTY; - } - - @Override - public void readNbt(NbtCompound nbt) { - this.itemsBeingDried.clear(); - Inventories.readNbt(nbt, this.itemsBeingDried); - int[] js; - if (nbt.contains("DryingTimes", 11)) { - js = nbt.getIntArray("DryingTimes"); - System.arraycopy(js, 0, this.dryingTimes, 0, Math.min(this.dryingTotalTimes.length, js.length)); - } - } - - @Override - public void writeNbt(NbtCompound nbt) { - saveInitialChunkData(nbt); - nbt.putIntArray("DryingTimes", dryingTimes); - nbt.putIntArray("DryingTotalTimes", dryingTotalTimes); - } - - private NbtCompound saveInitialChunkData(NbtCompound tag) { - Inventories.writeNbt(tag, this.itemsBeingDried, true); - return tag; - } - - @Override - public NbtCompound toInitialChunkDataNbt() { - return this.saveInitialChunkData(new NbtCompound()); - } - - @SuppressWarnings("ConstantConditions") - public Optional getRecipeFor(ItemStack item) { - return this.itemsBeingDried.stream().noneMatch(ItemStack::isEmpty) ? Optional.empty() : this.world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, new SimpleInventory(item), this.world); - } - - public boolean addItem(ItemStack item, int integer) { - for (int i = 0; i < this.itemsBeingDried.size(); ++i) { - ItemStack itemStack = this.itemsBeingDried.get(i); - if (itemStack.isEmpty()) { - this.dryingTotalTimes[i] = integer; - this.dryingTimes[i] = 0; - this.itemsBeingDried.set(i, item.split(1)); - this.updateListeners(); - return true; - } - } - - return false; - } - - @SuppressWarnings("ConstantConditions") - private void updateListeners() { - this.markDirty(); - this.getWorld().updateListeners(this.getPos(), this.getCachedState(), this.getCachedState(), 3); - } - - @Override - public void clear() { - this.itemsBeingDried.clear(); - } - - public void spawnItemsBeingDried() { - if (this.world != null) { - if (!this.world.isClient) { - ItemScatterer.spawn(this.world, this.getPos(), this.getItemsBeingDried()); - } - - this.updateListeners(); - } - - } + private final DefaultedList itemsBeingDried; + private final int[] dryingTimes; + private final int[] dryingTotalTimes; + + public DryingRackBlockEntity(BlockPos pos, BlockState state) { + super(AlaskaBlocks.DRYING_RACK_BLOCK_ENTITY, pos, state); + this.itemsBeingDried = DefaultedList.ofSize(4, ItemStack.EMPTY); + this.dryingTimes = new int[4]; + this.dryingTotalTimes = new int[4]; + } + + public static void possiblyWetTick(@NotNull World world, BlockPos pos, BlockState state, DryingRackBlockEntity dryingRackBlockEntity) { + if (world.isSkyVisible(pos)) { + for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) { + if (dryingRackBlockEntity.dryingTimes[i] > 0) { + dryingRackBlockEntity.dryingTimes[i] = MathHelper.clamp(dryingRackBlockEntity.dryingTimes[i] - 2, 0, dryingRackBlockEntity.dryingTotalTimes[i]); + } + } + } else { + updateItemsBeingDried(world, pos, state, dryingRackBlockEntity); + } + } + + @SuppressWarnings("unused") + public static void updateItemsBeingDried(World world, BlockPos pos, BlockState state, @NotNull DryingRackBlockEntity dryingRackBlockEntity) { + for (int i = 0; i < dryingRackBlockEntity.itemsBeingDried.size(); ++i) { + ItemStack itemStack = dryingRackBlockEntity.itemsBeingDried.get(i); + if (!itemStack.isEmpty()) { + dryingRackBlockEntity.dryingTimes[i]++; + if (dryingRackBlockEntity.dryingTimes[i] >= dryingRackBlockEntity.dryingTotalTimes[i]) { + // Don't want it to keep counting up unnecessarily high + dryingRackBlockEntity.dryingTimes[i] = dryingRackBlockEntity.dryingTotalTimes[i]; + + Inventory inventory = new SimpleInventory(itemStack); + ItemStack itemStack2 = world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, inventory, world).map((dryingRecipe) -> dryingRecipe.craft(inventory)).orElse(itemStack); + dryingRackBlockEntity.itemsBeingDried.set(i, itemStack2); + dryingRackBlockEntity.updateListeners(); + } + } + } + } + + @Nullable + @Override + public Packet toUpdatePacket() { + return BlockEntityUpdateS2CPacket.of(this); + } + + public DefaultedList getItemsBeingDried() { + return this.itemsBeingDried; + } + + public ItemStack getDriedItem() { + ItemStack stack; + for (int i = 0; i < this.itemsBeingDried.size(); ++i) { + if (this.dryingTimes[i] >= this.dryingTotalTimes[i]) { + stack = this.itemsBeingDried.get(i); + if (!stack.isEmpty()) { + this.itemsBeingDried.set(i, ItemStack.EMPTY); + this.updateListeners(); + return stack; + } + } + } + + for (int i = 0; i < this.itemsBeingDried.size(); ++i) { + stack = this.itemsBeingDried.get(i); + if (!stack.isEmpty()) { + this.itemsBeingDried.set(i, ItemStack.EMPTY); + this.updateListeners(); + return stack; + } + } + + return ItemStack.EMPTY; + } + + @Override + public void readNbt(NbtCompound nbt) { + this.itemsBeingDried.clear(); + Inventories.readNbt(nbt, this.itemsBeingDried); + int[] js; + if (nbt.contains("DryingTimes", 11)) { + js = nbt.getIntArray("DryingTimes"); + System.arraycopy(js, 0, this.dryingTimes, 0, Math.min(this.dryingTotalTimes.length, js.length)); + } + } + + @Override + public void writeNbt(NbtCompound nbt) { + this.saveInitialChunkData(nbt); + nbt.putIntArray("DryingTimes", this.dryingTimes); + nbt.putIntArray("DryingTotalTimes", this.dryingTotalTimes); + } + + private NbtCompound saveInitialChunkData(NbtCompound tag) { + Inventories.writeNbt(tag, this.itemsBeingDried, true); + return tag; + } + + @Override + public NbtCompound toInitialChunkDataNbt() { + return this.saveInitialChunkData(new NbtCompound()); + } + + @SuppressWarnings("ConstantConditions") + public Optional getRecipeFor(ItemStack item) { + return this.itemsBeingDried.stream().noneMatch(ItemStack::isEmpty) ? Optional.empty() : this.world.getRecipeManager().getFirstMatch(AlaskaRecipes.DRYING, new SimpleInventory(item), this.world); + } + + public boolean addItem(ItemStack item, int integer) { + for (int i = 0; i < this.itemsBeingDried.size(); ++i) { + ItemStack itemStack = this.itemsBeingDried.get(i); + if (itemStack.isEmpty()) { + this.dryingTotalTimes[i] = integer; + this.dryingTimes[i] = 0; + this.itemsBeingDried.set(i, item.split(1)); + this.updateListeners(); + return true; + } + } + + return false; + } + + @SuppressWarnings("ConstantConditions") + private void updateListeners() { + this.markDirty(); + this.getWorld().updateListeners(this.getPos(), this.getCachedState(), this.getCachedState(), 3); + } + + @Override + public void clear() { + this.itemsBeingDried.clear(); + } + + public void spawnItemsBeingDried() { + if (this.world != null) { + if (!this.world.isClient) { + ItemScatterer.spawn(this.world, this.getPos(), this.getItemsBeingDried()); + } + + this.updateListeners(); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java index cc8d6cd6..6aadf67a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/AlaskaModels.java @@ -6,34 +6,35 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; -import net.minecraft.client.render.entity.model.EntityModelLayer; -import net.minecraft.util.Identifier; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import net.minecraft.client.render.entity.model.EntityModelLayer; +import net.minecraft.util.Identifier; + @Environment(EnvType.CLIENT) public class AlaskaModels { - public static final EntityModelLayer PTARMIGAN = registerMain("ptarmigan"); - public static final EntityModelLayer DOGSLED = registerMain("dogsled"); - public static final EntityModelLayer HARPOON = registerMain("harpoon"); - public static final EntityModelLayer MOOSE = registerMain("moose"); - public static final EntityModelLayer SEAL = registerMain("seal"); - public static final EntityModelLayer KUSPUK_SKIRT = registerMain("kuspuk_skirt"); - public static final EntityModelLayer SNOWSHOES = registerMain("snowshoes"); + public static final EntityModelLayer PTARMIGAN = registerMain("ptarmigan"); + public static final EntityModelLayer DOGSLED = registerMain("dogsled"); + public static final EntityModelLayer HARPOON = registerMain("harpoon"); + public static final EntityModelLayer MOOSE = registerMain("moose"); + public static final EntityModelLayer SEAL = registerMain("seal"); + public static final EntityModelLayer KUSPUK_SKIRT = registerMain("kuspuk_skirt"); + public static final EntityModelLayer SNOWSHOES = registerMain("snowshoes"); - @Contract("_ -> new") - private static @NotNull EntityModelLayer registerMain(String id) { - return new EntityModelLayer(new Identifier(AlaskaNativeCraft.MOD_ID, id), "main"); - } + @Contract("_ -> new") + private static @NotNull EntityModelLayer registerMain(String id) { + return new EntityModelLayer(new Identifier(AlaskaNativeCraft.MOD_ID, id), "main"); + } - @Environment(EnvType.CLIENT) - public static void registerEntityModels() { - EntityModelLayerRegistry.registerModelLayer(PTARMIGAN, PtarmiganEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(DOGSLED, DogsledEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(HARPOON, HarpoonEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(MOOSE, MooseEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(SEAL, SealEntityModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(KUSPUK_SKIRT, KuspukSkirtModel::getTexturedModelData); - EntityModelLayerRegistry.registerModelLayer(SNOWSHOES, SnowshoeModel::getTexturedModelData); - } + @Environment(EnvType.CLIENT) + public static void registerEntityModels() { + EntityModelLayerRegistry.registerModelLayer(PTARMIGAN, PtarmiganEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(DOGSLED, DogsledEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(HARPOON, HarpoonEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(MOOSE, MooseEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(SEAL, SealEntityModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(KUSPUK_SKIRT, KuspukSkirtModel::getTexturedModelData); + EntityModelLayerRegistry.registerModelLayer(SNOWSHOES, SnowshoeModel::getTexturedModelData); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java index 4d3470a5..452d4c68 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/DogsledEntityModel.java @@ -2,101 +2,108 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.NotNull; + import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.model.*; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.CompositeEntityModel; import net.minecraft.client.util.math.MatrixStack; -import org.jetbrains.annotations.NotNull; public class DogsledEntityModel extends CompositeEntityModel { - private final ModelPart frame; - private final ImmutableList parts; - - public DogsledEntityModel(@NotNull ModelPart modelPart) { - frame = modelPart.getChild("frame"); - ModelPart leftRunner = modelPart.getChild("leftRunner"); - ModelPart rightRunner = modelPart.getChild("rightRunner"); - - ImmutableList.Builder builder = ImmutableList.builder(); - builder.add(this.frame).add(leftRunner).add(rightRunner); - this.parts = builder.build(); - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - - ModelPartData frame = modelPartData.addChild("frame", ModelPartBuilder.create() - .uv(20, 18) - .cuboid(-5.0F, -9.0F, -18.0F, 10.0F, 1.0F, 1.0F) - .uv(0, 0) - .cuboid(-4.0F, -9.0F, -17.0F, 8.0F, 1.0F, 17.0F) - .uv(0, 18) - .cuboid(-4.0f, -14.0f, -1.0f, 8.0f, 1.0f, 1.0f), - ModelTransform.pivot(0.0f, 24.0f, 3.0f)); - - ModelPartData leftRunner = modelPartData.addChild("leftRunner", ModelPartBuilder.create() - .uv(0, 18) - .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F) - .uv(0, 0) - .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F) - .uv(0, 20) - .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F) - .uv(20, 20) - .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f), - ModelTransform.pivot(5.0f, 0.0f, 0.0f)); - - leftRunner.addChild("cube_r1", ModelPartBuilder.create() - .uv(29, 30) - .cuboid(-0.999f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f), - ModelTransform.of(0.0f, -10.0f, 2.0f, - 0.6109f, 0.0f, 0.0f)); - - leftRunner.addChild("cube_r2", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-0.499f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f), - ModelTransform.of(-0.5f, 0.0f, -9.0f, - -0.6109f, 0.0f, 0.0f)); - - ModelPartData rightRunner = modelPartData.addChild("rightRunner", ModelPartBuilder.create() - .uv(0, 18) - .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F) - .uv(0, 0) - .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F) - .uv(0, 20) - .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F) - .uv(20, 20) - .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f), - ModelTransform.pivot(-4.0f, 0.0f, 0.0f)); - - rightRunner.addChild("cube_r3", ModelPartBuilder.create() - .uv(29, 30) - .cuboid(-1.001f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f), - ModelTransform.of(0.0f, -10.0f, 2.0f, - 0.6109f, 0.0f, 0.0f)); - - rightRunner.addChild("cube_r4", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-0.501f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f), - ModelTransform.of(-0.5f, 0.0f, -9.0f, - -0.6109f, 0.0f, 0.0f)); - - return TexturedModelData.of(modelData, 64, 64); - } - - @Override - public void setAngles(DogsledEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - this.frame.pivotY = 4.0F - animationProgress; - } - - @Override - public ImmutableList getParts() { - return this.parts; - } - - @Override - public void render(@NotNull MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { - matrices.translate(0.0F, 0.0F, 0.3F); - super.render(matrices, vertices, light, overlay, red, green, blue, alpha); - } -} \ No newline at end of file + private final ModelPart frame; + private final ImmutableList parts; + + public DogsledEntityModel(@NotNull ModelPart modelPart) { + this.frame = modelPart.getChild("frame"); + ModelPart leftRunner = modelPart.getChild("leftRunner"); + ModelPart rightRunner = modelPart.getChild("rightRunner"); + + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(this.frame).add(leftRunner).add(rightRunner); + this.parts = builder.build(); + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData modelPartData = modelData.getRoot(); + + ModelPartData frame = modelPartData.addChild("frame", ModelPartBuilder.create() + .uv(20, 18) + .cuboid(-5.0F, -9.0F, -18.0F, 10.0F, 1.0F, 1.0F) + .uv(0, 0) + .cuboid(-4.0F, -9.0F, -17.0F, 8.0F, 1.0F, 17.0F) + .uv(0, 18) + .cuboid(-4.0f, -14.0f, -1.0f, 8.0f, 1.0f, 1.0f), + ModelTransform.pivot(0.0f, 24.0f, 3.0f)); + + ModelPartData leftRunner = modelPartData.addChild("leftRunner", ModelPartBuilder.create() + .uv(0, 18) + .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F) + .uv(0, 0) + .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F) + .uv(0, 20) + .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F) + .uv(20, 20) + .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f), + ModelTransform.pivot(5.0f, 0.0f, 0.0f)); + + leftRunner.addChild("cube_r1", ModelPartBuilder.create() + .uv(29, 30) + .cuboid(-0.999f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f), + ModelTransform.of(0.0f, -10.0f, 2.0f, + 0.6109f, 0.0f, 0.0f)); + + leftRunner.addChild("cube_r2", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-0.499f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f), + ModelTransform.of(-0.5f, 0.0f, -9.0f, + -0.6109f, 0.0f, 0.0f)); + + ModelPartData rightRunner = modelPartData.addChild("rightRunner", ModelPartBuilder.create() + .uv(0, 18) + .cuboid(-1.0F, -1.0F, -9.0F, 1.0F, 1.0F, 18.0F) + .uv(0, 0) + .cuboid(-1.0F, -5.0F, -5.0F, 1.0F, 4.0F, 1.0F) + .uv(0, 20) + .cuboid(-1.0F, -10.0F, 2.0F, 1.0F, 9.0F, 1.0F) + .uv(20, 20) + .cuboid(-1.0f, -5.0f, -14.0f, 1.0f, 1.0f, 9.0f), + ModelTransform.pivot(-4.0f, 0.0f, 0.0f)); + + rightRunner.addChild("cube_r3", ModelPartBuilder.create() + .uv(29, 30) + .cuboid(-1.001f, 0.0f, -9.0f, 1.0f, 1.0f, 9.0f), + ModelTransform.of(0.0f, -10.0f, 2.0f, + 0.6109f, 0.0f, 0.0f)); + + rightRunner.addChild("cube_r4", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-0.501f, -1.0f, -7.0f, 1.0f, 1.0f, 7.0f), + ModelTransform.of(-0.5f, 0.0f, -9.0f, + -0.6109f, 0.0f, 0.0f)); + + return TexturedModelData.of(modelData, 64, 64); + } + + @Override + public void setAngles(DogsledEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + this.frame.pivotY = 4.0F - animationProgress; + } + + @Override + public ImmutableList getParts() { + return this.parts; + } + + @Override + public void render(@NotNull MatrixStack matrices, VertexConsumer vertices, int light, int overlay, float red, float green, float blue, float alpha) { + matrices.translate(0.0F, 0.0F, 0.3F); + super.render(matrices, vertices, light, overlay, red, green, blue, alpha); + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java index 6a607fd4..a3f9cb60 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/HarpoonEntityModel.java @@ -1,59 +1,64 @@ package com.github.platymemo.alaskanativecraft.client.model.entity; import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity; -import net.minecraft.client.model.*; -import net.minecraft.client.render.entity.model.SinglePartEntityModel; import org.jetbrains.annotations.NotNull; +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; +import net.minecraft.client.render.entity.model.SinglePartEntityModel; + public class HarpoonEntityModel extends SinglePartEntityModel { - private static final String BODY = "body"; - private static final String TIP = "tip"; - private static final String WRAP = "wrap"; - private static final String PRONG = "prong"; - private final ModelPart root; - - public HarpoonEntityModel(ModelPart root) { - this.root = root; - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData root = modelData.getRoot(); - root.addChild(BODY, - ModelPartBuilder.create() - .uv(0, 0) - .cuboid(6.0F, -19.0F, -8.0F, 1.0F, 27.0F, 1.0F), - ModelTransform.pivot(-6.0F, 16.0F, 7.0F) - ); - root.addChild(WRAP, - ModelPartBuilder.create() - .uv(4, 4) - .cuboid(6.0F, -20.0F, -9.0F, 1.0F, 1.0F, 2.0F), - ModelTransform.pivot(-6.0F, 16.0F, 7.0F) - ); - root.addChild(PRONG, - ModelPartBuilder.create() - .uv(4, 0) - .cuboid(6.0F, -19.0F, -10.0F, 1.0F, 2.0F, 1.0F), - ModelTransform.pivot(-6.0F, 16.0F, 7.0F) - ); - root.addChild(TIP, - ModelPartBuilder.create() - .uv(4, 0) - .cuboid(6.0F, -23.0F, -8.0F, 1.0F, 3.0F, 1.0F), - ModelTransform.pivot(-6.0F, 16.0F, 7.0F) - ); - - return TexturedModelData.of(modelData, 32, 32); - } - - @Override - public ModelPart getPart() { - return root; - } - - @Override - public void setAngles(HarpoonEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - - } -} \ No newline at end of file + private static final String BODY = "body"; + private static final String TIP = "tip"; + private static final String WRAP = "wrap"; + private static final String PRONG = "prong"; + private final ModelPart root; + + public HarpoonEntityModel(ModelPart root) { + this.root = root; + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData root = modelData.getRoot(); + root.addChild(BODY, + ModelPartBuilder.create() + .uv(0, 0) + .cuboid(6.0F, -19.0F, -8.0F, 1.0F, 27.0F, 1.0F), + ModelTransform.pivot(-6.0F, 16.0F, 7.0F) + ); + root.addChild(WRAP, + ModelPartBuilder.create() + .uv(4, 4) + .cuboid(6.0F, -20.0F, -9.0F, 1.0F, 1.0F, 2.0F), + ModelTransform.pivot(-6.0F, 16.0F, 7.0F) + ); + root.addChild(PRONG, + ModelPartBuilder.create() + .uv(4, 0) + .cuboid(6.0F, -19.0F, -10.0F, 1.0F, 2.0F, 1.0F), + ModelTransform.pivot(-6.0F, 16.0F, 7.0F) + ); + root.addChild(TIP, + ModelPartBuilder.create() + .uv(4, 0) + .cuboid(6.0F, -23.0F, -8.0F, 1.0F, 3.0F, 1.0F), + ModelTransform.pivot(-6.0F, 16.0F, 7.0F) + ); + + return TexturedModelData.of(modelData, 32, 32); + } + + @Override + public ModelPart getPart() { + return this.root; + } + + @Override + public void setAngles(HarpoonEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java index 83afdbb6..1d993bc0 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/MooseEntityModel.java @@ -2,177 +2,183 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.model.*; +import org.jetbrains.annotations.NotNull; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.QuadrupedEntityModel; import net.minecraft.entity.Entity; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class MooseEntityModel extends QuadrupedEntityModel { - public MooseEntityModel(ModelPart root) { - super(root, true, 14.0F, 3.0F, 2.0F, 2.0F, 24); - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - ModelPartData body = modelPartData.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create() - .uv(0, 25) - .cuboid(-3.5F, -5.0F, -11.0F, 7.0F, 10.0F, 9.0F) - .uv(0, 0) - .cuboid(-3.5F, -4.0F, -2.0F, 7.0F, 9.0F, 16.0F) - .uv(42, 11) - .cuboid(-1.0f, -3.0f, 14.0f, 2.0f, 3.0f, 1.0f), - ModelTransform.pivot(0.5f, 7.0f, 0.0f)); - - body.addChild("hump", ModelPartBuilder.create() - .uv(30, 0) - .cuboid(-3.0f, -6.0f, -10.0f, 6.0f, 4.0f, 7.0f), - ModelTransform.of(0.0f, 2.0f, -1.8f, - -0.4363f, 0.0f, 0.0f)); - - modelPartData.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create() - .uv(0, 1) - .cuboid(-1.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F) - .uv(52, 30) - .cuboid(0.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f), - ModelTransform.pivot(4.0f, 6.0f, 9.0f)); - - modelPartData.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create() - .uv(0, 1) - .cuboid(-2.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F) - .uv(52, 30) - .cuboid(-2.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f), - ModelTransform.pivot(-3.0f, 6.0f, 9.0f)); - - modelPartData.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create() - .uv(0, 1) - .cuboid(-1.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F) - .uv(52, 30) - .cuboid(0.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f), - ModelTransform.pivot(4.0f, 6.0f, -6.0f)); - - modelPartData.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create() - .uv(0, 1) - .cuboid(-2.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F) - .uv(52, 30) - .cuboid(-2.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f), - ModelTransform.pivot(-3.0f, 6.0f, -6.0f)); - - ModelPartData head = modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create() - .uv(0, 0), - ModelTransform.pivot(0.5f, 6.5f, -8.0f)); - - head.addChild("snout", ModelPartBuilder.create() - .uv(46, 12) - .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 3.0f), - ModelTransform.of(-0.5f, -1.8f, -11.8f, - 0.6109f, 0.0f, 0.0f)); - - head.addChild(EntityModelPartNames.NOSE, ModelPartBuilder.create() - .uv(23, 25) - .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 4.0f), - ModelTransform.of(-0.5f, -1.6f, -10.0f, - 0.1745f, 0.0f, 0.0f)); - - head.addChild("headBase", ModelPartBuilder.create() - .uv(41, 20) - .cuboid(-2.0f, -2.0f, -2.0f, 5.0f, 5.0f, 5.0f), - ModelTransform.of(-0.5f, -2.0f, -8.0f, - 0.5236f, 0.0f, 0.0f)); - - ModelPartData leftAntler = head.addChild("leftAntler", ModelPartBuilder.create() - .uv(0, 0), - ModelTransform.pivot(2.5f, -4.0f, -6.5f)); - - leftAntler.addChild("leftAntlerProng3", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(4.3f, -0.8f, -0.6f, - -0.6116f, -0.0114f, 0.1304f)); - - leftAntler.addChild("leftAntlerProng2", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(3.3f, -0.6f, -0.4f, - -0.6106f, 0.0907f, -0.0358f)); - - leftAntler.addChild("leftAntlerProng1", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(2.3f, -0.6f, -0.4f, - -0.6979f, -0.0831f, -0.0511f)); - - leftAntler.addChild("leftAntlerSideProng", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f), - ModelTransform.of(4.5f, -0.1f, -0.7f, - 0.0756f, -0.0436f, 0.5219f)); - - leftAntler.addChild("leftAntlerFrontProng", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f), - ModelTransform.of(3.7f, -0.1f, -0.7f, - 0.8782f, 0.3477f, 0.0317f)); - - leftAntler.addChild("leftAntlerBase", ModelPartBuilder.create() - .uv(30, 11) - .cuboid(-1.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f), - ModelTransform.of(0.5f, 0.4f, -0.7f, - -0.1309f, 0.0f, -0.1745f)); - - ModelPartData rightAntler = head.addChild("rightAntler", ModelPartBuilder.create() - .uv(0, 0), - ModelTransform.pivot(-2.5f, -4.0f, -6.5f)); - - rightAntler.addChild("rightAntlerProng3", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(-4.3f, -0.8f, -0.6f, - -0.6116f, 0.0114f, -0.1304f)); - - rightAntler.addChild("rightAntlerProng2", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(-3.3f, -0.6f, -0.4f, - -0.6106f, -0.0907f, 0.0358f)); - - rightAntler.addChild("rightAntlerProng1", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), - ModelTransform.of(-2.3f, -0.6f, -0.4f, - -0.6979f, 0.0831f, 0.0511f)); - - rightAntler.addChild("rightAntlerSideProng", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(0.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f), - ModelTransform.of(-4.5f, -0.1f, -0.7f, - 0.0756f, 0.0436f, -0.5219f)); - - rightAntler.addChild("rightAntlerFrontProng", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(0.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f), - ModelTransform.of(-3.7f, -0.1f, -0.7f, - 0.8782f, -0.3477f, -0.0317f)); - - rightAntler.addChild("rightAntlerBase", ModelPartBuilder.create() - .uv(30, 11) - .cuboid(-4.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f), - ModelTransform.of(-0.5f, 0.4f, -0.7f, - -0.1309f, 0.0f, 0.1745f)); - - ModelPartData neck = head.addChild(EntityModelPartNames.NECK, ModelPartBuilder.create() - .uv(32, 32) - .cuboid(-1.5f, -2.5f, -7.0f, 3.0f, 5.0f, 7.0f), - ModelTransform.of(0.0f, 0.0f, 0.0f, - -0.2182f, 0.0f, 0.0f)); - - neck.addChild("dewlap", ModelPartBuilder.create() - .uv(0, 21) - .cuboid(1.0f, -3.0f, -2.0f, 0.0f, 6.0f, 4.0f), - ModelTransform.pivot(-0.5f, 5.3817f, -4.3128f)); - - return TexturedModelData.of(modelData, 64, 64); - } -} \ No newline at end of file + public MooseEntityModel(ModelPart root) { + super(root, true, 14.0F, 3.0F, 2.0F, 2.0F, 24); + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData modelPartData = modelData.getRoot(); + ModelPartData body = modelPartData.addChild(EntityModelPartNames.BODY, ModelPartBuilder.create() + .uv(0, 25) + .cuboid(-3.5F, -5.0F, -11.0F, 7.0F, 10.0F, 9.0F) + .uv(0, 0) + .cuboid(-3.5F, -4.0F, -2.0F, 7.0F, 9.0F, 16.0F) + .uv(42, 11) + .cuboid(-1.0f, -3.0f, 14.0f, 2.0f, 3.0f, 1.0f), + ModelTransform.pivot(0.5f, 7.0f, 0.0f)); + + body.addChild("hump", ModelPartBuilder.create() + .uv(30, 0) + .cuboid(-3.0f, -6.0f, -10.0f, 6.0f, 4.0f, 7.0f), + ModelTransform.of(0.0f, 2.0f, -1.8f, + -0.4363f, 0.0f, 0.0f)); + + modelPartData.addChild(EntityModelPartNames.LEFT_HIND_LEG, ModelPartBuilder.create() + .uv(0, 1) + .cuboid(-1.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F) + .uv(52, 30) + .cuboid(0.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f), + ModelTransform.pivot(4.0f, 6.0f, 9.0f)); + + modelPartData.addChild(EntityModelPartNames.RIGHT_HIND_LEG, ModelPartBuilder.create() + .uv(0, 1) + .cuboid(-2.0F, -2.0F, -2.0F, 3.0F, 8.0F, 5.0F) + .uv(52, 30) + .cuboid(-2.0f, 6.0f, -1.0f, 2.0f, 12.0f, 3.0f), + ModelTransform.pivot(-3.0f, 6.0f, 9.0f)); + + modelPartData.addChild(EntityModelPartNames.LEFT_FRONT_LEG, ModelPartBuilder.create() + .uv(0, 1) + .cuboid(-1.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F) + .uv(52, 30) + .cuboid(0.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f), + ModelTransform.pivot(4.0f, 6.0f, -6.0f)); + + modelPartData.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, ModelPartBuilder.create() + .uv(0, 1) + .cuboid(-2.0F, -2.0F, -3.0F, 3.0F, 8.0F, 5.0F) + .uv(52, 30) + .cuboid(-2.0f, 6.0f, -2.0f, 2.0f, 12.0f, 3.0f), + ModelTransform.pivot(-3.0f, 6.0f, -6.0f)); + + ModelPartData head = modelPartData.addChild(EntityModelPartNames.HEAD, ModelPartBuilder.create() + .uv(0, 0), + ModelTransform.pivot(0.5f, 6.5f, -8.0f)); + + head.addChild("snout", ModelPartBuilder.create() + .uv(46, 12) + .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 3.0f), + ModelTransform.of(-0.5f, -1.8f, -11.8f, + 0.6109f, 0.0f, 0.0f)); + + head.addChild(EntityModelPartNames.NOSE, ModelPartBuilder.create() + .uv(23, 25) + .cuboid(-1.0f, -1.6736f, -2.9848f, 3.0f, 3.0f, 4.0f), + ModelTransform.of(-0.5f, -1.6f, -10.0f, + 0.1745f, 0.0f, 0.0f)); + + head.addChild("headBase", ModelPartBuilder.create() + .uv(41, 20) + .cuboid(-2.0f, -2.0f, -2.0f, 5.0f, 5.0f, 5.0f), + ModelTransform.of(-0.5f, -2.0f, -8.0f, + 0.5236f, 0.0f, 0.0f)); + + ModelPartData leftAntler = head.addChild("leftAntler", ModelPartBuilder.create() + .uv(0, 0), + ModelTransform.pivot(2.5f, -4.0f, -6.5f)); + + leftAntler.addChild("leftAntlerProng3", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(4.3f, -0.8f, -0.6f, + -0.6116f, -0.0114f, 0.1304f)); + + leftAntler.addChild("leftAntlerProng2", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(3.3f, -0.6f, -0.4f, + -0.6106f, 0.0907f, -0.0358f)); + + leftAntler.addChild("leftAntlerProng1", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(2.3f, -0.6f, -0.4f, + -0.6979f, -0.0831f, -0.0511f)); + + leftAntler.addChild("leftAntlerSideProng", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f), + ModelTransform.of(4.5f, -0.1f, -0.7f, + 0.0756f, -0.0436f, 0.5219f)); + + leftAntler.addChild("leftAntlerFrontProng", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f), + ModelTransform.of(3.7f, -0.1f, -0.7f, + 0.8782f, 0.3477f, 0.0317f)); + + leftAntler.addChild("leftAntlerBase", ModelPartBuilder.create() + .uv(30, 11) + .cuboid(-1.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f), + ModelTransform.of(0.5f, 0.4f, -0.7f, + -0.1309f, 0.0f, -0.1745f)); + + ModelPartData rightAntler = head.addChild("rightAntler", ModelPartBuilder.create() + .uv(0, 0), + ModelTransform.pivot(-2.5f, -4.0f, -6.5f)); + + rightAntler.addChild("rightAntlerProng3", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(-4.3f, -0.8f, -0.6f, + -0.6116f, 0.0114f, -0.1304f)); + + rightAntler.addChild("rightAntlerProng2", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(-3.3f, -0.6f, -0.4f, + -0.6106f, -0.0907f, 0.0358f)); + + rightAntler.addChild("rightAntlerProng1", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(0.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f), + ModelTransform.of(-2.3f, -0.6f, -0.4f, + -0.6979f, 0.0831f, 0.0511f)); + + rightAntler.addChild("rightAntlerSideProng", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(0.0f, -4.0f, 0.0f, 1.0f, 4.0f, 1.0f), + ModelTransform.of(-4.5f, -0.1f, -0.7f, + 0.0756f, 0.0436f, -0.5219f)); + + rightAntler.addChild("rightAntlerFrontProng", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(0.0f, -3.0f, 0.0f, 1.0f, 3.0f, 1.0f), + ModelTransform.of(-3.7f, -0.1f, -0.7f, + 0.8782f, -0.3477f, -0.0317f)); + + rightAntler.addChild("rightAntlerBase", ModelPartBuilder.create() + .uv(30, 11) + .cuboid(-4.0f, -1.0f, 0.0f, 5.0f, 1.0f, 1.0f), + ModelTransform.of(-0.5f, 0.4f, -0.7f, + -0.1309f, 0.0f, 0.1745f)); + + ModelPartData neck = head.addChild(EntityModelPartNames.NECK, ModelPartBuilder.create() + .uv(32, 32) + .cuboid(-1.5f, -2.5f, -7.0f, 3.0f, 5.0f, 7.0f), + ModelTransform.of(0.0f, 0.0f, 0.0f, + -0.2182f, 0.0f, 0.0f)); + + neck.addChild("dewlap", ModelPartBuilder.create() + .uv(0, 21) + .cuboid(1.0f, -3.0f, -2.0f, 0.0f, 6.0f, 4.0f), + ModelTransform.pivot(-0.5f, 5.3817f, -4.3128f)); + + return TexturedModelData.of(modelData, 64, 64); + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java index c8fcc3da..95cfbdec 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/PtarmiganEntityModel.java @@ -1,215 +1,220 @@ package com.github.platymemo.alaskanativecraft.client.model.entity; import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.model.*; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.SinglePartEntityModel; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.MathHelper; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class PtarmiganEntityModel extends SinglePartEntityModel { - private final ModelPart root; - private final ModelPart body; - private final ModelPart tail; - private final ModelPart leftWing; - private final ModelPart rightWing; - private final ModelPart head; - private final ModelPart leftLeg; - private final ModelPart rightLeg; - - public PtarmiganEntityModel(@NotNull ModelPart root) { - this.root = root; - this.body = root.getChild(EntityModelPartNames.BODY); - this.tail = root.getChild(EntityModelPartNames.TAIL); - this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING); - this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING); - this.head = root.getChild(EntityModelPartNames.HEAD); - this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG); - this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG); - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData root = modelData.getRoot(); - root.addChild(EntityModelPartNames.BODY, - ModelPartBuilder.create() - .uv(0, 7) - .cuboid(-2.5F, 0.0F, -2.5F, 5.0F, 6.0F, 5.0F), - ModelTransform.pivot(0.0F, 16.5F, -3.0F) - ); - root.addChild(EntityModelPartNames.TAIL, - ModelPartBuilder.create() - .uv(24, 0) - .cuboid(-1.5F, -1.0F, 0.0F, 3.0F, 4.0F, 1.0F), - ModelTransform.pivot(0.0F, 21.07F, 1.16F) - ); - root.addChild(EntityModelPartNames.LEFT_WING, - ModelPartBuilder.create() - .uv(2, 22) - .cuboid(-2.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F), - ModelTransform.pivot(2.5F, 16.94F, -2.76F) - ); - root.addChild(EntityModelPartNames.RIGHT_WING, - ModelPartBuilder.create() - .uv(2, 22) - .cuboid(1.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F), - ModelTransform.pivot(-2.5F, 16.94F, -2.76F) - ); - ModelPartData head = root.addChild(EntityModelPartNames.HEAD, - ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-1.0F, -1.5F, -1.0F, 2.0F, 3.0F, 2.0F), - ModelTransform.pivot(0.0F, 15.69F, -2.76F) - ); - head.addChild("beak", - ModelPartBuilder.create() - .uv(9, 0) - .cuboid(-0.5F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F), - ModelTransform.pivot(0.0F, -0.5F, -1.5F) - ); - - ModelPartBuilder legBuilder = ModelPartBuilder.create().uv(14, 24).cuboid(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F); - root.addChild(EntityModelPartNames.LEFT_LEG, legBuilder, ModelTransform.pivot(1.0F, 22.0F, -1.05F)); - root.addChild(EntityModelPartNames.RIGHT_LEG, legBuilder, ModelTransform.pivot(-1.0F, 22.0F, -1.05F)); - - return TexturedModelData.of(modelData, 32, 32); - } - - private static PtarmiganEntityModel.Pose getPose(@NotNull PtarmiganEntity ptarmigan) { - if (ptarmigan.isSongPlaying()) { - return PtarmiganEntityModel.Pose.PARTY; - } else if (ptarmigan.isInSittingPose()) { - return PtarmiganEntityModel.Pose.SITTING; - } else { - return ptarmigan.isInAir() ? PtarmiganEntityModel.Pose.FLYING : PtarmiganEntityModel.Pose.STANDING; - } - } - - @Override - public ModelPart getPart() { - return this.root; - } - - @Override - public void setAngles(PtarmiganEntity ptarmiganEntity, float f, float g, float h, float i, float j) { - this.setAngles(getPose(ptarmiganEntity), ptarmiganEntity.age, f, g, h, i, j); - } - - @Override - public void animateModel(PtarmiganEntity ptarmiganEntity, float f, float g, float h) { - this.animateModel(getPose(ptarmiganEntity)); - } - - public void poseOnShoulder(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float limbAngle, float limbDistance, float headYaw, float headPitch, int danceAngle) { - this.animateModel(PtarmiganEntityModel.Pose.ON_SHOULDER); - this.setAngles(PtarmiganEntityModel.Pose.ON_SHOULDER, danceAngle, limbAngle, limbDistance, 0.0F, headYaw, headPitch); - this.root.render(matrices, vertexConsumer, light, overlay); - } - - private void setAngles(@NotNull PtarmiganEntityModel.Pose pose, int danceAngle, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) { - this.head.pitch = headPitch * 0.017453292F; - this.head.yaw = headYaw * 0.017453292F; - this.head.roll = 0.0F; - this.head.pivotX = 0.0F; - this.body.pivotX = 0.0F; - this.tail.pivotX = 0.0F; - this.rightWing.pivotX = -1.5F; - this.leftWing.pivotX = 1.5F; - switch (pose) { - case SITTING: - break; - case PARTY: - float cosDanceAngle = MathHelper.cos((float) danceAngle); - float sinDanceAngle = MathHelper.sin((float) danceAngle); - this.head.pivotX = cosDanceAngle; - this.head.pivotY = 15.69F + sinDanceAngle; - this.head.pitch = 0.0F; - this.head.yaw = 0.0F; - this.head.roll = MathHelper.sin((float) danceAngle) * 0.4F; - this.body.pivotX = cosDanceAngle; - this.body.pivotY = 16.5F + sinDanceAngle; - this.leftWing.roll = -0.0873F - age; - this.leftWing.pivotX = 1.5F + cosDanceAngle; - this.leftWing.pivotY = 16.94F + sinDanceAngle; - this.rightWing.roll = 0.0873F + age; - this.rightWing.pivotX = -1.5F + cosDanceAngle; - this.rightWing.pivotY = 16.94F + sinDanceAngle; - this.tail.pivotX = cosDanceAngle; - this.tail.pivotY = 21.07F + sinDanceAngle; - break; - case STANDING: - this.leftLeg.pitch += MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance; - this.rightLeg.pitch += MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance; - case FLYING: - case ON_SHOULDER: - default: - float thirdOfAge = age * 0.3F; - this.head.pivotY = 15.69F + thirdOfAge; - this.tail.pitch = 1.015F + MathHelper.cos(limbAngle * 0.6662F) * 0.3F * limbDistance; - this.tail.pivotY = 21.07F + thirdOfAge; - this.body.pivotY = 16.5F + thirdOfAge; - this.leftWing.roll = -0.0873F - age; - this.leftWing.pivotY = 16.94F + thirdOfAge; - this.rightWing.roll = 0.0873F + age; - this.rightWing.pivotY = 16.94F + thirdOfAge; - this.leftLeg.pivotY = 22.0F + thirdOfAge; - this.rightLeg.pivotY = 22.0F + thirdOfAge; - } - - } - - private void animateModel(@NotNull PtarmiganEntityModel.Pose pose) { - this.body.pitch = 0.4937F; - this.leftWing.pitch = -0.6981F; - this.leftWing.yaw = -3.1415927F; - this.rightWing.pitch = -0.6981F; - this.rightWing.yaw = -3.1415927F; - this.leftLeg.pitch = -0.0299F; - this.rightLeg.pitch = -0.0299F; - this.leftLeg.pivotY = 22.0F; - this.rightLeg.pivotY = 22.0F; - this.leftLeg.roll = 0.0F; - this.rightLeg.roll = 0.0F; - switch (pose) { - case SITTING: - this.head.pivotY = 17.59F; - this.tail.pitch = 1.5388988F; - this.tail.pivotY = 22.97F; - this.body.pivotY = 18.4F; - this.leftWing.roll = -0.0873F; - this.leftWing.pivotY = 18.84F; - this.rightWing.roll = 0.0873F; - this.rightWing.pivotY = 18.84F; - ++this.leftLeg.pivotY; - ++this.rightLeg.pivotY; - ++this.leftLeg.pitch; - ++this.rightLeg.pitch; - break; - case PARTY: - this.leftLeg.roll = -0.34906584F; - this.rightLeg.roll = 0.34906584F; - case STANDING: - case ON_SHOULDER: - default: - break; - case FLYING: - this.leftLeg.pitch += 0.6981317F; - this.rightLeg.pitch += 0.6981317F; - } - - } - - @Environment(EnvType.CLIENT) - public enum Pose { - FLYING, - STANDING, - SITTING, - PARTY, - ON_SHOULDER - } + private final ModelPart root; + private final ModelPart body; + private final ModelPart tail; + private final ModelPart leftWing; + private final ModelPart rightWing; + private final ModelPart head; + private final ModelPart leftLeg; + private final ModelPart rightLeg; + + public PtarmiganEntityModel(@NotNull ModelPart root) { + this.root = root; + this.body = root.getChild(EntityModelPartNames.BODY); + this.tail = root.getChild(EntityModelPartNames.TAIL); + this.leftWing = root.getChild(EntityModelPartNames.LEFT_WING); + this.rightWing = root.getChild(EntityModelPartNames.RIGHT_WING); + this.head = root.getChild(EntityModelPartNames.HEAD); + this.leftLeg = root.getChild(EntityModelPartNames.LEFT_LEG); + this.rightLeg = root.getChild(EntityModelPartNames.RIGHT_LEG); + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData root = modelData.getRoot(); + root.addChild(EntityModelPartNames.BODY, + ModelPartBuilder.create() + .uv(0, 7) + .cuboid(-2.5F, 0.0F, -2.5F, 5.0F, 6.0F, 5.0F), + ModelTransform.pivot(0.0F, 16.5F, -3.0F) + ); + root.addChild(EntityModelPartNames.TAIL, + ModelPartBuilder.create() + .uv(24, 0) + .cuboid(-1.5F, -1.0F, 0.0F, 3.0F, 4.0F, 1.0F), + ModelTransform.pivot(0.0F, 21.07F, 1.16F) + ); + root.addChild(EntityModelPartNames.LEFT_WING, + ModelPartBuilder.create() + .uv(2, 22) + .cuboid(-2.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F), + ModelTransform.pivot(2.5F, 16.94F, -2.76F) + ); + root.addChild(EntityModelPartNames.RIGHT_WING, + ModelPartBuilder.create() + .uv(2, 22) + .cuboid(1.0F, 0.0F, -1.5F, 1.0F, 5.0F, 3.0F), + ModelTransform.pivot(-2.5F, 16.94F, -2.76F) + ); + ModelPartData head = root.addChild(EntityModelPartNames.HEAD, + ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-1.0F, -1.5F, -1.0F, 2.0F, 3.0F, 2.0F), + ModelTransform.pivot(0.0F, 15.69F, -2.76F) + ); + head.addChild("beak", + ModelPartBuilder.create() + .uv(9, 0) + .cuboid(-0.5F, -1.0F, -0.5F, 1.0F, 2.0F, 1.0F), + ModelTransform.pivot(0.0F, -0.5F, -1.5F) + ); + + ModelPartBuilder legBuilder = ModelPartBuilder.create().uv(14, 24).cuboid(-0.5F, 0.0F, -0.5F, 1.0F, 2.0F, 1.0F); + root.addChild(EntityModelPartNames.LEFT_LEG, legBuilder, ModelTransform.pivot(1.0F, 22.0F, -1.05F)); + root.addChild(EntityModelPartNames.RIGHT_LEG, legBuilder, ModelTransform.pivot(-1.0F, 22.0F, -1.05F)); + + return TexturedModelData.of(modelData, 32, 32); + } + + private static PtarmiganEntityModel.Pose getPose(@NotNull PtarmiganEntity ptarmigan) { + if (ptarmigan.isSongPlaying()) { + return PtarmiganEntityModel.Pose.PARTY; + } else if (ptarmigan.isInSittingPose()) { + return PtarmiganEntityModel.Pose.SITTING; + } else { + return ptarmigan.isInAir() ? PtarmiganEntityModel.Pose.FLYING : PtarmiganEntityModel.Pose.STANDING; + } + } + + @Override + public ModelPart getPart() { + return this.root; + } + + @Override + public void setAngles(PtarmiganEntity ptarmiganEntity, float f, float g, float h, float i, float j) { + this.setAngles(getPose(ptarmiganEntity), ptarmiganEntity.age, f, g, h, i, j); + } + + @Override + public void animateModel(PtarmiganEntity ptarmiganEntity, float f, float g, float h) { + this.animateModel(getPose(ptarmiganEntity)); + } + + public void poseOnShoulder(MatrixStack matrices, VertexConsumer vertexConsumer, int light, int overlay, float limbAngle, float limbDistance, float headYaw, float headPitch, int danceAngle) { + this.animateModel(PtarmiganEntityModel.Pose.ON_SHOULDER); + this.setAngles(PtarmiganEntityModel.Pose.ON_SHOULDER, danceAngle, limbAngle, limbDistance, 0.0F, headYaw, headPitch); + this.root.render(matrices, vertexConsumer, light, overlay); + } + + private void setAngles(@NotNull PtarmiganEntityModel.Pose pose, int danceAngle, float limbAngle, float limbDistance, float age, float headYaw, float headPitch) { + this.head.pitch = headPitch * 0.017453292F; + this.head.yaw = headYaw * 0.017453292F; + this.head.roll = 0.0F; + this.head.pivotX = 0.0F; + this.body.pivotX = 0.0F; + this.tail.pivotX = 0.0F; + this.rightWing.pivotX = -1.5F; + this.leftWing.pivotX = 1.5F; + switch (pose) { + case SITTING: + break; + case PARTY: + float cosDanceAngle = MathHelper.cos((float) danceAngle); + float sinDanceAngle = MathHelper.sin((float) danceAngle); + this.head.pivotX = cosDanceAngle; + this.head.pivotY = 15.69F + sinDanceAngle; + this.head.pitch = 0.0F; + this.head.yaw = 0.0F; + this.head.roll = MathHelper.sin((float) danceAngle) * 0.4F; + this.body.pivotX = cosDanceAngle; + this.body.pivotY = 16.5F + sinDanceAngle; + this.leftWing.roll = -0.0873F - age; + this.leftWing.pivotX = 1.5F + cosDanceAngle; + this.leftWing.pivotY = 16.94F + sinDanceAngle; + this.rightWing.roll = 0.0873F + age; + this.rightWing.pivotX = -1.5F + cosDanceAngle; + this.rightWing.pivotY = 16.94F + sinDanceAngle; + this.tail.pivotX = cosDanceAngle; + this.tail.pivotY = 21.07F + sinDanceAngle; + break; + case STANDING: + this.leftLeg.pitch += MathHelper.cos(limbAngle * 0.6662F) * 1.4F * limbDistance; + this.rightLeg.pitch += MathHelper.cos(limbAngle * 0.6662F + 3.1415927F) * 1.4F * limbDistance; + case FLYING: + case ON_SHOULDER: + default: + float thirdOfAge = age * 0.3F; + this.head.pivotY = 15.69F + thirdOfAge; + this.tail.pitch = 1.015F + MathHelper.cos(limbAngle * 0.6662F) * 0.3F * limbDistance; + this.tail.pivotY = 21.07F + thirdOfAge; + this.body.pivotY = 16.5F + thirdOfAge; + this.leftWing.roll = -0.0873F - age; + this.leftWing.pivotY = 16.94F + thirdOfAge; + this.rightWing.roll = 0.0873F + age; + this.rightWing.pivotY = 16.94F + thirdOfAge; + this.leftLeg.pivotY = 22.0F + thirdOfAge; + this.rightLeg.pivotY = 22.0F + thirdOfAge; + } + } + + private void animateModel(@NotNull PtarmiganEntityModel.Pose pose) { + this.body.pitch = 0.4937F; + this.leftWing.pitch = -0.6981F; + this.leftWing.yaw = -3.1415927F; + this.rightWing.pitch = -0.6981F; + this.rightWing.yaw = -3.1415927F; + this.leftLeg.pitch = -0.0299F; + this.rightLeg.pitch = -0.0299F; + this.leftLeg.pivotY = 22.0F; + this.rightLeg.pivotY = 22.0F; + this.leftLeg.roll = 0.0F; + this.rightLeg.roll = 0.0F; + switch (pose) { + case SITTING: + this.head.pivotY = 17.59F; + this.tail.pitch = 1.5388988F; + this.tail.pivotY = 22.97F; + this.body.pivotY = 18.4F; + this.leftWing.roll = -0.0873F; + this.leftWing.pivotY = 18.84F; + this.rightWing.roll = 0.0873F; + this.rightWing.pivotY = 18.84F; + ++this.leftLeg.pivotY; + ++this.rightLeg.pivotY; + ++this.leftLeg.pitch; + ++this.rightLeg.pitch; + break; + case PARTY: + this.leftLeg.roll = -0.34906584F; + this.rightLeg.roll = 0.34906584F; + case STANDING: + case ON_SHOULDER: + default: + break; + case FLYING: + this.leftLeg.pitch += 0.6981317F; + this.rightLeg.pitch += 0.6981317F; + } + } + + @Environment(EnvType.CLIENT) + public enum Pose { + FLYING, + STANDING, + SITTING, + PARTY, + ON_SHOULDER + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java index 0db739fb..b9fc1e36 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/SealEntityModel.java @@ -5,88 +5,94 @@ import com.google.common.collect.Iterables; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.model.*; +import org.jetbrains.annotations.NotNull; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.EntityModelPartNames; import net.minecraft.client.render.entity.model.QuadrupedEntityModel; import net.minecraft.util.math.MathHelper; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class SealEntityModel extends QuadrupedEntityModel { - public static final String STOMACH = "stomach"; - public static final String TAIL = "tail"; - protected final ModelPart stomach; - protected final ModelPart tail; + public static final String STOMACH = "stomach"; + public static final String TAIL = "tail"; + protected final ModelPart stomach; + protected final ModelPart tail; - public SealEntityModel(ModelPart root) { - super(root, true, 9.0F, 1.0F, 2.0F, 1.5F, 12); - stomach = root.getChild(STOMACH); - tail = root.getChild(TAIL); - } + public SealEntityModel(ModelPart root) { + super(root, true, 9.0F, 1.0F, 2.0F, 1.5F, 12); + this.stomach = root.getChild(STOMACH); + this.tail = root.getChild(TAIL); + } - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData root = modelData.getRoot(); - root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, - ModelPartBuilder.create().uv(38, 6).cuboid(-5.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F), - ModelTransform.of(-6.0F, 24.0F, -6.0F, 0.0F, -1.0F, 0.0F) - ); - root.addChild(EntityModelPartNames.LEFT_FRONT_LEG, - ModelPartBuilder.create().uv(32, 27).cuboid(0.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F), - ModelTransform.of(5.0F, 24.0F, -6.0F, 0.0F, 1.0F, 0.0F) - ); - root.addChild(EntityModelPartNames.RIGHT_HIND_LEG, - ModelPartBuilder.create().uv(30, 0).cuboid(-2.0F, 0.0F, -1.0F, 3.0F, 1.0F, 5.0F), - ModelTransform.pivot(-3.0F, 23.0F, 11.0F) - ); - root.addChild(EntityModelPartNames.LEFT_HIND_LEG, - ModelPartBuilder.create().uv(13, 38).cuboid(-1.0F, 0.0F, -1.1F, 3.0F, 1.0F, 5.0F), - ModelTransform.pivot(2.0F, 23.0F, 11.1F) - ); + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData root = modelData.getRoot(); + root.addChild(EntityModelPartNames.RIGHT_FRONT_LEG, + ModelPartBuilder.create().uv(38, 6).cuboid(-5.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F), + ModelTransform.of(-6.0F, 24.0F, -6.0F, 0.0F, -1.0F, 0.0F) + ); + root.addChild(EntityModelPartNames.LEFT_FRONT_LEG, + ModelPartBuilder.create().uv(32, 27).cuboid(0.0F, -1.0F, -1.0F, 5.0F, 1.0F, 3.0F), + ModelTransform.of(5.0F, 24.0F, -6.0F, 0.0F, 1.0F, 0.0F) + ); + root.addChild(EntityModelPartNames.RIGHT_HIND_LEG, + ModelPartBuilder.create().uv(30, 0).cuboid(-2.0F, 0.0F, -1.0F, 3.0F, 1.0F, 5.0F), + ModelTransform.pivot(-3.0F, 23.0F, 11.0F) + ); + root.addChild(EntityModelPartNames.LEFT_HIND_LEG, + ModelPartBuilder.create().uv(13, 38).cuboid(-1.0F, 0.0F, -1.1F, 3.0F, 1.0F, 5.0F), + ModelTransform.pivot(2.0F, 23.0F, 11.1F) + ); - root.addChild(EntityModelPartNames.HEAD, - ModelPartBuilder.create() - .uv(29, 31).cuboid(EntityModelPartNames.NECK, -4.5F, -5.0F, -3.0F, 9.0F, 9.0F, 3.0F) - .uv(32, 18).cuboid(-3.5F, -4.0F, -5.0F, 7.0F, 7.0F, 2.0F) - .uv(38, 10).cuboid(EntityModelPartNames.NOSE, -2.5F, -1.0F, -7.0F, 5.0F, 3.0F, 2.0F), - ModelTransform.pivot(-0.5F, 19.0F, -8.0F) - ); - root.addChild(EntityModelPartNames.BODY, - ModelPartBuilder.create().uv(0, 0).cuboid(-5.5F, -5.0F, -4.0F, 11.0F, 10.0F, 8.0F), - ModelTransform.pivot(-0.5F, 19.0F, -4.0F) - ); - root.addChild(STOMACH, - ModelPartBuilder.create().uv(0, 18).cuboid(-4.5F, -4.5F, -3.5F, 9.0F, 9.0F, 7.0F), - ModelTransform.pivot(-0.5F, 19.5F, 3.5F) - ); - root.addChild(TAIL, - ModelPartBuilder.create().uv(0, 34).cuboid(-2.5F, -2.5F, -2.0F, 5.0F, 5.0F, 4.0F), - ModelTransform.pivot(-0.5F, 21.0F, 9.0F) - ); - return TexturedModelData.of(modelData, 64, 64); - } + root.addChild(EntityModelPartNames.HEAD, + ModelPartBuilder.create() + .uv(29, 31).cuboid(EntityModelPartNames.NECK, -4.5F, -5.0F, -3.0F, 9.0F, 9.0F, 3.0F) + .uv(32, 18).cuboid(-3.5F, -4.0F, -5.0F, 7.0F, 7.0F, 2.0F) + .uv(38, 10).cuboid(EntityModelPartNames.NOSE, -2.5F, -1.0F, -7.0F, 5.0F, 3.0F, 2.0F), + ModelTransform.pivot(-0.5F, 19.0F, -8.0F) + ); + root.addChild(EntityModelPartNames.BODY, + ModelPartBuilder.create().uv(0, 0).cuboid(-5.5F, -5.0F, -4.0F, 11.0F, 10.0F, 8.0F), + ModelTransform.pivot(-0.5F, 19.0F, -4.0F) + ); + root.addChild(STOMACH, + ModelPartBuilder.create().uv(0, 18).cuboid(-4.5F, -4.5F, -3.5F, 9.0F, 9.0F, 7.0F), + ModelTransform.pivot(-0.5F, 19.5F, 3.5F) + ); + root.addChild(TAIL, + ModelPartBuilder.create().uv(0, 34).cuboid(-2.5F, -2.5F, -2.0F, 5.0F, 5.0F, 4.0F), + ModelTransform.pivot(-0.5F, 21.0F, 9.0F) + ); + return TexturedModelData.of(modelData, 64, 64); + } - @Override - protected Iterable getBodyParts() { - return Iterables.concat(super.getBodyParts(), ImmutableList.of(this.stomach), ImmutableList.of(this.tail)); - } + @Override + protected Iterable getBodyParts() { + return Iterables.concat(super.getBodyParts(), ImmutableList.of(this.stomach), ImmutableList.of(this.tail)); + } - @Override - public void setAngles(@NotNull T sealEntity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - this.head.pitch = headPitch * 0.017453292F; - this.head.yaw = headYaw * 0.017453292F; - this.body.pitch = 0.0F; - float flipperAnim = MathHelper.cos(limbAngle * 0.4F) * 0.5F * limbDistance; - if (!sealEntity.isTouchingWater() && sealEntity.isOnGround()) { - this.rightHindLeg.setAngles(0.0F, -flipperAnim, 0.0F); - this.leftHindLeg.setAngles(0.0F, flipperAnim, 0.0F); - this.rightFrontLeg.setAngles(0.0F, -flipperAnim * 2.0F, 0.0F); - this.leftFrontLeg.setAngles(0.0F, flipperAnim * 2.0F, 0.0F); - } else { - this.rightHindLeg.setAngles(flipperAnim, 0.0F, 0.0F); - this.leftHindLeg.setAngles(-flipperAnim, 0.0F, 0.0F); - this.rightFrontLeg.setAngles(1.0F + flipperAnim, -(flipperAnim * 2.0F), -(1.0F + flipperAnim)); - this.leftFrontLeg.setAngles(1.0F + flipperAnim, flipperAnim * 2.0F, 1.0F + flipperAnim); - } - } + @Override + public void setAngles(@NotNull T sealEntity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + this.head.pitch = headPitch * 0.017453292F; + this.head.yaw = headYaw * 0.017453292F; + this.body.pitch = 0.0F; + float flipperAnim = MathHelper.cos(limbAngle * 0.4F) * 0.5F * limbDistance; + if (!sealEntity.isTouchingWater() && sealEntity.isOnGround()) { + this.rightHindLeg.setAngles(0.0F, -flipperAnim, 0.0F); + this.leftHindLeg.setAngles(0.0F, flipperAnim, 0.0F); + this.rightFrontLeg.setAngles(0.0F, -flipperAnim * 2.0F, 0.0F); + this.leftFrontLeg.setAngles(0.0F, flipperAnim * 2.0F, 0.0F); + } else { + this.rightHindLeg.setAngles(flipperAnim, 0.0F, 0.0F); + this.leftHindLeg.setAngles(-flipperAnim, 0.0F, 0.0F); + this.rightFrontLeg.setAngles(1.0F + flipperAnim, -(flipperAnim * 2.0F), -(1.0F + flipperAnim)); + this.leftFrontLeg.setAngles(1.0F + flipperAnim, flipperAnim * 2.0F, 1.0F + flipperAnim); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java index f64deb58..082c53f4 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/KuspukSkirtModel.java @@ -1,88 +1,92 @@ package com.github.platymemo.alaskanativecraft.client.model.entity.feature; import com.google.common.collect.ImmutableList; -import net.minecraft.client.model.*; +import org.jetbrains.annotations.NotNull; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.AnimalModel; import net.minecraft.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; public class KuspukSkirtModel extends AnimalModel { - private final ModelPart skirt; - - public KuspukSkirtModel(@NotNull ModelPart modelPart) { - skirt = modelPart.getChild("skirt"); - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - ModelPartData skirt = modelPartData.addChild("skirt", ModelPartBuilder.create(), - ModelTransform.pivot(0.0f, 18.0f, 2.0f)); - - skirt.addChild("strip_1", ModelPartBuilder.create() - .uv(0, 9) - .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f), - ModelTransform.of(3.7f, 0.0f, -0.3f, - -1.309f, 0.7854f, 0.0f)); - - skirt.addChild("strip_2", ModelPartBuilder.create() - .uv(0, 9) - .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f), - ModelTransform.of(-3.7f, 0.0f, -3.7f, - 1.309f, 0.7854f, 0.0f)); - - skirt.addChild("strip_3", ModelPartBuilder.create() - .uv(0, 9) - .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f), - ModelTransform.of(-3.7f, 0.0f, -0.3f, - -1.309f, -0.7854f, 0.0f)); - - skirt.addChild("strip_4", ModelPartBuilder.create() - .uv(0, 9) - .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f), - ModelTransform.of(3.7f, 0.0f, -3.7f, - 1.309f, -0.7854f, 0.0f)); - - skirt.addChild("right", ModelPartBuilder.create() - .uv(0, 5) - .cuboid(-5.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f), - ModelTransform.of(-4.0f, 0.0f, -2.0f, - 0.0f, 0.0f, -1.309f)); - - skirt.addChild("left", ModelPartBuilder.create() - .uv(0, 5) - .cuboid(0.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f), - ModelTransform.of(4.0f, 0.0f, -2.0f, - 0.0f, 0.0f, 1.309f)); - - skirt.addChild("front", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-4.0f, 0.0f, -5.0f, 8.0f, 0.0f, 5.0f), - ModelTransform.of(0.0f, 0.0f, -4.0f, - 1.309f, 0.0f, 0.0f)); - - skirt.addChild("back", ModelPartBuilder.create() - .uv(0, 0) - .cuboid(-4.0f, 0.0f, 0.0f, 8.0f, 0.0f, 5.0f), - ModelTransform.of(0.0f, 0.0f, 0.0f, - -1.309f, 0.0f, 0.0f)); - - - return TexturedModelData.of(modelData, 32, 16); - } - - @Override - public void setAngles(E entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { - - } - - @Override - protected Iterable getHeadParts() { - return ImmutableList.of(); - } - - @Override - protected Iterable getBodyParts() { - return ImmutableList.of(this.skirt); - } -} \ No newline at end of file + private final ModelPart skirt; + + public KuspukSkirtModel(@NotNull ModelPart modelPart) { + this.skirt = modelPart.getChild("skirt"); + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData modelPartData = modelData.getRoot(); + ModelPartData skirt = modelPartData.addChild("skirt", ModelPartBuilder.create(), + ModelTransform.pivot(0.0f, 18.0f, 2.0f)); + + skirt.addChild("strip_1", ModelPartBuilder.create() + .uv(0, 9) + .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f), + ModelTransform.of(3.7f, 0.0f, -0.3f, + -1.309f, 0.7854f, 0.0f)); + + skirt.addChild("strip_2", ModelPartBuilder.create() + .uv(0, 9) + .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f), + ModelTransform.of(-3.7f, 0.0f, -3.7f, + 1.309f, 0.7854f, 0.0f)); + + skirt.addChild("strip_3", ModelPartBuilder.create() + .uv(0, 9) + .cuboid(-0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 5.0f), + ModelTransform.of(-3.7f, 0.0f, -0.3f, + -1.309f, -0.7854f, 0.0f)); + + skirt.addChild("strip_4", ModelPartBuilder.create() + .uv(0, 9) + .cuboid(-0.5f, 0.0f, -5.0f, 1.0f, 0.0f, 5.0f), + ModelTransform.of(3.7f, 0.0f, -3.7f, + 1.309f, -0.7854f, 0.0f)); + + skirt.addChild("right", ModelPartBuilder.create() + .uv(0, 5) + .cuboid(-5.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f), + ModelTransform.of(-4.0f, 0.0f, -2.0f, + 0.0f, 0.0f, -1.309f)); + + skirt.addChild("left", ModelPartBuilder.create() + .uv(0, 5) + .cuboid(0.0f, 0.0f, -2.0f, 5.0f, 0.0f, 4.0f), + ModelTransform.of(4.0f, 0.0f, -2.0f, + 0.0f, 0.0f, 1.309f)); + + skirt.addChild("front", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-4.0f, 0.0f, -5.0f, 8.0f, 0.0f, 5.0f), + ModelTransform.of(0.0f, 0.0f, -4.0f, + 1.309f, 0.0f, 0.0f)); + + skirt.addChild("back", ModelPartBuilder.create() + .uv(0, 0) + .cuboid(-4.0f, 0.0f, 0.0f, 8.0f, 0.0f, 5.0f), + ModelTransform.of(0.0f, 0.0f, 0.0f, + -1.309f, 0.0f, 0.0f)); + + return TexturedModelData.of(modelData, 32, 16); + } + + @Override + public void setAngles(E entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch) { + } + + @Override + protected Iterable getHeadParts() { + return ImmutableList.of(); + } + + @Override + protected Iterable getBodyParts() { + return ImmutableList.of(this.skirt); + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java index 7d7287eb..a5c03ed7 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/model/entity/feature/SnowshoeModel.java @@ -1,43 +1,48 @@ package com.github.platymemo.alaskanativecraft.client.model.entity.feature; import com.google.common.collect.ImmutableList; -import net.minecraft.client.model.*; +import org.jetbrains.annotations.NotNull; + +import net.minecraft.client.model.ModelData; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.model.ModelPartBuilder; +import net.minecraft.client.model.ModelPartData; +import net.minecraft.client.model.ModelTransform; +import net.minecraft.client.model.TexturedModelData; import net.minecraft.client.render.entity.model.AnimalModel; import net.minecraft.entity.LivingEntity; -import org.jetbrains.annotations.NotNull; public class SnowshoeModel extends AnimalModel { - private final ModelPart snowshoe; - - public SnowshoeModel(@NotNull ModelPart root) { - snowshoe = root.getChild("shoe"); - } - - public static @NotNull TexturedModelData getTexturedModelData() { - ModelData modelData = new ModelData(); - ModelPartData modelPartData = modelData.getRoot(); - modelPartData.addChild("shoe", ModelPartBuilder.create() - .uv(23, 5).cuboid(-1.0F, -24.0F, 8.0F, 2.0F, 1.0F, 5.0F) - .uv(23, 0).cuboid(-2.0F, -24.0F, 4.0F, 4.0F, 1.0F, 4.0F) - .uv(0, 0).cuboid(-3.0F, -24.0F, -7.0F, 6.0F, 1.0F, 11.0F) - .uv(0, 0).cuboid(-2.0F, -24.0F, -8.0F, 4.0F, 1.0F, 1.0F) - .uv(0, 9).cuboid(-1.0F, -24.0F, -10.0F, 2.0F, 1.0F, 2.0F), - ModelTransform.NONE); - return TexturedModelData.of(modelData, 64, 16); - } - - @Override - public void setAngles(E entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { - - } - - @Override - protected Iterable getHeadParts() { - return ImmutableList.of(); - } - - @Override - protected Iterable getBodyParts() { - return ImmutableList.of(this.snowshoe); - } -} \ No newline at end of file + private final ModelPart snowshoe; + + public SnowshoeModel(@NotNull ModelPart root) { + this.snowshoe = root.getChild("shoe"); + } + + public static @NotNull TexturedModelData getTexturedModelData() { + ModelData modelData = new ModelData(); + ModelPartData modelPartData = modelData.getRoot(); + modelPartData.addChild("shoe", ModelPartBuilder.create() + .uv(23, 5).cuboid(-1.0F, -24.0F, 8.0F, 2.0F, 1.0F, 5.0F) + .uv(23, 0).cuboid(-2.0F, -24.0F, 4.0F, 4.0F, 1.0F, 4.0F) + .uv(0, 0).cuboid(-3.0F, -24.0F, -7.0F, 6.0F, 1.0F, 11.0F) + .uv(0, 0).cuboid(-2.0F, -24.0F, -8.0F, 4.0F, 1.0F, 1.0F) + .uv(0, 9).cuboid(-1.0F, -24.0F, -10.0F, 2.0F, 1.0F, 2.0F), + ModelTransform.NONE); + return TexturedModelData.of(modelData, 64, 16); + } + + @Override + public void setAngles(E entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { + } + + @Override + protected Iterable getHeadParts() { + return ImmutableList.of(); + } + + @Override + protected Iterable getBodyParts() { + return ImmutableList.of(this.snowshoe); + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java index 03e485e7..2a584d05 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/block/entity/DryingRackBlockEntityRenderer.java @@ -4,6 +4,8 @@ import com.github.platymemo.alaskanativecraft.block.entity.DryingRackBlockEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.entity.BlockEntityRenderer; @@ -14,38 +16,35 @@ import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3f; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class DryingRackBlockEntityRenderer implements BlockEntityRenderer { - public DryingRackBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { - - } - - @Override - public void render(@NotNull DryingRackBlockEntity dryingRackBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { - Direction.Axis axis = dryingRackBlockEntity.getCachedState().get(DryingRackBlock.AXIS); - DefaultedList defaultedList = dryingRackBlockEntity.getItemsBeingDried(); - // Returns 0 if axis=X, 1 if axis=Z - int XOrZ = axis.choose(0, 0, 1); - int k = (int) dryingRackBlockEntity.getPos().asLong(); + public DryingRackBlockEntityRenderer(BlockEntityRendererFactory.Context ctx) { + } - for (int l = 0; l < defaultedList.size(); ++l) { - ItemStack itemStack = defaultedList.get(l); - if (itemStack != ItemStack.EMPTY) { - matrixStack.push(); - matrixStack.translate(0.5D, 0.45D, 0.5D); - Direction direction2 = Direction.fromHorizontal((l % 2) * 2 + XOrZ); - float g = -direction2.asRotation(); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(g)); - matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); - matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); - matrixStack.translate(-0.25D, 0.1D, 0.075D * (l < 1 || l > 2 ? 1 : -1)); - matrixStack.scale(0.375F, 0.375F, 0.375F); - MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider, k + l); - matrixStack.pop(); - } - } + @Override + public void render(@NotNull DryingRackBlockEntity dryingRackBlockEntity, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) { + Direction.Axis axis = dryingRackBlockEntity.getCachedState().get(DryingRackBlock.AXIS); + DefaultedList defaultedList = dryingRackBlockEntity.getItemsBeingDried(); + // Returns 0 if axis=X, 1 if axis=Z + int XOrZ = axis.choose(0, 0, 1); + int k = (int) dryingRackBlockEntity.getPos().asLong(); - } + for (int l = 0; l < defaultedList.size(); ++l) { + ItemStack itemStack = defaultedList.get(l); + if (itemStack != ItemStack.EMPTY) { + matrixStack.push(); + matrixStack.translate(0.5D, 0.45D, 0.5D); + Direction direction2 = Direction.fromHorizontal((l % 2) * 2 + XOrZ); + float g = -direction2.asRotation(); + matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(g)); + matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); + matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); + matrixStack.translate(-0.25D, 0.1D, 0.075D * (l < 1 || l > 2 ? 1 : -1)); + matrixStack.scale(0.375F, 0.375F, 0.375F); + MinecraftClient.getInstance().getItemRenderer().renderItem(itemStack, ModelTransformation.Mode.FIXED, i, j, matrixStack, vertexConsumerProvider, k + l); + matrixStack.pop(); + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java index 79bcf122..8a09d1a0 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/DogsledEntityRenderer.java @@ -4,9 +4,12 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.DogsledEntityModel; import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; @@ -18,64 +21,63 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3f; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class DogsledEntityRenderer extends EntityRenderer { - private static final Identifier[] TEXTURES = new Identifier[]{new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/oak.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/spruce.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/birch.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/jungle.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/acacia.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/dark_oak.png")}; - protected final DogsledEntityModel model; + private static final Identifier[] TEXTURES = new Identifier[] {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/oak.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/spruce.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/birch.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/jungle.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/acacia.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/dogsled/dark_oak.png")}; + protected final DogsledEntityModel model; - public DogsledEntityRenderer(EntityRendererFactory.Context ctx) { - super(ctx); - this.model = new DogsledEntityModel(ctx.getPart(AlaskaModels.DOGSLED)); - this.shadowRadius = 0.5F; - } + public DogsledEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx); + this.model = new DogsledEntityModel(ctx.getPart(AlaskaModels.DOGSLED)); + this.shadowRadius = 0.5F; + } - @Override - public void render(@NotNull DogsledEntity dogsledEntity, float yaw, float tickDelta, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) { - matrixStack.push(); - matrixStack.scale(1.5F, 1.5F, 1.5F); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270 - yaw)); - float h = (float) dogsledEntity.getDamageWobbleTicks() - tickDelta; - float j = dogsledEntity.getDamageWobbleStrength() - tickDelta; - if (j < 0.0F) { - j = 0.0F; - } + @Override + public void render(@NotNull DogsledEntity dogsledEntity, float yaw, float tickDelta, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) { + matrixStack.push(); + matrixStack.scale(1.5F, 1.5F, 1.5F); + matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(270 - yaw)); + float h = (float) dogsledEntity.getDamageWobbleTicks() - tickDelta; + float j = dogsledEntity.getDamageWobbleStrength() - tickDelta; + if (j < 0.0F) { + j = 0.0F; + } - if (h > 0.0F) { - matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) dogsledEntity.getDamageWobbleSide())); - } + if (h > 0.0F) { + matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(MathHelper.sin(h) * h * j / 10.0F * (float) dogsledEntity.getDamageWobbleSide())); + } - // Chest Rendering - matrixStack.push(); - float s = 0.5F; - matrixStack.scale(s, s, s); - matrixStack.translate(-0.3D, 0.6D, 0.5D); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F)); - this.renderBlock(Blocks.CHEST.getDefaultState(), matrixStack, vertexConsumerProvider, light); - matrixStack.pop(); + // Chest Rendering + matrixStack.push(); + float s = 0.5F; + matrixStack.scale(s, s, s); + matrixStack.translate(-0.3D, 0.6D, 0.5D); + matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F)); + this.renderBlock(Blocks.CHEST.getDefaultState(), matrixStack, vertexConsumerProvider, light); + matrixStack.pop(); - matrixStack.scale(-1.0F, -1.0F, 1.0F); - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F)); - this.model.setAngles(dogsledEntity, tickDelta, 0.0F, -0.1F, 0.0F, 0.0F); - VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(this.model.getLayer(this.getTexture(dogsledEntity))); - this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + matrixStack.scale(-1.0F, -1.0F, 1.0F); + matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90.0F)); + this.model.setAngles(dogsledEntity, tickDelta, 0.0F, -0.1F, 0.0F, 0.0F); + VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(this.model.getLayer(this.getTexture(dogsledEntity))); + this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); - matrixStack.pop(); - super.render(dogsledEntity, yaw, tickDelta, matrixStack, vertexConsumerProvider, light); - } + matrixStack.pop(); + super.render(dogsledEntity, yaw, tickDelta, matrixStack, vertexConsumerProvider, light); + } - @Override - public Identifier getTexture(@NotNull DogsledEntity dogsledEntity) { - return TEXTURES[dogsledEntity.getDogsledType().ordinal()]; - } + @Override + public Identifier getTexture(@NotNull DogsledEntity dogsledEntity) { + return TEXTURES[dogsledEntity.getDogsledType().ordinal()]; + } - protected void renderBlock(BlockState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { - MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(state, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV); - } + protected void renderBlock(BlockState state, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + MinecraftClient.getInstance().getBlockRenderManager().renderBlockAsEntity(state, matrices, vertexConsumers, light, OverlayTexture.DEFAULT_UV); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java index 0ec49a63..bddae9a8 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/HarpoonEntityRenderer.java @@ -1,10 +1,16 @@ package com.github.platymemo.alaskanativecraft.client.renderer.entity; +import java.util.HashMap; +import java.util.Map; + import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.HarpoonEntityModel; import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity; +import org.jetbrains.annotations.NotNull; + import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; @@ -16,44 +22,41 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3f; import net.minecraft.util.registry.Registry; -import org.jetbrains.annotations.NotNull; - -import java.util.HashMap; -import java.util.Map; public class HarpoonEntityRenderer extends EntityRenderer { - private static final Map, Identifier> TEXTURES = new HashMap<>(); - private final HarpoonEntityModel model; - - public HarpoonEntityRenderer(EntityRendererFactory.Context ctx) { - super(ctx); - model = new HarpoonEntityModel(ctx.getPart(AlaskaModels.HARPOON)); - } - - public static Identifier getTexture(EntityType type) { - if (!TEXTURES.containsKey(type)) { - TEXTURES.put(type, new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/harpoon/" + Registry.ENTITY_TYPE.getId(type).getPath() + ".png")); - } - return TEXTURES.get(type); - } - - @Override - public void render(@NotNull HarpoonEntity harpoon, float f, float g, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { - matrixStack.push(); - { - matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevYaw, harpoon.getYaw()) - 90.0F)); - matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevPitch, harpoon.getPitch()) + 90.0F)); - VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, model.getLayer(this.getTexture(harpoon)), false, harpoon.isEnchanted()); - model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); - matrixStack.scale(2.0F, -2.0F, -2.0F); - } - matrixStack.pop(); - super.render(harpoon, f, g, matrixStack, vertexConsumerProvider, i); - } - - @Override - public Identifier getTexture(@NotNull HarpoonEntity harpoon) { - return getTexture(harpoon.getType()); - } + private static final Map, Identifier> TEXTURES = new HashMap<>(); + private final HarpoonEntityModel model; + + public HarpoonEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx); + this.model = new HarpoonEntityModel(ctx.getPart(AlaskaModels.HARPOON)); + } + + public static Identifier getTexture(EntityType type) { + if (!TEXTURES.containsKey(type)) { + TEXTURES.put(type, new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/harpoon/" + Registry.ENTITY_TYPE.getId(type).getPath() + ".png")); + } + + return TEXTURES.get(type); + } + + @Override + public void render(@NotNull HarpoonEntity harpoon, float f, float g, @NotNull MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { + matrixStack.push(); + { + matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevYaw, harpoon.getYaw()) - 90.0F)); + matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(MathHelper.lerp(g, harpoon.prevPitch, harpoon.getPitch()) + 90.0F)); + VertexConsumer vertexConsumer = ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, this.model.getLayer(this.getTexture(harpoon)), false, harpoon.isEnchanted()); + this.model.render(matrixStack, vertexConsumer, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + matrixStack.scale(2.0F, -2.0F, -2.0F); + } + + matrixStack.pop(); + super.render(harpoon, f, g, matrixStack, vertexConsumerProvider, i); + } + + @Override + public Identifier getTexture(@NotNull HarpoonEntity harpoon) { + return getTexture(harpoon.getType()); + } } - diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java index adf3d198..6c727f93 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/MooseEntityRenderer.java @@ -6,6 +6,7 @@ import com.github.platymemo.alaskanativecraft.entity.MooseEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; + import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -13,20 +14,20 @@ @Environment(EnvType.CLIENT) public class MooseEntityRenderer extends MobEntityRenderer> { - private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/moose.png"); + private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/moose.png"); - public MooseEntityRenderer(EntityRendererFactory.Context ctx) { - super(ctx, new MooseEntityModel<>(ctx.getPart(AlaskaModels.MOOSE)), 1.5F); - } + public MooseEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx, new MooseEntityModel<>(ctx.getPart(AlaskaModels.MOOSE)), 1.5F); + } - @Override - public Identifier getTexture(MooseEntity mooseEntity) { - return TEXTURE; - } + @Override + public Identifier getTexture(MooseEntity mooseEntity) { + return TEXTURE; + } - @Override - protected void scale(MooseEntity entity, MatrixStack matrices, float amount) { - super.scale(entity, matrices, amount); - matrices.scale(2.0F, 2.0F, 2.0F); - } -} \ No newline at end of file + @Override + protected void scale(MooseEntity entity, MatrixStack matrices, float amount) { + super.scale(entity, matrices, amount); + matrices.scale(2.0F, 2.0F, 2.0F); + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java index d08a09a4..7f429807 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/PtarmiganEntityRenderer.java @@ -6,31 +6,32 @@ import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class PtarmiganEntityRenderer extends MobEntityRenderer { - public static final Identifier[] TEXTURES = {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/ptarmigan.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/brown_ptarmigan.png"), - new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/grey_ptarmigan.png")}; + public static final Identifier[] TEXTURES = {new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/ptarmigan.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/brown_ptarmigan.png"), + new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/ptarmigan/grey_ptarmigan.png")}; - public PtarmiganEntityRenderer(EntityRendererFactory.Context ctx) { - super(ctx, new PtarmiganEntityModel(ctx.getPart(AlaskaModels.PTARMIGAN)), 0.3F); - } + public PtarmiganEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx, new PtarmiganEntityModel(ctx.getPart(AlaskaModels.PTARMIGAN)), 0.3F); + } - @Override - public Identifier getTexture(@NotNull PtarmiganEntity ptarmiganEntity) { - return TEXTURES[ptarmiganEntity.getPtarmiganType()]; - } + @Override + public Identifier getTexture(@NotNull PtarmiganEntity ptarmiganEntity) { + return TEXTURES[ptarmiganEntity.getPtarmiganType()]; + } - @Override - public float getAnimationProgress(@NotNull PtarmiganEntity ptarmiganEntity, float f) { - float g = MathHelper.lerp(f, ptarmiganEntity.prevFlapProgress, ptarmiganEntity.flapProgress); - float h = MathHelper.lerp(f, ptarmiganEntity.prevMaxWingDeviation, ptarmiganEntity.maxWingDeviation); - return (MathHelper.sin(g) + 1.0F) * h; - } + @Override + public float getAnimationProgress(@NotNull PtarmiganEntity ptarmiganEntity, float f) { + float g = MathHelper.lerp(f, ptarmiganEntity.prevFlapProgress, ptarmiganEntity.flapProgress); + float h = MathHelper.lerp(f, ptarmiganEntity.prevMaxWingDeviation, ptarmiganEntity.maxWingDeviation); + return (MathHelper.sin(g) + 1.0F) * h; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java index be1ca8a2..817cefe3 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/SealEntityRenderer.java @@ -6,20 +6,21 @@ import com.github.platymemo.alaskanativecraft.entity.SealEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; + import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; import net.minecraft.util.Identifier; @Environment(EnvType.CLIENT) public class SealEntityRenderer extends MobEntityRenderer> { - private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/seal/seal.png"); + private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/seal/seal.png"); - public SealEntityRenderer(EntityRendererFactory.Context ctx) { - super(ctx, new SealEntityModel<>(ctx.getPart(AlaskaModels.SEAL)), 0.7F); - } + public SealEntityRenderer(EntityRendererFactory.Context ctx) { + super(ctx, new SealEntityModel<>(ctx.getPart(AlaskaModels.SEAL)), 0.7F); + } - @Override - public Identifier getTexture(SealEntity sealEntity) { - return TEXTURE; - } -} \ No newline at end of file + @Override + public Identifier getTexture(SealEntity sealEntity) { + return TEXTURE; + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java index 7dabec04..19e97042 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/KuspukSkirtFeatureRenderer.java @@ -4,9 +4,12 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.feature.KuspukSkirtModel; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; @@ -20,37 +23,37 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class KuspukSkirtFeatureRenderer> extends FeatureRenderer { - private final KuspukSkirtModel model; - private final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/skirt_layer.png"); + private static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/skirt_layer.png"); + private final KuspukSkirtModel model; + + public KuspukSkirtFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) { + super(context); + this.model = new KuspukSkirtModel<>(loader.getModelPart(AlaskaModels.KUSPUK_SKIRT)); + } - public KuspukSkirtFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) { - super(context); - this.model = new KuspukSkirtModel<>(loader.getModelPart(AlaskaModels.KUSPUK_SKIRT)); - } + @Override + public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { + ItemStack armorItemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST); + if (armorItemStack.isOf(AlaskaItems.KUSPUK_BODY)) { + int color = AlaskaItems.KUSPUK_BODY.getColor(armorItemStack); + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; + matrixStack.push(); + if (livingEntity.isInSneakingPose()) { + matrixStack.translate(0.0D, -2.55D, 0.3D); + } else { + matrixStack.translate(0.0D, -2.7D, 0.0D); + } - @Override - public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E livingEntity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { - ItemStack armorItemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST); - if (armorItemStack.isOf(AlaskaItems.KUSPUK_BODY)) { - int color = AlaskaItems.KUSPUK_BODY.getColor(armorItemStack); - float r = (float) (color >> 16 & 255) / 255.0F; - float g = (float) (color >> 8 & 255) / 255.0F; - float b = (float) (color & 255) / 255.0F; - matrixStack.push(); - if (livingEntity.isInSneakingPose()) { - matrixStack.translate(0.0D, -2.55D, 0.3D); - } else { - matrixStack.translate(0.0D, -2.7D, 0.0D); - } - matrixStack.scale(2.5F, 2.5F, 2.5F); - VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint()); - this.model.setAngles(livingEntity, limbAngle, limbDistance, animationProgress, headYaw, headPitch); - this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0F); - matrixStack.pop(); - } - } + matrixStack.scale(2.5F, 2.5F, 2.5F); + VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint()); + this.model.setAngles(livingEntity, limbAngle, limbDistance, animationProgress, headYaw, headPitch); + this.model.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV, r, g, b, 1.0F); + matrixStack.pop(); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java index 3e5465c3..c781e8d5 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/ShoulderPtarmiganFeatureRenderer.java @@ -4,9 +4,12 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.PtarmiganEntityModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.PtarmiganEntityRenderer; import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.feature.FeatureRenderer; @@ -17,31 +20,30 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class ShoulderPtarmiganFeatureRenderer extends FeatureRenderer> { - private final PtarmiganEntityModel model; + private final PtarmiganEntityModel model; - public ShoulderPtarmiganFeatureRenderer(FeatureRendererContext> context, @NotNull EntityModelLoader loader) { - super(context); - this.model = new PtarmiganEntityModel(loader.getModelPart(AlaskaModels.PTARMIGAN)); - } + public ShoulderPtarmiganFeatureRenderer(FeatureRendererContext> context, @NotNull EntityModelLoader loader) { + super(context); + this.model = new PtarmiganEntityModel(loader.getModelPart(AlaskaModels.PTARMIGAN)); + } - @Override - public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T playerEntity, float f, float g, float h, float j, float k, float l) { - this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, true); - this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, false); - } + @Override + public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T playerEntity, float f, float g, float h, float j, float k, float l) { + this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, true); + this.renderShoulderPtarmigan(matrixStack, vertexConsumerProvider, i, playerEntity, f, g, k, l, false); + } - private void renderShoulderPtarmigan(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T player, float limbAngle, float limbDistance, float headYaw, float headPitch, boolean leftShoulder) { - NbtCompound compoundTag = leftShoulder ? player.getShoulderEntityLeft() : player.getShoulderEntityRight(); - EntityType.get(compoundTag.getString("id")).filter((entityType) -> entityType == AlaskaEntities.PTARMIGAN).ifPresent((entityType) -> { - matrices.push(); - matrices.translate(leftShoulder ? 0.4D : -0.4D, player.isInSneakingPose() ? -1.3D : -1.5D, 0.0D); - VertexConsumer vertexConsumer = vertexConsumers.getBuffer(this.model.getLayer(PtarmiganEntityRenderer.TEXTURES[compoundTag.getInt("Type")])); - this.model.poseOnShoulder(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, limbAngle, limbDistance, headYaw, headPitch, player.age); - matrices.pop(); - }); - } + private void renderShoulderPtarmigan(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T player, float limbAngle, float limbDistance, float headYaw, float headPitch, boolean leftShoulder) { + NbtCompound compoundTag = leftShoulder ? player.getShoulderEntityLeft() : player.getShoulderEntityRight(); + EntityType.get(compoundTag.getString("id")).filter((entityType) -> entityType == AlaskaEntities.PTARMIGAN).ifPresent((entityType) -> { + matrices.push(); + matrices.translate(leftShoulder ? 0.4D : -0.4D, player.isInSneakingPose() ? -1.3D : -1.5D, 0.0D); + VertexConsumer vertexConsumer = vertexConsumers.getBuffer(this.model.getLayer(PtarmiganEntityRenderer.TEXTURES[compoundTag.getInt("Type")])); + this.model.poseOnShoulder(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, limbAngle, limbDistance, headYaw, headPitch, player.age); + matrices.pop(); + }); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java index d0c49e99..5a965323 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/entity/feature/SnowshoeFeatureRenderer.java @@ -4,9 +4,12 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.AlaskaModels; import com.github.platymemo.alaskanativecraft.client.model.entity.feature.SnowshoeModel; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.OverlayTexture; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.VertexConsumerProvider; @@ -22,65 +25,62 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3f; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public class SnowshoeFeatureRenderer> extends FeatureRenderer { - public static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/snowshoe.png"); - private final SnowshoeModel model; + public static final Identifier TEXTURE = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/entity/feature/snowshoe.png"); + private final SnowshoeModel model; + + public SnowshoeFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) { + super(context); + this.model = new SnowshoeModel<>(loader.getModelPart(AlaskaModels.SNOWSHOES)); + } + + @Override + public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { + ItemStack armorItemStack = entity.getEquippedStack(EquipmentSlot.FEET); + if (armorItemStack.isOf(AlaskaItems.SNOWSHOES)) { + VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint()); - public SnowshoeFeatureRenderer(FeatureRendererContext context, @NotNull EntityModelLoader loader) { - super(context); - this.model = new SnowshoeModel<>(loader.getModelPart(AlaskaModels.SNOWSHOES)); - } + matrices.push(); + this.translateToRightLeg(matrices, this.getContextModel(), entity); + this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + matrices.pop(); - @Override - public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, @NotNull E entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) { - ItemStack armorItemStack = entity.getEquippedStack(EquipmentSlot.FEET); - if (armorItemStack.isOf(AlaskaItems.SNOWSHOES)) { - VertexConsumer vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(TEXTURE), false, armorItemStack.hasGlint()); + matrices.push(); + this.translateToLeftLeg(matrices, this.getContextModel(), entity); + this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); + matrices.pop(); + } + } - matrices.push(); - { - this.translateToRightLeg(matrices, this.getContextModel(), entity); - this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); - } - matrices.pop(); + private void translateToRightLeg(MatrixStack matrices, M model, @NotNull E entity) { + if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) { + matrices.translate(0.0F, 0.0F, 0.25F); + } - matrices.push(); - { - this.translateToLeftLeg(matrices, this.getContextModel(), entity); - this.model.render(matrices, vertexConsumer, light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F); - } - matrices.pop(); - } - } + matrices.translate(-0.115F, 0.75F, 0.0F); + matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.rightLeg.roll)); + matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.rightLeg.yaw)); + matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.rightLeg.pitch)); + // This sets it just above the armor stand base. + float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F; + matrices.translate(0.0F, bottomOfFoot, 0.0F); + matrices.scale(2.0F, 2.0F, 2.0F); + } - private void translateToRightLeg(MatrixStack matrices, M model, @NotNull E entity) { - if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) { - matrices.translate(0.0F, 0.0F, 0.25F); - } - matrices.translate(-0.115F, 0.75F, 0.0F); - matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.rightLeg.roll)); - matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.rightLeg.yaw)); - matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.rightLeg.pitch)); - // This sets it just above the armor stand base. - float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F; - matrices.translate(0.0F, bottomOfFoot, 0.0F); - matrices.scale(2.0F, 2.0F, 2.0F); - } + private void translateToLeftLeg(MatrixStack matrices, M model, @NotNull E entity) { + if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) { + matrices.translate(0.0F, 0.0F, 0.25F); + } - private void translateToLeftLeg(MatrixStack matrices, M model, @NotNull E entity) { - if (entity.isInSneakingPose() && !model.riding && !entity.isSwimming()) { - matrices.translate(0.0F, 0.0F, 0.25F); - } - matrices.translate(0.115F, 0.75F, 0.0F); - matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.leftLeg.roll)); - matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.leftLeg.yaw)); - matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.leftLeg.pitch)); - // This sets it just above the armor stand base. - float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F; - matrices.translate(0.0F, bottomOfFoot, 0.0F); - matrices.scale(2.0F, 2.0F, 2.0F); - } + matrices.translate(0.115F, 0.75F, 0.0F); + matrices.multiply(Vec3f.POSITIVE_Z.getRadialQuaternion(model.leftLeg.roll)); + matrices.multiply(Vec3f.POSITIVE_Y.getRadialQuaternion(model.leftLeg.yaw)); + matrices.multiply(Vec3f.POSITIVE_X.getRadialQuaternion(model.leftLeg.pitch)); + // This sets it just above the armor stand base. + float bottomOfFoot = entity instanceof ArmorStandEntity ? 0.65F : 0.7F; + matrices.translate(0.0F, bottomOfFoot, 0.0F); + matrices.scale(2.0F, 2.0F, 2.0F); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java index a825d502..f149fb9e 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/HarpoonItemRenderer.java @@ -3,9 +3,11 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.HarpoonEntityModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.HarpoonEntityRenderer; import com.github.platymemo.alaskanativecraft.item.HarpoonItem; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; @@ -17,37 +19,37 @@ @Environment(EnvType.CLIENT) public enum HarpoonItemRenderer { - INSTANCE; - private final HarpoonEntityModel harpoonEntityModel = new HarpoonEntityModel(HarpoonEntityModel.getTexturedModelData().createModel()); - - public boolean render(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) { - if (renderMode == ModelTransformation.Mode.GUI || renderMode == ModelTransformation.Mode.GROUND || renderMode == ModelTransformation.Mode.FIXED) { - return false; - } - - matrices.push(); - { - model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); - - if (entity != null && entity.isUsingItem() && entity.getActiveItem() == stack && (renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND)) { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180)); - matrices.translate(0, 2, 0); - } else { - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90)); - matrices.translate(0, 0.85, 0); - } - - matrices.scale(2.0F, -2.0F, -2.0F); - VertexConsumer harpoon = ItemRenderer.getArmorGlintConsumer( - vertexConsumers, - this.harpoonEntityModel.getLayer(HarpoonEntityRenderer.getTexture(((HarpoonItem) stack.getItem()).getType())), - false, - stack.hasGlint() - ); - this.harpoonEntityModel.render(matrices, harpoon, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); - - } - matrices.pop(); - return true; - } + INSTANCE; + private final HarpoonEntityModel harpoonEntityModel = new HarpoonEntityModel(HarpoonEntityModel.getTexturedModelData().createModel()); + + public boolean render(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) { + if (renderMode == ModelTransformation.Mode.GUI || renderMode == ModelTransformation.Mode.GROUND || renderMode == ModelTransformation.Mode.FIXED) { + return false; + } + + matrices.push(); + { + model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); + + if (entity != null && entity.isUsingItem() && entity.getActiveItem() == stack && (renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND)) { + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180)); + matrices.translate(0, 2, 0); + } else { + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(90)); + matrices.translate(0, 0.85, 0); + } + + matrices.scale(2.0F, -2.0F, -2.0F); + VertexConsumer harpoon = ItemRenderer.getArmorGlintConsumer( + vertexConsumers, + this.harpoonEntityModel.getLayer(HarpoonEntityRenderer.getTexture(((HarpoonItem) stack.getItem()).getType())), + false, + stack.hasGlint() + ); + this.harpoonEntityModel.render(matrices, harpoon, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); + } + + matrices.pop(); + return true; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java index 362026b1..29c2489d 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/client/renderer/item/SnowshoeItemRenderer.java @@ -2,9 +2,12 @@ import com.github.platymemo.alaskanativecraft.client.model.entity.feature.SnowshoeModel; import com.github.platymemo.alaskanativecraft.client.renderer.entity.feature.SnowshoeFeatureRenderer; -import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + +import com.mojang.blaze3d.vertex.VertexConsumer; + import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.render.model.BakedModel; @@ -13,37 +16,37 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.Vec3f; -import org.jetbrains.annotations.NotNull; @Environment(EnvType.CLIENT) public enum SnowshoeItemRenderer { - INSTANCE; - private final SnowshoeModel snowshoeModel = new SnowshoeModel<>(SnowshoeModel.getTexturedModelData().createModel()); - - public boolean render(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, @NotNull MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, @NotNull BakedModel model) { - matrices.push(); - { - model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); - - if (renderMode.isFirstPerson() || renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND) { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); - matrices.translate(0, -0.05, -0.15); - matrices.scale(2.0F, 2.0F, 2.0F); - } else { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(45)); - matrices.scale(1.5F, 1.5F, 1.5F); - } - - VertexConsumer snowshoe = ItemRenderer.getArmorGlintConsumer( - vertexConsumers, - this.snowshoeModel.getLayer(SnowshoeFeatureRenderer.TEXTURE), - false, - stack.hasGlint() - ); - this.snowshoeModel.render(matrices, snowshoe, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); - } - matrices.pop(); - return true; - } + INSTANCE; + private final SnowshoeModel snowshoeModel = new SnowshoeModel<>(SnowshoeModel.getTexturedModelData().createModel()); + + public boolean render(ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, @NotNull MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, @NotNull BakedModel model) { + matrices.push(); + { + model.getTransformation().getTransformation(renderMode).apply(leftHanded, matrices); + + if (renderMode.isFirstPerson() || renderMode == ModelTransformation.Mode.THIRD_PERSON_LEFT_HAND || renderMode == ModelTransformation.Mode.THIRD_PERSON_RIGHT_HAND) { + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); + matrices.translate(0, -0.05, -0.15); + matrices.scale(2.0F, 2.0F, 2.0F); + } else { + matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90)); + matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(45)); + matrices.scale(1.5F, 1.5F, 1.5F); + } + + VertexConsumer snowshoe = ItemRenderer.getArmorGlintConsumer( + vertexConsumers, + this.snowshoeModel.getLayer(SnowshoeFeatureRenderer.TEXTURE), + false, + stack.hasGlint() + ); + this.snowshoeModel.render(matrices, snowshoe, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F); + } + + matrices.pop(); + return true; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java index ff968857..9f3a0361 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/AlaskaModMenu.java @@ -9,8 +9,8 @@ @Environment(EnvType.CLIENT) public class AlaskaModMenu implements ModMenuApi { - @Override - public ConfigScreenFactory getModConfigScreenFactory() { - return parent -> AutoConfig.getConfigScreen(AlaskaConfig.class, parent).get(); - } + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(AlaskaConfig.class, parent).get(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java index 27eea804..a3e56e61 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/AlaskaPlugin.java @@ -10,36 +10,37 @@ import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.plugin.client.BuiltinClientPlugin; -import net.minecraft.text.Text; import org.jetbrains.annotations.NotNull; +import net.minecraft.text.Text; + public class AlaskaPlugin implements REIClientPlugin { - public static final CategoryIdentifier DRYING_ID = CategoryIdentifier.of(AlaskaNativeCraft.MOD_ID, "plugins/drying"); + public static final CategoryIdentifier DRYING_ID = CategoryIdentifier.of(AlaskaNativeCraft.MOD_ID, "plugins/drying"); - @Override - public void registerCategories(@NotNull CategoryRegistry registry) { - registry.add(new DryingCategory(), config -> config.addWorkstations(EntryStacks.of(AlaskaBlocks.DRYING_RACK))); - } + @Override + public void registerCategories(@NotNull CategoryRegistry registry) { + registry.add(new DryingCategory(), config -> config.addWorkstations(EntryStacks.of(AlaskaBlocks.DRYING_RACK))); + } - @Override - public void registerDisplays(@NotNull DisplayRegistry registry) { - registry.registerFiller(DryingRecipe.class, DryingDisplay::new); - BuiltinClientPlugin.getInstance().registerInformation( - EntryStacks.of(AlaskaItems.AKUTAQ), - Text.translatable("item.alaskanativecraft.akutaq"), - (list) -> { - list.add(Text.translatable("alaskanativecraft.akutaq.line1")); - list.add(Text.translatable("alaskanativecraft.akutaq.line2")); - list.add(Text.translatable("alaskanativecraft.akutaq.line3")); - return list; - }); - BuiltinClientPlugin.getInstance().registerInformation( - EntryStacks.of(AlaskaItems.FISH_STRIP), - Text.translatable("item.alaskanativecraft.fish_strip"), - (list) -> { - list.add(Text.translatable("alaskanativecraft.fish_strip.line1")); - list.add(Text.translatable("alaskanativecraft.fish_strip.line2")); - return list; - }); - } + @Override + public void registerDisplays(@NotNull DisplayRegistry registry) { + registry.registerFiller(DryingRecipe.class, DryingDisplay::new); + BuiltinClientPlugin.getInstance().registerInformation( + EntryStacks.of(AlaskaItems.AKUTAQ), + Text.translatable("item.alaskanativecraft.akutaq"), + (list) -> { + list.add(Text.translatable("alaskanativecraft.akutaq.line1")); + list.add(Text.translatable("alaskanativecraft.akutaq.line2")); + list.add(Text.translatable("alaskanativecraft.akutaq.line3")); + return list; + }); + BuiltinClientPlugin.getInstance().registerInformation( + EntryStacks.of(AlaskaItems.FISH_STRIP), + Text.translatable("item.alaskanativecraft.fish_strip"), + (list) -> { + list.add(Text.translatable("alaskanativecraft.fish_strip.line1")); + list.add(Text.translatable("alaskanativecraft.fish_strip.line2")); + return list; + }); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java index dc00d64b..0646ea48 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingCategory.java @@ -1,5 +1,8 @@ package com.github.platymemo.alaskanativecraft.compat.rei; +import java.text.DecimalFormat; +import java.util.List; + import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.google.common.collect.Lists; import me.shedaniel.math.Point; @@ -10,46 +13,44 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.util.EntryStacks; -import net.minecraft.text.Text; import org.jetbrains.annotations.NotNull; -import java.text.DecimalFormat; -import java.util.List; +import net.minecraft.text.Text; public class DryingCategory implements DisplayCategory { - @Override - public CategoryIdentifier getCategoryIdentifier() { - return AlaskaPlugin.DRYING_ID; - } - - @Override - public @NotNull Renderer getIcon() { - return EntryStacks.of(AlaskaBlocks.DRYING_RACK); - } - - @Override - public Text getTitle() { - return Text.translatable("category.rei.alaskanativecraft.drying"); - } - - @Override - public @NotNull List setupDisplay(@NotNull DryingDisplay display, @NotNull Rectangle bounds) { - Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); - final double cookingTime = display.getDryTime(); - DecimalFormat df = new DecimalFormat("###.##"); - List widgets = Lists.newArrayList(); - widgets.add(Widgets.createRecipeBase(bounds)); - widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); - widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), - Text.translatable("category.rei.campfire.time", df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); - widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime)); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 9)).entries(display.getInputEntries().get(0)).markInput()); - widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); - return widgets; - } - - @Override - public int getDisplayHeight() { - return 49; - } + @Override + public CategoryIdentifier getCategoryIdentifier() { + return AlaskaPlugin.DRYING_ID; + } + + @Override + public @NotNull Renderer getIcon() { + return EntryStacks.of(AlaskaBlocks.DRYING_RACK); + } + + @Override + public Text getTitle() { + return Text.translatable("category.rei.alaskanativecraft.drying"); + } + + @Override + public @NotNull List setupDisplay(@NotNull DryingDisplay display, @NotNull Rectangle bounds) { + Point startPoint = new Point(bounds.getCenterX() - 41, bounds.y + 10); + final double cookingTime = display.getDryTime(); + DecimalFormat df = new DecimalFormat("###.##"); + List widgets = Lists.newArrayList(); + widgets.add(Widgets.createRecipeBase(bounds)); + widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 9))); + widgets.add(Widgets.createLabel(new Point(bounds.x + bounds.width - 5, bounds.y + 5), + Text.translatable("category.rei.campfire.time", df.format(cookingTime / 20d))).noShadow().rightAligned().color(0xFF404040, 0xFFBBBBBB)); + widgets.add(Widgets.createArrow(new Point(startPoint.x + 24, startPoint.y + 8)).animationDurationTicks(cookingTime)); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 1, startPoint.y + 9)).entries(display.getInputEntries().get(0)).markInput()); + widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 9)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput()); + return widgets; + } + + @Override + public int getDisplayHeight() { + return 49; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java index f365bd42..5c33e4ca 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/compat/rei/DryingDisplay.java @@ -1,5 +1,9 @@ package com.github.platymemo.alaskanativecraft.compat.rei; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + import com.github.platymemo.alaskanativecraft.recipe.DryingRecipe; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; @@ -7,56 +11,52 @@ import me.shedaniel.rei.api.common.util.EntryIngredients; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + import net.minecraft.item.ItemStack; import net.minecraft.recipe.Ingredient; import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; -import org.jetbrains.annotations.NotNull; - -import java.util.Collections; -import java.util.List; -import java.util.Optional; @Environment(EnvType.CLIENT) public class DryingDisplay implements Display { - private final List inputs; - private final List output; - private final int dryTime; - private DryingRecipe display; - - public DryingDisplay(@NotNull DryingRecipe recipe) { - this(recipe.getIngredients(), recipe.getOutput(), recipe.getCookTime()); - this.display = recipe; - } - - public DryingDisplay(DefaultedList ingredients, ItemStack output, int dryTime) { - this.inputs = EntryIngredients.ofIngredients(ingredients); - this.output = Collections.singletonList(EntryIngredients.of(output)); - this.dryTime = dryTime; - } - - public double getDryTime() { - return dryTime; - } - - @Override - public @NotNull Optional getDisplayLocation() { - return Optional.ofNullable(display).map(DryingRecipe::getId); - } - - @Override - public @NotNull List getInputEntries() { - return inputs; - } - - @Override - public @NotNull List getOutputEntries() { - return output; - } - - @Override - public CategoryIdentifier getCategoryIdentifier() { - return AlaskaPlugin.DRYING_ID; - } + private final List inputs; + private final List output; + private final int dryTime; + private DryingRecipe display; + + public DryingDisplay(@NotNull DryingRecipe recipe) { + this(recipe.getIngredients(), recipe.getOutput(), recipe.getCookTime()); + this.display = recipe; + } + + public DryingDisplay(DefaultedList ingredients, ItemStack output, int dryTime) { + this.inputs = EntryIngredients.ofIngredients(ingredients); + this.output = Collections.singletonList(EntryIngredients.of(output)); + this.dryTime = dryTime; + } + + public double getDryTime() { + return this.dryTime; + } + + @Override + public @NotNull Optional getDisplayLocation() { + return Optional.ofNullable(this.display).map(DryingRecipe::getId); + } + + @Override + public @NotNull List getInputEntries() { + return this.inputs; + } + + @Override + public @NotNull List getOutputEntries() { + return this.output; + } + + @Override + public CategoryIdentifier getCategoryIdentifier() { + return AlaskaPlugin.DRYING_ID; + } } - diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java b/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java index b34db4c5..4dcf6d1a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/config/AlaskaConfig.java @@ -9,73 +9,73 @@ @Config(name = AlaskaNativeCraft.MOD_ID) public class AlaskaConfig implements ConfigData { - @ConfigEntry.Gui.Excluded - private transient static boolean registered = false; - @ConfigEntry.Gui.TransitiveObject - @ConfigEntry.Category("spawning") - public SpawnOptions spawning = new SpawnOptions(); - @ConfigEntry.Gui.TransitiveObject - @ConfigEntry.Category("generation") - public GenerationOptions generation = new GenerationOptions(); + @ConfigEntry.Gui.Excluded + private static boolean registered = false; + @ConfigEntry.Gui.TransitiveObject + @ConfigEntry.Category("spawning") + public SpawnOptions spawning = new SpawnOptions(); + @ConfigEntry.Gui.TransitiveObject + @ConfigEntry.Category("generation") + public GenerationOptions generation = new GenerationOptions(); - public boolean snowballConversion = false; - public boolean mooseEatBark = true; - @ConfigEntry.Gui.CollapsibleObject - public SealFishing sealFishing = new SealFishing(); + public boolean snowballConversion = false; + public boolean mooseEatBark = true; + @ConfigEntry.Gui.CollapsibleObject + public SealFishing sealFishing = new SealFishing(); - public static synchronized AlaskaConfig getConfig() { - if (!registered) { - AutoConfig.register(AlaskaConfig.class, GsonConfigSerializer::new); - registered = true; - } + public static synchronized AlaskaConfig getConfig() { + if (!registered) { + AutoConfig.register(AlaskaConfig.class, GsonConfigSerializer::new); + registered = true; + } - return AutoConfig.getConfigHolder(AlaskaConfig.class).getConfig(); - } + return AutoConfig.getConfigHolder(AlaskaConfig.class).getConfig(); + } - public static class SealFishing { - public boolean sealsHuntFish = true; - @ConfigEntry.Gui.Tooltip(count = 2) - public boolean sealsEatHuntedFish = true; - @ConfigEntry.Gui.Tooltip(count = 2) - public boolean sealsBreedFromHuntedFish = false; - } + public static class SealFishing { + public boolean sealsHuntFish = true; + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean sealsEatHuntedFish = true; + @ConfigEntry.Gui.Tooltip(count = 2) + public boolean sealsBreedFromHuntedFish = false; + } - public static class SpawnOptions { - @ConfigEntry.Gui.CollapsibleObject - public SpawnSettings sealOceanSettings = new SpawnSettings(5, 1, 4); - @ConfigEntry.Gui.CollapsibleObject - public SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3); - @ConfigEntry.Gui.CollapsibleObject - public SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5); + public static class SpawnOptions { + @ConfigEntry.Gui.CollapsibleObject + public SpawnSettings sealOceanSettings = new SpawnSettings(5, 1, 4); + @ConfigEntry.Gui.CollapsibleObject + public SpawnSettings mooseSettings = new SpawnSettings(2, 1, 3); + @ConfigEntry.Gui.CollapsibleObject + public SpawnSettings ptarmiganSettings = new SpawnSettings(5, 2, 5); - public static class SpawnSettings { - @ConfigEntry.Gui.RequiresRestart - public int weight; - @ConfigEntry.Gui.RequiresRestart - public int minGroupSize; - @ConfigEntry.Gui.RequiresRestart - public int maxGroupSize; + public static class SpawnSettings { + @ConfigEntry.Gui.RequiresRestart + public int weight; + @ConfigEntry.Gui.RequiresRestart + public int minGroupSize; + @ConfigEntry.Gui.RequiresRestart + public int maxGroupSize; - public SpawnSettings(int weight, int minGroupSize, int maxGroupSize) { - this.weight = weight; - this.minGroupSize = minGroupSize; - this.maxGroupSize = maxGroupSize; - } - } - } + public SpawnSettings(int weight, int minGroupSize, int maxGroupSize) { + this.weight = weight; + this.minGroupSize = minGroupSize; + this.maxGroupSize = maxGroupSize; + } + } + } - public static class GenerationOptions { - @ConfigEntry.Gui.RequiresRestart - public boolean genDriftwood = true; - @ConfigEntry.Gui.RequiresRestart - public boolean genBlueberry = true; - @ConfigEntry.Gui.RequiresRestart - public boolean genCloudberry = true; - @ConfigEntry.Gui.RequiresRestart - public boolean genRaspberry = true; - @ConfigEntry.Gui.RequiresRestart - public boolean genSalmonberry = true; - @ConfigEntry.Gui.RequiresRestart - public boolean genLabradorTea = true; - } + public static class GenerationOptions { + @ConfigEntry.Gui.RequiresRestart + public boolean genDriftwood = true; + @ConfigEntry.Gui.RequiresRestart + public boolean genBlueberry = true; + @ConfigEntry.Gui.RequiresRestart + public boolean genCloudberry = true; + @ConfigEntry.Gui.RequiresRestart + public boolean genRaspberry = true; + @ConfigEntry.Gui.RequiresRestart + public boolean genSalmonberry = true; + @ConfigEntry.Gui.RequiresRestart + public boolean genLabradorTea = true; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java index 666cfe74..b2336911 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/AlaskaEntities.java @@ -1,5 +1,8 @@ package com.github.platymemo.alaskanativecraft.entity; +import java.util.LinkedHashMap; +import java.util.Map; + import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; @@ -7,6 +10,7 @@ import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; @@ -16,85 +20,83 @@ import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; + import org.quiltmc.qsl.worldgen.biome.api.BiomeModifications; import org.quiltmc.qsl.worldgen.biome.api.BiomeSelectors; -import java.util.LinkedHashMap; -import java.util.Map; - public class AlaskaEntities { - private static final Map> ENTITY_TYPES = new LinkedHashMap<>(); - - public static final EntityType HARP_SEAL = add("harp_seal", createEntity(SpawnGroup.WATER_CREATURE, SealEntity::new, true, 1.0F, 0.6F)); - public static final EntityType PTARMIGAN = add("ptarmigan", createEntity(SpawnGroup.AMBIENT, PtarmiganEntity::new, false, 0.5F, 0.5F)); - public static final EntityType MOOSE = add("moose", createEntity(SpawnGroup.CREATURE, MooseEntity::new, true, 3F, 2.6F)); - public static final EntityType DOGSLED = add("dogsled", createEntity(SpawnGroup.MISC, DogsledEntity::new, false, 1.5F, 1.0F)); - - public static final EntityType WOODEN_HARPOON = add("wooden_harpoon", createHarpoon(AlaskaItems.WOODEN_HARPOON)); - public static final EntityType STONE_HARPOON = add("stone_harpoon", createHarpoon(AlaskaItems.STONE_HARPOON)); - public static final EntityType IRON_HARPOON = add("iron_harpoon", createHarpoon(AlaskaItems.IRON_HARPOON)); - public static final EntityType GOLDEN_HARPOON = add("golden_harpoon", createHarpoon(AlaskaItems.GOLDEN_HARPOON)); - public static final EntityType DIAMOND_HARPOON = add("diamond_harpoon", createHarpoon(AlaskaItems.DIAMOND_HARPOON)); - public static final EntityType NETHERITE_HARPOON = add("netherite_harpoon", createHarpoon(AlaskaItems.NETHERITE_HARPOON)); - - public static void register() { - for (Identifier id : ENTITY_TYPES.keySet()) { - Registry.register(Registry.ENTITY_TYPE, id, ENTITY_TYPES.get(id)); - } - - initAttributes(); - initSpawns(); - initSpawnRestrictions(); - } - - private static void initSpawnRestrictions() { - SpawnRestriction.register(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn); - SpawnRestriction.register(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn); - SpawnRestriction.register(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn); - } - - // IntelliJ wrongly infers that the register call fails due to calling an accessor that throws an AssertionError - @SuppressWarnings("ConstantConditions") - private static void initAttributes() { - FabricDefaultAttributeRegistry.register(HARP_SEAL, SealEntity.createSealAttributes()); - FabricDefaultAttributeRegistry.register(PTARMIGAN, PtarmiganEntity.createPtarmiganAttributes()); - FabricDefaultAttributeRegistry.register(MOOSE, MooseEntity.createMooseAttributes()); - } - - private static void initSpawns() { - AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning; - BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_SEAL), - SpawnGroup.WATER_CREATURE, HARP_SEAL, - spawnOptions.sealOceanSettings.weight, - spawnOptions.sealOceanSettings.minGroupSize, - spawnOptions.sealOceanSettings.maxGroupSize); - BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_MOOSE), - SpawnGroup.CREATURE, MOOSE, - spawnOptions.mooseSettings.weight, - spawnOptions.mooseSettings.minGroupSize, - spawnOptions.mooseSettings.maxGroupSize); - BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_PTARMIGAN), - SpawnGroup.AMBIENT, PTARMIGAN, - spawnOptions.ptarmiganSettings.weight, - spawnOptions.ptarmiganSettings.minGroupSize, - spawnOptions.ptarmiganSettings.maxGroupSize); - } - - private static > E add(String name, E type) { - Identifier id = new Identifier(AlaskaNativeCraft.MOD_ID, name); - ENTITY_TYPES.put(id, type); - return type; - } - - private static EntityType createHarpoon(HarpoonItem item) { - return FabricEntityTypeBuilder.create(SpawnGroup.MISC, (entity, world) -> new HarpoonEntity(entity, world, item)).dimensions(EntityDimensions.fixed(0.5F, 0.5F)).build(); - } - - private static EntityType createEntity(SpawnGroup group, EntityType.EntityFactory factory, boolean changingDimensions, float width, float height) { - if (changingDimensions) { - return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.changing(width, height)).build(); - } - return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.fixed(width, height)).build(); - } + private static final Map> ENTITY_TYPES = new LinkedHashMap<>(); + + public static final EntityType HARP_SEAL = add("harp_seal", createEntity(SpawnGroup.WATER_CREATURE, SealEntity::new, true, 1.0F, 0.6F)); + public static final EntityType PTARMIGAN = add("ptarmigan", createEntity(SpawnGroup.AMBIENT, PtarmiganEntity::new, false, 0.5F, 0.5F)); + public static final EntityType MOOSE = add("moose", createEntity(SpawnGroup.CREATURE, MooseEntity::new, true, 3F, 2.6F)); + public static final EntityType DOGSLED = add("dogsled", createEntity(SpawnGroup.MISC, DogsledEntity::new, false, 1.5F, 1.0F)); + + public static final EntityType WOODEN_HARPOON = add("wooden_harpoon", createHarpoon(AlaskaItems.WOODEN_HARPOON)); + public static final EntityType STONE_HARPOON = add("stone_harpoon", createHarpoon(AlaskaItems.STONE_HARPOON)); + public static final EntityType IRON_HARPOON = add("iron_harpoon", createHarpoon(AlaskaItems.IRON_HARPOON)); + public static final EntityType GOLDEN_HARPOON = add("golden_harpoon", createHarpoon(AlaskaItems.GOLDEN_HARPOON)); + public static final EntityType DIAMOND_HARPOON = add("diamond_harpoon", createHarpoon(AlaskaItems.DIAMOND_HARPOON)); + public static final EntityType NETHERITE_HARPOON = add("netherite_harpoon", createHarpoon(AlaskaItems.NETHERITE_HARPOON)); + + public static void register() { + for (Identifier id : ENTITY_TYPES.keySet()) { + Registry.register(Registry.ENTITY_TYPE, id, ENTITY_TYPES.get(id)); + } + + initAttributes(); + initSpawns(); + initSpawnRestrictions(); + } + + private static void initSpawnRestrictions() { + SpawnRestriction.register(HARP_SEAL, SpawnRestriction.Location.IN_WATER, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, SealEntity::canSpawn); + SpawnRestriction.register(MOOSE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::isValidNaturalSpawn); + SpawnRestriction.register(PTARMIGAN, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING, PtarmiganEntity::isValidSpawn); + } + + // IntelliJ wrongly infers that the register call fails due to calling an accessor that throws an AssertionError + @SuppressWarnings("ConstantConditions") + private static void initAttributes() { + FabricDefaultAttributeRegistry.register(HARP_SEAL, SealEntity.createSealAttributes()); + FabricDefaultAttributeRegistry.register(PTARMIGAN, PtarmiganEntity.createPtarmiganAttributes()); + FabricDefaultAttributeRegistry.register(MOOSE, MooseEntity.createMooseAttributes()); + } + + private static void initSpawns() { + AlaskaConfig.SpawnOptions spawnOptions = AlaskaConfig.getConfig().spawning; + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_SEAL), + SpawnGroup.WATER_CREATURE, HARP_SEAL, + spawnOptions.sealOceanSettings.weight, + spawnOptions.sealOceanSettings.minGroupSize, + spawnOptions.sealOceanSettings.maxGroupSize); + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_MOOSE), + SpawnGroup.CREATURE, MOOSE, + spawnOptions.mooseSettings.weight, + spawnOptions.mooseSettings.minGroupSize, + spawnOptions.mooseSettings.maxGroupSize); + BiomeModifications.addSpawn(BiomeSelectors.isIn(AlaskaTags.HAS_PTARMIGAN), + SpawnGroup.AMBIENT, PTARMIGAN, + spawnOptions.ptarmiganSettings.weight, + spawnOptions.ptarmiganSettings.minGroupSize, + spawnOptions.ptarmiganSettings.maxGroupSize); + } + + private static > E add(String name, E type) { + Identifier id = new Identifier(AlaskaNativeCraft.MOD_ID, name); + ENTITY_TYPES.put(id, type); + return type; + } + + private static EntityType createHarpoon(HarpoonItem item) { + return FabricEntityTypeBuilder.create(SpawnGroup.MISC, (entity, world) -> new HarpoonEntity(entity, world, item)).dimensions(EntityDimensions.fixed(0.5F, 0.5F)).build(); + } + + private static EntityType createEntity(SpawnGroup group, EntityType.EntityFactory factory, boolean changingDimensions, float width, float height) { + if (changingDimensions) { + return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.changing(width, height)).build(); + } + return FabricEntityTypeBuilder.create(group, factory).dimensions(EntityDimensions.fixed(width, height)).build(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java index a001786b..6ea3e293 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/DogsledEntity.java @@ -1,15 +1,27 @@ package com.github.platymemo.alaskanativecraft.entity; +import java.util.Iterator; +import java.util.List; + import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.google.common.collect.Lists; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.advancement.criterion.Criteria; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.LilyPadBlock; -import net.minecraft.entity.*; +import net.minecraft.entity.Dismounting; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityDimensions; +import net.minecraft.entity.EntityPose; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.MovementType; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.data.DataTracker; import net.minecraft.entity.data.TrackedData; @@ -46,844 +58,845 @@ import net.minecraft.util.ItemScatterer; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.function.BooleanBiFunction; -import net.minecraft.util.math.*; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.util.shape.VoxelShape; import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockLocating; import net.minecraft.world.GameRules; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Iterator; -import java.util.List; public class DogsledEntity extends Entity implements Inventory, NamedScreenHandlerFactory { - private static final TrackedData DAMAGE_WOBBLE_TICKS; - private static final TrackedData DAMAGE_WOBBLE_SIDE; - private static final TrackedData DAMAGE_WOBBLE_STRENGTH; - private static final TrackedData DOGSLED_TYPE; - - static { - DAMAGE_WOBBLE_TICKS = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); - DAMAGE_WOBBLE_SIDE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); - DAMAGE_WOBBLE_STRENGTH = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.FLOAT); - DOGSLED_TYPE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); - } - - private float ticksUnderwater; - private float yawVelocity; - private float velocityDecay; - private int clientInterpolationSteps; - private double x; - private double y; - private double z; - private double dogsledYaw; - private double dogsledPitch; - private boolean pressingLeft; - private boolean pressingRight; - private boolean pressingForward; - private boolean pressingBack; - private double waterLevel; - private Location location; - private DefaultedList inventory; - @Nullable - private Identifier lootTableId; - private long lootSeed; - - public DogsledEntity(EntityType entityType, World world) { - super(entityType, world); - this.stepHeight = 1.0F; - this.inventory = DefaultedList.ofSize(36, ItemStack.EMPTY); - this.onGround = true; - } - - public DogsledEntity(World world, double x, double y, double z) { - this(AlaskaEntities.DOGSLED, world); - this.setPosition(x, y, z); - this.setVelocity(Vec3d.ZERO); - this.prevX = x; - this.prevY = y; - this.prevZ = z; - } - - @Override - protected float getEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) { - return dimensions.height; - } - - @Override - protected void initDataTracker() { - this.dataTracker.startTracking(DAMAGE_WOBBLE_TICKS, 0); - this.dataTracker.startTracking(DAMAGE_WOBBLE_SIDE, 1); - this.dataTracker.startTracking(DAMAGE_WOBBLE_STRENGTH, 0.0F); - this.dataTracker.startTracking(DOGSLED_TYPE, DogsledEntity.Type.OAK.ordinal()); - } - - @Override - public boolean collidesWith(Entity other) { - return BoatEntity.canCollide(this, other); - } - - @Override - public boolean isCollidable() { - return true; - } - - @Override - public boolean isPushable() { - return true; - } - - @Override - protected Vec3d positionInPortal(Direction.Axis axis, BlockLocating.Rectangle arg) { - return LivingEntity.positionInPortal(super.positionInPortal(axis, arg)); - } - - @Override - public void pushAwayFrom(Entity entity) { - if (entity instanceof BoatEntity || entity instanceof DogsledEntity) { - if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { - super.pushAwayFrom(entity); - } - } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) { - super.pushAwayFrom(entity); - } - - } - - public Item asItem() { - return switch (this.getDogsledType()) { - default -> AlaskaItems.OAK_DOGSLED; - case SPRUCE -> AlaskaItems.SPRUCE_DOGSLED; - case BIRCH -> AlaskaItems.BIRCH_DOGSLED; - case JUNGLE -> AlaskaItems.JUNGLE_DOGSLED; - case ACACIA -> AlaskaItems.ACACIA_DOGSLED; - case DARK_OAK -> AlaskaItems.DARK_OAK_DOGSLED; - }; - } - - @Override - @Environment(EnvType.CLIENT) - public void animateDamage() { - this.setDamageWobbleSide(-this.getDamageWobbleSide()); - this.setDamageWobbleTicks(10); - this.setDamageWobbleStrength(this.getDamageWobbleStrength() * 11.0F); - } - - @Override - public boolean collides() { - return !this.isRemoved(); - } - - @Override - @Environment(EnvType.CLIENT) - public void updateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) { - this.x = x; - this.y = y; - this.z = z; - this.dogsledYaw = yaw; - this.dogsledPitch = pitch; - this.clientInterpolationSteps = 10; - } - - @Override - public Direction getMovementDirection() { - return this.getHorizontalFacing().rotateYClockwise(); - } - - @Override - public void tick() { - this.location = this.checkLocation(); - if (this.location != Location.UNDER_WATER && this.location != Location.UNDER_FLOWING_WATER) { - this.ticksUnderwater = 0.0F; - } else { - ++this.ticksUnderwater; - } - - if (!this.world.isClient && this.ticksUnderwater >= 60.0F) { - this.removeAllPassengers(); - } - - if (this.getDamageWobbleTicks() > 0) { - this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1); - } - - if (this.getDamageWobbleStrength() > 0.0F) { - this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F); - } - - super.tick(); - this.clientInterpolation(); - if (this.isLogicalSideForUpdatingMovement()) { - this.updateVelocity(); - if (this.world.isClient) { - this.updateMovement(); - } - this.move(MovementType.SELF, this.getVelocity()); - } else { - this.setVelocity(Vec3d.ZERO); - } - - for (Entity passenger : this.getPassengerList()) { - if (passenger instanceof WolfEntity) { - if (!MathHelper.approximatelyEquals(this.getVelocity().length(), 0.0D)) { - ((TameableEntity) passenger).setInSittingPose(false); - } - ((LivingEntity) passenger).updateLimbs(((LivingEntity) passenger), false); - } - } - - this.checkBlockCollision(); - List list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntityPredicates.canBePushedBy(this)); - if (!list.isEmpty()) { - boolean bl = !this.world.isClient; - - for (Entity entity : list) { - if (!entity.hasPassenger(this)) { - if (bl && this.getPassengerList().size() < 2 && !entity.hasVehicle() && entity instanceof WolfEntity && ((WolfEntity) entity).getOwner() != null && !((WolfEntity) entity).isBaby()) { - entity.startRiding(this); - } else { - this.pushAwayFrom(entity); - } - } - } - } - - } - - private void clientInterpolation() { - if (this.isLogicalSideForUpdatingMovement()) { - this.clientInterpolationSteps = 0; - this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ()); - } - - if (this.clientInterpolationSteps > 0) { - double d = this.getX() + (this.x - this.getX()) / (double) this.clientInterpolationSteps; - double e = this.getY() + (this.y - this.getY()) / (double) this.clientInterpolationSteps; - double f = this.getZ() + (this.z - this.getZ()) / (double) this.clientInterpolationSteps; - double g = MathHelper.wrapDegrees(this.dogsledYaw - (double) this.getYaw()); - float yaw = (float) ((double) this.getYaw() + g / (double) this.clientInterpolationSteps); - float pitch = (float) ((double) this.getPitch() + (this.dogsledPitch - (double) this.getPitch()) / (double) this.clientInterpolationSteps); - --this.clientInterpolationSteps; - this.setPosition(d, e, f); - this.setRotation(yaw, pitch); - } - } - - private Location checkLocation() { - Location location = this.getUnderWaterLocation(); - if (location != null) { - this.waterLevel = this.getBoundingBox().maxY; - return location; - } else { - float f = this.getBlockSlipperiness(); - if (f > 0.0F) { - return Location.ON_LAND; - } else { - return Location.IN_AIR; - } - } - } - - public float getBlockSlipperiness() { - Box box = this.getBoundingBox(); - Box box2 = new Box(box.minX, box.minY - 0.001D, box.minZ, box.maxX, box.minY, box.maxZ); - int i = MathHelper.floor(box2.minX) - 1; - int j = MathHelper.ceil(box2.maxX) + 1; - int k = MathHelper.floor(box2.minY) - 1; - int l = MathHelper.ceil(box2.maxY) + 1; - int m = MathHelper.floor(box2.minZ) - 1; - int n = MathHelper.ceil(box2.maxZ) + 1; - VoxelShape voxelShape = VoxelShapes.cuboid(box2); - float f = 0.0F; - int o = 0; - BlockPos.Mutable mutable = new BlockPos.Mutable(); - - for (int p = i; p < j; ++p) { - for (int q = m; q < n; ++q) { - int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1); - if (r != 2) { - for (int s = k; s < l; ++s) { - if (r <= 0 || s != k && s != l - 1) { - mutable.set(p, s, q); - BlockState blockState = this.world.getBlockState(mutable); - BlockState topBlock = this.world.getBlockState(mutable.up()); - if (blockState.isOf(Blocks.SNOW_BLOCK) || topBlock.isOf(Blocks.SNOW)) { - f += 0.95F; - ++o; - } else if (!(blockState.getBlock() instanceof LilyPadBlock) && VoxelShapes.matchesAnywhere(blockState.getCollisionShape(this.world, mutable).offset(p, s, q), voxelShape, BooleanBiFunction.AND)) { - f += blockState.getBlock().getSlipperiness(); - ++o; - } - } - } - } - } - } - - return f / (float) o; - } - - @Nullable - private Location getUnderWaterLocation() { - Box box = this.getBoundingBox(); - double d = box.maxY + 0.001D; - int i = MathHelper.floor(box.minX); - int j = MathHelper.ceil(box.maxX); - int k = MathHelper.floor(box.maxY); - int l = MathHelper.ceil(d); - int m = MathHelper.floor(box.minZ); - int n = MathHelper.ceil(box.maxZ); - boolean bl = false; - BlockPos.Mutable mutable = new BlockPos.Mutable(); - - for (int o = i; o < j; ++o) { - for (int p = k; p < l; ++p) { - for (int q = m; q < n; ++q) { - mutable.set(o, p, q); - FluidState fluidState = this.world.getFluidState(mutable); - if (fluidState.isIn(FluidTags.WATER)) { - float f = (float) p + fluidState.getHeight(this.world, mutable); - this.waterLevel = Math.max(f, this.waterLevel); - bl |= box.minY < (double) f; - if (d < (double) ((float) mutable.getY() + fluidState.getHeight(this.world, mutable))) { - if (!fluidState.isSource()) { - return Location.UNDER_FLOWING_WATER; - } - - bl = true; - } - } - } - } - } - - return bl ? Location.UNDER_WATER : null; - } - - private void updateMovement() { - if (this.hasPassengers()) { - float f = 0.0F; - if (this.pressingLeft) { - --this.yawVelocity; - } - - if (this.pressingRight) { - ++this.yawVelocity; - } - - if (this.pressingRight != this.pressingLeft && !this.pressingForward && !this.pressingBack) { - f += 0.005F; - } - - this.setYaw(this.getYaw() + this.yawVelocity); - if (this.pressingForward) { - f += 0.04F; - } - - if (this.pressingBack) { - f -= 0.005F; - } - - this.setVelocity(this.getVelocity().add((MathHelper.sin(-this.getYaw() * 0.017453292F) * f), 0.0D, (MathHelper.cos(this.getYaw() * 0.017453292F) * f))); - } - } - - private void updateVelocity() { - double e = this.hasNoGravity() ? 0.0D : -0.03999999910593033D; - double f = 0.0D; - if (this.location == Location.ON_LAND) { - velocityDecay = this.getBlockSlipperiness(); - } else { - if (this.location == Location.UNDER_FLOWING_WATER) { - e = -7.0E-4D; - } else if (this.location == Location.UNDER_WATER) { - f = 0.009999999776482582D; - } - velocityDecay *= 0.95F; - } - - if (this.getPassengerList().size() < 2) { - velocityDecay /= 1.15F; - } - - Vec3d vec3d = this.getVelocity(); - this.setVelocity(vec3d.x * (double) velocityDecay, vec3d.y + e, vec3d.z * (double) velocityDecay); - this.yawVelocity *= velocityDecay / 1.5F; - if (f > 0.0D) { - Vec3d vec3d2 = this.getVelocity(); - this.setVelocity(vec3d2.x, (vec3d2.y + f * 0.06153846016296973D) * 0.75D, vec3d2.z); - } - } - - @Override - public Vec3d updatePassengerForDismount(@NotNull LivingEntity passenger) { - Vec3d vec3d = getPassengerDismountOffset((this.getWidth() * MathHelper.SQUARE_ROOT_OF_TWO), passenger.getWidth(), passenger.getYaw()); - double d = this.getX() + vec3d.x; - double e = this.getZ() + vec3d.z; - BlockPos blockPos = new BlockPos(d, this.getBoundingBox().maxY, e); - BlockPos blockPos2 = blockPos.down(); - if (!this.world.isWater(blockPos2)) { - List list = Lists.newArrayList(); - double f = this.world.getDismountHeight(blockPos); - if (Dismounting.canDismountInBlock(f)) { - list.add(new Vec3d(d, (double) blockPos.getY() + f, e)); - } - - double g = this.world.getDismountHeight(blockPos2); - if (Dismounting.canDismountInBlock(g)) { - list.add(new Vec3d(d, (double) blockPos2.getY() + g, e)); - } - - for (EntityPose entityPose : passenger.getPoses()) { - for (Vec3d vec3d2 : list) { - if (Dismounting.canPlaceEntityAt(this.world, vec3d2, passenger, entityPose)) { - passenger.setPose(entityPose); - return vec3d2; - } - } - } - } - - return super.updatePassengerForDismount(passenger); - } - - protected void copyEntityData(@NotNull Entity entity) { - entity.setBodyYaw(this.getYaw()); - float f = MathHelper.wrapDegrees(entity.getYaw() - this.getYaw()); - float g = MathHelper.clamp(f, -105.0F, 105.0F); - entity.prevYaw += (g - f); - entity.setYaw(entity.getYaw() + g - f); - entity.setHeadYaw(entity.getYaw()); - } - - @Override - @Environment(EnvType.CLIENT) - public void onPassengerLookAround(Entity passenger) { - this.copyEntityData(passenger); - } - - @Override - protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) { - if (!this.hasVehicle()) { - if (onGround) { - if (this.fallDistance > 3.0F) { - if (this.location != Location.ON_LAND) { - this.fallDistance = 0.0F; - return; - } - - this.handleFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); - if (!this.world.isClient && !this.isRemoved()) { - this.kill(); - if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { - int j; - for (j = 0; j < 3; ++j) { - this.dropItem(this.getDogsledType().getBaseBlock()); - } - - for (j = 0; j < 2; ++j) { - this.dropItem(Items.STICK); - } - - dropItems(null); - } - } - } - - this.fallDistance = 0.0F; - } else if (!this.world.getFluidState(this.getBlockPos().down()).isIn(FluidTags.WATER) && heightDifference < 0.0D) { - this.fallDistance = (float) ((double) this.fallDistance - heightDifference); - } - - } - } - - public float getDamageWobbleStrength() { - return this.dataTracker.get(DAMAGE_WOBBLE_STRENGTH); - } - - public void setDamageWobbleStrength(float wobbleStrength) { - this.dataTracker.set(DAMAGE_WOBBLE_STRENGTH, wobbleStrength); - } - - public int getDamageWobbleTicks() { - return this.dataTracker.get(DAMAGE_WOBBLE_TICKS); - } - - public void setDamageWobbleTicks(int wobbleTicks) { - this.dataTracker.set(DAMAGE_WOBBLE_TICKS, wobbleTicks); - } - - public int getDamageWobbleSide() { - return this.dataTracker.get(DAMAGE_WOBBLE_SIDE); - } - - public void setDamageWobbleSide(int side) { - this.dataTracker.set(DAMAGE_WOBBLE_SIDE, side); - } - - public DogsledEntity.Type getDogsledType() { - return DogsledEntity.Type.getType(this.dataTracker.get(DOGSLED_TYPE)); - } - - public void setDogsledType(@NotNull DogsledEntity.Type type) { - this.dataTracker.set(DOGSLED_TYPE, type.ordinal()); - } - - @Override - protected boolean canAddPassenger(Entity passenger) { - int i = this.getPassengerList().size(); - if (this.isSubmergedIn(FluidTags.WATER)) { - return false; - } - if (i == 0) { - return passenger instanceof PlayerEntity || passenger instanceof WolfEntity; - } else if (i == 1) { - return passenger instanceof PlayerEntity; - } - return false; - } - - @Override - @Nullable - public Entity getPrimaryPassenger() { - List list = this.getPassengerList(); - return list.isEmpty() ? null : list.get(0); - } - - @Override - public boolean isSubmergedInWater() { - return this.location == Location.UNDER_WATER || this.location == Location.UNDER_FLOWING_WATER; - } - - @Override - public Packet createSpawnPacket() { - return new EntitySpawnS2CPacket(this); - } - - @Environment(EnvType.CLIENT) - public void setInputs(boolean pressingLeft, boolean pressingRight, boolean pressingForward, boolean pressingBack) { - this.pressingLeft = pressingLeft; - this.pressingRight = pressingRight; - this.pressingForward = pressingForward; - this.pressingBack = pressingBack; - } - - @Override - public int size() { - return 27; - } - - @Override - public double getMountedHeightOffset() { - return 0.2D; - } - - @Override - public boolean damage(DamageSource source, float amount) { - if (!this.world.isClient && !this.isRemoved()) { - if (this.isInvulnerableTo(source)) { - return false; - } else { - this.setDamageWobbleSide(-this.getDamageWobbleSide()); - this.setDamageWobbleTicks(10); - this.scheduleVelocityUpdate(); - this.setDamageWobbleStrength(this.getDamageWobbleStrength() + amount * 10.0F); - boolean bl = source.getAttacker() instanceof PlayerEntity && ((PlayerEntity) source.getAttacker()).getAbilities().creativeMode; - if (bl || this.getDamageWobbleStrength() > 40.0F) { - this.removeAllPassengers(); - if (bl && !this.hasCustomName()) { - this.discard(); - } else { - this.dropItems(source); - } - } - - return true; - } - } else { - return true; - } - } - - @Override - public void removeAllPassengers() { - for (int i = this.getPassengerList().size() - 1; i >= 0; --i) { - Entity entity = this.getPassengerList().get(i); - if (entity instanceof WolfEntity) { - entity.noClip = false; - } - entity.stopRiding(); - } - } - - public void dropItems(DamageSource damageSource) { - this.remove(RemovalReason.KILLED); - if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { - if (damageSource != null) { - ItemStack itemStack = this.asItem().getDefaultStack(); - if (this.hasCustomName()) { - itemStack.setCustomName(this.getCustomName()); - } - this.dropStack(itemStack); - } - ItemScatterer.spawn(this.world, this, this); - if (damageSource != null && !this.world.isClient) { - Entity entity = damageSource.getSource(); - if (entity != null && entity.getType() == EntityType.PLAYER) { - PiglinBrain.onGuardedBlockInteracted((PlayerEntity) entity, true); - } - } - } - } - - @Override - public void updatePassengerPosition(Entity passenger) { - this.updatePassengerPosition(passenger, Entity::setPosition); - } - - private void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) { - if (this.hasPassenger(passenger)) { - if (passenger instanceof PlayerEntity) { - float g = (float) ((this.isRemoved() ? 0.009999999776482582D : this.getMountedHeightOffset()) + passenger.getHeightOffset()); - double x = MathHelper.cos((this.getYaw() + 90.0F) * 0.0174533F); - double z = MathHelper.sin((this.getYaw() + 90.0F) * 0.0174533F); - positionUpdater.accept(passenger, this.getX() - x, this.getY() + (double) g, this.getZ() - z); - } else if (passenger instanceof WolfEntity) { - passenger.noClip = true; - Vec3d vec3d = (new Vec3d(1.5D, 0.0D, 0.0D)).rotateY(-this.getYaw() * 0.017453292F - 1.5707964F); - positionUpdater.accept(passenger, this.getX() + vec3d.x, this.getY(), this.getZ() + vec3d.z); - passenger.setYaw(passenger.getYaw() + this.yawVelocity); - passenger.setHeadYaw(passenger.getHeadYaw() + this.yawVelocity); - this.copyEntityData(passenger); - } - } - } - - @Override - public void writeCustomDataToNbt(@NotNull NbtCompound tag) { - tag.putString("Type", this.getDogsledType().getName()); - if (this.lootTableId != null) { - tag.putString("LootTable", this.lootTableId.toString()); - if (this.lootSeed != 0L) { - tag.putLong("LootTableSeed", this.lootSeed); - } - } else { - Inventories.writeNbt(tag, this.inventory); - } - - } - - @Override - public void readCustomDataFromNbt(@NotNull NbtCompound tag) { - if (tag.contains("Type", 8)) { - this.setDogsledType(DogsledEntity.Type.getType(tag.getString("Type"))); - } - this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY); - if (tag.contains("LootTable", 8)) { - this.lootTableId = new Identifier(tag.getString("LootTable")); - this.lootSeed = tag.getLong("LootTableSeed"); - } else { - Inventories.readNbt(tag, this.inventory); - } - - } - - @Override - public ActionResult interact(@NotNull PlayerEntity player, Hand hand) { - if (player.isSneaking()) { - player.openHandledScreen(this); - if (!player.world.isClient) { - PiglinBrain.onGuardedBlockInteracted(player, true); - return ActionResult.CONSUME; - } else { - return ActionResult.SUCCESS; - } - } else { - if (this.ticksUnderwater < 60.0F) { - if (!this.world.isClient) { - return player.startRiding(this) ? ActionResult.CONSUME : ActionResult.PASS; - } else { - return ActionResult.SUCCESS; - } - } else { - return ActionResult.PASS; - } - } - } - - @Override - public boolean isEmpty() { - Iterator var1 = this.inventory.iterator(); - - ItemStack itemStack; - do { - if (!var1.hasNext()) { - return true; - } - - itemStack = var1.next(); - } while (itemStack.isEmpty()); - - return false; - } - - @Override - public ItemStack getStack(int slot) { - this.generateLoot(null); - return this.inventory.get(slot); - } - - @Override - public ItemStack removeStack(int slot, int amount) { - this.generateLoot(null); - return Inventories.splitStack(this.inventory, slot, amount); - } - - @Override - public ItemStack removeStack(int slot) { - this.generateLoot(null); - ItemStack itemStack = this.inventory.get(slot); - if (itemStack.isEmpty()) { - return ItemStack.EMPTY; - } else { - this.inventory.set(slot, ItemStack.EMPTY); - return itemStack; - } - } - - @Override - public void setStack(int slot, ItemStack stack) { - this.generateLoot(null); - this.inventory.set(slot, stack); - if (!stack.isEmpty() && stack.getCount() > this.getMaxCountPerStack()) { - stack.setCount(this.getMaxCountPerStack()); - } - - } - - public boolean equip(int slot, ItemStack item) { - if (slot >= 0 && slot < this.size()) { - this.setStack(slot, item); - return true; - } else { - return false; - } - } - - @Override - public void markDirty() { - } - - @Override - public boolean canPlayerUse(PlayerEntity player) { - if (this.isRemoved()) { - return false; - } else { - return player.squaredDistanceTo(this) <= 64.0D; - } - } - - public void generateLoot(@Nullable PlayerEntity player) { - if (this.lootTableId != null && this.world.getServer() != null) { - LootTable lootTable = this.world.getServer().getLootManager().getTable(this.lootTableId); - if (player instanceof ServerPlayerEntity) { - Criteria.PLAYER_GENERATES_CONTAINER_LOOT.trigger((ServerPlayerEntity) player, this.lootTableId); - } - - this.lootTableId = null; - LootContext.Builder builder = (new LootContext.Builder((ServerWorld) this.world)).parameter(LootContextParameters.ORIGIN, this.getPos()).random(this.lootSeed); - if (player != null) { - builder.luck(player.getLuck()).parameter(LootContextParameters.THIS_ENTITY, player); - } - - lootTable.supplyInventory(this, builder.build(LootContextTypes.CHEST)); - } - - } - - @Override - public void clear() { - this.generateLoot(null); - this.inventory.clear(); - } - - public void setLootTable(Identifier id, long lootSeed) { - this.lootTableId = id; - this.lootSeed = lootSeed; - } - - @Override - @Nullable - public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) { - if (this.lootTableId != null && playerEntity.isSpectator()) { - return null; - } else { - this.generateLoot(playerInventory.player); - return this.getScreenHandler(i, playerInventory); - } - } - - public ScreenHandler getScreenHandler(int syncId, PlayerInventory playerInventory) { - return GenericContainerScreenHandler.createGeneric9x3(syncId, playerInventory, this); - } - - public enum Type { - OAK(Blocks.OAK_PLANKS, "oak"), - SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"), - BIRCH(Blocks.BIRCH_PLANKS, "birch"), - JUNGLE(Blocks.JUNGLE_PLANKS, "jungle"), - ACACIA(Blocks.ACACIA_PLANKS, "acacia"), - DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak"); - - private final String name; - private final Block baseBlock; - - Type(Block baseBlock, String name) { - this.name = name; - this.baseBlock = baseBlock; - } - - public static DogsledEntity.Type getType(int i) { - DogsledEntity.Type[] types = values(); - if (i < 0 || i >= types.length) { - i = 0; - } - - return types[i]; - } - - public static DogsledEntity.Type getType(String string) { - DogsledEntity.Type[] types = values(); - - for (Type type : types) { - if (type.getName().equals(string)) { - return type; - } - } - - return types[0]; - } - - public String getName() { - return this.name; - } - - public Block getBaseBlock() { - return this.baseBlock; - } - - public String toString() { - return this.name; - } - } - - public enum Location { - UNDER_WATER, - UNDER_FLOWING_WATER, - ON_LAND, - IN_AIR - } + private static final TrackedData DAMAGE_WOBBLE_TICKS; + private static final TrackedData DAMAGE_WOBBLE_SIDE; + private static final TrackedData DAMAGE_WOBBLE_STRENGTH; + private static final TrackedData DOGSLED_TYPE; + + static { + DAMAGE_WOBBLE_TICKS = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); + DAMAGE_WOBBLE_SIDE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); + DAMAGE_WOBBLE_STRENGTH = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.FLOAT); + DOGSLED_TYPE = DataTracker.registerData(DogsledEntity.class, TrackedDataHandlerRegistry.INTEGER); + } + + private float ticksUnderwater; + private float yawVelocity; + private float velocityDecay; + private int clientInterpolationSteps; + private double x; + private double y; + private double z; + private double dogsledYaw; + private double dogsledPitch; + private boolean pressingLeft; + private boolean pressingRight; + private boolean pressingForward; + private boolean pressingBack; + private double waterLevel; + private Location location; + private DefaultedList inventory; + @Nullable + private Identifier lootTableId; + private long lootSeed; + + public DogsledEntity(EntityType entityType, World world) { + super(entityType, world); + this.stepHeight = 1.0F; + this.inventory = DefaultedList.ofSize(36, ItemStack.EMPTY); + this.onGround = true; + } + + public DogsledEntity(World world, double x, double y, double z) { + this(AlaskaEntities.DOGSLED, world); + this.setPosition(x, y, z); + this.setVelocity(Vec3d.ZERO); + this.prevX = x; + this.prevY = y; + this.prevZ = z; + } + + @Override + protected float getEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) { + return dimensions.height; + } + + @Override + protected void initDataTracker() { + this.dataTracker.startTracking(DAMAGE_WOBBLE_TICKS, 0); + this.dataTracker.startTracking(DAMAGE_WOBBLE_SIDE, 1); + this.dataTracker.startTracking(DAMAGE_WOBBLE_STRENGTH, 0.0F); + this.dataTracker.startTracking(DOGSLED_TYPE, DogsledEntity.Type.OAK.ordinal()); + } + + @Override + public boolean collidesWith(Entity other) { + return BoatEntity.canCollide(this, other); + } + + @Override + public boolean isCollidable() { + return true; + } + + @Override + public boolean isPushable() { + return true; + } + + @Override + protected Vec3d positionInPortal(Direction.Axis axis, BlockLocating.Rectangle arg) { + return LivingEntity.positionInPortal(super.positionInPortal(axis, arg)); + } + + @Override + public void pushAwayFrom(Entity entity) { + if (entity instanceof BoatEntity || entity instanceof DogsledEntity) { + if (entity.getBoundingBox().minY < this.getBoundingBox().maxY) { + super.pushAwayFrom(entity); + } + } else if (entity.getBoundingBox().minY <= this.getBoundingBox().minY) { + super.pushAwayFrom(entity); + } + } + + public Item asItem() { + return switch (this.getDogsledType()) { + case SPRUCE -> AlaskaItems.SPRUCE_DOGSLED; + case BIRCH -> AlaskaItems.BIRCH_DOGSLED; + case JUNGLE -> AlaskaItems.JUNGLE_DOGSLED; + case ACACIA -> AlaskaItems.ACACIA_DOGSLED; + case DARK_OAK -> AlaskaItems.DARK_OAK_DOGSLED; + default -> AlaskaItems.OAK_DOGSLED; + }; + } + + @Override + @Environment(EnvType.CLIENT) + public void animateDamage() { + this.setDamageWobbleSide(-this.getDamageWobbleSide()); + this.setDamageWobbleTicks(10); + this.setDamageWobbleStrength(this.getDamageWobbleStrength() * 11.0F); + } + + @Override + public boolean collides() { + return !this.isRemoved(); + } + + @Override + @Environment(EnvType.CLIENT) + public void updateTrackedPositionAndAngles(double x, double y, double z, float yaw, float pitch, int interpolationSteps, boolean interpolate) { + this.x = x; + this.y = y; + this.z = z; + this.dogsledYaw = yaw; + this.dogsledPitch = pitch; + this.clientInterpolationSteps = 10; + } + + @Override + public Direction getMovementDirection() { + return this.getHorizontalFacing().rotateYClockwise(); + } + + @Override + public void tick() { + this.location = this.checkLocation(); + if (this.location != Location.UNDER_WATER && this.location != Location.UNDER_FLOWING_WATER) { + this.ticksUnderwater = 0.0F; + } else { + ++this.ticksUnderwater; + } + + if (!this.world.isClient && this.ticksUnderwater >= 60.0F) { + this.removeAllPassengers(); + } + + if (this.getDamageWobbleTicks() > 0) { + this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1); + } + + if (this.getDamageWobbleStrength() > 0.0F) { + this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F); + } + + super.tick(); + this.clientInterpolation(); + if (this.isLogicalSideForUpdatingMovement()) { + this.updateVelocity(); + if (this.world.isClient) { + this.updateMovement(); + } + + this.move(MovementType.SELF, this.getVelocity()); + } else { + this.setVelocity(Vec3d.ZERO); + } + + for (Entity passenger : this.getPassengerList()) { + if (passenger instanceof WolfEntity) { + if (!MathHelper.approximatelyEquals(this.getVelocity().length(), 0.0D)) { + ((TameableEntity) passenger).setInSittingPose(false); + } + + ((LivingEntity) passenger).updateLimbs(((LivingEntity) passenger), false); + } + } + + this.checkBlockCollision(); + List list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntityPredicates.canBePushedBy(this)); + if (!list.isEmpty()) { + boolean bl = !this.world.isClient; + + for (Entity entity : list) { + if (!entity.hasPassenger(this)) { + if (bl && this.getPassengerList().size() < 2 && !entity.hasVehicle() && entity instanceof WolfEntity && ((WolfEntity) entity).getOwner() != null && !((WolfEntity) entity).isBaby()) { + entity.startRiding(this); + } else { + this.pushAwayFrom(entity); + } + } + } + } + } + + private void clientInterpolation() { + if (this.isLogicalSideForUpdatingMovement()) { + this.clientInterpolationSteps = 0; + this.syncPacketPositionCodec(this.getX(), this.getY(), this.getZ()); + } + + if (this.clientInterpolationSteps > 0) { + double d = this.getX() + (this.x - this.getX()) / (double) this.clientInterpolationSteps; + double e = this.getY() + (this.y - this.getY()) / (double) this.clientInterpolationSteps; + double f = this.getZ() + (this.z - this.getZ()) / (double) this.clientInterpolationSteps; + double g = MathHelper.wrapDegrees(this.dogsledYaw - (double) this.getYaw()); + float yaw = (float) ((double) this.getYaw() + g / (double) this.clientInterpolationSteps); + float pitch = (float) ((double) this.getPitch() + (this.dogsledPitch - (double) this.getPitch()) / (double) this.clientInterpolationSteps); + --this.clientInterpolationSteps; + this.setPosition(d, e, f); + this.setRotation(yaw, pitch); + } + } + + private Location checkLocation() { + Location location = this.getUnderWaterLocation(); + if (location != null) { + this.waterLevel = this.getBoundingBox().maxY; + return location; + } else { + float f = this.getBlockSlipperiness(); + if (f > 0.0F) { + return Location.ON_LAND; + } else { + return Location.IN_AIR; + } + } + } + + public float getBlockSlipperiness() { + Box box = this.getBoundingBox(); + Box box2 = new Box(box.minX, box.minY - 0.001D, box.minZ, box.maxX, box.minY, box.maxZ); + int i = MathHelper.floor(box2.minX) - 1; + int j = MathHelper.ceil(box2.maxX) + 1; + int k = MathHelper.floor(box2.minY) - 1; + int l = MathHelper.ceil(box2.maxY) + 1; + int m = MathHelper.floor(box2.minZ) - 1; + int n = MathHelper.ceil(box2.maxZ) + 1; + VoxelShape voxelShape = VoxelShapes.cuboid(box2); + float f = 0.0F; + int o = 0; + BlockPos.Mutable mutable = new BlockPos.Mutable(); + + for (int p = i; p < j; ++p) { + for (int q = m; q < n; ++q) { + int r = (p != i && p != j - 1 ? 0 : 1) + (q != m && q != n - 1 ? 0 : 1); + if (r != 2) { + for (int s = k; s < l; ++s) { + if (r <= 0 || s != k && s != l - 1) { + mutable.set(p, s, q); + BlockState blockState = this.world.getBlockState(mutable); + BlockState topBlock = this.world.getBlockState(mutable.up()); + if (blockState.isOf(Blocks.SNOW_BLOCK) || topBlock.isOf(Blocks.SNOW)) { + f += 0.95F; + ++o; + } else if (!(blockState.getBlock() instanceof LilyPadBlock) && VoxelShapes.matchesAnywhere(blockState.getCollisionShape(this.world, mutable).offset(p, s, q), voxelShape, BooleanBiFunction.AND)) { + f += blockState.getBlock().getSlipperiness(); + ++o; + } + } + } + } + } + } + + return f / (float) o; + } + + @Nullable + private Location getUnderWaterLocation() { + Box box = this.getBoundingBox(); + double d = box.maxY + 0.001D; + int i = MathHelper.floor(box.minX); + int j = MathHelper.ceil(box.maxX); + int k = MathHelper.floor(box.maxY); + int l = MathHelper.ceil(d); + int m = MathHelper.floor(box.minZ); + int n = MathHelper.ceil(box.maxZ); + boolean bl = false; + BlockPos.Mutable mutable = new BlockPos.Mutable(); + + for (int o = i; o < j; ++o) { + for (int p = k; p < l; ++p) { + for (int q = m; q < n; ++q) { + mutable.set(o, p, q); + FluidState fluidState = this.world.getFluidState(mutable); + if (fluidState.isIn(FluidTags.WATER)) { + float f = (float) p + fluidState.getHeight(this.world, mutable); + this.waterLevel = Math.max(f, this.waterLevel); + bl |= box.minY < (double) f; + if (d < (double) ((float) mutable.getY() + fluidState.getHeight(this.world, mutable))) { + if (!fluidState.isSource()) { + return Location.UNDER_FLOWING_WATER; + } + + bl = true; + } + } + } + } + } + + return bl ? Location.UNDER_WATER : null; + } + + private void updateMovement() { + if (this.hasPassengers()) { + float f = 0.0F; + if (this.pressingLeft) { + --this.yawVelocity; + } + + if (this.pressingRight) { + ++this.yawVelocity; + } + + if (this.pressingRight != this.pressingLeft && !this.pressingForward && !this.pressingBack) { + f += 0.005F; + } + + this.setYaw(this.getYaw() + this.yawVelocity); + if (this.pressingForward) { + f += 0.04F; + } + + if (this.pressingBack) { + f -= 0.005F; + } + + this.setVelocity(this.getVelocity().add((MathHelper.sin(-this.getYaw() * 0.017453292F) * f), 0.0D, (MathHelper.cos(this.getYaw() * 0.017453292F) * f))); + } + } + + private void updateVelocity() { + double e = this.hasNoGravity() ? 0.0D : -0.03999999910593033D; + double f = 0.0D; + if (this.location == Location.ON_LAND) { + this.velocityDecay = this.getBlockSlipperiness(); + } else { + if (this.location == Location.UNDER_FLOWING_WATER) { + e = -7.0E-4D; + } else if (this.location == Location.UNDER_WATER) { + f = 0.009999999776482582D; + } + + this.velocityDecay *= 0.95F; + } + + if (this.getPassengerList().size() < 2) { + this.velocityDecay /= 1.15F; + } + + Vec3d vec3d = this.getVelocity(); + this.setVelocity(vec3d.x * (double) this.velocityDecay, vec3d.y + e, vec3d.z * (double) this.velocityDecay); + this.yawVelocity *= this.velocityDecay / 1.5F; + if (f > 0.0D) { + Vec3d vec3d2 = this.getVelocity(); + this.setVelocity(vec3d2.x, (vec3d2.y + f * 0.06153846016296973D) * 0.75D, vec3d2.z); + } + } + + @Override + public Vec3d updatePassengerForDismount(@NotNull LivingEntity passenger) { + Vec3d vec3d = getPassengerDismountOffset((this.getWidth() * MathHelper.SQUARE_ROOT_OF_TWO), passenger.getWidth(), passenger.getYaw()); + double d = this.getX() + vec3d.x; + double e = this.getZ() + vec3d.z; + BlockPos blockPos = new BlockPos(d, this.getBoundingBox().maxY, e); + BlockPos blockPos2 = blockPos.down(); + if (!this.world.isWater(blockPos2)) { + List list = Lists.newArrayList(); + double f = this.world.getDismountHeight(blockPos); + if (Dismounting.canDismountInBlock(f)) { + list.add(new Vec3d(d, (double) blockPos.getY() + f, e)); + } + + double g = this.world.getDismountHeight(blockPos2); + if (Dismounting.canDismountInBlock(g)) { + list.add(new Vec3d(d, (double) blockPos2.getY() + g, e)); + } + + for (EntityPose entityPose : passenger.getPoses()) { + for (Vec3d vec3d2 : list) { + if (Dismounting.canPlaceEntityAt(this.world, vec3d2, passenger, entityPose)) { + passenger.setPose(entityPose); + return vec3d2; + } + } + } + } + + return super.updatePassengerForDismount(passenger); + } + + protected void copyEntityData(@NotNull Entity entity) { + entity.setBodyYaw(this.getYaw()); + float f = MathHelper.wrapDegrees(entity.getYaw() - this.getYaw()); + float g = MathHelper.clamp(f, -105.0F, 105.0F); + entity.prevYaw += (g - f); + entity.setYaw(entity.getYaw() + g - f); + entity.setHeadYaw(entity.getYaw()); + } + + @Override + @Environment(EnvType.CLIENT) + public void onPassengerLookAround(Entity passenger) { + this.copyEntityData(passenger); + } + + @Override + protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) { + if (!this.hasVehicle()) { + if (onGround) { + if (this.fallDistance > 3.0F) { + if (this.location != Location.ON_LAND) { + this.fallDistance = 0.0F; + return; + } + + this.handleFallDamage(this.fallDistance, 1.0F, DamageSource.FALL); + if (!this.world.isClient && !this.isRemoved()) { + this.kill(); + if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { + int j; + for (j = 0; j < 3; ++j) { + this.dropItem(this.getDogsledType().getBaseBlock()); + } + + for (j = 0; j < 2; ++j) { + this.dropItem(Items.STICK); + } + + this.dropItems(null); + } + } + } + + this.fallDistance = 0.0F; + } else if (!this.world.getFluidState(this.getBlockPos().down()).isIn(FluidTags.WATER) && heightDifference < 0.0D) { + this.fallDistance = (float) ((double) this.fallDistance - heightDifference); + } + } + } + + public float getDamageWobbleStrength() { + return this.dataTracker.get(DAMAGE_WOBBLE_STRENGTH); + } + + public void setDamageWobbleStrength(float wobbleStrength) { + this.dataTracker.set(DAMAGE_WOBBLE_STRENGTH, wobbleStrength); + } + + public int getDamageWobbleTicks() { + return this.dataTracker.get(DAMAGE_WOBBLE_TICKS); + } + + public void setDamageWobbleTicks(int wobbleTicks) { + this.dataTracker.set(DAMAGE_WOBBLE_TICKS, wobbleTicks); + } + + public int getDamageWobbleSide() { + return this.dataTracker.get(DAMAGE_WOBBLE_SIDE); + } + + public void setDamageWobbleSide(int side) { + this.dataTracker.set(DAMAGE_WOBBLE_SIDE, side); + } + + public DogsledEntity.Type getDogsledType() { + return DogsledEntity.Type.getType(this.dataTracker.get(DOGSLED_TYPE)); + } + + public void setDogsledType(@NotNull DogsledEntity.Type type) { + this.dataTracker.set(DOGSLED_TYPE, type.ordinal()); + } + + @Override + protected boolean canAddPassenger(Entity passenger) { + int i = this.getPassengerList().size(); + if (this.isSubmergedIn(FluidTags.WATER)) { + return false; + } + + if (i == 0) { + return passenger instanceof PlayerEntity || passenger instanceof WolfEntity; + } else if (i == 1) { + return passenger instanceof PlayerEntity; + } + + return false; + } + + @Override + @Nullable + public Entity getPrimaryPassenger() { + List list = this.getPassengerList(); + return list.isEmpty() ? null : list.get(0); + } + + @Override + public boolean isSubmergedInWater() { + return this.location == Location.UNDER_WATER || this.location == Location.UNDER_FLOWING_WATER; + } + + @Override + public Packet createSpawnPacket() { + return new EntitySpawnS2CPacket(this); + } + + @Environment(EnvType.CLIENT) + public void setInputs(boolean pressingLeft, boolean pressingRight, boolean pressingForward, boolean pressingBack) { + this.pressingLeft = pressingLeft; + this.pressingRight = pressingRight; + this.pressingForward = pressingForward; + this.pressingBack = pressingBack; + } + + @Override + public int size() { + return 27; + } + + @Override + public double getMountedHeightOffset() { + return 0.2D; + } + + @Override + public boolean damage(DamageSource source, float amount) { + if (!this.world.isClient && !this.isRemoved()) { + if (this.isInvulnerableTo(source)) { + return false; + } else { + this.setDamageWobbleSide(-this.getDamageWobbleSide()); + this.setDamageWobbleTicks(10); + this.scheduleVelocityUpdate(); + this.setDamageWobbleStrength(this.getDamageWobbleStrength() + amount * 10.0F); + boolean bl = source.getAttacker() instanceof PlayerEntity && ((PlayerEntity) source.getAttacker()).getAbilities().creativeMode; + if (bl || this.getDamageWobbleStrength() > 40.0F) { + this.removeAllPassengers(); + if (bl && !this.hasCustomName()) { + this.discard(); + } else { + this.dropItems(source); + } + } + + return true; + } + } else { + return true; + } + } + + @Override + public void removeAllPassengers() { + for (int i = this.getPassengerList().size() - 1; i >= 0; --i) { + Entity entity = this.getPassengerList().get(i); + if (entity instanceof WolfEntity) { + entity.noClip = false; + } + + entity.stopRiding(); + } + } + + public void dropItems(DamageSource damageSource) { + this.remove(RemovalReason.KILLED); + if (this.world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) { + if (damageSource != null) { + ItemStack itemStack = this.asItem().getDefaultStack(); + if (this.hasCustomName()) { + itemStack.setCustomName(this.getCustomName()); + } + + this.dropStack(itemStack); + } + + ItemScatterer.spawn(this.world, this, this); + if (damageSource != null && !this.world.isClient) { + Entity entity = damageSource.getSource(); + if (entity != null && entity.getType() == EntityType.PLAYER) { + PiglinBrain.onGuardedBlockInteracted((PlayerEntity) entity, true); + } + } + } + } + + @Override + public void updatePassengerPosition(Entity passenger) { + this.updatePassengerPosition(passenger, Entity::setPosition); + } + + private void updatePassengerPosition(Entity passenger, Entity.PositionUpdater positionUpdater) { + if (this.hasPassenger(passenger)) { + if (passenger instanceof PlayerEntity) { + float g = (float) ((this.isRemoved() ? 0.009999999776482582D : this.getMountedHeightOffset()) + passenger.getHeightOffset()); + double x = MathHelper.cos((this.getYaw() + 90.0F) * 0.0174533F); + double z = MathHelper.sin((this.getYaw() + 90.0F) * 0.0174533F); + positionUpdater.accept(passenger, this.getX() - x, this.getY() + (double) g, this.getZ() - z); + } else if (passenger instanceof WolfEntity) { + passenger.noClip = true; + Vec3d vec3d = (new Vec3d(1.5D, 0.0D, 0.0D)).rotateY(-this.getYaw() * 0.017453292F - 1.5707964F); + positionUpdater.accept(passenger, this.getX() + vec3d.x, this.getY(), this.getZ() + vec3d.z); + passenger.setYaw(passenger.getYaw() + this.yawVelocity); + passenger.setHeadYaw(passenger.getHeadYaw() + this.yawVelocity); + this.copyEntityData(passenger); + } + } + } + + @Override + public void writeCustomDataToNbt(@NotNull NbtCompound tag) { + tag.putString("Type", this.getDogsledType().getName()); + if (this.lootTableId != null) { + tag.putString("LootTable", this.lootTableId.toString()); + if (this.lootSeed != 0L) { + tag.putLong("LootTableSeed", this.lootSeed); + } + } else { + Inventories.writeNbt(tag, this.inventory); + } + } + + @Override + public void readCustomDataFromNbt(@NotNull NbtCompound tag) { + if (tag.contains("Type", 8)) { + this.setDogsledType(DogsledEntity.Type.getType(tag.getString("Type"))); + } + + this.inventory = DefaultedList.ofSize(this.size(), ItemStack.EMPTY); + if (tag.contains("LootTable", 8)) { + this.lootTableId = new Identifier(tag.getString("LootTable")); + this.lootSeed = tag.getLong("LootTableSeed"); + } else { + Inventories.readNbt(tag, this.inventory); + } + } + + @Override + public ActionResult interact(@NotNull PlayerEntity player, Hand hand) { + if (player.isSneaking()) { + player.openHandledScreen(this); + if (!player.world.isClient) { + PiglinBrain.onGuardedBlockInteracted(player, true); + return ActionResult.CONSUME; + } else { + return ActionResult.SUCCESS; + } + } else { + if (this.ticksUnderwater < 60.0F) { + if (!this.world.isClient) { + return player.startRiding(this) ? ActionResult.CONSUME : ActionResult.PASS; + } else { + return ActionResult.SUCCESS; + } + } else { + return ActionResult.PASS; + } + } + } + + @Override + public boolean isEmpty() { + Iterator var1 = this.inventory.iterator(); + + ItemStack itemStack; + do { + if (!var1.hasNext()) { + return true; + } + + itemStack = var1.next(); + } while (itemStack.isEmpty()); + + return false; + } + + @Override + public ItemStack getStack(int slot) { + this.generateLoot(null); + return this.inventory.get(slot); + } + + @Override + public ItemStack removeStack(int slot, int amount) { + this.generateLoot(null); + return Inventories.splitStack(this.inventory, slot, amount); + } + + @Override + public ItemStack removeStack(int slot) { + this.generateLoot(null); + ItemStack itemStack = this.inventory.get(slot); + if (itemStack.isEmpty()) { + return ItemStack.EMPTY; + } else { + this.inventory.set(slot, ItemStack.EMPTY); + return itemStack; + } + } + + @Override + public void setStack(int slot, ItemStack stack) { + this.generateLoot(null); + this.inventory.set(slot, stack); + if (!stack.isEmpty() && stack.getCount() > this.getMaxCountPerStack()) { + stack.setCount(this.getMaxCountPerStack()); + } + } + + public boolean equip(int slot, ItemStack item) { + if (slot >= 0 && slot < this.size()) { + this.setStack(slot, item); + return true; + } else { + return false; + } + } + + @Override + public void markDirty() { + } + + @Override + public boolean canPlayerUse(PlayerEntity player) { + if (this.isRemoved()) { + return false; + } else { + return player.squaredDistanceTo(this) <= 64.0D; + } + } + + public void generateLoot(@Nullable PlayerEntity player) { + if (this.lootTableId != null && this.world.getServer() != null) { + LootTable lootTable = this.world.getServer().getLootManager().getTable(this.lootTableId); + if (player instanceof ServerPlayerEntity) { + Criteria.PLAYER_GENERATES_CONTAINER_LOOT.trigger((ServerPlayerEntity) player, this.lootTableId); + } + + this.lootTableId = null; + LootContext.Builder builder = (new LootContext.Builder((ServerWorld) this.world)).parameter(LootContextParameters.ORIGIN, this.getPos()).random(this.lootSeed); + if (player != null) { + builder.luck(player.getLuck()).parameter(LootContextParameters.THIS_ENTITY, player); + } + + lootTable.supplyInventory(this, builder.build(LootContextTypes.CHEST)); + } + } + + @Override + public void clear() { + this.generateLoot(null); + this.inventory.clear(); + } + + public void setLootTable(Identifier id, long lootSeed) { + this.lootTableId = id; + this.lootSeed = lootSeed; + } + + @Override + @Nullable + public ScreenHandler createMenu(int i, PlayerInventory playerInventory, PlayerEntity playerEntity) { + if (this.lootTableId != null && playerEntity.isSpectator()) { + return null; + } else { + this.generateLoot(playerInventory.player); + return this.getScreenHandler(i, playerInventory); + } + } + + public ScreenHandler getScreenHandler(int syncId, PlayerInventory playerInventory) { + return GenericContainerScreenHandler.createGeneric9x3(syncId, playerInventory, this); + } + + public enum Type { + OAK(Blocks.OAK_PLANKS, "oak"), + SPRUCE(Blocks.SPRUCE_PLANKS, "spruce"), + BIRCH(Blocks.BIRCH_PLANKS, "birch"), + JUNGLE(Blocks.JUNGLE_PLANKS, "jungle"), + ACACIA(Blocks.ACACIA_PLANKS, "acacia"), + DARK_OAK(Blocks.DARK_OAK_PLANKS, "dark_oak"); + + private final String name; + private final Block baseBlock; + + Type(Block baseBlock, String name) { + this.name = name; + this.baseBlock = baseBlock; + } + + public static DogsledEntity.Type getType(int i) { + DogsledEntity.Type[] types = values(); + if (i < 0 || i >= types.length) { + i = 0; + } + + return types[i]; + } + + public static DogsledEntity.Type getType(String string) { + DogsledEntity.Type[] types = values(); + + for (Type type : types) { + if (type.getName().equals(string)) { + return type; + } + } + + return types[0]; + } + + public String getName() { + return this.name; + } + + public Block getBaseBlock() { + return this.baseBlock; + } + + public String toString() { + return this.name; + } + } + + public enum Location { + UNDER_WATER, + UNDER_FLOWING_WATER, + ON_LAND, + IN_AIR + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java index ede9434b..03385f12 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/HarpoonEntity.java @@ -5,6 +5,9 @@ import io.netty.buffer.Unpooled; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -35,322 +38,327 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.registry.Registry; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; + import org.quiltmc.qsl.networking.api.ServerPlayNetworking; public class HarpoonEntity extends PersistentProjectileEntity { - public static final Identifier SPAWN_PACKET = new Identifier(AlaskaNativeCraft.MOD_ID, "harpoon_entity"); - private static final TrackedData LOYALTY; - private static final TrackedData ENCHANTED; - - static { - ENCHANTED = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BOOLEAN); - LOYALTY = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BYTE); - } - - public int returnTimer; - private ItemStack harpoonStack; - private HarpoonEntity.State state; - private boolean dealtDamage; - - public HarpoonEntity(EntityType entityType, World world, HarpoonItem item) { - super(entityType, world); - this.state = HarpoonEntity.State.FLYING; - this.harpoonStack = new ItemStack(item); - } - - public HarpoonEntity(World world, LivingEntity owner, @NotNull HarpoonItem item, @NotNull ItemStack stack) { - super(item.getType(), owner, world); - this.harpoonStack = stack.copy(); - this.state = HarpoonEntity.State.FLYING; - this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack)); - this.dataTracker.set(ENCHANTED, stack.hasGlint()); - } - - public static DamageSource createHarpoonDamageSource(Entity harpoon, Entity owner) { - return new ProjectileDamageSource("harpoon", harpoon, owner).setProjectile(); - } - - @Override - protected void initDataTracker() { - super.initDataTracker(); - this.dataTracker.startTracking(LOYALTY, (byte) 0); - this.dataTracker.startTracking(ENCHANTED, false); - } - - @Override - public Packet createSpawnPacket() { - PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); - - packet.writeVarInt(Registry.ENTITY_TYPE.getRawId(this.getType())); - packet.writeUuid(this.getUuid()); - packet.writeVarInt(this.getId()); - packet.writeDouble(this.getX()); - packet.writeDouble(this.getY()); - packet.writeDouble(this.getZ()); - packet.writeByte(MathHelper.floor(this.getPitch() * 256.0F / 360.0F)); - packet.writeByte(MathHelper.floor(this.getYaw() * 256.0F / 360.0F)); - - return ServerPlayNetworking.createS2CPacket(SPAWN_PACKET, packet); - } - - @Override - protected ItemStack asItemStack() { - return this.harpoonStack.copy(); - } - - @Environment(EnvType.CLIENT) - public boolean isEnchanted() { - return this.dataTracker.get(ENCHANTED); - } - - @Override - @Nullable - protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPosition) { - return this.dealtDamage ? null : super.getEntityCollision(currentPosition, nextPosition); - } - - @Override - public void tick() { - if (this.state == State.BOBBING) { - float fluidHeight = 0.0F; - BlockPos blockPos = this.getBlockPos(); - FluidState fluidState = this.world.getFluidState(blockPos); - if (fluidState.isIn(FluidTags.WATER)) { - fluidHeight = fluidState.getHeight(this.world, blockPos); - } - Vec3d vec3d = this.getVelocity(); - double distanceFromLiquidHeight = this.getY() + vec3d.y - (double) blockPos.getY() - (double) fluidHeight; - - // Set pitch, zero it if its minimal. - if (vec3d.y > 0.032D) { - this.setPitch((float) (MathHelper.atan2(vec3d.y, vec3d.horizontalLength()) * 57.2957763671875D)); - this.setPitch(updateRotation(this.prevPitch, this.getPitch())); - } else { - this.setPitch(updateRotation(this.prevPitch, 0.0F)); - } - - // Get bobbing action - if (Math.abs(distanceFromLiquidHeight) < 0.01D) { - distanceFromLiquidHeight += Math.signum(distanceFromLiquidHeight) * 0.1D; - } - this.setVelocity(vec3d.x * 0.9D, vec3d.y - distanceFromLiquidHeight * (double) this.random.nextFloat() * 0.2D, vec3d.z * 0.9D); - vec3d = this.getVelocity(); - this.setPosition(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z); - this.checkBlockCollision(); - return; - } - - if (this.inGroundTime > 4) { - this.dealtDamage = true; - } - - Entity entity = this.getOwner(); - if ((this.dealtDamage || this.isNoClip()) && entity != null) { - int i = this.dataTracker.get(LOYALTY); - if (i > 0 && !entity.isAlive()) { - if (!this.world.isClient && this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED) { - this.dropStack(this.asItemStack(), 0.1F); - } - - this.discard(); - } else if (i > 0) { - this.setNoClip(true); - Vec3d vec3d = new Vec3d(entity.getX() - this.getX(), entity.getEyeY() - this.getY(), entity.getZ() - this.getZ()); - this.setPos(this.getX(), this.getY() + vec3d.y * 0.015D * (double) i, this.getZ()); - if (this.world.isClient) { - this.lastRenderY = this.getY(); - } - - double d = 0.05D * (double) i; - this.setVelocity(this.getVelocity().multiply(0.95D).add(vec3d.normalize().multiply(d))); - if (this.returnTimer == 0) { - this.playSound(SoundEvents.ITEM_TRIDENT_RETURN, 10.0F, 1.0F); - } - - ++this.returnTimer; - } - } - - super.tick(); - boolean inWater = this.isTouchingWater(); - - // We don't change anything unless the Harpoon is underwater - if (this.inGround && this.state != State.LANDED) { - this.state = State.LANDED; - return; - } else if (!inWater || this.state != State.FLYING) { - return; - } - - // Harpoon must be underwater - - // Revert previous fall calculations - Vec3d velocity = this.getVelocity(); - double d = velocity.x; - double e = velocity.y + 0.05D; - double g = velocity.z; - this.setVelocity(d, e, g); - - double h = this.getX() - d; - double j = this.getY() - e; - double k = this.getZ() - g; - - // Now do regular tick stuff - float f = 0.0F; - BlockPos blockPos = this.getBlockPos(); - FluidState fluidState = this.world.getFluidState(blockPos); - if (fluidState.isIn(FluidTags.WATER)) { - f = fluidState.getHeight(this.world, blockPos); - } - velocity = this.getVelocity(); - double distanceFromLiquidHeight = this.getY() + velocity.y - (double) blockPos.getY() - (double) f; - - // The harpoon is still flying through water, so make it buoyant - if (distanceFromLiquidHeight > 0.0D && velocity.length() < 1) { - this.state = State.BOBBING; - } else { - this.setVelocity(velocity.x, velocity.y + 0.025D, velocity.z); - } - - velocity = this.getVelocity().multiply(this.getDragInWater()); - h += velocity.x; - j += velocity.y; - k += velocity.z; - this.setPosition(h, j, k); - this.checkBlockCollision(); - } - - @Override - protected void checkBlockCollision() { - super.checkBlockCollision(); - if (this.inGround) { - this.state = State.LANDED; - } - } - - @SuppressWarnings("ConstantConditions") - @Override - protected void onEntityHit(@NotNull EntityHitResult entityHitResult) { - Entity hitEntity = entityHitResult.getEntity(); - float f = ((HarpoonItem) this.harpoonStack.getItem()).getAttackDamage(); - if (hitEntity instanceof LivingEntity livingHitEntity) { - f += EnchantmentHelper.getAttackDamage(this.harpoonStack, livingHitEntity.getGroup()); - } - - Entity owner = this.getOwner(); - DamageSource damageSource = createHarpoonDamageSource(this, (owner == null ? this : owner)); - this.dealtDamage = true; - SoundEvent soundEvent = SoundEvents.ITEM_TRIDENT_HIT; - if (hitEntity.damage(damageSource, f)) { - if (hitEntity.getType() == EntityType.ENDERMAN) { - return; - } - - if (hitEntity instanceof LivingEntity livingHitEntity) { - if (owner instanceof LivingEntity) { - EnchantmentHelper.onUserDamaged(livingHitEntity, owner); - EnchantmentHelper.onTargetDamaged((LivingEntity) owner, livingHitEntity); - } - - this.onHit(livingHitEntity); - - if (hitEntity instanceof MobEntity && this.getOwner() instanceof PlayerEntity && !((MobEntity) hitEntity).isLeashed() && this.harpoonStack.getOrCreateNbt().contains("leashed") && this.harpoonStack.getOrCreateNbt().getBoolean("leashed")) { - ((MobEntity) hitEntity).attachLeash(this.getOwner(), true); - // Chance to lose the leash, based on level of Loyalty - // 100% at 0, 50% at 1, 33% at 2, etc. - if (this.random.nextInt(this.dataTracker.get(LOYALTY) + 1) == 0) { - this.harpoonStack.removeSubNbt("leashed"); - } - this.setVelocity(Vec3d.ZERO); - this.playSound(soundEvent, 1.0F, 1.0F); - return; - } - } - } - - float g = 1.0F; - if (this.world instanceof ServerWorld && this.world.isThundering() && EnchantmentHelper.hasChanneling(this.harpoonStack)) { - BlockPos blockPos = hitEntity.getBlockPos(); - if (this.world.isSkyVisible(blockPos)) { - LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(this.world); - lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos)); - lightningEntity.setChanneler(owner instanceof ServerPlayerEntity ? (ServerPlayerEntity) owner : null); - this.world.spawnEntity(lightningEntity); - soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER; - g = 5.0F; - } - } - - this.playSound(soundEvent, g, 1.0F); - - this.setVelocity(this.getVelocity().multiply(-0.01D, -0.1D, -0.01D)); - this.playSound(soundEvent, 1.0F, 1.0F); - } - - @Override - protected SoundEvent getHitSound() { - return SoundEvents.ITEM_TRIDENT_HIT_GROUND; - } - - @Override - public void onPlayerCollision(PlayerEntity player) { - Entity entity = this.getOwner(); - if (entity == null || entity.getUuid() == player.getUuid()) { - if (this.state != State.FLYING && !this.world.isClient && (this.state == State.BOBBING || this.isNoClip()) && this.shake <= 0) { - boolean bl = this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED || this.pickupType == PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY && player.getAbilities().creativeMode || this.isNoClip() && this.getOwner().getUuid() == player.getUuid(); - if (this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED && !player.getInventory().insertStack(this.asItemStack())) { - bl = false; - } - - if (bl) { - player.sendPickup(this, 1); - this.discard(); - } - } else - super.onPlayerCollision(player); - } - } - - @Override - public void readCustomDataFromNbt(NbtCompound tag) { - super.readCustomDataFromNbt(tag); - if (tag.contains("Trident", 10)) { - this.harpoonStack = ItemStack.fromNbt(tag.getCompound("Harpoon")); - } - - this.dealtDamage = tag.getBoolean("DealtDamage"); - } - - @Override - public void writeCustomDataToNbt(NbtCompound tag) { - super.writeCustomDataToNbt(tag); - tag.put("Harpoon", this.harpoonStack.writeNbt(new NbtCompound())); - tag.putBoolean("DealtDamage", this.dealtDamage); - } - - @Override - public void age() { - if (this.pickupType != PersistentProjectileEntity.PickupPermission.ALLOWED) { - super.age(); - } - } - - @Override - protected float getDragInWater() { - return 0.9F; - } - - @Override - public boolean shouldRender(double cameraX, double cameraY, double cameraZ) { - return true; - } - - enum State { - FLYING, - HOOKED_IN_ENTITY, - BOBBING, - LANDED - } + public static final Identifier SPAWN_PACKET = new Identifier(AlaskaNativeCraft.MOD_ID, "harpoon_entity"); + private static final TrackedData LOYALTY; + private static final TrackedData ENCHANTED; + + static { + ENCHANTED = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BOOLEAN); + LOYALTY = DataTracker.registerData(HarpoonEntity.class, TrackedDataHandlerRegistry.BYTE); + } + + public int returnTimer; + private ItemStack harpoonStack; + private HarpoonEntity.State state; + private boolean dealtDamage; + + public HarpoonEntity(EntityType entityType, World world, HarpoonItem item) { + super(entityType, world); + this.state = HarpoonEntity.State.FLYING; + this.harpoonStack = new ItemStack(item); + } + + public HarpoonEntity(World world, LivingEntity owner, @NotNull HarpoonItem item, @NotNull ItemStack stack) { + super(item.getType(), owner, world); + this.harpoonStack = stack.copy(); + this.state = HarpoonEntity.State.FLYING; + this.dataTracker.set(LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack)); + this.dataTracker.set(ENCHANTED, stack.hasGlint()); + } + + public static DamageSource createHarpoonDamageSource(Entity harpoon, Entity owner) { + return new ProjectileDamageSource("harpoon", harpoon, owner).setProjectile(); + } + + @Override + protected void initDataTracker() { + super.initDataTracker(); + this.dataTracker.startTracking(LOYALTY, (byte) 0); + this.dataTracker.startTracking(ENCHANTED, false); + } + + @Override + public Packet createSpawnPacket() { + PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer()); + + packet.writeVarInt(Registry.ENTITY_TYPE.getRawId(this.getType())); + packet.writeUuid(this.getUuid()); + packet.writeVarInt(this.getId()); + packet.writeDouble(this.getX()); + packet.writeDouble(this.getY()); + packet.writeDouble(this.getZ()); + packet.writeByte(MathHelper.floor(this.getPitch() * 256.0F / 360.0F)); + packet.writeByte(MathHelper.floor(this.getYaw() * 256.0F / 360.0F)); + + return ServerPlayNetworking.createS2CPacket(SPAWN_PACKET, packet); + } + + @Override + protected ItemStack asItemStack() { + return this.harpoonStack.copy(); + } + + @Environment(EnvType.CLIENT) + public boolean isEnchanted() { + return this.dataTracker.get(ENCHANTED); + } + + @Override + @Nullable + protected EntityHitResult getEntityCollision(Vec3d currentPosition, Vec3d nextPosition) { + return this.dealtDamage ? null : super.getEntityCollision(currentPosition, nextPosition); + } + + @Override + public void tick() { + if (this.state == State.BOBBING) { + float fluidHeight = 0.0F; + BlockPos blockPos = this.getBlockPos(); + FluidState fluidState = this.world.getFluidState(blockPos); + if (fluidState.isIn(FluidTags.WATER)) { + fluidHeight = fluidState.getHeight(this.world, blockPos); + } + + Vec3d vec3d = this.getVelocity(); + double distanceFromLiquidHeight = this.getY() + vec3d.y - (double) blockPos.getY() - (double) fluidHeight; + + // Set pitch, zero it if its minimal. + if (vec3d.y > 0.032D) { + this.setPitch((float) (MathHelper.atan2(vec3d.y, vec3d.horizontalLength()) * 57.2957763671875D)); + this.setPitch(updateRotation(this.prevPitch, this.getPitch())); + } else { + this.setPitch(updateRotation(this.prevPitch, 0.0F)); + } + + // Get bobbing action + if (Math.abs(distanceFromLiquidHeight) < 0.01D) { + distanceFromLiquidHeight += Math.signum(distanceFromLiquidHeight) * 0.1D; + } + + this.setVelocity(vec3d.x * 0.9D, vec3d.y - distanceFromLiquidHeight * (double) this.random.nextFloat() * 0.2D, vec3d.z * 0.9D); + vec3d = this.getVelocity(); + this.setPosition(this.getX() + vec3d.x, this.getY() + vec3d.y, this.getZ() + vec3d.z); + this.checkBlockCollision(); + + return; + } + + if (this.inGroundTime > 4) { + this.dealtDamage = true; + } + + Entity entity = this.getOwner(); + if ((this.dealtDamage || this.isNoClip()) && entity != null) { + int i = this.dataTracker.get(LOYALTY); + if (i > 0 && !entity.isAlive()) { + if (!this.world.isClient && this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED) { + this.dropStack(this.asItemStack(), 0.1F); + } + + this.discard(); + } else if (i > 0) { + this.setNoClip(true); + Vec3d vec3d = new Vec3d(entity.getX() - this.getX(), entity.getEyeY() - this.getY(), entity.getZ() - this.getZ()); + this.setPos(this.getX(), this.getY() + vec3d.y * 0.015D * (double) i, this.getZ()); + if (this.world.isClient) { + this.lastRenderY = this.getY(); + } + + double d = 0.05D * (double) i; + this.setVelocity(this.getVelocity().multiply(0.95D).add(vec3d.normalize().multiply(d))); + if (this.returnTimer == 0) { + this.playSound(SoundEvents.ITEM_TRIDENT_RETURN, 10.0F, 1.0F); + } + + ++this.returnTimer; + } + } + + super.tick(); + boolean inWater = this.isTouchingWater(); + + // We don't change anything unless the Harpoon is underwater + if (this.inGround && this.state != State.LANDED) { + this.state = State.LANDED; + return; + } else if (!inWater || this.state != State.FLYING) { + return; + } + + // Harpoon must be underwater + + // Revert previous fall calculations + Vec3d velocity = this.getVelocity(); + double d = velocity.x; + double e = velocity.y + 0.05D; + double g = velocity.z; + this.setVelocity(d, e, g); + + double h = this.getX() - d; + double j = this.getY() - e; + double k = this.getZ() - g; + + // Now do regular tick stuff + float f = 0.0F; + BlockPos blockPos = this.getBlockPos(); + FluidState fluidState = this.world.getFluidState(blockPos); + if (fluidState.isIn(FluidTags.WATER)) { + f = fluidState.getHeight(this.world, blockPos); + } + + velocity = this.getVelocity(); + double distanceFromLiquidHeight = this.getY() + velocity.y - (double) blockPos.getY() - (double) f; + + // The harpoon is still flying through water, so make it buoyant + if (distanceFromLiquidHeight > 0.0D && velocity.length() < 1) { + this.state = State.BOBBING; + } else { + this.setVelocity(velocity.x, velocity.y + 0.025D, velocity.z); + } + + velocity = this.getVelocity().multiply(this.getDragInWater()); + h += velocity.x; + j += velocity.y; + k += velocity.z; + this.setPosition(h, j, k); + this.checkBlockCollision(); + } + + @Override + protected void checkBlockCollision() { + super.checkBlockCollision(); + if (this.inGround) { + this.state = State.LANDED; + } + } + + @SuppressWarnings("ConstantConditions") + @Override + protected void onEntityHit(@NotNull EntityHitResult entityHitResult) { + Entity hitEntity = entityHitResult.getEntity(); + float f = ((HarpoonItem) this.harpoonStack.getItem()).getAttackDamage(); + if (hitEntity instanceof LivingEntity livingHitEntity) { + f += EnchantmentHelper.getAttackDamage(this.harpoonStack, livingHitEntity.getGroup()); + } + + Entity owner = this.getOwner(); + DamageSource damageSource = createHarpoonDamageSource(this, (owner == null ? this : owner)); + this.dealtDamage = true; + SoundEvent soundEvent = SoundEvents.ITEM_TRIDENT_HIT; + if (hitEntity.damage(damageSource, f)) { + if (hitEntity.getType() == EntityType.ENDERMAN) { + return; + } + + if (hitEntity instanceof LivingEntity livingHitEntity) { + if (owner instanceof LivingEntity) { + EnchantmentHelper.onUserDamaged(livingHitEntity, owner); + EnchantmentHelper.onTargetDamaged((LivingEntity) owner, livingHitEntity); + } + + this.onHit(livingHitEntity); + + if (hitEntity instanceof MobEntity && this.getOwner() instanceof PlayerEntity && !((MobEntity) hitEntity).isLeashed() && this.harpoonStack.getOrCreateNbt().contains("leashed") && this.harpoonStack.getOrCreateNbt().getBoolean("leashed")) { + ((MobEntity) hitEntity).attachLeash(this.getOwner(), true); + // Chance to lose the leash, based on level of Loyalty + // 100% at 0, 50% at 1, 33% at 2, etc. + if (this.random.nextInt(this.dataTracker.get(LOYALTY) + 1) == 0) { + this.harpoonStack.removeSubNbt("leashed"); + } + + this.setVelocity(Vec3d.ZERO); + this.playSound(soundEvent, 1.0F, 1.0F); + return; + } + } + } + + float g = 1.0F; + if (this.world instanceof ServerWorld && this.world.isThundering() && EnchantmentHelper.hasChanneling(this.harpoonStack)) { + BlockPos blockPos = hitEntity.getBlockPos(); + if (this.world.isSkyVisible(blockPos)) { + LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(this.world); + lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos)); + lightningEntity.setChanneler(owner instanceof ServerPlayerEntity ? (ServerPlayerEntity) owner : null); + this.world.spawnEntity(lightningEntity); + soundEvent = SoundEvents.ITEM_TRIDENT_THUNDER; + g = 5.0F; + } + } + + this.playSound(soundEvent, g, 1.0F); + + this.setVelocity(this.getVelocity().multiply(-0.01D, -0.1D, -0.01D)); + this.playSound(soundEvent, 1.0F, 1.0F); + } + + @Override + protected SoundEvent getHitSound() { + return SoundEvents.ITEM_TRIDENT_HIT_GROUND; + } + + @Override + public void onPlayerCollision(PlayerEntity player) { + Entity entity = this.getOwner(); + if (entity == null || entity.getUuid() == player.getUuid()) { + if (this.state != State.FLYING && !this.world.isClient && (this.state == State.BOBBING || this.isNoClip()) && this.shake <= 0) { + boolean bl = this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED || this.pickupType == PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY && player.getAbilities().creativeMode || this.isNoClip() && this.getOwner().getUuid() == player.getUuid(); + if (this.pickupType == PersistentProjectileEntity.PickupPermission.ALLOWED && !player.getInventory().insertStack(this.asItemStack())) { + bl = false; + } + + if (bl) { + player.sendPickup(this, 1); + this.discard(); + } + } else { + super.onPlayerCollision(player); + } + } + } + + @Override + public void readCustomDataFromNbt(NbtCompound tag) { + super.readCustomDataFromNbt(tag); + if (tag.contains("Trident", 10)) { + this.harpoonStack = ItemStack.fromNbt(tag.getCompound("Harpoon")); + } + + this.dealtDamage = tag.getBoolean("DealtDamage"); + } + + @Override + public void writeCustomDataToNbt(NbtCompound tag) { + super.writeCustomDataToNbt(tag); + tag.put("Harpoon", this.harpoonStack.writeNbt(new NbtCompound())); + tag.putBoolean("DealtDamage", this.dealtDamage); + } + + @Override + public void age() { + if (this.pickupType != PersistentProjectileEntity.PickupPermission.ALLOWED) { + super.age(); + } + } + + @Override + protected float getDragInWater() { + return 0.9F; + } + + @Override + public boolean shouldRender(double cameraX, double cameraY, double cameraZ) { + return true; + } + + enum State { + FLYING, + HOOKED_IN_ENTITY, + BOBBING, + LANDED + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java index ae6925bf..0792358f 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/MooseEntity.java @@ -1,11 +1,16 @@ package com.github.platymemo.alaskanativecraft.entity; +import java.util.EnumSet; + import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.entity.ai.goal.AdultMeleeAttackGoal; import com.github.platymemo.alaskanativecraft.entity.ai.goal.ChildEscapeDangerGoal; import com.github.platymemo.alaskanativecraft.mixin.AxeItemAccessor; import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents; import com.github.platymemo.alaskanativecraft.tags.common.CommonBlockTags; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.PillarBlock; @@ -13,7 +18,15 @@ import net.minecraft.entity.EntityPose; import net.minecraft.entity.EntityType; import net.minecraft.entity.ai.NavigationConditions; -import net.minecraft.entity.ai.goal.*; +import net.minecraft.entity.ai.goal.AnimalMateGoal; +import net.minecraft.entity.ai.goal.FollowParentGoal; +import net.minecraft.entity.ai.goal.Goal; +import net.minecraft.entity.ai.goal.LookAroundGoal; +import net.minecraft.entity.ai.goal.LookAtEntityGoal; +import net.minecraft.entity.ai.goal.RevengeGoal; +import net.minecraft.entity.ai.goal.SwimGoal; +import net.minecraft.entity.ai.goal.TemptGoal; +import net.minecraft.entity.ai.goal.WanderAroundFarGoal; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.damage.DamageSource; @@ -29,186 +42,182 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameRules; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.EnumSet; public class MooseEntity extends AnimalEntity { - - protected MooseEntity(EntityType entityType, World world) { - super(entityType, world); - this.calculateDimensions(); - this.stepHeight = this.isBaby() ? 1.0F : 2.0F; - } - - public static DefaultAttributeContainer.Builder createMooseAttributes() { - return MooseEntity.createMobAttributes() - .add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0D) - .add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 0.5D) - .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2D) - .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 8.0D) - .add(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, 1.0D); - } - - @Override - protected void initGoals() { - this.goalSelector.add(0, new SwimGoal(this)); - this.goalSelector.add(1, new ChildEscapeDangerGoal(this, 2.5D)); - this.goalSelector.add(1, new AdultMeleeAttackGoal(this, 2.5D, true)); - this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D)); - this.goalSelector.add(3, new TemptGoal(this, 1.25D, Ingredient.ofItems(Items.WHEAT), false)); - this.goalSelector.add(4, new FollowParentGoal(this, 1.25D)); - this.goalSelector.add(5, new WanderAroundFarGoal(this, 1.0D)); - this.goalSelector.add(6, new MooseEntity.EatBarkGoal(2.25D, 0.2D)); - this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); - this.goalSelector.add(7, new LookAroundGoal(this)); - this.targetSelector.add(0, new RevengeGoal(this).setGroupRevenge()); - } - - @Override - protected SoundEvent getAmbientSound() { - return this.random.nextInt(100) > 75 ? AlaskaSoundEvents.ENTITY_MOOSE_AMBIENT : super.getAmbientSound(); - } - - @Override - protected SoundEvent getHurtSound(DamageSource source) { - return AlaskaSoundEvents.ENTITY_MOOSE_HURT; - } - - @Override - protected SoundEvent getDeathSound() { - return AlaskaSoundEvents.ENTITY_MOOSE_HURT; - } - - @Override - protected void playStepSound(BlockPos pos, BlockState state) { - this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); - } - - @Override - protected float getSoundVolume() { - return 0.2F; - } - - @Override - public MooseEntity createChild(ServerWorld serverWorld, PassiveEntity passiveEntity) { - return AlaskaEntities.MOOSE.create(serverWorld); - } - - @Override - protected void onGrowUp() { - super.onGrowUp(); - this.stepHeight = 2.0F; - } - - @Override - protected float getActiveEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) { - return dimensions.height * 0.95F; - } - - class EatBarkGoal extends Goal { - private final double distance; - private final double speed; - protected BlockPos logPos; - protected BlockState logState; - protected boolean logValid; - private Vec3d target; - - public EatBarkGoal(double distance, double speed) { - this.logPos = BlockPos.ORIGIN; - this.distance = distance; - this.speed = speed; - this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK, Goal.Control.JUMP)); - } - - protected void setLogStripped() { - World world = MooseEntity.this.world; - if (this.logValid) { - this.logState = world.getBlockState(this.logPos); - if (this.logState.isIn(CommonBlockTags.LOGS_WITH_BARK)) { - BlockState blockState = world.getBlockState(this.logPos); - Block block = AxeItemAccessor.getStrippedBlocks().get(blockState.getBlock()); - if (block != null && !world.isClient) { - world.setBlockState(this.logPos, block.getDefaultState().with(PillarBlock.AXIS, blockState.get(PillarBlock.AXIS)), 11); - } - } - } - } - - protected boolean targetLogPos() { - Vec3d vec3d = this.locateLogPos(); - if (vec3d == null) { - this.logValid = false; - this.target = Vec3d.ZERO; - this.logPos = BlockPos.ORIGIN; - return false; - } else { - this.logValid = true; - this.target = vec3d; - this.logPos = new BlockPos(vec3d); - return true; - } - } - - @Nullable - protected Vec3d locateLogPos() { - Iterable iterable = BlockPos.iterate( - MooseEntity.this.getBlockX() - 3, - MooseEntity.this.getBlockY() - 1, - MooseEntity.this.getBlockZ() - 3, - MooseEntity.this.getBlockX() + 3, - MooseEntity.this.getBlockY() + 4, - MooseEntity.this.getBlockZ() + 3 - ); - - for (BlockPos blockPos : iterable) { - if (MooseEntity.this.world.getBlockState(blockPos).isIn(CommonBlockTags.LOGS_WITH_BARK)) { - return Vec3d.ofBottomCenter(blockPos); - } - } - return null; - } - - @Override - public boolean canStart() { - if (!AlaskaConfig.getConfig().mooseEatBark) { - return false; - } - - if (!MooseEntity.this.world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) - || !NavigationConditions.hasMobNavigation(MooseEntity.this) - || MooseEntity.this.getTarget() != null - || MooseEntity.this.isBaby() - || MooseEntity.this.getRandom().nextInt(200) != 0) { - return false; - } else { - return this.targetLogPos(); - } - } - - @Override - public boolean shouldContinue() { - return !MooseEntity.this.getNavigation().isIdle(); - } - - @Override - public void start() { - MooseEntity.this.getNavigation().startMovingTo(this.target.x, this.target.y, this.target.z, this.speed); - } - - @Override - public void tick() { - double h = MooseEntity.this.getPos().distanceTo(this.target); - if (h < this.distance) { - MooseEntity.this.getLookControl().lookAt(this.target); - } - } - - @Override - public void stop() { - this.setLogStripped(); - MooseEntity.this.getNavigation().stop(); - } - } + protected MooseEntity(EntityType entityType, World world) { + super(entityType, world); + this.calculateDimensions(); + this.stepHeight = this.isBaby() ? 1.0F : 2.0F; + } + + public static DefaultAttributeContainer.Builder createMooseAttributes() { + return MooseEntity.createMobAttributes() + .add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0D) + .add(EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, 0.5D) + .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.2D) + .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 8.0D) + .add(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, 1.0D); + } + + @Override + protected void initGoals() { + this.goalSelector.add(0, new SwimGoal(this)); + this.goalSelector.add(1, new ChildEscapeDangerGoal(this, 2.5D)); + this.goalSelector.add(1, new AdultMeleeAttackGoal(this, 2.5D, true)); + this.goalSelector.add(2, new AnimalMateGoal(this, 1.0D)); + this.goalSelector.add(3, new TemptGoal(this, 1.25D, Ingredient.ofItems(Items.WHEAT), false)); + this.goalSelector.add(4, new FollowParentGoal(this, 1.25D)); + this.goalSelector.add(5, new WanderAroundFarGoal(this, 1.0D)); + this.goalSelector.add(6, new MooseEntity.EatBarkGoal(2.25D, 0.2D)); + this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 6.0F)); + this.goalSelector.add(7, new LookAroundGoal(this)); + this.targetSelector.add(0, new RevengeGoal(this).setGroupRevenge()); + } + + @Override + protected SoundEvent getAmbientSound() { + return this.random.nextInt(100) > 75 ? AlaskaSoundEvents.ENTITY_MOOSE_AMBIENT : super.getAmbientSound(); + } + + @Override + protected SoundEvent getHurtSound(DamageSource source) { + return AlaskaSoundEvents.ENTITY_MOOSE_HURT; + } + + @Override + protected SoundEvent getDeathSound() { + return AlaskaSoundEvents.ENTITY_MOOSE_HURT; + } + + @Override + protected void playStepSound(BlockPos pos, BlockState state) { + this.playSound(SoundEvents.ENTITY_COW_STEP, 0.15F, 1.0F); + } + + @Override + protected float getSoundVolume() { + return 0.2F; + } + + @Override + public MooseEntity createChild(ServerWorld serverWorld, PassiveEntity passiveEntity) { + return AlaskaEntities.MOOSE.create(serverWorld); + } + + @Override + protected void onGrowUp() { + super.onGrowUp(); + this.stepHeight = 2.0F; + } + + @Override + protected float getActiveEyeHeight(EntityPose pose, @NotNull EntityDimensions dimensions) { + return dimensions.height * 0.95F; + } + + class EatBarkGoal extends Goal { + private final double distance; + private final double speed; + protected BlockPos logPos; + protected BlockState logState; + protected boolean logValid; + private Vec3d target; + + EatBarkGoal(double distance, double speed) { + this.logPos = BlockPos.ORIGIN; + this.distance = distance; + this.speed = speed; + this.setControls(EnumSet.of(Goal.Control.MOVE, Goal.Control.LOOK, Goal.Control.JUMP)); + } + + protected void setLogStripped() { + World world = MooseEntity.this.world; + if (this.logValid) { + this.logState = world.getBlockState(this.logPos); + if (this.logState.isIn(CommonBlockTags.LOGS_WITH_BARK)) { + BlockState blockState = world.getBlockState(this.logPos); + Block block = AxeItemAccessor.getStrippedBlocks().get(blockState.getBlock()); + if (block != null && !world.isClient) { + world.setBlockState(this.logPos, block.getDefaultState().with(PillarBlock.AXIS, blockState.get(PillarBlock.AXIS)), 11); + } + } + } + } + + protected boolean targetLogPos() { + Vec3d vec3d = this.locateLogPos(); + if (vec3d == null) { + this.logValid = false; + this.target = Vec3d.ZERO; + this.logPos = BlockPos.ORIGIN; + return false; + } else { + this.logValid = true; + this.target = vec3d; + this.logPos = new BlockPos(vec3d); + return true; + } + } + + @Nullable + protected Vec3d locateLogPos() { + Iterable iterable = BlockPos.iterate( + MooseEntity.this.getBlockX() - 3, + MooseEntity.this.getBlockY() - 1, + MooseEntity.this.getBlockZ() - 3, + MooseEntity.this.getBlockX() + 3, + MooseEntity.this.getBlockY() + 4, + MooseEntity.this.getBlockZ() + 3 + ); + + for (BlockPos blockPos : iterable) { + if (MooseEntity.this.world.getBlockState(blockPos).isIn(CommonBlockTags.LOGS_WITH_BARK)) { + return Vec3d.ofBottomCenter(blockPos); + } + } + + return null; + } + + @Override + public boolean canStart() { + if (!AlaskaConfig.getConfig().mooseEatBark) { + return false; + } + + if (!MooseEntity.this.world.getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) + || !NavigationConditions.hasMobNavigation(MooseEntity.this) + || MooseEntity.this.getTarget() != null + || MooseEntity.this.isBaby() + || MooseEntity.this.getRandom().nextInt(200) != 0) { + return false; + } else { + return this.targetLogPos(); + } + } + + @Override + public boolean shouldContinue() { + return !MooseEntity.this.getNavigation().isIdle(); + } + + @Override + public void start() { + MooseEntity.this.getNavigation().startMovingTo(this.target.x, this.target.y, this.target.z, this.speed); + } + + @Override + public void tick() { + double h = MooseEntity.this.getPos().distanceTo(this.target); + if (h < this.distance) { + MooseEntity.this.getLookControl().lookAt(this.target); + } + } + + @Override + public void stop() { + this.setLogStripped(); + MooseEntity.this.getNavigation().stop(); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java index 0fc068ff..026c2bef 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/PtarmiganEntity.java @@ -1,6 +1,8 @@ package com.github.platymemo.alaskanativecraft.entity; import net.fabricmc.fabric.api.tag.convention.v1.ConventionalBiomeTags; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.EntityData; @@ -23,97 +25,99 @@ import net.minecraft.world.LocalDifficulty; import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; public class PtarmiganEntity extends ParrotEntity { - private static final TrackedData TYPE; - - static { - TYPE = DataTracker.registerData(PtarmiganEntity.class, TrackedDataHandlerRegistry.INTEGER); - } - - public PtarmiganEntity(EntityType entityType, World world) { - super(entityType, world); - } - - public static boolean isValidSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { - BlockState blockState = serverWorldAccess.getBlockState(blockPos.down()); - return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; - } - - public static DefaultAttributeContainer.Builder createPtarmiganAttributes() { - return PtarmiganEntity.createMobAttributes(). - add(EntityAttributes.GENERIC_MAX_HEALTH, 6.0D). - add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4000000059604645D). - add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20000000298023224D); - } - - @Override - public EntityData initialize(@NotNull ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) { - if (world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.CLIMATE_COLD)) { - this.setType(0); - } else { - this.setType(this.random.nextInt(2) + 1); - } - if (entityData == null) { - entityData = new PassiveEntity.PassiveData(false); - } - - return super.initialize(world, difficulty, spawnReason, entityData, entityTag); - } - - @Override - public PtarmiganEntity createChild(ServerWorld world, PassiveEntity entity) { - PtarmiganEntity ptarmiganEntity = AlaskaEntities.PTARMIGAN.create(world); - if (ptarmiganEntity != null) - ptarmiganEntity.setType(this.random.nextBoolean() ? this.getPtarmiganType() : ((PtarmiganEntity) entity).getPtarmiganType()); - return ptarmiganEntity; - } - - @Override - protected void initDataTracker() { - super.initDataTracker(); - this.dataTracker.startTracking(TYPE, 0); - } - - @Override - public SoundEvent getAmbientSound() { - return SoundEvents.ENTITY_PARROT_AMBIENT; - } - - /** - * This is so the Ptarmigan doesn't imitate mobs as parrots do - */ - @Override - public void tickMovement() { - boolean silent = this.isSilent(); - this.setSilent(true); - super.tickMovement(); - this.setSilent(silent); - } - - public int getPtarmiganType() { - return this.dataTracker.get(TYPE); - } - - /* - * Somehow a player spawned a ptarmigan with type = 3, so this is a safety check - */ - private void setType(int type) { - if (type >= 0 && type < 3) { - this.dataTracker.set(TYPE, type); - } - } - - @Override - public void writeCustomDataToNbt(NbtCompound tag) { - super.writeCustomDataToNbt(tag); - tag.putInt("Type", this.getPtarmiganType()); - } - - @Override - public void readCustomDataFromNbt(NbtCompound tag) { - super.readCustomDataFromNbt(tag); - this.setType(tag.getInt("Type")); - } + private static final TrackedData TYPE; + + static { + TYPE = DataTracker.registerData(PtarmiganEntity.class, TrackedDataHandlerRegistry.INTEGER); + } + + public PtarmiganEntity(EntityType entityType, World world) { + super(entityType, world); + } + + public static boolean isValidSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { + BlockState blockState = serverWorldAccess.getBlockState(blockPos.down()); + return (blockState.isIn(BlockTags.LEAVES) || blockState.isOf(Blocks.GRASS_BLOCK) || blockState.isIn(BlockTags.LOGS) || blockState.isOf(Blocks.AIR)) && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; + } + + public static DefaultAttributeContainer.Builder createPtarmiganAttributes() { + return PtarmiganEntity.createMobAttributes() + .add(EntityAttributes.GENERIC_MAX_HEALTH, 6.0D) + .add(EntityAttributes.GENERIC_FLYING_SPEED, 0.4000000059604645D) + .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.20000000298023224D); + } + + @Override + public EntityData initialize(@NotNull ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, EntityData entityData, NbtCompound entityTag) { + if (world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.SNOWY) || world.getBiome(getBlockPos()).hasTag(ConventionalBiomeTags.CLIMATE_COLD)) { + this.setType(0); + } else { + this.setType(this.random.nextInt(2) + 1); + } + + if (entityData == null) { + entityData = new PassiveEntity.PassiveData(false); + } + + return super.initialize(world, difficulty, spawnReason, entityData, entityTag); + } + + @Override + public PtarmiganEntity createChild(ServerWorld world, PassiveEntity entity) { + PtarmiganEntity ptarmiganEntity = AlaskaEntities.PTARMIGAN.create(world); + if (ptarmiganEntity != null) { + ptarmiganEntity.setType(this.random.nextBoolean() ? this.getPtarmiganType() : ((PtarmiganEntity) entity).getPtarmiganType()); + } + + return ptarmiganEntity; + } + + @Override + protected void initDataTracker() { + super.initDataTracker(); + this.dataTracker.startTracking(TYPE, 0); + } + + @Override + public SoundEvent getAmbientSound() { + return SoundEvents.ENTITY_PARROT_AMBIENT; + } + + /** + * This is so the Ptarmigan doesn't imitate mobs as parrots do. + */ + @Override + public void tickMovement() { + boolean silent = this.isSilent(); + this.setSilent(true); + super.tickMovement(); + this.setSilent(silent); + } + + public int getPtarmiganType() { + return this.dataTracker.get(TYPE); + } + + /* + * Somehow a player spawned a ptarmigan with type = 3, so this is a safety check + */ + private void setType(int type) { + if (type >= 0 && type < 3) { + this.dataTracker.set(TYPE, type); + } + } + + @Override + public void writeCustomDataToNbt(NbtCompound tag) { + super.writeCustomDataToNbt(tag); + tag.putInt("Type", this.getPtarmiganType()); + } + + @Override + public void readCustomDataFromNbt(NbtCompound tag) { + super.readCustomDataFromNbt(tag); + this.setType(tag.getInt("Type")); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java index f812381a..810e11fc 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/SealEntity.java @@ -4,6 +4,9 @@ import com.github.platymemo.alaskanativecraft.entity.ai.goal.GroundFoodMateGoal; import com.github.platymemo.alaskanativecraft.sound.AlaskaSoundEvents; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.Entity; @@ -52,294 +55,290 @@ import net.minecraft.world.ServerWorldAccess; import net.minecraft.world.World; import net.minecraft.world.WorldView; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class SealEntity extends AnimalEntity { - - public SealEntity(EntityType entityType, World world) { - super(entityType, world); - this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); - this.moveControl = new SealEntity.SealMoveControl(this); - this.stepHeight = 1.0F; - } - - @SuppressWarnings({"deprecation", "unused"}) - public static boolean canSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { - return blockPos.getY() < serverWorldAccess.getSeaLevel() + 2 && blockPos.getY() > serverWorldAccess.getSeaLevel() - 10 && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; - } - - public static DefaultAttributeContainer.Builder createSealAttributes() { - return SealEntity.createMobAttributes(). - add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0D). - add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75D). - add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.5D); - } - - @Override - public boolean canSpawn(WorldView world) { - return world.doesNotIntersectEntities(this); - } - - @Override - @Nullable - public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData, @Nullable NbtCompound entityTag) { - return super.initialize(world, difficulty, spawnReason, entityData, entityTag); - } - - @Override - protected void initGoals() { - this.goalSelector.add(0, new FleeEntityGoal<>(this, PolarBearEntity.class, 8.0F, 1.0D, 1.5D)); - this.goalSelector.add(0, new SealEntity.SealEscapeDangerGoal(this, 1.5D)); - this.goalSelector.add(1, new AnimalMateGoal(this, 1.0D)); - this.goalSelector.add(2, new TemptGoal(this, 1.1D, Ingredient.ofTag(AlaskaTags.SEAL_FOOD), true)); - this.goalSelector.add(3, new FleeEntityGoal<>(this, PlayerEntity.class, 16.0F, 1.0D, 1.5D)); - this.goalSelector.add(3, new SwimAroundGoal(this, this.isBaby() ? 2.0D : 1.0D, 40)); - this.goalSelector.add(5, new SealEntity.WanderOnLandGoal(this, 1.0D, 100)); - this.goalSelector.add(5, new GroundFoodMateGoal(this)); - this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); - this.goalSelector.add(7, new SealEntity.HuntFishGoal(this, 1.2D, true)); - this.targetSelector.add(0, new TargetGoal<>(this, SalmonEntity.class, true)); - this.targetSelector.add(0, new TargetGoal<>(this, CodEntity.class, true)); - this.targetSelector.add(1, new TargetGoal<>(this, SquidEntity.class, true)); - } - - @Override - public boolean isPushedByFluids() { - return false; - } - - @Override - public boolean canBreatheInWater() { - return true; - } - - @Override - public EntityGroup getGroup() { - return EntityGroup.AQUATIC; - } - - @Override - public int getMinAmbientSoundDelay() { - return 200; - } - - @Override - @Nullable - protected SoundEvent getAmbientSound() { - if (!this.isTouchingWater() && this.onGround) { - return this.isBaby() ? AlaskaSoundEvents.ENTITY_SEAL_AMBIENT_BABY : AlaskaSoundEvents.ENTITY_SEAL_AMBIENT; - } - return super.getAmbientSound(); - } - - @Override - protected void playSwimSound(float volume) { - super.playSwimSound(volume * 1.5F); - } - - @Override - protected SoundEvent getSwimSound() { - return SoundEvents.ENTITY_TURTLE_SWIM; - } - - @Override - @Nullable - protected SoundEvent getHurtSound(DamageSource source) { - return AlaskaSoundEvents.ENTITY_SEAL_HURT; - } - - @Override - @Nullable - protected SoundEvent getDeathSound() { - return AlaskaSoundEvents.ENTITY_SEAL_HURT; - } - - @Override - protected void playStepSound(BlockPos pos, BlockState state) { - SoundEvent soundEvent = this.isBaby() ? SoundEvents.ENTITY_TURTLE_SHAMBLE_BABY : SoundEvents.ENTITY_TURTLE_SHAMBLE; - this.playSound(soundEvent, 0.15F, 1.0F); - } - - @Override - protected float calculateNextStepSoundDistance() { - return this.distanceTraveled + 0.15F; - } - - @Override - public float getScaleFactor() { - return this.isBaby() ? 0.3F : 1.0F; - } - - @Override - protected EntityNavigation createNavigation(World world) { - return new SealEntity.SealSwimNavigation(this, world); - } - - @Override - @Nullable - public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { - return AlaskaEntities.HARP_SEAL.create(world); - } - - @Override - public boolean isBreedingItem(@NotNull ItemStack stack) { - return stack.isIn(AlaskaTags.SEAL_FOOD); - } - - @Override - public float getPathfindingFavor(BlockPos pos, @NotNull WorldView world) { - if (world.getFluidState(pos).isIn(FluidTags.WATER)) { - return 15.0F; - } else { - return world.getBlockState(pos).isOf(Blocks.SAND) ? 10.0F : world.getLightLevel(pos) - 0.5F; - } - } - - @Override - public void travel(Vec3d movementInput) { - if (this.canMoveVoluntarily() && this.isTouchingWater()) { - this.updateVelocity(0.1F, movementInput); - this.move(MovementType.SELF, this.getVelocity()); - this.setVelocity(this.getVelocity().multiply(0.9D)); - if (this.getTarget() == null) { - this.setVelocity(this.getVelocity().add(0.0D, -0.005D, 0.0D)); - } - } else { - super.travel(movementInput); - } - } - - @Override - public boolean tryAttack(@NotNull Entity target) { - boolean bl = target.damage(DamageSource.mob(this), (float) ((int) this.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE))); - if (bl) { - this.applyDamageEffects(this, target); - } - - return bl; - } - - static class SealSwimNavigation extends SwimNavigation { - SealSwimNavigation(SealEntity owner, World world) { - super(owner, world); - } - - @Override - protected boolean isAtValidPosition() { - return true; - } - - @Override - protected PathNodeNavigator createPathNodeNavigator(int range) { - this.nodeMaker = new AmphibiousPathNodeMaker(false); - return new PathNodeNavigator(this.nodeMaker, range); - } - - @Override - public boolean isValidPosition(BlockPos pos) { - return !this.world.getBlockState(pos.down()).isAir(); - } - } - - static class SealMoveControl extends MoveControl { - private final SealEntity seal; - - SealMoveControl(SealEntity seal) { - super(seal); - this.seal = seal; - } - - private void updateVelocity() { - if (this.seal.isTouchingWater()) { - this.seal.setVelocity(this.seal.getVelocity().add(0.0D, 0.005D, 0.0D)); - this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.1F)); - - if (this.seal.isBaby()) { - this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 2.0F, 0.08F)); - } - - } else if (this.seal.onGround) { - this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.08F)); - } - - } - - @Override - public void tick() { - this.updateVelocity(); - if (this.state == MoveControl.State.MOVE_TO && !this.seal.getNavigation().isIdle()) { - double d = this.targetX - this.seal.getX(); - double e = this.targetY - this.seal.getY(); - double f = this.targetZ - this.seal.getZ(); - double g = Math.sqrt(d * d + e * e + f * f); - e /= g; - float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F; - this.seal.setYaw(this.wrapDegrees(this.seal.getYaw(), h, 90.0F)); - this.seal.bodyYaw = this.seal.getYaw(); - this.seal.headYaw = this.seal.getYaw(); - float i = (float) (this.speed * this.seal.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)); - this.seal.setMovementSpeed(MathHelper.lerp(0.125F, this.seal.getMovementSpeed(), i)); - this.seal.setVelocity(this.seal.getVelocity().add(0.0D, (double) this.seal.getMovementSpeed() * e * 0.1D, 0.0D)); - } else { - this.seal.setMovementSpeed(0.0F); - } - } - } - - static class WanderOnLandGoal extends WanderAroundGoal { - - private WanderOnLandGoal(SealEntity seal, double speed, int chance) { - super(seal, speed, chance); - } - - @Override - public boolean canStart() { - return !this.mob.isTouchingWater() && super.canStart(); - } - } - - static class HuntFishGoal extends MeleeAttackGoal { - private final AnimalEntity animal; - - public HuntFishGoal(SealEntity sealEntity, double speed, boolean pauseWhenMobIdle) { - super(sealEntity, speed, pauseWhenMobIdle); - this.animal = sealEntity; - } - - @Override - public boolean canStart() { - if (!AlaskaConfig.getConfig().sealFishing.sealsHuntFish) { - return false; - } - - if (this.animal.getRandom().nextInt(1000) != 0 || !this.animal.canEat()) { - return false; - } - return super.canStart(); - } - } - - static class SealEscapeDangerGoal extends EscapeDangerGoal { - SealEscapeDangerGoal(SealEntity seal, double speed) { - super(seal, speed); - } - - @Override - public boolean canStart() { - if (this.mob.getAttacker() == null && !this.mob.isOnFire()) { - return false; - } else { - BlockPos blockPos = this.locateClosestWater(this.mob.world, this.mob, 5); - if (blockPos != null) { - this.targetX = blockPos.getX(); - this.targetY = blockPos.getY(); - this.targetZ = blockPos.getZ(); - return true; - } else { - return this.findTarget(); - } - } - } - } + public SealEntity(EntityType entityType, World world) { + super(entityType, world); + this.setPathfindingPenalty(PathNodeType.WATER, 0.0F); + this.moveControl = new SealEntity.SealMoveControl(this); + this.stepHeight = 1.0F; + } + + @SuppressWarnings({"deprecation", "unused"}) + public static boolean canSpawn(EntityType entityType, ServerWorldAccess serverWorldAccess, SpawnReason spawnReason, BlockPos blockPos, RandomGenerator randomGenerator) { + return blockPos.getY() < serverWorldAccess.getSeaLevel() + 2 && blockPos.getY() > serverWorldAccess.getSeaLevel() - 10 && serverWorldAccess.getBaseLightLevel(blockPos, 0) > 8; + } + + public static DefaultAttributeContainer.Builder createSealAttributes() { + return SealEntity.createMobAttributes() + .add(EntityAttributes.GENERIC_MAX_HEALTH, 10.0D) + .add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.75D) + .add(EntityAttributes.GENERIC_ATTACK_DAMAGE, 1.5D); + } + + @Override + public boolean canSpawn(WorldView world) { + return world.doesNotIntersectEntities(this); + } + + @Override + @Nullable + public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData, @Nullable NbtCompound entityTag) { + return super.initialize(world, difficulty, spawnReason, entityData, entityTag); + } + + @Override + protected void initGoals() { + this.goalSelector.add(0, new FleeEntityGoal<>(this, PolarBearEntity.class, 8.0F, 1.0D, 1.5D)); + this.goalSelector.add(0, new SealEntity.SealEscapeDangerGoal(this, 1.5D)); + this.goalSelector.add(1, new AnimalMateGoal(this, 1.0D)); + this.goalSelector.add(2, new TemptGoal(this, 1.1D, Ingredient.ofTag(AlaskaTags.SEAL_FOOD), true)); + this.goalSelector.add(3, new FleeEntityGoal<>(this, PlayerEntity.class, 16.0F, 1.0D, 1.5D)); + this.goalSelector.add(3, new SwimAroundGoal(this, this.isBaby() ? 2.0D : 1.0D, 40)); + this.goalSelector.add(5, new SealEntity.WanderOnLandGoal(this, 1.0D, 100)); + this.goalSelector.add(5, new GroundFoodMateGoal(this)); + this.goalSelector.add(6, new LookAtEntityGoal(this, PlayerEntity.class, 8.0F)); + this.goalSelector.add(7, new SealEntity.HuntFishGoal(this, 1.2D, true)); + this.targetSelector.add(0, new TargetGoal<>(this, SalmonEntity.class, true)); + this.targetSelector.add(0, new TargetGoal<>(this, CodEntity.class, true)); + this.targetSelector.add(1, new TargetGoal<>(this, SquidEntity.class, true)); + } + + @Override + public boolean isPushedByFluids() { + return false; + } + + @Override + public boolean canBreatheInWater() { + return true; + } + + @Override + public EntityGroup getGroup() { + return EntityGroup.AQUATIC; + } + + @Override + public int getMinAmbientSoundDelay() { + return 200; + } + + @Override + @Nullable + protected SoundEvent getAmbientSound() { + if (!this.isTouchingWater() && this.onGround) { + return this.isBaby() ? AlaskaSoundEvents.ENTITY_SEAL_AMBIENT_BABY : AlaskaSoundEvents.ENTITY_SEAL_AMBIENT; + } + + return super.getAmbientSound(); + } + + @Override + protected void playSwimSound(float volume) { + super.playSwimSound(volume * 1.5F); + } + + @Override + protected SoundEvent getSwimSound() { + return SoundEvents.ENTITY_TURTLE_SWIM; + } + + @Override + @Nullable + protected SoundEvent getHurtSound(DamageSource source) { + return AlaskaSoundEvents.ENTITY_SEAL_HURT; + } + + @Override + @Nullable + protected SoundEvent getDeathSound() { + return AlaskaSoundEvents.ENTITY_SEAL_HURT; + } + + @Override + protected void playStepSound(BlockPos pos, BlockState state) { + SoundEvent soundEvent = this.isBaby() ? SoundEvents.ENTITY_TURTLE_SHAMBLE_BABY : SoundEvents.ENTITY_TURTLE_SHAMBLE; + this.playSound(soundEvent, 0.15F, 1.0F); + } + + @Override + protected float calculateNextStepSoundDistance() { + return this.distanceTraveled + 0.15F; + } + + @Override + public float getScaleFactor() { + return this.isBaby() ? 0.3F : 1.0F; + } + + @Override + protected EntityNavigation createNavigation(World world) { + return new SealEntity.SealSwimNavigation(this, world); + } + + @Override + @Nullable + public PassiveEntity createChild(ServerWorld world, PassiveEntity entity) { + return AlaskaEntities.HARP_SEAL.create(world); + } + + @Override + public boolean isBreedingItem(@NotNull ItemStack stack) { + return stack.isIn(AlaskaTags.SEAL_FOOD); + } + + @Override + public float getPathfindingFavor(BlockPos pos, @NotNull WorldView world) { + if (world.getFluidState(pos).isIn(FluidTags.WATER)) { + return 15.0F; + } else { + return world.getBlockState(pos).isOf(Blocks.SAND) ? 10.0F : world.getLightLevel(pos) - 0.5F; + } + } + + @Override + public void travel(Vec3d movementInput) { + if (this.canMoveVoluntarily() && this.isTouchingWater()) { + this.updateVelocity(0.1F, movementInput); + this.move(MovementType.SELF, this.getVelocity()); + this.setVelocity(this.getVelocity().multiply(0.9D)); + if (this.getTarget() == null) { + this.setVelocity(this.getVelocity().add(0.0D, -0.005D, 0.0D)); + } + } else { + super.travel(movementInput); + } + } + + @Override + public boolean tryAttack(@NotNull Entity target) { + boolean bl = target.damage(DamageSource.mob(this), (float) ((int) this.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE))); + if (bl) { + this.applyDamageEffects(this, target); + } + + return bl; + } + + static class SealSwimNavigation extends SwimNavigation { + SealSwimNavigation(SealEntity owner, World world) { + super(owner, world); + } + + @Override + protected boolean isAtValidPosition() { + return true; + } + + @Override + protected PathNodeNavigator createPathNodeNavigator(int range) { + this.nodeMaker = new AmphibiousPathNodeMaker(false); + return new PathNodeNavigator(this.nodeMaker, range); + } + + @Override + public boolean isValidPosition(BlockPos pos) { + return !this.world.getBlockState(pos.down()).isAir(); + } + } + + static class SealMoveControl extends MoveControl { + private final SealEntity seal; + + SealMoveControl(SealEntity seal) { + super(seal); + this.seal = seal; + } + + private void updateVelocity() { + if (this.seal.isTouchingWater()) { + this.seal.setVelocity(this.seal.getVelocity().add(0.0D, 0.005D, 0.0D)); + this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.1F)); + + if (this.seal.isBaby()) { + this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 2.0F, 0.08F)); + } + } else if (this.seal.onGround) { + this.seal.setMovementSpeed(Math.max(this.seal.getMovementSpeed() / 1.5F, 0.08F)); + } + } + + @Override + public void tick() { + this.updateVelocity(); + if (this.state == MoveControl.State.MOVE_TO && !this.seal.getNavigation().isIdle()) { + double d = this.targetX - this.seal.getX(); + double e = this.targetY - this.seal.getY(); + double f = this.targetZ - this.seal.getZ(); + double g = Math.sqrt(d * d + e * e + f * f); + e /= g; + float h = (float) (MathHelper.atan2(f, d) * 57.2957763671875D) - 90.0F; + this.seal.setYaw(this.wrapDegrees(this.seal.getYaw(), h, 90.0F)); + this.seal.bodyYaw = this.seal.getYaw(); + this.seal.headYaw = this.seal.getYaw(); + float i = (float) (this.speed * this.seal.getAttributeValue(EntityAttributes.GENERIC_MOVEMENT_SPEED)); + this.seal.setMovementSpeed(MathHelper.lerp(0.125F, this.seal.getMovementSpeed(), i)); + this.seal.setVelocity(this.seal.getVelocity().add(0.0D, (double) this.seal.getMovementSpeed() * e * 0.1D, 0.0D)); + } else { + this.seal.setMovementSpeed(0.0F); + } + } + } + + static class WanderOnLandGoal extends WanderAroundGoal { + private WanderOnLandGoal(SealEntity seal, double speed, int chance) { + super(seal, speed, chance); + } + + @Override + public boolean canStart() { + return !this.mob.isTouchingWater() && super.canStart(); + } + } + + static class HuntFishGoal extends MeleeAttackGoal { + private final AnimalEntity animal; + + HuntFishGoal(SealEntity sealEntity, double speed, boolean pauseWhenMobIdle) { + super(sealEntity, speed, pauseWhenMobIdle); + this.animal = sealEntity; + } + + @Override + public boolean canStart() { + if (!AlaskaConfig.getConfig().sealFishing.sealsHuntFish) { + return false; + } + + if (this.animal.getRandom().nextInt(1000) != 0 || !this.animal.canEat()) { + return false; + } + + return super.canStart(); + } + } + + static class SealEscapeDangerGoal extends EscapeDangerGoal { + SealEscapeDangerGoal(SealEntity seal, double speed) { + super(seal, speed); + } + + @Override + public boolean canStart() { + if (this.mob.getAttacker() == null && !this.mob.isOnFire()) { + return false; + } else { + BlockPos blockPos = this.locateClosestWater(this.mob.world, this.mob, 5); + if (blockPos != null) { + this.targetX = blockPos.getX(); + this.targetY = blockPos.getY(); + this.targetZ = blockPos.getZ(); + return true; + } else { + return this.findTarget(); + } + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java index 7f37fdc1..09efe24f 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/AdultMeleeAttackGoal.java @@ -1,47 +1,47 @@ package com.github.platymemo.alaskanativecraft.entity.ai.goal; import com.github.platymemo.alaskanativecraft.mixin.MeleeAttackGoalAccessor; +import org.jetbrains.annotations.NotNull; + import net.minecraft.entity.LivingEntity; import net.minecraft.entity.ai.goal.MeleeAttackGoal; import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.util.Hand; -import org.jetbrains.annotations.NotNull; public class AdultMeleeAttackGoal extends MeleeAttackGoal { + public AdultMeleeAttackGoal(PathAwareEntity mob, double speed, boolean pauseWhenMobIdle) { + super(mob, speed, pauseWhenMobIdle); + } - public AdultMeleeAttackGoal(PathAwareEntity mob, double speed, boolean pauseWhenMobIdle) { - super(mob, speed, pauseWhenMobIdle); - } - - @Override - public boolean canStart() { - if (!mob.isBaby()) { - return super.canStart(); - } else { - return false; - } - } + @Override + public boolean canStart() { + if (!mob.isBaby()) { + return super.canStart(); + } else { + return false; + } + } - @Override - protected void resetCooldown() { - ((MeleeAttackGoalAccessor) this).setCooldown(50); - } + @Override + protected void resetCooldown() { + ((MeleeAttackGoalAccessor) this).setCooldown(50); + } - @Override - protected double getSquaredMaxAttackDistance(@NotNull LivingEntity entity) { - float f = mob.getWidth() - 1.0F; - return (f * 2.0F * f * 2.0F + entity.getWidth()); - } + @Override + protected double getSquaredMaxAttackDistance(@NotNull LivingEntity entity) { + float f = mob.getWidth() - 1.0F; + return (f * 2.0F * f * 2.0F + entity.getWidth()); + } - @Override - protected void attack(LivingEntity target, double squaredDistance) { - double d = this.getSquaredMaxAttackDistance(target); - if (squaredDistance <= d && this.isCooledDown()) { - this.resetCooldown(); - this.mob.swingHand(Hand.MAIN_HAND); - if (this.mob.tryAttack(target) && this.mob.getRandom().nextFloat() < 0.6F) { - this.stop(); - } - } - } + @Override + protected void attack(LivingEntity target, double squaredDistance) { + double d = this.getSquaredMaxAttackDistance(target); + if (squaredDistance <= d && this.isCooledDown()) { + this.resetCooldown(); + this.mob.swingHand(Hand.MAIN_HAND); + if (this.mob.tryAttack(target) && this.mob.getRandom().nextFloat() < 0.6F) { + this.stop(); + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java index a27c358f..86ae734b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/ChildEscapeDangerGoal.java @@ -4,17 +4,16 @@ import net.minecraft.entity.mob.PathAwareEntity; public class ChildEscapeDangerGoal extends EscapeDangerGoal { + public ChildEscapeDangerGoal(PathAwareEntity mob, double speed) { + super(mob, speed); + } - public ChildEscapeDangerGoal(PathAwareEntity mob, double speed) { - super(mob, speed); - } - - @Override - public boolean canStart() { - if (mob.isBaby()) { - return super.canStart(); - } else { - return false; - } - } + @Override + public boolean canStart() { + if (mob.isBaby()) { + return super.canStart(); + } else { + return false; + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java index 47238742..744b39a8 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/ai/goal/GroundFoodMateGoal.java @@ -5,86 +5,87 @@ package com.github.platymemo.alaskanativecraft.entity.ai.goal; +import java.util.EnumSet; +import java.util.List; + import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.entity.SealEntity; + import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ai.goal.Goal; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.world.GameRules; -import java.util.EnumSet; -import java.util.List; - public class GroundFoodMateGoal extends Goal { - protected final AnimalEntity animal; - protected ItemEntity foodEntity; - - public GroundFoodMateGoal(AnimalEntity animal) { - this.setControls(EnumSet.of(Control.MOVE, Control.LOOK)); - this.animal = animal; - } - - @Override - public boolean canStart() { - if (this.animal instanceof SealEntity && !AlaskaConfig.getConfig().sealFishing.sealsEatHuntedFish) { - return false; - } - - if (this.animal.getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { - this.foodEntity = this.findFood(); - } - - if (this.animal.getRandom().nextInt(100) != 0) { - return false; - } - - return this.foodEntity != null; - } - - @Override - public boolean shouldContinue() { - return this.foodEntity != null && this.foodEntity.getStack().getCount() > 0 && this.animal.canEat() && this.animal.getBreedingAge() == 0; - } - - @Override - public void stop() { - this.foodEntity = null; - } - - @Override - public void tick() { - if (this.foodEntity != null) { - this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, this.animal.getLookPitchSpeed()); - this.animal.getNavigation().startMovingTo(this.foodEntity, 1.0f); - if (this.animal.squaredDistanceTo(this.foodEntity) < 4.0D) { - this.feed(); - } - } - } - - private ItemEntity findFood() { - List list = animal.world.getEntitiesByClass(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), (entity) -> true); - double d = Double.MAX_VALUE; - - ItemEntity result = null; - for (ItemEntity itemEntity : list) { - if (this.animal.isBreedingItem(itemEntity.getStack()) && this.animal.squaredDistanceTo(itemEntity) < d) { - result = itemEntity; - d = this.animal.squaredDistanceTo(itemEntity); - } - } - - return result; - } - - private void feed() { - if (this.foodEntity.getStack().getCount() > 0) { - foodEntity.getStack().decrement(1); - if (!(this.animal instanceof SealEntity) || AlaskaConfig.getConfig().sealFishing.sealsBreedFromHuntedFish) { - animal.lovePlayer(null); - } - } - - stop(); - } + protected final AnimalEntity animal; + protected ItemEntity foodEntity; + + public GroundFoodMateGoal(AnimalEntity animal) { + this.setControls(EnumSet.of(Control.MOVE, Control.LOOK)); + this.animal = animal; + } + + @Override + public boolean canStart() { + if (this.animal instanceof SealEntity && !AlaskaConfig.getConfig().sealFishing.sealsEatHuntedFish) { + return false; + } + + if (this.animal.getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING) && this.animal.canEat() && this.animal.getBreedingAge() == 0) { + this.foodEntity = this.findFood(); + } + + if (this.animal.getRandom().nextInt(100) != 0) { + return false; + } + + return this.foodEntity != null; + } + + @Override + public boolean shouldContinue() { + return this.foodEntity != null && this.foodEntity.getStack().getCount() > 0 && this.animal.canEat() && this.animal.getBreedingAge() == 0; + } + + @Override + public void stop() { + this.foodEntity = null; + } + + @Override + public void tick() { + if (this.foodEntity != null) { + this.animal.getLookControl().lookAt(this.foodEntity, 10.0F, this.animal.getLookPitchSpeed()); + this.animal.getNavigation().startMovingTo(this.foodEntity, 1.0f); + if (this.animal.squaredDistanceTo(this.foodEntity) < 4.0D) { + this.feed(); + } + } + } + + private ItemEntity findFood() { + List list = this.animal.world.getEntitiesByClass(ItemEntity.class, this.animal.getBoundingBox().expand(8.0D), (entity) -> true); + double d = Double.MAX_VALUE; + + ItemEntity result = null; + for (ItemEntity itemEntity : list) { + if (this.animal.isBreedingItem(itemEntity.getStack()) && this.animal.squaredDistanceTo(itemEntity) < d) { + result = itemEntity; + d = this.animal.squaredDistanceTo(itemEntity); + } + } + + return result; + } + + private void feed() { + if (this.foodEntity.getStack().getCount() > 0) { + this.foodEntity.getStack().decrement(1); + if (!(this.animal instanceof SealEntity) || AlaskaConfig.getConfig().sealFishing.sealsBreedFromHuntedFish) { + this.animal.lovePlayer(null); + } + } + + this.stop(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java index 1aaf89e3..b841bbe1 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/AlaskaEffects.java @@ -5,10 +5,10 @@ import net.minecraft.util.registry.Registry; public class AlaskaEffects { - public static StatusEffect MEDICINAL = - Registry.register( - Registry.STATUS_EFFECT, - "medicinal", - new MedicinalStatusEffect(StatusEffectType.BENEFICIAL, 0x929D2A) - ); + public static StatusEffect MEDICINAL = + Registry.register( + Registry.STATUS_EFFECT, + "medicinal", + new MedicinalStatusEffect(StatusEffectType.BENEFICIAL, 0x929D2A) + ); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java index daa64cb4..f1c6fb2a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/entity/effect/MedicinalStatusEffect.java @@ -5,27 +5,26 @@ import net.minecraft.entity.effect.StatusEffectType; public class MedicinalStatusEffect extends StatusEffect { + protected MedicinalStatusEffect(StatusEffectType category, int color) { + super(category, color); + } - protected MedicinalStatusEffect(StatusEffectType category, int color) { - super(category, color); - } + @Override + public boolean canApplyUpdateEffect(int duration, int amplifier) { + // The medicinal effect removes other effects, + // It cannot do that at the regular time otherwise it will result in a CME + // Therefore applyUpdateEffect will not run in the regular loop + return false; + } - @Override - public boolean canApplyUpdateEffect(int duration, int amplifier) { - // The medicinal effect removes other effects, - // It cannot do that at the regular time otherwise it will result in a CME - // Therefore applyUpdateEffect will not run in the regular loop - return false; - } - - @Override - public void applyUpdateEffect(LivingEntity entity, int amplifier) { - // remove first negative status effect found - for (StatusEffect type : entity.getActiveStatusEffects().keySet()) { - if (type.getType() == StatusEffectType.HARMFUL) { - entity.removeStatusEffect(type); - break; - } - } - } + @Override + public void applyUpdateEffect(LivingEntity entity, int amplifier) { + // remove first negative status effect found + for (StatusEffect type : entity.getActiveStatusEffects().keySet()) { + if (type.getType() == StatusEffectType.HARMFUL) { + entity.removeStatusEffect(type); + break; + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java index 338c5f03..cca2c2dc 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaItems.java @@ -1,5 +1,7 @@ package com.github.platymemo.alaskanativecraft.item; +import java.util.List; + import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.entity.AlaskaEntities; @@ -7,6 +9,7 @@ import com.github.platymemo.alaskanativecraft.item.material.AlaskaNativeArmorMaterials; import com.github.platymemo.alaskanativecraft.mixin.BrewingRecipeRegistryAccessor; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; + import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; @@ -31,143 +34,142 @@ import net.minecraft.util.Identifier; import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.registry.Registry; + import org.quiltmc.qsl.item.group.api.QuiltItemGroup; import org.quiltmc.qsl.item.setting.api.QuiltItemSettings; -import java.util.List; - public class AlaskaItems { - public static final Item MUKTUK; - public static final Item SEAL; - public static final Item COOKED_SEAL; - public static final Item DRY_SEAL; - public static final Item PTARMIGAN; - public static final Item COOKED_PTARMIGAN; - public static final Item VENISON; - public static final Item COOKED_VENISON; - public static final Item DRIFTWOOD_CHUNK; - public static final Item ANTLER; - public static final Item IVORY; - public static final Item FISH_STRIP; - public static final Item DRY_FISH; - public static final Item BLUEBERRIES; - public static final Item CLOUDBERRIES; - public static final Item RASPBERRIES; - public static final Item SALMONBERRIES; - public static final Item LABRADOR_TEA; - public static final SuspiciousStewItem AKUTAQ; - public static final UluItem ULU; - public static final HarpoonItem WOODEN_HARPOON; - public static final HarpoonItem STONE_HARPOON; - public static final HarpoonItem IRON_HARPOON; - public static final HarpoonItem GOLDEN_HARPOON; - public static final HarpoonItem DIAMOND_HARPOON; - public static final HarpoonItem NETHERITE_HARPOON; - public static final DyeableArmorItem KUSPUK_HOOD; - public static final DyeableArmorItem KUSPUK_BODY; - public static final ArmorItem MUKLUKS; - public static final ArmorItem SNOW_GOGGLES; - public static final ArmorItem SNOWSHOES; - public static final DogsledItem OAK_DOGSLED; - public static final DogsledItem SPRUCE_DOGSLED; - public static final DogsledItem BIRCH_DOGSLED; - public static final DogsledItem JUNGLE_DOGSLED; - public static final DogsledItem ACACIA_DOGSLED; - public static final DogsledItem DARK_OAK_DOGSLED; - public static final SpawnEggItem SEAL_SPAWN_EGG; - public static final SpawnEggItem PTARMIGAN_SPAWN_EGG; - public static final SpawnEggItem MOOSE_SPAWN_EGG; - - static { - MUKTUK = register("muktuk", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build()))); - SEAL = register("seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); - COOKED_SEAL = register("cooked_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build()))); - DRY_SEAL = register("dry_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build()))); - PTARMIGAN = register("ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build()))); - COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build()))); - VENISON = register("venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); - COOKED_VENISON = register("cooked_venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build()))); - - DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); - ANTLER = register("antler", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); - IVORY = register("ivory", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); - - FISH_STRIP = register("fish_strip", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build()))); - DRY_FISH = register("dry_fish", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build()))); - - BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); - - LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new QuiltItemSettings().group(ItemGroup.BREWING))); - - AKUTAQ = register("akutaq", new SuspiciousStewItem(new QuiltItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build()))); - - ULU = register("ulu", new UluItem(new QuiltItemSettings().group(ItemGroup.TOOLS).maxDamage(472))); - - WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); - STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); - IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); - GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); - DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); - NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT).fireproof())); - - KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); - KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new QuiltItemSettings().group(ItemGroup.COMBAT))); - MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); - - SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); - SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); - - OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); - - SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new QuiltItemSettings().group(ItemGroup.MISC))); - PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new QuiltItemSettings().group(ItemGroup.MISC))); - MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new QuiltItemSettings().group(ItemGroup.MISC))); - } - - private static I register(String name, I item) { - return Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item); - } - - public static void register() { - addPotionRecipes(); - addItemGroupEntries(); - addSnowGogglesToLootTable(); - } - - private static void addPotionRecipes() { - for (Potion potion: List.of(Potions.WATER, Potions.MUNDANE, Potions.THICK, Potions.AWKWARD)) { - BrewingRecipeRegistryAccessor.registerRecipe(potion, AlaskaItems.LABRADOR_TEA, AlaskaPotions.TUNDRA_TEA); - } - BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, AlaskaItems.LABRADOR_TEA, AlaskaPotions.STRONG_TUNDRA_TEA); - BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.GLOWSTONE_DUST, AlaskaPotions.STRONG_TUNDRA_TEA); - BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.REDSTONE, AlaskaPotions.LONG_TUNDRA_TEA); - } - - private static void addItemGroupEntries() { - QuiltItemGroup.builder(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> { - if (Registry.ITEM.getId(item).getNamespace().equals(AlaskaNativeCraft.MOD_ID)) { - item.appendStacks(item.getGroup(), (DefaultedList) stacks); - } - })).build(); - } - - private static void addSnowGogglesToLootTable() { - LootTableEvents.MODIFY.register((resourceManager, lootManager, id, table, source) -> { - if (LootTables.VILLAGE_SNOWY_HOUSE_CHEST.equals(id) || LootTables.VILLAGE_TAIGA_HOUSE_CHEST.equals(id)) { - LootPool.Builder poolBuilder = new LootPool.Builder().rolls(UniformLootNumberProvider.create(0.0F, 1.0F)) - .with(ItemEntry.builder(AlaskaItems.SNOW_GOGGLES).build()); - - table.pool(poolBuilder); - } - }); - } - + public static final Item MUKTUK; + public static final Item SEAL; + public static final Item COOKED_SEAL; + public static final Item DRY_SEAL; + public static final Item PTARMIGAN; + public static final Item COOKED_PTARMIGAN; + public static final Item VENISON; + public static final Item COOKED_VENISON; + public static final Item DRIFTWOOD_CHUNK; + public static final Item ANTLER; + public static final Item IVORY; + public static final Item FISH_STRIP; + public static final Item DRY_FISH; + public static final Item BLUEBERRIES; + public static final Item CLOUDBERRIES; + public static final Item RASPBERRIES; + public static final Item SALMONBERRIES; + public static final Item LABRADOR_TEA; + public static final SuspiciousStewItem AKUTAQ; + public static final UluItem ULU; + public static final HarpoonItem WOODEN_HARPOON; + public static final HarpoonItem STONE_HARPOON; + public static final HarpoonItem IRON_HARPOON; + public static final HarpoonItem GOLDEN_HARPOON; + public static final HarpoonItem DIAMOND_HARPOON; + public static final HarpoonItem NETHERITE_HARPOON; + public static final DyeableArmorItem KUSPUK_HOOD; + public static final DyeableArmorItem KUSPUK_BODY; + public static final ArmorItem MUKLUKS; + public static final ArmorItem SNOW_GOGGLES; + public static final ArmorItem SNOWSHOES; + public static final DogsledItem OAK_DOGSLED; + public static final DogsledItem SPRUCE_DOGSLED; + public static final DogsledItem BIRCH_DOGSLED; + public static final DogsledItem JUNGLE_DOGSLED; + public static final DogsledItem ACACIA_DOGSLED; + public static final DogsledItem DARK_OAK_DOGSLED; + public static final SpawnEggItem SEAL_SPAWN_EGG; + public static final SpawnEggItem PTARMIGAN_SPAWN_EGG; + public static final SpawnEggItem MOOSE_SPAWN_EGG; + + static { + MUKTUK = register("muktuk", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(1.0F).build()))); + SEAL = register("seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); + COOKED_SEAL = register("cooked_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(7).saturationModifier(1.0F).meat().build()))); + DRY_SEAL = register("dry_seal", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(9).saturationModifier(0.2F).meat().build()))); + PTARMIGAN = register("ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.3F).statusEffect(new StatusEffectInstance(StatusEffects.HUNGER, 400, 0), 0.5F).meat().build()))); + COOKED_PTARMIGAN = register("cooked_ptarmigan", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(5).saturationModifier(0.6F).meat().build()))); + VENISON = register("venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(3).saturationModifier(0.3F).meat().build()))); + COOKED_VENISON = register("cooked_venison", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(8).saturationModifier(0.8F).meat().build()))); + + DRIFTWOOD_CHUNK = register("driftwood_chunk", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + ANTLER = register("antler", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + IVORY = register("ivory", new Item(new QuiltItemSettings().group(ItemGroup.MISC))); + + FISH_STRIP = register("fish_strip", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(0.1F).snack().build()))); + DRY_FISH = register("dry_fish", new Item(new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(1).saturationModifier(1F).snack().build()))); + + BLUEBERRIES = register("blueberries", new AliasedBlockItem(AlaskaBlocks.BLUEBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + CLOUDBERRIES = register("cloudberries", new AliasedBlockItem(AlaskaBlocks.CLOUDBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + RASPBERRIES = register("raspberries", new AliasedBlockItem(AlaskaBlocks.RASPBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + SALMONBERRIES = register("salmonberries", new AliasedBlockItem(AlaskaBlocks.SALMONBERRY_BUSH, new QuiltItemSettings().group(ItemGroup.FOOD).food(new FoodComponent.Builder().hunger(2).saturationModifier(0.1F).snack().build()))); + + LABRADOR_TEA = register("labrador_tea", new BlockItem(AlaskaBlocks.LABRADOR_TEA, new QuiltItemSettings().group(ItemGroup.BREWING))); + + AKUTAQ = register("akutaq", new SuspiciousStewItem(new QuiltItemSettings().group(ItemGroup.FOOD).maxCount(1).food(new FoodComponent.Builder().hunger(4).saturationModifier(0.8F).build()))); + + ULU = register("ulu", new UluItem(new QuiltItemSettings().group(ItemGroup.TOOLS).maxDamage(472))); + + WOODEN_HARPOON = register("wooden_harpoon", new HarpoonItem(ToolMaterials.WOOD, 4.0F, -2.2F, () -> AlaskaEntities.WOODEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + STONE_HARPOON = register("stone_harpoon", new HarpoonItem(ToolMaterials.STONE, 4.0F, -2.3F, () -> AlaskaEntities.STONE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + IRON_HARPOON = register("iron_harpoon", new HarpoonItem(ToolMaterials.IRON, 4.0F, -2.5F, () -> AlaskaEntities.IRON_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + GOLDEN_HARPOON = register("golden_harpoon", new HarpoonItem(ToolMaterials.GOLD, 4.0F, -2.7F, () -> AlaskaEntities.GOLDEN_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + DIAMOND_HARPOON = register("diamond_harpoon", new HarpoonItem(ToolMaterials.DIAMOND, 4.0F, -2.7F, () -> AlaskaEntities.DIAMOND_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT))); + NETHERITE_HARPOON = register("netherite_harpoon", new HarpoonItem(ToolMaterials.NETHERITE, 4.0F, -2.8F, () -> AlaskaEntities.NETHERITE_HARPOON, new QuiltItemSettings().group(ItemGroup.COMBAT).fireproof())); + + KUSPUK_HOOD = register("kuspuk_hood", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); + KUSPUK_BODY = register("kuspuk_body", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.CHEST, new QuiltItemSettings().group(ItemGroup.COMBAT))); + MUKLUKS = register("mukluks", new DyeableArmorItem(AlaskaNativeArmorMaterials.KUSPUK, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); + + SNOW_GOGGLES = register("snow_goggles", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.HEAD, new QuiltItemSettings().group(ItemGroup.COMBAT))); + SNOWSHOES = register("snowshoes", new ArmorItem(AlaskaNativeArmorMaterials.SNOW_GEAR, EquipmentSlot.FEET, new QuiltItemSettings().group(ItemGroup.COMBAT))); + + OAK_DOGSLED = register("oak_dogsled", new DogsledItem(DogsledEntity.Type.OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + SPRUCE_DOGSLED = register("spruce_dogsled", new DogsledItem(DogsledEntity.Type.SPRUCE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + BIRCH_DOGSLED = register("birch_dogsled", new DogsledItem(DogsledEntity.Type.BIRCH, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + JUNGLE_DOGSLED = register("jungle_dogsled", new DogsledItem(DogsledEntity.Type.JUNGLE, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + ACACIA_DOGSLED = register("acacia_dogsled", new DogsledItem(DogsledEntity.Type.ACACIA, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + DARK_OAK_DOGSLED = register("dark_oak_dogsled", new DogsledItem(DogsledEntity.Type.DARK_OAK, new QuiltItemSettings().maxCount(1).group(ItemGroup.TRANSPORTATION))); + + SEAL_SPAWN_EGG = register("seal_spawn_egg", new SpawnEggItem(AlaskaEntities.HARP_SEAL, 8355711, 3355443, new QuiltItemSettings().group(ItemGroup.MISC))); + PTARMIGAN_SPAWN_EGG = register("ptarmigan_spawn_egg", new SpawnEggItem(AlaskaEntities.PTARMIGAN, 13750737, 12763849, new QuiltItemSettings().group(ItemGroup.MISC))); + MOOSE_SPAWN_EGG = register("moose_spawn_egg", new SpawnEggItem(AlaskaEntities.MOOSE, 3811094, 14075317, new QuiltItemSettings().group(ItemGroup.MISC))); + } + + private static I register(String name, I item) { + return Registry.register(Registry.ITEM, new Identifier(AlaskaNativeCraft.MOD_ID, name), item); + } + + public static void register() { + addPotionRecipes(); + addItemGroupEntries(); + addSnowGogglesToLootTable(); + } + + private static void addPotionRecipes() { + for (Potion potion : List.of(Potions.WATER, Potions.MUNDANE, Potions.THICK, Potions.AWKWARD)) { + BrewingRecipeRegistryAccessor.registerRecipe(potion, AlaskaItems.LABRADOR_TEA, AlaskaPotions.TUNDRA_TEA); + } + + BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, AlaskaItems.LABRADOR_TEA, AlaskaPotions.STRONG_TUNDRA_TEA); + BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.GLOWSTONE_DUST, AlaskaPotions.STRONG_TUNDRA_TEA); + BrewingRecipeRegistryAccessor.registerRecipe(AlaskaPotions.TUNDRA_TEA, Items.REDSTONE, AlaskaPotions.LONG_TUNDRA_TEA); + } + + private static void addItemGroupEntries() { + QuiltItemGroup.builder(new Identifier(AlaskaNativeCraft.MOD_ID, "items")).icon(() -> MUKTUK.asItem().getDefaultStack()).appendItems(stacks -> Registry.ITEM.forEach(item -> { + if (Registry.ITEM.getId(item).getNamespace().equals(AlaskaNativeCraft.MOD_ID)) { + item.appendStacks(item.getGroup(), (DefaultedList) stacks); + } + })).build(); + } + + private static void addSnowGogglesToLootTable() { + LootTableEvents.MODIFY.register((resourceManager, lootManager, id, table, source) -> { + if (LootTables.VILLAGE_SNOWY_HOUSE_CHEST.equals(id) || LootTables.VILLAGE_TAIGA_HOUSE_CHEST.equals(id)) { + LootPool.Builder poolBuilder = new LootPool.Builder().rolls(UniformLootNumberProvider.create(0.0F, 1.0F)) + .with(ItemEntry.builder(AlaskaItems.SNOW_GOGGLES).build()); + + table.pool(poolBuilder); + } + }); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java index dbfe445a..b50f83d2 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/AlaskaPotions.java @@ -1,12 +1,13 @@ package com.github.platymemo.alaskanativecraft.item; import com.github.platymemo.alaskanativecraft.entity.effect.AlaskaEffects; + import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.potion.Potion; import net.minecraft.util.registry.Registry; public class AlaskaPotions { - public static final Potion TUNDRA_TEA = Registry.register(Registry.POTION, "tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 1200))); - public static final Potion LONG_TUNDRA_TEA = Registry.register(Registry.POTION, "long_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 2400))); - public static final Potion STRONG_TUNDRA_TEA = Registry.register(Registry.POTION, "strong_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 600, 1))); + public static final Potion TUNDRA_TEA = Registry.register(Registry.POTION, "tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 1200))); + public static final Potion LONG_TUNDRA_TEA = Registry.register(Registry.POTION, "long_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 2400))); + public static final Potion STRONG_TUNDRA_TEA = Registry.register(Registry.POTION, "strong_tundra_tea", new Potion(new StatusEffectInstance(AlaskaEffects.MEDICINAL, 600, 1))); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java index 102eb217..51bb2e02 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/DogsledItem.java @@ -1,6 +1,11 @@ package com.github.platymemo.alaskanativecraft.item; +import java.util.List; +import java.util.function.Predicate; + import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; +import org.jetbrains.annotations.NotNull; + import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; @@ -14,65 +19,61 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; - -import java.util.List; -import java.util.function.Predicate; public class DogsledItem extends Item { - private static final Predicate RIDERS; + private static final Predicate RIDERS; - static { - RIDERS = EntityPredicates.EXCEPT_SPECTATOR.and(Entity::collides); - } + static { + RIDERS = EntityPredicates.EXCEPT_SPECTATOR.and(Entity::collides); + } - private final DogsledEntity.Type type; + private final DogsledEntity.Type type; - public DogsledItem(DogsledEntity.Type type, Item.Settings settings) { - super(settings); - this.type = type; - } + public DogsledItem(DogsledEntity.Type type, Item.Settings settings) { + super(settings); + this.type = type; + } - @Override - public TypedActionResult use(World world, @NotNull PlayerEntity user, Hand hand) { - ItemStack itemStack = user.getStackInHand(hand); - HitResult hitResult = raycast(world, user, RaycastContext.FluidHandling.ANY); - if (hitResult.getType() == HitResult.Type.MISS) { - return TypedActionResult.pass(itemStack); - } else { - Vec3d vec3d = user.getRotationVec(1.0F); - List list = world.getOtherEntities(user, user.getBoundingBox().stretch(vec3d.multiply(5.0D)).expand(1.0D), RIDERS); - if (!list.isEmpty()) { - Vec3d vec3d2 = user.getCameraPosVec(1.0F); + @Override + public TypedActionResult use(World world, @NotNull PlayerEntity user, Hand hand) { + ItemStack itemStack = user.getStackInHand(hand); + HitResult hitResult = raycast(world, user, RaycastContext.FluidHandling.ANY); + if (hitResult.getType() == HitResult.Type.MISS) { + return TypedActionResult.pass(itemStack); + } else { + Vec3d vec3d = user.getRotationVec(1.0F); + List list = world.getOtherEntities(user, user.getBoundingBox().stretch(vec3d.multiply(5.0D)).expand(1.0D), RIDERS); + if (!list.isEmpty()) { + Vec3d vec3d2 = user.getCameraPosVec(1.0F); - for (Entity entity : list) { - Box box = entity.getBoundingBox().expand(entity.getTargetingMargin()); - if (box.contains(vec3d2)) { - return TypedActionResult.pass(itemStack); - } - } - } + for (Entity entity : list) { + Box box = entity.getBoundingBox().expand(entity.getTargetingMargin()); + if (box.contains(vec3d2)) { + return TypedActionResult.pass(itemStack); + } + } + } - if (hitResult.getType() == HitResult.Type.BLOCK) { - DogsledEntity dogsledEntity = new DogsledEntity(world, hitResult.getPos().x, hitResult.getPos().y, hitResult.getPos().z); - dogsledEntity.setDogsledType(this.type); - dogsledEntity.setBodyYaw(user.getYaw()); - if (!world.isSpaceEmpty(dogsledEntity, dogsledEntity.getBoundingBox().expand(-0.1D))) { - return TypedActionResult.fail(itemStack); - } else { - if (!world.isClient) { - world.spawnEntity(dogsledEntity); - if (!user.getAbilities().creativeMode) { - itemStack.decrement(1); - } - } + if (hitResult.getType() == HitResult.Type.BLOCK) { + DogsledEntity dogsledEntity = new DogsledEntity(world, hitResult.getPos().x, hitResult.getPos().y, hitResult.getPos().z); + dogsledEntity.setDogsledType(this.type); + dogsledEntity.setBodyYaw(user.getYaw()); + if (!world.isSpaceEmpty(dogsledEntity, dogsledEntity.getBoundingBox().expand(-0.1D))) { + return TypedActionResult.fail(itemStack); + } else { + if (!world.isClient) { + world.spawnEntity(dogsledEntity); + if (!user.getAbilities().creativeMode) { + itemStack.decrement(1); + } + } - user.incrementStat(Stats.USED.getOrCreateStat(this)); - return TypedActionResult.success(itemStack, world.isClient()); - } - } else { - return TypedActionResult.pass(itemStack); - } - } - } + user.incrementStat(Stats.USED.getOrCreateStat(this)); + return TypedActionResult.success(itemStack, world.isClient()); + } + } else { + return TypedActionResult.pass(itemStack); + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java index 9c62ff69..e19bc19b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/HarpoonItem.java @@ -1,8 +1,12 @@ package com.github.platymemo.alaskanativecraft.item; +import java.util.function.Supplier; + import com.github.platymemo.alaskanativecraft.entity.HarpoonEntity; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -29,124 +33,121 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; - -import java.util.function.Supplier; public class HarpoonItem extends TridentItem { - - private final Multimap attributeModifiers; - - private final ToolMaterial material; - private final float attackDamage; - private final Supplier> typeSupplier; - private EntityType cachedType = null; - - public HarpoonItem(@NotNull ToolMaterial material, float attackDamage, float attackSpeed, Supplier> typeSupplier, @NotNull Item.Settings settings) { - super(settings.maxDamageIfAbsent(material.getDurability())); - this.material = material; - this.attackDamage = attackDamage + material.getAttackDamage(); - this.typeSupplier = typeSupplier; - ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); - builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", this.attackDamage - 1, EntityAttributeModifier.Operation.ADDITION)); - builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Tool modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION)); - this.attributeModifiers = builder.build(); - } - - public EntityType getType() { - if (cachedType == null) { - cachedType = typeSupplier.get(); - } - return cachedType; - } - - public ToolMaterial getMaterial() { - return this.material; - } - - @Override - public int getEnchantability() { - return this.material.getEnchantability(); - } - - @Override - public boolean canRepair(ItemStack stack, ItemStack ingredient) { - return this.material.getRepairIngredient().test(ingredient) || super.canRepair(stack, ingredient); - } - - public float getAttackDamage() { - return this.attackDamage; - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) { - Block block = state.getBlock(); - if (block == Blocks.COBWEB) { - return 15.0F; - } else { - Material material = state.getMaterial(); - return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.MOSS_BLOCK && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F; - } - } - - @Override - public Multimap getAttributeModifiers(EquipmentSlot slot) { - return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot); - } - - @Override - public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { - if (user instanceof PlayerEntity playerEntity) { - int i = this.getMaxUseTime(stack) - remainingUseTicks; - if (i >= 10) { - int j = EnchantmentHelper.getRiptide(stack); - if (j <= 0 || playerEntity.isTouchingWaterOrRain()) { - if (!world.isClient && j == 0) { - stack.damage(1, playerEntity, entity -> entity.sendToolBreakStatus(user.getActiveHand())); - HarpoonEntity harpoonEntity = new HarpoonEntity(world, playerEntity, this, stack); - harpoonEntity.setProperties(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F); - if (playerEntity.getAbilities().creativeMode) { - harpoonEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY; - } - - world.spawnEntity(harpoonEntity); - world.playSoundFromEntity(null, harpoonEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); - if (!playerEntity.getAbilities().creativeMode) { - playerEntity.getInventory().removeOne(stack); - } - } - - playerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); - if (j > 0) { - float yaw = playerEntity.getYaw(); - float pitch = playerEntity.getPitch(); - float h = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); - float k = -MathHelper.sin(pitch * 0.017453292F); - float l = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); - float length = MathHelper.sqrt(h * h + k * k + l * l); - float multiplier = 3.0F * ((1.0F + (float) j) / 5.5F); - h *= multiplier / length; - k *= multiplier / length; - l *= multiplier / length; - playerEntity.addVelocity(h, k, l); - playerEntity.startRiptideAttack(20); - if (playerEntity.isOnGround()) { - playerEntity.move(MovementType.SELF, new Vec3d(0.0D, 1.2D, 0.0D)); - } - - SoundEvent soundEvent; - if (j >= 3) { - soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_3; - } else if (j == 2) { - soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_2; - } else { - soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_1; - } - - world.playSoundFromEntity(null, playerEntity, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F); - } - } - } - } - } + private final Multimap attributeModifiers; + + private final ToolMaterial material; + private final float attackDamage; + private final Supplier> typeSupplier; + private EntityType cachedType = null; + + public HarpoonItem(@NotNull ToolMaterial material, float attackDamage, float attackSpeed, Supplier> typeSupplier, @NotNull Item.Settings settings) { + super(settings.maxDamageIfAbsent(material.getDurability())); + this.material = material; + this.attackDamage = attackDamage + material.getAttackDamage(); + this.typeSupplier = typeSupplier; + ImmutableMultimap.Builder builder = ImmutableMultimap.builder(); + builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", this.attackDamage - 1, EntityAttributeModifier.Operation.ADDITION)); + builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Tool modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION)); + this.attributeModifiers = builder.build(); + } + + public EntityType getType() { + if (this.cachedType == null) { + this.cachedType = this.typeSupplier.get(); + } + + return this.cachedType; + } + + public ToolMaterial getMaterial() { + return this.material; + } + + @Override + public int getEnchantability() { + return this.material.getEnchantability(); + } + + @Override + public boolean canRepair(ItemStack stack, ItemStack ingredient) { + return this.material.getRepairIngredient().test(ingredient) || super.canRepair(stack, ingredient); + } + + public float getAttackDamage() { + return this.attackDamage; + } + + @Override + public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) { + Block block = state.getBlock(); + if (block == Blocks.COBWEB) { + return 15.0F; + } else { + Material material = state.getMaterial(); + return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.MOSS_BLOCK && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F; + } + } + + @Override + public Multimap getAttributeModifiers(EquipmentSlot slot) { + return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot); + } + + @Override + public void onStoppedUsing(ItemStack stack, World world, LivingEntity user, int remainingUseTicks) { + if (user instanceof PlayerEntity playerEntity) { + int i = this.getMaxUseTime(stack) - remainingUseTicks; + if (i >= 10) { + int j = EnchantmentHelper.getRiptide(stack); + if (j <= 0 || playerEntity.isTouchingWaterOrRain()) { + if (!world.isClient && j == 0) { + stack.damage(1, playerEntity, entity -> entity.sendToolBreakStatus(user.getActiveHand())); + HarpoonEntity harpoonEntity = new HarpoonEntity(world, playerEntity, this, stack); + harpoonEntity.setProperties(playerEntity, playerEntity.getPitch(), playerEntity.getYaw(), 0.0F, 2.5F, 1.0F); + if (playerEntity.getAbilities().creativeMode) { + harpoonEntity.pickupType = PersistentProjectileEntity.PickupPermission.CREATIVE_ONLY; + } + + world.spawnEntity(harpoonEntity); + world.playSoundFromEntity(null, harpoonEntity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F); + if (!playerEntity.getAbilities().creativeMode) { + playerEntity.getInventory().removeOne(stack); + } + } + + playerEntity.incrementStat(Stats.USED.getOrCreateStat(this)); + if (j > 0) { + float yaw = playerEntity.getYaw(); + float pitch = playerEntity.getPitch(); + float h = -MathHelper.sin(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); + float k = -MathHelper.sin(pitch * 0.017453292F); + float l = MathHelper.cos(yaw * 0.017453292F) * MathHelper.cos(pitch * 0.017453292F); + float length = MathHelper.sqrt(h * h + k * k + l * l); + float multiplier = 3.0F * ((1.0F + (float) j) / 5.5F); + h *= multiplier / length; + k *= multiplier / length; + l *= multiplier / length; + playerEntity.addVelocity(h, k, l); + playerEntity.startRiptideAttack(20); + if (playerEntity.isOnGround()) { + playerEntity.move(MovementType.SELF, new Vec3d(0.0D, 1.2D, 0.0D)); + } + + SoundEvent soundEvent; + if (j >= 3) { + soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_3; + } else if (j == 2) { + soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_2; + } else { + soundEvent = SoundEvents.ITEM_TRIDENT_RIPTIDE_1; + } + + world.playSoundFromEntity(null, playerEntity, soundEvent, SoundCategory.PLAYERS, 1.0F, 1.0F); + } + } + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java index a44a41e8..715a4774 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/UluItem.java @@ -2,28 +2,28 @@ import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.MiningToolItem; import net.minecraft.item.ToolMaterials; import net.minecraft.tag.BlockTags; -import org.jetbrains.annotations.NotNull; public class UluItem extends MiningToolItem { + public UluItem(Settings settings) { + super(1.0F, -2.8F, ToolMaterials.IRON, AlaskaTags.ULU_MINEABLE, settings); + } - public UluItem(Settings settings) { - super(1.0F, -2.8F, ToolMaterials.IRON, AlaskaTags.ULU_MINEABLE, settings); - } - - @Override - public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) { - if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) { - return state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state); - } else if (state.isOf(AlaskaBlocks.WHALE_MEAT_BLOCK)) { - return 1.5F; - } else { - return 15.0F; - } - } + @Override + public float getMiningSpeedMultiplier(ItemStack stack, @NotNull BlockState state) { + if (!state.isOf(Blocks.COBWEB) && !state.isIn(BlockTags.LEAVES)) { + return state.isIn(BlockTags.WOOL) ? 5.0F : super.getMiningSpeedMultiplier(stack, state); + } else if (state.isOf(AlaskaBlocks.WHALE_MEAT_BLOCK)) { + return 1.5F; + } else { + return 15.0F; + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java index 38891d0c..51f38107 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/item/material/AlaskaNativeArmorMaterials.java @@ -2,79 +2,78 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; + import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ArmorMaterial; import net.minecraft.recipe.Ingredient; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.tag.ItemTags; -import org.jetbrains.annotations.NotNull; public enum AlaskaNativeArmorMaterials implements ArmorMaterial { + KUSPUK("kuspuk", 5, new int[] {1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.WOOL)), + SNOW_GEAR("snow_goggles", 5, new int[] {1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.PLANKS)); - KUSPUK("kuspuk", 5, new int[]{1, 0, 3, 1}, 15, SoundEvents.BLOCK_WOOL_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.WOOL)), - - SNOW_GEAR("snow_goggles", 5, new int[]{1, 0, 0, 1}, 25, SoundEvents.BLOCK_WOOD_STEP, 0.0F, 0.0F, Ingredient.ofTag(ItemTags.PLANKS)); - - private static final int[] BASE_DURABILITY = new int[]{13, 15, 16, 11}; - private final String name; - private final int durabilityMultiplier; - private final int[] protectionAmounts; - private final int enchantability; - private final SoundEvent equipSound; - private final float toughness; - private final float knockbackResistance; - private final Ingredient repairIngredient; + private static final int[] BASE_DURABILITY = new int[] {13, 15, 16, 11}; + private final String name; + private final int durabilityMultiplier; + private final int[] protectionAmounts; + private final int enchantability; + private final SoundEvent equipSound; + private final float toughness; + private final float knockbackResistance; + private final Ingredient repairIngredient; - AlaskaNativeArmorMaterials(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, SoundEvent equipSound, float toughness, float knockbackResistance, Ingredient repairIngredient) { - this.name = name; - this.durabilityMultiplier = durabilityMultiplier; - this.protectionAmounts = protectionAmounts; - this.enchantability = enchantability; - this.equipSound = equipSound; - this.toughness = toughness; - this.knockbackResistance = knockbackResistance; - this.repairIngredient = repairIngredient; - } + AlaskaNativeArmorMaterials(String name, int durabilityMultiplier, int[] protectionAmounts, int enchantability, SoundEvent equipSound, float toughness, float knockbackResistance, Ingredient repairIngredient) { + this.name = name; + this.durabilityMultiplier = durabilityMultiplier; + this.protectionAmounts = protectionAmounts; + this.enchantability = enchantability; + this.equipSound = equipSound; + this.toughness = toughness; + this.knockbackResistance = knockbackResistance; + this.repairIngredient = repairIngredient; + } - @Override - public int getDurability(@NotNull EquipmentSlot slot) { - return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier; - } + @Override + public int getDurability(@NotNull EquipmentSlot slot) { + return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier; + } - @Override - public int getProtectionAmount(@NotNull EquipmentSlot slot) { - return this.protectionAmounts[slot.getEntitySlotId()]; - } + @Override + public int getProtectionAmount(@NotNull EquipmentSlot slot) { + return this.protectionAmounts[slot.getEntitySlotId()]; + } - @Override - public int getEnchantability() { - return this.enchantability; - } + @Override + public int getEnchantability() { + return this.enchantability; + } - @Override - public SoundEvent getEquipSound() { - return this.equipSound; - } + @Override + public SoundEvent getEquipSound() { + return this.equipSound; + } - @Override - public Ingredient getRepairIngredient() { - return this.repairIngredient; - } + @Override + public Ingredient getRepairIngredient() { + return this.repairIngredient; + } - @Override - @Environment(EnvType.CLIENT) - public String getName() { - return this.name; - } + @Override + @Environment(EnvType.CLIENT) + public String getName() { + return this.name; + } - @Override - public float getToughness() { - return this.toughness; - } + @Override + public float getToughness() { + return this.toughness; + } - @Override - public float getKnockbackResistance() { - return this.knockbackResistance; - } + @Override + public float getKnockbackResistance() { + return this.knockbackResistance; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java index 4f071d3c..b184b40e 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/AlaskaLootFunctionTypes.java @@ -1,14 +1,15 @@ package com.github.platymemo.alaskanativecraft.loot.function; import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; + import net.minecraft.loot.function.LootFunctionType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class AlaskaLootFunctionTypes { - public static final LootFunctionType SET_AKUTAQ_EFFECT = new LootFunctionType(new SetAkutaqEffectsLootFunction.Serializer()); + public static final LootFunctionType SET_AKUTAQ_EFFECT = new LootFunctionType(new SetAkutaqEffectsLootFunction.Serializer()); - public static void register() { - Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "set_akutaq_effects"), SET_AKUTAQ_EFFECT); - } + public static void register() { + Registry.register(Registry.LOOT_FUNCTION_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "set_akutaq_effects"), SET_AKUTAQ_EFFECT); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java index 06a3799a..bd6fe348 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/loot/function/SetAkutaqEffectsLootFunction.java @@ -1,12 +1,23 @@ package com.github.platymemo.alaskanativecraft.loot.function; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.github.platymemo.alaskanativecraft.recipe.AkutaqRecipe; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Maps; -import com.google.gson.*; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSyntaxException; + import net.minecraft.entity.effect.StatusEffect; import net.minecraft.item.ItemStack; import net.minecraft.loot.condition.LootCondition; @@ -21,130 +32,126 @@ import net.minecraft.util.JsonHelper; import net.minecraft.util.registry.Registry; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - public class SetAkutaqEffectsLootFunction extends ConditionalLootFunction { - final Map effects; - final LootNumberProvider amountNumberProvider; - - SetAkutaqEffectsLootFunction(LootCondition[] conditions, Map effects, LootNumberProvider amountNumberProvider) { - super(conditions); - this.effects = ImmutableMap.copyOf(effects); - this.amountNumberProvider = amountNumberProvider; - } - - public static SetAkutaqEffectsLootFunction.Builder builder() { - return new SetAkutaqEffectsLootFunction.Builder(); - } - - @Override - public LootFunctionType getType() { - return AlaskaLootFunctionTypes.SET_AKUTAQ_EFFECT; - } - - @Override - public Set> getRequiredParameters() { - return this.effects - .values() - .stream() - .flatMap(numberProvider -> numberProvider.getRequiredParameters().stream()) - .collect(ImmutableSet.toImmutableSet()); - } - - @Override - public ItemStack process(ItemStack stack, LootContext context) { - if (stack.isOf(AlaskaItems.AKUTAQ) && !this.effects.isEmpty()) { - for (int i = 0; i < this.amountNumberProvider.nextInt(context); i++) { - int selectedInt = context.getRandom().nextInt(this.effects.size()); - Entry entry = Iterables.get(this.effects.entrySet(), selectedInt); - StatusEffect statusEffect = entry.getKey(); - int duration = entry.getValue().nextInt(context); - if (!statusEffect.isInstant()) { - duration *= 20; - } - - AkutaqRecipe.addEffectToAkutaq(stack, statusEffect, duration); - } - } - return stack; - } - - public static class Builder extends ConditionalLootFunction.Builder { - private final Map map = Maps.newHashMap(); - private LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(0.0F); - - @Override - protected SetAkutaqEffectsLootFunction.Builder getThisBuilder() { - return this; - } - - public SetAkutaqEffectsLootFunction.Builder withAmount(LootNumberProvider amountRange) { - this.amountNumberProvider = amountRange; - return this; - } - - public SetAkutaqEffectsLootFunction.Builder withEffect(StatusEffect effect, LootNumberProvider durationRange) { - this.map.put(effect, durationRange); - return this; - } - - @Override - public LootFunction build() { - return new SetAkutaqEffectsLootFunction(this.getConditions(), this.map, amountNumberProvider); - } - } - - public static class Serializer extends ConditionalLootFunction.Serializer { - @Override - public void toJson(JsonObject jsonObject, SetAkutaqEffectsLootFunction lootFunction, JsonSerializationContext jsonSerializationContext) { - super.toJson(jsonObject, lootFunction, jsonSerializationContext); - if (!lootFunction.effects.isEmpty()) { - JsonArray jsonArray = new JsonArray(); - - for (StatusEffect statusEffect : lootFunction.effects.keySet()) { - JsonObject jsonObject2 = new JsonObject(); - Identifier identifier = Registry.STATUS_EFFECT.getId(statusEffect); - if (identifier == null) { - throw new IllegalArgumentException("Don't know how to serialize mob effect " + statusEffect); - } - - jsonObject2.add("type", new JsonPrimitive(identifier.toString())); - jsonObject2.add("duration", jsonSerializationContext.serialize(lootFunction.effects.get(statusEffect))); - jsonArray.add(jsonObject2); - } - - jsonObject.add("effects", jsonArray); - } - - } - - @Override - public SetAkutaqEffectsLootFunction fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, LootCondition[] lootConditions) { - Map map = Maps.newHashMap(); - if (jsonObject.has("effects")) { - for (JsonElement jsonElement : JsonHelper.getArray(jsonObject, "effects")) { - String string = JsonHelper.getString(jsonElement.getAsJsonObject(), "type"); - StatusEffect statusEffect = Registry.STATUS_EFFECT - .getOrEmpty(new Identifier(string)) - .orElseThrow(() -> new JsonSyntaxException("Unknown mob effect '" + string + "'")); - LootNumberProvider lootNumberProvider = JsonHelper.deserialize( - jsonElement.getAsJsonObject(), "duration", jsonDeserializationContext, LootNumberProvider.class - ); - - map.put(statusEffect, lootNumberProvider); - } - } - - LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(1.0F); - if (jsonObject.has("amount")) { - amountNumberProvider = JsonHelper.deserialize( - jsonObject, "amount", jsonDeserializationContext, LootNumberProvider.class - ); - } - - return new SetAkutaqEffectsLootFunction(lootConditions, map, amountNumberProvider); - } - } + final Map effects; + final LootNumberProvider amountNumberProvider; + + SetAkutaqEffectsLootFunction(LootCondition[] conditions, Map effects, LootNumberProvider amountNumberProvider) { + super(conditions); + this.effects = ImmutableMap.copyOf(effects); + this.amountNumberProvider = amountNumberProvider; + } + + public static SetAkutaqEffectsLootFunction.Builder builder() { + return new SetAkutaqEffectsLootFunction.Builder(); + } + + @Override + public LootFunctionType getType() { + return AlaskaLootFunctionTypes.SET_AKUTAQ_EFFECT; + } + + @Override + public Set> getRequiredParameters() { + return this.effects + .values() + .stream() + .flatMap(numberProvider -> numberProvider.getRequiredParameters().stream()) + .collect(ImmutableSet.toImmutableSet()); + } + + @Override + public ItemStack process(ItemStack stack, LootContext context) { + if (stack.isOf(AlaskaItems.AKUTAQ) && !this.effects.isEmpty()) { + for (int i = 0; i < this.amountNumberProvider.nextInt(context); i++) { + int selectedInt = context.getRandom().nextInt(this.effects.size()); + Entry entry = Iterables.get(this.effects.entrySet(), selectedInt); + StatusEffect statusEffect = entry.getKey(); + int duration = entry.getValue().nextInt(context); + if (!statusEffect.isInstant()) { + duration *= 20; + } + + AkutaqRecipe.addEffectToAkutaq(stack, statusEffect, duration); + } + } + + return stack; + } + + public static class Builder extends ConditionalLootFunction.Builder { + private final Map map = Maps.newHashMap(); + private LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(0.0F); + + @Override + protected SetAkutaqEffectsLootFunction.Builder getThisBuilder() { + return this; + } + + public SetAkutaqEffectsLootFunction.Builder withAmount(LootNumberProvider amountRange) { + this.amountNumberProvider = amountRange; + return this; + } + + public SetAkutaqEffectsLootFunction.Builder withEffect(StatusEffect effect, LootNumberProvider durationRange) { + this.map.put(effect, durationRange); + return this; + } + + @Override + public LootFunction build() { + return new SetAkutaqEffectsLootFunction(this.getConditions(), this.map, this.amountNumberProvider); + } + } + + public static class Serializer extends ConditionalLootFunction.Serializer { + @Override + public void toJson(JsonObject jsonObject, SetAkutaqEffectsLootFunction lootFunction, JsonSerializationContext jsonSerializationContext) { + super.toJson(jsonObject, lootFunction, jsonSerializationContext); + if (!lootFunction.effects.isEmpty()) { + JsonArray jsonArray = new JsonArray(); + + for (StatusEffect statusEffect : lootFunction.effects.keySet()) { + JsonObject jsonObject2 = new JsonObject(); + Identifier identifier = Registry.STATUS_EFFECT.getId(statusEffect); + if (identifier == null) { + throw new IllegalArgumentException("Don't know how to serialize mob effect " + statusEffect); + } + + jsonObject2.add("type", new JsonPrimitive(identifier.toString())); + jsonObject2.add("duration", jsonSerializationContext.serialize(lootFunction.effects.get(statusEffect))); + jsonArray.add(jsonObject2); + } + + jsonObject.add("effects", jsonArray); + } + } + + @Override + public SetAkutaqEffectsLootFunction fromJson(JsonObject jsonObject, JsonDeserializationContext jsonDeserializationContext, LootCondition[] lootConditions) { + Map map = Maps.newHashMap(); + if (jsonObject.has("effects")) { + for (JsonElement jsonElement : JsonHelper.getArray(jsonObject, "effects")) { + String string = JsonHelper.getString(jsonElement.getAsJsonObject(), "type"); + StatusEffect statusEffect = Registry.STATUS_EFFECT + .getOrEmpty(new Identifier(string)) + .orElseThrow(() -> new JsonSyntaxException("Unknown mob effect '" + string + "'")); + LootNumberProvider lootNumberProvider = JsonHelper.deserialize( + jsonElement.getAsJsonObject(), "duration", jsonDeserializationContext, LootNumberProvider.class + ); + + map.put(statusEffect, lootNumberProvider); + } + } + + LootNumberProvider amountNumberProvider = ConstantLootNumberProvider.create(1.0F); + if (jsonObject.has("amount")) { + amountNumberProvider = JsonHelper.deserialize( + jsonObject, "amount", jsonDeserializationContext, LootNumberProvider.class + ); + } + + return new SetAkutaqEffectsLootFunction(lootConditions, map, amountNumberProvider); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java index f1df68b8..815fcd0c 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AnvilScreenHandlerMixin.java @@ -1,10 +1,6 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; -import net.minecraft.screen.*; import org.jetbrains.annotations.Nullable; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; @@ -14,33 +10,41 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.screen.AnvilScreenHandler; +import net.minecraft.screen.ForgingScreenHandler; +import net.minecraft.screen.Property; +import net.minecraft.screen.ScreenHandlerContext; +import net.minecraft.screen.ScreenHandlerType; + @Mixin(AnvilScreenHandler.class) public abstract class AnvilScreenHandlerMixin extends ForgingScreenHandler { + @Shadow + @Final + private final Property levelCost; - @Shadow - @Final - private final Property levelCost; - - @Shadow - private int repairItemUsage; + @Shadow + private int repairItemUsage; - protected AnvilScreenHandlerMixin(@Nullable ScreenHandlerType type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) { - super(type, syncId, playerInventory, context); - throw new AssertionError("AlaskaNativeCraft's AnvilScreenHandlerMixin constructor called!"); - } + protected AnvilScreenHandlerMixin(@Nullable ScreenHandlerType type, int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) { + super(type, syncId, playerInventory, context); + throw new AssertionError("AlaskaNativeCraft's AnvilScreenHandlerMixin constructor called!"); + } - @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), method = "updateResult", cancellable = true) - private void addLeashedHarpoon(CallbackInfo ci) { - ItemStack base = this.input.getStack(0); - ItemStack addition = this.input.getStack(1); - if (base.isIn(AlaskaTags.HARPOONS) && !base.getOrCreateNbt().getBoolean("leashed") && addition.isOf(Items.LEAD)) { - ItemStack result = base.copy(); - result.getOrCreateNbt().putInt("leashed", addition.getCount()); - this.output.setStack(0, result); - this.levelCost.set(1); - this.repairItemUsage = 1; - sendContentUpdates(); - ci.cancel(); - } - } + @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), method = "updateResult", cancellable = true) + private void addLeashedHarpoon(CallbackInfo ci) { + ItemStack base = this.input.getStack(0); + ItemStack addition = this.input.getStack(1); + if (base.isIn(AlaskaTags.HARPOONS) && !base.getOrCreateNbt().getBoolean("leashed") && addition.isOf(Items.LEAD)) { + ItemStack result = base.copy(); + result.getOrCreateNbt().putInt("leashed", addition.getCount()); + this.output.setStack(0, result); + this.levelCost.set(1); + this.repairItemUsage = 1; + sendContentUpdates(); + ci.cancel(); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java index c25222a3..a01bbdd9 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/AxeItemAccessor.java @@ -1,16 +1,17 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.block.Block; -import net.minecraft.item.AxeItem; +import java.util.Map; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import net.minecraft.block.Block; +import net.minecraft.item.AxeItem; @Mixin(AxeItem.class) public interface AxeItemAccessor { - @Accessor("STRIPPED_BLOCKS") - static Map getStrippedBlocks() { - throw new AssertionError("Accessor dummy method called somehow!"); - } + @Accessor("STRIPPED_BLOCKS") + static Map getStrippedBlocks() { + throw new AssertionError("Accessor dummy method called somehow!"); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java index 941d528d..69ebd170 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/BrewingRecipeRegistryAccessor.java @@ -1,15 +1,16 @@ package com.github.platymemo.alaskanativecraft.mixin; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + import net.minecraft.item.Item; import net.minecraft.potion.Potion; import net.minecraft.recipe.BrewingRecipeRegistry; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(BrewingRecipeRegistry.class) public interface BrewingRecipeRegistryAccessor { - @Invoker("registerPotionRecipe") - static void registerRecipe(Potion input, Item item, Potion output) { - throw new AssertionError("Something is very wrong!! Dummy method in BrewingRecipeRegistryAccessor called!"); - } + @Invoker("registerPotionRecipe") + static void registerRecipe(Potion input, Item item, Potion output) { + throw new AssertionError("Something is very wrong!! Dummy method in BrewingRecipeRegistryAccessor called!"); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java index 94b081ef..d9c02389 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/EndermanEntityMixin.java @@ -1,6 +1,13 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.mob.EndermanEntity; @@ -8,28 +15,21 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; @Mixin(EndermanEntity.class) public abstract class EndermanEntityMixin extends HostileEntity implements Angerable { + protected EndermanEntityMixin(EntityType entityType, World world) { + super(entityType, world); + throw new AssertionError("Mixin constructor called, something is very wrong!"); + } - protected EndermanEntityMixin(EntityType entityType, World world) { - super(entityType, world); - throw new AssertionError("Mixin constructor called, something is very wrong!"); - } - - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", ordinal = 0), - method = "isPlayerStaring(Lnet/minecraft/entity/player/PlayerEntity;)Z", - locals = LocalCapture.CAPTURE_FAILHARD, - cancellable = true) - private void isPlayerWearingSnowGoggles(PlayerEntity player, CallbackInfoReturnable cir, @NotNull ItemStack stack) { - if (stack.isOf(AlaskaItems.SNOW_GOGGLES.asItem())) { - cir.setReturnValue(false); - } - } + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;isOf(Lnet/minecraft/item/Item;)Z", ordinal = 0), + method = "isPlayerStaring(Lnet/minecraft/entity/player/PlayerEntity;)Z", + locals = LocalCapture.CAPTURE_FAILHARD, + cancellable = true) + private void isPlayerWearingSnowGoggles(PlayerEntity player, CallbackInfoReturnable cir, @NotNull ItemStack stack) { + if (stack.isOf(AlaskaItems.SNOW_GOGGLES.asItem())) { + cir.setReturnValue(false); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java index 2e831bac..6b876b06 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/FoxMixin.java @@ -1,30 +1,30 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.FoxEntity; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(FoxEntity.class) public abstract class FoxMixin extends AnimalEntity { + protected FoxMixin(EntityType type, World world) { + super(type, world); + throw new AssertionError("AlaskaNativeCraft's FoxMixin constructor called!"); + } - protected FoxMixin(EntityType type, World world) { - super(type, world); - throw new AssertionError("AlaskaNativeCraft's FoxMixin constructor called!"); - } - - // Mixin to the lambdas for chicken and rabbit predicate - // There is some very weird stuff happening, but it works:tm: - @Inject(at = @At("HEAD"), method = {"m_hklcoapa", "m_clkjuklc", "method_18262", "method_18261"}, cancellable = true, require = 1, remap = false) - private static void addPtarmiganTarget(LivingEntity entity, CallbackInfoReturnable cir) { - if (entity instanceof PtarmiganEntity) { - cir.setReturnValue(true); - } - } + // Mixin to the lambdas for chicken and rabbit predicate + // There is some very weird stuff happening, but it works:tm: + @Inject(at = @At("HEAD"), method = {"m_hklcoapa", "m_clkjuklc", "method_18262", "method_18261"}, cancellable = true, require = 1, remap = false) + private static void addPtarmiganTarget(LivingEntity entity, CallbackInfoReturnable cir) { + if (entity instanceof PtarmiganEntity) { + cir.setReturnValue(true); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java index 7591e667..18230605 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/GrindstoneScreenHandlerMixin.java @@ -1,9 +1,5 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.inventory.Inventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.screen.GrindstoneScreenHandler; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -13,22 +9,27 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.inventory.Inventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.screen.GrindstoneScreenHandler; + @Mixin(GrindstoneScreenHandler.class) public abstract class GrindstoneScreenHandlerMixin { - @Shadow - @Final - Inventory input; + @Shadow + @Final + Inventory input; - @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I")) - private int redirectGetMaxDamage(Item item) { - return this.input.getStack(0).getMaxDamage(); - } + @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I")) + private int redirectGetMaxDamage(Item item) { + return this.input.getStack(0).getMaxDamage(); + } - @SuppressWarnings("ConstantConditions") - @Inject(method = "transferEnchantments", at = @At("RETURN")) - private void copyDurabilityMultiplier(ItemStack target, @NotNull ItemStack source, CallbackInfoReturnable cir) { - if (source.hasNbt() && source.getNbt().contains("DurabilityMultiplier")) { - cir.getReturnValue().getNbt().putFloat("DurabilityMultiplier", source.getOrCreateNbt().getFloat("DurabilityMultiplier")); - } - } + @SuppressWarnings("ConstantConditions") + @Inject(method = "transferEnchantments", at = @At("RETURN")) + private void copyDurabilityMultiplier(ItemStack target, @NotNull ItemStack source, CallbackInfoReturnable cir) { + if (source.hasNbt() && source.getNbt().contains("DurabilityMultiplier")) { + cir.getReturnValue().getNbt().putFloat("DurabilityMultiplier", source.getOrCreateNbt().getFloat("DurabilityMultiplier")); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java index d5d61f77..81c5a742 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IglooGeneratorMixin.java @@ -1,8 +1,19 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +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.LocalCapture; + import net.minecraft.loot.LootTables; -import net.minecraft.structure.*; +import net.minecraft.structure.IglooGenerator; +import net.minecraft.structure.Structure; +import net.minecraft.structure.StructureManager; +import net.minecraft.structure.StructurePlacementData; +import net.minecraft.structure.StructureTemplateManager; import net.minecraft.structure.piece.SimpleStructurePiece; import net.minecraft.structure.piece.StructurePieceType; import net.minecraft.text.Text; @@ -14,45 +25,39 @@ import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.StructureWorldAccess; import net.minecraft.world.gen.chunk.ChunkGenerator; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -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.LocalCapture; @Mixin(IglooGenerator.Piece.class) public abstract class IglooGeneratorMixin extends SimpleStructurePiece { - private static final Identifier DOGSLED_LOOT_TABLE = LootTables.VILLAGE_SNOWY_HOUSE_CHEST; - private static BlockPos lastPos; + private static final Identifier DOGSLED_LOOT_TABLE = LootTables.VILLAGE_SNOWY_HOUSE_CHEST; + private static BlockPos lastPos; - @Shadow - private static StructurePlacementData createPlacementData(BlockRotation rotation, Identifier identifier) { - throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!"); - } + protected IglooGeneratorMixin(StructureTemplateManager manager, Identifier identifier, BlockPos pos, BlockRotation rotation, int yOffset) { + super(StructurePieceType.IGLOO, 0, manager, identifier, identifier.toString(), createPlacementData(rotation, identifier), getPosOffset(identifier, pos, yOffset)); + throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin constructor called!"); + } - @Shadow - private static BlockPos getPosOffset(Identifier identifier, BlockPos pos, int yOffset) { - throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!"); - } + @Shadow + private static StructurePlacementData createPlacementData(BlockRotation rotation, Identifier identifier) { + throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!"); + } - protected IglooGeneratorMixin(StructureTemplateManager manager, Identifier identifier, BlockPos pos, BlockRotation rotation, int yOffset) { - super(StructurePieceType.IGLOO, 0, manager, identifier, identifier.toString(), createPlacementData(rotation, identifier), getPosOffset(identifier, pos, yOffset)); - throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin constructor called!"); - } + @Shadow + private static BlockPos getPosOffset(Identifier identifier, BlockPos pos, int yOffset) { + throw new AssertionError("AlaskaNativeCraft's IglooGeneratorMixin shadowed method called!"); + } - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/piece/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/structure/StructureManager;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/random/RandomGenerator;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER), - method = "generate", - locals = LocalCapture.CAPTURE_FAILHARD) - private void addDogsleds(StructureWorldAccess world, StructureManager structureManager, ChunkGenerator chunkGenerator, RandomGenerator random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier id, StructurePlacementData structurePlacementData) { - BlockPos chestLocation = this.pos.add(Structure.transform(structurePlacementData, new BlockPos(0, 1, 0))); - if (lastPos == null || !lastPos.equals(chestLocation)) { - DogsledEntity dogsled = new DogsledEntity(world.toServerWorld(), (double) chestLocation.getX() + 0.5D, (double) chestLocation.getY() + 0.5D, (double) chestLocation.getZ() + 0.5D); - dogsled.setDogsledType(DogsledEntity.Type.SPRUCE); - dogsled.setCustomName(Text.literal("Abandoned Dogsled")); - dogsled.setLootTable(DOGSLED_LOOT_TABLE, random.nextLong()); - world.spawnEntity(dogsled); - lastPos = chestLocation; - } - } + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/structure/piece/SimpleStructurePiece;generate(Lnet/minecraft/world/StructureWorldAccess;Lnet/minecraft/structure/StructureManager;Lnet/minecraft/world/gen/chunk/ChunkGenerator;Lnet/minecraft/util/random/RandomGenerator;Lnet/minecraft/util/math/BlockBox;Lnet/minecraft/util/math/ChunkPos;Lnet/minecraft/util/math/BlockPos;)V", shift = At.Shift.AFTER), + method = "generate", + locals = LocalCapture.CAPTURE_FAILHARD) + private void addDogsleds(StructureWorldAccess world, StructureManager structureManager, ChunkGenerator chunkGenerator, RandomGenerator random, BlockBox boundingBox, ChunkPos chunkPos, BlockPos pos, CallbackInfo ci, Identifier id, StructurePlacementData structurePlacementData) { + BlockPos chestLocation = this.pos.add(Structure.transform(structurePlacementData, new BlockPos(0, 1, 0))); + if (lastPos == null || !lastPos.equals(chestLocation)) { + DogsledEntity dogsled = new DogsledEntity(world.toServerWorld(), (double) chestLocation.getX() + 0.5D, (double) chestLocation.getY() + 0.5D, (double) chestLocation.getZ() + 0.5D); + dogsled.setDogsledType(DogsledEntity.Type.SPRUCE); + dogsled.setCustomName(Text.literal("Abandoned Dogsled")); + dogsled.setLootTable(DOGSLED_LOOT_TABLE, random.nextLong()); + world.spawnEntity(dogsled); + lastPos = chestLocation; + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java index 347cffd6..59cb90ef 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/IngredientMixin.java @@ -2,23 +2,23 @@ import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import com.google.gson.JsonObject; -import net.minecraft.item.Item; -import net.minecraft.item.Items; -import net.minecraft.recipe.Ingredient; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import net.minecraft.item.Item; +import net.minecraft.item.Items; +import net.minecraft.recipe.Ingredient; + @Mixin(Ingredient.class) public class IngredientMixin { - - @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/recipe/ShapedRecipe;getItem(Lcom/google/gson/JsonObject;)Lnet/minecraft/item/Item;"), - method = "entryFromJson", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) - private static void addDriftwoodAntlersAndIvory(JsonObject json, CallbackInfoReturnable cir, Item item) { - if (item == Items.STICK) { - cir.setReturnValue(new Ingredient.TagEntry(AlaskaTags.STICKS)); - } - } + @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/recipe/ShapedRecipe;getItem(Lcom/google/gson/JsonObject;)Lnet/minecraft/item/Item;"), + method = "entryFromJson", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private static void addDriftwoodAntlersAndIvory(JsonObject json, CallbackInfoReturnable cir, Item item) { + if (item == Items.STICK) { + cir.setReturnValue(new Ingredient.TagEntry(AlaskaTags.STICKS)); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java index a4659375..a2f0ca97 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemMixin.java @@ -1,29 +1,31 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + @Mixin(Item.class) public abstract class ItemMixin { - @Shadow - @Final - private int maxDamage; + @Shadow + @Final + private int maxDamage; + + @Shadow + public abstract boolean isDamageable(); - @Shadow - public abstract boolean isDamageable(); + @SuppressWarnings("ConstantConditions") + @Redirect(method = {"getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) + private int redirectForDurabilityMultiplier(Item item, ItemStack stack) { + int newMaxDamage = this.maxDamage; + if (this.isDamageable() && stack.hasNbt() && stack.getNbt().contains("DurabilityMultiplier")) { + newMaxDamage *= stack.getNbt().getFloat("DurabilityMultiplier"); + } - @SuppressWarnings("ConstantConditions") - @Redirect(method = {"getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I")) - private int redirectForDurabilityMultiplier(Item item, ItemStack stack) { - int newMaxDamage = this.maxDamage; - if (this.isDamageable() && stack.hasNbt() && stack.getNbt().contains("DurabilityMultiplier")) { - newMaxDamage *= stack.getNbt().getFloat("DurabilityMultiplier"); - } - return newMaxDamage; - } + return newMaxDamage; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java index f8ce8d6c..7c545d07 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ItemStackMixin.java @@ -1,7 +1,5 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -9,23 +7,25 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; + @Mixin(ItemStack.class) public abstract class ItemStackMixin { + @Shadow + @Nullable + public abstract NbtCompound getNbt(); - @Shadow - @Nullable - public abstract NbtCompound getNbt(); - - @Shadow - public abstract boolean hasNbt(); + @Shadow + public abstract boolean hasNbt(); - @SuppressWarnings("ConstantConditions") - @Inject(method = "getMaxDamage", at = @At("RETURN"), cancellable = true) - private void durabilityMultiplier(CallbackInfoReturnable cir) { - if (this.hasNbt() && this.getNbt().contains("DurabilityMultiplier")) { - int newDurability = cir.getReturnValue(); - newDurability *= this.getNbt().getFloat("DurabilityMultiplier"); - cir.setReturnValue(newDurability); - } - } + @SuppressWarnings("ConstantConditions") + @Inject(method = "getMaxDamage", at = @At("RETURN"), cancellable = true) + private void durabilityMultiplier(CallbackInfoReturnable cir) { + if (this.hasNbt() && this.getNbt().contains("DurabilityMultiplier")) { + int newDurability = cir.getReturnValue(); + newDurability *= this.getNbt().getFloat("DurabilityMultiplier"); + cir.setReturnValue(newDurability); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java index 545f287a..82b0fd20 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LeadLengthMixin.java @@ -1,22 +1,22 @@ package com.github.platymemo.alaskanativecraft.mixin; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.MobEntity; import net.minecraft.entity.mob.PathAwareEntity; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; @Mixin(PathAwareEntity.class) public abstract class LeadLengthMixin extends MobEntity { + protected LeadLengthMixin(EntityType entityType, World world) { + super(entityType, world); + } - protected LeadLengthMixin(EntityType entityType, World world) { - super(entityType, world); - } - - @ModifyConstant(method = "updateLeash", constant = @Constant(floatValue = 10.0F)) - private float maxLeadLength(float maxLength) { - return 48.0F; - } -} \ No newline at end of file + @ModifyConstant(method = "updateLeash", constant = @Constant(floatValue = 10.0F)) + private float maxLeadLength(float maxLength) { + return 48.0F; + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java index 378654ee..f63af2b5 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/LivingEntityMixin.java @@ -1,8 +1,20 @@ package com.github.platymemo.alaskanativecraft.mixin; +import java.util.Map; +import java.util.UUID; + import com.github.platymemo.alaskanativecraft.entity.effect.AlaskaEffects; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +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.LocalCapture; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; @@ -17,82 +29,72 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -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.LocalCapture; - -import java.util.Map; -import java.util.UUID; @Mixin(LivingEntity.class) public abstract class LivingEntityMixin extends Entity { - @Unique - private static final UUID SNOWSHOE_SPEED_BOOST_ID = UUID.fromString("0b824742-8bbc-4043-8caf-f997a543495f"); - - protected LivingEntityMixin(EntityType type, World world) { - super(type, world); - throw new AssertionError("wut"); - } + @Unique + private static final UUID SNOWSHOE_SPEED_BOOST_ID = UUID.fromString("0b824742-8bbc-4043-8caf-f997a543495f"); + @Shadow + @Final + private Map activeStatusEffects; - @Shadow - public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute genericMovementSpeed); + protected LivingEntityMixin(EntityType type, World world) { + super(type, world); + throw new AssertionError("wut"); + } - @Shadow - public abstract ItemStack getEquippedStack(EquipmentSlot feet); + @Shadow + public abstract EntityAttributeInstance getAttributeInstance(EntityAttribute genericMovementSpeed); - @Shadow - public abstract RandomGenerator getRandom(); + @Shadow + public abstract ItemStack getEquippedStack(EquipmentSlot feet); - @Shadow @Final private Map activeStatusEffects; + @Shadow + public abstract RandomGenerator getRandom(); - @Inject(method = "removeSoulSpeedBoost", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION) - protected void removeSnowshoeSpeedBoost(CallbackInfo ci, EntityAttributeInstance entityAttributeInstance) { - if (entityAttributeInstance != null && entityAttributeInstance.getModifier(SNOWSHOE_SPEED_BOOST_ID) != null) { - entityAttributeInstance.removeModifier(SNOWSHOE_SPEED_BOOST_ID); - } - } + @Inject(method = "removeSoulSpeedBoost", at = @At("TAIL"), locals = LocalCapture.CAPTURE_FAILEXCEPTION) + protected void removeSnowshoeSpeedBoost(CallbackInfo ci, EntityAttributeInstance entityAttributeInstance) { + if (entityAttributeInstance != null && entityAttributeInstance.getModifier(SNOWSHOE_SPEED_BOOST_ID) != null) { + entityAttributeInstance.removeModifier(SNOWSHOE_SPEED_BOOST_ID); + } + } - @Inject(method = "addSoulSpeedBoostIfNeeded", at = @At("TAIL")) - protected void addSnowshoeSpeedBoostIfNeeded(CallbackInfo ci) { - if (!this.getLandingBlockState().isAir()) { - if (this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.SNOWSHOES) && this.isOnSnowshoeSpeedBlock()) { - EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED); - if (entityAttributeInstance == null) { - return; - } + @Inject(method = "addSoulSpeedBoostIfNeeded", at = @At("TAIL")) + protected void addSnowshoeSpeedBoostIfNeeded(CallbackInfo ci) { + if (!this.getLandingBlockState().isAir()) { + if (this.getEquippedStack(EquipmentSlot.FEET).isOf(AlaskaItems.SNOWSHOES) && this.isOnSnowshoeSpeedBlock()) { + EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED); + if (entityAttributeInstance == null) { + return; + } - entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(SNOWSHOE_SPEED_BOOST_ID, "Snowshoe speed boost", 0.025F, EntityAttributeModifier.Operation.ADDITION)); - if (this.getRandom().nextFloat() < 0.01F) { - ItemStack itemStack = this.getEquippedStack(EquipmentSlot.FEET); - itemStack.damage(1, (LivingEntity) (Object) this, player -> player.sendEquipmentBreakStatus(EquipmentSlot.FEET)); - } - } - } - } + entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(SNOWSHOE_SPEED_BOOST_ID, "Snowshoe speed boost", 0.025F, EntityAttributeModifier.Operation.ADDITION)); + if (this.getRandom().nextFloat() < 0.01F) { + ItemStack itemStack = this.getEquippedStack(EquipmentSlot.FEET); + itemStack.damage(1, (LivingEntity) (Object) this, player -> player.sendEquipmentBreakStatus(EquipmentSlot.FEET)); + } + } + } + } - @Unique - protected boolean isOnSnowshoeSpeedBlock() { - BlockPos pos = this.getVelocityAffectingPos(); - return this.world.getBlockState(pos).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS) || this.world.getBlockState(pos.up()).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS); - } + @Unique + protected boolean isOnSnowshoeSpeedBlock() { + BlockPos pos = this.getVelocityAffectingPos(); + return this.world.getBlockState(pos).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS) || this.world.getBlockState(pos.up()).isIn(AlaskaTags.SNOWSHOE_SPEED_BLOCKS); + } - /* - * We have to tick the medicinal effect before all the others because we modify the list of active effects - */ - @Inject(method = "tickStatusEffects", at = @At("HEAD")) - private void tickMedicinalEffect(CallbackInfo ci) { - if (this.activeStatusEffects.containsKey(AlaskaEffects.MEDICINAL)) { - var statusEffect = this.activeStatusEffects.get(AlaskaEffects.MEDICINAL); - var duration = statusEffect.getDuration(); - var amplifier = statusEffect.getAmplifier(); - if (duration % (80 >> amplifier) == 0) { - statusEffect.getEffectType().applyUpdateEffect((LivingEntity) (Object) this, amplifier); - } - } - } + /* + * We have to tick the medicinal effect before all the others because we modify the list of active effects + */ + @Inject(method = "tickStatusEffects", at = @At("HEAD")) + private void tickMedicinalEffect(CallbackInfo ci) { + if (this.activeStatusEffects.containsKey(AlaskaEffects.MEDICINAL)) { + var statusEffect = this.activeStatusEffects.get(AlaskaEffects.MEDICINAL); + var duration = statusEffect.getDuration(); + var amplifier = statusEffect.getAmplifier(); + if (duration % (80 >> amplifier) == 0) { + statusEffect.getEffectType().applyUpdateEffect((LivingEntity) (Object) this, amplifier); + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java index a401af14..37af8a36 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/MeleeAttackGoalAccessor.java @@ -1,11 +1,12 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.entity.ai.goal.MeleeAttackGoal; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import net.minecraft.entity.ai.goal.MeleeAttackGoal; + @Mixin(MeleeAttackGoal.class) public interface MeleeAttackGoalAccessor { - @Accessor("cooldown") - void setCooldown(int cooldown); + @Accessor("cooldown") + void setCooldown(int cooldown); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java index e0e8ddd8..78df4084 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PlayerEntityMixin.java @@ -1,6 +1,12 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; @@ -8,29 +14,23 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerEntity.class) public abstract class PlayerEntityMixin extends LivingEntity { + protected PlayerEntityMixin(EntityType entityType, World world) { + super(entityType, world); + throw new AssertionError("wut"); + } - protected PlayerEntityMixin(EntityType entityType, World world) { - super(entityType, world); - throw new AssertionError("wut"); - } - - @Override - @Shadow - public abstract ItemStack getEquippedStack(EquipmentSlot slot); + @Override + @Shadow + public abstract ItemStack getEquippedStack(EquipmentSlot slot); - @Inject(at = @At("HEAD"), method = "updateTurtleHelmet") - private void updateSnowGoggles(CallbackInfo ci) { - ItemStack stack = this.getEquippedStack(EquipmentSlot.HEAD); - if (stack.isOf(AlaskaItems.SNOW_GOGGLES)) { - this.removeStatusEffect(StatusEffects.BLINDNESS); - } - } + @Inject(at = @At("HEAD"), method = "updateTurtleHelmet") + private void updateSnowGoggles(CallbackInfo ci) { + ItemStack stack = this.getEquippedStack(EquipmentSlot.HEAD); + if (stack.isOf(AlaskaItems.SNOW_GOGGLES)) { + this.removeStatusEffect(StatusEffects.BLINDNESS); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java index 23104a5d..9c562785 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PolarBearMixin.java @@ -1,26 +1,26 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.entity.SealEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.entity.EntityType; import net.minecraft.entity.ai.goal.TargetGoal; import net.minecraft.entity.mob.Angerable; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.PolarBearEntity; import net.minecraft.world.World; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PolarBearEntity.class) public abstract class PolarBearMixin extends AnimalEntity implements Angerable { + protected PolarBearMixin(EntityType type, World world) { + super(type, world); + } - protected PolarBearMixin(EntityType type, World world) { - super(type, world); - } - - @Inject(at = @At("TAIL"), method = "initGoals()V") - private void addSealTarget(CallbackInfo ci) { - targetSelector.add(3, new TargetGoal<>(this, SealEntity.class, true)); - } + @Inject(at = @At("TAIL"), method = "initGoals()V") + private void addSealTarget(CallbackInfo ci) { + targetSelector.add(3, new TargetGoal<>(this, SealEntity.class, true)); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java index 4e7db9e9..6bff3ffc 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/PowderSnowBlockMixin.java @@ -1,25 +1,27 @@ package com.github.platymemo.alaskanativecraft.mixin; import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import net.minecraft.block.PowderSnowBlock; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.LivingEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.block.PowderSnowBlock; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; + @Mixin(PowderSnowBlock.class) public class PowderSnowBlockMixin { - @Inject(method = "canWalkOnPowderSnow", at = @At(value = "RETURN", ordinal = 1), cancellable = true) - private static void isWearingSnowshoesOrMukluks(Entity entity, CallbackInfoReturnable cir) { - if (entity instanceof LivingEntity livingEntity) { - var stack = livingEntity.getEquippedStack(EquipmentSlot.FEET); - cir.setReturnValue(stack.isOf(AlaskaItems.SNOWSHOES) || stack.isOf(AlaskaItems.MUKLUKS)); - return; - } - // Prevents leather boots from allowing snow walking - cir.setReturnValue(false); - } + @Inject(method = "canWalkOnPowderSnow", at = @At(value = "RETURN", ordinal = 1), cancellable = true) + private static void isWearingSnowshoesOrMukluks(Entity entity, CallbackInfoReturnable cir) { + if (entity instanceof LivingEntity livingEntity) { + var stack = livingEntity.getEquippedStack(EquipmentSlot.FEET); + cir.setReturnValue(stack.isOf(AlaskaItems.SNOWSHOES) || stack.isOf(AlaskaItems.MUKLUKS)); + return; + } + + // Prevents leather boots from allowing snow walking + cir.setReturnValue(false); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java index 2ebec7a8..a747a5d8 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/RepairItemRecipeMixin.java @@ -1,9 +1,7 @@ package com.github.platymemo.alaskanativecraft.mixin; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.recipe.RepairItemRecipe; +import java.util.List; + import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -13,29 +11,31 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import java.util.List; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.RepairItemRecipe; @Mixin(RepairItemRecipe.class) public abstract class RepairItemRecipeMixin { + @Unique + private ItemStack anc$cachedStack; - @Unique - private ItemStack anc$cachedStack; - - @Inject(method = "craft", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD) - private void cacheItemStack(CraftingInventory craftingInventory, CallbackInfoReturnable cir, @NotNull List list) { - this.anc$cachedStack = list.get(0); - } + @Inject(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;"), locals = LocalCapture.CAPTURE_FAILHARD) + private void cacheItemStack(CraftingInventory craftingInventory, CallbackInfoReturnable cir, @NotNull List list) { + this.anc$cachedStack = list.get(0); + } - @Redirect(method = "craft", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I")) - private int redirectGetMaxDamage(Item item) { - return this.anc$cachedStack.getMaxDamage(); - } + @Redirect(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;getMaxDamage()I")) + private int redirectGetMaxDamage(Item item) { + return this.anc$cachedStack.getMaxDamage(); + } - @SuppressWarnings("ConstantConditions") - @Inject(method = "craft", at = @At("RETURN")) - private void addDurabilityMultiplier(CraftingInventory craftingInventory, @NotNull CallbackInfoReturnable cir) { - if (!cir.getReturnValue().isEmpty() && anc$cachedStack.hasNbt() && anc$cachedStack.getNbt().contains("DurabilityMultiplier")) { - cir.getReturnValue().getOrCreateNbt().putFloat("DurabilityMultiplier", anc$cachedStack.getNbt().getFloat("DurabilityMultiplier")); - } - } + @SuppressWarnings("ConstantConditions") + @Inject(method = "craft(Lnet/minecraft/inventory/CraftingInventory;)Lnet/minecraft/item/ItemStack;", at = @At("RETURN")) + private void addDurabilityMultiplier(CraftingInventory craftingInventory, @NotNull CallbackInfoReturnable cir) { + if (!cir.getReturnValue().isEmpty() && this.anc$cachedStack.hasNbt() && this.anc$cachedStack.getNbt().contains("DurabilityMultiplier")) { + cir.getReturnValue().getOrCreateNbt().putFloat("DurabilityMultiplier", this.anc$cachedStack.getNbt().getFloat("DurabilityMultiplier")); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java index 7a9cf624..d3d30c5a 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/ShapedRecipeMixin.java @@ -1,10 +1,8 @@ package com.github.platymemo.alaskanativecraft.mixin; +import java.util.Set; + import com.github.platymemo.alaskanativecraft.item.AlaskaItems; -import net.minecraft.inventory.CraftingInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.recipe.ShapedRecipe; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -13,32 +11,36 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import java.util.Set; +import net.minecraft.inventory.CraftingInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.recipe.ShapedRecipe; @Mixin(ShapedRecipe.class) public class ShapedRecipeMixin { - @Shadow - @Final - ItemStack output; + @Shadow + @Final + ItemStack output; + + @Inject(at = @At("RETURN"), method = "craft*", cancellable = true) + private void addDurability(@NotNull CraftingInventory craftingInventory, CallbackInfoReturnable cir) { + if (craftingInventory.containsAny(Set.of(AlaskaItems.DRIFTWOOD_CHUNK, AlaskaItems.ANTLER, AlaskaItems.IVORY)) && this.output.getItem().isDamageable()) { + ItemStack protectedItem = this.output.copy(); + NbtCompound tag = protectedItem.getOrCreateNbt(); + float durabilityMultiplier = 1; + for (int i = 0; i < craftingInventory.size(); ++i) { + ItemStack stack = craftingInventory.getStack(i); + if (stack.isOf(AlaskaItems.DRIFTWOOD_CHUNK)) { + durabilityMultiplier *= 1.05; + } else if (stack.isOf(AlaskaItems.ANTLER)) { + durabilityMultiplier *= 1.2; + } else if (stack.isOf(AlaskaItems.IVORY)) { + durabilityMultiplier *= 1.4; + } + } - @Inject(at = @At("RETURN"), method = "craft*", cancellable = true) - private void addDurability(@NotNull CraftingInventory craftingInventory, CallbackInfoReturnable cir) { - if (craftingInventory.containsAny(Set.of(AlaskaItems.DRIFTWOOD_CHUNK, AlaskaItems.ANTLER, AlaskaItems.IVORY)) && this.output.getItem().isDamageable()) { - ItemStack protectedItem = this.output.copy(); - NbtCompound tag = protectedItem.getOrCreateNbt(); - float durabilityMultiplier = 1; - for (int i = 0; i < craftingInventory.size(); ++i) { - ItemStack stack = craftingInventory.getStack(i); - if (stack.isOf(AlaskaItems.DRIFTWOOD_CHUNK)) { - durabilityMultiplier *= 1.05; - } else if (stack.isOf(AlaskaItems.ANTLER)) { - durabilityMultiplier *= 1.2; - } else if (stack.isOf(AlaskaItems.IVORY)) { - durabilityMultiplier *= 1.4; - } - } - tag.putFloat("DurabilityMultiplier", durabilityMultiplier); - cir.setReturnValue(protectedItem); - } - } + tag.putFloat("DurabilityMultiplier", durabilityMultiplier); + cir.setReturnValue(protectedItem); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java index c081c998..b8ca6340 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/SnowballEntityMixin.java @@ -3,6 +3,11 @@ import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.entity.PtarmiganEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.ChickenEntity; @@ -13,43 +18,38 @@ import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.hit.EntityHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SnowballEntity.class) public class SnowballEntityMixin { - @Inject(at = @At("TAIL"), method = "onEntityHit") - private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInfo ci) { - if (AlaskaConfig.getConfig().snowballConversion) { - Entity entity = entityHitResult.getEntity(); - if ((entity instanceof ParrotEntity && !(entity instanceof PtarmiganEntity)) || entity instanceof ChickenEntity) { - - Identifier ptarmigan = new Identifier(AlaskaNativeCraft.MOD_ID, "ptarmigan"); - - Text entityName = null; - if (entity.hasCustomName()) { - entityName = entity.getCustomName(); - } - - NbtCompound entityTag = new NbtCompound(); - entityTag.putString("id", ptarmigan.toString()); - - if (entity.getWorld() instanceof ServerWorld world) { - Entity newEntity = EntityType.loadEntityWithPassengers(entityTag, world, (entityMaker) -> { - entityMaker.refreshPositionAndAngles(entity.getX(), entity.getY(), entity.getZ(), entityMaker.getYaw(), entityMaker.getPitch()); - return entityMaker; - }); - - if (newEntity != null) { - newEntity.setCustomName(entityName); - } - - world.spawnEntityAndPassengers(newEntity); - entity.discard(); - } - } - } - } + @Inject(at = @At("TAIL"), method = "onEntityHit") + private void makeThatBirbAPtarmigan(EntityHitResult entityHitResult, CallbackInfo ci) { + if (AlaskaConfig.getConfig().snowballConversion) { + Entity entity = entityHitResult.getEntity(); + if ((entity instanceof ParrotEntity && !(entity instanceof PtarmiganEntity)) || entity instanceof ChickenEntity) { + Identifier ptarmigan = new Identifier(AlaskaNativeCraft.MOD_ID, "ptarmigan"); + + Text entityName = null; + if (entity.hasCustomName()) { + entityName = entity.getCustomName(); + } + + NbtCompound entityTag = new NbtCompound(); + entityTag.putString("id", ptarmigan.toString()); + + if (entity.getWorld() instanceof ServerWorld world) { + Entity newEntity = EntityType.loadEntityWithPassengers(entityTag, world, (entityMaker) -> { + entityMaker.refreshPositionAndAngles(entity.getX(), entity.getY(), entity.getZ(), entityMaker.getYaw(), entityMaker.getPitch()); + return entityMaker; + }); + + if (newEntity != null) { + newEntity.setCustomName(entityName); + } + + world.spawnEntityAndPassengers(newEntity); + entity.discard(); + } + } + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java index ba3ec62a..9192d832 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientPlayerEntityMixin.java @@ -4,12 +4,6 @@ import com.mojang.authlib.GameProfile; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.input.Input; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.network.encryption.PlayerPublicKey; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -17,25 +11,31 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.client.input.Input; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.network.encryption.PlayerPublicKey; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + @Environment(EnvType.CLIENT) @Mixin(ClientPlayerEntity.class) public abstract class ClientPlayerEntityMixin extends PlayerEntity { - @Shadow - public Input input; - @Shadow - private boolean riding; - - ClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { - super(world, pos, yaw, gameProfile, publicKey); - throw new AssertionError("Mixin constructor called, something is very wrong!"); - } + @Shadow + public Input input; + @Shadow + private boolean riding; + ClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { + super(world, pos, yaw, gameProfile, publicKey); + throw new AssertionError("Mixin constructor called, something is very wrong!"); + } - @Inject(at = @At("TAIL"), method = "tickRiding()V") - private void rideDogsled(CallbackInfo ci) { - if (this.getVehicle() instanceof DogsledEntity dogsledEntity) { - dogsledEntity.setInputs(this.input.pressingLeft, this.input.pressingRight, this.input.pressingForward, this.input.pressingBack); - this.riding |= this.input.pressingLeft || this.input.pressingRight || this.input.pressingForward || this.input.pressingBack; - } - } + @Inject(at = @At("TAIL"), method = "tickRiding()V") + private void rideDogsled(CallbackInfo ci) { + if (this.getVehicle() instanceof DogsledEntity dogsledEntity) { + dogsledEntity.setInputs(this.input.pressingLeft, this.input.pressingRight, this.input.pressingForward, this.input.pressingBack); + this.riding |= this.input.pressingLeft || this.input.pressingRight || this.input.pressingForward || this.input.pressingBack; + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java index 39cc1ae0..c108c7a8 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ClientRecipeBookMixin.java @@ -3,22 +3,23 @@ import com.github.platymemo.alaskanativecraft.recipe.AlaskaRecipes; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.recipebook.ClientRecipeBook; -import net.minecraft.client.recipebook.RecipeBookGroup; -import net.minecraft.recipe.Recipe; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.client.recipebook.ClientRecipeBook; +import net.minecraft.client.recipebook.RecipeBookGroup; +import net.minecraft.recipe.Recipe; + @Environment(EnvType.CLIENT) @Mixin(ClientRecipeBook.class) public class ClientRecipeBookMixin { - @Inject(method = "getGroupForRecipe(Lnet/minecraft/recipe/Recipe;)Lnet/minecraft/client/recipebook/RecipeBookGroup;", at = @At("HEAD"), cancellable = true) - private static void removeDryingRecipe(@NotNull Recipe recipe, CallbackInfoReturnable cir) { - if (recipe.getType() == AlaskaRecipes.DRYING) { - cir.setReturnValue(RecipeBookGroup.UNKNOWN); - } - } + @Inject(method = "getGroupForRecipe(Lnet/minecraft/recipe/Recipe;)Lnet/minecraft/client/recipebook/RecipeBookGroup;", at = @At("HEAD"), cancellable = true) + private static void removeDryingRecipe(@NotNull Recipe recipe, CallbackInfoReturnable cir) { + if (recipe.getType() == AlaskaRecipes.DRYING) { + cir.setReturnValue(RecipeBookGroup.UNKNOWN); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java index fa035a0f..10c89d90 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/InGameHudMixin.java @@ -4,10 +4,6 @@ import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.hud.InGameHud; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -16,23 +12,28 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; + @Environment(EnvType.CLIENT) @Mixin(InGameHud.class) public abstract class InGameHudMixin { - private static final Identifier SNOWGOOGLES_BLUR = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/misc/gogglesblur.png"); + private static final Identifier SNOWGOOGLES_BLUR = new Identifier(AlaskaNativeCraft.MOD_ID, "textures/misc/gogglesblur.png"); - @Shadow - @Final - private MinecraftClient client; + @Shadow + @Final + private MinecraftClient client; - @Shadow - protected abstract void renderOverlay(Identifier texture, float opacity); + @Shadow + protected abstract void renderOverlay(Identifier texture, float opacity); - @SuppressWarnings("ConstantConditions") - @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1), method = "render") - private void renderSnowGogglesOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci) { - if (this.client.options.getPerspective().isFirstPerson() && this.client.player.getInventory().getArmorStack(3).getItem() == AlaskaItems.SNOW_GOGGLES) { - this.renderOverlay(SNOWGOOGLES_BLUR, 1.0F); - } - } + @SuppressWarnings("ConstantConditions") + @Inject(at = @At(value = "JUMP", opcode = Opcodes.IFEQ, ordinal = 1), method = "render") + private void renderSnowGogglesOverlay(MatrixStack matrices, float tickDelta, CallbackInfo ci) { + if (this.client.options.getPerspective().isFirstPerson() && this.client.player.getInventory().getArmorStack(3).getItem() == AlaskaItems.SNOW_GOGGLES) { + this.renderOverlay(SNOWGOOGLES_BLUR, 1.0F); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java index 575f3fef..20f91350 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/ItemRendererMixin.java @@ -6,6 +6,12 @@ import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.item.ItemRenderer; @@ -15,33 +21,26 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Environment(EnvType.CLIENT) @Mixin(ItemRenderer.class) public class ItemRendererMixin { + @Inject(at = @At("HEAD"), + method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", + cancellable = true) + public void renderHarpoons(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int k, CallbackInfo ci) { + BakedModel model = MinecraftClient.getInstance().getItemRenderer().getHeldItemModel(stack, world, entity, k); + if (stack.isIn(AlaskaTags.HARPOONS) && HarpoonItemRenderer.INSTANCE.render(entity, stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) { + ci.cancel(); + } + } - @Inject(at = @At("HEAD"), - method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", - cancellable = true) - public void renderHarpoons(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int k, CallbackInfo ci) { - BakedModel model = MinecraftClient.getInstance().getItemRenderer().getHeldItemModel(stack, world, entity, k); - if (stack.isIn(AlaskaTags.HARPOONS) && HarpoonItemRenderer.INSTANCE.render(entity, stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) { - ci.cancel(); - } - } - - @Inject(at = @At("HEAD"), - method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", - cancellable = true) - public void renderSnowshoes(@NotNull ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { - if (stack.isOf(AlaskaItems.SNOWSHOES) && SnowshoeItemRenderer.INSTANCE.render(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) { - ci.cancel(); - } - } - -} \ No newline at end of file + @Inject(at = @At("HEAD"), + method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V", + cancellable = true) + public void renderSnowshoes(@NotNull ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { + if (stack.isOf(AlaskaItems.SNOWSHOES) && SnowshoeItemRenderer.INSTANCE.render(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model)) { + ci.cancel(); + } + } +} diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java index 99cb7e1d..2098f4d2 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/LivingEntityRendererMixin.java @@ -3,6 +3,11 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRendererFactory; @@ -13,40 +18,37 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.WolfEntity; import net.minecraft.util.math.MathHelper; -import org.objectweb.asm.Opcodes; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; @Environment(EnvType.CLIENT) @Mixin(LivingEntityRenderer.class) public abstract class LivingEntityRendererMixin> extends EntityRenderer implements FeatureRendererContext { + protected LivingEntityRendererMixin(EntityRendererFactory.Context context) { + super(context); + } + + @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), + method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + ordinal = 7) + private float changeLimbDistance(float limbDistance, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { + if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) { + limbDistance = MathHelper.lerp(g, livingEntity.lastLimbDistance, livingEntity.limbDistance); + + if (limbDistance > 1.0F) { + limbDistance = 1.0F; + } + } + + return limbDistance; + } + + @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), + method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", + ordinal = 8) + private float changeLimbAngle(float limbAngle, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { + if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) { + limbAngle = livingEntity.limbAngle - livingEntity.limbDistance * (1.0F - g); + } - protected LivingEntityRendererMixin(EntityRendererFactory.Context context) { - super(context); - } - - @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), - method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", - ordinal = 7) - private float changeLimbDistance(float limbDistance, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { - if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) { - limbDistance = MathHelper.lerp(g, livingEntity.lastLimbDistance, livingEntity.limbDistance); - - if (limbDistance > 1.0F) { - limbDistance = 1.0F; - } - } - return limbDistance; - } - - @ModifyVariable(at = @At(value = "JUMP", opcode = Opcodes.IFNE, ordinal = 0), - method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", - ordinal = 8) - private float changeLimbAngle(float limbAngle, T livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { - if (livingEntity instanceof WolfEntity && livingEntity.hasVehicle() && livingEntity.getVehicle() instanceof DogsledEntity) { - limbAngle = livingEntity.limbAngle - livingEntity.limbDistance * (1.0F - g); - } - return limbAngle; - } + return limbAngle; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java index b8fc6c17..66f7d7f6 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/mixin/client/MinecraftClientMixin.java @@ -3,6 +3,12 @@ import com.github.platymemo.alaskanativecraft.entity.DogsledEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerInteractionManager; @@ -12,47 +18,42 @@ import net.minecraft.util.Hand; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Environment(EnvType.CLIENT) @Mixin(MinecraftClient.class) public class MinecraftClientMixin { - - @Shadow - public HitResult crosshairTarget; - - @Shadow - public ClientPlayerEntity player; - - @Shadow - public ClientPlayerInteractionManager interactionManager; - - @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/hit/EntityHitResult;getEntity()Lnet/minecraft/entity/Entity;", ordinal = 0), - method = "doItemPick", - cancellable = true) - private void pickDogsledItem(CallbackInfo ci) { - Entity entity = ((EntityHitResult) this.crosshairTarget).getEntity(); - - if (entity instanceof DogsledEntity) { - ItemStack pickedDogsled = new ItemStack(((DogsledEntity) entity).asItem()); - PlayerInventory playerInventory = this.player.getInventory(); - - int i = playerInventory.getSlotWithStack(pickedDogsled); - if (this.player.getAbilities().creativeMode) { - playerInventory.addPickBlock(pickedDogsled); - this.interactionManager.clickCreativeStack(this.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot); - } else if (i != -1) { - if (PlayerInventory.isValidHotbarIndex(i)) { - playerInventory.selectedSlot = i; - } else { - this.interactionManager.pickFromInventory(i); - } - } - ci.cancel(); - } - } + @Shadow + public HitResult crosshairTarget; + + @Shadow + public ClientPlayerEntity player; + + @Shadow + public ClientPlayerInteractionManager interactionManager; + + @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/util/hit/EntityHitResult;getEntity()Lnet/minecraft/entity/Entity;", ordinal = 0), + method = "doItemPick", + cancellable = true) + private void pickDogsledItem(CallbackInfo ci) { + Entity entity = ((EntityHitResult) this.crosshairTarget).getEntity(); + + if (entity instanceof DogsledEntity) { + ItemStack pickedDogsled = new ItemStack(((DogsledEntity) entity).asItem()); + PlayerInventory playerInventory = this.player.getInventory(); + + int i = playerInventory.getSlotWithStack(pickedDogsled); + if (this.player.getAbilities().creativeMode) { + playerInventory.addPickBlock(pickedDogsled); + this.interactionManager.clickCreativeStack(this.player.getStackInHand(Hand.MAIN_HAND), 36 + playerInventory.selectedSlot); + } else if (i != -1) { + if (PlayerInventory.isValidHotbarIndex(i)) { + playerInventory.selectedSlot = i; + } else { + this.interactionManager.pickFromInventory(i); + } + } + + ci.cancel(); + } + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java index c933344b..6fb4dbab 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AkutaqRecipe.java @@ -1,8 +1,12 @@ package com.github.platymemo.alaskanativecraft.recipe; +import java.util.Random; + import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; import com.google.common.collect.ImmutableList; +import org.jetbrains.annotations.NotNull; + import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.inventory.CraftingInventory; @@ -15,118 +19,115 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Pair; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; - -import java.util.Random; public class AkutaqRecipe extends SpecialCraftingRecipe { - private static final ImmutableList> POSSIBLE_EFFECTS = ImmutableList.of( - new Pair<>(StatusEffects.ABSORPTION, 20), - new Pair<>(StatusEffects.REGENERATION, 10), - new Pair<>(StatusEffects.RESISTANCE, 10), - new Pair<>(StatusEffects.FIRE_RESISTANCE, 10), - new Pair<>(StatusEffects.HASTE, 10), - new Pair<>(StatusEffects.STRENGTH, 5), - new Pair<>(StatusEffects.SPEED, 12), - new Pair<>(StatusEffects.JUMP_BOOST, 10), - new Pair<>(StatusEffects.SATURATION, 10) - ); - - public AkutaqRecipe(Identifier id) { - super(id); - } - - // Can't use SuspiciousStewItem.addEffectToStew because it overwrites the list tag each time - public static void addEffectToAkutaq(@NotNull ItemStack stew, StatusEffect effect, int duration) { - NbtCompound compoundTag = stew.getOrCreateNbt(); - NbtList listTag = compoundTag.getList("Effects", 10); - - boolean effectExists = false; - - byte effectId = (byte) StatusEffect.getRawId(effect); - int actualDuration = duration; - for (int i = 0; i < listTag.size(); ++i) { - NbtCompound previousEffect = listTag.getCompound(i); - if (previousEffect.contains("EffectDuration", 3) && effectId == previousEffect.getByte("EffectId")) { - actualDuration += previousEffect.getInt("EffectDuration"); - previousEffect.putInt("EffectDuration", actualDuration); - effectExists = true; - } - } - - if (!effectExists) { - NbtCompound newEffect = new NbtCompound(); - newEffect.putByte("EffectId", effectId); - newEffect.putInt("EffectDuration", actualDuration); - listTag.add(newEffect); - } - - compoundTag.put("Effects", listTag); - } - - @Override - public boolean matches(@NotNull CraftingInventory inv, World world) { - boolean hasMeat = false; - boolean hasBerries = false; - boolean hasBowl = false; - - for (int i = 0; i < inv.size(); ++i) { - ItemStack itemStack = inv.getStack(i); - if (!itemStack.isEmpty()) { - - // Need at least 1 berry but can have more - if (itemStack.isIn(AlaskaTags.AKUTAQ_BERRIES)) { - hasBerries = true; - } - // Can only have one piece of meat - else if (itemStack.isIn(AlaskaTags.AKUTAQ_MEATS) && !hasMeat) { - hasMeat = true; - } else { - - // Checks for bowl, if not a bowl or anything but a bowl, returns false - if (itemStack.getItem() != Items.BOWL || hasBowl) { - return false; - } - - hasBowl = true; - } - } - } - - return hasMeat && hasBerries && hasBowl; - } - - @Override - public ItemStack craft(@NotNull CraftingInventory inv) { - ItemStack akutaq = new ItemStack(AlaskaItems.AKUTAQ, 1); - Random random = new Random(); - - ItemStack currentItemstack; - for (int i = 0; i < inv.size(); ++i) { - currentItemstack = inv.getStack(i); - if (!currentItemstack.isEmpty() && currentItemstack.isIn(AlaskaTags.AKUTAQ_BERRIES)) { - Pair pair = POSSIBLE_EFFECTS.get(random.nextInt(POSSIBLE_EFFECTS.size())); - StatusEffect statusEffect = pair.getLeft(); - int duration = pair.getRight(); - if (!statusEffect.isInstant()) { - duration *= 20; - } - - // Add effect - addEffectToAkutaq(akutaq, statusEffect, duration); - } - } - - return akutaq; - } - - @Override - public boolean fits(int width, int height) { - return width >= 2 && height >= 2; - } - - @Override - public RecipeSerializer getSerializer() { - return AlaskaRecipes.AKUTAQ; - } + private static final ImmutableList> POSSIBLE_EFFECTS = ImmutableList.of( + new Pair<>(StatusEffects.ABSORPTION, 20), + new Pair<>(StatusEffects.REGENERATION, 10), + new Pair<>(StatusEffects.RESISTANCE, 10), + new Pair<>(StatusEffects.FIRE_RESISTANCE, 10), + new Pair<>(StatusEffects.HASTE, 10), + new Pair<>(StatusEffects.STRENGTH, 5), + new Pair<>(StatusEffects.SPEED, 12), + new Pair<>(StatusEffects.JUMP_BOOST, 10), + new Pair<>(StatusEffects.SATURATION, 10) + ); + + public AkutaqRecipe(Identifier id) { + super(id); + } + + // Can't use SuspiciousStewItem.addEffectToStew because it overwrites the list tag each time + public static void addEffectToAkutaq(@NotNull ItemStack stew, StatusEffect effect, int duration) { + NbtCompound compoundTag = stew.getOrCreateNbt(); + NbtList listTag = compoundTag.getList("Effects", 10); + + boolean effectExists = false; + + byte effectId = (byte) StatusEffect.getRawId(effect); + int actualDuration = duration; + for (int i = 0; i < listTag.size(); ++i) { + NbtCompound previousEffect = listTag.getCompound(i); + if (previousEffect.contains("EffectDuration", 3) && effectId == previousEffect.getByte("EffectId")) { + actualDuration += previousEffect.getInt("EffectDuration"); + previousEffect.putInt("EffectDuration", actualDuration); + effectExists = true; + } + } + + if (!effectExists) { + NbtCompound newEffect = new NbtCompound(); + newEffect.putByte("EffectId", effectId); + newEffect.putInt("EffectDuration", actualDuration); + listTag.add(newEffect); + } + + compoundTag.put("Effects", listTag); + } + + @Override + public boolean matches(@NotNull CraftingInventory inv, World world) { + boolean hasMeat = false; + boolean hasBerries = false; + boolean hasBowl = false; + + for (int i = 0; i < inv.size(); ++i) { + ItemStack itemStack = inv.getStack(i); + if (!itemStack.isEmpty()) { + if (itemStack.isIn(AlaskaTags.AKUTAQ_BERRIES)) { // Need at least 1 berry but can have more + hasBerries = true; + } else if (itemStack.isIn(AlaskaTags.AKUTAQ_MEATS)) { + // Can only have one piece of meat + if (hasMeat) { + return false; + } + + hasMeat = true; + } else { + // Checks for bowl, if not a bowl, or we've already found a bowl, returns false + if (itemStack.getItem() != Items.BOWL || hasBowl) { + return false; + } + + hasBowl = true; + } + } + } + + return hasMeat && hasBerries && hasBowl; + } + + @Override + public ItemStack craft(@NotNull CraftingInventory inv) { + ItemStack akutaq = new ItemStack(AlaskaItems.AKUTAQ, 1); + Random random = new Random(); + + ItemStack currentItemstack; + for (int i = 0; i < inv.size(); ++i) { + currentItemstack = inv.getStack(i); + if (!currentItemstack.isEmpty() && currentItemstack.isIn(AlaskaTags.AKUTAQ_BERRIES)) { + Pair pair = POSSIBLE_EFFECTS.get(random.nextInt(POSSIBLE_EFFECTS.size())); + StatusEffect statusEffect = pair.getLeft(); + int duration = pair.getRight(); + if (!statusEffect.isInstant()) { + duration *= 20; + } + + // Add effect + addEffectToAkutaq(akutaq, statusEffect, duration); + } + } + + return akutaq; + } + + @Override + public boolean fits(int width, int height) { + return width >= 2 && height >= 2; + } + + @Override + public RecipeSerializer getSerializer() { + return AlaskaRecipes.AKUTAQ; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java index a5f9d39e..b253b355 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/AlaskaRecipes.java @@ -1,6 +1,7 @@ package com.github.platymemo.alaskanativecraft.recipe; import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; + import net.minecraft.recipe.CookingRecipeSerializer; import net.minecraft.recipe.RecipeType; import net.minecraft.recipe.SpecialRecipeSerializer; @@ -8,17 +9,16 @@ import net.minecraft.util.registry.Registry; public class AlaskaRecipes { - public static final SpecialRecipeSerializer AKUTAQ = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_akutaq"), new SpecialRecipeSerializer<>(AkutaqRecipe::new)); - public static final SpecialRecipeSerializer FISH_STRIP = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_fish_strip"), new SpecialRecipeSerializer<>(FishStripRecipe::new)); - - public static final RecipeType DRYING = Registry.register(Registry.RECIPE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new RecipeType() { - public String toString() { - return "drying"; - } - }); - public static final CookingRecipeSerializer DRYING_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new CookingRecipeSerializer<>(DryingRecipe::new, 1200)); + public static final SpecialRecipeSerializer AKUTAQ = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_akutaq"), new SpecialRecipeSerializer<>(AkutaqRecipe::new)); + public static final SpecialRecipeSerializer FISH_STRIP = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "crafting_special_fish_strip"), new SpecialRecipeSerializer<>(FishStripRecipe::new)); - public static void register() { + public static final RecipeType DRYING = Registry.register(Registry.RECIPE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new RecipeType() { + public String toString() { + return "drying"; + } + }); + public static final CookingRecipeSerializer DRYING_SERIALIZER = Registry.register(Registry.RECIPE_SERIALIZER, new Identifier(AlaskaNativeCraft.MOD_ID, "drying"), new CookingRecipeSerializer<>(DryingRecipe::new, 1200)); - } + public static void register() { + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java index 10f8488e..63c9589d 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/DryingRecipe.java @@ -3,6 +3,7 @@ import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; + import net.minecraft.item.ItemStack; import net.minecraft.recipe.AbstractCookingRecipe; import net.minecraft.recipe.Ingredient; @@ -10,18 +11,18 @@ import net.minecraft.util.Identifier; public class DryingRecipe extends AbstractCookingRecipe { - public DryingRecipe(Identifier id, String group, Ingredient input, ItemStack output, float experience, int cookTime) { - super(AlaskaRecipes.DRYING, id, group, input, output, experience, cookTime); - } + public DryingRecipe(Identifier id, String group, Ingredient input, ItemStack output, float experience, int cookTime) { + super(AlaskaRecipes.DRYING, id, group, input, output, experience, cookTime); + } - @Override - @Environment(EnvType.CLIENT) - public ItemStack createIcon() { - return new ItemStack(AlaskaBlocks.DRYING_RACK); - } + @Override + @Environment(EnvType.CLIENT) + public ItemStack createIcon() { + return new ItemStack(AlaskaBlocks.DRYING_RACK); + } - @Override - public RecipeSerializer getSerializer() { - return AlaskaRecipes.DRYING_SERIALIZER; - } + @Override + public RecipeSerializer getSerializer() { + return AlaskaRecipes.DRYING_SERIALIZER; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java index c364c25c..b77a4177 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/recipe/FishStripRecipe.java @@ -2,6 +2,8 @@ import com.github.platymemo.alaskanativecraft.item.AlaskaItems; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; +import org.jetbrains.annotations.NotNull; + import net.minecraft.inventory.CraftingInventory; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeSerializer; @@ -10,75 +12,70 @@ import net.minecraft.util.collection.DefaultedList; import net.minecraft.util.random.RandomGenerator; import net.minecraft.world.World; -import org.jetbrains.annotations.NotNull; public class FishStripRecipe extends SpecialCraftingRecipe { + public FishStripRecipe(Identifier id) { + super(id); + } - public FishStripRecipe(Identifier id) { - super(id); - } - - @Override - public boolean matches(@NotNull CraftingInventory inv, World world) { - boolean hasUlu = false; - boolean hasFish = false; + @Override + public boolean matches(@NotNull CraftingInventory inv, World world) { + boolean hasUlu = false; + boolean hasFish = false; - for (int i = 0; i < inv.size(); ++i) { - ItemStack itemStack = inv.getStack(i); - if (!itemStack.isEmpty()) { + for (int i = 0; i < inv.size(); ++i) { + ItemStack itemStack = inv.getStack(i); + if (!itemStack.isEmpty()) { + if (itemStack.isIn(AlaskaTags.SLICEABLE_FISH)) { // Need at least 1 fish but can have more + hasFish = true; + } else if (itemStack.isIn(AlaskaTags.ULUS) && !hasUlu) { // Can only have one ulu + hasUlu = true; + } else { + return false; + } + } + } - // Need at least 1 fish but can have more - if (itemStack.isIn(AlaskaTags.SLICEABLE_FISH)) { - hasFish = true; - } - // Can only have one ulu - else if (itemStack.isIn(AlaskaTags.ULUS) && !hasUlu) { - hasUlu = true; - } else { - return false; - } - } - } + return hasUlu && hasFish; + } - return hasUlu && hasFish; - } + @Override + public ItemStack craft(@NotNull CraftingInventory inv) { + int numOfFish = 0; + ItemStack stack; + for (int i = 0; i < inv.size(); ++i) { + stack = inv.getStack(i); + if (stack.isIn(AlaskaTags.SLICEABLE_FISH)) { + numOfFish++; + } + } - @Override - public ItemStack craft(@NotNull CraftingInventory inv) { - int numOfFish = 0; - ItemStack stack; - for (int i = 0; i < inv.size(); ++i) { - stack = inv.getStack(i); - if (stack.isIn(AlaskaTags.SLICEABLE_FISH)) { - numOfFish++; - } - } - return new ItemStack(AlaskaItems.FISH_STRIP, numOfFish * 3); - } + return new ItemStack(AlaskaItems.FISH_STRIP, numOfFish * 3); + } - @Override - public DefaultedList getRemainder(@NotNull CraftingInventory inventory) { - DefaultedList defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY); + @Override + public DefaultedList getRemainder(@NotNull CraftingInventory inventory) { + DefaultedList defaultedList = DefaultedList.ofSize(inventory.size(), ItemStack.EMPTY); - for (int i = 0; i < defaultedList.size(); ++i) { - ItemStack stack = inventory.getStack(i); - if (stack.isIn(AlaskaTags.ULUS)) { - if (!stack.damage(5, RandomGenerator.createLegacy(), null)) { - defaultedList.set(i, stack.copy()); - } - } - } + for (int i = 0; i < defaultedList.size(); ++i) { + ItemStack stack = inventory.getStack(i); + if (stack.isIn(AlaskaTags.ULUS)) { + if (!stack.damage(5, RandomGenerator.createLegacy(), null)) { + defaultedList.set(i, stack.copy()); + } + } + } - return defaultedList; - } + return defaultedList; + } - @Override - public boolean fits(int width, int height) { - return width * height >= 2; - } + @Override + public boolean fits(int width, int height) { + return width * height >= 2; + } - @Override - public RecipeSerializer getSerializer() { - return AlaskaRecipes.FISH_STRIP; - } + @Override + public RecipeSerializer getSerializer() { + return AlaskaRecipes.FISH_STRIP; + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java b/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java index ac1fc42f..687a115b 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/sound/AlaskaSoundEvents.java @@ -1,29 +1,30 @@ package com.github.platymemo.alaskanativecraft.sound; import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; + import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class AlaskaSoundEvents { - public static final SoundEvent ENTITY_SEAL_AMBIENT; - public static final SoundEvent ENTITY_SEAL_AMBIENT_BABY; - public static final SoundEvent ENTITY_SEAL_HURT; - public static final SoundEvent ENTITY_MOOSE_AMBIENT; - public static final SoundEvent ENTITY_MOOSE_HURT; + public static final SoundEvent ENTITY_SEAL_AMBIENT; + public static final SoundEvent ENTITY_SEAL_AMBIENT_BABY; + public static final SoundEvent ENTITY_SEAL_HURT; + public static final SoundEvent ENTITY_MOOSE_AMBIENT; + public static final SoundEvent ENTITY_MOOSE_HURT; - static { - ENTITY_SEAL_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient")); - ENTITY_SEAL_AMBIENT_BABY = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient.baby")); - ENTITY_SEAL_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.hurt")); - ENTITY_MOOSE_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.ambient")); - ENTITY_MOOSE_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.hurt")); - } + static { + ENTITY_SEAL_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient")); + ENTITY_SEAL_AMBIENT_BABY = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.ambient.baby")); + ENTITY_SEAL_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.seal.hurt")); + ENTITY_MOOSE_AMBIENT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.ambient")); + ENTITY_MOOSE_HURT = register(new Identifier(AlaskaNativeCraft.MOD_ID, "entity.moose.hurt")); + } - private static SoundEvent register(Identifier id) { - return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id)); - } + private static SoundEvent register(Identifier id) { + return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id)); + } - public static void register() { - } + public static void register() { + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java b/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java index 4b3820a1..6d7ea542 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/tags/AlaskaTags.java @@ -2,6 +2,7 @@ import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.tags.common.CommonBlockTags; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.tag.TagKey; @@ -10,27 +11,27 @@ import net.minecraft.world.biome.Biome; public class AlaskaTags { - public static final TagKey ULUS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "ulus")); - public static final TagKey KUSPUKS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "kuspuks")); - public static final TagKey HARPOONS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "harpoons")); - public static final TagKey AKUTAQ_MEATS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "akutaq_meats")); - public static final TagKey AKUTAQ_BERRIES = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "akutaq_berries")); - public static final TagKey SLICEABLE_FISH = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "sliceable_fish")); - public static final TagKey SEAL_FOOD = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "seal_food")); + public static final TagKey ULUS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "ulus")); + public static final TagKey KUSPUKS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "kuspuks")); + public static final TagKey HARPOONS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "harpoons")); + public static final TagKey AKUTAQ_MEATS = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "akutaq_meats")); + public static final TagKey AKUTAQ_BERRIES = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "akutaq_berries")); + public static final TagKey SLICEABLE_FISH = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "sliceable_fish")); + public static final TagKey SEAL_FOOD = TagKey.of(Registry.ITEM_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "seal_food")); - public static final TagKey SNOWSHOE_SPEED_BLOCKS = TagKey.of(Registry.BLOCK_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "snowshoe_speed_blocks")); - public static final TagKey ULU_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "mineable/ulu")); + public static final TagKey SNOWSHOE_SPEED_BLOCKS = TagKey.of(Registry.BLOCK_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "snowshoe_speed_blocks")); + public static final TagKey ULU_MINEABLE = TagKey.of(Registry.BLOCK_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "mineable/ulu")); - public static final TagKey STICKS = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "sticks")); + public static final TagKey STICKS = TagKey.of(Registry.ITEM_KEY, new Identifier("c", "sticks")); - public static final TagKey HAS_DRIFTWOOD = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/driftwood")); - public static final TagKey HAS_BUSHES = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/berry_bushes")); - public static final TagKey HAS_LABRADOR_TEA = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/labrador_tea")); - public static final TagKey HAS_SEAL = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/seal")); - public static final TagKey HAS_MOOSE = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/moose")); - public static final TagKey HAS_PTARMIGAN = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/ptarmigan")); + public static final TagKey HAS_DRIFTWOOD = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/driftwood")); + public static final TagKey HAS_BUSHES = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/berry_bushes")); + public static final TagKey HAS_LABRADOR_TEA = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_feature/labrador_tea")); + public static final TagKey HAS_SEAL = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/seal")); + public static final TagKey HAS_MOOSE = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/moose")); + public static final TagKey HAS_PTARMIGAN = TagKey.of(Registry.BIOME_KEY, new Identifier(AlaskaNativeCraft.MOD_ID, "has_mob/ptarmigan")); - public static void register() { - CommonBlockTags.register(); - } + public static void register() { + CommonBlockTags.register(); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/tags/common/CommonBlockTags.java b/src/main/java/com/github/platymemo/alaskanativecraft/tags/common/CommonBlockTags.java index 6c59684e..a5e180cb 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/tags/common/CommonBlockTags.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/tags/common/CommonBlockTags.java @@ -6,8 +6,8 @@ import net.minecraft.util.registry.Registry; public class CommonBlockTags { - public static final TagKey LOGS_WITH_BARK = TagKey.of(Registry.BLOCK_KEY, new Identifier("c", "logs_with_bark")); + public static final TagKey LOGS_WITH_BARK = TagKey.of(Registry.BLOCK_KEY, new Identifier("c", "logs_with_bark")); - public static void register() { - } + public static void register() { + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java index 555782d2..6a295371 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/feature/AlaskaFeatures.java @@ -1,127 +1,129 @@ package com.github.platymemo.alaskanativecraft.worldgen.feature; +import java.util.List; +import java.util.function.Predicate; + import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; import com.github.platymemo.alaskanativecraft.block.AlaskaBlocks; import com.github.platymemo.alaskanativecraft.config.AlaskaConfig; import com.github.platymemo.alaskanativecraft.tags.AlaskaTags; -import dev.architectury.event.events.common.BlockEvent; -import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; -import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; +import org.jetbrains.annotations.NotNull; + import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.SweetBerryBushBlock; import net.minecraft.util.Holder; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.decorator.BiomePlacementModifier; import net.minecraft.world.gen.decorator.InSquarePlacementModifier; import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier; -import net.minecraft.world.gen.feature.*; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.world.gen.feature.RandomPatchFeatureConfig; +import net.minecraft.world.gen.feature.SimpleBlockFeatureConfig; import net.minecraft.world.gen.feature.util.ConfiguredFeatureUtil; import net.minecraft.world.gen.feature.util.PlacedFeatureUtil; import net.minecraft.world.gen.stateprovider.BlockStateProvider; -import org.jetbrains.annotations.NotNull; -import java.util.List; -import java.util.function.Predicate; +import org.quiltmc.qsl.worldgen.biome.api.BiomeModifications; +import org.quiltmc.qsl.worldgen.biome.api.BiomeSelectionContext; +import org.quiltmc.qsl.worldgen.biome.api.BiomeSelectors; public class AlaskaFeatures { - private static final int DECORATED_MULTIPLIER = 12; - private static final int BERRY_RARITY = 64; - - public static void register() { - AlaskaConfig.GenerationOptions genOptions = AlaskaConfig.getConfig().generation; - - if (genOptions.genBlueberry) { - registerBerryPatch(AlaskaBlocks.BLUEBERRY_BUSH, "blueberry_bush"); - } - - if (genOptions.genCloudberry) { - registerBerryPatch(AlaskaBlocks.CLOUDBERRY_BUSH, "cloudberry_bush"); - } - - if (genOptions.genRaspberry) { - registerBerryPatch(AlaskaBlocks.RASPBERRY_BUSH, "raspberry_bush"); - } - - if (genOptions.genSalmonberry) { - registerBerryPatch(AlaskaBlocks.SALMONBERRY_BUSH, "salmonberry_bush"); - } - - if (genOptions.genLabradorTea) { - registerPatch(AlaskaBlocks.LABRADOR_TEA.getDefaultState(), "labrador_tea_patch", 64, BiomeSelectors.tag(AlaskaTags.HAS_LABRADOR_TEA)); - } - - if (genOptions.genDriftwood) { - registerPatch(AlaskaBlocks.DRIFTWOOD_LOG.getDefaultState(), "washed_up_driftwood", BERRY_RARITY / 2, BiomeSelectors.tag(AlaskaTags.HAS_DRIFTWOOD), Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.CLAY, Blocks.SAND, Blocks.RED_SAND); - } - } - - private static void registerBerryPatch(@NotNull Block berryBush, String bushName) { - registerPatch( - berryBush.getDefaultState().with(SweetBerryBushBlock.AGE, 3), - bushName, - BERRY_RARITY, - BiomeSelectors.tag(AlaskaTags.HAS_BUSHES), - Blocks.GRASS_BLOCK - ); - } - - private static void registerPatch(BlockState blockState, String featureName, int rarity, Predicate selector, Block... whitelist) { - // Sparse feature - RegistryKey sparsePatchKey = RegistryKey.of( - Registry.PLACED_FEATURE_KEY, - new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_sparse") - ); - - - Holder> patchFeature = ConfiguredFeatureUtil.register( - sparsePatchKey.getValue().toString(), - Feature.RANDOM_PATCH, - ConfiguredFeatureUtil.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(blockState)), List.of(whitelist))); - - //create and register placed feature - PlacedFeatureUtil.register( - sparsePatchKey.getValue().toString(), - patchFeature, - RarityFilterPlacementModifier.create(rarity), - InSquarePlacementModifier.getInstance(), - PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.getInstance() - ); - BiomeModifications.addFeature( - selector, - GenerationStep.Feature.VEGETAL_DECORATION, - sparsePatchKey - ); - - // Decorated (extra sparse) patches - RegistryKey decoratedPatchRegistryKey = RegistryKey.of( - Registry.PLACED_FEATURE_KEY, - new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_decorated") - ); - - PlacedFeatureUtil.register( - decoratedPatchRegistryKey.getValue().toString(), - patchFeature, - List.of( - RarityFilterPlacementModifier.create(rarity * DECORATED_MULTIPLIER), - InSquarePlacementModifier.getInstance(), - PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.getInstance() - ) - ); - - BiomeModifications.addFeature( - selector, - GenerationStep.Feature.VEGETAL_DECORATION, - decoratedPatchRegistryKey - ); - } + private static final int DECORATED_MULTIPLIER = 12; + private static final int BERRY_RARITY = 64; + + public static void register() { + AlaskaConfig.GenerationOptions genOptions = AlaskaConfig.getConfig().generation; + + if (genOptions.genBlueberry) { + registerBerryPatch(AlaskaBlocks.BLUEBERRY_BUSH, "blueberry_bush"); + } + + if (genOptions.genCloudberry) { + registerBerryPatch(AlaskaBlocks.CLOUDBERRY_BUSH, "cloudberry_bush"); + } + + if (genOptions.genRaspberry) { + registerBerryPatch(AlaskaBlocks.RASPBERRY_BUSH, "raspberry_bush"); + } + + if (genOptions.genSalmonberry) { + registerBerryPatch(AlaskaBlocks.SALMONBERRY_BUSH, "salmonberry_bush"); + } + + if (genOptions.genLabradorTea) { + registerPatch(AlaskaBlocks.LABRADOR_TEA.getDefaultState(), "labrador_tea_patch", 64, BiomeSelectors.isIn(AlaskaTags.HAS_LABRADOR_TEA)); + } + + if (genOptions.genDriftwood) { + registerPatch(AlaskaBlocks.DRIFTWOOD_LOG.getDefaultState(), "washed_up_driftwood", BERRY_RARITY / 2, BiomeSelectors.isIn(AlaskaTags.HAS_DRIFTWOOD), Blocks.GRASS_BLOCK, Blocks.GRAVEL, Blocks.CLAY, Blocks.SAND, Blocks.RED_SAND); + } + } + + private static void registerBerryPatch(@NotNull Block berryBush, String bushName) { + registerPatch( + berryBush.getDefaultState().with(SweetBerryBushBlock.AGE, 3), + bushName, + BERRY_RARITY, + BiomeSelectors.isIn(AlaskaTags.HAS_BUSHES), + Blocks.GRASS_BLOCK + ); + } + + private static void registerPatch(BlockState blockState, String featureName, int rarity, Predicate selector, Block... whitelist) { + // Sparse feature + RegistryKey sparsePatchKey = RegistryKey.of( + Registry.PLACED_FEATURE_KEY, + new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_sparse") + ); + + Holder> patchFeature = ConfiguredFeatureUtil.register( + sparsePatchKey.getValue().toString(), + Feature.RANDOM_PATCH, + ConfiguredFeatureUtil.createRandomPatchFeatureConfig(Feature.SIMPLE_BLOCK, new SimpleBlockFeatureConfig(BlockStateProvider.of(blockState)), List.of(whitelist))); + + //create and register placed feature + PlacedFeatureUtil.register( + sparsePatchKey.getValue().toString(), + patchFeature, + RarityFilterPlacementModifier.create(rarity), + InSquarePlacementModifier.getInstance(), + PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.getInstance() + ); + BiomeModifications.addFeature( + selector, + GenerationStep.Feature.VEGETAL_DECORATION, + sparsePatchKey + ); + + // Decorated (extra sparse) patches + RegistryKey decoratedPatchRegistryKey = RegistryKey.of( + Registry.PLACED_FEATURE_KEY, + new Identifier(AlaskaNativeCraft.MOD_ID, "patch_" + featureName + "_decorated") + ); + + PlacedFeatureUtil.register( + decoratedPatchRegistryKey.getValue().toString(), + patchFeature, + List.of( + RarityFilterPlacementModifier.create(rarity * DECORATED_MULTIPLIER), + InSquarePlacementModifier.getInstance(), + PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, + BiomePlacementModifier.getInstance() + ) + ); + + BiomeModifications.addFeature( + selector, + GenerationStep.Feature.VEGETAL_DECORATION, + decoratedPatchRegistryKey + ); + } } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java index a7f62a6f..3c8e5033 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/AlaskaStructures.java @@ -1,10 +1,11 @@ package com.github.platymemo.alaskanativecraft.worldgen.structure; import com.github.platymemo.alaskanativecraft.AlaskaNativeCraft; + import net.minecraft.structure.StructureType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; public class AlaskaStructures { - public static StructureType FISH_CAMP = Registry.register(Registry.STRUCTURE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "fish_camp"), () -> FishCampStructure.CODEC); + public static StructureType FISH_CAMP = Registry.register(Registry.STRUCTURE_TYPE, new Identifier(AlaskaNativeCraft.MOD_ID, "fish_camp"), () -> FishCampStructure.CODEC); } diff --git a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java index 8958ee9f..d54270a3 100644 --- a/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java +++ b/src/main/java/com/github/platymemo/alaskanativecraft/worldgen/structure/FishCampStructure.java @@ -1,8 +1,10 @@ package com.github.platymemo.alaskanativecraft.worldgen.structure; +import java.util.Optional; + import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.structure.Structure; + import net.minecraft.structure.StructureType; import net.minecraft.structure.pool.StructurePool; import net.minecraft.structure.pool.StructurePoolBasedGenerator; @@ -10,63 +12,60 @@ import net.minecraft.util.Holder; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.registry.DynamicRegistryManager; import net.minecraft.world.Heightmap; -import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.feature.StructureFeature; import net.minecraft.world.gen.heightprovider.HeightProvider; -import java.util.Optional; -import java.util.Set; - +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class FishCampStructure extends StructureFeature { - public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> - instance.group(FishCampStructure.settingsCodec(instance), - StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), - Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), - Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), - HeightProvider.CODEC.fieldOf("start_height").forGetter(structure -> structure.startHeight), - Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap").forGetter(structure -> structure.projectStartToHeightmap), - Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) - ).apply(instance, FishCampStructure::new)).codec(); + public static final Codec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group(FishCampStructure.settingsCodec(instance), + StructurePool.REGISTRY_CODEC.fieldOf("start_pool").forGetter(structure -> structure.startPool), + Identifier.CODEC.optionalFieldOf("start_jigsaw_name").forGetter(structure -> structure.startJigsawName), + Codec.intRange(0, 30).fieldOf("size").forGetter(structure -> structure.size), + HeightProvider.CODEC.fieldOf("start_height").forGetter(structure -> structure.startHeight), + Heightmap.Type.CODEC.optionalFieldOf("project_start_to_heightmap").forGetter(structure -> structure.projectStartToHeightmap), + Codec.intRange(1, 128).fieldOf("max_distance_from_center").forGetter(structure -> structure.maxDistanceFromCenter) + ).apply(instance, FishCampStructure::new)).codec(); - private final Holder startPool; - private final Optional startJigsawName; - private final int size; - private final HeightProvider startHeight; - private final Optional projectStartToHeightmap; - private final int maxDistanceFromCenter; + private final Holder startPool; + private final Optional startJigsawName; + private final int size; + private final HeightProvider startHeight; + private final Optional projectStartToHeightmap; + private final int maxDistanceFromCenter; - public FishCampStructure(StructureSettings config, - Holder startPool, - Optional startJigsawName, - int size, - HeightProvider startHeight, - Optional projectStartToHeightmap, - int maxDistanceFromCenter) - { - super(config); - this.startPool = startPool; - this.startJigsawName = startJigsawName; - this.size = size; - this.startHeight = startHeight; - this.projectStartToHeightmap = projectStartToHeightmap; - this.maxDistanceFromCenter = maxDistanceFromCenter; - } + public FishCampStructure(StructureSettings config, + Holder startPool, + Optional startJigsawName, + int size, + HeightProvider startHeight, + Optional projectStartToHeightmap, + int maxDistanceFromCenter) { + super(config); + this.startPool = startPool; + this.startJigsawName = startJigsawName; + this.size = size; + this.startHeight = startHeight; + this.projectStartToHeightmap = projectStartToHeightmap; + this.maxDistanceFromCenter = maxDistanceFromCenter; + } - @Override - public Optional findGenerationPos(GenerationContext context) { - BlockPos spawnXZPosition = context.chunkPos().getCenterAtY(0); - int landHeight = context.chunkGenerator().getHeightInGround(spawnXZPosition.getX(), spawnXZPosition.getZ(), Heightmap.Type.WORLD_SURFACE_WG, context.world(), context.randomState()); + @Override + public Optional findGenerationPos(GenerationContext context) { + BlockPos spawnXZPosition = context.chunkPos().getCenterAtY(0); + int landHeight = context.chunkGenerator().getHeightInGround(spawnXZPosition.getX(), spawnXZPosition.getZ(), Heightmap.Type.WORLD_SURFACE_WG, context.world(), context.randomState()); - var biomes = context.chunkGenerator().getBiomeSource().getBiomesInArea(spawnXZPosition.getX(), landHeight, spawnXZPosition.getZ(), 32, context.randomState().getSampler()); - if (biomes.stream().noneMatch(biome -> biome.hasTag(BiomeTags.IS_RIVER) || biome.hasTag(BiomeTags.IS_OCEAN))) return Optional.empty(); + var biomes = context.chunkGenerator().getBiomeSource().getBiomesInArea(spawnXZPosition.getX(), landHeight, spawnXZPosition.getZ(), 32, context.randomState().getSampler()); + if (biomes.stream().noneMatch(biome -> biome.hasTag(BiomeTags.IS_RIVER) || biome.hasTag(BiomeTags.IS_OCEAN))) { + return Optional.empty(); + } - return StructurePoolBasedGenerator.m_drsiegyr(context, this.startPool, this.startJigsawName, this.size, spawnXZPosition.up(landHeight), false, this.projectStartToHeightmap, this.maxDistanceFromCenter); - } + return StructurePoolBasedGenerator.m_drsiegyr(context, this.startPool, this.startJigsawName, this.size, spawnXZPosition.up(landHeight), false, this.projectStartToHeightmap, this.maxDistanceFromCenter); + } - @Override - public StructureType getType() { - return AlaskaStructures.FISH_CAMP; - } + @Override + public StructureType getType() { + return AlaskaStructures.FISH_CAMP; + } } diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/blueberry_bush.json b/src/main/resources/assets/alaskanativecraft/blockstates/blueberry_bush.json index d62453b0..ee6411be 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/blueberry_bush.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/blueberry_bush.json @@ -13,4 +13,4 @@ "model": "alaskanativecraft:block/blueberry_bush/blueberry_bush_stage3" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/cloudberry_bush.json b/src/main/resources/assets/alaskanativecraft/blockstates/cloudberry_bush.json index fc5f1a9a..bc8ca36c 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/cloudberry_bush.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/cloudberry_bush.json @@ -13,4 +13,4 @@ "model": "alaskanativecraft:block/cloudberry_bush/cloudberry_bush_stage3" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_log.json b/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_log.json index 1fe06a6e..0fd22f8f 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_log.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_log.json @@ -13,4 +13,4 @@ "x": 90 } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_planks.json b/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_planks.json index 35ec9721..d26711fd 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_planks.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/driftwood_planks.json @@ -4,4 +4,4 @@ "model": "alaskanativecraft:block/driftwood_planks" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/drying_rack.json b/src/main/resources/assets/alaskanativecraft/blockstates/drying_rack.json index f00e9111..811cc39a 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/drying_rack.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/drying_rack.json @@ -96,4 +96,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/raspberry_bush.json b/src/main/resources/assets/alaskanativecraft/blockstates/raspberry_bush.json index f277b262..71048d9b 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/raspberry_bush.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/raspberry_bush.json @@ -13,4 +13,4 @@ "model": "alaskanativecraft:block/raspberry_bush/raspberry_bush_stage3" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/salmonberry_bush.json b/src/main/resources/assets/alaskanativecraft/blockstates/salmonberry_bush.json index 926606a8..eae8d101 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/salmonberry_bush.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/salmonberry_bush.json @@ -13,4 +13,4 @@ "model": "alaskanativecraft:block/salmonberry_bush/salmonberry_bush_stage3" } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/blockstates/whale_meat_block.json b/src/main/resources/assets/alaskanativecraft/blockstates/whale_meat_block.json index 70922837..3b06afb0 100644 --- a/src/main/resources/assets/alaskanativecraft/blockstates/whale_meat_block.json +++ b/src/main/resources/assets/alaskanativecraft/blockstates/whale_meat_block.json @@ -24,4 +24,4 @@ "y": 270 } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage2.json b/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage2.json index 755e06c2..82399ffb 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage2.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage2.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/blueberry_bush/blueberry_bush_stage2" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage3.json b/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage3.json index 9e56eb2b..0741b607 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage3.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/blueberry_bush/blueberry_bush_stage3.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/blueberry_bush/blueberry_bush_stage3" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage0.json b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage0.json index 77df57a7..3b47ebd9 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage0.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage0.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/cloudberry_bush/cloudberry_bush_stage0" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage1.json b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage1.json index 28670dc3..f57945ac 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage1.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage1.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/cloudberry_bush/cloudberry_bush_stage1" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage2.json b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage2.json index 22191871..64bee2a4 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage2.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage2.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/cloudberry_bush/cloudberry_bush_stage2" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage3.json b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage3.json index dbf173bf..39abd6d5 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage3.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/cloudberry_bush/cloudberry_bush_stage3.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/cloudberry_bush/cloudberry_bush_stage3" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log.json b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log.json index 321efdaa..24aa20d0 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log.json @@ -4,4 +4,4 @@ "end": "alaskanativecraft:block/driftwood_log_top", "side": "alaskanativecraft:block/driftwood_log" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log_horizontal.json b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log_horizontal.json index ebb657ef..d8aa6556 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log_horizontal.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_log_horizontal.json @@ -4,4 +4,4 @@ "end": "alaskanativecraft:block/driftwood_log_top", "side": "alaskanativecraft:block/driftwood_log" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_planks.json b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_planks.json index d20334a1..23227931 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/driftwood_planks.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/driftwood_planks.json @@ -3,4 +3,4 @@ "textures": { "all": "alaskanativecraft:block/driftwood_planks" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack.json b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack.json index 57aa17c9..cb4e2ed7 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack.json @@ -247,4 +247,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_extension.json b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_extension.json index 6864c356..0effb603 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_extension.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_extension.json @@ -94,4 +94,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_legs.json b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_legs.json index 81f0186b..35e48d4c 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_legs.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/drying_rack/drying_rack_legs.json @@ -162,4 +162,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage2.json b/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage2.json index d14f33b8..389bbb44 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage2.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage2.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/raspberry_bush/raspberry_bush_stage2" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage3.json b/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage3.json index 735b18b2..428d2d46 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage3.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/raspberry_bush/raspberry_bush_stage3.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/raspberry_bush/raspberry_bush_stage3" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage2.json b/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage2.json index f87e99b8..a50dffca 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage2.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage2.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/salmonberry_bush/salmonberry_bush_stage2" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage3.json b/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage3.json index 3d437bbb..8d9c961b 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage3.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/salmonberry_bush/salmonberry_bush_stage3.json @@ -3,4 +3,4 @@ "textures": { "cross": "alaskanativecraft:block/salmonberry_bush/salmonberry_bush_stage3" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/block/whale_meat_block.json b/src/main/resources/assets/alaskanativecraft/models/block/whale_meat_block.json index d586cc91..cc9e66af 100644 --- a/src/main/resources/assets/alaskanativecraft/models/block/whale_meat_block.json +++ b/src/main/resources/assets/alaskanativecraft/models/block/whale_meat_block.json @@ -85,4 +85,4 @@ } } ] -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/acacia_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/acacia_dogsled.json index 42c0d549..3bb2e43a 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/acacia_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/acacia_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/acacia_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/akutaq.json b/src/main/resources/assets/alaskanativecraft/models/item/akutaq.json index 849d0bd4..b2453633 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/akutaq.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/akutaq.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/akutaq" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/antler.json b/src/main/resources/assets/alaskanativecraft/models/item/antler.json index 0166c870..417718a8 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/antler.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/antler.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/antler" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/birch_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/birch_dogsled.json index 5760f61a..c8c6fadc 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/birch_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/birch_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/birch_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/blueberries.json b/src/main/resources/assets/alaskanativecraft/models/item/blueberries.json index 54e95f65..4c4862a9 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/blueberries.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/blueberries.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/blueberries" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/cloudberries.json b/src/main/resources/assets/alaskanativecraft/models/item/cloudberries.json index d91db79f..602883de 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/cloudberries.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/cloudberries.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/cloudberries" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/cooked_ptarmigan.json b/src/main/resources/assets/alaskanativecraft/models/item/cooked_ptarmigan.json index 9255ebcc..d0db4ff6 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/cooked_ptarmigan.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/cooked_ptarmigan.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/cooked_ptarmigan" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/cooked_seal.json b/src/main/resources/assets/alaskanativecraft/models/item/cooked_seal.json index 51bde855..bea1547f 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/cooked_seal.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/cooked_seal.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/cooked_seal" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/cooked_venison.json b/src/main/resources/assets/alaskanativecraft/models/item/cooked_venison.json index 6196f51d..2568bfca 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/cooked_venison.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/cooked_venison.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/cooked_venison" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/dark_oak_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/dark_oak_dogsled.json index ebfe3a72..3234feea 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/dark_oak_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/dark_oak_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/dark_oak_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/diamond_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/diamond_harpoon.json index e3f9024a..88d8ab2c 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/diamond_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/diamond_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/diamond_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/driftwood_chunk.json b/src/main/resources/assets/alaskanativecraft/models/item/driftwood_chunk.json index 1c7234b5..49da99b8 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/driftwood_chunk.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/driftwood_chunk.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/driftwood_chunk" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/dry_fish.json b/src/main/resources/assets/alaskanativecraft/models/item/dry_fish.json index e5bec1bd..e7f7b77a 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/dry_fish.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/dry_fish.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dry_fish" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/dry_seal.json b/src/main/resources/assets/alaskanativecraft/models/item/dry_seal.json index 2fa56e3d..4e176c66 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/dry_seal.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/dry_seal.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dry_seal" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/fish_strip.json b/src/main/resources/assets/alaskanativecraft/models/item/fish_strip.json index d9486bd8..72ce82d7 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/fish_strip.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/fish_strip.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/fish_strip" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/golden_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/golden_harpoon.json index 1b334702..d582d0c7 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/golden_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/golden_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/golden_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/iron_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/iron_harpoon.json index f922da71..ca7fab7e 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/iron_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/iron_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/iron_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/ivory.json b/src/main/resources/assets/alaskanativecraft/models/item/ivory.json index c3d3a1c8..b8bf1910 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/ivory.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/ivory.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/ivory" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/jungle_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/jungle_dogsled.json index 0e01ac78..4e7143c4 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/jungle_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/jungle_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/jungle_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_body.json b/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_body.json index 685ac881..b15edb48 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_body.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_body.json @@ -4,4 +4,4 @@ "layer0": "alaskanativecraft:item/kuspuk_body", "layer1": "alaskanativecraft:item/kuspuk_body_overlay" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_hood.json b/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_hood.json index a3d0f92f..f15b893f 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_hood.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/kuspuk_hood.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/kuspuk_hood" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/mukluks.json b/src/main/resources/assets/alaskanativecraft/models/item/mukluks.json index 0df5c1b9..f1f2e588 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/mukluks.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/mukluks.json @@ -4,4 +4,4 @@ "layer0": "alaskanativecraft:item/mukluks", "layer1": "alaskanativecraft:item/mukluks_overlay" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/muktuk.json b/src/main/resources/assets/alaskanativecraft/models/item/muktuk.json index 27aaa633..03e74e93 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/muktuk.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/muktuk.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/muktuk" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/netherite_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/netherite_harpoon.json index e849979b..10457cc7 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/netherite_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/netherite_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/netherite_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/oak_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/oak_dogsled.json index f9e12755..d0db9c07 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/oak_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/oak_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/oak_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/ptarmigan.json b/src/main/resources/assets/alaskanativecraft/models/item/ptarmigan.json index b9754908..0810bd1e 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/ptarmigan.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/ptarmigan.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/ptarmigan" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/raspberries.json b/src/main/resources/assets/alaskanativecraft/models/item/raspberries.json index 87b7d6f3..9f9e4055 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/raspberries.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/raspberries.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/raspberries" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/salmonberries.json b/src/main/resources/assets/alaskanativecraft/models/item/salmonberries.json index cd69d5d9..048890ae 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/salmonberries.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/salmonberries.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/salmonberries" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/seal.json b/src/main/resources/assets/alaskanativecraft/models/item/seal.json index 0c37d01d..8579ab9f 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/seal.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/seal.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/seal" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/snow_goggles.json b/src/main/resources/assets/alaskanativecraft/models/item/snow_goggles.json index 685cce5b..2a4d17bf 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/snow_goggles.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/snow_goggles.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/snow_goggles" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/snowshoes.json b/src/main/resources/assets/alaskanativecraft/models/item/snowshoes.json index f029d51d..002d2b50 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/snowshoes.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/snowshoes.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/backup_snowshoes" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/spruce_dogsled.json b/src/main/resources/assets/alaskanativecraft/models/item/spruce_dogsled.json index ac5bba2d..078cf7eb 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/spruce_dogsled.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/spruce_dogsled.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/dogsled/spruce_dogsled" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/stone_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/stone_harpoon.json index e59f63f8..65f9ea37 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/stone_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/stone_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/stone_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/ulu.json b/src/main/resources/assets/alaskanativecraft/models/item/ulu.json index 4ccf6414..87ffe7d8 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/ulu.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/ulu.json @@ -73,4 +73,4 @@ ] } } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/venison.json b/src/main/resources/assets/alaskanativecraft/models/item/venison.json index 422c919f..21204ae4 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/venison.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/venison.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/venison" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/models/item/wooden_harpoon.json b/src/main/resources/assets/alaskanativecraft/models/item/wooden_harpoon.json index 7f46f59b..d8e4e128 100644 --- a/src/main/resources/assets/alaskanativecraft/models/item/wooden_harpoon.json +++ b/src/main/resources/assets/alaskanativecraft/models/item/wooden_harpoon.json @@ -3,4 +3,4 @@ "textures": { "layer0": "alaskanativecraft:item/harpoon/wooden_harpoon" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/sounds.json b/src/main/resources/assets/alaskanativecraft/sounds.json index cf7d7352..fd5b38bc 100644 --- a/src/main/resources/assets/alaskanativecraft/sounds.json +++ b/src/main/resources/assets/alaskanativecraft/sounds.json @@ -34,4 +34,4 @@ ], "subtitle": "alaskanativecraft:subtitles.moose.hurt" } -} \ No newline at end of file +} diff --git a/src/main/resources/assets/alaskanativecraft/textures/misc/gogglesblur.png.mcmeta b/src/main/resources/assets/alaskanativecraft/textures/misc/gogglesblur.png.mcmeta index 2077f3ce..e38a5ad3 100644 --- a/src/main/resources/assets/alaskanativecraft/textures/misc/gogglesblur.png.mcmeta +++ b/src/main/resources/assets/alaskanativecraft/textures/misc/gogglesblur.png.mcmeta @@ -3,4 +3,3 @@ "blur": true } } - diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/akutaq.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/akutaq.json index a2ca75a3..28be5ba4 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/akutaq.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/akutaq.json @@ -35,4 +35,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/diamond_harpoon.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/diamond_harpoon.json index 6f6f17e9..e6e32a0a 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/diamond_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/diamond_harpoon.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/dogsleds.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/dogsleds.json index c7f59d7c..74e34d2b 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/dogsleds.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/dogsleds.json @@ -65,4 +65,4 @@ "has_the_dark_oak_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/drying_rack.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/drying_rack.json index 8f05d8b7..d28979d5 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/drying_rack.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/drying_rack.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/golden_harpoon.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/golden_harpoon.json index f906f8f4..44125687 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/golden_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/golden_harpoon.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/iron_harpoon.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/iron_harpoon.json index d105fafb..82c504e1 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/iron_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/iron_harpoon.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/kuspuk.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/kuspuk.json index 54f7b788..6491f299 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/kuspuk.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/kuspuk.json @@ -33,4 +33,4 @@ "has_the_hood_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/netherite_harpoon_smithing.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/netherite_harpoon_smithing.json index e0a4c7f8..cef7b086 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/netherite_harpoon_smithing.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/netherite_harpoon_smithing.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/stone_harpoon.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/stone_harpoon.json index 7daebb21..eb7c0dfd 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/stone_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/stone_harpoon.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/ulu.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/ulu.json index 1e6fe11a..2297e498 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/ulu.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/ulu.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/advancements/recipes/wooden_harpoon.json b/src/main/resources/data/alaskanativecraft/advancements/recipes/wooden_harpoon.json index 189f39e8..132d8c75 100644 --- a/src/main/resources/data/alaskanativecraft/advancements/recipes/wooden_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/advancements/recipes/wooden_harpoon.json @@ -29,4 +29,4 @@ "has_the_recipe" ] ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/blueberry_bush.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/blueberry_bush.json index 90854ee2..0d27f122 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/blueberry_bush.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/blueberry_bush.json @@ -79,4 +79,4 @@ "function": "minecraft:explosion_decay" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/cloudberry_bush.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/cloudberry_bush.json index c26cc6fa..467d9f1d 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/cloudberry_bush.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/cloudberry_bush.json @@ -79,4 +79,4 @@ "function": "minecraft:explosion_decay" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/driftwood_log.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/driftwood_log.json index 9b5ae414..4aaaa71c 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/driftwood_log.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/driftwood_log.json @@ -64,4 +64,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/drying_rack.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/drying_rack.json index c43a8e45..b0c263a9 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/drying_rack.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/drying_rack.json @@ -16,4 +16,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/raspberry_bush.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/raspberry_bush.json index 82c8a1a1..92f9240b 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/raspberry_bush.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/raspberry_bush.json @@ -79,4 +79,4 @@ "function": "minecraft:explosion_decay" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/salmonberry_bush.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/salmonberry_bush.json index 4e8ed7b5..98c35680 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/salmonberry_bush.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/salmonberry_bush.json @@ -79,4 +79,4 @@ "function": "minecraft:explosion_decay" } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/whale_meat_block.json b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/whale_meat_block.json index 00e1ab02..18b8385f 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/blocks/whale_meat_block.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/blocks/whale_meat_block.json @@ -51,4 +51,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/entities/harp_seal.json b/src/main/resources/data/alaskanativecraft/loot_tables/entities/harp_seal.json index c501054b..2fd1af10 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/entities/harp_seal.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/entities/harp_seal.json @@ -42,4 +42,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/entities/moose.json b/src/main/resources/data/alaskanativecraft/loot_tables/entities/moose.json index 9a2add22..96d18bb2 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/entities/moose.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/entities/moose.json @@ -94,4 +94,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/loot_tables/entities/ptarmigan.json b/src/main/resources/data/alaskanativecraft/loot_tables/entities/ptarmigan.json index 455dbcd5..07634371 100644 --- a/src/main/resources/data/alaskanativecraft/loot_tables/entities/ptarmigan.json +++ b/src/main/resources/data/alaskanativecraft/loot_tables/entities/ptarmigan.json @@ -60,4 +60,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/acacia_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/acacia_dogsled.json index fc9b023b..b47182e9 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/acacia_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/acacia_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:acacia_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/birch_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/birch_dogsled.json index 31aa8d8e..3cdd2930 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/birch_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/birch_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:birch_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/blue_dye.json b/src/main/resources/data/alaskanativecraft/recipes/blue_dye.json index cc6668fe..019fc0f6 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/blue_dye.json +++ b/src/main/resources/data/alaskanativecraft/recipes/blue_dye.json @@ -9,4 +9,4 @@ "result": { "item": "minecraft:blue_dye" } -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan.json index ceaba7ac..61f70b1e 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 200, "type": "smelting" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_campfire_cooking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_campfire_cooking.json index 5833e245..3b78a24c 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_campfire_cooking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_campfire_cooking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 600, "type": "campfire_cooking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_smoking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_smoking.json index ba1d9056..a5a89a08 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_smoking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_ptarmigan_from_smoking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 100, "type": "smoking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal.json index 809cbed9..981dc932 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 200, "type": "smelting" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_campfire_cooking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_campfire_cooking.json index b40d3bb1..131aa0bb 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_campfire_cooking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_campfire_cooking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 600, "type": "campfire_cooking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_smoking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_smoking.json index 4c12f9e5..38c73397 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_smoking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_seal_from_smoking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 100, "type": "smoking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison.json index bed300b0..7580b3da 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 200, "type": "smelting" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_campfire_cooking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_campfire_cooking.json index 2033c66d..2accc58d 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_campfire_cooking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_campfire_cooking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 600, "type": "campfire_cooking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_smoking.json b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_smoking.json index bd9c1e5c..7e14a47d 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_smoking.json +++ b/src/main/resources/data/alaskanativecraft/recipes/cooked_venison_from_smoking.json @@ -6,4 +6,4 @@ "experience": 0.35, "cookingtime": 100, "type": "smoking" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/dark_oak_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/dark_oak_dogsled.json index 486e38c0..feda2da6 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/dark_oak_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/dark_oak_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:dark_oak_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/diamond_harpoon.json b/src/main/resources/data/alaskanativecraft/recipes/diamond_harpoon.json index efd9efdb..c4ab96cb 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/diamond_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/recipes/diamond_harpoon.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:diamond_harpoon" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/dried_kelp.json b/src/main/resources/data/alaskanativecraft/recipes/dried_kelp.json index ad30413c..e13c87e9 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/dried_kelp.json +++ b/src/main/resources/data/alaskanativecraft/recipes/dried_kelp.json @@ -5,4 +5,4 @@ "result": "minecraft:dried_kelp", "cookingtime": 1200, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/driftwood_chunk.json b/src/main/resources/data/alaskanativecraft/recipes/driftwood_chunk.json index dcfa4d86..cb779a3e 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/driftwood_chunk.json +++ b/src/main/resources/data/alaskanativecraft/recipes/driftwood_chunk.json @@ -9,4 +9,4 @@ "item": "alaskanativecraft:driftwood_chunk", "count": 4 } -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/dry_bush.json b/src/main/resources/data/alaskanativecraft/recipes/dry_bush.json index c5081673..a8403b23 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/dry_bush.json +++ b/src/main/resources/data/alaskanativecraft/recipes/dry_bush.json @@ -5,4 +5,4 @@ "result": "minecraft:dead_bush", "cookingtime": 1200, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/dry_fish.json b/src/main/resources/data/alaskanativecraft/recipes/dry_fish.json index a4945ab3..c596019e 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/dry_fish.json +++ b/src/main/resources/data/alaskanativecraft/recipes/dry_fish.json @@ -5,4 +5,4 @@ "result": "alaskanativecraft:dry_fish", "cookingtime": 1200, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/drying_rack.json b/src/main/resources/data/alaskanativecraft/recipes/drying_rack.json index 4665418e..a8356951 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/drying_rack.json +++ b/src/main/resources/data/alaskanativecraft/recipes/drying_rack.json @@ -15,4 +15,4 @@ "item": "alaskanativecraft:drying_rack" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/golden_harpoon.json b/src/main/resources/data/alaskanativecraft/recipes/golden_harpoon.json index 6bed6eb9..a84149ed 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/golden_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/recipes/golden_harpoon.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:golden_harpoon" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/green_dye.json b/src/main/resources/data/alaskanativecraft/recipes/green_dye.json index 191e6fed..2cfd033c 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/green_dye.json +++ b/src/main/resources/data/alaskanativecraft/recipes/green_dye.json @@ -5,4 +5,4 @@ "result": "minecraft:green_dye", "cookingtime": 1200, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/iron_harpoon.json b/src/main/resources/data/alaskanativecraft/recipes/iron_harpoon.json index a8a8dc3b..ad851cfb 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/iron_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/recipes/iron_harpoon.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:iron_harpoon" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/jungle_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/jungle_dogsled.json index 50fdbd42..607ce8d1 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/jungle_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/jungle_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:jungle_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/kuspuk_body.json b/src/main/resources/data/alaskanativecraft/recipes/kuspuk_body.json index b2bd9722..b72854af 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/kuspuk_body.json +++ b/src/main/resources/data/alaskanativecraft/recipes/kuspuk_body.json @@ -16,4 +16,4 @@ "item": "alaskanativecraft:kuspuk_body" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/kuspuk_hood.json b/src/main/resources/data/alaskanativecraft/recipes/kuspuk_hood.json index 7f2b2961..19655439 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/kuspuk_hood.json +++ b/src/main/resources/data/alaskanativecraft/recipes/kuspuk_hood.json @@ -15,4 +15,4 @@ "item": "alaskanativecraft:kuspuk_hood" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/leather.json b/src/main/resources/data/alaskanativecraft/recipes/leather.json index 5074d564..74327aa0 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/leather.json +++ b/src/main/resources/data/alaskanativecraft/recipes/leather.json @@ -5,4 +5,4 @@ "result": "minecraft:leather", "cookingtime": 3600, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/lime_dye.json b/src/main/resources/data/alaskanativecraft/recipes/lime_dye.json index 5dd4b453..fa477347 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/lime_dye.json +++ b/src/main/resources/data/alaskanativecraft/recipes/lime_dye.json @@ -5,4 +5,4 @@ "result": "minecraft:lime_dye", "cookingtime": 1200, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/mukluks.json b/src/main/resources/data/alaskanativecraft/recipes/mukluks.json index 9a7b66b6..86f99e1e 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/mukluks.json +++ b/src/main/resources/data/alaskanativecraft/recipes/mukluks.json @@ -15,4 +15,4 @@ "item": "alaskanativecraft:mukluks" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/netherite_harpoon_smithing.json b/src/main/resources/data/alaskanativecraft/recipes/netherite_harpoon_smithing.json index aee2cbbc..ff3ca54f 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/netherite_harpoon_smithing.json +++ b/src/main/resources/data/alaskanativecraft/recipes/netherite_harpoon_smithing.json @@ -9,4 +9,4 @@ "item": "alaskanativecraft:netherite_harpoon" }, "type": "smithing" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/oak_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/oak_dogsled.json index aacb6e70..d297102f 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/oak_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/oak_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:oak_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/red_dye.json b/src/main/resources/data/alaskanativecraft/recipes/red_dye.json index 4ffedc79..0c6ad2c8 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/red_dye.json +++ b/src/main/resources/data/alaskanativecraft/recipes/red_dye.json @@ -9,4 +9,4 @@ "result": { "item": "minecraft:red_dye" } -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/snowshoes.json b/src/main/resources/data/alaskanativecraft/recipes/snowshoes.json index 1b8f21c2..be7acdf1 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/snowshoes.json +++ b/src/main/resources/data/alaskanativecraft/recipes/snowshoes.json @@ -16,4 +16,4 @@ "item": "alaskanativecraft:snowshoes" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/sponge.json b/src/main/resources/data/alaskanativecraft/recipes/sponge.json index 636ee499..7d259ecd 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/sponge.json +++ b/src/main/resources/data/alaskanativecraft/recipes/sponge.json @@ -5,4 +5,4 @@ "result": "minecraft:sponge", "cookingtime": 4800, "type": "alaskanativecraft:drying" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/spruce_dogsled.json b/src/main/resources/data/alaskanativecraft/recipes/spruce_dogsled.json index 48241045..915c0189 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/spruce_dogsled.json +++ b/src/main/resources/data/alaskanativecraft/recipes/spruce_dogsled.json @@ -20,4 +20,4 @@ "item": "alaskanativecraft:spruce_dogsled" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/stone_harpoon.json b/src/main/resources/data/alaskanativecraft/recipes/stone_harpoon.json index 70c08c7b..4e4b6cc0 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/stone_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/recipes/stone_harpoon.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:stone_harpoon" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/ulu.json b/src/main/resources/data/alaskanativecraft/recipes/ulu.json index 1854be69..23a9dffe 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/ulu.json +++ b/src/main/resources/data/alaskanativecraft/recipes/ulu.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:ulu" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/recipes/wooden_harpoon.json b/src/main/resources/data/alaskanativecraft/recipes/wooden_harpoon.json index 6262ee4a..504a62af 100644 --- a/src/main/resources/data/alaskanativecraft/recipes/wooden_harpoon.json +++ b/src/main/resources/data/alaskanativecraft/recipes/wooden_harpoon.json @@ -19,4 +19,4 @@ "item": "alaskanativecraft:wooden_harpoon" }, "type": "minecraft:crafting_shaped" -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/blocks/mineable/ulu.json b/src/main/resources/data/alaskanativecraft/tags/blocks/mineable/ulu.json index 90e68add..98bbaf6c 100644 --- a/src/main/resources/data/alaskanativecraft/tags/blocks/mineable/ulu.json +++ b/src/main/resources/data/alaskanativecraft/tags/blocks/mineable/ulu.json @@ -8,4 +8,4 @@ "#minecraft:leaves", "#minecraft:wool" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/blocks/snowshoe_speed_blocks.json b/src/main/resources/data/alaskanativecraft/tags/blocks/snowshoe_speed_blocks.json index b471b71f..0d05d56b 100644 --- a/src/main/resources/data/alaskanativecraft/tags/blocks/snowshoe_speed_blocks.json +++ b/src/main/resources/data/alaskanativecraft/tags/blocks/snowshoe_speed_blocks.json @@ -4,4 +4,4 @@ "#minecraft:ice", "#minecraft:snow" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/akutaq_berries.json b/src/main/resources/data/alaskanativecraft/tags/items/akutaq_berries.json index 29d9ff94..3f874fe8 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/akutaq_berries.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/akutaq_berries.json @@ -9,4 +9,4 @@ "#c:blueberries", "#c:raspberries" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/akutaq_meats.json b/src/main/resources/data/alaskanativecraft/tags/items/akutaq_meats.json index c957d7ed..de84fc78 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/akutaq_meats.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/akutaq_meats.json @@ -5,4 +5,4 @@ "minecraft:salmon", "minecraft:cod" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/dogsleds.json b/src/main/resources/data/alaskanativecraft/tags/items/dogsleds.json index 2836842d..0ec46710 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/dogsleds.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/dogsleds.json @@ -8,4 +8,4 @@ "alaskanativecraft:acacia_dogsled", "alaskanativecraft:dark_oak_dogsled" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/harpoons.json b/src/main/resources/data/alaskanativecraft/tags/items/harpoons.json index 3ef622e7..48658964 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/harpoons.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/harpoons.json @@ -8,4 +8,4 @@ "alaskanativecraft:diamond_harpoon", "alaskanativecraft:netherite_harpoon" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/kuspuks.json b/src/main/resources/data/alaskanativecraft/tags/items/kuspuks.json index c7a3321d..e2f0d690 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/kuspuks.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/kuspuks.json @@ -4,4 +4,4 @@ "alaskanativecraft:kuspuk_hood", "alaskanativecraft:kuspuk_body" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/seal_food.json b/src/main/resources/data/alaskanativecraft/tags/items/seal_food.json index 7555424e..efd7cf5a 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/seal_food.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/seal_food.json @@ -5,4 +5,4 @@ "alaskanativecraft:fish_strip", "#alaskanativecraft:sliceable_fish" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/sliceable_fish.json b/src/main/resources/data/alaskanativecraft/tags/items/sliceable_fish.json index ba801d1f..569040e9 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/sliceable_fish.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/sliceable_fish.json @@ -4,4 +4,4 @@ "minecraft:cod", "minecraft:salmon" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/alaskanativecraft/tags/items/ulus.json b/src/main/resources/data/alaskanativecraft/tags/items/ulus.json index 430510a3..5062ef97 100644 --- a/src/main/resources/data/alaskanativecraft/tags/items/ulus.json +++ b/src/main/resources/data/alaskanativecraft/tags/items/ulus.json @@ -3,4 +3,4 @@ "values": [ "alaskanativecraft:ulu" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/blocks/chests.json b/src/main/resources/data/c/tags/blocks/chests.json index bd0b1e62..32a8db98 100644 --- a/src/main/resources/data/c/tags/blocks/chests.json +++ b/src/main/resources/data/c/tags/blocks/chests.json @@ -22,4 +22,4 @@ "minecraft:red_shulker_box", "minecraft:black_shulker_box" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/blocks/logs_with_bark.json b/src/main/resources/data/c/tags/blocks/logs_with_bark.json index 2af22d72..31079dad 100644 --- a/src/main/resources/data/c/tags/blocks/logs_with_bark.json +++ b/src/main/resources/data/c/tags/blocks/logs_with_bark.json @@ -18,4 +18,4 @@ "minecraft:warped_hyphae", "minecraft:crimson_hyphae" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/blueberries.json b/src/main/resources/data/c/tags/items/blueberries.json index cb54a0bf..95b11670 100644 --- a/src/main/resources/data/c/tags/items/blueberries.json +++ b/src/main/resources/data/c/tags/items/blueberries.json @@ -3,4 +3,4 @@ "values": [ "alaskanativecraft:blueberries" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/chests.json b/src/main/resources/data/c/tags/items/chests.json index bd0b1e62..32a8db98 100644 --- a/src/main/resources/data/c/tags/items/chests.json +++ b/src/main/resources/data/c/tags/items/chests.json @@ -22,4 +22,4 @@ "minecraft:red_shulker_box", "minecraft:black_shulker_box" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/cooked_venison.json b/src/main/resources/data/c/tags/items/cooked_venison.json index f1dba7f6..34fb2571 100644 --- a/src/main/resources/data/c/tags/items/cooked_venison.json +++ b/src/main/resources/data/c/tags/items/cooked_venison.json @@ -3,4 +3,4 @@ "values": [ "alaskanativecraft:cooked_venison" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/leathers.json b/src/main/resources/data/c/tags/items/leathers.json index 8247c9a3..118f5c9e 100644 --- a/src/main/resources/data/c/tags/items/leathers.json +++ b/src/main/resources/data/c/tags/items/leathers.json @@ -3,4 +3,4 @@ "values": [ "minecraft:leather" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/logs_with_bark.json b/src/main/resources/data/c/tags/items/logs_with_bark.json index 2af22d72..31079dad 100644 --- a/src/main/resources/data/c/tags/items/logs_with_bark.json +++ b/src/main/resources/data/c/tags/items/logs_with_bark.json @@ -18,4 +18,4 @@ "minecraft:warped_hyphae", "minecraft:crimson_hyphae" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/raspberries.json b/src/main/resources/data/c/tags/items/raspberries.json index ecba0962..7dac9984 100644 --- a/src/main/resources/data/c/tags/items/raspberries.json +++ b/src/main/resources/data/c/tags/items/raspberries.json @@ -3,4 +3,4 @@ "values": [ "alaskanativecraft:raspberries" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/raw_meat.json b/src/main/resources/data/c/tags/items/raw_meat.json index e0cb8ed7..30cbce2f 100644 --- a/src/main/resources/data/c/tags/items/raw_meat.json +++ b/src/main/resources/data/c/tags/items/raw_meat.json @@ -5,4 +5,4 @@ "alaskanativecraft:ptarmigan", "alaskanativecraft:seal" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/c/tags/items/venison.json b/src/main/resources/data/c/tags/items/venison.json index 6e814cb1..fbc42742 100644 --- a/src/main/resources/data/c/tags/items/venison.json +++ b/src/main/resources/data/c/tags/items/venison.json @@ -3,4 +3,4 @@ "values": [ "alaskanativecraft:venison" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json b/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json index bfa1af95..50c85772 100644 --- a/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json +++ b/src/main/resources/data/minecraft/tags/blocks/logs_that_burn.json @@ -9,4 +9,4 @@ "#minecraft:spruce_logs", "alaskanativecraft:driftwood_log" ] -} \ No newline at end of file +} diff --git a/src/main/resources/data/minecraft/tags/items/logs_that_burn.json b/src/main/resources/data/minecraft/tags/items/logs_that_burn.json index bfa1af95..50c85772 100644 --- a/src/main/resources/data/minecraft/tags/items/logs_that_burn.json +++ b/src/main/resources/data/minecraft/tags/items/logs_that_burn.json @@ -9,4 +9,4 @@ "#minecraft:spruce_logs", "alaskanativecraft:driftwood_log" ] -} \ No newline at end of file +} From b7335be4a731434a8920614886828ab587eb1bab Mon Sep 17 00:00:00 2001 From: Platymemo <67663207+Platymemo@users.noreply.github.com> Date: Fri, 7 Oct 2022 00:36:13 -0800 Subject: [PATCH 4/4] fix compat --- build.gradle | 5 ++++- gradle.properties | 3 ++- src/main/resources/quilt.mod.json | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b96bbde2..028b2e99 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,10 @@ dependencies { modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}" // REI integration - modCompileOnly "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + modImplementation "me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}" + + // We have to manually override the version of Architectury used by REI to run on Quilt + modLocalRuntime "dev.architectury:architectury-fabric:${project.architectury_override_version}" // ClothConfig modApi("me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}") { diff --git a/gradle.properties b/gradle.properties index 44c646e3..8dd2ad0e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,5 @@ org.gradle.parallel = true # Dependencies clothconfig_version=8.0.75 modmenu_version=4.0.6 - rei_version=9.1.530 + rei_version=9.1.550 + architectury_override_version=6.2.46 diff --git a/src/main/resources/quilt.mod.json b/src/main/resources/quilt.mod.json index 86ae6133..3a1fb8d1 100644 --- a/src/main/resources/quilt.mod.json +++ b/src/main/resources/quilt.mod.json @@ -20,7 +20,9 @@ "intermediate_mappings": "net.fabricmc:intermediary", "entrypoints": { "init": "com.github.platymemo.alaskanativecraft.AlaskaNativeCraft", - "client_init": "com.github.platymemo.alaskanativecraft.AlaskaNativeCraftClient" + "client_init": "com.github.platymemo.alaskanativecraft.AlaskaNativeCraftClient", + "modmenu": [ "com.github.platymemo.alaskanativecraft.compat.AlaskaModMenu" ], + "rei_client": [ "com.github.platymemo.alaskanativecraft.compat.rei.AlaskaPlugin" ] }, "depends": [ {