mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Move brews to a forge registry (about time)
This commit is contained in:
1 parent
9af5cdbd2d
commit
12129ea470
21 files changed
+183
-213
No files matched your search
@@ -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<IExoflameHeatable> EXOFLAME_HEATABLE_CAP;
|
||||
|
||||
public static final Map<String, Brew> brewMap = new LinkedHashMap<>();
|
||||
// TODO 1.15 MOVE THIS
|
||||
public static IForgeRegistry<Brew> 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;
|
||||
|
||||
@@ -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<Brew> {
|
||||
private final int color;
|
||||
private final int cost;
|
||||
private final List<EffectInstance> 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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -28,9 +28,6 @@ public final class BotaniaStateProps {
|
||||
// The property for floating flower island type
|
||||
public static final ModelProperty<IFloatingFlower> FLOATING_DATA = new ModelProperty<>();
|
||||
|
||||
// The 16 Minecraft colors
|
||||
public static final EnumProperty<DyeColor> 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");
|
||||
|
||||
@@ -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")) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<Brew>()
|
||||
.setName(prefix("brews"))
|
||||
.setType(Brew.class)
|
||||
.setDefaultKey(prefix("fallback"))
|
||||
.disableSaving()
|
||||
.create();
|
||||
}
|
||||
|
||||
public static void initTC() {
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<Brew> 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));
|
||||
}
|
||||
}
|
||||
@@ -122,9 +122,9 @@ public class ItemBrewBase extends Item implements IBrewItem {
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup tab, NonNullList<ItemStack> 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
|
||||
|
||||
@@ -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<ItemStack> 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
|
||||
|
||||
@@ -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<ItemStack> 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
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user