Skip to content

Commit

Permalink
Added armor effects
Browse files Browse the repository at this point in the history
fixed some metabolites
cake block mixins
  • Loading branch information
lilypuree committed Dec 24, 2023
1 parent 94ff9c7 commit 207acb9
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/main/java/lilypuree/metabolism/data/Metabolites.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.google.gson.JsonElement;
import com.mojang.serialization.JsonOps;
import lilypuree.metabolism.client.ClientMetabolites;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -53,7 +53,7 @@ protected void apply(Map<ResourceLocation, JsonElement> map, ResourceManager res
ImmutableMap.Builder<Item, Metabolite> builder = ImmutableMap.builder();
map.forEach((location, value) -> {
Item item = ForgeRegistries.ITEMS.getValue(location);
if (item != null) {
if (item != Items.AIR) {
Metabolite metabolite = Metabolite.CODEC.parse(JsonOps.INSTANCE, value)
.getOrThrow(false, prefix("Metabolite for " + location + ": "));
builder.put(item, metabolite);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/lilypuree/metabolism/metabolism/Metabolism.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void causeDamage(Player player) {
}

private void applyHeatTarget(float heatTarget) {
if (Math.abs(heat - heatTarget) < 1E-3) {
if (Math.abs(heat - heatTarget) < 1E-2) {
heat = heatTarget;
} else if (heat > 0) {
//HOT
Expand Down Expand Up @@ -155,7 +155,7 @@ public void eat(Metabolite metabolite) {
}

public void eat(float foodLevel, float saturationLevelModifier) {
this.food += foodLevel;
this.food += foodLevel * MetabolismConstants.OTHER_FOOD_MULTIPLIER;
}

public void peacefulWarmth() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public class MetabolismConstants {
public static final float ENERGY_SPRINT = 0.1F; //about 3 minutes sprinting = 100 energy
public static final float ENERGY_FLY = 0.03F; //about 1 minutes of flying down = 100 energy
public static final float EXHAUSTION_MULTIPLIER = 1.0F; //about 1 minute of gliding =
public static final float OTHER_FOOD_MULTIPLIER = 0.5F;
}
23 changes: 23 additions & 0 deletions src/main/java/lilypuree/metabolism/mixin/CakeBlockMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package lilypuree.metabolism.mixin;

import lilypuree.metabolism.metabolism.FoodDataDuck;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.CakeBlock;
import net.minecraft.world.level.block.state.BlockState;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(CakeBlock.class)
public class CakeBlockMixin {

@Inject(method = "eat", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getFoodData()Lnet/minecraft/world/food/FoodData;"))
private static void onEat(LevelAccessor level, BlockPos pos, BlockState state, Player player, CallbackInfoReturnable<InteractionResult> callbackInfo) {
((FoodDataDuck) player.getFoodData()).getMetabolism().consumeEnergy(-2.0F);
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
{
"conditions": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:gold_chestplate",
"minecraft:gold_leggings",
"minecraft:gold_boots",
"minecraft:gold_helmet"
]
"condition" : "any_of",
"terms": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:golden_helmet"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"chest": {
"items": [
"minecraft:golden_chestplate"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"legs": {
"items": [
"minecraft:golden_leggings"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"feet": {
"items": [
"minecraft:golden_boots"
]
}
}
}
}
}
]
},
"is_resistance": true,
"is_additive": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
{
"conditions": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:leather_chestplate",
"minecraft:leather_leggings",
"minecraft:leather_boots",
"minecraft:leather_helmet"
]
"condition" : "any_of",
"terms": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:leather_helmet"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"chest": {
"items": [
"minecraft:leather_chestplate"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"legs": {
"items": [
"minecraft:leather_leggings"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"feet": {
"items": [
"minecraft:leather_boots"
]
}
}
}
}
}
]
},
"is_resistance": true,
"is_additive": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,60 @@
{
"conditions": {
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:netherite_chestplate",
"minecraft:netherite_leggings",
"minecraft:netherite_boots",
"minecraft:netherite_helmet"
]
"condition" : "any_of",
"terms": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"head": {
"items": [
"minecraft:netherite_helmet"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"chest": {
"items": [
"minecraft:netherite_chestplate"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"legs": {
"items": [
"minecraft:netherite_leggings"
]
}
}
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"equipment": {
"feet": {
"items": [
"minecraft:netherite_boots"
]
}
}
}
}
}
]
},
"is_resistance": true,
"is_additive": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
],
"is_additive": true,
"warmth_effect": 1.0
"warmth_effect": 0.1
}
3 changes: 2 additions & 1 deletion src/main/resources/metabolism.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"compatibilityLevel": "JAVA_17",
"refmap": "metabolism.refmap.json",
"mixins": [
"LocationCheckAccessor",
"CakeBlockMixin",
"FoodDataMixin",
"LocationCheckAccessor",
"PlayerMixin"
],
"client": [
Expand Down

0 comments on commit 207acb9

Please sign in to comment.