mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 13:18:34 +01:00
added a passive effect where aura gets added to aura caches around
This commit is contained in:
parent
8f33476403
commit
8007fcb62b
11 changed files with 150 additions and 4 deletions
|
@ -3,6 +3,7 @@ package de.ellpeck.naturesaura;
|
||||||
import baubles.api.BaublesApi;
|
import baubles.api.BaublesApi;
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
|
||||||
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
import de.ellpeck.naturesaura.api.multiblock.IMultiblock;
|
||||||
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
import de.ellpeck.naturesaura.blocks.multi.Multiblock;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
|
@ -26,7 +27,16 @@ import java.util.function.BiConsumer;
|
||||||
public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
@Override
|
@Override
|
||||||
public boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate) {
|
public boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate) {
|
||||||
if (player.capabilities.isCreativeMode)
|
return this.auraPlayerInteraction(player, amount, true, simulate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertAuraIntoPlayer(EntityPlayer player, int amount, boolean simulate) {
|
||||||
|
return this.auraPlayerInteraction(player, amount, false, simulate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean auraPlayerInteraction(EntityPlayer player, int amount, boolean extract, boolean simulate) {
|
||||||
|
if (extract && player.capabilities.isCreativeMode)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Compat.baubles) {
|
if (Compat.baubles) {
|
||||||
|
@ -34,7 +44,11 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||||
ItemStack stack = baubles.getStackInSlot(i);
|
ItemStack stack = baubles.getStackInSlot(i);
|
||||||
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||||
amount -= stack.getCapability(NaturesAuraAPI.capAuraContainer, null).drainAura(amount, simulate);
|
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||||
|
if (extract)
|
||||||
|
amount -= container.drainAura(amount, simulate);
|
||||||
|
else
|
||||||
|
amount -= container.storeAura(amount, simulate);
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +58,11 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||||
ItemStack stack = player.inventory.getStackInSlot(i);
|
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||||
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
if (!stack.isEmpty() && stack.hasCapability(NaturesAuraAPI.capAuraContainer, null)) {
|
||||||
amount -= stack.getCapability(NaturesAuraAPI.capAuraContainer, null).drainAura(amount, simulate);
|
IAuraContainer container = stack.getCapability(NaturesAuraAPI.capAuraContainer, null);
|
||||||
|
if (extract)
|
||||||
|
amount -= container.drainAura(amount, simulate);
|
||||||
|
else
|
||||||
|
amount -= container.storeAura(amount, simulate);
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ public final class ModConfig {
|
||||||
public boolean grassDieEffect = true;
|
public boolean grassDieEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
@Comment("If the Aura Imbalance effect of plant growth being boosted if the Aura levels are high enough should occur")
|
||||||
public boolean plantBoostEffect = true;
|
public boolean plantBoostEffect = true;
|
||||||
|
@Comment("If the Aura Imbalance effect of aura containers in players' inventories being filled if the Aura levels are high enough should occur")
|
||||||
|
public boolean cacheRechargeEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
@Comment("If the Aura Imbalance effect of explosions happening randomly if Aura levels are too low should occur")
|
||||||
public boolean explosionEffect = true;
|
public boolean explosionEffect = true;
|
||||||
@Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
@Comment("If the Aura Imbalance effect of breathlessness if Aura levels are too low should occur")
|
||||||
|
|
|
@ -173,6 +173,18 @@ public final class NaturesAuraAPI {
|
||||||
*/
|
*/
|
||||||
boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate);
|
boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to insert aura into an {@link IAuraContainer} in the
|
||||||
|
* supplied player's inventory or baubles slots. The method returns true
|
||||||
|
* if the aura could be inserted.
|
||||||
|
*
|
||||||
|
* @param player The player
|
||||||
|
* @param amount The amount to insert
|
||||||
|
* @param simulate If the insertion should be simulated
|
||||||
|
* @return If the insertion was successful
|
||||||
|
*/
|
||||||
|
boolean insertAuraIntoPlayer(EntityPlayer player, int amount, boolean simulate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method can be used to spawn the magic particle effect used by
|
* 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
|
* Nature's Aura. It will not have an effect on the client side, so if
|
||||||
|
|
|
@ -16,6 +16,11 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean insertAuraIntoPlayer(EntityPlayer player, int amount, boolean simulate) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package de.ellpeck.naturesaura.chunk.effect;
|
||||||
|
|
||||||
|
import de.ellpeck.naturesaura.ModConfig;
|
||||||
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
|
||||||
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CacheRechargeEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "cache_recharge");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||||
|
if (spot < 1000)
|
||||||
|
return;
|
||||||
|
int aura = IAuraChunk.getAuraInArea(world, pos, 20);
|
||||||
|
if (aura < 15000)
|
||||||
|
return;
|
||||||
|
if (NaturesAuraAPI.instance().isEffectInhibited(world, pos, NAME, 30))
|
||||||
|
return;
|
||||||
|
int dist = MathHelper.clamp(aura / 3500, 3, 15);
|
||||||
|
int amount = aura / 2500 - 2;
|
||||||
|
|
||||||
|
List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(pos).grow(dist));
|
||||||
|
for (EntityPlayer player : players) {
|
||||||
|
if (NaturesAuraAPI.instance().insertAuraIntoPlayer(player, amount, true)) {
|
||||||
|
NaturesAuraAPI.instance().insertAuraIntoPlayer(player, amount, false);
|
||||||
|
auraChunk.drainAura(pos, amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||||
|
return ModConfig.enabledFeatures.cacheRechargeEffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation getName() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,7 +12,9 @@ public final class DrainSpotEffects {
|
||||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(ExplosionEffect.NAME, ExplosionEffect::new);
|
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(ExplosionEffect.NAME, ExplosionEffect::new);
|
||||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BreathlessEffect.NAME, BreathlessEffect::new);
|
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(BreathlessEffect.NAME, BreathlessEffect::new);
|
||||||
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(SpreadEffect.NAME, SpreadEffect::new);
|
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(SpreadEffect.NAME, SpreadEffect::new);
|
||||||
|
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(CacheRechargeEffect.NAME, CacheRechargeEffect::new);
|
||||||
|
|
||||||
NaturesAuraAPI.INHIBITED_EFFECTS.put(PlantBoostEffect.NAME, 0xc2f442);
|
NaturesAuraAPI.INHIBITED_EFFECTS.put(PlantBoostEffect.NAME, 0xc2f442);
|
||||||
|
NaturesAuraAPI.INHIBITED_EFFECTS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
|
||||||
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
|
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
|
||||||
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
|
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
|
||||||
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
import de.ellpeck.naturesaura.blocks.ModBlocks;
|
||||||
|
import de.ellpeck.naturesaura.chunk.effect.CacheRechargeEffect;
|
||||||
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
|
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
|
||||||
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
import de.ellpeck.naturesaura.items.ItemAuraBottle;
|
||||||
import de.ellpeck.naturesaura.items.ItemInhibitingPowder;
|
import de.ellpeck.naturesaura.items.ItemInhibitingPowder;
|
||||||
|
@ -73,6 +74,13 @@ public final class ModRecipes {
|
||||||
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
||||||
Ingredient.fromItem(ModItems.SKY_INGOT),
|
Ingredient.fromItem(ModItems.SKY_INGOT),
|
||||||
Ingredient.fromItem(Items.WHEAT)).register();
|
Ingredient.fromItem(Items.WHEAT)).register();
|
||||||
|
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "cache_powder"),
|
||||||
|
Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)),
|
||||||
|
ItemInhibitingPowder.setEffect(new ItemStack(ModItems.INHIBITING_POWDER), CacheRechargeEffect.NAME), 400,
|
||||||
|
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
||||||
|
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
||||||
|
Ingredient.fromItem(ModItems.SKY_INGOT),
|
||||||
|
Ingredient.fromItem(ModItems.AURA_CACHE)).register();
|
||||||
|
|
||||||
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"),
|
new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"),
|
||||||
Ingredient.fromItem(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON),
|
Ingredient.fromItem(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON),
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "naturesaura:aura_cache"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"translate": "advancement.naturesaura.aura_cache"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"translate": "advancement.naturesaura.aura_cache.desc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"parent": "naturesaura:infused_materials",
|
||||||
|
"criteria": {
|
||||||
|
"cache": {
|
||||||
|
"trigger": "minecraft:inventory_changed",
|
||||||
|
"conditions": {
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"item": "naturesaura:aura_cache"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -64,6 +64,7 @@ item.naturesaura.infused_iron_chest.name=Botanist's Chestplate
|
||||||
item.naturesaura.infused_iron_pants.name=Botanist's Leggings
|
item.naturesaura.infused_iron_pants.name=Botanist's Leggings
|
||||||
item.naturesaura.infused_iron_shoes.name=Botanist's Shoes
|
item.naturesaura.infused_iron_shoes.name=Botanist's Shoes
|
||||||
item.naturesaura.inhibiting_powder.naturesaura:plant_boost.name=Powder of Steady Growth
|
item.naturesaura.inhibiting_powder.naturesaura:plant_boost.name=Powder of Steady Growth
|
||||||
|
item.naturesaura.inhibiting_powder.naturesaura:cache_recharge.name=Powder of no Storage
|
||||||
|
|
||||||
container.naturesaura.tree_ritual.name=Ritual of the Forest
|
container.naturesaura.tree_ritual.name=Ritual of the Forest
|
||||||
container.naturesaura.altar.name=Natural Altar Infusion
|
container.naturesaura.altar.name=Natural Altar Infusion
|
||||||
|
@ -112,6 +113,8 @@ advancement.naturesaura.offering=Yo God, ya want this?
|
||||||
advancement.naturesaura.offering.desc=Create an Offering Table for the Offering to the Gods
|
advancement.naturesaura.offering.desc=Create an Offering Table for the Offering to the Gods
|
||||||
advancement.naturesaura.sky_ingot=Sturdy and light
|
advancement.naturesaura.sky_ingot=Sturdy and light
|
||||||
advancement.naturesaura.sky_ingot.desc=Create an Ingot of the Skies using the Offering to the Gods
|
advancement.naturesaura.sky_ingot.desc=Create an Ingot of the Skies using the Offering to the Gods
|
||||||
|
advancement.naturesaura.aura_cache=Ca-ching
|
||||||
|
advancement.naturesaura.aura_cache.desc=Create an Aura Cache to store Aura in your inventory
|
||||||
|
|
||||||
command.naturesaura.aura.usage=/naaura <action> <amount> <range>
|
command.naturesaura.aura.usage=/naaura <action> <amount> <range>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "Natural Storage",
|
||||||
|
"icon": "naturesaura:aura_cache",
|
||||||
|
"category": "effects",
|
||||||
|
"advancement": "naturesaura:aura_cache",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "If enough $(aura) is present in the environment, so much so that the bar of the $(l:items/eye)Environmental Eye$() is filled up by about half above the regular amount, $(item)Natural Storage$() will start to occur: For any players around a saturated area that carry an $(l:items/aura_cache)Aura Cache$() with them, it will slowly start to $(thing)fill up$(), draining from the oversaturated $(aura)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "naturesaura:tree_ritual",
|
||||||
|
"recipe": "naturesaura:cache_powder",
|
||||||
|
"text": "This effect can be inhibited in a radius of about 30 blocks around the saturated area using $(l:effects/inhibiting_powder)Powder of no Storage$()."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "Inhibition Powder",
|
"name": "Inhibition Powder",
|
||||||
"icon": "naturesaura:inhibiting_powder{effect:'naturesaura:plant_boost'}",
|
"icon": "naturesaura:inhibiting_powder{effect:'naturesaura:plant_boost'}",
|
||||||
"category": "effects",
|
"category": "effects",
|
||||||
"advancement": "naturesaura:flower_generator",
|
"advancement": "naturesaura:aura_cache",
|
||||||
"priority": true,
|
"priority": true,
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue