added botanist's armor

This commit is contained in:
Ellpeck 2018-12-01 18:56:05 +01:00
parent 0ea4d7391b
commit 330e4f89fa
29 changed files with 274 additions and 28 deletions

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
@ -156,14 +155,18 @@ public final class Helper {
return false;
}
public static ICapabilityProvider makeRechargeProvider(ItemStack stack) {
public static ICapabilityProvider makeRechargeProvider(ItemStack stack, boolean needsSelected) {
return new ICapabilityProvider() {
private final IAuraRecharge recharge = container -> {
int toDrain = 3;
if (stack.getItemDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
stack.setItemDamage(stack.getItemDamage() - 1);
container.drainAura(toDrain, false);
private final IAuraRecharge recharge = (container, containerSlot, itemSlot, isSelected) -> {
if (isSelected || !needsSelected) {
int toDrain = 3;
if (stack.getItemDamage() > 0 && container.drainAura(toDrain, true) >= toDrain) {
stack.setItemDamage(stack.getItemDamage() - 1);
container.drainAura(toDrain, false);
return true;
}
}
return false;
};
@Override

View file

@ -30,10 +30,13 @@ import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.Locale;
@Mod(modid = NaturesAura.MOD_ID, name = NaturesAura.MOD_NAME, version = NaturesAura.VERSION, dependencies = NaturesAura.DEPS)
public final class NaturesAura {
public static final String MOD_ID = NaturesAuraAPI.MOD_ID;
public static final String MOD_ID_UPPER = MOD_ID.toUpperCase(Locale.ROOT);
public static final String PROXY_LOCATION = "de.ellpeck." + MOD_ID + ".proxy.";
public static final String MOD_NAME = "Nature's Aura";
public static final String VERSION = "@VERSION@";

View file

@ -4,6 +4,6 @@ import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
public interface IAuraRecharge {
void rechargeFromContainer(IAuraContainer container);
boolean rechargeFromContainer(IAuraContainer container, int containerSlot, int itemSlot, boolean isSelected);
}

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.container.ItemAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
import de.ellpeck.naturesaura.api.render.ITrinketItem;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.creativetab.CreativeTabs;
@ -35,10 +36,16 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem {
if (!worldIn.isRemote && entityIn instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entityIn;
if (player.isSneaking()) {
ItemStack stack = player.getHeldItemMainhand();
if (stack.hasCapability(NaturesAuraAPI.capAuraRecharge, null)) {
IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer, null);
stack.getCapability(NaturesAuraAPI.capAuraRecharge, null).rechargeFromContainer(container);
IAuraContainer container = stackIn.getCapability(NaturesAuraAPI.capAuraContainer, null);
if (container.getStoredAura() <= 0)
return;
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stack = player.inventory.getStackInSlot(i);
if (stack.hasCapability(NaturesAuraAPI.capAuraRecharge, null)) {
IAuraRecharge recharge = stack.getCapability(NaturesAuraAPI.capAuraRecharge, null);
if (recharge.rechargeFromContainer(container, itemSlot, i, player.inventory.currentItem == i))
break;
}
}
}
}

View file

@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.render.ITrinketItem;
import de.ellpeck.naturesaura.items.tools.ItemArmorNA;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block;
@ -16,9 +17,11 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
@ -78,6 +81,7 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
source = DamageSource.causePlayerDamage((EntityPlayer) living);
else
source = DamageSource.MAGIC;
boolean infusedSet = ItemArmorNA.isFullSetEquipped(living, 0);
int range = 5;
List<EntityLivingBase> mobs = worldIn.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(
@ -91,6 +95,9 @@ public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
if (living instanceof EntityPlayer && !NaturesAuraAPI.instance().extractAuraFromPlayer((EntityPlayer) living, 5, false))
break;
mob.attackEntityFrom(source, 4F);
if (infusedSet)
mob.addPotionEffect(new PotionEffect(MobEffects.WITHER, 120));
}
BlockPos pos = living.getPosition();

View file

@ -2,20 +2,29 @@ package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.items.tools.*;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.util.EnumHelper;
import java.util.Locale;
public final class ModItems {
public static final Item.ToolMaterial TOOL_MATERIAL_INFUSED_IRON =
EnumHelper.addToolMaterial(NaturesAura.MOD_ID.toUpperCase(Locale.ROOT) + "_INFUSED_IRON", 3, 300, 6.25F, 2.25F, 16);
public static final Item INFUSED_PICKAXE = new ItemPickaxeNA("infused_iron_pickaxe", TOOL_MATERIAL_INFUSED_IRON);
public static final Item INFUSED_AXE = new ItemAxeNA("infused_iron_axe", TOOL_MATERIAL_INFUSED_IRON, 8.25F, -3.2F);
public static final Item INFUSED_SHOVEL = new ItemShovelNA("infused_iron_shovel", TOOL_MATERIAL_INFUSED_IRON);
public static final Item INFUSED_HOE = new ItemHoeNA("infused_iron_hoe", TOOL_MATERIAL_INFUSED_IRON);
public static final Item INFUSED_SWORD = new ItemSwordNA("infused_iron_sword", TOOL_MATERIAL_INFUSED_IRON);
public static final ToolMaterial TOOL_INFUSED = EnumHelper.addToolMaterial(
NaturesAura.MOD_ID_UPPER + "_INFUSED_IRON", 3, 300, 6.25F, 2.25F, 16);
public static final Item INFUSED_PICKAXE = new ItemPickaxeNA("infused_iron_pickaxe", TOOL_INFUSED);
public static final Item INFUSED_AXE = new ItemAxeNA("infused_iron_axe", TOOL_INFUSED, 8.25F, -3.2F);
public static final Item INFUSED_SHOVEL = new ItemShovelNA("infused_iron_shovel", TOOL_INFUSED);
public static final Item INFUSED_HOE = new ItemHoeNA("infused_iron_hoe", TOOL_INFUSED);
public static final Item INFUSED_SWORD = new ItemSwordNA("infused_iron_sword", TOOL_INFUSED);
public static final ArmorMaterial ARMOR_INFUSED = EnumHelper.addArmorMaterial(
NaturesAura.MOD_ID_UPPER + "INFUSED_IRON", NaturesAura.MOD_ID + ":infused_iron",
19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ITEM_ARMOR_EQUIP_GENERIC, 0F);
public static final Item INFUSED_HELMET = new ItemArmorNA("infused_iron_helmet", ARMOR_INFUSED, EntityEquipmentSlot.HEAD);
public static final Item INFUSED_CHEST = new ItemArmorNA("infused_iron_chest", ARMOR_INFUSED, EntityEquipmentSlot.CHEST);
public static final Item INFUSED_PANTS = new ItemArmorNA("infused_iron_pants", ARMOR_INFUSED, EntityEquipmentSlot.LEGS);
public static final Item INFUSED_SHOES = new ItemArmorNA("infused_iron_shoes", ARMOR_INFUSED, EntityEquipmentSlot.FEET);
public static final Item EYE = new ItemEye();
public static final Item GOLD_FIBER = new ItemGoldFiber();

View file

@ -0,0 +1,96 @@
package de.ellpeck.naturesaura.items.tools;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ICreativeItem;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ItemArmorNA extends ItemArmor implements IModItem, ICreativeItem, IModelProvider {
private static List<Item[]> sets;
private final String baseName;
public ItemArmorNA(String baseName, ArmorMaterial materialIn, EntityEquipmentSlot equipmentSlotIn) {
super(materialIn, 0, equipmentSlotIn);
this.baseName = baseName;
ModRegistry.add(this);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onAttack(LivingAttackEvent event) {
EntityLivingBase entity = event.getEntityLiving();
if (!entity.world.isRemote) {
if (!isFullSetEquipped(entity, 0))
return;
Entity source = event.getSource().getTrueSource();
if (source instanceof EntityLivingBase)
((EntityLivingBase) source).addPotionEffect(new PotionEffect(MobEffects.WITHER, 40));
}
}
@Override
public String getBaseName() {
return this.baseName;
}
@Override
public void onPreInit(FMLPreInitializationEvent event) {
}
@Override
public void onInit(FMLInitializationEvent event) {
}
@Override
public void onPostInit(FMLPostInitializationEvent event) {
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
return Helper.makeRechargeProvider(stack, false);
}
public static boolean isFullSetEquipped(EntityLivingBase entity, int setIndex) {
if (sets == null) {
sets = new ArrayList<>();
sets.add(new Item[]{ModItems.INFUSED_SHOES, ModItems.INFUSED_PANTS, ModItems.INFUSED_CHEST, ModItems.INFUSED_HELMET});
}
Item[] set = sets.get(setIndex);
for (int i = 0; i < 4; i++) {
EntityEquipmentSlot slot = EntityEquipmentSlot.values()[i + 2];
ItemStack stack = entity.getItemStackFromSlot(slot);
if (stack.isEmpty() || stack.getItem() != set[i])
return false;
}
return true;
}
}

View file

@ -59,7 +59,7 @@ public class ItemAxeNA extends ItemAxe implements IModItem, ICreativeItem, IMode
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
if (this == ModItems.INFUSED_AXE)
return Helper.makeRechargeProvider(stack);
return Helper.makeRechargeProvider(stack, true);
else return null;
}
}

View file

@ -1,6 +1,5 @@
package de.ellpeck.naturesaura.items.tools;
import crafttweaker.api.creativetabs.ICreativeTab;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ICreativeItem;
@ -87,7 +86,7 @@ public class ItemHoeNA extends ItemHoe implements IModItem, ICreativeItem, IMode
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
if (this == ModItems.INFUSED_HOE)
return Helper.makeRechargeProvider(stack);
return Helper.makeRechargeProvider(stack, true);
else return null;
}
}

View file

@ -76,7 +76,7 @@ public class ItemPickaxeNA extends ItemPickaxe implements IModItem, ICreativeIte
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
if (this == ModItems.INFUSED_PICKAXE)
return Helper.makeRechargeProvider(stack);
return Helper.makeRechargeProvider(stack, true);
else return null;
}
}

View file

@ -100,7 +100,7 @@ public class ItemShovelNA extends ItemSpade implements IModItem, ICreativeItem,
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
if (this == ModItems.INFUSED_SHOVEL)
return Helper.makeRechargeProvider(stack);
return Helper.makeRechargeProvider(stack, true);
else return null;
}
}

