Skip to content

Commit

Permalink
Wendigoism Integration, Added Autoconfig, Nerfed Heart
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigereye504 committed Oct 7, 2020
1 parent 4250e7c commit 63ac21b
Show file tree
Hide file tree
Showing 24 changed files with 461 additions and 53 deletions.
20 changes: 16 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 8 additions & 2 deletions src/main/java/net/tigereye/chestcavity/ChestCavity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -16,21 +20,23 @@
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<InventoryComponent> INVENTORY_COMPONENT = ComponentRegistry.INSTANCE.registerStatic(new Identifier("chestcavity","inventory_component"), InventoryComponent.class);
public static final ComponentType<InventoryComponent> INVENTORYCOMPONENT =
ComponentRegistry.INSTANCE.registerIfAbsent(new Identifier("chestcavity:inventorycomponent"), InventoryComponent.class);


@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();
}
}
23 changes: 23 additions & 0 deletions src/main/java/net/tigereye/chestcavity/config/CCConfig.java
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;
}
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();
}
}
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.");
}
}
}
}
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);
}
}

}
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);
}
}
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);
}
}
}
}
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);
}
Loading

0 comments on commit 63ac21b

Please sign in to comment.