From 436f3b809b536a5977a69ba50abaf5b956f901be Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 11 Nov 2018 13:26:19 +0100 Subject: [PATCH] added a proper API \o/ --- .../java/de/ellpeck/naturesaura/Helper.java | 16 +-- .../de/ellpeck/naturesaura/InternalHooks.java | 77 ++++++++++ .../de/ellpeck/naturesaura/NaturesAura.java | 12 +- .../NACapabilities.java} | 14 +- .../naturesaura/api/NaturesAuraAPI.java | 111 +++++++++++++++ .../naturesaura/{ => api}/aura/AuraType.java | 2 +- .../api/aura/chunk/IAuraChunk.java | 132 ++++++++++++++++++ .../aura/chunk}/IDrainSpotEffect.java | 7 +- .../{ => api}/aura/chunk/ISpotDrainable.java | 4 +- .../aura/container/BasicAuraContainer.java | 4 +- .../aura/container/IAuraContainer.java | 4 +- .../aura/container/ItemAuraContainer.java | 4 +- .../aura/container/NaturalAuraContainer.java | 6 +- .../api/aura/item/IAuraRecharge.java | 9 ++ .../naturesaura/api/internal/StubHooks.java | 35 +++++ .../{ => api}/recipes/AltarRecipe.java | 20 +-- .../{ => api}/recipes/TreeRitualRecipe.java | 10 +- .../naturesaura/aura/chunk/AuraChunk.java | 91 ++---------- .../aura/chunk/effect/GrassDieEffect.java | 10 +- .../aura/chunk/effect/PlantBoostEffect.java | 14 +- .../aura/chunk/effect/ReplenishingEffect.java | 17 +-- .../naturesaura/aura/item/IAuraRecharge.java | 9 -- .../blocks/BlockAncientLeaves.java | 3 +- .../blocks/BlockFurnaceHeater.java | 4 +- .../blocks/tiles/TileEntityAncientLeaves.java | 6 +- .../blocks/tiles/TileEntityAuraDetector.java | 6 +- .../tiles/TileEntityFlowerGenerator.java | 10 +- .../blocks/tiles/TileEntityFurnaceHeater.java | 5 +- .../blocks/tiles/TileEntityHopperUpgrade.java | 7 +- .../blocks/tiles/TileEntityImpl.java | 8 +- .../blocks/tiles/TileEntityNatureAltar.java | 52 ++++--- .../blocks/tiles/TileEntityPlacer.java | 5 +- .../tiles/TileEntityPotionGenerator.java | 7 +- .../blocks/tiles/TileEntityWoodStand.java | 5 +- .../naturesaura/commands/CommandAura.java | 10 +- .../compat/jei/JEINaturesAuraPlugin.java | 9 +- .../compat/jei/altar/AltarCategory.java | 2 +- .../compat/jei/altar/AltarWrapper.java | 2 +- .../jei/treeritual/TreeRitualCategory.java | 2 +- .../jei/treeritual/TreeRitualWrapper.java | 2 +- .../compat/patchouli/ProcessorAltar.java | 5 +- .../compat/patchouli/ProcessorTreeRitual.java | 5 +- .../naturesaura/events/ClientEvents.java | 24 ++-- .../naturesaura/events/CommonEvents.java | 12 +- .../naturesaura/events/TerrainGenEvents.java | 5 +- .../naturesaura/items/ItemAuraBottle.java | 10 +- .../naturesaura/items/ItemAuraCache.java | 22 +-- .../naturesaura/packet/PacketAuraChunk.java | 6 +- .../packet/PacketParticleStream.java | 3 +- .../naturesaura/packet/PacketParticles.java | 27 ++-- .../naturesaura/recipes/ModRecipes.java | 4 +- 51 files changed, 589 insertions(+), 287 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/InternalHooks.java rename src/main/java/de/ellpeck/naturesaura/{aura/Capabilities.java => api/NACapabilities.java} (71%) create mode 100644 src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/AuraType.java (92%) create mode 100644 src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java rename src/main/java/de/ellpeck/naturesaura/{aura/chunk/effect => api/aura/chunk}/IDrainSpotEffect.java (50%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/chunk/ISpotDrainable.java (53%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/container/BasicAuraContainer.java (93%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/container/IAuraContainer.java (73%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/container/ItemAuraContainer.java (94%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/aura/container/NaturalAuraContainer.java (78%) create mode 100644 src/main/java/de/ellpeck/naturesaura/api/aura/item/IAuraRecharge.java create mode 100644 src/main/java/de/ellpeck/naturesaura/api/internal/StubHooks.java rename src/main/java/de/ellpeck/naturesaura/{ => api}/recipes/AltarRecipe.java (55%) rename src/main/java/de/ellpeck/naturesaura/{ => api}/recipes/TreeRitualRecipe.java (72%) delete mode 100644 src/main/java/de/ellpeck/naturesaura/aura/item/IAuraRecharge.java diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 891f9fcb..d6b71d96 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura; import baubles.api.BaublesApi; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.item.IAuraRecharge; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; import de.ellpeck.naturesaura.compat.Compat; import net.minecraft.client.Minecraft; @@ -170,13 +170,13 @@ public final class Helper { @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == Capabilities.auraRecharge; + return capability == NACapabilities.auraRecharge; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == Capabilities.auraRecharge ? (T) this.recharge : null; + return capability == NACapabilities.auraRecharge ? (T) this.recharge : null; } }; } @@ -189,8 +189,8 @@ public final class Helper { IItemHandler baubles = BaublesApi.getBaublesHandler(player); for (int i = 0; i < baubles.getSlots(); i++) { ItemStack stack = baubles.getStackInSlot(i); - if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) { - amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate); + if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { + amount -= stack.getCapability(NACapabilities.auraContainer, null).drainAura(amount, simulate); if (amount <= 0) return true; } @@ -199,8 +199,8 @@ public final class Helper { for (int i = 0; i < player.inventory.getSizeInventory(); i++) { ItemStack stack = player.inventory.getStackInSlot(i); - if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) { - amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate); + if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { + amount -= stack.getCapability(NACapabilities.auraContainer, null).drainAura(amount, simulate); if (amount <= 0) return true; } diff --git a/src/main/java/de/ellpeck/naturesaura/InternalHooks.java b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java new file mode 100644 index 00000000..2a2444b6 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/InternalHooks.java @@ -0,0 +1,77 @@ +package de.ellpeck.naturesaura; + +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import org.apache.commons.lang3.mutable.MutableInt; +import org.apache.commons.lang3.mutable.MutableObject; + +import java.util.function.BiConsumer; + +public class InternalHooks implements NaturesAuraAPI.IInternalHooks { + @Override + public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { + NaturesAura.proxy.spawnMagicParticle(world, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision, fade); + } + + @Override + public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer) { + world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getSpotsInArea"); + for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) { + 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); + auraChunk.getSpotsInArea(pos, radius, consumer); + } + } + } + } + world.profiler.endSection(); + } + + @Override + public int getAuraInArea(World world, BlockPos pos, int radius) { + MutableInt result = new MutableInt(IAuraChunk.DEFAULT_AURA); + this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot.intValue())); + return result.intValue(); + } + + @Override + public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + MutableInt lowestAmount = new MutableInt(Integer.MAX_VALUE); + MutableObject lowestSpot = new MutableObject<>(); + this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { + int amount = drainSpot.intValue(); + if (amount < lowestAmount.intValue()) { + lowestAmount.setValue(amount); + lowestSpot.setValue(blockPos); + } + }); + BlockPos lowest = lowestSpot.getValue(); + if (lowest == null) + lowest = defaultSpot; + return lowest; + } + + @Override + public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + MutableInt highestAmount = new MutableInt(Integer.MIN_VALUE); + MutableObject highestSpot = new MutableObject<>(); + this.getAuraSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { + int amount = drainSpot.intValue(); + if (amount > highestAmount.intValue()) { + highestAmount.setValue(amount); + highestSpot.setValue(blockPos); + } + }); + BlockPos highest = highestSpot.getValue(); + if (highest == null) + highest = defaultSpot; + return highest; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java index 9ef6a06b..997e450d 100644 --- a/src/main/java/de/ellpeck/naturesaura/NaturesAura.java +++ b/src/main/java/de/ellpeck/naturesaura/NaturesAura.java @@ -1,9 +1,10 @@ package de.ellpeck.naturesaura; -import de.ellpeck.naturesaura.aura.Capabilities.StorageImpl; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.aura.item.IAuraRecharge; +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; +import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.commands.CommandAura; @@ -54,9 +55,10 @@ 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(AuraChunk.class, new StorageImpl<>(), () -> null); + CapabilityManager.INSTANCE.register(IAuraChunk.class, new StorageImpl<>(), () -> null); new ModBlocks(); new ModItems(); diff --git a/src/main/java/de/ellpeck/naturesaura/aura/Capabilities.java b/src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java similarity index 71% rename from src/main/java/de/ellpeck/naturesaura/aura/Capabilities.java rename to src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java index 928c2b49..b9cb4d3e 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/Capabilities.java +++ b/src/main/java/de/ellpeck/naturesaura/api/NACapabilities.java @@ -1,8 +1,8 @@ -package de.ellpeck.naturesaura.aura; +package de.ellpeck.naturesaura.api; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.aura.item.IAuraRecharge; +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; @@ -11,7 +11,7 @@ import net.minecraftforge.common.capabilities.CapabilityInject; import javax.annotation.Nullable; -public final class Capabilities { +public final class NACapabilities { @CapabilityInject(IAuraContainer.class) public static Capability auraContainer; @@ -19,8 +19,8 @@ public final class Capabilities { @CapabilityInject(IAuraRecharge.class) public static Capability auraRecharge; - @CapabilityInject(AuraChunk.class) - public static Capability auraChunk; + @CapabilityInject(IAuraChunk.class) + public static Capability auraChunk; public static class StorageImpl implements IStorage { diff --git a/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java new file mode 100644 index 00000000..a070a667 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java @@ -0,0 +1,111 @@ +package de.ellpeck.naturesaura.api; + +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.internal.StubHooks; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.apache.commons.lang3.mutable.MutableInt; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.BiConsumer; + +/** + * The main class of the Nature's Aura API. This is where you can find recipe + * lists and the {@link IInternalHooks} instance, which can be used to hook into + * internal mod functions not exposed to the API. + */ +public final class NaturesAuraAPI { + private static IInternalHooks instance = new StubHooks(); + + /** + * The list of all {@link AltarRecipe} instances which are the recipes used + * by the Natural Altar. Newly created recipes are automatically added to + * this list. + */ + public static final Map ALTAR_RECIPES = new HashMap<>(); + /** + * The list of all {@link TreeRitualRecipe} instances which are the recipes + * used in the Ritual of the Forest. Newly created recipes are automatically + * added to this list. + */ + public static final Map TREE_RITUAL_RECIPES = new HashMap<>(); + + /** + * This method returns the active {@link IInternalHooks} instance which can + * be used to hook into the mod's internal functionalities. This is + * instantiated as {@link StubHooks} by default which has no functionality, + * but, in the mod's preInit phase, this will be overriden to a proper + * implementation. If you want to use this instance, use it after Nature's + * Aura's preInit phase. + * + * @return The active {@link IInternalHooks} instance + */ + public static IInternalHooks instance() { + return instance; + } + + /** + * This is an internal function. Do not use. + */ + public static void setInstance(IInternalHooks inst) { + if (instance instanceof StubHooks) + instance = inst; + else + throw new IllegalStateException(); + } + + /** + * @see #instance() + */ + public interface IInternalHooks { + + /** + * This method can be used to spawn the magic particle effect used by + * Nature's Aura. It will not have an effect on the client side, so if + * you want to send it from the server side, you need to create your own + * packet. + * + * @param world The world to spawn the particle in + * @param posX The x position + * @param posY The y position + * @param posZ The z position + * @param motionX The x motion + * @param motionY The y motion + * @param motionZ The z motion + * @param color The color the particle should have, in hex + * @param scale The scale of the particle + * @param maxAge The max age before the particle should die + * @param gravity The amount of gravity the particle should have, can + * be 0 + * @param collision If the particle should collide with blocks + * @param fade If the particle should slowly fade out or suddenly + * disappear + */ + void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade); + + /** + * @see IAuraChunk#getSpotsInArea(World, BlockPos, int, BiConsumer) + */ + void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer); + + /** + * @see IAuraChunk#getAuraInArea(World, BlockPos, int) + */ + int getAuraInArea(World world, BlockPos pos, int radius); + + /** + * @see IAuraChunk#getLowestSpot(World, BlockPos, int, BlockPos) + */ + BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot); + + /** + * @see IAuraChunk#getHighestSpot(World, BlockPos, int, BlockPos) + */ + BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot); + } + +} diff --git a/src/main/java/de/ellpeck/naturesaura/aura/AuraType.java b/src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java similarity index 92% rename from src/main/java/de/ellpeck/naturesaura/aura/AuraType.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java index 83b2f90b..2f0c7932 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/AuraType.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/AuraType.java @@ -1,4 +1,4 @@ -package de.ellpeck.naturesaura.aura; +package de.ellpeck.naturesaura.api.aura; import net.minecraft.world.World; 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 new file mode 100644 index 00000000..a15d9947 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IAuraChunk.java @@ -0,0 +1,132 @@ +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.AuraType; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.INBTSerializable; +import org.apache.commons.lang3.mutable.MutableInt; + +import java.util.function.BiConsumer; + +/** + * A class whose instances hold information about the aura present in any given + * {@link Chunk}. To get an instance for a chunk, use {@link + * #getAuraChunk(World, BlockPos)}. + *

+ * It is not intended for API users to create custom implementation of this + * class. + */ +public interface IAuraChunk extends ICapabilityProvider, INBTSerializable { + /** + * The default amount of Aura that a chunk has stored + */ + int DEFAULT_AURA = 10000; + + /** + * This method is used to get information about the Aura in any given chunk. + * This is a convenience method. + * + * @param world The world + * @param pos A position that the chunk contains + * @return The {@link IAuraChunk} instance belonging to the chunk + */ + static IAuraChunk getAuraChunk(World world, BlockPos pos) { + Chunk chunk = world.getChunk(pos); + if (chunk.hasCapability(NACapabilities.auraChunk, null)) { + return chunk.getCapability(NACapabilities.auraChunk, null); + } else { + return null; + } + } + + /** + * This method uses the supplied consumer to iterate over all the drain + * spots, represented as a position and the number of Aura in them, in any + * given area. + *

+ * Notice that this is different from {@link #getSpotsInArea(BlockPos, int, + * BiConsumer)} because this method iterates over several chunks while the + * former only uses the current aura chunk instance. Most of the time, you + * will want to use this method. + * + * @param world The world + * @param pos The center position + * @param radius The radius around the center to search for spots in + * @param consumer A consumer that gets given the position and amount of + * aura in each drain spot found + */ + static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer) { + NaturesAuraAPI.instance().getAuraSpotsInArea(world, pos, radius, consumer); + } + + /** + * Convenience method that adds up all of the aura from each drain spot from + * {@link #getSpotsInArea(World, BlockPos, int, BiConsumer)} and + * conveniently returns it. + * + * @param world The world + * @param pos The center position + * @param radius The radius around the center to search for spots in + * @return The amount of Aura present in that area, based on the drain spots + * that are found + */ + static int getAuraInArea(World world, BlockPos pos, int radius) { + return NaturesAuraAPI.instance().getAuraInArea(world, pos, radius); + } + + /** + * This method returns the position of the lowest drain spot (meaning the + * one that has the least Aura stored) in the given area. This should be + * used with any machines that fill up Aura in an area, so that the most + * drained spots get selected first. + * + * @param world The world + * @param pos The center position + * @param radius The radius around the center to search for spots in + * @param defaultSpot A position that will be used to create a new drain + * spot when none are found + * @return The position of the lowest drain spot + */ + static BlockPos getLowestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + return NaturesAuraAPI.instance().getLowestAuraDrainSpot(world, pos, radius, defaultSpot); + } + + /** + * This method returns the position of the highest drain spot (meaning the + * one that has the most Aura stored) in the given area. This should be used + * with any machines that use up Aura so that the spots with the highest + * amount are drained first. + * + * @param world The world + * @param pos The center position + * @param radius The radius around the center to search for spots in + * @param defaultSpot A position that will be used to create a new drain + * spot when none are found + * @return The position of the highest drain spot + */ + static BlockPos getHighestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + return NaturesAuraAPI.instance().getHighestAuraDrainSpot(world, pos, radius, defaultSpot); + } + + void addEffect(IDrainSpotEffect effect); + + /** + * @see #getSpotsInArea(World, BlockPos, int, BiConsumer) + */ + void getSpotsInArea(BlockPos pos, int radius, BiConsumer consumer); + + void drainAura(BlockPos pos, int amount); + + void storeAura(BlockPos pos, int amount); + + MutableInt getDrainSpot(BlockPos pos); + + AuraType getType(); + + void markDirty(); +} diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/IDrainSpotEffect.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java similarity index 50% rename from src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/IDrainSpotEffect.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java index 7009965b..8e9394cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/IDrainSpotEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/IDrainSpotEffect.java @@ -1,7 +1,6 @@ -package de.ellpeck.naturesaura.aura.chunk.effect; +package de.ellpeck.naturesaura.api.aura.chunk; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.AuraType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @@ -9,7 +8,7 @@ import org.apache.commons.lang3.mutable.MutableInt; public interface IDrainSpotEffect { - void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot); + void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot); boolean appliesToType(AuraType type); } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/ISpotDrainable.java b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/ISpotDrainable.java similarity index 53% rename from src/main/java/de/ellpeck/naturesaura/aura/chunk/ISpotDrainable.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/chunk/ISpotDrainable.java index 3bbbba82..33b81543 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/ISpotDrainable.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/chunk/ISpotDrainable.java @@ -1,6 +1,6 @@ -package de.ellpeck.naturesaura.aura.chunk; +package de.ellpeck.naturesaura.api.aura.chunk; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; public interface ISpotDrainable extends IAuraContainer { diff --git a/src/main/java/de/ellpeck/naturesaura/aura/container/BasicAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java similarity index 93% rename from src/main/java/de/ellpeck/naturesaura/aura/container/BasicAuraContainer.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java index 5c43d7e1..cc9e4e7c 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/container/BasicAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/BasicAuraContainer.java @@ -1,6 +1,6 @@ -package de.ellpeck.naturesaura.aura.container; +package de.ellpeck.naturesaura.api.aura.container; -import de.ellpeck.naturesaura.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.AuraType; import net.minecraft.nbt.NBTTagCompound; public class BasicAuraContainer implements IAuraContainer { diff --git a/src/main/java/de/ellpeck/naturesaura/aura/container/IAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/IAuraContainer.java similarity index 73% rename from src/main/java/de/ellpeck/naturesaura/aura/container/IAuraContainer.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/container/IAuraContainer.java index dbdbefd7..5477def3 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/container/IAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/IAuraContainer.java @@ -1,6 +1,6 @@ -package de.ellpeck.naturesaura.aura.container; +package de.ellpeck.naturesaura.api.aura.container; -import de.ellpeck.naturesaura.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.AuraType; public interface IAuraContainer { int storeAura(int amountToStore, boolean simulate); diff --git a/src/main/java/de/ellpeck/naturesaura/aura/container/ItemAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java similarity index 94% rename from src/main/java/de/ellpeck/naturesaura/aura/container/ItemAuraContainer.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java index 0b104151..4cd9228e 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/container/ItemAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/ItemAuraContainer.java @@ -1,6 +1,6 @@ -package de.ellpeck.naturesaura.aura.container; +package de.ellpeck.naturesaura.api.aura.container; -import de.ellpeck.naturesaura.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.AuraType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/main/java/de/ellpeck/naturesaura/aura/container/NaturalAuraContainer.java b/src/main/java/de/ellpeck/naturesaura/api/aura/container/NaturalAuraContainer.java similarity index 78% rename from src/main/java/de/ellpeck/naturesaura/aura/container/NaturalAuraContainer.java rename to src/main/java/de/ellpeck/naturesaura/api/aura/container/NaturalAuraContainer.java index b1d2c9d3..777f01de 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/container/NaturalAuraContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/container/NaturalAuraContainer.java @@ -1,7 +1,7 @@ -package de.ellpeck.naturesaura.aura.container; +package de.ellpeck.naturesaura.api.aura.container; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable; public class NaturalAuraContainer extends BasicAuraContainer implements ISpotDrainable { diff --git a/src/main/java/de/ellpeck/naturesaura/api/aura/item/IAuraRecharge.java b/src/main/java/de/ellpeck/naturesaura/api/aura/item/IAuraRecharge.java new file mode 100644 index 00000000..42f15628 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/aura/item/IAuraRecharge.java @@ -0,0 +1,9 @@ +package de.ellpeck.naturesaura.api.aura.item; + +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; + +public interface IAuraRecharge { + + void rechargeFromContainer(IAuraContainer container); + +} diff --git a/src/main/java/de/ellpeck/naturesaura/api/internal/StubHooks.java b/src/main/java/de/ellpeck/naturesaura/api/internal/StubHooks.java new file mode 100644 index 00000000..3b820144 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/api/internal/StubHooks.java @@ -0,0 +1,35 @@ +package de.ellpeck.naturesaura.api.internal; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import org.apache.commons.lang3.mutable.MutableInt; + +import java.util.function.BiConsumer; + +public class StubHooks implements NaturesAuraAPI.IInternalHooks { + @Override + public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) { + + } + + @Override + public void getAuraSpotsInArea(World world, BlockPos pos, int radius, BiConsumer consumer) { + + } + + @Override + public int getAuraInArea(World world, BlockPos pos, int radius) { + return 0; + } + + @Override + public BlockPos getLowestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + return BlockPos.ORIGIN; + } + + @Override + public BlockPos getHighestAuraDrainSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { + return BlockPos.ORIGIN; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java similarity index 55% rename from src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java rename to src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java index fb050a9d..7d3dc83d 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/AltarRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java @@ -1,17 +1,12 @@ -package de.ellpeck.naturesaura.recipes; +package de.ellpeck.naturesaura.api.recipes; -import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import java.util.HashMap; -import java.util.Map; - public class AltarRecipe { - public static final Map RECIPES = new HashMap<>(); - public final ResourceLocation name; public final ItemStack input; public final ItemStack output; @@ -27,15 +22,6 @@ public class AltarRecipe { this.aura = aura; this.time = time; - RECIPES.put(this.name, this); - } - - public static AltarRecipe forInput(ItemStack input) { - for (AltarRecipe recipe : RECIPES.values()) { - if (Helper.areItemsEqual(recipe.input, input, true)) { - return recipe; - } - } - return null; + NaturesAuraAPI.ALTAR_RECIPES.put(this.name, this); } } diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java similarity index 72% rename from src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java rename to src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java index 2f6f83f3..a1579ea9 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java @@ -1,15 +1,11 @@ -package de.ellpeck.naturesaura.recipes; +package de.ellpeck.naturesaura.api.recipes; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import java.util.HashMap; -import java.util.Map; - public class TreeRitualRecipe { - public static final Map RECIPES = new HashMap<>(); - public final ResourceLocation name; public final ItemStack saplingType; public final ItemStack[] items; @@ -23,6 +19,6 @@ public class TreeRitualRecipe { this.result = result; this.time = time; - RECIPES.put(this.name, this); + NaturesAuraAPI.TREE_RITUAL_RECIPES.put(this.name, this); } } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/AuraChunk.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/AuraChunk.java index 6a5735ae..de65ee36 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/AuraChunk.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/AuraChunk.java @@ -1,11 +1,11 @@ package de.ellpeck.naturesaura.aura.chunk; -import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.Capabilities; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.aura.chunk.effect.GrassDieEffect; -import de.ellpeck.naturesaura.aura.chunk.effect.IDrainSpotEffect; import de.ellpeck.naturesaura.aura.chunk.effect.PlantBoostEffect; import de.ellpeck.naturesaura.aura.chunk.effect.ReplenishingEffect; import de.ellpeck.naturesaura.packet.PacketAuraChunk; @@ -18,11 +18,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.common.util.INBTSerializable; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import org.apache.commons.lang3.mutable.MutableInt; -import org.apache.commons.lang3.mutable.MutableObject; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -32,9 +29,7 @@ import java.util.List; import java.util.Map; import java.util.function.BiConsumer; -public class AuraChunk implements ICapabilityProvider, INBTSerializable { - - public static final int DEFAULT_AURA = 10000; +public class AuraChunk implements IAuraChunk { private final Chunk chunk; private final AuraType type; @@ -51,74 +46,13 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable consumer) { - world.profiler.func_194340_a(() -> NaturesAura.MOD_ID + ":getSpotsInArea"); - for (int x = (pos.getX() - radius) >> 4; x <= (pos.getX() + radius) >> 4; x++) { - 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(Capabilities.auraChunk, null)) { - AuraChunk auraChunk = chunk.getCapability(Capabilities.auraChunk, null); - auraChunk.getSpotsInArea(pos, radius, consumer); - } - } - } - } - world.profiler.endSection(); - } - - public static int getAuraInArea(World world, BlockPos pos, int radius) { - MutableInt result = new MutableInt(DEFAULT_AURA); - getSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> result.add(drainSpot.intValue())); - return result.intValue(); - } - - public static AuraChunk getAuraChunk(World world, BlockPos pos) { - Chunk chunk = world.getChunk(pos); - if (chunk.hasCapability(Capabilities.auraChunk, null)) { - return chunk.getCapability(Capabilities.auraChunk, null); - } else { - return null; - } - } - - public static BlockPos getLowestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { - MutableInt lowestAmount = new MutableInt(Integer.MAX_VALUE); - MutableObject lowestSpot = new MutableObject<>(); - getSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { - int amount = drainSpot.intValue(); - if (amount < lowestAmount.intValue()) { - lowestAmount.setValue(amount); - lowestSpot.setValue(blockPos); - } - }); - BlockPos lowest = lowestSpot.getValue(); - if (lowest == null) - lowest = defaultSpot; - return lowest; - } - - public static BlockPos getHighestSpot(World world, BlockPos pos, int radius, BlockPos defaultSpot) { - MutableInt highestAmount = new MutableInt(Integer.MIN_VALUE); - MutableObject highestSpot = new MutableObject<>(); - getSpotsInArea(world, pos, radius, (blockPos, drainSpot) -> { - int amount = drainSpot.intValue(); - if (amount > highestAmount.intValue()) { - highestAmount.setValue(amount); - highestSpot.setValue(blockPos); - } - }); - BlockPos highest = highestSpot.getValue(); - if (highest == null) - highest = defaultSpot; - return highest; - } - + @Override public void getSpotsInArea(BlockPos pos, int radius, BiConsumer consumer) { for (Map.Entry entry : this.drainSpots.entrySet()) { BlockPos drainPos = entry.getKey(); @@ -128,6 +62,7 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable capability, @Nullable EnumFacing facing) { - return capability == Capabilities.auraChunk; + return capability == NACapabilities.auraChunk; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - return capability == Capabilities.auraChunk ? (T) this : null; + return capability == NACapabilities.auraChunk ? (T) this : null; } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java index b928cad2..fc81c9d7 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/GrassDieEffect.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.aura.chunk.effect; -import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.blocks.ModBlocks; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; @@ -15,9 +15,9 @@ import org.apache.commons.lang3.mutable.MutableInt; public class GrassDieEffect implements IDrainSpotEffect { @Override - public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) { + public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) { if (spot.intValue() < 0) { - int aura = AuraChunk.getAuraInArea(world, pos, 25); + int aura = IAuraChunk.getAuraInArea(world, pos, 25); if (aura < 0) { int amount = Math.min(300, Math.abs(aura) / 1000); if (amount > 1) { diff --git a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java index 71ff786c..2f48ccb0 100644 --- a/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java +++ b/src/main/java/de/ellpeck/naturesaura/aura/chunk/effect/PlantBoostEffect.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.aura.chunk.effect; -import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.block.Block; @@ -17,10 +17,10 @@ import org.apache.commons.lang3.mutable.MutableInt; public class PlantBoostEffect implements IDrainSpotEffect { @Override - public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) { + public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) { if (spot.intValue() <= 0) return; - int aura = AuraChunk.getAuraInArea(world, pos, 25); + int aura = IAuraChunk.getAuraInArea(world, pos, 25); if (aura <= 0) return; int amount = Math.min(45, Math.abs(aura) / 1000); @@ -42,8 +42,8 @@ public class PlantBoostEffect implements IDrainSpotEffect { if (growable.canGrow(world, plantPos, state, false)) { growable.grow(world, world.rand, plantPos, state); - BlockPos closestSpot = AuraChunk.getHighestSpot(world, plantPos, 25, pos); - AuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 100); + BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos); + IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 100); PacketHandler.sendToAllAround(world, plantPos, 32, new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6)); 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 61bd2383..5e50386e 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,11 +1,12 @@ package de.ellpeck.naturesaura.aura.chunk.effect; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; -import de.ellpeck.naturesaura.aura.chunk.ISpotDrainable; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect; +import de.ellpeck.naturesaura.api.aura.chunk.ISpotDrainable; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; @@ -16,14 +17,14 @@ import java.util.List; public class ReplenishingEffect implements IDrainSpotEffect { @Override - public void update(World world, Chunk chunk, AuraChunk auraChunk, BlockPos pos, MutableInt spot) { + public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, MutableInt spot) { int amount = spot.intValue(); if (amount < 0) { AuraType type = AuraType.forWorld(world); List tiles = new ArrayList<>(); Helper.getTileEntitiesInArea(world, pos, 25, tile -> { - if (tile.hasCapability(Capabilities.auraContainer, null)) { - IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null); + if (tile.hasCapability(NACapabilities.auraContainer, null)) { + IAuraContainer container = tile.getCapability(NACapabilities.auraContainer, null); if (container instanceof ISpotDrainable) { tiles.add((ISpotDrainable) container); } diff --git a/src/main/java/de/ellpeck/naturesaura/aura/item/IAuraRecharge.java b/src/main/java/de/ellpeck/naturesaura/aura/item/IAuraRecharge.java deleted file mode 100644 index b6aee92f..00000000 --- a/src/main/java/de/ellpeck/naturesaura/aura/item/IAuraRecharge.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.ellpeck.naturesaura.aura.item; - -import de.ellpeck.naturesaura.aura.container.IAuraContainer; - -public interface IAuraRecharge { - - void rechargeFromContainer(IAuraContainer container); - -} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java index 47d32ac4..f0b447d1 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAncientLeaves.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAncientLeaves; import de.ellpeck.naturesaura.reg.*; import net.minecraft.block.BlockLeaves; @@ -132,7 +133,7 @@ public class BlockAncientLeaves extends BlockLeaves implements TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityAncientLeaves) { if (((TileEntityAncientLeaves) tile).getAuraContainer(null).getStoredAura() > 0) { - NaturesAura.proxy.spawnMagicParticle(worldIn, + NaturesAuraAPI.instance().spawnMagicParticle(worldIn, pos.getX() + rand.nextDouble(), pos.getY(), pos.getZ() + rand.nextDouble(), 0F, 0F, 0F, 0xc46df9, rand.nextFloat() * 2F + 0.5F, diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java index 3afcd442..ad8e55e6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockFurnaceHeater.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks; -import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.tiles.TileEntityFurnaceHeater; import net.minecraft.block.material.Material; import net.minecraft.block.state.BlockFaceShape; @@ -31,7 +31,7 @@ public class BlockFurnaceHeater extends BlockContainerImpl { public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileEntityFurnaceHeater && ((TileEntityFurnaceHeater) tile).isActive) { - NaturesAura.proxy.spawnMagicParticle(worldIn, + NaturesAuraAPI.instance().spawnMagicParticle(worldIn, pos.getX() + 0.35F + rand.nextFloat() * 0.3F, pos.getY() + 0.2F, pos.getZ() + 0.35F + rand.nextFloat() * 0.3F, diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java index c154010b..45c9093d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAncientLeaves.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.blocks.tiles; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.aura.container.NaturalAuraContainer; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.aura.container.NaturalAuraContainer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java index 76b57972..6eb122b9 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAuraDetector.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.blocks.tiles; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.util.ITickable; import net.minecraft.util.math.MathHelper; @@ -11,8 +11,8 @@ public class TileEntityAuraDetector extends TileEntityImpl implements ITickable @Override public void update() { if (!this.world.isRemote && this.world.getTotalWorldTime() % 80 == 0) { - int amount = AuraChunk.getAuraInArea(this.world, this.pos, 8); - int power = MathHelper.clamp(MathHelper.ceil(amount / (AuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15); + int amount = IAuraChunk.getAuraInArea(this.world, this.pos, 8); + int power = MathHelper.clamp(MathHelper.ceil(amount / (IAuraChunk.DEFAULT_AURA * 2F) * 15F), 0, 15); if (this.redstonePower != power) { this.redstonePower = power; this.world.updateComparatorOutputLevel(this.pos, this.getBlockType()); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java index e5d334de..063ecbb6 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFlowerGenerator.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -62,9 +62,9 @@ public class TileEntityFlowerGenerator extends TileEntityImpl implements ITickab int addAmount = 100; int toAdd = Math.max(0, addAmount - curr.getValue()); if (toAdd > 0) { - BlockPos auraPos = AuraChunk.getLowestSpot(this.world, this.pos, 30, this.pos); - if (AuraType.OVERWORLD.isPresent(this.world) && AuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000) - AuraChunk.getAuraChunk(this.world, auraPos).storeAura(auraPos, toAdd); + BlockPos auraPos = IAuraChunk.getLowestSpot(this.world, this.pos, 30, this.pos); + if (AuraType.OVERWORLD.isPresent(this.world) && IAuraChunk.getAuraInArea(this.world, auraPos, 30) < 20000) + IAuraChunk.getAuraChunk(this.world, auraPos).storeAura(auraPos, toAdd); else toAdd = 0; } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java index 991545e7..bb25a641 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityFurnaceHeater.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; @@ -34,8 +35,8 @@ public class TileEntityFurnaceHeater extends TileEntityImpl implements ITickable //if set higher than 199, it'll never finish because the furnace does ++ and then == furnace.setField(2, Math.min(199, furnace.getField(2) + 5)); - BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 15, this.pos); - AuraChunk chunk = AuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 15, this.pos); + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); chunk.drainAura(spot, MathHelper.ceil((200 - time) / 4F)); did = true; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java index 7acd0d3a..adb850ca 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityHopperUpgrade.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.blocks.tiles; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; @@ -21,7 +22,7 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable @Override public void update() { if (!this.world.isRemote && this.world.getTotalWorldTime() % 10 == 0) { - if (AuraChunk.getAuraInArea(this.world, this.pos, 25) < 1000) + if (IAuraChunk.getAuraInArea(this.world, this.pos, 25) < 1000) return; TileEntity tile = this.world.getTileEntity(this.pos.down()); if (!(tile instanceof TileEntityHopper) || !BlockHopper.isEnabled(tile.getBlockMetadata())) @@ -58,8 +59,8 @@ public class TileEntityHopperUpgrade extends TileEntityImpl implements ITickable if (copy.isEmpty()) item.setDead(); - BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos); - AuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10); + BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 25, this.pos); + IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles((float) item.posX, (float) item.posY, (float) item.posZ, 10)); 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 2594f045..ebfd68d8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityImpl.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.blocks.tiles; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; @@ -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 == Capabilities.auraContainer) { + } else if (capability == NACapabilities.auraContainer) { 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 == Capabilities.auraContainer) { + } else if (capability == NACapabilities.auraContainer) { 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 296711e3..db8e82ed 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -2,16 +2,17 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; -import de.ellpeck.naturesaura.aura.container.BasicAuraContainer; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.container.BasicAuraContainer; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; -import de.ellpeck.naturesaura.recipes.AltarRecipe; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.SoundEvents; @@ -39,15 +40,15 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { @Override protected boolean canInsert(ItemStack stack, int slot) { - return AltarRecipe.forInput(stack) != null || stack.hasCapability(Capabilities.auraContainer, null); + return getRecipeForInput(stack) != null || stack.hasCapability(NACapabilities.auraContainer, null); } @Override protected boolean canExtract(ItemStack stack, int slot, int amount) { - if (stack.hasCapability(Capabilities.auraContainer, null)) - return stack.getCapability(Capabilities.auraContainer, null).storeAura(1, true) <= 0; + if (stack.hasCapability(NACapabilities.auraContainer, null)) + return stack.getCapability(NACapabilities.auraContainer, null).storeAura(1, true) <= 0; else - return AltarRecipe.forInput(stack) == null; + return getRecipeForInput(stack) == null; } }; @@ -78,10 +79,10 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { if (this.structureFine) { int space = this.container.storeAura(3, true); if (space > 0 && this.container.isAcceptableType(AuraType.forWorld(this.world))) { - int toStore = Math.min(AuraChunk.getAuraInArea(this.world, this.pos, 20), space); + int toStore = Math.min(IAuraChunk.getAuraInArea(this.world, this.pos, 20), space); if (toStore > 0) { - BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos); - AuraChunk chunk = AuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 20, this.pos); + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); chunk.drainAura(spot, toStore); this.container.storeAura(toStore, false); @@ -98,8 +99,8 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { } ItemStack stack = this.items.getStackInSlot(0); - if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) { - IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null); + if (!stack.isEmpty() && stack.hasCapability(NACapabilities.auraContainer, null)) { + IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, null); int theoreticalDrain = this.container.drainAura(10, true); if (theoreticalDrain > 0) { int stored = container.storeAura(theoreticalDrain, false); @@ -114,7 +115,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { } else { if (this.currentRecipe == null) { if (!stack.isEmpty()) { - this.currentRecipe = AltarRecipe.forInput(stack); + this.currentRecipe = getRecipeForInput(stack); } } else { if (stack.isEmpty() || !Helper.areItemsEqual(stack, this.currentRecipe.input, true)) { @@ -153,22 +154,22 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { if (rand.nextFloat() >= 0.7F) { int fourths = this.container.getMaxAura() / 4; if (this.container.getStoredAura() > 0) { - NaturesAura.proxy.spawnMagicParticle(this.world, + NaturesAuraAPI.instance().spawnMagicParticle(this.world, this.pos.getX() - 4F + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths) { - NaturesAura.proxy.spawnMagicParticle(this.world, + NaturesAuraAPI.instance().spawnMagicParticle(this.world, this.pos.getX() + 4F + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 2) { - NaturesAura.proxy.spawnMagicParticle(this.world, + NaturesAuraAPI.instance().spawnMagicParticle(this.world, this.pos.getX() + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() - 4F + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } if (this.container.getStoredAura() >= fourths * 3) { - NaturesAura.proxy.spawnMagicParticle(this.world, + NaturesAuraAPI.instance().spawnMagicParticle(this.world, this.pos.getX() + rand.nextFloat(), this.pos.getY() + 3F, this.pos.getZ() + 4F + rand.nextFloat(), 0F, 0F, 0F, this.container.getAuraColor(), rand.nextFloat() * 3F + 1F, rand.nextInt(100) + 50, -0.05F, true, true); } @@ -180,6 +181,15 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { } } + private static AltarRecipe getRecipeForInput(ItemStack input) { + for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) { + if (Helper.areItemsEqual(recipe.input, input, true)) { + return recipe; + } + } + return null; + } + private boolean hasCatalyst(Block block) { if (block == null) return true; @@ -220,7 +230,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { } if (type == SaveType.TILE) { if (compound.hasKey("recipe")) { - this.currentRecipe = AltarRecipe.RECIPES.get(new ResourceLocation(compound.getString("recipe"))); + this.currentRecipe = NaturesAuraAPI.ALTAR_RECIPES.get(new ResourceLocation(compound.getString("recipe"))); this.timer = compound.getInteger("timer"); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java index dfb25fcf..156b6b0c 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.items.ModItems; @@ -74,8 +75,8 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable { continue; handler.extractItem(i, 1, false); - BlockPos spot = AuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos); - AuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10); + BlockPos spot = IAuraChunk.getHighestSpot(this.world, this.pos, 10, this.pos); + IAuraChunk.getAuraChunk(this.world, spot).drainAura(spot, 10); PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(pos.getX(), pos.getY(), pos.getZ(), 9)); diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java index 4f2e00f4..f17f8471 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPotionGenerator.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.blocks.tiles; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -47,9 +48,9 @@ public class TileEntityPotionGenerator extends TileEntityImpl implements ITickab boolean foundEmpty = false; for (EnumFacing dir : EnumFacing.HORIZONTALS) { BlockPos offset = this.pos.offset(dir, 12); - BlockPos spot = AuraChunk.getLowestSpot(this.world, offset, 15, offset); - if (AuraChunk.getAuraInArea(this.world, spot, 15) < 20000) { - AuraChunk chunk = AuraChunk.getAuraChunk(this.world, spot); + BlockPos spot = IAuraChunk.getLowestSpot(this.world, offset, 15, offset); + if (IAuraChunk.getAuraInArea(this.world, spot, 15) < 20000) { + IAuraChunk chunk = IAuraChunk.getAuraChunk(this.world, spot); chunk.storeAura(spot, toAdd); foundEmpty = true; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index c07d3d35..b7378c22 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -1,11 +1,12 @@ package de.ellpeck.naturesaura.blocks.tiles; import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticleStream; import de.ellpeck.naturesaura.packet.PacketParticles; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLog; import net.minecraft.block.state.IBlockState; @@ -191,7 +192,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { if (compound.hasKey("recipe")) { this.ritualPos = BlockPos.fromLong(compound.getLong("ritual_pos")); this.timer = compound.getInteger("timer"); - this.recipe = TreeRitualRecipe.RECIPES.get(new ResourceLocation(compound.getString("recipe"))); + this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(new ResourceLocation(compound.getString("recipe"))); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java index 3eb906ab..155aaaad 100644 --- a/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java +++ b/src/main/java/de/ellpeck/naturesaura/commands/CommandAura.java @@ -1,7 +1,7 @@ package de.ellpeck.naturesaura.commands; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.command.*; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; @@ -43,12 +43,12 @@ public class CommandAura extends CommandBase { BlockPos pos = sender.getPosition(); if ("add".equals(action)) { - BlockPos spot = AuraChunk.getLowestSpot(world, pos, range, pos); - AuraChunk.getAuraChunk(world, spot).storeAura(spot, amount); + BlockPos spot = IAuraChunk.getLowestSpot(world, pos, range, pos); + IAuraChunk.getAuraChunk(world, spot).storeAura(spot, amount); sender.sendMessage(new TextComponentString("Added " + amount + " aura")); } else if ("remove".equals(action)) { - BlockPos spot = AuraChunk.getHighestSpot(world, pos, range, pos); - AuraChunk.getAuraChunk(world, spot).drainAura(spot, amount); + BlockPos spot = IAuraChunk.getHighestSpot(world, pos, range, pos); + IAuraChunk.getAuraChunk(world, spot).drainAura(spot, amount); sender.sendMessage(new TextComponentString("Removed " + amount + " aura")); } else { throw new SyntaxErrorException("Invalid action " + action); diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/JEINaturesAuraPlugin.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/JEINaturesAuraPlugin.java index 14afa4e0..39a2eb46 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/JEINaturesAuraPlugin.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/JEINaturesAuraPlugin.java @@ -1,13 +1,14 @@ package de.ellpeck.naturesaura.compat.jei; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.compat.jei.altar.AltarCategory; import de.ellpeck.naturesaura.compat.jei.altar.AltarWrapper; import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualCategory; import de.ellpeck.naturesaura.compat.jei.treeritual.TreeRitualWrapper; -import de.ellpeck.naturesaura.recipes.AltarRecipe; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.IModPlugin; import mezz.jei.api.IModRegistry; @@ -35,8 +36,8 @@ public class JEINaturesAuraPlugin implements IModPlugin { registry.handleRecipes(TreeRitualRecipe.class, TreeRitualWrapper::new, TREE_RITUAL); registry.handleRecipes(AltarRecipe.class, AltarWrapper::new, ALTAR); - registry.addRecipes(TreeRitualRecipe.RECIPES.values(), TREE_RITUAL); - registry.addRecipes(AltarRecipe.RECIPES.values(), ALTAR); + registry.addRecipes(NaturesAuraAPI.TREE_RITUAL_RECIPES.values(), TREE_RITUAL); + registry.addRecipes(NaturesAuraAPI.ALTAR_RECIPES.values(), ALTAR); registry.addRecipeCatalyst(new ItemStack(ModBlocks.GOLD_POWDER), TREE_RITUAL); registry.addRecipeCatalyst(new ItemStack(ModBlocks.WOOD_STAND), TREE_RITUAL); diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java index fd8d5e2a..f2a4a699 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java @@ -3,7 +3,7 @@ package de.ellpeck.naturesaura.compat.jei.altar; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin; -import de.ellpeck.naturesaura.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java index b98d2ad1..b0be40b1 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.compat.jei.altar; -import de.ellpeck.naturesaura.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java index 38e00f3d..e5a95d60 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.compat.jei.treeritual; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java index d75469b6..fe1e6b86 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java @@ -1,6 +1,6 @@ package de.ellpeck.naturesaura.compat.jei.treeritual; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java index 065b947d..6a2a50ed 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.compat.patchouli; -import de.ellpeck.naturesaura.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import vazkii.patchouli.api.IComponentProcessor; @@ -14,7 +15,7 @@ public class ProcessorAltar implements IComponentProcessor { @Override public void setup(IVariableProvider provider) { ResourceLocation res = new ResourceLocation(provider.get("recipe")); - this.recipe = AltarRecipe.RECIPES.get(res); + this.recipe = NaturesAuraAPI.ALTAR_RECIPES.get(res); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java index 09a0d28e..9f975bc2 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.compat.patchouli; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import net.minecraft.util.ResourceLocation; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariableProvider; @@ -13,7 +14,7 @@ public class ProcessorTreeRitual implements IComponentProcessor { @Override public void setup(IVariableProvider provider) { ResourceLocation res = new ResourceLocation(provider.get("recipe")); - this.recipe = TreeRitualRecipe.RECIPES.get(res); + this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(res); } @Override diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index 840ba1c7..f7d98e0c 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -2,10 +2,10 @@ package de.ellpeck.naturesaura.events; import baubles.api.BaublesApi; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.items.ModItems; @@ -53,9 +53,9 @@ public class ClientEvents { if (mc.player.capabilities.isCreativeMode) { left.add(prefix + "Aura:"); - MutableInt amount = new MutableInt(AuraChunk.DEFAULT_AURA); + MutableInt amount = new MutableInt(IAuraChunk.DEFAULT_AURA); MutableInt spots = new MutableInt(); - AuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 15, ((blockPos, drainSpot) -> { + IAuraChunk.getSpotsInArea(mc.world, mc.player.getPosition(), 15, ((blockPos, drainSpot) -> { spots.increment(); amount.add(drainSpot.intValue()); left.add(prefix + drainSpot.intValue() + " @ " + blockPos.getX() + " " + blockPos.getY() + " " + blockPos.getZ()); @@ -124,7 +124,7 @@ public class ClientEvents { } if (!cache.isEmpty()) { - IAuraContainer container = cache.getCapability(Capabilities.auraContainer, null); + IAuraContainer container = cache.getCapability(NACapabilities.auraContainer, 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; @@ -154,7 +154,7 @@ public class ClientEvents { if (!mc.gameSettings.showDebugInfo) { GlStateManager.color(83 / 255F, 160 / 255F, 8 / 255F); - float totalPercentage = AuraChunk.getAuraInArea(mc.world, mc.player.getPosition(), 15) / (AuraChunk.DEFAULT_AURA * 2F); + float totalPercentage = IAuraChunk.getAuraInArea(mc.world, mc.player.getPosition(), 15) / (IAuraChunk.DEFAULT_AURA * 2F); int tHeight = MathHelper.ceil(MathHelper.clamp(totalPercentage, 0F, 1F) * 50); if (tHeight < 50) Gui.drawModalRectWithCustomSizedTexture(3, 10, 6, 12, 6, 50 - tHeight, 256, 256); @@ -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(Capabilities.auraContainer, null)) { - IAuraContainer container = tile.getCapability(Capabilities.auraContainer, null); + if (tile != null && tile.hasCapability(NACapabilities.auraContainer, null)) { + IAuraContainer container = tile.getCapability(NACapabilities.auraContainer, 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(Capabilities.auraContainer, null)) { - IAuraContainer stackContainer = tileStack.getCapability(Capabilities.auraContainer, null); + if (!tileStack.isEmpty() && tileStack.hasCapability(NACapabilities.auraContainer, null)) { + IAuraContainer stackContainer = tileStack.getCapability(NACapabilities.auraContainer, 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 ef569f74..c4feb5fc 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.events; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.Capabilities; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.AuraType; import de.ellpeck.naturesaura.aura.chunk.AuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; import net.minecraft.util.ResourceLocation; @@ -35,8 +35,8 @@ public class CommonEvents { Iterator chunks = event.world.getPersistentChunkIterable(((WorldServer) event.world).getPlayerChunkMap().getChunkIterator()); while (chunks.hasNext()) { Chunk chunk = chunks.next(); - if (chunk.hasCapability(Capabilities.auraChunk, null)) { - AuraChunk auraChunk = chunk.getCapability(Capabilities.auraChunk, null); + if (chunk.hasCapability(NACapabilities.auraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); auraChunk.update(); } } @@ -48,8 +48,8 @@ public class CommonEvents { @SubscribeEvent public void onChunkWatch(ChunkWatchEvent.Watch event) { Chunk chunk = event.getChunkInstance(); - if (!chunk.getWorld().isRemote && chunk.hasCapability(Capabilities.auraChunk, null)) { - AuraChunk auraChunk = chunk.getCapability(Capabilities.auraChunk, null); + if (!chunk.getWorld().isRemote && chunk.hasCapability(NACapabilities.auraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java index c8b9f436..9192cadb 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/TerrainGenEvents.java @@ -1,9 +1,10 @@ package de.ellpeck.naturesaura.events; import de.ellpeck.naturesaura.Helper; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand; -import de.ellpeck.naturesaura.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -28,7 +29,7 @@ public class TerrainGenEvents { IBlockState sapling = world.getBlockState(pos); ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling); if (!saplingStack.isEmpty()) { - for (TreeRitualRecipe recipe : TreeRitualRecipe.RECIPES.values()) { + for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values()) { if (Helper.areItemsEqual(saplingStack, recipe.saplingType, true)) { List required = new ArrayList<>(Arrays.asList(recipe.items)); MutableObject toPick = new MutableObject<>(); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java index be77c544..072da149 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; -import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; @@ -38,7 +38,7 @@ public class ItemAuraBottle extends ItemImpl { if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) return; BlockPos pos = player.getPosition(); - if (AuraChunk.getAuraInArea(player.world, pos, 30) < 1000) + if (IAuraChunk.getAuraInArea(player.world, pos, 30) < 1000) return; if (!player.world.isRemote) { @@ -47,8 +47,8 @@ public class ItemAuraBottle extends ItemImpl { player.inventory.addItemStackToInventory( setType(new ItemStack(this), AuraType.forWorld(player.world))); - BlockPos spot = AuraChunk.getHighestSpot(player.world, pos, 30, pos); - AuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 200); + BlockPos spot = IAuraChunk.getHighestSpot(player.world, pos, 30, pos); + IAuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 200); player.world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1F, 1F); diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index 9a17814b..e3a3bae1 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -1,9 +1,9 @@ package de.ellpeck.naturesaura.items; import de.ellpeck.naturesaura.Helper; -import de.ellpeck.naturesaura.aura.Capabilities; -import de.ellpeck.naturesaura.aura.container.IAuraContainer; -import de.ellpeck.naturesaura.aura.container.ItemAuraContainer; +import de.ellpeck.naturesaura.api.NACapabilities; +import de.ellpeck.naturesaura.api.aura.container.IAuraContainer; +import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer; import de.ellpeck.naturesaura.renderers.ITrinketItem; import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets.RenderType; import net.minecraft.client.renderer.GlStateManager; @@ -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(Capabilities.auraRecharge, null)) { - IAuraContainer container = stackIn.getCapability(Capabilities.auraContainer, null); - stack.getCapability(Capabilities.auraRecharge, null).rechargeFromContainer(container); + if (stack.hasCapability(NACapabilities.auraRecharge, null)) { + IAuraContainer container = stackIn.getCapability(NACapabilities.auraContainer, null); + stack.getCapability(NACapabilities.auraRecharge, 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(Capabilities.auraContainer, null); + IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, 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(Capabilities.auraContainer, null)) { - IAuraContainer container = stack.getCapability(Capabilities.auraContainer, null); + if (stack.hasCapability(NACapabilities.auraContainer, null)) { + IAuraContainer container = stack.getCapability(NACapabilities.auraContainer, 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 == Capabilities.auraContainer; + return capability == NACapabilities.auraContainer; } @Nullable @Override public T getCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { - if (capability == Capabilities.auraContainer) { + if (capability == NACapabilities.auraContainer) { 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 d001efb3..6f05a409 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.aura.Capabilities; +import de.ellpeck.naturesaura.api.NACapabilities; 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(Capabilities.auraChunk, null)) { - AuraChunk auraChunk = chunk.getCapability(Capabilities.auraChunk, null); + if (chunk.hasCapability(NACapabilities.auraChunk, null)) { + AuraChunk auraChunk = (AuraChunk) chunk.getCapability(NACapabilities.auraChunk, null); auraChunk.setSpots(message.drainSpots); } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java index 6fc91f4e..2892a37d 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticleStream.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; @@ -80,7 +81,7 @@ public class PacketParticleStream implements IMessage { int maxAge = (int) (dir.length() / message.speed); dir.normalise(); - NaturesAura.proxy.spawnMagicParticle(Minecraft.getMinecraft().world, + NaturesAuraAPI.instance().spawnMagicParticle(Minecraft.getMinecraft().world, message.startX, message.startY, message.startZ, dir.x * message.speed, dir.y * message.speed, dir.z * message.speed, message.color, message.scale, maxAge, 0F, false, false); diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index 5fa15721..078d44a7 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -1,6 +1,7 @@ package de.ellpeck.naturesaura.packet; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import io.netty.buffer.ByteBuf; import net.minecraft.block.state.IBlockState; @@ -74,7 +75,7 @@ public class PacketParticles implements IMessage { Multiblocks.TREE_RITUAL.forEach(pos, 'G', (dustPos, matcher) -> { IBlockState state = world.getBlockState(dustPos); AxisAlignedBB box = state.getBoundingBox(world, dustPos); - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, dustPos.getX() + box.minX + (box.maxX - box.minX) * world.rand.nextFloat(), dustPos.getY() + 0.1F, dustPos.getZ() + box.minZ + (box.maxZ - box.minZ) * world.rand.nextFloat(), @@ -87,7 +88,7 @@ public class PacketParticles implements IMessage { break; case 1: // Tree ritual: Consuming item for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + 0.5F, message.posY + 0.9F, message.posZ + 0.5F, (float) world.rand.nextGaussian() * 0.04F, world.rand.nextFloat() * 0.04F, (float) world.rand.nextGaussian() * 0.04F, 0x89cc37, 1.5F, 25, 0F, false, true); @@ -95,7 +96,7 @@ public class PacketParticles implements IMessage { break; case 2: // Tree ritual: Tree disappearing for (int i = world.rand.nextInt(5) + 3; i >= 0; i--) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + world.rand.nextFloat(), message.posY + world.rand.nextFloat(), message.posZ + world.rand.nextFloat(), 0F, 0F, 0F, 0x33FF33, 1F, 50, 0F, false, true); @@ -103,7 +104,7 @@ public class PacketParticles implements IMessage { break; case 3: // Tree ritual: Spawn result item for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX, message.posY, message.posZ, world.rand.nextGaussian() * 0.1F, world.rand.nextGaussian() * 0.1F, world.rand.nextGaussian() * 0.1F, 0x89cc37, 2F, 100, 0F, true, true); @@ -111,7 +112,7 @@ public class PacketParticles implements IMessage { break; case 4: // Nature altar: Conversion for (int i = world.rand.nextInt(5) + 2; i >= 0; i--) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + 0.25F + world.rand.nextFloat() * 0.5F, message.posY + 0.9F + 0.25F * world.rand.nextFloat(), message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, @@ -123,7 +124,7 @@ public class PacketParticles implements IMessage { int color = message.data[0]; boolean disperse = message.data[1] > 0; for (int i = world.rand.nextInt(5) + 5; i >= 0; i--) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + world.rand.nextFloat(), message.posY + 1.1F, message.posZ + world.rand.nextFloat(), @@ -133,7 +134,7 @@ public class PacketParticles implements IMessage { if (disperse) for (int x = -1; x <= 1; x += 2) for (int z = -1; z <= 1; z += 2) { - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + x * 3 + 0.5F, message.posY + 2.5, message.posZ + z * 3 + 0.5F, @@ -146,7 +147,7 @@ public class PacketParticles implements IMessage { break; case 6: // Plant boost effect for (int i = world.rand.nextInt(20) + 15; i >= 0; i--) - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + world.rand.nextFloat(), message.posY + 0.25F + world.rand.nextFloat() * 0.5F, message.posZ + world.rand.nextFloat(), @@ -157,7 +158,7 @@ public class PacketParticles implements IMessage { case 7: // Flower generator consumation color = message.data[0]; for (int i = world.rand.nextInt(10) + 10; i >= 0; i--) - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + 0.25F + world.rand.nextFloat() * 0.5F, message.posY + 0.25F + world.rand.nextFloat() * 0.5F, message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, @@ -168,7 +169,7 @@ public class PacketParticles implements IMessage { break; case 8: // Flower generator aura creation for (int i = world.rand.nextInt(10) + 5; i >= 0; i--) - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + 0.25F + world.rand.nextFloat() * 0.5F, message.posY + 1.01F, message.posZ + 0.25F + world.rand.nextFloat() * 0.5F, @@ -182,7 +183,7 @@ public class PacketParticles implements IMessage { boolean side = world.rand.nextBoolean(); float x = side ? world.rand.nextFloat() : (world.rand.nextBoolean() ? 1.1F : -0.1F); float z = !side ? world.rand.nextFloat() : (world.rand.nextBoolean() ? 1.1F : -0.1F); - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX + x, message.posY + 0.1F + world.rand.nextFloat() * 0.98F, message.posZ + z, 0F, 0F, 0F, 0xad7a37, world.rand.nextFloat() + 1F, 50, 0F, true, true); @@ -190,7 +191,7 @@ public class PacketParticles implements IMessage { break; case 10: // Hopper upgrade picking up for (int i = world.rand.nextInt(20) + 10; i >= 0; i--) - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX, message.posY + 0.45F, message.posZ, world.rand.nextGaussian() * 0.015F, world.rand.nextGaussian() * 0.015F, @@ -200,7 +201,7 @@ public class PacketParticles implements IMessage { case 11: // Shockwave creator particles for (int i = 0; i < 360; i += 2) { double rad = Math.toRadians(i); - NaturesAura.proxy.spawnMagicParticle(world, + NaturesAuraAPI.instance().spawnMagicParticle(world, message.posX, message.posY + 0.01F, message.posZ, (float) Math.sin(rad) * 0.65F, 0F, diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index be22bd75..c5612fc5 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -1,7 +1,9 @@ package de.ellpeck.naturesaura.recipes; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.aura.AuraType; +import de.ellpeck.naturesaura.api.aura.AuraType; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; +import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.items.ItemAuraBottle; import de.ellpeck.naturesaura.items.ModItems;