mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
added a proper API \o/
This commit is contained in:
parent
49185192b8
commit
436f3b809b
51 changed files with 589 additions and 287 deletions
|
@ -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> T getCapability(@Nonnull Capability<T> 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;
|
||||
}
|
||||
|
|
77
src/main/java/de/ellpeck/naturesaura/InternalHooks.java
Normal file
77
src/main/java/de/ellpeck/naturesaura/InternalHooks.java
Normal file
|
@ -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<BlockPos, MutableInt> 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<BlockPos> 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<BlockPos> 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;
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
|
|
|
@ -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<IAuraContainer> auraContainer;
|
||||
|
@ -19,8 +19,8 @@ public final class Capabilities {
|
|||
@CapabilityInject(IAuraRecharge.class)
|
||||
public static Capability<IAuraRecharge> auraRecharge;
|
||||
|
||||
@CapabilityInject(AuraChunk.class)
|
||||
public static Capability<AuraChunk> auraChunk;
|
||||
@CapabilityInject(IAuraChunk.class)
|
||||
public static Capability<IAuraChunk> auraChunk;
|
||||
|
||||
public static class StorageImpl<T> implements IStorage<T> {
|
||||
|
111
src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java
Normal file
111
src/main/java/de/ellpeck/naturesaura/api/NaturesAuraAPI.java
Normal file
|
@ -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<ResourceLocation, AltarRecipe> 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<ResourceLocation, TreeRitualRecipe> 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<BlockPos, MutableInt> 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package de.ellpeck.naturesaura.aura;
|
||||
package de.ellpeck.naturesaura.api.aura;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
|
@ -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)}.
|
||||
* <p>
|
||||
* It is not intended for API users to create custom implementation of this
|
||||
* class.
|
||||
*/
|
||||
public interface IAuraChunk extends ICapabilityProvider, INBTSerializable<NBTTagCompound> {
|
||||
/**
|
||||
* 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.
|
||||
* <p>
|
||||
* 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<BlockPos, MutableInt> 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<BlockPos, MutableInt> consumer);
|
||||
|
||||
void drainAura(BlockPos pos, int amount);
|
||||
|
||||
void storeAura(BlockPos pos, int amount);
|
||||
|
||||
MutableInt getDrainSpot(BlockPos pos);
|
||||
|
||||
AuraType getType();
|
||||
|
||||
void markDirty();
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
|
@ -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);
|
|
@ -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;
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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);
|
||||
|
||||
}
|
|
@ -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<BlockPos, MutableInt> 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;
|
||||
}
|
||||
}
|
|
@ -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<ResourceLocation, AltarRecipe> 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);
|
||||
}
|
||||
}
|
|
@ -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<ResourceLocation, TreeRitualRecipe> 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);
|
||||
}
|
||||
}
|
|
@ -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<NBTTagCompound> {
|
||||
|
||||
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<NBTTagCo
|
|||
this.addEffect(new PlantBoostEffect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEffect(IDrainSpotEffect effect) {
|
||||
if (effect.appliesToType(this.type))
|
||||
this.effects.add(effect);
|
||||
}
|
||||
|
||||
public static void getSpotsInArea(World world, BlockPos pos, int radius, BiConsumer<BlockPos, MutableInt> 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<BlockPos> 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<BlockPos> 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<BlockPos, MutableInt> consumer) {
|
||||
for (Map.Entry<BlockPos, MutableInt> entry : this.drainSpots.entrySet()) {
|
||||
BlockPos drainPos = entry.getKey();
|
||||
|
@ -128,6 +62,7 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drainAura(BlockPos pos, int amount) {
|
||||
MutableInt spot = this.getDrainSpot(pos);
|
||||
spot.subtract(amount);
|
||||
|
@ -136,6 +71,7 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeAura(BlockPos pos, int amount) {
|
||||
MutableInt spot = this.getDrainSpot(pos);
|
||||
spot.add(amount);
|
||||
|
@ -144,7 +80,8 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
this.markDirty();
|
||||
}
|
||||
|
||||
private MutableInt getDrainSpot(BlockPos pos) {
|
||||
@Override
|
||||
public MutableInt getDrainSpot(BlockPos pos) {
|
||||
MutableInt spot = this.drainSpots.get(pos);
|
||||
if (spot == null) {
|
||||
spot = new MutableInt();
|
||||
|
@ -158,10 +95,12 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
this.drainSpots.putAll(spots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuraType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
this.needsSync = true;
|
||||
}
|
||||
|
@ -190,13 +129,13 @@ public class AuraChunk implements ICapabilityProvider, INBTSerializable<NBTTagCo
|
|||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
return capability == Capabilities.auraChunk;
|
||||
return capability == NACapabilities.auraChunk;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
return capability == Capabilities.auraChunk ? (T) this : null;
|
||||
return capability == NACapabilities.auraChunk ? (T) this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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<ISpotDrainable> 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);
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package de.ellpeck.naturesaura.aura.item;
|
||||
|
||||
import de.ellpeck.naturesaura.aura.container.IAuraContainer;
|
||||
|
||||
public interface IAuraRecharge {
|
||||
|
||||
void rechargeFromContainer(IAuraContainer container);
|
||||
|
||||
}
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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> T getCapability(Capability<T> 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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<String> provider) {
|
||||
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
|
||||
this.recipe = AltarRecipe.RECIPES.get(res);
|
||||
this.recipe = NaturesAuraAPI.ALTAR_RECIPES.get(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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<String> provider) {
|
||||
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
|
||||
this.recipe = TreeRitualRecipe.RECIPES.get(res);
|
||||
this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Chunk> 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<ItemStack> required = new ArrayList<>(Arrays.asList(recipe.items));
|
||||
MutableObject<TileEntityWoodStand> toPick = new MutableObject<>();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability == Capabilities.auraContainer) {
|
||||
if (capability == NACapabilities.auraContainer) {
|
||||
return (T) this.container;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue