From 13d6cf778a824202f88b85e786d4d7a40d7e6d87 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 12 Nov 2018 22:04:40 +0100 Subject: [PATCH] move some API stuff around --- .../java/de/ellpeck/naturesaura/Helper.java | 26 ++++++++++--- .../de/ellpeck/naturesaura/InternalHooks.java | 13 +++---- .../de/ellpeck/naturesaura/NaturesAura.java | 8 ++-- .../naturesaura/api/NACapabilities.java | 38 ------------------- .../naturesaura/api/NaturesAuraAPI.java | 26 +++++++++++++ .../api/aura/chunk/IAuraChunk.java | 5 +-- .../naturesaura/aura/chunk/AuraChunk.java | 6 +-- .../aura/chunk/effect/ReplenishingEffect.java | 6 +-- .../blocks/tiles/TileEntityImpl.java | 6 +-- .../blocks/tiles/TileEntityNatureAltar.java | 11 +++--- .../naturesaura/events/ClientEvents.java | 12 +++--- .../naturesaura/events/CommonEvents.java | 10 ++--- .../naturesaura/items/ItemAuraCache.java | 18 ++++----- .../naturesaura/packet/PacketAuraChunk.java | 6 +-- 14 files changed, 94 insertions(+), 97 deletions(-) delete mode 100644 src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 904d5795..dde544d1 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -1,10 +1,8 @@ package de.ellpeck.naturesaura; -import baubles.api.BaublesApi; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; -import de.ellpeck.naturesaura.compat.Compat; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; @@ -16,6 +14,7 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -27,10 +26,10 @@ import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderServer; import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; import org.lwjgl.opengl.GL11; @@ -174,13 +173,13 @@ public final class Helper { @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == NACapabilities.auraRecharge; + return capability == NaturesAuraAPI.capAuraRecharge; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == NACapabilities.auraRecharge ? (T) this.recharge : null; + return capability == NaturesAuraAPI.capAuraRecharge ? (T) this.recharge : null; } }; } @@ -214,4 +213,19 @@ public final class Helper { return state.withProperty(prop, value); return null; } + + public static void registerCap(Class type) { + CapabilityManager.INSTANCE.register(type, new Capability.IStorage() { + @Nullable + @Override + public NBTBase writeNBT(Capability capability, Object instance, EnumFacing side) { + return null; + } + + @Override + public void readNBT(Capability capability, Object instance, EnumFacing side, NBTBase nbt) { + + } + }, () -> null); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/InternalHooks.java b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java index b9622116..59a3eae0 100644 --- a/src/main/java/de/ellpeck/naturesaura/InternalHooks.java +++ b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura; import baubles.api.BaublesApi; -import de.ellpeck.naturesaura.api.NACapabilities; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.compat.Compat; @@ -26,8 +25,8 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { IItemHandler baubles = BaublesApi.getBaublesHandler(player); for (int i = 0; i < baubles.getSlots(); i++) { ItemStack stack = baubles.getStackInSlot(i); - if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { - amount -= stack.getCapability(NACapabilities.auraContainer, null).drainAura(amount, simulate); + if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + amount -= stack.getCapability(NaturesAuraAPI.capAuraContainer, null).drainAura(amount, simulate); if (amount <= 0) return true; } @@ -36,8 +35,8 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { - amount -= stack.getCapability(NACapabilities.auraContainer, null).drainAura(amount, simulate); + if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + amount -= stack.getCapability(NaturesAuraAPI.capAuraContainer, null).drainAura(amount, simulate); if (amount <= 0) return true; } @@ -58,8 +57,8 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks { for (int z = (pos.getZ() - radius) >> 4; z <= (pos.getZ() + radius) >> 4; z++) { if (Helper.isChunkLoaded(world, x, z)) { Chunk chunk = world.getChunk(x, z); - if (chunk.hasCapability(NACapabilities.auraChunk, null)) { - IAuraChunk auraChunk = chunk.getCapability(NACapabilities.auraChunk, null); + if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) { + IAuraChunk auraChunk = chunk.getCapability(NaturesAuraAPI.capAuraChunk, null); auraChunk.getSpotsInArea(pos, radius, consumer); } } diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 44f37fa8..958f30a3 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura; -import de.ellpeck.naturesaura.api.NACapabilities.StorageImpl; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; @@ -21,7 +20,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; @@ -56,9 +54,9 @@ public final class NaturesAura { @EventHandler public void preInit(FMLPreInitializationEvent event) { NaturesAuraAPI.setInstance(new InternalHooks()); - CapabilityManager.INSTANCE.register(IAuraContainer.class, new StorageImpl<>(), () -> null); - CapabilityManager.INSTANCE.register(IAuraRecharge.class, new StorageImpl<>(), () -> null); - CapabilityManager.INSTANCE.register(IAuraChunk.class, new StorageImpl<>(), () -> null); + Helper.registerCap(IAuraContainer.class); + Helper.registerCap(IAuraRecharge.class); + Helper.registerCap(IAuraChunk.class); new ModBlocks(); new ModItems(); diff --git a/src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java b/src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java deleted file mode 100644 index b9cb4d3e..00000000 --- a/src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.ellpeck.naturesaura.api; - -import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; -import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; -import net.minecraft.nbt.NBTBase; -import net.minecraft.util.EnumFacing; -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.Capability.IStorage; -import net.minecraftforge.common.capabilities.CapabilityInject; - -import javax.annotation.Nullable; - -public final class NACapabilities { - - @CapabilityInject(IAuraContainer.class) - public static Capability auraContainer; - - @CapabilityInject(IAuraRecharge.class) - public static Capability auraRecharge; - - @CapabilityInject(IAuraChunk.class) - public static Capability auraChunk; - - public static class StorageImpl implements IStorage { - - @Nullable - @Override - public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { - return null; - } - - @Override - public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { - - } - } -} diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java index 2c8f377d..15c9ee03 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.api; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.api.aura.type.BasicAuraType; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.api.internal.StubHooks; @@ -14,6 +15,8 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.DimensionType; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; import org.apache.commons.lang3.mutable.MutableInt; import java.util.ArrayList; @@ -66,6 +69,29 @@ public final class NaturesAuraAPI { public static final IAuraType TYPE_END = new BasicAuraType(new ResourceLocation(MOD_ID, "end"), DimensionType.THE_END, 0x302624).register(); public static final IAuraType TYPE_OTHER = new BasicAuraType(new ResourceLocation(MOD_ID, "other"), null, 0x2fa8a0).register(); + /** + * The capability for any item or block that stores Aura in the form of an + * {@link IAuraContainer} + */ + @CapabilityInject(IAuraContainer.class) + public static Capability capAuraContainer; + /** + * The capability for any item that can be recharged from an Aura storage + * container like the Aura Cache in the form of {@link IAuraRecharge} by a + * player holding it in their hand + */ + @CapabilityInject(IAuraRecharge.class) + public static Capability capAuraRecharge; + /** + * The capability that any chunk in a world has to store Aura in it. As this + * is only applicable to chunks and all chunks in the world automatically + * get assigned this capability, using it directly is not necessary for + * addon developers. To retrieve this capability from any chunk, use the + * helper method {@link IAuraChunk#getAuraChunk(World, BlockPos)}. + */ + @CapabilityInject(IAuraChunk.class) + public static Capability capAuraChunk; + /** * This method returns the active {@link IInternalHooks} instance which can * be used to hook into the mod's internal functionalities. This is diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java index 9380b87f..07acfc00 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java @@ -1,6 +1,5 @@ package de.ellpeck.naturesaura.api.aura.chunk; -import de.ellpeck.naturesaura.api.NACapabilities; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import net.minecraft.nbt.NBTTagCompound; @@ -37,8 +36,8 @@ public interface IAuraChunk extends ICapabilityProvider, INBTSerializable capability, @Nullable EnumFacing facing) { - return capability == NACapabilities.auraChunk; + return capability == NaturesAuraAPI.capAuraChunk; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == NACapabilities.auraChunk ? (T) this : null; + return capability == NaturesAuraAPI.capAuraChunk ? (T) this : null; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java index 7cb7d410..4fdaf551 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/ReplenishingEffect.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.aura.chunk.effect; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable; @@ -22,8 +22,8 @@ public class ReplenishingEffect implements IDrainSpotEffect { if (amount < 0) { List tiles = new ArrayList<>(); Helper.getTileEntitiesInArea(world, pos, 25, tile -> { - if (tile.hasCapability(NACapabilities.auraContainer, null)) { - IAuraContainer container = tile.getCapability(NACapabilities.auraContainer, null); + if (tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null); if (container instanceof ISpotDrainable) { tiles.add((ISpotDrainable) container); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java index ebfd68d8..203c8be1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks.tiles; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -94,7 +94,7 @@ public class TileEntityImpl extends TileEntity { public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return this.getItemHandler(facing) != null; - } else if (capability == NACapabilities.auraContainer) { + } else if (capability == NaturesAuraAPI.capAuraContainer) { return this.getAuraContainer(facing) != null; } else { return super.hasCapability(capability, facing); @@ -106,7 +106,7 @@ public class TileEntityImpl extends TileEntity { public T getCapability(Capability capability, @Nullable EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) this.getItemHandler(facing); - } else if (capability == NACapabilities.auraContainer) { + } else if (capability == NaturesAuraAPI.capAuraContainer) { return (T) this.getAuraContainer(facing); } else { return super.getCapability(capability, facing); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index e9a0a6d9..77cc11c6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -1,7 +1,6 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.api.NACapabilities; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer; @@ -39,13 +38,13 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { @Override protected boolean canInsert(ItemStack stack, int slot) { - return getRecipeForInput(stack) != null || stack.hasCapability(NACapabilities.auraContainer, null); + return getRecipeForInput(stack) != null || stack.hasCapability(NaturesAuraAPI.capAuraContainer, null); } @Override protected boolean canExtract(ItemStack stack, int slot, int amount) { - if (stack.hasCapability(NACapabilities.auraContainer, null)) - return stack.getCapability(NACapabilities.auraContainer, null).storeAura(1, true) <= 0; + if (stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) + return stack.getCapability(NaturesAuraAPI.capAuraContainer, null).storeAura(1, true) <= 0; else return getRecipeForInput(stack) == null; } @@ -98,8 +97,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { } ItemStack stack = this.items.getStackInSlot(0); - if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { - IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, null); + if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null); int theoreticalDrain = this.container.drainAura(10, true); if (theoreticalDrain > 0) { int stored = container.storeAura(theoreticalDrain, false); diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 99efa64a..29a81e6d 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.events; import baubles.api.BaublesApi; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.type.IAuraType; @@ -124,7 +124,7 @@ public class ClientEvents { } if (!cache.isEmpty()) { - IAuraContainer container = cache.getCapability(NACapabilities.auraContainer, null); + IAuraContainer container = cache.getCapability(NaturesAuraAPI.capAuraContainer, null); int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80); int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29); int y = res.getScaledHeight() - 8; @@ -177,8 +177,8 @@ public class ClientEvents { BlockPos pos = mc.objectMouseOver.getBlockPos(); if (pos != null) { TileEntity tile = mc.world.getTileEntity(pos); - if (tile != null && tile.hasCapability(NACapabilities.auraContainer, null)) { - IAuraContainer container = tile.getCapability(NACapabilities.auraContainer, null); + if (tile != null && tile.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + IAuraContainer container = tile.getCapability(NaturesAuraAPI.capAuraContainer, null); IBlockState state = mc.world.getBlockState(pos); ItemStack blockStack = state.getBlock().getPickBlock(state, mc.objectMouseOver, mc.world, pos, mc.player); @@ -186,8 +186,8 @@ public class ClientEvents { if (tile instanceof TileEntityNatureAltar) { ItemStack tileStack = ((TileEntityNatureAltar) tile).getItemHandler(null).getStackInSlot(0); - if (!tileStack.isEmpty() && tileStack.hasCapability(NACapabilities.auraContainer, null)) { - IAuraContainer stackContainer = tileStack.getCapability(NACapabilities.auraContainer, null); + if (!tileStack.isEmpty() && tileStack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + IAuraContainer stackContainer = tileStack.getCapability(NaturesAuraAPI.capAuraContainer, null); this.drawContainerInfo(stackContainer, mc, res, 55, tileStack.getDisplayName()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 52fee0e0..b6fefff3 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.events; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -36,8 +36,8 @@ public class CommonEvents { Iterator chunks = event.world.getPersistentChunkIterable(((WorldServer) event.world).getPlayerChunkMap().getChunkIterator()); while (chunks.hasNext()) { Chunk chunk = chunks.next(); - if (chunk.hasCapability(NACapabilities.auraChunk, null)) { - AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); + if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null); auraChunk.update(); } } @@ -49,8 +49,8 @@ public class CommonEvents { @SubscribeEvent public void onChunkWatch(ChunkWatchEvent.Watch event) { Chunk chunk = event.getChunkInstance(); - if (!chunk.getWorld().isRemote && chunk.hasCapability(NACapabilities.auraChunk, null)) { - AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); + if (!chunk.getWorld().isRemote && chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null); PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index e3a3bae1..e6b4be72 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer; import de.ellpeck.naturesaura.renderers.ITrinketItem; @@ -37,9 +37,9 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { EntityPlayer player = (EntityPlayer) entityIn; if (player.isSneaking()) { ItemStack stack = player.getHeldItemMainhand(); - if (stack.hasCapability(NACapabilities.auraRecharge, null)) { - IAuraContainer container = stackIn.getCapability(NACapabilities.auraContainer, null); - stack.getCapability(NACapabilities.auraRecharge, null).rechargeFromContainer(container); + if (stack.hasCapability(NaturesAuraAPI.capAuraRecharge, null)) { + IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer, null); + stack.getCapability(NaturesAuraAPI.capAuraRecharge, null).rechargeFromContainer(container); } } } @@ -51,7 +51,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { items.add(new ItemStack(this)); ItemStack stack = new ItemStack(this); - IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, null); + IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null); container.storeAura(container.getMaxAura(), false); items.add(stack); } @@ -64,8 +64,8 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Override public double getDurabilityForDisplay(ItemStack stack) { - if (stack.hasCapability(NACapabilities.auraContainer, null)) { - IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, null); + if (stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) { + IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null); return 1 - container.getStoredAura() / (double) container.getMaxAura(); } else { return 0; @@ -80,13 +80,13 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == NACapabilities.auraContainer; + return capability == NaturesAuraAPI.capAuraContainer; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - if (capability == NACapabilities.auraContainer) { + if (capability == NaturesAuraAPI.capAuraContainer) { return (T) this.container; } else { return null; diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java index 6f05a409..32864afe 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketAuraChunk.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; @@ -70,8 +70,8 @@ public class PacketAuraChunk implements IMessage { World world = Minecraft.getMinecraft().world; if (world != null) { Chunk chunk = world.getChunk(message.chunkX, message.chunkZ); - if (chunk.hasCapability(NACapabilities.auraChunk, null)) { - AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); + if (chunk.hasCapability(NaturesAuraAPI.capAuraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NaturesAuraAPI.capAuraChunk, null); auraChunk.setSpots(message.drainSpots); } }