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 00000000..b1bc5c87 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_end.png differ 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 00000000..db1fdb30 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_nether.png differ 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 00000000..360ec68c Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_other.png differ diff --git a/src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png new file mode 100644 index 00000000..23449358 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/items/aura_bottle_overworld.png differ