Skip to content

Commit

Permalink
Merge branch '1.18' into 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
Siphalor committed Mar 26, 2023
2 parents 1512a69 + e5d817d commit e2adbcd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ yarn_mappings = 2
loader_version = 0.14.12

# Mod Properties
mod_version = 1.3.0
mod_version = 1.3.1
release_type = release
maven_group = de.siphalor
archives_base_name = capsaicin
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.siphalor.capsaicin.impl.food;

import de.siphalor.capsaicin.api.food.CamoFoodContext;
import net.minecraft.entity.LivingEntity;

public record CamoFoodContextImpl(LivingEntity user) implements CamoFoodContext {

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ public LivingEntity getUser() {
this.stack = stack;
Item item = stack.getItem();
if (item instanceof CamoFoodItem camoFoodItem) {
this.stack = camoFoodItem.getCamoFoodStack(stack, new CamoFoodContext() {
@Override
public LivingEntity user() {
return user;
}
});
this.stack = camoFoodItem.getCamoFoodStack(stack, new CamoFoodContextImpl(user));
if (this.stack == null) {
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package de.siphalor.capsaicin.impl.mixin.client.appleskin;

import de.siphalor.capsaicin.api.food.CamoFoodContext;
import de.siphalor.capsaicin.api.food.CamoFoodItem;
import de.siphalor.capsaicin.impl.food.CamoFoodContextImpl;
import de.siphalor.capsaicin.impl.food.FoodHandler;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodComponent;
import net.minecraft.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import squeek.appleskin.helpers.DynamicFood;

@Mixin(CamoFoodItem.class)
public interface MixinCamoFoodItem extends DynamicFood {
@Shadow
@Nullable ItemStack getCamoFoodStack(ItemStack stack, CamoFoodContext context);

@Override
default int getDynamicHunger(ItemStack stack, PlayerEntity player) {
ItemStack camoFoodStack = getCamoFoodStack(stack, new CamoFoodContextImpl(player));
if (camoFoodStack == null) {
return 0;
}
FoodComponent foodComponent = FoodHandler.INSTANCE.get().withStack(stack).withUser(player).getModifiedFoodComponent();
if (foodComponent == null) {
return 0;
}
return foodComponent.getHunger();
}

@Override
default float getDynamicSaturation(ItemStack stack, PlayerEntity player) {
ItemStack camoFoodStack = getCamoFoodStack(stack, new CamoFoodContextImpl(player));
if (camoFoodStack == null) {
return 0;
}
FoodComponent foodComponent = FoodHandler.INSTANCE.get().withStack(stack).withUser(player).getModifiedFoodComponent();
if (foodComponent == null) {
return 0;
}
return foodComponent.getSaturationModifier();
}
}
1 change: 1 addition & 0 deletions src/main/resources/capsaicin.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"MixinPlayerEntity"
],
"client": [
"client.appleskin.MixinCamoFoodItem",
"client.appleskin.MixinFoodHelper",
"client.polymer.MixinPolymerAppleskinPlugin"
],
Expand Down

0 comments on commit e2adbcd

Please sign in to comment.