diff --git a/src/main/java/vazkii/botania/api/BotaniaAPI.java b/src/main/java/vazkii/botania/api/BotaniaAPI.java index 35bae71db..f2039572e 100644 --- a/src/main/java/vazkii/botania/api/BotaniaAPI.java +++ b/src/main/java/vazkii/botania/api/BotaniaAPI.java @@ -20,11 +20,13 @@ import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.SoundEvents; +import net.minecraft.util.registry.DefaultedRegistry; +import net.minecraft.util.registry.MutableRegistry; +import net.minecraft.util.registry.Registry; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.IRegistryDelegate; +import net.minecraftforge.registries.*; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.internal.DummyMethodHandler; @@ -52,7 +54,8 @@ public final class BotaniaAPI { @CapabilityInject(IExoflameHeatable.class) public static Capability EXOFLAME_HEATABLE_CAP; - public static final Map brewMap = new LinkedHashMap<>(); + // TODO 1.15 MOVE THIS + public static IForgeRegistry brewRegistry; /* * These maps are not meant to be mutated! @@ -327,7 +330,9 @@ public final class BotaniaAPI { public static final Rarity rarityRelic = Rarity.create("RELIC", TextFormatting.GOLD); - public static final Brew fallbackBrew = new Brew("fallback", "botania.brew.fallback", 0, 0); + // todo 1.15 move this too + @ObjectHolder("botania:fallback") + public static Brew fallbackBrew; /** * The internal method handler in use. @@ -338,25 +343,6 @@ public final class BotaniaAPI { */ public static volatile IInternalMethodHandler internalHandler = new DummyMethodHandler(); - /** - * Registers a Brew and returns it. - */ - public static Brew registerBrew(Brew brew) { - brewMap.put(brew.getKey(), brew); - return brew; - } - - /** - * Gets a brew from the key passed in, returns the fallback if - * it's not in the map. - */ - public static Brew getBrewFromKey(String key) { - if (brewMap.containsKey(key)) { - return brewMap.get(key); - } - return fallbackBrew; - } - // todo 1.15 this is temporary, move when moving API to interface public static IAttribute getPixieSpawnChanceAttribute() { return PixieHandler.PIXIE_SPAWN_CHANCE; diff --git a/src/main/java/vazkii/botania/api/brew/Brew.java b/src/main/java/vazkii/botania/api/brew/Brew.java index 64662df19..cc2e69c0d 100644 --- a/src/main/java/vazkii/botania/api/brew/Brew.java +++ b/src/main/java/vazkii/botania/api/brew/Brew.java @@ -12,16 +12,14 @@ import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; +import net.minecraftforge.registries.ForgeRegistryEntry; import java.util.List; /** * The class for a Brew definition, each one is a singleton. */ -public class Brew { - - private final String key; - private final String name; +public class Brew extends ForgeRegistryEntry { private final int color; private final int cost; private final List effects; @@ -29,15 +27,14 @@ public class Brew { private boolean canInfuseIncense = true; /** - * @param name The unlocalized name of this potion. * @param color The color for the potion to be rendered in the bottle, note that it will get * changed a bit when it renders (for more or less brightness) to give a fancy effect. + * See {@link net.minecraft.potion.PotionUtils#getPotionColorFromEffectList} for a method + * to calculate this automatically. * @param cost The cost, in Mana for this brew. * @param effects A list of effects to apply to the player when they drink it. */ - public Brew(String key, String name, int color, int cost, EffectInstance... effects) { - this.key = key; - this.name = name; + public Brew(int color, int cost, EffectInstance... effects) { this.color = color; this.cost = cost; this.effects = ImmutableList.copyOf(effects); @@ -67,26 +64,18 @@ public class Brew { return canInfuseIncense; } - /** - * Returns the key for this brew, for it to be found in the map in the API. - * This should ALWAYS return the same result. - */ - public String getKey() { - return key; - } - /** * Gets the insensitive unlocalized name. This is used for the lexicon. */ - public String getUnlocalizedName() { - return name; + public String getTranslationKey() { + return String.format("%s.brew.%s", getRegistryName().getNamespace(), getRegistryName().getPath()); } /** * Gets the unlocalized name for the ItemStack passed in. */ - public String getUnlocalizedName(ItemStack stack) { - return getUnlocalizedName(); + public String getTranslationKey(ItemStack stack) { + return getTranslationKey(); } /** diff --git a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java index e4748b179..dd870e00c 100644 --- a/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java +++ b/src/main/java/vazkii/botania/api/recipe/RecipeBrew.java @@ -108,7 +108,7 @@ public class RecipeBrew { public void write(PacketBuffer buf) { buf.writeResourceLocation(id); - buf.writeString(brew.getKey()); + buf.writeResourceLocation(brew.getRegistryName()); buf.writeVarInt(inputs.size()); for (Ingredient input : inputs) { input.write(buf); @@ -117,7 +117,7 @@ public class RecipeBrew { public static RecipeBrew read(PacketBuffer buf) { ResourceLocation id = buf.readResourceLocation(); - Brew brew = BotaniaAPI.getBrewFromKey(buf.readString()); + Brew brew = BotaniaAPI.brewRegistry.getValue(buf.readResourceLocation()); Ingredient[] inputs = new Ingredient[buf.readVarInt()]; for (int i = 0; i < inputs.length; i++) { inputs[i] = Ingredient.read(buf); diff --git a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java index da123fd4d..c7d5949a4 100644 --- a/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java +++ b/src/main/java/vazkii/botania/api/state/BotaniaStateProps.java @@ -28,9 +28,6 @@ public final class BotaniaStateProps { // The property for floating flower island type public static final ModelProperty FLOATING_DATA = new ModelProperty<>(); - // The 16 Minecraft colors - public static final EnumProperty COLOR = EnumProperty.create("color", DyeColor.class); - // Redstone power - boolean // Also for any other simple boolean "on/off" state public static final BooleanProperty POWERED = BooleanProperty.create("powered"); diff --git a/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java b/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java index a738ba247..a15403a9b 100644 --- a/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java +++ b/src/main/java/vazkii/botania/client/patchouli/processor/BrewRecipeProcessor.java @@ -32,7 +32,7 @@ public class BrewRecipeProcessor implements IComponentProcessor { if (recipe == null) { return null; } else if (key.equals("heading")) { - return I18n.format("botaniamisc.brewOf", I18n.format(recipe.getBrew().getUnlocalizedName())); + return I18n.format("botaniamisc.brewOf", I18n.format(recipe.getBrew().getTranslationKey())); } else if (key.equals("vial")) { return PatchouliAPI.instance.serializeItemStack(recipe.getOutput(new ItemStack(ModItems.vial))); } else if (key.equals("flask")) { diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index ccf15ef34..8bd24c0d5 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -126,13 +126,11 @@ public class Botania { BotaniaAPI.internalHandler = new InternalMethodHandler(); PacketHandler.init(); - ModBrews.init(); if (Botania.thaumcraftLoaded) { if (ConfigHandler.COMMON.enableThaumcraftAspects.get()) { // todo 1.13 MinecraftForge.EVENT_BUS.register(TCAspects.class); } - ModBrews.initTC(); } MinecraftForge.EVENT_BUS.register(ManaNetworkHandler.instance); diff --git a/src/main/java/vazkii/botania/common/brew/BrewMod.java b/src/main/java/vazkii/botania/common/brew/BrewMod.java deleted file mode 100644 index 022c93e10..000000000 --- a/src/main/java/vazkii/botania/common/brew/BrewMod.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This class is distributed as part of the Botania Mod. - * Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.common.brew; - -import net.minecraft.potion.EffectInstance; -import net.minecraft.potion.PotionUtils; - -import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.brew.Brew; - -import java.util.Arrays; - -public class BrewMod extends Brew { - - public BrewMod(String key, int color, int cost, EffectInstance... effects) { - super(key, key, color, cost, effects); - BotaniaAPI.registerBrew(this); - } - - public BrewMod(String key, int cost, EffectInstance... effects) { - this(key, PotionUtils.getPotionColorFromEffectList(Arrays.asList(effects)), cost, effects); - } - - @Override - public String getUnlocalizedName() { - return "botania.brew." + super.getUnlocalizedName(); - } - -} diff --git a/src/main/java/vazkii/botania/common/brew/ModBrews.java b/src/main/java/vazkii/botania/common/brew/ModBrews.java index d3bdb283f..d8b82dd5c 100644 --- a/src/main/java/vazkii/botania/common/brew/ModBrews.java +++ b/src/main/java/vazkii/botania/common/brew/ModBrews.java @@ -11,14 +11,27 @@ package vazkii.botania.common.brew; import net.minecraft.potion.Effect; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; +import net.minecraft.potion.PotionUtils; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.event.RegistryEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryBuilder; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.common.lib.LibBrewNames; +import vazkii.botania.common.lib.LibMisc; +import java.util.Arrays; + +import static vazkii.botania.common.lib.ResourceLocationHelper.prefix; + +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, modid = LibMisc.MOD_ID) public class ModBrews { + public static Brew fallback; public static Brew speed; public static Brew strength; public static Brew haste; @@ -43,35 +56,57 @@ public class ModBrews { public static Brew warpWard; - public static void init() { - speed = new BrewMod(LibBrewNames.SPEED, 0x59B7FF, 4000, new EffectInstance(Effects.SPEED, 1800, 1)); - strength = new BrewMod(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new EffectInstance(Effects.STRENGTH, 1800, 1)); - haste = new BrewMod(LibBrewNames.HASTE, 0xF4A432, 4000, new EffectInstance(Effects.HASTE, 1800, 1)); - healing = new BrewMod(LibBrewNames.HEALING, 0xFF5ECC, 6000, new EffectInstance(Effects.INSTANT_HEALTH, 1, 1)); - jumpBoost = new BrewMod(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new EffectInstance(Effects.JUMP_BOOST, 1800, 1)); - regen = new BrewMod(LibBrewNames.REGEN, 0xFD6488, 7000, new EffectInstance(Effects.REGENERATION, 500, 1)); - regenWeak = new BrewMod(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new EffectInstance(Effects.REGENERATION, 2400, 0)); - resistance = new BrewMod(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new EffectInstance(Effects.RESISTANCE, 1800, 1)); - fireResistance = new BrewMod(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new EffectInstance(Effects.FIRE_RESISTANCE, 9600, 0)); - waterBreathing = new BrewMod(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new EffectInstance(Effects.WATER_BREATHING, 9600, 0)); - invisibility = new BrewMod(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new EffectInstance(Effects.INVISIBILITY, 9600, 0)).setNotBloodPendantInfusable(); - nightVision = new BrewMod(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new EffectInstance(Effects.NIGHT_VISION, 9600, 0)); - absorption = new BrewMod(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new EffectInstance(Effects.ABSORPTION, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable(); - - overload = new BrewMod(LibBrewNames.OVERLOAD, 0x232323, 12000, new EffectInstance(Effects.STRENGTH, 1800, 3), new EffectInstance(Effects.SPEED, 1800, 2), new EffectInstance(Effects.WEAKNESS, 3600, 1), new EffectInstance(Effects.HUNGER, 200, 2)); - soulCross = new BrewMod(LibBrewNames.SOUL_CROSS, 10000, new EffectInstance(ModPotions.soulCross, 1800, 0)); - featherfeet = new BrewMod(LibBrewNames.FEATHER_FEET, 7000, new EffectInstance(ModPotions.featherfeet, 1800, 0)); - emptiness = new BrewMod(LibBrewNames.EMPTINESS, 30000, new EffectInstance(ModPotions.emptiness, 7200, 0)); - bloodthirst = new BrewMod(LibBrewNames.BLOODTHIRST, 20000, new EffectInstance(ModPotions.bloodthrst, 7200, 0)); - allure = new BrewMod(LibBrewNames.ALLURE, 2000, new EffectInstance(ModPotions.allure, 4800, 0)); - clear = new BrewMod(LibBrewNames.CLEAR, 4000, new EffectInstance(ModPotions.clear, 0, 0)); + @SubscribeEvent + public static void registerRegistry(RegistryEvent.NewRegistry evt) { + BotaniaAPI.brewRegistry = new RegistryBuilder() + .setName(prefix("brews")) + .setType(Brew.class) + .setDefaultKey(prefix("fallback")) + .disableSaving() + .create(); } - public static void initTC() { + @SubscribeEvent + public static void register(RegistryEvent.Register evt) { + fallback = make("fallback", 0, 0); + speed = make(LibBrewNames.SPEED, 0x59B7FF, 4000, new EffectInstance(Effects.SPEED, 1800, 1)); + strength = make(LibBrewNames.STRENGTH, 0xEE3F3F, 4000, new EffectInstance(Effects.STRENGTH, 1800, 1)); + haste = make(LibBrewNames.HASTE, 0xF4A432, 4000, new EffectInstance(Effects.HASTE, 1800, 1)); + healing = make(LibBrewNames.HEALING, 0xFF5ECC, 6000, new EffectInstance(Effects.INSTANT_HEALTH, 1, 1)); + jumpBoost = make(LibBrewNames.JUMP_BOOST, 0x32F46D, 4000, new EffectInstance(Effects.JUMP_BOOST, 1800, 1)); + regen = make(LibBrewNames.REGEN, 0xFD6488, 7000, new EffectInstance(Effects.REGENERATION, 500, 1)); + regenWeak = make(LibBrewNames.REGEN_WEAK, 0xFD6488, 9000, new EffectInstance(Effects.REGENERATION, 2400, 0)); + resistance = make(LibBrewNames.RESISTANCE, 0xB44E17, 4000, new EffectInstance(Effects.RESISTANCE, 1800, 1)); + fireResistance = make(LibBrewNames.FIRE_RESISTANCE, 0xF86900, 4000, new EffectInstance(Effects.FIRE_RESISTANCE, 9600, 0)); + waterBreathing = make(LibBrewNames.WATER_BREATHING, 0x84A7CF, 4000, new EffectInstance(Effects.WATER_BREATHING, 9600, 0)); + invisibility = make(LibBrewNames.INVISIBILITY, 0xAEAEAE, 8000, new EffectInstance(Effects.INVISIBILITY, 9600, 0)).setNotBloodPendantInfusable(); + nightVision = make(LibBrewNames.NIGHT_VISION, 0x7C4BEB, 4000, new EffectInstance(Effects.NIGHT_VISION, 9600, 0)); + absorption = make(LibBrewNames.ABSORPTION, 0xF2EB23, 7000, new EffectInstance(Effects.ABSORPTION, 1800, 3)).setNotBloodPendantInfusable().setNotIncenseInfusable(); + + overload = make(LibBrewNames.OVERLOAD, 0x232323, 12000, new EffectInstance(Effects.STRENGTH, 1800, 3), new EffectInstance(Effects.SPEED, 1800, 2), new EffectInstance(Effects.WEAKNESS, 3600, 1), new EffectInstance(Effects.HUNGER, 200, 2)); + soulCross = make(LibBrewNames.SOUL_CROSS, 10000, new EffectInstance(ModPotions.soulCross, 1800, 0)); + featherfeet = make(LibBrewNames.FEATHER_FEET, 7000, new EffectInstance(ModPotions.featherfeet, 1800, 0)); + emptiness = make(LibBrewNames.EMPTINESS, 30000, new EffectInstance(ModPotions.emptiness, 7200, 0)); + bloodthirst = make(LibBrewNames.BLOODTHIRST, 20000, new EffectInstance(ModPotions.bloodthrst, 7200, 0)); + allure = make(LibBrewNames.ALLURE, 2000, new EffectInstance(ModPotions.allure, 4800, 0)); + clear = make(LibBrewNames.CLEAR, 4000, new EffectInstance(ModPotions.clear, 0, 0)); + evt.getRegistry().registerAll(fallback, speed, strength, haste, healing, jumpBoost, regen, regenWeak, resistance, + fireResistance, waterBreathing, invisibility, nightVision, absorption, overload, soulCross, featherfeet, + emptiness, bloodthirst, allure, clear); + Effect warpWardPotion = ForgeRegistries.POTIONS.getValue(new ResourceLocation("thaumcraft:warpward")); if (warpWardPotion != null) { - warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new EffectInstance(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable(); + warpWard = make(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new EffectInstance(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable(); + evt.getRegistry().register(warpWard); } } + + private static Brew make(String name, int cost, EffectInstance... effects) { + return new Brew(PotionUtils.getPotionColorFromEffectList(Arrays.asList(effects)), cost, effects).setRegistryName(prefix(name)); + } + + private static Brew make(String name, int color, int cost, EffectInstance... effects) { + return new Brew(color, cost, effects).setRegistryName(prefix(name)); + } } diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java index 6eb43a305..40581836f 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemBrewBase.java @@ -122,9 +122,9 @@ public class ItemBrewBase extends Item implements IBrewItem { @Override public void fillItemGroup(ItemGroup tab, NonNullList list) { if (isInGroup(tab)) { - for (String s : BotaniaAPI.brewMap.keySet()) { + for (ResourceLocation id : BotaniaAPI.brewRegistry.getKeys()) { ItemStack stack = new ItemStack(this); - setBrew(stack, s); + setBrew(stack, id); list.add(stack); } } @@ -133,7 +133,7 @@ public class ItemBrewBase extends Item implements IBrewItem { @Nonnull @Override public ITextComponent getDisplayName(@Nonnull ItemStack stack) { - return new TranslationTextComponent(getTranslationKey(), new TranslationTextComponent(getBrew(stack).getUnlocalizedName(stack)), + return new TranslationTextComponent(getTranslationKey(), new TranslationTextComponent(getBrew(stack).getTranslationKey(stack)), new StringTextComponent(Integer.toString(getSwigsLeft(stack))).applyTextStyle(TextFormatting.BOLD)); } @@ -201,15 +201,15 @@ public class ItemBrewBase extends Item implements IBrewItem { @Override public Brew getBrew(ItemStack stack) { String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); + return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key)); } public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getKey()); + setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getRegistryName()); } - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + public static void setBrew(ItemStack stack, ResourceLocation brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew.toString()); } @Nonnull diff --git a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java index 7a2507d3a..d8188d103 100644 --- a/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java +++ b/src/main/java/vazkii/botania/common/item/brew/ItemIncenseStick.java @@ -13,6 +13,7 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; @@ -43,8 +44,8 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList list) { super.fillItemGroup(tab, list); if (isInGroup(tab)) { - for (String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + for (Brew brew : BotaniaAPI.brewRegistry) { + ItemStack brewStack = getItemForBrew(brew, new ItemStack(this)); if (!brewStack.isEmpty()) { list.add(brewStack); } @@ -61,22 +62,22 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer return; } - list.add(new TranslationTextComponent("botaniamisc.brewOf", new TranslationTextComponent(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE)); + list.add(new TranslationTextComponent("botaniamisc.brewOf", new TranslationTextComponent(brew.getTranslationKey(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE)); ItemBrewBase.addPotionTooltip(brew.getPotionEffects(stack), list, TIME_MULTIPLIER); } @Override public Brew getBrew(ItemStack stack) { String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); + return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key)); } public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); + setBrew(stack, brew.getRegistryName()); } - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + public static void setBrew(ItemStack stack, ResourceLocation brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew.toString()); } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index 460b84f93..b1a74cf52 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -14,7 +14,6 @@ import com.mojang.blaze3d.vertex.IVertexBuilder; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Atlases; import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.Vector3f; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.resources.I18n; @@ -27,6 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.EffectInstance; import net.minecraft.potion.Effects; import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; @@ -38,7 +38,6 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.brew.Brew; import vazkii.botania.api.brew.IBrewContainer; import vazkii.botania.api.brew.IBrewItem; -import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.BaubleRenderHandler; @@ -59,8 +58,8 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre public void fillItemGroup(ItemGroup tab, NonNullList list) { super.fillItemGroup(tab, list); if (isInGroup(tab)) { - for (String s : BotaniaAPI.brewMap.keySet()) { - ItemStack brewStack = getItemForBrew(BotaniaAPI.brewMap.get(s), new ItemStack(this)); + for (Brew brew : BotaniaAPI.brewRegistry) { + ItemStack brewStack = getItemForBrew(brew, new ItemStack(this)); if (!brewStack.isEmpty()) { list.add(brewStack); } @@ -79,7 +78,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre return; } - list.add(new TranslationTextComponent("botaniamisc.brewOf", I18n.format(brew.getUnlocalizedName(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE)); + list.add(new TranslationTextComponent("botaniamisc.brewOf", I18n.format(brew.getTranslationKey(stack))).applyTextStyle(TextFormatting.LIGHT_PURPLE)); for (EffectInstance effect : brew.getPotionEffects(stack)) { TextFormatting format = effect.getPotion().type.getColor(); ITextComponent cmp = new TranslationTextComponent(effect.getEffectName()); @@ -139,15 +138,15 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre @Override public Brew getBrew(ItemStack stack) { String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, ""); - return BotaniaAPI.getBrewFromKey(key); + return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key)); } public static void setBrew(ItemStack stack, Brew brew) { - setBrew(stack, brew.getKey()); + setBrew(stack, brew.getRegistryName()); } - public static void setBrew(ItemStack stack, String brew) { - ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew); + public static void setBrew(ItemStack stack, ResourceLocation brew) { + ItemNBTHelper.setString(stack, TAG_BREW_KEY, brew.toString()); } @Override diff --git a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java index 94038a12c..9f4c37d5f 100644 --- a/src/main/java/vazkii/botania/common/lib/LibBrewNames.java +++ b/src/main/java/vazkii/botania/common/lib/LibBrewNames.java @@ -14,24 +14,24 @@ public final class LibBrewNames { public static final String STRENGTH = "strength"; public static final String HASTE = "haste"; public static final String HEALING = "healing"; - public static final String JUMP_BOOST = "jumpBoost"; + public static final String JUMP_BOOST = "jump_boost"; public static final String REGEN = "regen"; - public static final String REGEN_WEAK = "regenWeak"; + public static final String REGEN_WEAK = "regen_weak"; public static final String RESISTANCE = "resistance"; - public static final String FIRE_RESISTANCE = "fireResistance"; - public static final String WATER_BREATHING = "waterBreathing"; + public static final String FIRE_RESISTANCE = "fire_resistance"; + public static final String WATER_BREATHING = "water_breathing"; public static final String INVISIBILITY = "invisibility"; - public static final String NIGHT_VISION = "nightVision"; + public static final String NIGHT_VISION = "night_vision"; public static final String ABSORPTION = "absorption"; - public static final String SOUL_CROSS = "soulCross"; - public static final String FEATHER_FEET = "featherFeet"; + public static final String SOUL_CROSS = "soul_cross"; + public static final String FEATHER_FEET = "feather_feet"; public static final String EMPTINESS = "emptiness"; public static final String BLOODTHIRST = "bloodthirst"; public static final String OVERLOAD = "overload"; public static final String ALLURE = "allure"; public static final String CLEAR = "clear"; - public static final String WARP_WARD = "warpWard"; + public static final String WARP_WARD = "warp_ward"; } diff --git a/src/main/resources/assets/botania/lang/en_us.json b/src/main/resources/assets/botania/lang/en_us.json index a2a9f2054..be838fd64 100644 --- a/src/main/resources/assets/botania/lang/en_us.json +++ b/src/main/resources/assets/botania/lang/en_us.json @@ -1376,22 +1376,22 @@ "botania.brew.strength": "Vigor", "botania.brew.haste": "Adrenaline", "botania.brew.healing": "Mending", - "botania.brew.jumpBoost": "Upsurging", + "botania.brew.jump_boost": "Upsurging", "botania.brew.regen": "Revitalization", - "botania.brew.regenWeak": "Restoration", + "botania.brew.regen_weak": "Restoration", "botania.brew.resistance": "Fortitude", - "botania.brew.fireResistance": "Magmaskin", - "botania.brew.waterBreathing": "Gills", + "botania.brew.fire_resistance": "Magmaskin", + "botania.brew.water_breathing": "Gills", "botania.brew.invisibility": "Cloaking", - "botania.brew.nightVision": "Owlsight", + "botania.brew.night_vision": "Owlsight", "botania.brew.absorption": "Shielding", - "botania.brew.soulCross": "Crossed Souls", - "botania.brew.featherFeet": "Feather Feet", + "botania.brew.soul_cross": "Crossed Souls", + "botania.brew.feather_feet": "Feather Feet", "botania.brew.emptiness": "Vanity's Emptiness", "botania.brew.bloodthirst": "Crimson Shade", "botania.brew.overload": "Overload", "botania.brew.allure": "Marine Allure", - "botania.brew.warpWard": "Sane Thoughts", + "botania.brew.warp_ward": "Sane Thoughts", "botania.brew.clear": "Absolution", "effect.botania.soul_cross": "Soul Cross", diff --git a/src/main/resources/assets/botania/lang/es_es.json b/src/main/resources/assets/botania/lang/es_es.json index a0442c54b..8e549c886 100644 --- a/src/main/resources/assets/botania/lang/es_es.json +++ b/src/main/resources/assets/botania/lang/es_es.json @@ -1187,22 +1187,22 @@ "botania.brew.strength": "vigor", "botania.brew.haste": "adrenalina", "botania.brew.healing": "reparación", - "botania.brew.jumpBoost": "aumento", + "botania.brew.jump_boost": "aumento", "botania.brew.regen": "revitalización", - "botania.brew.regenWeak": "restauración", + "botania.brew.regen_weak": "restauración", "botania.brew.resistance": "fortaleza", - "botania.brew.fireResistance": "piel magmática", - "botania.brew.waterBreathing": "agallas", + "botania.brew.fire_resistance": "piel magmática", + "botania.brew.water_breathing": "agallas", "botania.brew.invisibility": "ocultamiento", - "botania.brew.nightVision": "vista de búho", + "botania.brew.night_vision": "vista de búho", "botania.brew.absorption": "protección", - "botania.brew.soulCross": "cruz de alma", - "botania.brew.featherFeet": "pies de pluma", + "botania.brew.soul_cross": "cruz de alma", + "botania.brew.feather_feet": "pies de pluma", "botania.brew.emptiness": "vacío vanal", "botania.brew.bloodthirst": "sombra carmesí", "botania.brew.overload": "sobrecarga", "botania.brew.allure": "atracción marina", - "botania.brew.warpWard": "pensamientos cuerdos", + "botania.brew.warp_ward": "pensamientos cuerdos", "botania.brew.clear": "absolución", "effect.botania.soul_cross": "Cruz de alma", diff --git a/src/main/resources/assets/botania/lang/fr_fr.json b/src/main/resources/assets/botania/lang/fr_fr.json index 5bb111bee..a924d9f26 100644 --- a/src/main/resources/assets/botania/lang/fr_fr.json +++ b/src/main/resources/assets/botania/lang/fr_fr.json @@ -1050,22 +1050,22 @@ "botania.brew.strength": "Vigueur", "botania.brew.haste": "Adrénaline", "botania.brew.healing": "Raccomodage", - "botania.brew.jumpBoost": "Augmentation", + "botania.brew.jump_boost": "Augmentation", "botania.brew.regen": "Revitalisation", - "botania.brew.regenWeak": "Restauration", + "botania.brew.regen_weak": "Restauration", "botania.brew.resistance": "Fermeté", - "botania.brew.fireResistance": "Peau de magma", - "botania.brew.waterBreathing": "Branchies", + "botania.brew.fire_resistance": "Peau de magma", + "botania.brew.water_breathing": "Branchies", "botania.brew.invisibility": "Dissimulation", - "botania.brew.nightVision": "Vue de hibou", + "botania.brew.night_vision": "Vue de hibou", "botania.brew.absorption": "Protection", - "botania.brew.soulCross": "Âmes croisées", - "botania.brew.featherFeet": "Pieds de plume", + "botania.brew.soul_cross": "Âmes croisées", + "botania.brew.feather_feet": "Pieds de plume", "botania.brew.emptiness": "Le vide de vanité", "botania.brew.bloodthirst": "Ombre cramoisie", "botania.brew.overload": "Surcharge", "botania.brew.allure": "Charme marin", - "botania.brew.warpWard": "Pensées saines", + "botania.brew.warp_ward": "Pensées saines", "botania.brew.clear": "Absolution", "effect.botania.soul_cross": "Croisée d'âme", diff --git a/src/main/resources/assets/botania/lang/ko_kr.json b/src/main/resources/assets/botania/lang/ko_kr.json index df2b77790..97accfca3 100644 --- a/src/main/resources/assets/botania/lang/ko_kr.json +++ b/src/main/resources/assets/botania/lang/ko_kr.json @@ -1153,22 +1153,22 @@ "botania.brew.strength": "활력", "botania.brew.haste": "흥분", "botania.brew.healing": "수선", - "botania.brew.jumpBoost": "급증", + "botania.brew.jump_boost": "급증", "botania.brew.regen": "재활성화", - "botania.brew.regenWeak": "복원", + "botania.brew.regen_weak": "복원", "botania.brew.resistance": "정신력", - "botania.brew.fireResistance": "단단한피부", - "botania.brew.waterBreathing": "아가미", + "botania.brew.fire_resistance": "단단한피부", + "botania.brew.water_breathing": "아가미", "botania.brew.invisibility": "은폐", - "botania.brew.nightVision": "올빼미의시야", + "botania.brew.night_vision": "올빼미의시야", "botania.brew.absorption": "차폐", - "botania.brew.soulCross": "소울 크로스", - "botania.brew.featherFeet": "날개달린 발", + "botania.brew.soul_cross": "소울 크로스", + "botania.brew.feather_feet": "날개달린 발", "botania.brew.emptiness": "자만의 공허", "botania.brew.bloodthirst": "핏빛 안개", "botania.brew.overload": "과부화", "botania.brew.allure": "바다의 매력", - "botania.brew.warpWard": "온전한 정신", + "botania.brew.warp_ward": "온전한 정신", "botania.brew.clear": "면죄", "effect.botania.soul_cross": "소울 크로스", diff --git a/src/main/resources/assets/botania/lang/nl_nl.json b/src/main/resources/assets/botania/lang/nl_nl.json index 428d58113..eb1cef904 100644 --- a/src/main/resources/assets/botania/lang/nl_nl.json +++ b/src/main/resources/assets/botania/lang/nl_nl.json @@ -1240,22 +1240,22 @@ "botania.brew.strength": "Kracht", "botania.brew.haste": "Adrenaline", "botania.brew.healing": "Genezend", - "botania.brew.jumpBoost": "Opwaarts", + "botania.brew.jump_boost": "Opwaarts", "botania.brew.regen": "Vitaliserend", - "botania.brew.regenWeak": "Herstellend", + "botania.brew.regen_weak": "Herstellend", "botania.brew.resistance": "Standvastigheid", - "botania.brew.fireResistance": "Magmahuid", - "botania.brew.waterBreathing": "Kieuwen", + "botania.brew.fire_resistance": "Magmahuid", + "botania.brew.water_breathing": "Kieuwen", "botania.brew.invisibility": "Camouflage", - "botania.brew.nightVision": "Uilenzicht", + "botania.brew.night_vision": "Uilenzicht", "botania.brew.absorption": "Afscherming", - "botania.brew.soulCross": "Gekruisde Zielen", - "botania.brew.featherFeet": "Lichtvoetig", + "botania.brew.soul_cross": "Gekruisde Zielen", + "botania.brew.feather_feet": "Lichtvoetig", "botania.brew.emptiness": "Ijdelheid's Leegte", "botania.brew.bloodthirst": "Crimson Schaduw", "botania.brew.overload": "Overbelasting", "botania.brew.allure": "Waterverleiding", - "botania.brew.warpWard": "Verstandige Gedachten", + "botania.brew.warp_ward": "Verstandige Gedachten", "botania.brew.clear": "Totaalheid", "effect.botania.soul_cross": "Gekruisde Zielen", diff --git a/src/main/resources/assets/botania/lang/pt_br.json b/src/main/resources/assets/botania/lang/pt_br.json index 7ebaba0c6..2b9e98730 100644 --- a/src/main/resources/assets/botania/lang/pt_br.json +++ b/src/main/resources/assets/botania/lang/pt_br.json @@ -1299,22 +1299,22 @@ "botania.brew.strength": "Vigor", "botania.brew.haste": "Adrenalina", "botania.brew.healing": "Cura", - "botania.brew.jumpBoost": "Super Pulo", + "botania.brew.jump_boost": "Super Pulo", "botania.brew.regen": "Revitalização", - "botania.brew.regenWeak": "Restauração", + "botania.brew.regen_weak": "Restauração", "botania.brew.resistance": "Resistência", - "botania.brew.fireResistance": "Pele de Magma", - "botania.brew.waterBreathing": "Guelras", + "botania.brew.fire_resistance": "Pele de Magma", + "botania.brew.water_breathing": "Guelras", "botania.brew.invisibility": "Invisibilidade", - "botania.brew.nightVision": "Visão Noturna", + "botania.brew.night_vision": "Visão Noturna", "botania.brew.absorption": "Absorção", - "botania.brew.soulCross": "Almas Cruzadas", - "botania.brew.featherFeet": "Peso Pena", + "botania.brew.soul_cross": "Almas Cruzadas", + "botania.brew.feather_feet": "Peso Pena", "botania.brew.emptiness": "Vazio da Alma", "botania.brew.bloodthirst": "Sombra Carmim", "botania.brew.overload": "Sobrecarga", "botania.brew.allure": "Sedução marinha", - "botania.brew.warpWard": "Mente Sã", + "botania.brew.warp_ward": "Mente Sã", "botania.brew.clear": "Absolução", "effect.botania.soul_cross": "Almas Cruzadas", diff --git a/src/main/resources/assets/botania/lang/ru_ru.json b/src/main/resources/assets/botania/lang/ru_ru.json index c0fbb7108..02cfefc28 100644 --- a/src/main/resources/assets/botania/lang/ru_ru.json +++ b/src/main/resources/assets/botania/lang/ru_ru.json @@ -1458,22 +1458,22 @@ "botania.brew.strength": "Силы", "botania.brew.haste": "Ускорения", "botania.brew.healing": "Мгновенного лечения", - "botania.brew.jumpBoost": "Прыгучести", + "botania.brew.jump_boost": "Прыгучести", "botania.brew.regen": "Восстановления", - "botania.brew.regenWeak": "Восстановления (II)", + "botania.brew.regen_weak": "Восстановления (II)", "botania.brew.resistance": "Сопротивления урону", - "botania.brew.fireResistance": "Огнестойкости", - "botania.brew.waterBreathing": "Подводного дыхания", + "botania.brew.fire_resistance": "Огнестойкости", + "botania.brew.water_breathing": "Подводного дыхания", "botania.brew.invisibility": "Невидимости", - "botania.brew.nightVision": "Ночного зрения", + "botania.brew.night_vision": "Ночного зрения", "botania.brew.absorption": "Поглощения", - "botania.brew.soulCross": "Вампиризма", - "botania.brew.featherFeet": "Защиты от падений", + "botania.brew.soul_cross": "Вампиризма", + "botania.brew.feather_feet": "Защиты от падений", "botania.brew.emptiness": "Тщеславия пустоты", "botania.brew.bloodthirst": "Багровой тени", "botania.brew.overload": "Божественной силы", "botania.brew.allure": "Морского очарования", - "botania.brew.warpWard": "Здравых мыслей", + "botania.brew.warp_ward": "Здравых мыслей", "botania.brew.clear": "Отпущения грехов", "botania.potion.soulCross": "Скрещивания душ", diff --git a/src/main/resources/assets/botania/lang/zh_cn.json b/src/main/resources/assets/botania/lang/zh_cn.json index 1a01d42e0..7611ebd29 100644 --- a/src/main/resources/assets/botania/lang/zh_cn.json +++ b/src/main/resources/assets/botania/lang/zh_cn.json @@ -1350,22 +1350,22 @@ "botania.brew.strength": "活力", "botania.brew.haste": "肾上腺素", "botania.brew.healing": "治疗", - "botania.brew.jumpBoost": "上涌", + "botania.brew.jump_boost": "上涌", "botania.brew.regen": "再生", - "botania.brew.regenWeak": "恢复", + "botania.brew.regen_weak": "恢复", "botania.brew.resistance": "刚毅", - "botania.brew.fireResistance": "炎肤", - "botania.brew.waterBreathing": "鱼鳃", + "botania.brew.fire_resistance": "炎肤", + "botania.brew.water_breathing": "鱼鳃", "botania.brew.invisibility": "隐身", - "botania.brew.nightVision": "枭眼", + "botania.brew.night_vision": "枭眼", "botania.brew.absorption": "护盾", - "botania.brew.soulCross": "噬魂", - "botania.brew.featherFeet": "羽翼", + "botania.brew.soul_cross": "噬魂", + "botania.brew.feather_feet": "羽翼", "botania.brew.emptiness": "虚空之影", "botania.brew.bloodthirst": "腥红之影", "botania.brew.overload": "过载", "botania.brew.allure": "诱惑", - "botania.brew.warpWard": "理智", + "botania.brew.warp_ward": "理智", "botania.brew.clear": "赦免", "effect.botania.soul_cross": "噬魂", diff --git a/src/main/resources/assets/botania/lang/zh_tw.json b/src/main/resources/assets/botania/lang/zh_tw.json index 176d158d2..fea3ba9e0 100644 --- a/src/main/resources/assets/botania/lang/zh_tw.json +++ b/src/main/resources/assets/botania/lang/zh_tw.json @@ -1334,22 +1334,22 @@ "botania.brew.strength": "活力", "botania.brew.haste": "腎上腺素", "botania.brew.healing": "治療", - "botania.brew.jumpBoost": "上湧", + "botania.brew.jump_boost": "上湧", "botania.brew.regen": "再生", - "botania.brew.regenWeak": "恢復", + "botania.brew.regen_weak": "恢復", "botania.brew.resistance": "剛毅", - "botania.brew.fireResistance": "炎膚", - "botania.brew.waterBreathing": "魚鰓", + "botania.brew.fire_resistance": "炎膚", + "botania.brew.water_breathing": "魚鰓", "botania.brew.invisibility": "隱身", - "botania.brew.nightVision": "梟眼", + "botania.brew.night_vision": "梟眼", "botania.brew.absorption": "護盾", - "botania.brew.soulCross": "噬魂", - "botania.brew.featherFeet": "羽翼", + "botania.brew.soul_cross": "噬魂", + "botania.brew.feather_feet": "羽翼", "botania.brew.emptiness": "虛空之影", "botania.brew.bloodthirst": "腥紅之影", "botania.brew.overload": "過載", "botania.brew.allure": "誘惑", - "botania.brew.warpWard": "理智", + "botania.brew.warp_ward": "理智", "botania.brew.clear": "赦免", "effect.botania.soul_cross": "噬魂",