mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 03:43:30 +01:00
baubles compat
This commit is contained in:
parent
0d9a18b41a
commit
663bff02f4
5 changed files with 68 additions and 2 deletions
|
@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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<ItemStack> 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> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
return capability == BaublesCapabilities.CAPABILITY_ITEM_BAUBLE ? (T) BaublesCompat.this.eye : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
16
src/main/java/de/ellpeck/naturesaura/compat/Compat.java
Normal file
16
src/main/java/de/ellpeck/naturesaura/compat/Compat.java
Normal file
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue