rename inhibiting powder to effect powder to allow it to also create some ffects

This commit is contained in:
Ellpeck 2018-12-16 18:15:54 +01:00
parent 8007fcb62b
commit 02aa21f9db
18 changed files with 53 additions and 56 deletions

View file

@ -95,7 +95,7 @@ public class InternalHooks implements NaturesAuraAPI.IInternalHooks {
} }
@Override @Override
public boolean isEffectInhibited(World world, BlockPos pos, ResourceLocation name, int radius) { public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name, int radius) {
List<EntityEffectInhibitor> inhibitors = world.getEntitiesWithinAABB( List<EntityEffectInhibitor> inhibitors = world.getEntitiesWithinAABB(
EntityEffectInhibitor.class, EntityEffectInhibitor.class,
new AxisAlignedBB(pos).grow(radius), new AxisAlignedBB(pos).grow(radius),

View file

@ -39,7 +39,7 @@ public final class NaturesAuraAPI {
public static final String MOD_ID = "naturesaura"; public static final String MOD_ID = "naturesaura";
public static final String API_ID = MOD_ID + "api"; public static final String API_ID = MOD_ID + "api";
public static final String VERSION = "5"; public static final String VERSION = "6";
/** /**
* The list of all {@link AltarRecipe} instances which are the recipes used * The list of all {@link AltarRecipe} instances which are the recipes used
@ -92,14 +92,12 @@ public final class NaturesAuraAPI {
*/ */
public static final Map<ResourceLocation, Supplier<IDrainSpotEffect>> DRAIN_SPOT_EFFECTS = new HashMap<>(); public static final Map<ResourceLocation, Supplier<IDrainSpotEffect>> DRAIN_SPOT_EFFECTS = new HashMap<>();
/** /**
* A map of all {@link IDrainSpotEffect} names (registered in {@link * A map of all effect powder type. The integer the effect is registered to
* #DRAIN_SPOT_EFFECTS}) that can be inhibited using the inhibiting powder. * is the color that the powder and its effect should have. To check if a
* The integer the effect is registered to is the color that the powder and * powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(World,
* its effect should have. To check if an effect should be inhibited, use * BlockPos, ResourceLocation, int)}
* {@link IInternalHooks#isEffectInhibited(World, BlockPos,
* ResourceLocation, int)}
*/ */
public static final Map<ResourceLocation, Integer> INHIBITED_EFFECTS = new HashMap<>(); public static final Map<ResourceLocation, Integer> EFFECT_POWDERS = new HashMap<>();
/** /**
* A map of all {@link IMultiblock} objects which are multiblock structures * A map of all {@link IMultiblock} objects which are multiblock structures
* that can easily be looped through and checked, and also easily created * that can easily be looped through and checked, and also easily created
@ -244,18 +242,17 @@ public final class NaturesAuraAPI {
IMultiblock createMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers); IMultiblock createMultiblock(ResourceLocation name, String[][] pattern, Object... rawMatchers);
/** /**
* Returns true if there is an effect inhibitor entity in the given * Returns true if there is an effect powder entity active anywhere
* radius from the given position that inhibits the {@link * around the given position in the given radius. To register a powder
* IDrainSpotEffect} with the given name. * with the supplied name, use {@link #EFFECT_POWDERS}
* *
* @param world The world * @param world The world
* @param pos The center position * @param pos The center position
* @param name The registry name of the {@link IDrainSpotEffect} to * @param name The registry name of the powder
* check for
* @param radius The radius around the center to check for * @param radius The radius around the center to check for
* @return If the effect is currently inhibited by any inhibitors * @return If the effect is currently inhibited by any inhibitors
*/ */
boolean isEffectInhibited(World world, BlockPos pos, ResourceLocation name, int radius); boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name, int radius);
/** /**
* @see IAuraChunk#getSpotsInArea(World, BlockPos, int, BiConsumer) * @see IAuraChunk#getSpotsInArea(World, BlockPos, int, BiConsumer)

View file

@ -37,7 +37,7 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
} }
@Override @Override
public boolean isEffectInhibited(World world, BlockPos pos, ResourceLocation name, int radius) { public boolean isEffectPowderActive(World world, BlockPos pos, ResourceLocation name, int radius) {
return false; return false;
} }

View file

@ -27,7 +27,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
int aura = IAuraChunk.getAuraInArea(world, pos, 20); int aura = IAuraChunk.getAuraInArea(world, pos, 20);
if (aura < 15000) if (aura < 15000)
return; return;
if (NaturesAuraAPI.instance().isEffectInhibited(world, pos, NAME, 30)) if (NaturesAuraAPI.instance().isEffectPowderActive(world, pos, NAME, 30))
return; return;
int dist = MathHelper.clamp(aura / 3500, 3, 15); int dist = MathHelper.clamp(aura / 3500, 3, 15);
int amount = aura / 2500 - 2; int amount = aura / 2500 - 2;

View file

@ -14,7 +14,7 @@ public final class DrainSpotEffects {
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.INHIBITED_EFFECTS.put(PlantBoostEffect.NAME, 0xc2f442); NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
NaturesAuraAPI.INHIBITED_EFFECTS.put(CacheRechargeEffect.NAME, 0x1fb0d1); NaturesAuraAPI.EFFECT_POWDERS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
} }
} }

View file

@ -39,7 +39,7 @@ public class PlantBoostEffect implements IDrainSpotEffect {
int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * dist); int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * dist);
BlockPos plantPos = new BlockPos(x, world.getHeight(x, z), z); BlockPos plantPos = new BlockPos(x, world.getHeight(x, z), z);
if (plantPos.distanceSq(pos) <= dist * dist && world.isBlockLoaded(plantPos)) { if (plantPos.distanceSq(pos) <= dist * dist && world.isBlockLoaded(plantPos)) {
if (NaturesAuraAPI.instance().isEffectInhibited(world, plantPos, NAME, 15)) if (NaturesAuraAPI.instance().isEffectPowderActive(world, plantPos, NAME, 15))
continue; continue;
IBlockState state = world.getBlockState(plantPos); IBlockState state = world.getBlockState(plantPos);

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.entities; package de.ellpeck.naturesaura.entities;
import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ItemInhibitingPowder; import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -67,7 +67,7 @@ public class EntityEffectInhibitor extends Entity {
public boolean attackEntityFrom(DamageSource source, float amount) { public boolean attackEntityFrom(DamageSource source, float amount) {
if (source instanceof EntityDamageSource && !this.world.isRemote) { if (source instanceof EntityDamageSource && !this.world.isRemote) {
this.setDead(); this.setDead();
this.entityDropItem(ItemInhibitingPowder.setEffect(new ItemStack(ModItems.INHIBITING_POWDER), this.getInhibitedEffect()), 0F); this.entityDropItem(ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), this.getInhibitedEffect()), 0F);
return true; return true;
} else } else
return super.attackEntityFrom(source, amount); return super.attackEntityFrom(source, amount);

View file

@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.entities.render;
import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.items.ItemInhibitingPowder; import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.Render;
@ -42,7 +42,7 @@ public class RenderEffectInhibitor extends Render<EntityEffectInhibitor> {
GlStateManager.scale(0.5F, 0.5F, 0.5F); GlStateManager.scale(0.5F, 0.5F, 0.5F);
ResourceLocation effect = entity.getInhibitedEffect(); ResourceLocation effect = entity.getInhibitedEffect();
Helper.renderItemInWorld(this.items.computeIfAbsent(effect, Helper.renderItemInWorld(this.items.computeIfAbsent(effect,
res -> ItemInhibitingPowder.setEffect(new ItemStack(ModItems.INHIBITING_POWDER), effect))); res -> ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), effect)));
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }
} }

View file

@ -15,10 +15,10 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingItem { public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
public ItemInhibitingPowder() { public ItemEffectPowder() {
super("inhibiting_powder"); super("effect_powder");
} }
@Override @Override
@ -28,7 +28,7 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
ResourceLocation effect = getEffect(stack); ResourceLocation effect = getEffect(stack);
EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn); EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn);
entity.setInhibitedEffect(effect); entity.setInhibitedEffect(effect);
entity.setColor(NaturesAuraAPI.INHIBITED_EFFECTS.get(effect)); entity.setColor(NaturesAuraAPI.EFFECT_POWDERS.get(effect));
entity.setPosition(pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ); entity.setPosition(pos.getX() + hitX, pos.getY() + hitY + 1, pos.getZ() + hitZ);
worldIn.spawnEntity(entity); worldIn.spawnEntity(entity);
stack.shrink(1); stack.shrink(1);
@ -39,7 +39,7 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
@Override @Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) { public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) { if (this.isInCreativeTab(tab)) {
for (ResourceLocation effect : NaturesAuraAPI.INHIBITED_EFFECTS.keySet()) { for (ResourceLocation effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) {
ItemStack stack = new ItemStack(this); ItemStack stack = new ItemStack(this);
setEffect(stack, effect); setEffect(stack, effect);
items.add(stack); items.add(stack);
@ -71,6 +71,6 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public IItemColor getItemColor() { public IItemColor getItemColor() {
return (stack, tintIndex) -> NaturesAuraAPI.INHIBITED_EFFECTS.getOrDefault(getEffect(stack), 0xFFFFFF); return (stack, tintIndex) -> NaturesAuraAPI.EFFECT_POWDERS.getOrDefault(getEffect(stack), 0xFFFFFF);
} }
} }

View file

@ -40,5 +40,5 @@ public final class ModItems {
public static final Item FARMING_STENCIL = new ItemImpl("farming_stencil"); public static final Item FARMING_STENCIL = new ItemImpl("farming_stencil");
public static final Item SKY_INGOT = new ItemImpl("sky_ingot"); public static final Item SKY_INGOT = new ItemImpl("sky_ingot");
public static final Item CALLING_SPIRIT = new ItemGlowing("calling_spirit"); public static final Item CALLING_SPIRIT = new ItemGlowing("calling_spirit");
public static final Item INHIBITING_POWDER = new ItemInhibitingPowder(); public static final Item EFFECT_POWDER = new ItemEffectPowder();
} }

View file

@ -12,7 +12,7 @@ import de.ellpeck.naturesaura.blocks.ModBlocks;
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;
import de.ellpeck.naturesaura.items.ItemInhibitingPowder; import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockFlower;
@ -69,14 +69,14 @@ public final class ModRecipes {
Helper.blockIng(Blocks.GLOWSTONE)).register(); Helper.blockIng(Blocks.GLOWSTONE)).register();
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "plant_powder"), new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "plant_powder"),
Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)), Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)),
ItemInhibitingPowder.setEffect(new ItemStack(ModItems.INHIBITING_POWDER), PlantBoostEffect.NAME), 400, ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), PlantBoostEffect.NAME), 400,
Helper.blockIng(ModBlocks.GOLD_POWDER), Helper.blockIng(ModBlocks.GOLD_POWDER),
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"), new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "cache_powder"),
Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)), Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)),
ItemInhibitingPowder.setEffect(new ItemStack(ModItems.INHIBITING_POWDER), CacheRechargeEffect.NAME), 400, ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), CacheRechargeEffect.NAME), 400,
Helper.blockIng(ModBlocks.GOLD_POWDER), Helper.blockIng(ModBlocks.GOLD_POWDER),
Helper.blockIng(ModBlocks.GOLD_POWDER), Helper.blockIng(ModBlocks.GOLD_POWDER),
Ingredient.fromItem(ModItems.SKY_INGOT), Ingredient.fromItem(ModItems.SKY_INGOT),

View file

@ -63,8 +63,8 @@ item.naturesaura.infused_iron_helmet.name=Botanist's Headwear
item.naturesaura.infused_iron_chest.name=Botanist's Chestplate 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.effect_powder.naturesaura:plant_boost.name=Powder of Steady Growth
item.naturesaura.inhibiting_powder.naturesaura:cache_recharge.name=Powder of no Storage item.naturesaura.effect_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

View file

@ -1,6 +1,6 @@
{ {
"parent": "item/generated", "parent": "item/generated",
"textures": { "textures": {
"layer0": "naturesaura:items/inhibiting_powder" "layer0": "naturesaura:items/effect_powder"
} }
} }

View file

@ -11,7 +11,7 @@
{ {
"type": "naturesaura:tree_ritual", "type": "naturesaura:tree_ritual",
"recipe": "naturesaura:cache_powder", "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$()." "text": "This effect can be inhibited in a radius of about 30 blocks around the saturated area using $(l:effects/effect_powder)Powder of no Storage$()."
} }
] ]
} }

View file

@ -0,0 +1,17 @@
{
"name": "Effect Powder",
"icon": "naturesaura:effect_powder{effect:'naturesaura:plant_boost'}",
"category": "effects",
"advancement": "naturesaura:aura_cache",
"priority": true,
"pages": [
{
"type": "text",
"text": "$(item)Effect Powder$() is a magical substance that has two purposes: For one, it can $(thing)inhibit$() existing passive effects from happening in a certain area around it. Additionally, some effects can only happen with it around in the first place, meaning that it also has $(thing)creational$() abilities.$(p)The powder, of course, only works on positive effects."
},
{
"type": "text",
"text": "To use it, simply placing it down on the ground will cause it to either stop its effect or create it, depending on the type of powder used. Hitting it while it is on the ground will cause it to go back into its item form.$(p)Each effect that has an $(item)Effect Powder$() attached to it will show the recipe and radius in its chapter."
}
]
}

View file

@ -1,17 +0,0 @@
{
"name": "Inhibition Powder",
"icon": "naturesaura:inhibiting_powder{effect:'naturesaura:plant_boost'}",
"category": "effects",
"advancement": "naturesaura:aura_cache",
"priority": true,
"pages": [
{
"type": "text",
"text": "Sometimes, the effects of an excess of $(aura) can become troublesome in certain situations. For this, $(item)Inhibition Powder$() can be of huge assistance: Some positive effects can be $(thing)inhibited$() in a certain radius by making a powder of their kind."
},
{
"type": "text",
"text": "Then, simply placing it down on the ground will cause it to stop the effect it is bound to from happening. Hitting it while it is on the ground will cause it to go back into its item form.$(p)Each effect that has an $(item)Inhibition Powder$() attached to it will show the recipe and radius in its chapter."
}
]
}

View file

@ -15,7 +15,7 @@
{ {
"type": "naturesaura:tree_ritual", "type": "naturesaura:tree_ritual",
"recipe": "naturesaura:plant_powder", "recipe": "naturesaura:plant_powder",
"text": "This effect can be inhibited in a radius of about 15 blocks using $(l:effects/inhibiting_powder)Powder of Steady Growth$()." "text": "This effect can be inhibited in a radius of about 15 blocks using $(l:effects/effect_powder)Powder of Steady Growth$()."
} }
] ]
} }