diff --git a/build.gradle b/build.gradle index 4bda543..9d32f0d 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -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 { diff --git a/src/main/java/io/github/cottonmc/epicurean/EpicureanGastronomy.java b/src/main/java/io/github/cottonmc/epicurean/EpicureanGastronomy.java index 4e7cc7e..76f437f 100644 --- a/src/main/java/io/github/cottonmc/epicurean/EpicureanGastronomy.java +++ b/src/main/java/io/github/cottonmc/epicurean/EpicureanGastronomy.java @@ -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!"); diff --git a/src/main/java/io/github/cottonmc/epicurean/container/CookingTableContainer.java b/src/main/java/io/github/cottonmc/epicurean/container/CookingTableContainer.java index dc43266..dd355e8 100644 --- a/src/main/java/io/github/cottonmc/epicurean/container/CookingTableContainer.java +++ b/src/main/java/io/github/cottonmc/epicurean/container/CookingTableContainer.java @@ -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) { @@ -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); } } diff --git a/src/main/java/io/github/cottonmc/epicurean/mixins/MixinOmnivore.java b/src/main/java/io/github/cottonmc/epicurean/mixins/MixinOmnivore.java index 60fffa4..cd049df 100644 --- a/src/main/java/io/github/cottonmc/epicurean/mixins/MixinOmnivore.java +++ b/src/main/java/io/github/cottonmc/epicurean/mixins/MixinOmnivore.java @@ -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; @@ -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) { @@ -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; + } } diff --git a/src/main/resources/data/epicurean/tweakers_unused/smoked_salmon.js b/src/main/resources/data/epicurean/tweakers_unused/smoked_salmon.js new file mode 100644 index 0000000..fd1187d --- /dev/null +++ b/src/main/resources/data/epicurean/tweakers_unused/smoked_salmon.js @@ -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); \ No newline at end of file