mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 13:18:34 +01:00
added the animal effect
This commit is contained in:
parent
8e6d29272b
commit
1a2eee7ed9
7 changed files with 153 additions and 1 deletions
|
@ -46,6 +46,8 @@ public final class ModConfig {
|
||||||
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")
|
||||||
public boolean breathlessEffect = true;
|
public boolean breathlessEffect = true;
|
||||||
|
@Comment("If the Aura Imbalance effect of farm animals being affected in positive ways if Aura levels are too high should occur")
|
||||||
|
public boolean animalEffect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Client {
|
public static class Client {
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
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.item.EntityItem;
|
||||||
|
import net.minecraft.entity.passive.EntityAnimal;
|
||||||
|
import net.minecraft.entity.passive.EntityChicken;
|
||||||
|
import net.minecraft.item.ItemEgg;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
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.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class AnimalEffect implements IDrainSpotEffect {
|
||||||
|
|
||||||
|
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "animal");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
|
||||||
|
if (spot <= 0)
|
||||||
|
return;
|
||||||
|
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
|
||||||
|
if (aura < 15000)
|
||||||
|
return;
|
||||||
|
int chance = Math.min(50, Math.abs(aura) / 5000);
|
||||||
|
if (chance <= 0)
|
||||||
|
return;
|
||||||
|
int dist = MathHelper.clamp(Math.abs(aura) / 1500, 5, 35);
|
||||||
|
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(dist);
|
||||||
|
|
||||||
|
List<EntityAnimal> animals = world.getEntitiesWithinAABB(EntityAnimal.class, bb);
|
||||||
|
if (animals.size() >= 40)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (world.getTotalWorldTime() % 200 == 0) {
|
||||||
|
List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, bb);
|
||||||
|
for (EntityItem item : items) {
|
||||||
|
if (item.isDead)
|
||||||
|
continue;
|
||||||
|
if (NaturesAuraAPI.instance().isEffectPowderActive(world, item.getPosition(), NAME, 35))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ItemStack stack = item.getItem();
|
||||||
|
if (!(stack.getItem() instanceof ItemEgg) || item.getAge() < item.lifespan / 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
stack.shrink(1);
|
||||||
|
if (stack.isEmpty())
|
||||||
|
item.setDead();
|
||||||
|
|
||||||
|
EntityChicken chicken = new EntityChicken(world);
|
||||||
|
chicken.setGrowingAge(-24000);
|
||||||
|
chicken.setPosition(item.posX, item.posY, item.posZ);
|
||||||
|
world.spawnEntity(chicken);
|
||||||
|
|
||||||
|
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, item.getPosition(), 35, pos);
|
||||||
|
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 150);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world.rand.nextInt(200) <= chance) {
|
||||||
|
if (animals.size() < 2)
|
||||||
|
return;
|
||||||
|
EntityAnimal first = animals.get(world.rand.nextInt(animals.size()));
|
||||||
|
if (first.isChild() || first.isInLove())
|
||||||
|
return;
|
||||||
|
if (NaturesAuraAPI.instance().isEffectPowderActive(world, first.getPosition(), NAME, 35))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Optional<EntityAnimal> secondOptional = animals.stream()
|
||||||
|
.filter(e -> e != first && !e.isInLove() && !e.isChild())
|
||||||
|
.min(Comparator.comparingDouble(e -> e.getDistanceSq(first)));
|
||||||
|
if (!secondOptional.isPresent())
|
||||||
|
return;
|
||||||
|
EntityAnimal second = secondOptional.get();
|
||||||
|
|
||||||
|
this.setInLove(first);
|
||||||
|
this.setInLove(second);
|
||||||
|
|
||||||
|
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, first.getPosition(), 35, pos);
|
||||||
|
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInLove(EntityAnimal animal) {
|
||||||
|
animal.setInLove(null);
|
||||||
|
for (int j = 0; j < 7; j++)
|
||||||
|
animal.world.spawnParticle(EnumParticleTypes.HEART,
|
||||||
|
(animal.posX + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
||||||
|
animal.posY + 0.5D + (double) (animal.world.rand.nextFloat() * animal.height),
|
||||||
|
(animal.posZ + (double) (animal.world.rand.nextFloat() * animal.width * 2.0F)) - animal.width,
|
||||||
|
animal.world.rand.nextGaussian() * 0.02D,
|
||||||
|
animal.world.rand.nextGaussian() * 0.02D,
|
||||||
|
animal.world.rand.nextGaussian() * 0.02D);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
|
||||||
|
return ModConfig.enabledFeatures.animalEffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation getName() {
|
||||||
|
return NAME;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,8 +13,10 @@ public final class DrainSpotEffects {
|
||||||
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.DRAIN_SPOT_EFFECTS.put(CacheRechargeEffect.NAME, CacheRechargeEffect::new);
|
||||||
|
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(AnimalEffect.NAME, AnimalEffect::new);
|
||||||
|
|
||||||
NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
|
NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
|
||||||
NaturesAuraAPI.EFFECT_POWDERS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
|
NaturesAuraAPI.EFFECT_POWDERS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
|
||||||
|
NaturesAuraAPI.EFFECT_POWDERS.put(AnimalEffect.NAME, 0xba1010);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
|
||||||
growable.grow(world, world.rand, plantPos, state);
|
growable.grow(world, world.rand, plantPos, state);
|
||||||
|
|
||||||
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, plantPos, 25, pos);
|
||||||
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 100);
|
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 200);
|
||||||
|
|
||||||
PacketHandler.sendToAllAround(world, plantPos, 32,
|
PacketHandler.sendToAllAround(world, plantPos, 32,
|
||||||
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
|
new PacketParticles(plantPos.getX(), plantPos.getY(), plantPos.getZ(), 6));
|
||||||
|
|
|
@ -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.AnimalEffect;
|
||||||
import de.ellpeck.naturesaura.chunk.effect.CacheRechargeEffect;
|
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;
|
||||||
|
@ -81,6 +82,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(ModItems.AURA_CACHE)).register();
|
Ingredient.fromItem(ModItems.AURA_CACHE)).register();
|
||||||
|
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "animal_powder"),
|
||||||
|
Ingredient.fromStacks(new ItemStack(Blocks.SAPLING, 1, 3)),
|
||||||
|
ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), AnimalEffect.NAME), 400,
|
||||||
|
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
||||||
|
Helper.blockIng(ModBlocks.GOLD_POWDER),
|
||||||
|
Ingredient.fromItem(ModItems.SKY_INGOT),
|
||||||
|
Ingredient.fromItem(Items.EGG)).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),
|
||||||
|
|
|
@ -65,6 +65,7 @@ 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.effect_powder.naturesaura:plant_boost.name=Powder of Steady Growth
|
item.naturesaura.effect_powder.naturesaura:plant_boost.name=Powder of Steady Growth
|
||||||
item.naturesaura.effect_powder.naturesaura:cache_recharge.name=Powder of no Storage
|
item.naturesaura.effect_powder.naturesaura:cache_recharge.name=Powder of no Storage
|
||||||
|
item.naturesaura.effect_powder.naturesaura:animal.name=Powder of Chastity
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"name": "Increase of Fertility",
|
||||||
|
"icon": "minecraft:egg",
|
||||||
|
"category": "effects",
|
||||||
|
"advancement": "naturesaura:flower_generator",
|
||||||
|
"pages": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "When the amount of $(aura) in an area increases beyond about two thirds of the $(l:items/eye)Environmental Eye$()'s gauge, it starts to affect the $(item)animals$() in the area: Cows, sheep, pigs and the like will start $(thing)mating$() without any encouragement occasionally, draining some of the $(aura) in the process as if falling in love because of its power."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "Additionally, $(item)Eggs$() that have been laying around on the ground as an item for a while will have a chance to $(thing)hatch$() into a chicken without needing to be thrown.$(p)Note that both of these effects will cease to occur once there are enough animals present in the area, preventing overpopulation."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "naturesaura:tree_ritual",
|
||||||
|
"recipe": "naturesaura:animal_powder",
|
||||||
|
"text": "This effect can be inhibited in a radius of about 15 blocks using $(l:effects/effect_powder)Powder of Chastity$()."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue