From e57255dc42019860c34519d6900fa5cfeb5bcbca Mon Sep 17 00:00:00 2001 From: Chloe Dawn Date: Tue, 13 Feb 2018 00:50:35 +0000 Subject: [PATCH] Add compatibility with AppleCore (https://github.com/squeek502/AppleCore/issues/113) --- build.gradle | 8 ++++++++ gradle.properties | 1 + .../insomniakitten/cake/PersistentCake.java | 2 +- .../cake/PersistentCakeBlock.java | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 720f074..70999ca 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,14 @@ minecraft { replace '%VERSION%', modVersion } +repositories { + maven { url 'http://www.ryanliptak.com/maven' } +} + +dependencies { + deobfCompile "applecore:AppleCore:$applecoreVersion:api" +} + processResources { from(sourceSets.main.resources.srcDirs) { include 'mcmod.info', 'pack.mcmeta' diff --git a/gradle.properties b/gradle.properties index ee594cd..6c01a8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ modVersion=2.0.0 mcfVersion=1.12.2-14.23.1.2582 mcpMappings=snapshot_20171229 +applecoreVersion=1.12.2-3.1.0+296.50100 \ No newline at end of file diff --git a/src/main/java/net/insomniakitten/cake/PersistentCake.java b/src/main/java/net/insomniakitten/cake/PersistentCake.java index e623bec..958a7e4 100644 --- a/src/main/java/net/insomniakitten/cake/PersistentCake.java +++ b/src/main/java/net/insomniakitten/cake/PersistentCake.java @@ -20,7 +20,7 @@ public final class PersistentCake { public static final String ID = "persistentcake"; public static final String NAME = "Persistent Cake"; public static final String VERSION = "%VERSION%"; - public static final String DEPENDENCIES = "after:harvestcraft"; + public static final String DEPENDENCIES = "after:applecore;after:harvestcraft"; protected static final Logger LOGGER = LogManager.getLogger(ID); diff --git a/src/main/java/net/insomniakitten/cake/PersistentCakeBlock.java b/src/main/java/net/insomniakitten/cake/PersistentCakeBlock.java index 507e646..71813b3 100644 --- a/src/main/java/net/insomniakitten/cake/PersistentCakeBlock.java +++ b/src/main/java/net/insomniakitten/cake/PersistentCakeBlock.java @@ -12,16 +12,21 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.Explosion; import net.minecraft.world.World; +import net.minecraftforge.fml.common.Optional; import org.apache.logging.log4j.Logger; +import squeek.applecore.api.food.FoodValues; +import squeek.applecore.api.food.IEdibleBlock; import javax.annotation.Nonnull; import java.util.Random; -public class PersistentCakeBlock extends BlockCake { +@Optional.Interface(iface = "squeek.applecore.api.food.IEdibleBlock", modid = "applecore") +public class PersistentCakeBlock extends BlockCake implements IEdibleBlock { private final Block delegate; @@ -110,4 +115,16 @@ private boolean canBlockStay(World world, BlockPos pos) { return world.getBlockState(pos.down()).getMaterial().isSolid(); } + @Override + @Optional.Method(modid = "applecore") + public void setEdibleAtMaxHunger(boolean value) { + ((IEdibleBlock) delegate).setEdibleAtMaxHunger(value); + } + + @Override + @Optional.Method(modid = "applecore") + public FoodValues getFoodValues(@Nonnull ItemStack stack) { + return ((IEdibleBlock) delegate).getFoodValues(stack); + } + }