From b20c1be95f2cd22ab79739a4732ba2b6a7d184cb Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 8 Nov 2018 13:50:45 +0100 Subject: [PATCH] added bottled aura --- .../naturesaura/items/ItemAuraBottle.java | 88 ++++++++++++++++++ .../ellpeck/naturesaura/items/ModItems.java | 17 ++-- .../assets/naturesaura/lang/en_US.lang | 4 + .../naturesaura/models/item/aura_bottle.json | 26 ++++++ .../models/item/aura_bottle_end.json | 6 ++ .../models/item/aura_bottle_nether.json | 6 ++ .../models/item/aura_bottle_other.json | 6 ++ .../en_us/entries/collecting/aura_bottle.json | 17 ++++ .../textures/items/aura_bottle_end.png | Bin 0 -> 301 bytes .../textures/items/aura_bottle_nether.png | Bin 0 -> 316 bytes .../textures/items/aura_bottle_other.png | Bin 0 -> 310 bytes .../textures/items/aura_bottle_overworld.png | Bin 0 -> 294 bytes 12 files changed, 162 insertions(+), 8 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java create mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle.json create mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json create mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json create mode 100644 src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json create mode 100644 src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png create mode 100644 src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java new file mode 100644 index 00000000..0200d9eb --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraBottle.java @@ -0,0 +1,88 @@ +package de.ellpeck.naturesaura.items; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.aura.AuraType; +import de.ellpeck.naturesaura.aura.chunk.AuraChunk; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.text.translation.I18n; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class ItemAuraBottle extends ItemImpl { + + public ItemAuraBottle() { + super("aura_bottle"); + this.addPropertyOverride(new ResourceLocation(NaturesAura.MOD_ID, "type"), + (stack, worldIn, entityIn) -> getType(stack).ordinal()); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onRightClick(PlayerInteractEvent.RightClickItem event) { + ItemStack held = event.getItemStack(); + if (held.isEmpty() || held.getItem() != Items.GLASS_BOTTLE) + return; + EntityPlayer player = event.getEntityPlayer(); + RayTraceResult ray = this.rayTrace(player.world, player, true); + if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) + return; + BlockPos pos = player.getPosition(); + if (AuraChunk.getAuraInArea(player.world, pos, 30) < 1000) + return; + + if (!player.world.isRemote) { + held.shrink(1); + + player.inventory.addItemStackToInventory( + setType(new ItemStack(this), AuraType.forWorld(player.world))); + + BlockPos spot = AuraChunk.getHighestSpot(player.world, pos, 30, pos); + AuraChunk.getAuraChunk(player.world, spot).drainAura(spot, 500); + + player.world.playSound(null, player.posX, player.posY, player.posZ, + SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1F, 1F); + } + player.swingArm(event.getHand()); + } + + @Override + public void getSubItems(CreativeTabs tab, NonNullList items) { + if (this.isInCreativeTab(tab)) { + for (AuraType type : AuraType.values()) { + ItemStack stack = new ItemStack(this); + setType(stack, type); + items.add(stack); + } + } + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return I18n.translateToLocal(this.getUnlocalizedNameInefficiently(stack) + "." + getType(stack).name().toLowerCase() + ".name").trim(); + } + + public static AuraType getType(ItemStack stack) { + if (!stack.hasTagCompound()) + return AuraType.OTHER; + String type = stack.getTagCompound().getString("type"); + return AuraType.valueOf(type); + } + + public static ItemStack setType(ItemStack stack, AuraType type) { + if (!stack.hasTagCompound()) + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setString("type", type.name()); + return stack; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 9d7111aa..f3897b5c 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -9,6 +9,14 @@ 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 Item EYE = new ItemEye(); public static final Item GOLD_FIBER = new ItemGoldFiber(); public static final Item GOLD_LEAF = new ItemImpl("gold_leaf"); @@ -17,13 +25,6 @@ public final class ModItems { public static final Item COLOR_CHANGER = new ItemColorChanger(); public static final Item AURA_CACHE = new ItemAuraCache(); public static final Item SHOCKWAVE_CREATOR = new ItemShockwaveCreator(); - - 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 Item MULTIBLOCK_MAKER = new ItemMultiblockMaker(); + public static final Item AURA_BOTTLE = new ItemAuraBottle(); } diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index 49f56efc..102b17f0 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -44,6 +44,10 @@ item.naturesaura.color_changer.name=Bucket of Infinite Color item.naturesaura.book.name=Book of Natural Aura item.naturesaura.shockwave_creator.name=Amulet of Wrath item.naturesaura.multiblock_maker.name=Multiblock Maker +item.naturesaura.aura_bottle.overworld.name=Bottled Sunlight +item.naturesaura.aura_bottle.nether.name=Bottled Ghosts +item.naturesaura.aura_bottle.end.name=Bottled Darkness +item.naturesaura.aura_bottle.other.name=Bottled Substance container.naturesaura.tree_ritual.name=Ritual of the Forest container.naturesaura.altar.name=Natural Altar Infusion diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle.json new file mode 100644 index 00000000..fc0685c3 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/aura_bottle.json @@ -0,0 +1,26 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/aura_bottle_overworld" + }, + "overrides": [ + { + "predicate": { + "naturesaura:type": 1 + }, + "model": "naturesaura:item/aura_bottle_nether" + }, + { + "predicate": { + "naturesaura:type": 2 + }, + "model": "naturesaura:item/aura_bottle_end" + }, + { + "predicate": { + "naturesaura:type": 3 + }, + "model": "naturesaura:item/aura_bottle_other" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json new file mode 100644 index 00000000..e4ad0195 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/aura_bottle_end.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/aura_bottle_end" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json new file mode 100644 index 00000000..a7bf0b8b --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/aura_bottle_nether.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/aura_bottle_nether" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json b/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json new file mode 100644 index 00000000..ada33030 --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/aura_bottle_other.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/aura_bottle_other" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json new file mode 100644 index 00000000..1cdb07f0 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/collecting/aura_bottle.json @@ -0,0 +1,17 @@ +{ + "name": "Aura Bottling", + "icon": "naturesaura:aura_bottle{type:'OVERWORLD'}", + "category": "collecting", + "advancement": "naturesaura:gold_leaf", + "pages": [ + { + "type": "text", + "text": "$(aura) and its presence in the world has been a conundrum to researchers for decades. As such, they needed a way to better be able to analyze it, which is why $(item)Bottles$() were invented.$(br)While this might not be the full story of their conception, they can still be used to collect $(aura) in its purest form by simply interacting with the air directly while holding one in your hand." + }, + { + "type": "spotlight", + "item": "naturesaura:aura_bottle{type:'OVERWORLD'}", + "text": "Of course, based on the world that you are currently in, the type of $(aura) collected will slightly vary. For instance, in the normal world, $(aura) can be gathered in the form of sunlight, while in the Nether realm, $(aura) can be gathered in the form of ghosts." + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png new file mode 100644 index 0000000000000000000000000000000000000000..b1bc5c878470f70377141595044a7192135fd907 GIT binary patch literal 301 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3nto3g#}EtuWQjWuyw*McZ@aMVfB3G||Ju0( z`RCbGe)@mr*U|!>N6t$-m=$>0lXd>DFADu*e>djM|DDCpJ<3@GT-c#RocCg(En95!h-nUu=FGdYF9 r$I$F73vUDCjHDEvsf*MSfW8XZdf|opEtfQ)(-=Hm{an^LB{Ts5+b(6V literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png new file mode 100644 index 0000000000000000000000000000000000000000..db1fdb3094d87d42204d6f2dc16766f01f1a8e21 GIT binary patch literal 316 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3nt7fsjv*HQ$r5)Sc&&T>-*#c!|L|R_|Fv@o z^3SuW{Ph3KucZY%kDQlwFe~t~C+qxQUljVs{%*{h|2vDHdz7kh3QS0wpeDh4=;E(QM|ofzG&#^?C_7xQaX*{MA;1U4l{;j zoVGk3Mhs~jn=W^nF)ZOoPwY^5&Hr3{{~elF{r G5}E+4Y-%q6 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png new file mode 100644 index 0000000000000000000000000000000000000000..360ec68cdea16d6017898a0bb7eed241a4a61972 GIT binary patch literal 310 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`3dtTpz6=aistgPb%?u1b{{!il z3=E|P3=FRl7#OT(FffScPl`Y422{&g;1OBOz`zYOgj;}dt@7SdprAyFYeY$Kep*R+ zVo@qXL1JcJiC$i6iGqoqp`Kx~)*Nr3ni-xhjv*HQ$r5)Sc&&T>-*#c!|L|R_|Fv@o z^3SuW{Ph3KucZY%kDQlwFe~t~C+qxQUljVs{%*{h|2vDHdz7N6t$-m=$>0lXd>DFADu*e>djM|DDCpJ<3@d&1N#~_2I3*+)e*XMsZq=y$8|WqmPgg&ebxsLQ09fK