diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 58a1fd052..487ff2435 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -425,21 +425,21 @@ a3a11524cd3515fc01d905767b4b7ea782adaf03 assets/create/blockstates/yellow_seat.j 6801fa1f466f172700e573e5b8ee8ee5f9ca4583 assets/create/blockstates/yellow_valve_handle.json 7f39521b211441f5c3e06d60c5978cebe16cacfb assets/create/blockstates/zinc_block.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets/create/blockstates/zinc_ore.json -1fa99fbea1418694aea41dea81f9cbf5e30066d4 assets/create/lang/en_ud.json -f38e0d6773f0618212e6d036290be02692302b1b assets/create/lang/en_us.json -8456877fca4c1c97a74c25c97e0dbd274e728d25 assets/create/lang/unfinished/de_de.json -b3c20a8376120c330440cc29cadbff45608de1a1 assets/create/lang/unfinished/es_es.json -2c72b40a22f6da68c179e875fecc471dfb63882c assets/create/lang/unfinished/es_mx.json -801a7fc4c0b83f94ee5fc6ff2dcfbc2c794e7fd5 assets/create/lang/unfinished/fr_fr.json -7c23104e6f627e2812391696550f7ac560a8543d assets/create/lang/unfinished/it_it.json -6a488e40ec2bd295e51447889e1643b12d744a1b assets/create/lang/unfinished/ja_jp.json -aea13865e1613a09110c6d3b52c3da68015d6a72 assets/create/lang/unfinished/ko_kr.json -7be41ad5b274297072b1cc17663686287bc3f618 assets/create/lang/unfinished/nl_nl.json -3e1957e45a5cc7586236517a5ee0f57788be9e8e assets/create/lang/unfinished/pl_pl.json -e57e2fbe82324c567d130f008865f34c45e2f9be assets/create/lang/unfinished/pt_br.json -e85f3a6441b932d3ebb4023a34d300ad196c7f41 assets/create/lang/unfinished/ru_ru.json -4186b08ae85862b6b73895507f6849d2f249d006 assets/create/lang/unfinished/zh_cn.json -90e0931966c8e272a2bd03378b25769c5daf64bb assets/create/lang/unfinished/zh_tw.json +e1d3c02695cbd2ee7bbede97f72941835634a3a5 assets/create/lang/en_ud.json +3e74ffe81510f420f5f1821808291c0539a14c13 assets/create/lang/en_us.json +82571338ff8edf812ae01f0a5d45c58718374469 assets/create/lang/unfinished/de_de.json +6cf3dd48a1708deedbb7ed1029616d932094aa93 assets/create/lang/unfinished/es_es.json +a6a3d443ff8ef03952f3e1843a88c91349f52680 assets/create/lang/unfinished/es_mx.json +c5fff5dee93fcb5eb5576bdf0598139e11b91e5c assets/create/lang/unfinished/fr_fr.json +1647117134ac3fcda2110abe13504d3699135f9c assets/create/lang/unfinished/it_it.json +ed0fd66cfa74b2390f127262242c8385fb699d72 assets/create/lang/unfinished/ja_jp.json +f0b83a1f5377c07e6a3beaa40d13ffe34ae4a269 assets/create/lang/unfinished/ko_kr.json +8e2ba058fa004c86d48c869232b85a6a1cdfa7f9 assets/create/lang/unfinished/nl_nl.json +0d99e0a375d6d1cf5f00ab48e090f4472fff94ad assets/create/lang/unfinished/pl_pl.json +2d1882cf35f0e09d9e820bd408183d902ed64b50 assets/create/lang/unfinished/pt_br.json +295b171018e6f8c2c488f109f4b080d9019e2ae2 assets/create/lang/unfinished/ru_ru.json +5f238e588fc997b23cb332fb9a0c3594d6cbfaaf assets/create/lang/unfinished/zh_cn.json +274a919cbefb9e83213e579dbc8cc0c507f65df8 assets/create/lang/unfinished/zh_tw.json 487a511a01b2a4531fb672f917922312db78f958 assets/create/models/block/acacia_window.json b48060cba1a382f373a05bf0039054053eccf076 assets/create/models/block/acacia_window_pane_noside.json 3066db1bf03cffa1a9c7fbacf47ae586632f4eb3 assets/create/models/block/acacia_window_pane_noside_alt.json @@ -2490,7 +2490,7 @@ d76113310fc56eca6382d44df174096f2210d416 data/create/loot_tables/blocks/clutch.j 673ba3a5deae9133b917d16c9eb87fe4c2873c8a data/create/loot_tables/blocks/cogwheel.json 096af6b5df6e87d36cb936eea9b00982a554f4af data/create/loot_tables/blocks/content_observer.json 80c2cb21714651116a71f449368c06bb22e841ce data/create/loot_tables/blocks/controller_rail.json -662b8d41803ef166d20850653b36759de719206c data/create/loot_tables/blocks/copper_backtank.json +41992d0c81379e0693a1a5ec3e6ee4ada381df34 data/create/loot_tables/blocks/copper_backtank.json f38802b919c49f162f102d6e5d94113f05bf4ab1 data/create/loot_tables/blocks/copper_block.json 5a65a18ea787130ac7b8f5652bfa5ed187446649 data/create/loot_tables/blocks/copper_casing.json 31a51237763c374b7cdf39b9b62c14e965871047 data/create/loot_tables/blocks/copper_ore.json diff --git a/src/generated/resources/assets/create/lang/en_ud.json b/src/generated/resources/assets/create/lang/en_ud.json index f6297f0e2..8731d1eda 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -426,6 +426,7 @@ "block.create.yellow_valve_handle": "\u01DD\u05DFpu\u0250H \u01DD\u028C\u05DF\u0250\u039B \u028Do\u05DF\u05DF\u01DD\u028E", "block.create.zinc_block": "\u0254u\u0131Z \u025Fo \u029E\u0254o\u05DF\u15FA", "block.create.zinc_ore": "\u01DD\u0279O \u0254u\u0131Z", + "enchantment.create.capacity": "\u028E\u0287\u0131\u0254\u0250d\u0250\u0186", "enchantment.create.potato_recovery": "\u028E\u0279\u01DD\u028Co\u0254\u01DD\u1D1A o\u0287\u0250\u0287o\u0500", "entity.create.contraption": "uo\u0131\u0287d\u0250\u0279\u0287uo\u0186", "entity.create.crafting_blueprint": "\u0287u\u0131\u0279d\u01DDn\u05DF\u15FA bu\u0131\u0287\u025F\u0250\u0279\u0186", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index 50e7a2fb7..a597e594b 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -430,6 +430,7 @@ "block.create.zinc_block": "Block of Zinc", "block.create.zinc_ore": "Zinc Ore", + "enchantment.create.capacity": "Capacity", "enchantment.create.potato_recovery": "Potato Recovery", "entity.create.contraption": "Contraption", diff --git a/src/generated/resources/assets/create/lang/unfinished/de_de.json b/src/generated/resources/assets/create/lang/unfinished/de_de.json index dcd31b851..b143ebadf 100644 --- a/src/generated/resources/assets/create/lang/unfinished/de_de.json +++ b/src/generated/resources/assets/create/lang/unfinished/de_de.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1118", + "_": "Missing Localizations: 1119", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Zinkblock", "block.create.zinc_ore": "Zinkerz", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Vorrichtung", diff --git a/src/generated/resources/assets/create/lang/unfinished/es_es.json b/src/generated/resources/assets/create/lang/unfinished/es_es.json index 3db3726e3..21074e3b5 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_es.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_es.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 41", + "_": "Missing Localizations: 42", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Bloque de zinc", "block.create.zinc_ore": "Mena de zinc", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Artilugio", diff --git a/src/generated/resources/assets/create/lang/unfinished/es_mx.json b/src/generated/resources/assets/create/lang/unfinished/es_mx.json index 5a1a8c86a..971203175 100644 --- a/src/generated/resources/assets/create/lang/unfinished/es_mx.json +++ b/src/generated/resources/assets/create/lang/unfinished/es_mx.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1485", + "_": "Missing Localizations: 1486", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Bloque de Zinc", "block.create.zinc_ore": "Mineral de Zinc", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Artefacto", diff --git a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json index 57b4c4194..94e8e3196 100644 --- a/src/generated/resources/assets/create/lang/unfinished/fr_fr.json +++ b/src/generated/resources/assets/create/lang/unfinished/fr_fr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1370", + "_": "Missing Localizations: 1371", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Bloc de zinc", "block.create.zinc_ore": "Minerai de zinc", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Engin", diff --git a/src/generated/resources/assets/create/lang/unfinished/it_it.json b/src/generated/resources/assets/create/lang/unfinished/it_it.json index 44d778471..b305be2b8 100644 --- a/src/generated/resources/assets/create/lang/unfinished/it_it.json +++ b/src/generated/resources/assets/create/lang/unfinished/it_it.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 898", + "_": "Missing Localizations: 899", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Blocco di zinco", "block.create.zinc_ore": "Zinco grezzo", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Contrazione", diff --git a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json index 75a7148cb..ff6ee296d 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ja_jp.json +++ b/src/generated/resources/assets/create/lang/unfinished/ja_jp.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 30", + "_": "Missing Localizations: 31", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "亜鉛ブロック", "block.create.zinc_ore": "亜鉛鉱石", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "からくり", diff --git a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json index ed57b3807..849b7d5d0 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ko_kr.json +++ b/src/generated/resources/assets/create/lang/unfinished/ko_kr.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 276", + "_": "Missing Localizations: 277", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "아연 블록", "block.create.zinc_ore": "아연 광석", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "장치", diff --git a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json index 0c75091b9..b2204fd12 100644 --- a/src/generated/resources/assets/create/lang/unfinished/nl_nl.json +++ b/src/generated/resources/assets/create/lang/unfinished/nl_nl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1751", + "_": "Missing Localizations: 1752", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "UNLOCALIZED: Block of Zinc", "block.create.zinc_ore": "UNLOCALIZED: Zinc Ore", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "UNLOCALIZED: Contraption", diff --git a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json index 96f3defca..8d16ccfee 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pl_pl.json +++ b/src/generated/resources/assets/create/lang/unfinished/pl_pl.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 240", + "_": "Missing Localizations: 241", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Blok cynku", "block.create.zinc_ore": "Ruda cynku", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Maszyna", diff --git a/src/generated/resources/assets/create/lang/unfinished/pt_br.json b/src/generated/resources/assets/create/lang/unfinished/pt_br.json index 2e8ae8c56..6163cba3a 100644 --- a/src/generated/resources/assets/create/lang/unfinished/pt_br.json +++ b/src/generated/resources/assets/create/lang/unfinished/pt_br.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 1792", + "_": "Missing Localizations: 1793", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "UNLOCALIZED: Block of Zinc", "block.create.zinc_ore": "UNLOCALIZED: Zinc Ore", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "UNLOCALIZED: Contraption", diff --git a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json index 8fd4ba2b7..8a6c396f5 100644 --- a/src/generated/resources/assets/create/lang/unfinished/ru_ru.json +++ b/src/generated/resources/assets/create/lang/unfinished/ru_ru.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 271", + "_": "Missing Localizations: 272", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "Цинковый блок", "block.create.zinc_ore": "Цинковая руда", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "Штуковина", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json index 61b29d131..d7b417dfc 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_cn.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_cn.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 281", + "_": "Missing Localizations: 282", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "锌块", "block.create.zinc_ore": "锌矿石", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "装置", diff --git a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json index 326dabd84..8724d55b5 100644 --- a/src/generated/resources/assets/create/lang/unfinished/zh_tw.json +++ b/src/generated/resources/assets/create/lang/unfinished/zh_tw.json @@ -1,5 +1,5 @@ { - "_": "Missing Localizations: 276", + "_": "Missing Localizations: 277", "_": "->------------------------] Game Elements [------------------------<-", @@ -431,6 +431,7 @@ "block.create.zinc_block": "鋅磚", "block.create.zinc_ore": "鋅礦石", + "enchantment.create.capacity": "UNLOCALIZED: Capacity", "enchantment.create.potato_recovery": "UNLOCALIZED: Potato Recovery", "entity.create.contraption": "結構", diff --git a/src/generated/resources/data/create/loot_tables/blocks/copper_backtank.json b/src/generated/resources/data/create/loot_tables/blocks/copper_backtank.json index b5466bfc9..d1903f132 100644 --- a/src/generated/resources/data/create/loot_tables/blocks/copper_backtank.json +++ b/src/generated/resources/data/create/loot_tables/blocks/copper_backtank.json @@ -21,6 +21,17 @@ "op": "replace" } ] + }, + { + "function": "minecraft:copy_nbt", + "source": "block_entity", + "ops": [ + { + "source": "Enchantments", + "target": "Enchantments", + "op": "replace" + } + ] } ], "name": "create:copper_backtank" diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 28a9ed80c..dd17da0f0 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1324,7 +1324,9 @@ public class AllBlocks { .addEntry(ItemLootEntry.builder(AllItems.COPPER_BACKTANK.get()) .acceptFunction(CopyName.builder(CopyName.Source.BLOCK_ENTITY)) .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) - .func_216056_a("Air", "Air"))))); + .func_216056_a("Air", "Air")) + .acceptFunction(CopyNbt.func_215881_a(CopyNbt.Source.BLOCK_ENTITY) + .func_216056_a("Enchantments", "Enchantments"))))); }) .register(); diff --git a/src/main/java/com/simibubi/create/AllEnchantments.java b/src/main/java/com/simibubi/create/AllEnchantments.java index d1931256f..eae8bf6e0 100644 --- a/src/main/java/com/simibubi/create/AllEnchantments.java +++ b/src/main/java/com/simibubi/create/AllEnchantments.java @@ -1,5 +1,6 @@ package com.simibubi.create; +import com.simibubi.create.content.curiosities.armor.CapacityEnchantment; import com.simibubi.create.content.curiosities.weapons.PotatoRecoveryEnchantment; import com.simibubi.create.foundation.data.CreateRegistrate; import com.tterrag.registrate.util.entry.RegistryEntry; @@ -18,6 +19,13 @@ public class AllEnchantments { .lang("Potato Recovery") .rarity(Rarity.UNCOMMON) .register(); + + public static final RegistryEntry CAPACITY = REGISTRATE.object("capacity") + .enchantment(EnchantmentType.ARMOR_CHEST, CapacityEnchantment::new) + .addSlots(EquipmentSlotType.CHEST) + .lang("Capacity") + .rarity(Rarity.COMMON) + .register(); public static void register() {} diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java index d38cb9ff2..6310de114 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/BackTankUtil.java @@ -1,10 +1,12 @@ package com.simibubi.create.content.curiosities.armor; +import com.simibubi.create.AllEnchantments; import com.simibubi.create.AllItems; import com.simibubi.create.foundation.config.AllConfigs; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; @@ -28,17 +30,26 @@ public class BackTankUtil { public static float getAir(ItemStack backtank) { CompoundNBT tag = backtank.getOrCreateTag(); - return tag.getFloat("Air"); + return Math.min(tag.getFloat("Air"), maxAir(backtank)); } public static void consumeAir(ItemStack backtank, float i) { CompoundNBT tag = backtank.getOrCreateTag(); - tag.putFloat("Air", getAir(backtank) - i); + tag.putFloat("Air", Math.min(getAir(backtank) - i, maxAir(backtank))); backtank.setTag(tag); } - private static float maxAir() { - return AllConfigs.SERVER.curiosities.maxAirInBacktank.get(); + public static int maxAir(ItemStack backtank) { + return maxAir(EnchantmentHelper.getEnchantmentLevel(AllEnchantments.CAPACITY.get(), backtank)); + } + + public static int maxAir(int enchantLevel) { + return AllConfigs.SERVER.curiosities.airInBacktank.get() + + AllConfigs.SERVER.curiosities.enchantedBacktankCapacity.get() * enchantLevel; + } + + public static int maxAirWithoutEnchants() { + return AllConfigs.SERVER.curiosities.airInBacktank.get(); } public static boolean canAbsorbDamage(LivingEntity entity, int usesPerTank) { @@ -51,7 +62,7 @@ public class BackTankUtil { return false; if (!hasAirRemaining(backtank)) return false; - float cost = maxAir() / usesPerTank; + float cost = ((float) maxAirWithoutEnchants()) / usesPerTank; consumeAir(backtank, cost); return true; } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java new file mode 100644 index 000000000..49b31df0d --- /dev/null +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CapacityEnchantment.java @@ -0,0 +1,27 @@ +package com.simibubi.create.content.curiosities.armor; + +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentType; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.ItemStack; + +public class CapacityEnchantment extends Enchantment { + + public CapacityEnchantment(Rarity p_i46731_1_, EnchantmentType p_i46731_2_, EquipmentSlotType[] p_i46731_3_) { + super(p_i46731_1_, p_i46731_2_, p_i46731_3_); + } + + @Override + public int getMaxLevel() { + return 3; + } + + @Override + public boolean canApplyAtEnchantingTable(ItemStack stack) { + return stack.getItem() instanceof ICapacityEnchantable; + } + + public interface ICapacityEnchantable { + } + +} diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java index 01ccb623e..8825db1c5 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperArmorItem.java @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; public class CopperArmorItem extends ArmorItem { public CopperArmorItem(EquipmentSlotType p_i48534_2_, Properties p_i48534_3_) { - super(AllArmorMaterials.COPPER, p_i48534_2_, p_i48534_3_); + super(AllArmorMaterials.COPPER, p_i48534_2_, p_i48534_3_.maxStackSize(1)); } public boolean isWornBy(Entity entity) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankBlock.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankBlock.java index 53327ec31..c19b2d6d9 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankBlock.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.curiosities.armor; import java.util.Optional; +import com.simibubi.create.AllEnchantments; import com.simibubi.create.AllItems; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; @@ -11,6 +12,7 @@ import com.simibubi.create.foundation.block.ITE; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.IWaterLoggable; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.FluidState; @@ -19,6 +21,8 @@ import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; import net.minecraft.pathfinding.PathType; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; @@ -96,8 +100,11 @@ public class CopperBacktankBlock extends HorizontalKineticBlock if (stack == null) return; withTileEntityDo(worldIn, pos, te -> { + te.setCapacityEnchantLevel(EnchantmentHelper.getEnchantmentLevel(AllEnchantments.CAPACITY.get(), stack)); te.setAirLevel(stack.getOrCreateTag() .getInt("Air")); + if (stack.isEnchanted()) + te.setEnchantmentTag(stack.getEnchantmentTagList()); if (stack.hasDisplayName()) te.setCustomName(stack.getDisplayName()); }); @@ -130,12 +137,22 @@ public class CopperBacktankBlock extends HorizontalKineticBlock public ItemStack getItem(IBlockReader p_185473_1_, BlockPos p_185473_2_, BlockState p_185473_3_) { ItemStack item = AllItems.COPPER_BACKTANK.asStack(); Optional tileEntityOptional = getTileEntityOptional(p_185473_1_, p_185473_2_); + int air = tileEntityOptional.map(CopperBacktankTileEntity::getAirLevel) .orElse(0); + CompoundNBT tag = item.getOrCreateTag(); + tag.putInt("Air", air); + + ListNBT enchants = tileEntityOptional.map(CopperBacktankTileEntity::getEnchantmentTag) + .orElse(new ListNBT()); + if (!enchants.isEmpty()) { + ListNBT enchantmentTagList = item.getEnchantmentTagList(); + enchantmentTagList.addAll(enchants); + tag.put("Enchantments", enchantmentTagList); + } + ITextComponent customName = tileEntityOptional.map(CopperBacktankTileEntity::getCustomName) .orElse(null); - item.getOrCreateTag() - .putInt("Air", air); if (customName != null) item.setDisplayName(customName); return item; diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java index 7e537816d..d01a1cda2 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankItem.java @@ -1,6 +1,6 @@ package com.simibubi.create.content.curiosities.armor; -import com.simibubi.create.foundation.config.AllConfigs; +import com.simibubi.create.content.curiosities.armor.CapacityEnchantment.ICapacityEnchantable; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.BlockItem; @@ -12,7 +12,7 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.NonNullList; import net.minecraft.util.math.MathHelper; -public class CopperBacktankItem extends CopperArmorItem { +public class CopperBacktankItem extends CopperArmorItem implements ICapacityEnchantable { public static final int DURABILITY_BAR = 0xefefef; private BlockItem blockItem; @@ -31,6 +31,11 @@ public class CopperBacktankItem extends CopperArmorItem { public boolean isDamageable() { return false; } + + @Override + public boolean isEnchantable(ItemStack p_77616_1_) { + return true; + } @Override public int getRGBDurabilityForDisplay(ItemStack stack) { @@ -44,7 +49,7 @@ public class CopperBacktankItem extends CopperArmorItem { ItemStack stack = new ItemStack(this); CompoundNBT nbt = new CompoundNBT(); - nbt.putInt("Air", AllConfigs.SERVER.curiosities.maxAirInBacktank.get()); + nbt.putInt("Air", BackTankUtil.maxAirWithoutEnchants()); stack.setTag(nbt); p_150895_2_.add(stack); } @@ -52,7 +57,7 @@ public class CopperBacktankItem extends CopperArmorItem { @Override public double getDurabilityForDisplay(ItemStack stack) { return 1 - MathHelper - .clamp(getRemainingAir(stack) / ((float) AllConfigs.SERVER.curiosities.maxAirInBacktank.get()), 0, 1); + .clamp(getRemainingAir(stack) / ((float) BackTankUtil.maxAir(stack)), 0, 1); } @Override @@ -64,5 +69,5 @@ public class CopperBacktankItem extends CopperArmorItem { CompoundNBT orCreateTag = stack.getOrCreateTag(); return orCreateTag.getInt("Air"); } - + } diff --git a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java index 30b63d8c2..a4e94dd08 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java +++ b/src/main/java/com/simibubi/create/content/curiosities/armor/CopperBacktankTileEntity.java @@ -5,11 +5,11 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.base.KineticTileEntity; import com.simibubi.create.content.contraptions.particle.AirParticleData; -import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.utility.VecHelper; import net.minecraft.block.BlockState; import net.minecraft.nbt.CompoundNBT; +import net.minecraft.nbt.ListNBT; import net.minecraft.particles.ParticleTypes; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction.Axis; @@ -18,15 +18,20 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; +import net.minecraftforge.common.util.Constants.NBT; public class CopperBacktankTileEntity extends KineticTileEntity implements INameable { public int airLevel; public int airLevelTimer; private ITextComponent customName; + + private int capacityEnchantLevel; + private ListNBT enchantmentTag; public CopperBacktankTileEntity(TileEntityType typeIn) { super(typeIn); + enchantmentTag = new ListNBT(); } @Override @@ -39,7 +44,7 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName return; } - int max = getMaxAir(); + int max = BackTankUtil.maxAir(capacityEnchantLevel); if (world.isRemote) { Vector3d centerOf = VecHelper.getCenterOf(pos); Vector3d v = VecHelper.offsetRandomly(centerOf, Create.RANDOM, .65f); @@ -60,45 +65,28 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName airLevelTimer = MathHelper.clamp((int) (128f - abs / 5f) - 108, 0, 20); } - protected int getMaxAir() { - return AllConfigs.SERVER.curiosities.maxAirInBacktank.get(); - } - - public int getAirLevel() { - return airLevel; - } - - public void setAirLevel(int airLevel) { - this.airLevel = airLevel; - sendData(); - } - - public void setCustomName(ITextComponent customName) { - this.customName = customName; - } - - public ITextComponent getCustomName() { - return customName; - } - @Override protected void write(CompoundNBT compound, boolean clientPacket) { super.write(compound, clientPacket); compound.putInt("Air", airLevel); compound.putInt("Timer", airLevelTimer); + compound.putInt("CapacityEnchantment", capacityEnchantLevel); if (this.customName != null) compound.putString("CustomName", ITextComponent.Serializer.toJson(this.customName)); + compound.put("Enchantments", enchantmentTag); } @Override protected void fromTag(BlockState state, CompoundNBT compound, boolean clientPacket) { super.fromTag(state, compound, clientPacket); int prev = airLevel; + capacityEnchantLevel = compound.getInt("CapacityEnchantment"); airLevel = compound.getInt("Air"); airLevelTimer = compound.getInt("Timer"); + enchantmentTag = compound.getList("Enchantments", NBT.TAG_COMPOUND); if (compound.contains("CustomName", 8)) this.customName = ITextComponent.Serializer.fromJson(compound.getString("CustomName")); - if (prev != 0 && prev != airLevel && airLevel == getMaxAir() && clientPacket) + if (prev != 0 && prev != airLevel && airLevel == BackTankUtil.maxAir(capacityEnchantLevel) && clientPacket) playFilledEffect(); } @@ -127,4 +115,33 @@ public class CopperBacktankTileEntity extends KineticTileEntity implements IName return true; } + public int getAirLevel() { + return airLevel; + } + + public void setAirLevel(int airLevel) { + this.airLevel = airLevel; + sendData(); + } + + public void setCustomName(ITextComponent customName) { + this.customName = customName; + } + + public ITextComponent getCustomName() { + return customName; + } + + public ListNBT getEnchantmentTag() { + return enchantmentTag; + } + + public void setEnchantmentTag(ListNBT enchantmentTag) { + this.enchantmentTag = enchantmentTag; + } + + public void setCapacityEnchantLevel(int capacityEnchantLevel) { + this.capacityEnchantLevel = capacityEnchantLevel; + } + } diff --git a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java index ffa5876b7..2ba15eaea 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java +++ b/src/main/java/com/simibubi/create/foundation/config/CCuriosities.java @@ -4,7 +4,8 @@ public class CCuriosities extends ConfigBase { public ConfigInt maxSymmetryWandRange = i(50, 10, "maxSymmetryWandRange", Comments.symmetryRange); public ConfigInt placementAssistRange = i(12, 3, "placementAssistRange", Comments.placementRange); - public ConfigInt maxAirInBacktank = i(900, 1, "maxAirInBacktank", Comments.maxAirInBacktank); + public ConfigInt airInBacktank = i(900, 1, "airInBacktank", Comments.maxAirInBacktank); + public ConfigInt enchantedBacktankCapacity = i(300, 1, "enchantedBacktankCapacity", Comments.enchantedBacktankCapacity); public ConfigInt maxExtendoGripActions = i(1000, 0, "maxExtendoGripActions", Comments.maxExtendoGripActions); public ConfigInt maxPotatoCannonShots = i(200, 0, "maxPotatoCannonShots", Comments.maxPotatoCannonShots); @@ -20,6 +21,8 @@ public class CCuriosities extends ConfigBase { static String symmetryRange = "The Maximum Distance to an active mirror for the symmetry wand to trigger."; static String maxAirInBacktank = "The Maximum volume of Air that can be stored in a backtank = Seconds of underwater breathing"; + static String enchantedBacktankCapacity = + "The volume of Air added by each level of the backtanks Capacity Enchantment"; static String placementRange = "The Maximum Distance a Block placed by Create's placement assist will have to its interaction point."; static String maxExtendoGripActions =