more stuff
This commit is contained in:
parent
d83dd30445
commit
a6069f065d
7 changed files with 96 additions and 44 deletions
2
TODO.md
2
TODO.md
|
|
@ -0,0 +1,2 @@
|
|||
- [ ] Finish moving over rest of the stuff
|
||||
- [ ] Add debuffs based on consciousness/other stuff (like mining fatigue, slowness etc)
|
||||
|
|
@ -10,4 +10,13 @@ public interface IPlayerHealthDataAccessor {
|
|||
|
||||
float getVomitTime();
|
||||
void setVomitTime(float value);
|
||||
|
||||
float getBloodVomitTime();
|
||||
void setBloodVomitTime(float value);
|
||||
|
||||
float getRadiationSickness();
|
||||
void setRadiationSickness(float value);
|
||||
|
||||
float getStamina();
|
||||
void setStamina(float value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,22 +8,15 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import xyz.illuc.tfcpain.IPlayerHealthDataAccessor;
|
||||
import xyz.illuc.neuralgiacore.IPlayerHealthDataAccessor;
|
||||
|
||||
@Mixin(PlayerHealthData.class)
|
||||
public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
||||
|
||||
// Add your new variable here
|
||||
// Sepsis
|
||||
@Unique
|
||||
private float sepsis = 0.0f;
|
||||
|
||||
@Unique
|
||||
private float sickness = 0.0f;
|
||||
|
||||
@Unique
|
||||
private float vomitTime = 0.0f;
|
||||
|
||||
|
||||
@Unique
|
||||
public float getSepsis() {
|
||||
return this.sepsis;
|
||||
|
|
@ -34,6 +27,9 @@ public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
|||
this.sepsis = value;
|
||||
}
|
||||
|
||||
// Sickness
|
||||
@Unique
|
||||
private float sickness = 0.0f;
|
||||
|
||||
@Unique
|
||||
public float getSickness() {
|
||||
|
|
@ -45,6 +41,10 @@ public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
|||
this.sickness = value;
|
||||
}
|
||||
|
||||
// Vomit timer
|
||||
@Unique
|
||||
private float vomitTime = 0.0f;
|
||||
|
||||
@Override
|
||||
public float getVomitTime() {
|
||||
return this.vomitTime;
|
||||
|
|
@ -55,7 +55,48 @@ public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
|||
this.vomitTime = value;
|
||||
}
|
||||
|
||||
// Inject into serializeNBT to save the new variable
|
||||
// Blood Vomit timer
|
||||
@Unique
|
||||
private float bloodVomitTime = 0.0f;
|
||||
|
||||
@Override
|
||||
public float getBloodVomitTime() {
|
||||
return this.bloodVomitTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBloodVomitTime(float value) {
|
||||
this.bloodVomitTime = value;
|
||||
}
|
||||
|
||||
// Radiation sickness
|
||||
@Unique
|
||||
private float radiationSickness = 0.0f;
|
||||
|
||||
@Override
|
||||
public float getRadiationSickness() {
|
||||
return this.radiationSickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRadiationSickness(float value) {
|
||||
this.radiationSickness = value;
|
||||
}
|
||||
|
||||
// Stamina
|
||||
@Unique
|
||||
private float stamina = 0.0f;
|
||||
|
||||
@Override
|
||||
public float getStamina() {
|
||||
return this.stamina;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStamina(float value) {
|
||||
this.stamina = value;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "serializeNBT",
|
||||
at = @At("RETURN"),
|
||||
|
|
@ -65,10 +106,9 @@ public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
|||
CompoundTag tag = cir.getReturnValue();
|
||||
tag.putFloat("Sepsis", this.sepsis);
|
||||
tag.putFloat("Sickness", this.sickness);
|
||||
tag.putFloat("VomitTimer", this.vomitTime);
|
||||
tag.putFloat("VomitTime", this.vomitTime);
|
||||
}
|
||||
|
||||
// Inject into deserializeNBT to load the new variable
|
||||
@Inject(
|
||||
method = "deserializeNBT",
|
||||
at = @At("TAIL"),
|
||||
|
|
@ -81,25 +121,11 @@ public class MixinPlayerHealthDataExtras implements IPlayerHealthDataAccessor {
|
|||
if (nbt.contains("Sickness")) {
|
||||
this.sickness = nbt.getFloat("Sickness");
|
||||
}
|
||||
if (nbt.contains("VomitTimer")) {
|
||||
this.vomitTime = nbt.getFloat("VomitTimer");
|
||||
if (nbt.contains("VomitTime")) {
|
||||
this.vomitTime = nbt.getFloat("VomitTime");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Inject into copyFrom to copy the new variable
|
||||
@Inject(
|
||||
method = "copyFrom",
|
||||
at = @At("TAIL"),
|
||||
remap = false
|
||||
)
|
||||
private void onCopyFrom(PlayerHealthData other, CallbackInfo ci) {
|
||||
if (other instanceof MixinPlayerHealthDataExtras otherMixin) {
|
||||
this.customVariable = otherMixin.getCustomVariable();
|
||||
}
|
||||
} */
|
||||
|
||||
// Inject into resetToDefaults to reset the new variable
|
||||
@Inject(
|
||||
method = "resetToDefaults",
|
||||
at = @At("TAIL"),
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import xyz.illuc.tfcpain.IPlayerHealthDataAccessor;
|
||||
import xyz.illuc.neuralgiacore.IPlayerHealthDataAccessor;
|
||||
|
||||
@Mixin(TFCFoodData.class)
|
||||
public class MixinFoodData {
|
||||
|
|
@ -35,7 +35,7 @@ public class MixinFoodData {
|
|||
|
||||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/food/FoodData;tick(Lnet/minecraft/world/entity/player/Player;)V", shift = At.Shift.AFTER))
|
||||
private void injected(Player player, CallbackInfo ci, @Local LocalRef<Difficulty> difficulty) {
|
||||
difficulty.set(Difficulty.PEACEFUL); //Disables the default thirst thing
|
||||
difficulty.set(Difficulty.PEACEFUL); //Disables the default thirst debuffs
|
||||
}
|
||||
|
||||
@Inject(method = "eat(Lnet/dries007/tfc/common/capabilities/food/FoodData;)V", at = @At(value = "HEAD"), remap = false)
|
||||
|
|
@ -81,7 +81,7 @@ public class MixinFoodData {
|
|||
// Calculate total sickness to add
|
||||
float totalSicknessToAdd = 0;
|
||||
|
||||
// 1. Add sickness from nutrient deficiency
|
||||
// Add sickness from nutrient deficiency
|
||||
if (deficientCount > 0) {
|
||||
// More deficient nutrients = more sickness
|
||||
// Severity also matters (how far below 20%)
|
||||
|
|
@ -90,11 +90,11 @@ public class MixinFoodData {
|
|||
totalSicknessToAdd += deficiencySickness;
|
||||
}
|
||||
|
||||
// 2. Add sickness from imbalance (existing code)
|
||||
// Add sickness from imbalance
|
||||
// Calculate the average nutrition level
|
||||
float average = (grains + vegetables + fruit + protein + dairy) / 5.0f;
|
||||
|
||||
// Calculate imbalance - sum of squared differences from average
|
||||
// Calculate imbalance
|
||||
float imbalance = 0;
|
||||
imbalance += (float) Math.pow(grains - average, 2);
|
||||
imbalance += (float) Math.pow(vegetables - average, 2);
|
||||
|
|
@ -102,13 +102,11 @@ public class MixinFoodData {
|
|||
imbalance += (float) Math.pow(protein - average, 2);
|
||||
imbalance += (float) Math.pow(dairy - average, 2);
|
||||
|
||||
// Normalize imbalance (divide by 5 and take square root to get standard deviation)
|
||||
// Normalize imbalance
|
||||
float stdDev = (float) Math.sqrt(imbalance / 5.0f);
|
||||
|
||||
// Only add sickness if imbalance is significant (std dev > 0.25 or 25%)
|
||||
// Only add sickness if imbalance is significant
|
||||
if (stdDev > 0.25f) {
|
||||
// Scale sickness based on severity of imbalance
|
||||
// At 0.25 std dev = 0.5 sickness, at 0.40 std dev = 3 sickness
|
||||
float imbalanceSickness = (stdDev - 0.25f) * 16.7f;
|
||||
imbalanceSickness = Math.min(imbalanceSickness, 5.0f); // Cap imbalance sickness
|
||||
totalSicknessToAdd += imbalanceSickness*100;
|
||||
|
|
@ -116,7 +114,6 @@ public class MixinFoodData {
|
|||
|
||||
// Apply total sickness if any was calculated
|
||||
if (totalSicknessToAdd > 0) {
|
||||
// Cap total sickness added per meal
|
||||
totalSicknessToAdd = Math.min(totalSicknessToAdd, 10.0f);
|
||||
|
||||
float finalSicknessToAdd = totalSicknessToAdd;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
package xyz.illuc.neuralgiacore.mixin.vanilla;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public abstract class MixinNametag {
|
||||
public abstract class MixinRemovePlayerNametag {
|
||||
@Inject(
|
||||
method = "renderNameTag",
|
||||
at = @At("HEAD"),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,13 @@
|
|||
package xyz.illuc.neuralgiacore;
|
||||
package xyz.illuc.neuralgiacore.registers;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = Tfcpain.MODID, value = Dist.CLIENT)
|
||||
public class MoodleController {
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import xyz.illuc.neuralgiacore.NeuralgiaCoreMod;
|
||||
|
||||
import static net.adinvas.prototype_pain.client.moodles.MoodleController.registerMoodle;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = NeuralgiaCoreMod.MOD_ID, value = Dist.CLIENT)
|
||||
public class RegisterMoodles {
|
||||
static {
|
||||
registerMoodle(new SepsisMoodle());
|
||||
registerMoodle(new SicknessMoodle());
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
"compatibilityLevel": "JAVA_17",
|
||||
"refmap": "tfcpain.refmap.json",
|
||||
"mixins": [
|
||||
|
||||
"PrototypePain.MixinPlayerHealthDataExtras",
|
||||
"Tfc.MixinHealthBar"
|
||||
],
|
||||
"client": [
|
||||
|
||||
"vanilla.MixinRemovePlayerNametag"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue