From 8b02621c5d647ab893474f23bb8e1262a3160d4e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 18 Mar 2019 21:19:06 +0100 Subject: [PATCH] aura trove my dudes --- .../naturesaura/compat/BaublesCompat.java | 63 +++++++++---------- .../naturesaura/events/ClientEvents.java | 5 +- .../naturesaura/items/ItemAuraCache.java | 9 ++- .../ellpeck/naturesaura/items/ModItems.java | 3 +- .../blockstates/projectile_generator.json | 20 ++++++ .../assets/naturesaura/lang/en_US.lang | 1 + .../naturesaura/models/item/aura_trove.json | 6 ++ .../book/en_us/entries/items/aura_trove.json | 17 +++++ .../naturesaura/recipes/aura_trove.json | 22 +++++++ 9 files changed, 108 insertions(+), 38 deletions(-) create mode 100644 src/main/resources/assets/naturesaura/blockstates/projectile_generator.json create mode 100644 src/main/resources/assets/naturesaura/models/item/aura_trove.json create mode 100644 src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/aura_trove.json create mode 100644 src/main/resources/assets/naturesaura/recipes/aura_trove.json diff --git a/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java index 3247cffb..101f6ff4 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/BaublesCompat.java @@ -20,44 +20,17 @@ import javax.annotation.Nullable; public class BaublesCompat { - private final IBauble eye = stack -> BaubleType.CHARM; - private final IBauble cache = new IBauble() { - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.BELT; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - stack.getItem().onUpdate(stack, player.world, player, -1, false); - } - - @Override - public boolean willAutoSync(ItemStack stack, EntityLivingBase player) { - return true; - } - }; - private final IBauble shockwaveCreator = new IBauble() { - @Override - public BaubleType getBaubleType(ItemStack itemstack) { - return BaubleType.AMULET; - } - - @Override - public void onWornTick(ItemStack stack, EntityLivingBase player) { - stack.getItem().onUpdate(stack, player.world, player, -1, false); - } - }; - @SubscribeEvent public void onCapabilitiesAttach(AttachCapabilitiesEvent event) { Item item = event.getObject().getItem(); if (item == ModItems.EYE || item == ModItems.EYE_IMPROVED) - this.addCap(event, this.eye); + this.addCap(event, stack -> BaubleType.CHARM); else if (item == ModItems.AURA_CACHE) - this.addCap(event, this.cache); + this.addCap(event, new UpdatingBauble(BaubleType.BELT, true)); + else if (item == ModItems.AURA_TROVE) + this.addCap(event, new UpdatingBauble(BaubleType.BELT, true)); else if (item == ModItems.SHOCKWAVE_CREATOR) - this.addCap(event, this.shockwaveCreator); + this.addCap(event, new UpdatingBauble(BaubleType.AMULET, false)); } @@ -75,4 +48,30 @@ public class BaublesCompat { } }); } + + private static class UpdatingBauble implements IBauble { + + private final BaubleType type; + private final boolean sync; + + public UpdatingBauble(BaubleType type, boolean sync) { + this.type = type; + this.sync = sync; + } + + @Override + public BaubleType getBaubleType(ItemStack itemstack) { + return this.type; + } + + @Override + public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) { + return this.sync; + } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + stack.getItem().onUpdate(stack, player.world, player, -1, false); + } + } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java index ed504baa..11fcbf35 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/ClientEvents.java @@ -14,6 +14,7 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar; import de.ellpeck.naturesaura.blocks.tiles.TileEntityRFConverter; import de.ellpeck.naturesaura.compat.Compat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; +import de.ellpeck.naturesaura.items.ItemAuraCache; import de.ellpeck.naturesaura.items.ItemRangeVisualizer; import de.ellpeck.naturesaura.items.ModItems; import de.ellpeck.naturesaura.particles.ParticleHandler; @@ -165,7 +166,7 @@ public class ClientEvents { for (int i = 0; i < baubles.getSlots(); i++) { ItemStack slot = baubles.getStackInSlot(i); if (!slot.isEmpty()) { - if (slot.getItem() == ModItems.AURA_CACHE) + if (slot.getItem() instanceof ItemAuraCache) heldCache = slot; else if (slot.getItem() == ModItems.EYE) heldEye = slot; @@ -178,7 +179,7 @@ public class ClientEvents { for (int i = 0; i < mc.player.inventory.getSizeInventory(); i++) { ItemStack slot = mc.player.inventory.getStackInSlot(i); if (!slot.isEmpty()) { - if (slot.getItem() == ModItems.AURA_CACHE) + if (slot.getItem() instanceof ItemAuraCache) heldCache = slot; else if (slot.getItem() == ModItems.EYE && i <= 8) heldEye = slot; diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java index 58587163..c8fd0f40 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemAuraCache.java @@ -26,8 +26,11 @@ import javax.annotation.Nullable; public class ItemAuraCache extends ItemImpl implements ITrinketItem { - public ItemAuraCache() { - super("aura_cache"); + private final int capacity; + + public ItemAuraCache(String name, int capacity) { + super(name); + this.capacity = capacity; this.setMaxStackSize(1); } @@ -82,7 +85,7 @@ public class ItemAuraCache extends ItemImpl implements ITrinketItem { @Override public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { return new ICapabilityProvider() { - private final ItemAuraContainer container = new ItemAuraContainer(stack, null, 400000); + private final ItemAuraContainer container = new ItemAuraContainer(stack, null, ItemAuraCache.this.capacity); @Override public boolean hasCapability(@Nonnull Capability capability, @Nullable EnumFacing facing) { diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 6a3990e2..ee458273 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -33,7 +33,8 @@ public final class ModItems { public static final Item INFUSED_IRON = new ItemImpl("infused_iron"); public static final Item ANCIENT_STICK = new ItemImpl("ancient_stick"); public static final Item COLOR_CHANGER = new ItemColorChanger(); - public static final Item AURA_CACHE = new ItemAuraCache(); + public static final Item AURA_CACHE = new ItemAuraCache("aura_cache", 400000); + public static final Item AURA_TROVE = new ItemAuraCache("aura_trove", 1200000); public static final Item SHOCKWAVE_CREATOR = new ItemShockwaveCreator(); public static final Item MULTIBLOCK_MAKER = new ItemMultiblockMaker(); public static final Item BOTTLE_TWO = new ItemImpl("bottle_two_the_rebottling"); diff --git a/src/main/resources/assets/naturesaura/blockstates/projectile_generator.json b/src/main/resources/assets/naturesaura/blockstates/projectile_generator.json new file mode 100644 index 00000000..d743cb40 --- /dev/null +++ b/src/main/resources/assets/naturesaura/blockstates/projectile_generator.json @@ -0,0 +1,20 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "minecraft:cube", + "textures": { + "particle": "naturesaura:blocks/projectile_generator", + "up": "naturesaura:blocks/projectile_generator_top", + "down": "#particle", + "north": "#particle", + "east": "#particle", + "south": "#particle", + "west": "#particle" + }, + "transform": "forge:default-block" + }, + "variants": { + "normal": [{}], + "inventory": [{}] + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index bfd61459..c83bf6ef 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -95,6 +95,7 @@ item.naturesaura.token_sorrow.name=Token of Sorrow item.naturesaura.token_terror.name=Token of Terror item.naturesaura.ender_access.name=Ender Ocular item.naturesaura.cave_finder.name=Staff of Shadows +item.naturesaura.aura_trove.name=Aura Trove 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_trove.json b/src/main/resources/assets/naturesaura/models/item/aura_trove.json new file mode 100644 index 00000000..9c54327d --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/item/aura_trove.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:items/aura_trove" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/aura_trove.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/aura_trove.json new file mode 100644 index 00000000..94bac053 --- /dev/null +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/items/aura_trove.json @@ -0,0 +1,17 @@ +{ + "name": "Aura Trove", + "icon": "naturesaura:aura_trove", + "category": "items", + "advancement": "naturesaura:sky_ingot", + "pages": [ + { + "type": "text", + "text": "Once the amount of $(aura) required becomes too much for the $(l:items/aura_cache)Aura Cache$() to store without having to refill it on too regular of a basis, one can employ the help of an $(item)Aura Trove$() - a higher tier version of the $(item)Aura Cache$() that has three times its storage capacity." + }, + { + "type": "crafting", + "text": "Creating the $(item)Aura Trove$()", + "recipe": "naturesaura:aura_trove" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/recipes/aura_trove.json b/src/main/resources/assets/naturesaura/recipes/aura_trove.json new file mode 100644 index 00000000..84c3feb6 --- /dev/null +++ b/src/main/resources/assets/naturesaura/recipes/aura_trove.json @@ -0,0 +1,22 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "SIS", + "IBI", + "SIS" + ], + "key": { + "S": { + "item": "naturesaura:infused_stone" + }, + "I": { + "item": "naturesaura:sky_ingot" + }, + "B": { + "item": "naturesaura:aura_cache" + } + }, + "result": { + "item": "naturesaura:aura_trove" + } +} \ No newline at end of file