diff --git a/build.gradle b/build.gradle index 73522a96..a2d05de0 100644 --- a/build.gradle +++ b/build.gradle @@ -24,10 +24,14 @@ repositories { maven { url "http://dvs1.progwml6.com/files/maven" } + maven { + url = "http://maven.thiakil.com" + } } dependencies { deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220" + deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" } diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index ebca484f..7678bba4 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura; import de.ellpeck.naturesaura.blocks.ModBlocks; +import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.events.TerrainGenEvents; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -42,6 +43,7 @@ public final class NaturesAura { new ModBlocks(); new ModItems(); + Compat.init(); PacketHandler.init(); ModRegistry.preInit(event); diff --git a/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java new file mode 100644 index 00000000..6d54f94e --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java @@ -0,0 +1,42 @@ +package de.ellpeck.naturesaura.compat; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import baubles.api.cap.BaublesCapabilities; +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.items.ModItems; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.event.AttachCapabilitiesEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class BaublesCompat { + + private final IBauble eye = stack -> BaubleType.CHARM; + + @SubscribeEvent + public void onCapabilitiesAttach(AttachCapabilitiesEvent event) { + Item item = event.getObject().getItem(); + if (item == ModItems.EYE) { + event.addCapability(new ResourceLocation(NaturesAura.MOD_ID, "bauble"), new ICapabilityProvider() { + @Override + public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE; + } + + @Nullable + @Override + public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { + return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T) BaublesCompat.this.eye : null; + } + }); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java new file mode 100644 index 00000000..0d242859 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java @@ -0,0 +1,16 @@ +package de.ellpeck.naturesaura.compat; + +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.common.Loader; + +public final class Compat { + + public static boolean baubles; + + public static void init() { + baubles = Loader.isModLoaded("baubles"); + if (baubles) { + MinecraftForge.EVENT_BUS.register(new BaublesCompat()); + } + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 2e4531e0..c5c7bba9 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -1,9 +1,11 @@ package de.ellpeck.naturesaura.events; +import baubles.api.BaublesApi; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.aura.IAuraContainer; import de.ellpeck.naturesaura.aura.IAuraContainerProvider; +import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.particles.ParticleHandler; import de.ellpeck.naturesaura.particles.ParticleMagic; @@ -69,11 +71,11 @@ public class ClientEvents { @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); - if (event.getType() == ElementType.ALL /*&& mc.currentScreen == null*/) { + if (event.getType() == ElementType.ALL && mc.currentScreen == null) { ScaledResolution res = event.getResolution(); if (mc.player != null) { ItemStack stack = mc.player.getHeldItemMainhand(); - if (!stack.isEmpty() && stack.getItem() == ModItems.EYE) { + if (!stack.isEmpty() && stack.getItem() == ModItems.EYE || Compat.baubles && BaublesApi.isBaubleEquipped(mc.player, ModItems.EYE) >= 0) { int maxAura = 0; int aura = 0; int total = 0;