Skip to content

Commit

Permalink
temporarily disable tweaker, fix yet another dupe bug, add DynamicFoo…
Browse files Browse the repository at this point in the history
…d support to jellied food
  • Loading branch information
LemmaEOF committed Jun 14, 2019
1 parent 7f5ec05 commit f3f5dcc
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ targetCompatibility = 1.8

archivesBaseName = "epicurean-gastronomy"
group = "io.github.cottonmc"
version = "2.2.1+1.14.2"
version = "2.2.2+1.14.2"

minecraft {
refmapName = "mixins.epicurean.refmap.json"
Expand All @@ -43,11 +43,13 @@ dependencies {
modCompile "net.fabricmc.fabric-api:fabric-api:0.3.0+build.181"

modCompile "io.github.prospector.modmenu:ModMenu:1.6.2-92"
modCompile "io.github.cottonmc:cotton:0.7.3+1.14.2-SNAPSHOT"
modCompile "io.github.cottonmc:cotton:0.7.5+1.14.2-SNAPSHOT"
modCompile "cloth-config:ClothConfig2:0.2.0"
include "cloth-config:ClothConfig2:0.2.0"
// modCompile "appleskin:appleskin-mc1.14:fabric:1.0.6"
modCompile "io.github.cottonmc:SkillCheck:1.0.9+1.14.1"

compileOnly ("com.google.code.findbugs:jsr305:3.0.2")
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class EpicureanGastronomy implements ModInitializer {

@Override
public void onInitialize() {
if (config == null) config = ConfigManager.loadConfig(EpicureanConfig.class, "EpicureanGastronomy.json5");
config = ConfigManager.loadConfig(EpicureanConfig.class, "EpicureanGastronomy.json5");
if (config.omnivoreEnabled) {
LOGGER.info("You're feeling hungry...");
LOGGER.info("Be warned, this might cause weird behavior!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CookingTableContainer(int syncId, PlayerInventory playerInv, BlockContext
this.resultInv = new CraftingResultInventory();
this.context = ctx;
this.player = playerInv.player;
this.addSlot(new CraftingResultSlot(playerInv.player, this.cookingInv, this.resultInv, 0, 146, 40));
this.addSlot(new CookingResultSlot(playerInv.player, this.cookingInv, this.resultInv, 0, 146, 40));

//base slots
for (int i = 0; i < 2; ++i) {
Expand Down Expand Up @@ -130,6 +130,7 @@ protected static void syncCraft(int syncId, World world, PlayerEntity player, Co
MealRecipe recipe = optional.get();
if (resultInv.shouldCraftRecipe(world, serverPlayer, recipe)) {
stack = recipe.craft(cookingInv);
stack.setAmount(1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import net.minecraft.advancement.criterion.Criterions;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.FoodItemSetting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
Expand All @@ -18,12 +20,19 @@
import net.minecraft.world.World;
import net.minecraft.world.explosion.Explosion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import squeek.appleskin.helpers.DynamicFood;

import javax.annotation.Nullable;

@Mixin(Item.class)
public class MixinOmnivore {
public abstract class MixinOmnivore implements DynamicFood {

@Shadow @Nullable
public abstract FoodItemSetting getFoodSetting();

@Inject(method = "getUseAction", at = @At("RETURN"), cancellable = true)
public void getOmnivoreUseAction(ItemStack stack, CallbackInfoReturnable cir) {
Expand Down Expand Up @@ -87,4 +96,31 @@ public void getOmnivoreOnItemFinishedUsing(ItemStack stack, World world, LivingE
}
}

@Override
public int getDynamicHunger(ItemStack stack, PlayerEntity player) {
if (stack.getItem().isFood()) {
int base = this.getFoodSetting().getHunger();
CompoundTag tag = stack.getOrCreateTag();
if (tag.containsKey("jellied")) return base + 2;
else if (tag.containsKey("super_jellied")) return base + 4;
else return base;
} else if (EpicureanGastronomy.config.omnivoreEnabled) {
return EpicureanGastronomy.config.omnivoreFoodRestore;
}
return 0;
}

@Override
public float getDynamicSaturation(ItemStack stack, PlayerEntity player) {
if (stack.getItem().isFood()) {
float base = this.getFoodSetting().getSaturationModifier();
CompoundTag tag = stack.getOrCreateTag();
if (tag.containsKey("jellied")) return base + 0.25f;
else if (tag.containsKey("super_jellied")) return base + 0.3f;
else return base;
} else if (EpicureanGastronomy.config.omnivoreEnabled) {
return EpicureanGastronomy.config.omnivoreSaturationRestore;
}
return 0f;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var TweakerUtils = Java.type('io.github.cottonmc.cotton.tweaker.TweakerUtils');
var RecipeTweaker = Java.type('io.github.cottonmc.cotton.tweaker.RecipeTweaker');

//I *really* hope I can find a way to get rid of using a tweaker in a jar,
// but for some reason vanilla has higher priority over Epicurean.
RecipeTweaker.removeRecipe("minecraft:cooked_salmon_from_smoking");
RecipeTweaker.addSmoking("minecraft:salmon", TweakerUtils.createItemStack("epicurean:smoked_salmon", 1), 800, 0.35);

0 comments on commit f3f5dcc

Please sign in to comment.