diff --git a/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index ed62d0fb..3eb4c973 100644 --- a/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/common/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,4 +1,4 @@ -// 1.20.4 2024-01-01T08:38:05.3377628 Recipes +// 1.20.4 2024-01-02T15:35:08.8489587 Recipes 09252bd5a872203de304820e8d5c5493afe96cf4 data/toughasnails/advancements/recipes/combat/leaf_boots.json 2da825265e95f5dfc0dd4026e0dafee70c17512c data/toughasnails/advancements/recipes/combat/leaf_chestplate.json 6d96cd4baff66d426c9405852ceed3aa8a3cde8f data/toughasnails/advancements/recipes/combat/leaf_helmet.json @@ -18,6 +18,7 @@ db0a08a7c6ccc69ca4625db57d678ce644fdfe49 data/toughasnails/advancements/recipes/ 1b3828862b65dcfb0a1e6d99070287e896379558 data/toughasnails/advancements/recipes/food/sweet_berry_juice.json 12ff7cdfde84ded584c6dd340468d1ea34b2afa1 data/toughasnails/advancements/recipes/redstone/temperature_gauge.json 8b0e1899a965cbcf725172709f9f7f7062c43a5c data/toughasnails/advancements/recipes/tools/empty_canteen.json +9ce52988e0ffa4ebd960125423c6dc331a72aadd data/toughasnails/advancements/recipes/tools/thermometer.json 715184d6dfbadc65234a787d2e8271dce076e7b1 data/toughasnails/recipes/apple_juice.json 7aefc36c9cb1e7393660e57c9bfe2f47e9c472b9 data/toughasnails/recipes/cactus_juice.json c03137fedf80a5cea96fa69ecc23ddcc733b02bf data/toughasnails/recipes/chorus_fruit_juice.json @@ -35,6 +36,7 @@ e4a98b0325be4fb27194eb56a079871cdc8d4114 data/toughasnails/recipes/pumpkin_juice 454a67d0df9042690154a1b3b372a5fff586b47d data/toughasnails/recipes/rain_collector.json 2512026dc3a027f39db7e77e023a7017de386b9c data/toughasnails/recipes/sweet_berry_juice.json 114b28980e7fe554a5d673093f323d73b4497447 data/toughasnails/recipes/temperature_gauge.json +b75d1caa0b1dcb9ae14dc02e47bba2a3c4b4a4dc data/toughasnails/recipes/thermometer.json 9e06d792260bac7da2725c0b4ab95e165f6ffbec data/toughasnails/recipes/water_canteen.json 26985bc2361f55479fce0f342c9c2b7573237c7f data/toughasnails/recipes/water_purifier.json 30229579a58927cae7011781b0936f7ca87888a4 data/toughasnails/recipes/wool_boots.json diff --git a/common/src/generated/resources/.cache/cee4a031f97c8b7c81810a1ed20819f05a390a91 b/common/src/generated/resources/.cache/cee4a031f97c8b7c81810a1ed20819f05a390a91 new file mode 100644 index 00000000..335cf3ee --- /dev/null +++ b/common/src/generated/resources/.cache/cee4a031f97c8b7c81810a1ed20819f05a390a91 @@ -0,0 +1,23 @@ +// 1.20.4 2024-01-02T13:56:32.5236813 Item Models: toughasnails +ce273d4a6776e0951a77c06d990ff960e28f66f5 assets/toughasnails/models/item/thermometer.json +0fbb3edc334b05d5f3657d01ad0444da28d830ec assets/toughasnails/models/item/thermometer_00.json +f90715b0138223634226f703377c9210440ebba4 assets/toughasnails/models/item/thermometer_01.json +440c2d22c0b439446b29607c91a0f59c109a2ac9 assets/toughasnails/models/item/thermometer_02.json +2907ac0ae691401c03c0ca68d12a9957a001acdb assets/toughasnails/models/item/thermometer_03.json +c52014a435b97758257ab34348feb7ff1e84ae40 assets/toughasnails/models/item/thermometer_04.json +95e6ab7ba41753eb89e2b6734b3f65f67a516fea assets/toughasnails/models/item/thermometer_05.json +6f9f7308638335f6d22deed54f58af41d80d57ac assets/toughasnails/models/item/thermometer_06.json +650c231de872dafeefafe2178f68bbf11db28577 assets/toughasnails/models/item/thermometer_07.json +17be302c23083a79a0737442f263d8a90ba9a082 assets/toughasnails/models/item/thermometer_08.json +2f20e8f45b4bbffe275eb3cf833adc221afc27b7 assets/toughasnails/models/item/thermometer_09.json +78599b8e101dce74c1a8b35fa0f329493e0b2500 assets/toughasnails/models/item/thermometer_10.json +dd8bfe31c24513ada71c632b77b9ece6d1c59c1a assets/toughasnails/models/item/thermometer_11.json +aa47031765274df8d84141ce6ee6723a4d0d0152 assets/toughasnails/models/item/thermometer_12.json +717bda823c19584c4d1f0d4e6ad8776d3ca0dada assets/toughasnails/models/item/thermometer_13.json +3e152a20f652e3ae96905168bc5fdb9cc38e4c58 assets/toughasnails/models/item/thermometer_14.json +678f08f1c7738e468f663117f0c3e7ee736c7fe3 assets/toughasnails/models/item/thermometer_15.json +f330be7df4b6985d0c83fd154ad528cc1eeee767 assets/toughasnails/models/item/thermometer_16.json +62e6066b57cdaafc3c70c415cf98e3f9387d2a43 assets/toughasnails/models/item/thermometer_17.json +a90d31153bbc8e7d36dcb024c10e4c0a2b27e7bf assets/toughasnails/models/item/thermometer_18.json +0f27a70b4dddfcf0598b74f6f02b86be202ca464 assets/toughasnails/models/item/thermometer_19.json +e0508d7e82ef472eff6f73f7a8a92a54094cbd41 assets/toughasnails/models/item/thermometer_20.json diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer.json new file mode 100644 index 00000000..20db79cc --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer.json @@ -0,0 +1,131 @@ +{ + "parent": "minecraft:item/generated", + "overrides": [ + { + "model": "toughasnails:item/thermometer_00", + "predicate": { + "toughasnails:temperature": 0.0 + } + }, + { + "model": "toughasnails:item/thermometer_01", + "predicate": { + "toughasnails:temperature": 0.05 + } + }, + { + "model": "toughasnails:item/thermometer_02", + "predicate": { + "toughasnails:temperature": 0.1 + } + }, + { + "model": "toughasnails:item/thermometer_03", + "predicate": { + "toughasnails:temperature": 0.15 + } + }, + { + "model": "toughasnails:item/thermometer_04", + "predicate": { + "toughasnails:temperature": 0.2 + } + }, + { + "model": "toughasnails:item/thermometer_05", + "predicate": { + "toughasnails:temperature": 0.25 + } + }, + { + "model": "toughasnails:item/thermometer_06", + "predicate": { + "toughasnails:temperature": 0.3 + } + }, + { + "model": "toughasnails:item/thermometer_07", + "predicate": { + "toughasnails:temperature": 0.35 + } + }, + { + "model": "toughasnails:item/thermometer_08", + "predicate": { + "toughasnails:temperature": 0.4 + } + }, + { + "model": "toughasnails:item/thermometer_09", + "predicate": { + "toughasnails:temperature": 0.45 + } + }, + { + "model": "toughasnails:item/thermometer_10", + "predicate": { + "toughasnails:temperature": 0.5 + } + }, + { + "model": "toughasnails:item/thermometer_11", + "predicate": { + "toughasnails:temperature": 0.55 + } + }, + { + "model": "toughasnails:item/thermometer_12", + "predicate": { + "toughasnails:temperature": 0.6 + } + }, + { + "model": "toughasnails:item/thermometer_13", + "predicate": { + "toughasnails:temperature": 0.65 + } + }, + { + "model": "toughasnails:item/thermometer_14", + "predicate": { + "toughasnails:temperature": 0.7 + } + }, + { + "model": "toughasnails:item/thermometer_15", + "predicate": { + "toughasnails:temperature": 0.75 + } + }, + { + "model": "toughasnails:item/thermometer_16", + "predicate": { + "toughasnails:temperature": 0.8 + } + }, + { + "model": "toughasnails:item/thermometer_17", + "predicate": { + "toughasnails:temperature": 0.85 + } + }, + { + "model": "toughasnails:item/thermometer_18", + "predicate": { + "toughasnails:temperature": 0.9 + } + }, + { + "model": "toughasnails:item/thermometer_19", + "predicate": { + "toughasnails:temperature": 0.95 + } + }, + { + "model": "toughasnails:item/thermometer_20", + "predicate": { + "toughasnails:temperature": 1.0 + } + } + ] +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_00.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_00.json new file mode 100644 index 00000000..63a85688 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_00.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_00" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_01.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_01.json new file mode 100644 index 00000000..14cdebc9 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_01.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_01" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_02.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_02.json new file mode 100644 index 00000000..04fd3a0a --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_02.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_02" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_03.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_03.json new file mode 100644 index 00000000..a72778d1 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_03.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_03" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_04.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_04.json new file mode 100644 index 00000000..8ad7a232 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_04.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_04" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_05.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_05.json new file mode 100644 index 00000000..9ad9d641 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_05.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_05" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_06.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_06.json new file mode 100644 index 00000000..76378ded --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_06.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_06" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_07.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_07.json new file mode 100644 index 00000000..8b99cb1f --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_07.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_07" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_08.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_08.json new file mode 100644 index 00000000..37bfce7c --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_08.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_08" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_09.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_09.json new file mode 100644 index 00000000..02fdafb9 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_09.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_09" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_10.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_10.json new file mode 100644 index 00000000..3cd5dd2d --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_10.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_10" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_11.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_11.json new file mode 100644 index 00000000..37683d2e --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_11.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_11" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_12.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_12.json new file mode 100644 index 00000000..ad7d70b9 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_12.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_12" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_13.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_13.json new file mode 100644 index 00000000..e8408654 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_13.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_13" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_14.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_14.json new file mode 100644 index 00000000..b9317ae2 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_14.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_14" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_15.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_15.json new file mode 100644 index 00000000..0ad823f6 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_15.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_15" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_16.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_16.json new file mode 100644 index 00000000..cd826ddd --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_16.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_16" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_17.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_17.json new file mode 100644 index 00000000..bd23f292 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_17.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_17" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_18.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_18.json new file mode 100644 index 00000000..64dd3b13 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_18.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_18" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_19.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_19.json new file mode 100644 index 00000000..29b79ed0 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_19.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_19" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/assets/toughasnails/models/item/thermometer_20.json b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_20.json new file mode 100644 index 00000000..547bbf67 --- /dev/null +++ b/common/src/generated/resources/assets/toughasnails/models/item/thermometer_20.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/generated", + "textures": { + "layer0": "toughasnails:item/thermometer_20" + } +} \ No newline at end of file diff --git a/common/src/generated/resources/data/toughasnails/advancements/recipes/tools/thermometer.json b/common/src/generated/resources/data/toughasnails/advancements/recipes/tools/thermometer.json new file mode 100644 index 00000000..d9c8d4cc --- /dev/null +++ b/common/src/generated/resources/data/toughasnails/advancements/recipes/tools/thermometer.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_redstone": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:redstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "toughasnails:thermometer" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "has_redstone" + ] + ], + "rewards": { + "recipes": [ + "toughasnails:thermometer" + ] + } +} \ No newline at end of file diff --git a/common/src/generated/resources/data/toughasnails/recipes/thermometer.json b/common/src/generated/resources/data/toughasnails/recipes/thermometer.json new file mode 100644 index 00000000..d857607c --- /dev/null +++ b/common/src/generated/resources/data/toughasnails/recipes/thermometer.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "equipment", + "key": { + "#": { + "item": "minecraft:copper_ingot" + }, + "X": { + "item": "minecraft:redstone" + } + }, + "pattern": [ + " # ", + "#X#", + " # " + ], + "result": { + "item": "toughasnails:thermometer" + } +} \ No newline at end of file diff --git a/common/src/main/java/toughasnails/api/item/TANItems.java b/common/src/main/java/toughasnails/api/item/TANItems.java index d187c24a..0abfdaa9 100644 --- a/common/src/main/java/toughasnails/api/item/TANItems.java +++ b/common/src/main/java/toughasnails/api/item/TANItems.java @@ -35,6 +35,8 @@ public class TANItems public static Item LEAF_LEGGINGS; public static Item LEAF_BOOTS; + public static Item THERMOMETER; + public static Item TAN_ICON; // Block items diff --git a/common/src/main/java/toughasnails/init/ModItems.java b/common/src/main/java/toughasnails/init/ModItems.java index 30b07ec4..aca32f15 100644 --- a/common/src/main/java/toughasnails/init/ModItems.java +++ b/common/src/main/java/toughasnails/init/ModItems.java @@ -5,13 +5,24 @@ package toughasnails.init; import glitchcore.event.client.RegisterColorsEvent; +import glitchcore.util.Environment; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.item.ClampedItemPropertyFunction; +import net.minecraft.client.renderer.item.ItemProperties; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.Nullable; import toughasnails.api.TANAPI; import toughasnails.api.block.TANBlocks; import toughasnails.api.item.TANItems; +import toughasnails.api.temperature.TemperatureHelper; +import toughasnails.api.temperature.TemperatureLevel; import toughasnails.core.ToughAsNails; import toughasnails.item.*; @@ -47,11 +58,18 @@ public static void registerItems(BiConsumer func) TANItems.LEAF_LEGGINGS = register(func, "leaf_leggings", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.LEGGINGS, (new Item.Properties()))); TANItems.LEAF_BOOTS = register(func, "leaf_boots", new LeafArmorItem(ModArmorMaterials.LEAF, ArmorItem.Type.BOOTS, (new Item.Properties()))); + TANItems.THERMOMETER = register(func, "thermometer", new Item(new Item.Properties().stacksTo(1))); + TANItems.TAN_ICON = register(func, "tan_icon", new Item(new Item.Properties())); TANItems.TEMPERATURE_GAUGE = register(func, "temperature_gauge", new BlockItem(TANBlocks.TEMPERATURE_GAUGE, new Item.Properties())); TANItems.RAIN_COLLECTOR = register(func, "rain_collector", new BlockItem(TANBlocks.RAIN_COLLECTOR, new Item.Properties())); TANItems.WATER_PURIFIER = register(func, "water_purifier", new BlockItem(TANBlocks.WATER_PURIFIER, new Item.Properties())); + + if (Environment.isClient()) + { + registerItemProperties(); + } } public static void registerItemColors(RegisterColorsEvent.Item event) @@ -65,6 +83,48 @@ public static void registerItemColors(RegisterColorsEvent.Item event) }, TANItems.LEAF_HELMET, TANItems.LEAF_CHESTPLATE, TANItems.LEAF_LEGGINGS, TANItems.LEAF_BOOTS); } + private static void registerItemProperties() + { + ItemProperties.register(TANItems.THERMOMETER, new ResourceLocation(ToughAsNails.MOD_ID, "temperature"), new ClampedItemPropertyFunction() { + private double currentValue; + private double rota; + private long lastUpdateTick; + + @Override + public float unclampedCall(ItemStack stack, @Nullable ClientLevel level, @Nullable LivingEntity entity, int seed) + { + Entity holder = entity != null ? entity : stack.getEntityRepresentation(); + + if (holder == null) + return 0.0F; + + if (level == null && holder.level() instanceof ClientLevel) + level = (ClientLevel)holder.level(); + + if (level == null) + return 0.0F; + + TemperatureLevel temperatureLevel = TemperatureHelper.getTemperatureAtPos(level, holder.blockPosition()); + double targetValue = temperatureLevel.ordinal() * 0.25; + + if (level.getGameTime() != this.lastUpdateTick) { + this.lastUpdateTick = level.getGameTime(); + double delta = targetValue - this.currentValue; + + // Add a small increment to the rota to move towards the target value + this.rota += delta * 0.1; + + // Diminish the rota over time. The clock uses 0.9, but we want slightly less wobbling + this.rota *= 0.87; + this.currentValue = Mth.clamp(this.currentValue + this.rota, 0.0, 1.0); + } + + // Round to the nearest 0.05 + return (float)((double)Math.round(this.currentValue * 20.0) / 20.0); + } + }); + } + private static Item register(BiConsumer func, String name, Item item) { func.accept(new ResourceLocation(TANAPI.MOD_ID, name), item); diff --git a/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java b/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java index 8de5c04b..655692f3 100644 --- a/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java +++ b/common/src/main/java/toughasnails/temperature/TemperatureHelperImpl.java @@ -22,6 +22,7 @@ import toughasnails.api.potion.TANEffects; import toughasnails.api.temperature.*; import toughasnails.api.temperature.IProximityBlockModifier.Type; +import toughasnails.core.ToughAsNails; import toughasnails.init.ModConfig; import toughasnails.init.ModTags; @@ -30,7 +31,7 @@ public class TemperatureHelperImpl implements TemperatureHelper.Impl.ITemperatureHelper { - protected static List positionalModifiers = Lists.newArrayList(TemperatureHelperImpl::altitudeModifier); + protected static List positionalModifiers = Lists.newArrayList(TemperatureHelperImpl::altitudeModifier, TemperatureHelperImpl::rainModifier); protected static List proximityModifiers = new ArrayList<>(); protected static List playerModifiers = Lists.newArrayList(TemperatureHelperImpl::immersionModifier); @@ -49,14 +50,10 @@ public TemperatureLevel getTemperatureAtPos(Level level, BlockPos pos) return proximityModifier(level, pos, temperature); } - private static ITemperature lastTemperature; - @Override public ITemperature getPlayerTemperature(Player player) { - ITemperature temperature = ((ITANPlayer)player).getTemperatureData(); - lastTemperature = temperature; - return temperature; + return ((ITANPlayer)player).getTemperatureData(); } @Override @@ -143,6 +140,21 @@ private static TemperatureLevel altitudeModifier(Level level, BlockPos pos, Temp return current; } + private static TemperatureLevel rainModifier(Level level, BlockPos pos, TemperatureLevel current) + { + Holder biome = level.getBiome(pos); + + if (isExposedToRain(level, pos)) + { + if (coldEnoughToSnow(level, biome, pos)) + current = current.increment(ModConfig.temperature.snowTemperatureChange); + else + current = current.increment(ModConfig.temperature.wetTemperatureChange); + } + + return current; + } + private static TemperatureLevel nightModifier(Level level, BlockPos pos, TemperatureLevel current) { // Drop the temperature during the night @@ -302,14 +314,10 @@ private static TemperatureLevel immersionModifier(Player player, TemperatureLeve if (player.isOnFire()) current = current.increment(ModConfig.temperature.onFireTemperatureChange); if (player.isInPowderSnow) current = current.increment(ModConfig.temperature.powderSnowTemperatureChange); - if (player.level().isRaining() && player.level().canSeeSky(pos)) { + if (isExposedToRain(level, pos)) + { + // Only set the dry ticks here, as the temperature change associated with rain has already been handled by the positional modifier temperature.setDryTicks(0); - Holder biome = player.level().getBiome(pos); - - if (coldEnoughToSnow(player.level(), biome, pos)) - current = current.increment(ModConfig.temperature.snowTemperatureChange); - else - current.increment(ModConfig.temperature.wetTemperatureChange); } else if (!(player.getRootVehicle() instanceof Boat) && (player.isInWater() || level.getFluidState(pos).is(FluidTags.WATER))) { @@ -376,6 +384,11 @@ protected static TemperatureLevel internalModifier(Player player, TemperatureLev return current; } + private static boolean isExposedToRain(Level level, BlockPos pos) + { + return level.isRaining() && level.canSeeSky(pos); + } + private static boolean coldEnoughToSnow(Level level, Holder biome, BlockPos pos) { return biome.value().coldEnoughToSnow(pos); diff --git a/common/src/main/resources/toughasnails.accesswidener b/common/src/main/resources/toughasnails.accesswidener index a61da2db..9ec6d752 100644 --- a/common/src/main/resources/toughasnails.accesswidener +++ b/common/src/main/resources/toughasnails.accesswidener @@ -12,6 +12,9 @@ accessible method net/minecraft/world/effect/MobEffect (Lnet/minecraft/wo # Block entity registration accessible class net/minecraft/world/level/block/entity/BlockEntityType$BlockEntitySupplier +# Item property registration +accessible method net/minecraft/client/renderer/item/ItemProperties register (Lnet/minecraft/world/item/Item;Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/renderer/item/ClampedItemPropertyFunction;)V + # Potion registration accessible method net/minecraft/world/item/alchemy/PotionBrewing addMix (Lnet/minecraft/world/item/alchemy/Potion;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/alchemy/Potion;)V diff --git a/forge/src/main/java/toughasnails/datagen/DataGenerationHandler.java b/forge/src/main/java/toughasnails/datagen/DataGenerationHandler.java index 10081f30..6df2a5e2 100644 --- a/forge/src/main/java/toughasnails/datagen/DataGenerationHandler.java +++ b/forge/src/main/java/toughasnails/datagen/DataGenerationHandler.java @@ -53,6 +53,9 @@ public static void onGatherData(GatherDataEvent event) generator.addProvider(event.includeServer(), new TANItemTagsProvider(output, datapackProvider.getRegistryProvider(), blocksTagProvider.contentsGetter(), existingFileHelper)); generator.addProvider(event.includeServer(), new TANBiomeTagsProvider(output, datapackProvider.getRegistryProvider(), existingFileHelper)); generator.addProvider(event.includeServer(), new TANDamageTypeTagsProvider(output, datapackProvider.getRegistryProvider(), existingFileHelper)); + + // Client + generator.addProvider(event.includeClient(), new TANItemModelProvider(output, existingFileHelper)); } diff --git a/forge/src/main/java/toughasnails/datagen/provider/TANItemModelProvider.java b/forge/src/main/java/toughasnails/datagen/provider/TANItemModelProvider.java new file mode 100644 index 00000000..3c701a46 --- /dev/null +++ b/forge/src/main/java/toughasnails/datagen/provider/TANItemModelProvider.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright 2023, the Glitchfiend Team. + * All rights reserved. + ******************************************************************************/ +package toughasnails.datagen.provider; + +import net.minecraft.data.PackOutput; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.client.model.generators.ItemModelProvider; +import net.minecraftforge.client.model.generators.ModelFile; +import net.minecraftforge.common.data.ExistingFileHelper; +import toughasnails.core.ToughAsNails; + +public class TANItemModelProvider extends ItemModelProvider +{ + private static final int NUM_THERMOMETER_MODELS = 21; + + public TANItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) + { + super(output, ToughAsNails.MOD_ID, existingFileHelper); + } + + @Override + protected void registerModels() + { + this.registerThermometerModels(); + } + + private void registerThermometerModels() + { + var thermometer = getBuilder(loc("thermometer").toString()).parent(new ModelFile.UncheckedModelFile("item/generated")); + ModelFile[] thermometerModels = new ModelFile[NUM_THERMOMETER_MODELS]; + + // Populate standard and tropical arrays + for (int i = 0; i < NUM_THERMOMETER_MODELS; i++) + { + String pathIndex = String.format("%02d", i); + thermometerModels[i] = this.basicItem(loc("thermometer_" + pathIndex)); + } + + // Thermometer overrides + for (int i = 0; i < NUM_THERMOMETER_MODELS; i++) + { + thermometer.override() + .predicate(loc("temperature"), (float)i / (float)(NUM_THERMOMETER_MODELS - 1)) + .model(thermometerModels[i]); + } + } + + private static ResourceLocation loc(String name) + { + return new ResourceLocation(ToughAsNails.MOD_ID, name); + } +} diff --git a/forge/src/main/java/toughasnails/datagen/provider/TANRecipeProvider.java b/forge/src/main/java/toughasnails/datagen/provider/TANRecipeProvider.java index 647b15c0..0bd78ce6 100644 --- a/forge/src/main/java/toughasnails/datagen/provider/TANRecipeProvider.java +++ b/forge/src/main/java/toughasnails/datagen/provider/TANRecipeProvider.java @@ -52,6 +52,8 @@ protected void buildRecipes(RecipeOutput output) ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, TANItems.WOOL_HELMET).define('X', ItemTags.WOOL).pattern("XXX").pattern("X X").unlockedBy("has_wool", has(ItemTags.WOOL)).save(output); ShapedRecipeBuilder.shaped(RecipeCategory.COMBAT, TANItems.WOOL_LEGGINGS).define('X', ItemTags.WOOL).pattern("XXX").pattern("X X").pattern("X X").unlockedBy("has_wool", has(ItemTags.WOOL)).save(output); + ShapedRecipeBuilder.shaped(RecipeCategory.TOOLS, TANItems.THERMOMETER).define('#', Items.COPPER_INGOT).define('X', Items.REDSTONE).pattern(" # ").pattern("#X#").pattern(" # ").unlockedBy("has_redstone", has(Items.REDSTONE)).save(output); + // // Water purification recipes //