-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wendigoism Integration, Added Autoconfig, Nerfed Heart
- Loading branch information
1 parent
4250e7c
commit 63ac21b
Showing
24 changed files
with
461 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/net/tigereye/chestcavity/config/CCConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/net/tigereye/chestcavity/config/CCModMenuIntegration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/net/tigereye/chestcavity/crossmod/CrossModContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."); | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismItems.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Identifier,Float> flesh = new HashMap<>(); | ||
flesh.put(CCItems.ORGANS_MUSCLE,.75f); | ||
VanillaOrgans.map.put(WDItems.FLESH,flesh); | ||
} | ||
if(item == WDItems.CORRUPT_FLESH){ | ||
Map<Identifier,Float> corruptedFlesh = new HashMap<>(); | ||
corruptedFlesh.put(CCItems.ORGANS_MUSCLE,1f); | ||
VanillaOrgans.map.put(WDItems.CORRUPT_FLESH,corruptedFlesh); | ||
} | ||
} | ||
|
||
} |
101 changes: 101 additions & 0 deletions
101
src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/CCWendigoismListeners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Identifier, Float> oldScores, Map<Identifier, Float> 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); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/net/tigereye/chestcavity/crossmod/wendigoism/TetheredCannibalHeart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Identifier, Float> getOrganQualityMap(ItemStack item) { | ||
if(item.getTag() == null){ | ||
item.setTag(new CompoundTag()); | ||
return getOrganQualityMap(); | ||
} | ||
if(!item.getTag().contains("wendigoism")) { | ||
return getOrganQualityMap(); | ||
} | ||
Map<Identifier,Float> 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); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
src/main/java/net/tigereye/chestcavity/items/ChestCavityOrgan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
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; | ||
|
||
import java.util.Map; | ||
|
||
public interface ChestCavityOrgan { | ||
Map<Identifier,Float> getOrganQualityMap(); | ||
Map<Identifier,Float> getOrganQualityMap(ItemStack item); | ||
} |
Oops, something went wrong.