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
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(
EntityEffectInhibitor.class,
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 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
@ -92,14 +92,12 @@ public final class NaturesAuraAPI {
*/
public static final Map<ResourceLocation, Supplier<IDrainSpotEffect>> DRAIN_SPOT_EFFECTS = new HashMap<>();
/**
* A map of all {@link IDrainSpotEffect} names (registered in {@link
* #DRAIN_SPOT_EFFECTS}) that can be inhibited using the inhibiting powder.
* The integer the effect is registered to is the color that the powder and
* its effect should have. To check if an effect should be inhibited, use
* {@link IInternalHooks#isEffectInhibited(World, BlockPos,
* ResourceLocation, int)}
* A map of all effect powder type. The integer the effect is registered to
* is the color that the powder and its effect should have. To check if a
* powder is active in any given area, use {@link IInternalHooks#isEffectPowderActive(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
* 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);
/**
* Returns true if there is an effect inhibitor entity in the given
* radius from the given position that inhibits the {@link
* IDrainSpotEffect} with the given name.
* Returns true if there is an effect powder entity active anywhere
* around the given position in the given radius. To register a powder
* with the supplied name, use {@link #EFFECT_POWDERS}
*
* @param world The world
* @param pos The center position
* @param name The registry name of the {@link IDrainSpotEffect} to
* check for
* @param name The registry name of the powder
* @param radius The radius around the center to check for
* @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)

View file

@ -37,7 +37,7 @@ public class StubHooks implements NaturesAuraAPI.IInternalHooks {
}
@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;
}

View file

@ -27,7 +27,7 @@ public class CacheRechargeEffect implements IDrainSpotEffect {
int aura = IAuraChunk.getAuraInArea(world, pos, 20);
if (aura < 15000)
return;
if (NaturesAuraAPI.instance().isEffectInhibited(world, pos, NAME, 30))
if (NaturesAuraAPI.instance().isEffectPowderActive(world, pos, NAME, 30))
return;
int dist = MathHelper.clamp(aura / 3500, 3, 15);
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(CacheRechargeEffect.NAME, CacheRechargeEffect::new);
NaturesAuraAPI.INHIBITED_EFFECTS.put(PlantBoostEffect.NAME, 0xc2f442);
NaturesAuraAPI.INHIBITED_EFFECTS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
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);
BlockPos plantPos = new BlockPos(x, world.getHeight(x, z), z);
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;
IBlockState state = world.getBlockState(plantPos);

View file

@ -1,7 +1,7 @@
package de.ellpeck.naturesaura.entities;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.ItemInhibitingPowder;
import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
@ -67,7 +67,7 @@ public class EntityEffectInhibitor extends Entity {
public boolean attackEntityFrom(DamageSource source, float amount) {
if (source instanceof EntityDamageSource && !this.world.isRemote) {
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;
} else
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.entities.EntityEffectInhibitor;
import de.ellpeck.naturesaura.items.ItemInhibitingPowder;
import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems;
import net.minecraft.client.renderer.GlStateManager;
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);
ResourceLocation effect = entity.getInhibitedEffect();
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();
}
}

View file

@ -15,10 +15,10 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingItem {
public class ItemEffectPowder extends ItemImpl implements IColorProvidingItem {
public ItemInhibitingPowder() {
super("inhibiting_powder");
public ItemEffectPowder() {
super("effect_powder");
}
@Override
@ -28,7 +28,7 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
ResourceLocation effect = getEffect(stack);
EntityEffectInhibitor entity = new EntityEffectInhibitor(worldIn);
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);
worldIn.spawnEntity(entity);
stack.shrink(1);
@ -39,7 +39,7 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
for (ResourceLocation effect : NaturesAuraAPI.INHIBITED_EFFECTS.keySet()) {
for (ResourceLocation effect : NaturesAuraAPI.EFFECT_POWDERS.keySet()) {
ItemStack stack = new ItemStack(this);
setEffect(stack, effect);
items.add(stack);
@ -71,6 +71,6 @@ public class ItemInhibitingPowder extends ItemImpl implements IColorProvidingIte
@Override
@SideOnly(Side.CLIENT)
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 SKY_INGOT = new ItemImpl("sky_ingot");
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.PlantBoostEffect;
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 net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
@ -69,14 +69,14 @@ public final class ModRecipes {
Helper.blockIng(Blocks.GLOWSTONE)).register();
new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "plant_powder"),
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),
Ingredient.fromItem(ModItems.SKY_INGOT),
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,
ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER), CacheRechargeEffect.NAME), 400,
Helper.blockIng(ModBlocks.GOLD_POWDER),
Helper.blockIng(ModBlocks.GOLD_POWDER),
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_pants.name=Botanist's Leggings
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:cache_recharge.name=Powder of no Storage
item.naturesaura.effect_powder.naturesaura:plant_boost.name=Powder of Steady Growth
item.naturesaura.effect_powder.naturesaura:cache_recharge.name=Powder of no Storage
container.naturesaura.tree_ritual.name=Ritual of the Forest
container.naturesaura.altar.name=Natural Altar Infusion

View file

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

View file

@ -11,7 +11,7 @@
{
"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$()."
"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",
"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$()."
}
]
}