View file

@ -59,7 +59,7 @@ public class ItemSwordNA extends ItemSword implements IModItem, ICreativeItem, I
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
if (this == ModItems.INFUSED_SWORD)
return Helper.makeRechargeProvider(stack);
return Helper.makeRechargeProvider(stack, true);
else return null;
}
}

View file

@ -59,6 +59,10 @@ item.naturesaura.farming_stencil.name=Farming Stencil
item.naturesaura.bottle_two_the_rebottling.name=Bottle and Cork
item.naturesaura.sky_ingot.name=Ingot of the Skies
item.naturesaura.calling_spirit.name=Spirit of Calling
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
container.naturesaura.tree_ritual.name=Ritual of the Forest
container.naturesaura.altar.name=Natural Altar Infusion

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,26 @@
{
"name": "Botanist's Armor",
"icon": "naturesaura:infused_iron_chest",
"category": "items",
"advancement": "naturesaura:infused_materials",
"pages": [
{
"type": "text",
"text": "Additionally to their $(l:items/infused_iron_tools)tools$(), a botanist can gain protection through armor, specifically $(item)Botanist's Armor$(). Along with being about as protective as iron armor, it can have its lost durability recharged by sneaking while posessing an $(l:items/aura_cache)Aura Cache$(), similarly to the tools of the same kind. Additionally, however, the armor also has a $(thing)set bonus$() which is applied when the full armor set is worn at once."
},
{
"type": "text",
"text": "Then, when a mob attacks the wearer, it will be inflicted with a short $(item)Withering$() effect, hurting it in a similar way to the Thorns enchantment.$(br)Additionally, using an $(l:items/shockwave_creator)Amulet of Wrath$() while the full set is equipped will also inflict the Withering effect onto any mobs that are hit by its effect for a short amount of time."
},
{
"type": "crafting",
"recipe": "naturesaura:infused_helmet",
"recipe2": "naturesaura:infused_chest"
},
{
"type": "crafting",
"recipe": "naturesaura:infused_pants",
"recipe2": "naturesaura:infused_shoes"
}
]
}

