From 63ac21b62f1336d89f905c20dfcf50645b4617cb Mon Sep 17 00:00:00 2001 From: David Troyer Date: Tue, 6 Oct 2020 18:55:39 -0700 Subject: [PATCH] Wendigoism Integration, Added Autoconfig, Nerfed Heart --- build.gradle | 20 +++- gradle.properties | 8 +- .../net/tigereye/chestcavity/ChestCavity.java | 10 +- .../tigereye/chestcavity/config/CCConfig.java | 23 ++++ .../config/CCModMenuIntegration.java | 18 ++++ .../chestcavity/crossmod/CrossModContent.java | 26 +++++ .../wendigoism/CCWendigoismItems.java | 53 +++++++++ .../wendigoism/CCWendigoismListeners.java | 101 ++++++++++++++++++ .../wendigoism/TetheredCannibalHeart.java | 49 +++++++++ .../chestcavity/items/ChestCavityOrgan.java | 3 + .../tigereye/chestcavity/items/OrganBase.java | 9 +- .../listeners/ChestCavityListener.java | 6 +- .../chestcavity/listeners/LootRegister.java | 12 +-- .../listeners/OrganTickListeners.java | 14 ++- .../listeners/OrganUpdateListeners.java | 27 ++++- .../chestcavity/mixin/MixinPlayerEntity.java | 42 ++++---- .../assets/chestcavity/lang/en_us.json | 15 ++- .../models/item/cannibal_heart.json | 6 ++ .../models/item/tethered_cannibal_heart.json | 6 ++ .../recipes/wendigoism_cannibal_heart.json | 15 +++ .../wendigoism_salvage_human_organ.json | 15 +++ .../wendigoism_tethered_cannibal_heart.json | 15 +++ .../tags/items/salvageable_human_organs.json | 13 +++ src/main/resources/fabric.mod.json | 8 +- 24 files changed, 461 insertions(+), 53 deletions(-) create mode 100644 src/main/java/net/tigereye/chestcavity/config/CCConfig.java create mode 100644 src/main/java/net/tigereye/chestcavity/config/CCModMenuIntegration.java create mode 100644 src/main/java/net/tigereye/chestcavity/crossmod/CrossModContent.java create mode 100644 src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismItems.java create mode 100644 src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismListeners.java create mode 100644 src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/TetheredCannibalHeart.java create mode 100644 src/main/resources/assets/chestcavity/models/item/cannibal_heart.json create mode 100644 src/main/resources/assets/chestcavity/models/item/tethered_cannibal_heart.json create mode 100644 src/main/resources/data/chestcavity/recipes/wendigoism_cannibal_heart.json create mode 100644 src/main/resources/data/chestcavity/recipes/wendigoism_salvage_human_organ.json create mode 100644 src/main/resources/data/chestcavity/recipes/wendigoism_tethered_cannibal_heart.json create mode 100644 src/main/resources/data/chestcavity/tags/items/salvageable_human_organs.json diff --git a/build.gradle b/build.gradle index fe5c2c4..110d5ed 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.4-SNAPSHOT' + id 'fabric-loom' version '0.5-SNAPSHOT' id 'maven-publish' } @@ -25,11 +25,23 @@ dependencies { // Replace modImplementation with modApi if you expose components in your own API modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:2.6.0" modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.6.0" - modImplementation 'com.github.tigereye504:modify-drops-api:0.2.1' - // Includes Cardinal Components API as a Jar-in-Jar dependency (optional) + modImplementation "com.github.tigereye504:modify-drops-api:0.2.1" + modApi("me.shedaniel.cloth:config-2:4.8.2") { + exclude(group: "net.fabricmc.fabric-api") + } + modApi("me.sargunvohra.mcmods:autoconfig1u:3.2.2") { + exclude(group: "net.fabricmc.fabric-api") + } + modImplementation "io.github.prospector:modmenu:1.14.6+build.31" + // These are optional dependencies, though best as I can tell gradlew doesn't care + modImplementation "com.github.moriyashiine:wendigoism:1.16.3-1" + + // Jar-in-Jar dependencies include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:2.6.0" include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-base:2.6.0" - include 'com.github.tigereye504:modify-drops-api:0.2.1' + include "com.github.tigereye504:modify-drops-api:0.2.1" + include "me.shedaniel.cloth:config-2:4.8.2" + include "me.sargunvohra.mcmods:autoconfig1u:3.2.2" } repositories { diff --git a/gradle.properties b/gradle.properties index 9bf39c9..ff407f1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,14 +4,14 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use minecraft_version=1.16.3 - yarn_mappings=1.16.3+build.1 - loader_version=0.9.3+build.207 + yarn_mappings=1.16.3+build.28 + loader_version=0.10.1+build.209 # Mod Properties - mod_version = 1.2.5 + mod_version = 1.3.0 maven_group = net.tigereye.chestcavity archives_base_name = chestcavity # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.20.2+build.402-1.16 + fabric_version=0.23.0+build.410-1.16 diff --git a/src/main/java/net/tigereye/chestcavity/ChestCavity.java b/src/main/java/net/tigereye/chestcavity/ChestCavity.java index a1d6b1f..d08e969 100644 --- a/src/main/java/net/tigereye/chestcavity/ChestCavity.java +++ b/src/main/java/net/tigereye/chestcavity/ChestCavity.java @@ -1,7 +1,11 @@ package net.tigereye.chestcavity; +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer; import net.tigereye.chestcavity.components.CCComponent; import net.tigereye.chestcavity.components.InventoryComponent; +import net.tigereye.chestcavity.config.CCConfig; +import net.tigereye.chestcavity.crossmod.CrossModContent; import net.tigereye.chestcavity.items.*; import net.tigereye.chestcavity.listeners.LootRegister; import nerdhub.cardinal.components.api.ComponentRegistry; @@ -16,8 +20,8 @@ public class ChestCavity implements ModInitializer { public static final String MODID = "chestcavity"; public static final boolean DEBUG_MODE = false; + public static CCConfig config; - //public static final ComponentKey INVENTORY_COMPONENT = ComponentRegistry.INSTANCE.registerStatic(new Identifier("chestcavity","inventory_component"), InventoryComponent.class); public static final ComponentType INVENTORYCOMPONENT = ComponentRegistry.INSTANCE.registerIfAbsent(new Identifier("chestcavity:inventorycomponent"), InventoryComponent.class); @@ -25,12 +29,14 @@ public class ChestCavity implements ModInitializer { @Override public void onInitialize() { //Register mod resources + AutoConfig.register(CCConfig.class, GsonConfigSerializer::new); + config = AutoConfig.getConfigHolder(CCConfig.class).getConfig(); CCItems.register(); EntityComponentCallback.event(PlayerEntity.class).register((player, components) -> components.put(INVENTORYCOMPONENT, new CCComponent(player))); LootRegister.register(); OrganUpdateListeners.register(); OrganTickListeners.register(); VanillaOrgans.init(); - + CrossModContent.register(); } } diff --git a/src/main/java/net/tigereye/chestcavity/config/CCConfig.java b/src/main/java/net/tigereye/chestcavity/config/CCConfig.java new file mode 100644 index 0000000..78cb061 --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/config/CCConfig.java @@ -0,0 +1,23 @@ +package net.tigereye.chestcavity.config; + +import me.sargunvohra.mcmods.autoconfig1u.ConfigData; +import me.sargunvohra.mcmods.autoconfig1u.annotation.Config; +import net.tigereye.chestcavity.ChestCavity; + +@Config(name = ChestCavity.MODID) +public class CCConfig implements ConfigData { + public float ORGAN_BUNDLE_DROP_RATE = .025f; + public float ORGAN_BUNDLE_LOOTING_BOOST = .01f; + + + public int HEARTBLEED_RATE = 20; //how fast you die from lacking a heart in ticks + public int LIVER_RATE = 40; //how often the liver purifies status effects in ticks + public int KIDNEY_RATE = 59; //how often the kidneys prevent blood poisoning in ticks + //avoid clean multiples or factors of LIVER_SPEED to avoid strange sweet or sour spots in kidney/liver scores. + public float APPENDIX_LUCK = .1f; //how lucky your appendix is + public float HEART_HP = 4; //how much health each heart is worth + public float MUSCLE_STRENGTH = 1f; //how much 8 stacks of muscles contribute to attack damage + public float MUSCLE_SPEED = .5f; //how much 8 stacks of muscles contribute to movement speed + + public boolean WENDIGOISM_INTEGRATION = true; +} diff --git a/src/main/java/net/tigereye/chestcavity/config/CCModMenuIntegration.java b/src/main/java/net/tigereye/chestcavity/config/CCModMenuIntegration.java new file mode 100644 index 0000000..c475967 --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/config/CCModMenuIntegration.java @@ -0,0 +1,18 @@ +package net.tigereye.chestcavity.config; + +import io.github.prospector.modmenu.api.ConfigScreenFactory; +import io.github.prospector.modmenu.api.ModMenuApi; +import me.sargunvohra.mcmods.autoconfig1u.AutoConfig; +import net.tigereye.chestcavity.ChestCavity; + +public class CCModMenuIntegration implements ModMenuApi { + @Override + public String getModId() { + return ChestCavity.MODID; // Return your modid here + } + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> AutoConfig.getConfigScreen(CCConfig.class, parent).get(); + } +} \ No newline at end of file diff --git a/src/main/java/net/tigereye/chestcavity/crossmod/CrossModContent.java b/src/main/java/net/tigereye/chestcavity/crossmod/CrossModContent.java new file mode 100644 index 0000000..db974ec --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/crossmod/CrossModContent.java @@ -0,0 +1,26 @@ +package net.tigereye.chestcavity.crossmod; + +import net.fabricmc.loader.api.FabricLoader; +import net.tigereye.chestcavity.ChestCavity; +import net.tigereye.chestcavity.crossmod.wendigoism.CCWendigoismItems; +import net.tigereye.chestcavity.crossmod.wendigoism.CCWendigoismListeners; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class CrossModContent { + public static final Logger LOGGER = LogManager.getLogger(); + + public static void register(){ + if (FabricLoader.getInstance().isModLoaded("wendigoism")){ + LOGGER.info("[Chest Cavity] Wendigoism Detected!"); + if(ChestCavity.config.WENDIGOISM_INTEGRATION) { + LOGGER.info("[Chest Cavity] Integrating with Wendigoism"); + CCWendigoismItems.register(); + CCWendigoismListeners.register(); + } + else{ + LOGGER.info("[Chest Cavity] Wendigoism integration has been disabled in the config."); + } + } + } +} diff --git a/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismItems.java b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismItems.java new file mode 100644 index 0000000..4fce212 --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismItems.java @@ -0,0 +1,53 @@ +package net.tigereye.chestcavity.crossmod.wendigoism; + +import moriyashiine.wendigoism.common.Wendigoism; +import moriyashiine.wendigoism.common.registry.WDItems; +import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; +import net.minecraft.item.Item; +import net.minecraft.util.Identifier; +import net.minecraft.util.registry.Registry; +import net.tigereye.chestcavity.ChestCavity; +import net.tigereye.chestcavity.items.CCItems; +import net.tigereye.chestcavity.items.OrganBase; +import net.tigereye.chestcavity.items.VanillaOrgans; +import net.tigereye.chestcavity.listeners.OrganTickCallback; + +import java.util.HashMap; +import java.util.Map; + +public class CCWendigoismItems { + public static final Identifier ORGANS_CANNIBAL_HEART = new Identifier(ChestCavity.MODID, "organs_cannibal_heart"); + public static final Identifier ORGANS_TETHERED_CANNIBAL_HEART = new Identifier(ChestCavity.MODID, "organs_tethered_cannibal_heart"); + + public static final Item CANNIBAL_HEART = new OrganBase() + .setOrganQuality(CCItems.ORGANS_HEART,.5f) + .setOrganQuality(ORGANS_CANNIBAL_HEART,1); + public static final Item TETHERED_CANNIBAL_HEART = new TetheredCannibalHeart() + .setOrganQuality(CCItems.ORGANS_HEART,.75f) + .setOrganQuality(ORGANS_TETHERED_CANNIBAL_HEART,1); + + public static void register() { + registerItem("cannibal_heart", CANNIBAL_HEART); + registerItem("tethered_cannibal_heart", TETHERED_CANNIBAL_HEART); + + RegistryEntryAddedCallback.event(Registry.ITEM).register(CCWendigoismItems::addWindegoismHeartsToExternalOrgans); + } + + private static void registerItem(String name, Item item) { + Registry.register(Registry.ITEM, ChestCavity.MODID + ":" + name, item); + } + + private static void addWindegoismHeartsToExternalOrgans(int i, Identifier identifier, Item item) { + if(item == WDItems.FLESH){ + Map flesh = new HashMap<>(); + flesh.put(CCItems.ORGANS_MUSCLE,.75f); + VanillaOrgans.map.put(WDItems.FLESH,flesh); + } + if(item == WDItems.CORRUPT_FLESH){ + Map corruptedFlesh = new HashMap<>(); + corruptedFlesh.put(CCItems.ORGANS_MUSCLE,1f); + VanillaOrgans.map.put(WDItems.CORRUPT_FLESH,corruptedFlesh); + } + } + +} diff --git a/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismListeners.java b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismListeners.java new file mode 100644 index 0000000..b4fc18a --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismListeners.java @@ -0,0 +1,101 @@ +package net.tigereye.chestcavity.crossmod.wendigoism; + +import moriyashiine.wendigoism.api.accessor.WendigoAccessor; +import net.minecraft.entity.attribute.EntityAttributeInstance; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.Identifier; +import net.tigereye.chestcavity.ChestCavity; +import net.tigereye.chestcavity.listeners.ChestCavityListener; +import net.tigereye.chestcavity.listeners.OrganTickCallback; +import net.tigereye.chestcavity.listeners.OrganUpdateCallback; + +import java.util.Map; +import java.util.UUID; + +public class CCWendigoismListeners { + private static final Identifier WENDIGOISM_TRACKER = new Identifier(ChestCavity.MODID, "wendigoism_tracker"); + public static final Identifier WENDIGOISM_TARGET = new Identifier(ChestCavity.MODID, "wendigoism_target"); + private static final UUID cannibalHeartID = UUID.fromString("140317b9-74be-40cb-802e-95971fbc6d29"); + + private static final float BONUS_HEART_PER_100_WENDIGOISM = .25f; + + public static void register(){ + OrganUpdateCallback.EVENT.register(CCWendigoismListeners::UpdateCannibalHeart); + OrganTickCallback.EVENT.register(CCWendigoismListeners::TickTetheredCannibalHeart); + OrganTickCallback.EVENT.register(CCWendigoismListeners::TickCannibalHeart); + } + + private static void UpdateCannibalHeart(PlayerEntity player, Map oldScores, Map newScores) { + if(oldScores.getOrDefault(CCWendigoismItems.ORGANS_CANNIBAL_HEART,0f) != newScores.getOrDefault(CCWendigoismItems.ORGANS_CANNIBAL_HEART,0f)) { + SetCannibalHeartBonusHP(player, newScores.getOrDefault(CCWendigoismItems.ORGANS_CANNIBAL_HEART,0f)); + } + //this lets us detect when the user's wendigoism changes + if((!player.world.isClient()) && player instanceof WendigoAccessor && newScores.getOrDefault(CCWendigoismItems.ORGANS_CANNIBAL_HEART,0f) > 0) { + WendigoAccessor accessor = (WendigoAccessor)player; + newScores.put(WENDIGOISM_TRACKER,(float)accessor.getWendigoLevel()); + } + } + + public static void TickTetheredCannibalHeart(PlayerEntity player,ChestCavityListener chestCavity){ + if ((!player.world.isClient()) && chestCavity.getOrganScore(CCWendigoismItems.ORGANS_TETHERED_CANNIBAL_HEART) > 0 && player instanceof WendigoAccessor){ + if(chestCavity.getOrganScore(WENDIGOISM_TARGET) > ((WendigoAccessor)player).getWendigoLevel()){ + if(ChestCavity.DEBUG_MODE && ((WendigoAccessor)player).getWendigoLevel() % 10 == 0){ + System.out.println("Tethered Cabbibal Heart Increasing Wendigoism"); + } + int newWendigoismLevel = Math.min( + ((WendigoAccessor)player).getWendigoLevel() + (int)chestCavity.getOrganScore(CCWendigoismItems.ORGANS_TETHERED_CANNIBAL_HEART), + (int)chestCavity.getOrganScore(WENDIGOISM_TARGET)); + newWendigoismLevel = Math.min(newWendigoismLevel,300); + ((WendigoAccessor)player).setWendigoLevel(newWendigoismLevel); + } + else if(chestCavity.getOrganScore(WENDIGOISM_TARGET) < ((WendigoAccessor)player).getWendigoLevel()){ + if(ChestCavity.DEBUG_MODE && ((WendigoAccessor)player).getWendigoLevel() % 10 == 0){ + System.out.println("Tethered Cabbibal Heart Decreasing Wendigoism"); + } + int newWendigoismLevel = Math.max( + ((WendigoAccessor)player).getWendigoLevel() - (int)chestCavity.getOrganScore(CCWendigoismItems.ORGANS_TETHERED_CANNIBAL_HEART), + (int)chestCavity.getOrganScore(WENDIGOISM_TARGET)); + newWendigoismLevel = Math.max(newWendigoismLevel,0); + ((WendigoAccessor)player).setWendigoLevel(newWendigoismLevel); + } + } + } + public static void TickCannibalHeart(PlayerEntity player,ChestCavityListener chestCavity){ + if ((!player.world.isClient()) && chestCavity.getOrganScore(CCWendigoismItems.ORGANS_CANNIBAL_HEART) > 0 && player instanceof WendigoAccessor){ + if(chestCavity.getOrganScore(WENDIGOISM_TRACKER) != ((WendigoAccessor)player).getWendigoLevel()){ + chestCavity.setOrganScore(WENDIGOISM_TRACKER,((WendigoAccessor)player).getWendigoLevel()); + SetCannibalHeartBonusHP(player,chestCavity.getOrganScore(CCWendigoismItems.ORGANS_CANNIBAL_HEART)); + } + } + } + + private static void SetCannibalHeartBonusHP(PlayerEntity player,float CannibalHeartScore){ + EntityAttributeInstance att; + float bonusHP = 0; + try { + att = player.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH); + } + catch(NullPointerException e){ + return; + } + if(player instanceof WendigoAccessor) { + WendigoAccessor accessor = (WendigoAccessor)player; + bonusHP = ChestCavity.config.HEART_HP * BONUS_HEART_PER_100_WENDIGOISM * accessor.getWendigoLevel() + * CannibalHeartScore / 100; + } + EntityAttributeModifier mod = new EntityAttributeModifier(cannibalHeartID, "ChestCavityCannibalHeartBonusMaxHP", + bonusHP, EntityAttributeModifier.Operation.ADDITION); + ReplaceAttributeModifier(att,mod); + } + + private static void ReplaceAttributeModifier(EntityAttributeInstance att, EntityAttributeModifier mod) { + //removes any existing mod and replaces it with the updated one. + //if(att.hasModifier(mod)) + //{ + att.removeModifier(mod); + //} + att.addPersistentModifier(mod); + } +} diff --git a/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/TetheredCannibalHeart.java b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/TetheredCannibalHeart.java new file mode 100644 index 0000000..5de50b6 --- /dev/null +++ b/src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/TetheredCannibalHeart.java @@ -0,0 +1,49 @@ +package net.tigereye.chestcavity.crossmod.wendigoism; + +import moriyashiine.wendigoism.api.accessor.WendigoAccessor; +import net.minecraft.entity.Entity; +import net.minecraft.inventory.Inventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.world.World; +import net.tigereye.chestcavity.items.OrganBase; +import net.tigereye.chestcavity.listeners.OrganUpdateListeners; + +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +public class TetheredCannibalHeart extends OrganBase { + + @Override + public Map getOrganQualityMap(ItemStack item) { + if(item.getTag() == null){ + item.setTag(new CompoundTag()); + return getOrganQualityMap(); + } + if(!item.getTag().contains("wendigoism")) { + return getOrganQualityMap(); + } + Map retMap = new HashMap<>(organQualityMap); + retMap.put(CCWendigoismListeners.WENDIGOISM_TARGET,(float)item.getTag().getInt("wendigoism")); + return retMap; + } + + public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { + if(!world.isClient()){ + if(stack.getTag() == null){ + stack.setTag(new CompoundTag()); + } + if(!stack.getTag().contains("wendigoism")) { + int wendigoism = 0; + if (entity instanceof WendigoAccessor) { + WendigoAccessor accessor = (WendigoAccessor) entity; + wendigoism = accessor.getWendigoLevel(); + } + stack.getTag().putInt("wendigoism", wendigoism); + } + } + } +} diff --git a/src/main/java/net/tigereye/chestcavity/items/ChestCavityOrgan.java b/src/main/java/net/tigereye/chestcavity/items/ChestCavityOrgan.java index 085e50b..3305450 100644 --- a/src/main/java/net/tigereye/chestcavity/items/ChestCavityOrgan.java +++ b/src/main/java/net/tigereye/chestcavity/items/ChestCavityOrgan.java @@ -1,6 +1,8 @@ package net.tigereye.chestcavity.items; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.tag.Tag; import net.minecraft.util.Identifier; @@ -8,4 +10,5 @@ public interface ChestCavityOrgan { Map getOrganQualityMap(); + Map getOrganQualityMap(ItemStack item); } \ No newline at end of file diff --git a/src/main/java/net/tigereye/chestcavity/items/OrganBase.java b/src/main/java/net/tigereye/chestcavity/items/OrganBase.java index d4dfdb3..bff7716 100644 --- a/src/main/java/net/tigereye/chestcavity/items/OrganBase.java +++ b/src/main/java/net/tigereye/chestcavity/items/OrganBase.java @@ -1,15 +1,19 @@ package net.tigereye.chestcavity.items; import com.google.common.collect.Maps; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; +import net.minecraft.world.World; import java.util.Map; public class OrganBase extends Item implements ChestCavityOrgan { - private Map organQualityMap = Maps.newHashMap(); + protected Map organQualityMap = Maps.newHashMap(); public OrganBase() { @@ -23,6 +27,9 @@ public OrganBase(Item.Settings settings) { public Map getOrganQualityMap() { return organQualityMap; } + public Map getOrganQualityMap(ItemStack item) { + return getOrganQualityMap(); + } public float getOrganQuality(Identifier id) { return organQualityMap.getOrDefault(id, 0f); diff --git a/src/main/java/net/tigereye/chestcavity/listeners/ChestCavityListener.java b/src/main/java/net/tigereye/chestcavity/listeners/ChestCavityListener.java index 7fc9507..2f5fffd 100644 --- a/src/main/java/net/tigereye/chestcavity/listeners/ChestCavityListener.java +++ b/src/main/java/net/tigereye/chestcavity/listeners/ChestCavityListener.java @@ -50,7 +50,7 @@ public boolean EvaluateChestCavity(Inventory inv) { Item slotitem = slot.getItem(); if(slotitem instanceof ChestCavityOrgan){ - ((ChestCavityOrgan) slotitem).getOrganQualityMap().forEach((key,value) -> + ((ChestCavityOrgan) slotitem).getOrganQualityMap(slot).forEach((key,value) -> organScores.put(key,organScores.getOrDefault(key,0f)+(value*slot.getCount()))); } else { @@ -79,6 +79,10 @@ public boolean EvaluateChestCavity(Inventory inv) public float getOrganScore(Identifier id) { return organScores.getOrDefault(id, 0f); } + + public void setOrganScore(Identifier id, float value){ + organScores.put(id,value); + } public float applyBoneDefense(float damage){ float boneScore = organScores.getOrDefault(CCItems.ORGANS_RIB,0f) diff --git a/src/main/java/net/tigereye/chestcavity/listeners/LootRegister.java b/src/main/java/net/tigereye/chestcavity/listeners/LootRegister.java index 113cff4..293f4d6 100644 --- a/src/main/java/net/tigereye/chestcavity/listeners/LootRegister.java +++ b/src/main/java/net/tigereye/chestcavity/listeners/LootRegister.java @@ -8,14 +8,12 @@ import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.passive.WanderingTraderEntity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.loot.BinomialLootTableRange; -import net.minecraft.loot.ConstantLootTableRange; -import net.minecraft.loot.condition.*; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.util.Identifier; +import net.tigereye.chestcavity.ChestCavity; import net.tigereye.chestcavity.items.CCItems; import net.tigereye.modifydropsapi.api.LivingEntityDropLootCallback_AddDrops; @@ -47,7 +45,7 @@ public static void register(){ } if (entity instanceof ZombieEntity) { - if(random.nextFloat() < .025 + (.01f*lootingLevel)) { + if(random.nextFloat() < ChestCavity.config.ORGAN_BUNDLE_DROP_RATE + (ChestCavity.config.ORGAN_BUNDLE_LOOTING_BOOST*lootingLevel)) { LinkedList organPile = new LinkedList<>(); organPile.add(CCItems.ROTTEN_APPENDIX); organPile.add(CCItems.ROTTEN_HEART); @@ -66,7 +64,7 @@ public static void register(){ } } else if (entity instanceof SkeletonEntity) { - if(random.nextFloat() < .025 + (.01f*lootingLevel)) { + if(random.nextFloat() < ChestCavity.config.ORGAN_BUNDLE_DROP_RATE + (ChestCavity.config.ORGAN_BUNDLE_LOOTING_BOOST*lootingLevel)) { LinkedList organPile = new LinkedList<>(); organPile.add(CCItems.ROTTEN_SPINE); for(int i = 0; i < 16; i++){ @@ -81,7 +79,7 @@ else if (entity instanceof SkeletonEntity) { } } else if (entity instanceof AnimalEntity || entity instanceof AbstractPiglinEntity) { - if(random.nextFloat() < .025 + (.01f*lootingLevel)) { + if(random.nextFloat() < ChestCavity.config.ORGAN_BUNDLE_DROP_RATE + (ChestCavity.config.ORGAN_BUNDLE_LOOTING_BOOST*lootingLevel)) { LinkedList organPile = new LinkedList<>(); for(int i = 0; i < 16; i++){ organPile.add(CCItems.ANIMAL_RIB); @@ -108,7 +106,7 @@ else if (entity instanceof AnimalEntity || entity instanceof AbstractPiglinEntit } } else if (entity instanceof PatrolEntity || entity instanceof VillagerEntity || entity instanceof WanderingTraderEntity) { - if(random.nextFloat() < .025 + (.01f*lootingLevel)) { + if(random.nextFloat() < ChestCavity.config.ORGAN_BUNDLE_DROP_RATE + (ChestCavity.config.ORGAN_BUNDLE_LOOTING_BOOST*lootingLevel)) { LinkedList organPile = new LinkedList<>(); for(int i = 0; i < 16; i++){ organPile.add(CCItems.RIB); diff --git a/src/main/java/net/tigereye/chestcavity/listeners/OrganTickListeners.java b/src/main/java/net/tigereye/chestcavity/listeners/OrganTickListeners.java index b1442f9..7ceb7d8 100644 --- a/src/main/java/net/tigereye/chestcavity/listeners/OrganTickListeners.java +++ b/src/main/java/net/tigereye/chestcavity/listeners/OrganTickListeners.java @@ -5,6 +5,7 @@ import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.effect.StatusEffects; import net.minecraft.entity.player.PlayerEntity; +import net.tigereye.chestcavity.ChestCavity; import net.tigereye.chestcavity.interfaces.CCPlayerEntityInterface; import net.tigereye.chestcavity.interfaces.CCStatusEffect; import net.tigereye.chestcavity.interfaces.CCStatusEffectInstance; @@ -13,9 +14,6 @@ import java.util.Map; public class OrganTickListeners { - private static final int HEARTBLEED_SPEED = 20; //how fast you die from lacking a heart - private static final int LIVER_SPEED = 40; //how often the liver purifies status effects - private static final int KIDNEY_SPEED = 59; //how often the kidneys prevent blood poisoning, avoid clean multiples of LIVERSPEED public static void register(){ OrganTickCallback.EVENT.register(OrganTickListeners::TickHeart); @@ -29,8 +27,8 @@ public static void TickHeart(PlayerEntity player,ChestCavityListener chestCavity { int heartTimer =((CCPlayerEntityInterface)player).getCCHeartTimer()+1; ((CCPlayerEntityInterface)player).setCCHeartTimer(heartTimer); - if(heartTimer % HEARTBLEED_SPEED == 0){ - player.damage(DamageSource.STARVE, (heartTimer / HEARTBLEED_SPEED)); + if(heartTimer % ChestCavity.config.HEARTBLEED_RATE == 0){ + player.damage(DamageSource.STARVE, (heartTimer / ChestCavity.config.HEARTBLEED_RATE)); } } else{ @@ -46,7 +44,7 @@ public static void TickKidney(PlayerEntity player,ChestCavityListener chestCavit if(kidneyScore < 2) { int kidneyTimer =((CCPlayerEntityInterface)player).getCCKidneyTimer()+1; - if(kidneyTimer >= KIDNEY_SPEED){ + if(kidneyTimer >= ChestCavity.config.KIDNEY_RATE){ player.addStatusEffect(new StatusEffectInstance(StatusEffects.POISON, (int)(24*(2-kidneyScore)))); kidneyTimer = 0; } @@ -61,11 +59,11 @@ public static void TickLiver(PlayerEntity player,ChestCavityListener chestCavity float liverScore = chestCavity.getOrganScore(CCItems.ORGANS_LIVER); int newDur; int liverTimer = ((CCPlayerEntityInterface)player).getCCLiverTimer()+1; - if(liverTimer >= LIVER_SPEED && liverScore != 1) + if(liverTimer >= ChestCavity.config.LIVER_RATE && liverScore != 1) { for(Map.Entry iter : player.getActiveStatusEffects().entrySet()){ if (((CCStatusEffect)iter.getValue().getEffectType()).CC_IsHarmful()) { - newDur = Math.max(0, iter.getValue().getDuration() + Math.round(LIVER_SPEED * (1 - liverScore) / 2)); + newDur = Math.max(0, iter.getValue().getDuration() + Math.round(ChestCavity.config.LIVER_RATE * (1 - liverScore) / 2)); ((CCStatusEffectInstance) iter.getValue()).CC_setDuration(newDur); } } diff --git a/src/main/java/net/tigereye/chestcavity/listeners/OrganUpdateListeners.java b/src/main/java/net/tigereye/chestcavity/listeners/OrganUpdateListeners.java index 53b0527..ab10525 100644 --- a/src/main/java/net/tigereye/chestcavity/listeners/OrganUpdateListeners.java +++ b/src/main/java/net/tigereye/chestcavity/listeners/OrganUpdateListeners.java @@ -5,6 +5,7 @@ import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; +import net.tigereye.chestcavity.ChestCavity; import net.tigereye.chestcavity.items.CCItems; import java.util.Map; @@ -12,17 +13,35 @@ public class OrganUpdateListeners { + private static final UUID appendixID = UUID.fromString("ac606ec3-4cc3-42b5-9399-7fa8ceba8722"); private static final UUID heartID = UUID.fromString("edb1e124-a951-48bd-b711-782ec1364722"); private static final UUID muscleID1 = UUID.fromString("bf560396-9855-496e-a942-99824467e1ad"); private static final UUID muscleID2 = UUID.fromString("979aa156-3f01-45d3-8784-56185eeef96d"); private static final UUID spineID = UUID.fromString("8f56feed-589f-416f-86c5-315765d41f57"); public static void register(){ + OrganUpdateCallback.EVENT.register(OrganUpdateListeners::UpdateAppendix); OrganUpdateCallback.EVENT.register(OrganUpdateListeners::UpdateHeart); OrganUpdateCallback.EVENT.register(OrganUpdateListeners::UpdateMuscle); OrganUpdateCallback.EVENT.register(OrganUpdateListeners::UpdateSpine); } + private static void UpdateAppendix(PlayerEntity player, Map oldScores, Map newScores) { + //Update Max Health Modifier + if(oldScores.getOrDefault(CCItems.ORGANS_APPENDIX,0f) != newScores.getOrDefault(CCItems.ORGANS_APPENDIX,0f)){ + EntityAttributeInstance att; + try { + att = player.getAttributeInstance(EntityAttributes.GENERIC_LUCK); + } + catch(NullPointerException e){ + return; + } + EntityAttributeModifier mod = new EntityAttributeModifier(appendixID, "ChestCavityAppendixLuck", + (newScores.getOrDefault(CCItems.ORGANS_APPENDIX,0f)-1)* ChestCavity.config.APPENDIX_LUCK, EntityAttributeModifier.Operation.ADDITION); + ReplaceAttributeModifier(att,mod); + } + } + private static void UpdateHeart(PlayerEntity player, Map oldScores, Map newScores) { //Update Max Health Modifier if(oldScores.getOrDefault(CCItems.ORGANS_HEART,0f) != newScores.getOrDefault(CCItems.ORGANS_HEART,0f)){ @@ -34,7 +53,7 @@ private static void UpdateHeart(PlayerEntity player, Map oldS return; } EntityAttributeModifier mod = new EntityAttributeModifier(heartID, "ChestCavityHeartMaxHP", - (newScores.getOrDefault(CCItems.ORGANS_HEART,0f)*6)-6, EntityAttributeModifier.Operation.ADDITION); + (newScores.getOrDefault(CCItems.ORGANS_HEART,0f)-1)* ChestCavity.config.HEART_HP, EntityAttributeModifier.Operation.ADDITION); ReplaceAttributeModifier(att,mod); } } @@ -52,10 +71,12 @@ private static void UpdateMuscle(PlayerEntity player, Map old return; } EntityAttributeModifier mod = new EntityAttributeModifier(muscleID1, "ChestCavityMuscleAttackDamage", - (newScores.getOrDefault(CCItems.ORGANS_MUSCLE, 0f) / (64 * 8)) - 1, EntityAttributeModifier.Operation.MULTIPLY_BASE); + ((newScores.getOrDefault(CCItems.ORGANS_MUSCLE, 0f) / (64 * 8))-1) + * ChestCavity.config.MUSCLE_STRENGTH, EntityAttributeModifier.Operation.MULTIPLY_BASE); ReplaceAttributeModifier(att, mod); EntityAttributeModifier mod2 = new EntityAttributeModifier(muscleID2, "ChestCavityMuscleMovementSpeed", - (newScores.getOrDefault(CCItems.ORGANS_MUSCLE, 0f) / (64 * 8 * 2)) - .5, EntityAttributeModifier.Operation.MULTIPLY_BASE); + ((newScores.getOrDefault(CCItems.ORGANS_MUSCLE, 0f) / (64 * 8))-1) + * ChestCavity.config.MUSCLE_SPEED, EntityAttributeModifier.Operation.MULTIPLY_BASE); ReplaceAttributeModifier(att2, mod2); } } diff --git a/src/main/java/net/tigereye/chestcavity/mixin/MixinPlayerEntity.java b/src/main/java/net/tigereye/chestcavity/mixin/MixinPlayerEntity.java index b672fef..dbba26f 100644 --- a/src/main/java/net/tigereye/chestcavity/mixin/MixinPlayerEntity.java +++ b/src/main/java/net/tigereye/chestcavity/mixin/MixinPlayerEntity.java @@ -37,14 +37,14 @@ protected MixinPlayerEntity(PlayerEntity entityType, World world) { super(EntityType.PLAYER, world); } - public void baseTick() { + public void baseTick() { //TODO: consider moving this to LivingEntity and check if its a PlayerEntity ChestCavityListener chestCavity = ((CCComponent) (ChestCavity.INVENTORYCOMPONENT .get((PlayerEntity) (Object) this))).getCCListener(); OrganTickCallback.EVENT.invoker().onOrganTick(((PlayerEntity) (Object) this), chestCavity); super.baseTick(); } - protected int getNextAirUnderwater(int air) { + protected int getNextAirUnderwater(int air) { //TODO: consider moving this to LivingEntity and check if its a PlayerEntity ChestCavityListener chestCavity = ((CCComponent) (ChestCavity.INVENTORYCOMPONENT .get((PlayerEntity) (Object) this))).getCCListener(); int i = EnchantmentHelper.getRespiration(this); @@ -63,24 +63,6 @@ public void chestCavityPlayerEntityDropInventoryMixin(CallbackInfo info){ ((CCComponent) (ChestCavity.INVENTORYCOMPONENT.get((PlayerEntity) (Object) this))).chestCavityPostMortem(); } - @Shadow - public Iterable getArmorItems() { - return null; - } - - @Shadow - public ItemStack getEquippedStack(EquipmentSlot slot) { - return null; - } - - @Shadow - public void equipStack(EquipmentSlot slot, ItemStack stack) {} - - @Shadow - public Arm getMainArm() { - return null; - } - public int getCCHeartTimer() { return CCHeartTimer; } @@ -120,4 +102,24 @@ public int getCCLungRemainder() { public void setCCLungRemainder(int CCLungRemainder) { this.CCLungRemainder = CCLungRemainder; } + + @Shadow + public Iterable getArmorItems() { + return null; + } + + @Shadow + public ItemStack getEquippedStack(EquipmentSlot slot) { + return null; + } + + @Shadow + public void equipStack(EquipmentSlot slot, ItemStack stack) {} + + @Shadow + public Arm getMainArm() { + return null; + } + + } diff --git a/src/main/resources/assets/chestcavity/lang/en_us.json b/src/main/resources/assets/chestcavity/lang/en_us.json index 3154da3..c90881a 100644 --- a/src/main/resources/assets/chestcavity/lang/en_us.json +++ b/src/main/resources/assets/chestcavity/lang/en_us.json @@ -34,5 +34,18 @@ "item.chestcavity.saltwater_heart": "Saltwater Heart", "item.chestcavity.saltwater_lung": "Saltwater Lung", "item.chestcavity.raw_organ_meat": "Raw Organ Meat", - "item.chestcavity.cooked_organ_meat": "Cooked Organ Meat" + "item.chestcavity.cooked_organ_meat": "Cooked Organ Meat", + "item.chestcavity.cannibal_heart": "Cannibal Heart", + "item.chestcavity.tethered_cannibal_heart": "Tethered Cannibal Heart", + "text.autoconfig.chestcavity.title": "Chest Cavity", + "text.autoconfig.chestcavity.option.ORGAN_BUNDLE_DROP_RATE": "Organ Bundle Drop Rate", + "text.autoconfig.chestcavity.option.ORGAN_BUNDLE_LOOTING_BOOST": "Organ Bundle Looting Boost", + "text.autoconfig.chestcavity.option.HEARTBLEED_RATE": "Heartbleed Frequency", + "text.autoconfig.chestcavity.option.LIVER_RATE": "Liver Cleansing Frequency", + "text.autoconfig.chestcavity.option.KIDNEY_RATE": "Kidney Poison Frequency", + "text.autoconfig.chestcavity.option.APPENDIX_LUCK": "Luck per Appendix", + "text.autoconfig.chestcavity.option.HEART_HP": "HP Per Heart", + "text.autoconfig.chestcavity.option.MUSCLE_STRENGTH": "Muscle Strength", + "text.autoconfig.chestcavity.option.MUSCLE_SPEED": "Muscle Speed", + "text.autoconfig.chestcavity.option.WENDIGOISM_INTEGRATION": "Wendigoism Integration (Requires Restart)" } diff --git a/src/main/resources/assets/chestcavity/models/item/cannibal_heart.json b/src/main/resources/assets/chestcavity/models/item/cannibal_heart.json new file mode 100644 index 0000000..d1e0de1 --- /dev/null +++ b/src/main/resources/assets/chestcavity/models/item/cannibal_heart.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "wendigoism:item/wendigo_heart" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/chestcavity/models/item/tethered_cannibal_heart.json b/src/main/resources/assets/chestcavity/models/item/tethered_cannibal_heart.json new file mode 100644 index 0000000..e8e1fc1 --- /dev/null +++ b/src/main/resources/assets/chestcavity/models/item/tethered_cannibal_heart.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "wendigoism:item/tethered_heart" + } +} \ No newline at end of file diff --git a/src/main/resources/data/chestcavity/recipes/wendigoism_cannibal_heart.json b/src/main/resources/data/chestcavity/recipes/wendigoism_cannibal_heart.json new file mode 100644 index 0000000..65b0159 --- /dev/null +++ b/src/main/resources/data/chestcavity/recipes/wendigoism_cannibal_heart.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "chestcavity:raw_organ_meat" + }, + { + "item": "wendigoism:wendigo_heart" + } + ], + "result": { + "item": "chestcavity:cannibal_heart", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/chestcavity/recipes/wendigoism_salvage_human_organ.json b/src/main/resources/data/chestcavity/recipes/wendigoism_salvage_human_organ.json new file mode 100644 index 0000000..8544087 --- /dev/null +++ b/src/main/resources/data/chestcavity/recipes/wendigoism_salvage_human_organ.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "tag": "chestcavity:salvageable_human_organs" + }, + { + "item": "wendigoism:flesh" + } + ], + "result": { + "item": "wendigoism:flesh", + "count": 8 + } +} \ No newline at end of file diff --git a/src/main/resources/data/chestcavity/recipes/wendigoism_tethered_cannibal_heart.json b/src/main/resources/data/chestcavity/recipes/wendigoism_tethered_cannibal_heart.json new file mode 100644 index 0000000..9decb22 --- /dev/null +++ b/src/main/resources/data/chestcavity/recipes/wendigoism_tethered_cannibal_heart.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "chestcavity:raw_organ_meat" + }, + { + "item": "wendigoism:tethered_heart" + } + ], + "result": { + "item": "chestcavity:tethered_cannibal_heart", + "count": 1 + } +} \ No newline at end of file diff --git a/src/main/resources/data/chestcavity/tags/items/salvageable_human_organs.json b/src/main/resources/data/chestcavity/tags/items/salvageable_human_organs.json new file mode 100644 index 0000000..23d9b61 --- /dev/null +++ b/src/main/resources/data/chestcavity/tags/items/salvageable_human_organs.json @@ -0,0 +1,13 @@ +{ + "replace": false, + "values": [ + "chestcavity:appendix", + "chestcavity:heart", + "chestcavity:intestine", + "chestcavity:kidney", + "chestcavity:liver", + "chestcavity:lung", + "chestcavity:stomach", + "chestcavity:spleen" + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1758d23..862b464 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "chestcavity", - "version": "1.2.5", + "version": "${version}", "name": "Chest Cavity", "description": "Perfectly Safe Extra Storage", @@ -20,6 +20,9 @@ "entrypoints": { "main": [ "net.tigereye.chestcavity.ChestCavity" + ], + "modmenu": [ + "net.tigereye.chestcavity.config.CCModMenuIntegration" ] }, "mixins": [ @@ -32,6 +35,7 @@ "minecraft": "1.16.x" }, "suggests": { - "flamingo": "*" + "flamingo": "*", + "wendigoism": "*" } }