View file

@ -10,7 +10,7 @@
},
{
"type": "text",
"text": "On top of that, when taking an $(l:naturesaura:items/aura_cache)Aura Cache$() with you, the tools will be able to use the $(aura) that it has stored to regenerate their durability, significantly increasing their lifespan. For this, one simply needs to hold still and sneak, and the tool in one's hand will slowly recharge."
"text": "On top of that, when taking an $(l:items/aura_cache)Aura Cache$() with you, the tools will be able to use the $(aura) that it has stored to regenerate their durability, significantly increasing their lifespan. For this, one simply needs to hold still and sneak, and the tool in one's hand will slowly recharge."
},
{
"type": "crafting",

View file

@ -0,0 +1,19 @@
{
"type": "forge:ore_shaped",
"pattern": [
"ASA",
"AAA",
"AAA"
],
"key": {
"A": {
"item": "naturesaura:infused_iron"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:infused_iron_chest"
}
}

View file

@ -0,0 +1,18 @@
{
"type": "forge:ore_shaped",
"pattern": [
"AAA",
"ASA"
],
"key": {
"A": {
"item": "naturesaura:infused_iron"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:infused_iron_helmet"
}
}

View file

@ -0,0 +1,16 @@
{
"type": "forge:ore_shaped",
"pattern": [
"AAA",
"A A",
"A A"
],
"key": {
"A": {
"item": "naturesaura:infused_iron"
}
},
"result": {
"item": "naturesaura:infused_iron_pants"
}
}

View file

@ -0,0 +1,15 @@
{
"type": "forge:ore_shaped",
"pattern": [
"A A",
"A A"
],
"key": {
"A": {
"item": "naturesaura:infused_iron"
}
},
"result": {
"item": "naturesaura:infused_iron_shoes"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B