mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-23 13:40:11 +00:00
Migrate botaniaAPI and botaniaAPIClient to interface. Rework IMC to not rely on API.
This commit is contained in:
1 parent
b14a964b1e
commit
8e4666918f
65 files changed
+555
-500
No files matched your search
@@ -10,335 +10,195 @@ package vazkii.botania.api;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.entity.ai.attributes.RangedAttribute;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraft.item.IArmorMaterial;
|
||||
import net.minecraft.item.IItemTier;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Rarity;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.LazyValue;
|
||||
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.*;
|
||||
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.DummyMethodHandler;
|
||||
import vazkii.botania.api.internal.IInternalMethodHandler;
|
||||
import vazkii.botania.api.item.IExoflameHeatable;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
import vazkii.botania.api.recipe.RecipeBrew;
|
||||
import vazkii.botania.api.recipe.RecipePetals;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.common.core.handler.PixieHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public final class BotaniaAPI {
|
||||
public static final String NO_MOD_MESSAGE = "Botania not present";
|
||||
public interface BotaniaAPI {
|
||||
LazyValue<BotaniaAPI> INSTANCE = new LazyValue<>(() -> {
|
||||
try {
|
||||
return (BotaniaAPI) Class.forName("vazkii.botania.common.impl.BotaniaAPIImpl").newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
LogManager.getLogger().warn("Unable to find BotaniaAPIImpl, using a dummy");
|
||||
return new BotaniaAPI() {};
|
||||
}
|
||||
});
|
||||
|
||||
public static int apiVersion() {
|
||||
return 94;
|
||||
static BotaniaAPI instance() {
|
||||
return INSTANCE.getValue();
|
||||
}
|
||||
|
||||
@CapabilityInject(IFloatingFlower.class) public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP;
|
||||
default int apiVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@CapabilityInject(IExoflameHeatable.class) public static Capability<IExoflameHeatable> EXOFLAME_HEATABLE_CAP;
|
||||
@CapabilityInject(IFloatingFlower.class) public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP = null;
|
||||
|
||||
// TODO 1.15 MOVE THIS
|
||||
public static IForgeRegistry<Brew> brewRegistry;
|
||||
@CapabilityInject(IExoflameHeatable.class) public static Capability<IExoflameHeatable> EXOFLAME_HEATABLE_CAP = null;
|
||||
|
||||
public static Map<ResourceLocation, Integer> oreWeights = Collections.emptyMap();
|
||||
public static Map<ResourceLocation, Integer> oreWeightsNether = Collections.emptyMap();
|
||||
default IForgeRegistry<Brew> getBrewRegistry() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> paintableBlocks = Collections.emptyMap();
|
||||
default Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
private static final int[] MAX_DAMAGE_ARRAY = new int[] { 13, 15, 16, 11 };
|
||||
public static final IArmorMaterial MANASTEEL_ARMOR_MAT = new IArmorMaterial() {
|
||||
private final int[] damageReduction = { 2, 5, 6, 2 };
|
||||
default Map<ResourceLocation, Integer> getNetherOreWeights() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
default Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> getPaintableBlocks() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
default void registerPaintableBlock(Block block, Function<DyeColor, Block> transformer) {
|
||||
registerPaintableBlock(block.delegate, transformer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make Botania aware of how to transform between different colors of a block, for use in the paint lens.
|
||||
* This method can be safely called during parallel mod initialization
|
||||
* @param block The block
|
||||
* @param transformer Function from color to a new block
|
||||
*/
|
||||
default void registerPaintableBlock(IRegistryDelegate<Block> block, Function<DyeColor, Block> transformer) {
|
||||
|
||||
}
|
||||
|
||||
IArmorMaterial DUMMY_ARMOR_MATERIAL = new IArmorMaterial() {
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slotIn) {
|
||||
return 16 * MAX_DAMAGE_ARRAY[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||
return damageReduction[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return SoundEvents.ITEM_ARMOR_EQUIP_IRON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "manasteel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
public int getDurability(@Nonnull EquipmentSlotType slot) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
public static final IItemTier MANASTEEL_ITEM_TIER = new IItemTier() {
|
||||
@Override
|
||||
public int getMaxUses() {
|
||||
return 300;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEfficiency() {
|
||||
return 6.2F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
|
||||
public static final IArmorMaterial ELEMENTIUM_ARMOR_MAT = new IArmorMaterial() {
|
||||
private final int[] damageReduction = { 2, 5, 6, 2 };
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slotIn) {
|
||||
return 18 * MAX_DAMAGE_ARRAY[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||
return damageReduction[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return SoundEvents.ITEM_ARMOR_EQUIP_IRON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "elementium_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "elementium";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
public int getDamageReductionAmount(@Nonnull EquipmentSlotType slot) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
public static final IItemTier ELEMENTIUM_ITEM_TIER = new IItemTier() {
|
||||
@Override
|
||||
public int getMaxUses() {
|
||||
return 720;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEfficiency() {
|
||||
return 6.2F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 20;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
|
||||
public static final IArmorMaterial TERRASTEEL_ARMOR_MAT = new IArmorMaterial() {
|
||||
private final int[] damageReduction = { 3, 6, 8, 3 };
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slotIn) {
|
||||
return 34 * MAX_DAMAGE_ARRAY[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||
return damageReduction[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 26;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "terrasteel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
return 3;
|
||||
}
|
||||
};
|
||||
public static final IItemTier TERRASTEEL_ITEM_TIER = new IItemTier() {
|
||||
@Override
|
||||
public int getMaxUses() {
|
||||
return 2300;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEfficiency() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 26;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "terrasteel_ingot"));
|
||||
return Ingredient.fromItems(item);
|
||||
}
|
||||
};
|
||||
public static final IArmorMaterial MANAWEAVE_ARMOR_MAT = new IArmorMaterial() {
|
||||
private final int[] damageReduction = { 1, 2, 2, 1 };
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slotIn) {
|
||||
return 5 * MAX_DAMAGE_ARRAY[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slotIn) {
|
||||
return damageReduction[slotIn.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return SoundEvents.ITEM_ARMOR_EQUIP_LEATHER;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("botania", "manaweave_cloth"));
|
||||
return Ingredient.fromItems(item);
|
||||
return Ingredient.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "manaweave";
|
||||
return "missingno";
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
@Override public float getToughness() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Rarity rarityRelic = Rarity.create("RELIC", TextFormatting.GOLD);
|
||||
IItemTier DUMMY_ITEM_TIER = new IItemTier() {
|
||||
@Override
|
||||
public int getMaxUses() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// todo 1.15 move this too
|
||||
@ObjectHolder("botania:fallback") public static Brew fallbackBrew;
|
||||
@Override
|
||||
public float getEfficiency() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal method handler in use.
|
||||
* <b>DO NOT OVERWRITE THIS OR YOU'RE GOING TO FEEL MY WRATH WHEN I UPDATE THE API.</b>
|
||||
* The fact I have to write that means some moron already tried, don't be that moron.
|
||||
*
|
||||
* @see IInternalMethodHandler
|
||||
*/
|
||||
public static volatile IInternalMethodHandler internalHandler = new DummyMethodHandler();
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// todo 1.15 this is temporary, move when moving API to interface
|
||||
public static IAttribute getPixieSpawnChanceAttribute() {
|
||||
return PixieHandler.PIXIE_SPAWN_CHANCE;
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override public Ingredient getRepairMaterial() {
|
||||
return Ingredient.EMPTY;
|
||||
}
|
||||
};
|
||||
|
||||
default IArmorMaterial getManasteelArmorMaterial() {
|
||||
return DUMMY_ARMOR_MATERIAL;
|
||||
}
|
||||
|
||||
default IArmorMaterial getElementiumArmorMaterial() {
|
||||
return DUMMY_ARMOR_MATERIAL;
|
||||
}
|
||||
|
||||
default IArmorMaterial getManaweaveArmorMaterial() {
|
||||
return DUMMY_ARMOR_MATERIAL;
|
||||
}
|
||||
|
||||
default IArmorMaterial getTerrasteelArmorMaterial() {
|
||||
return DUMMY_ARMOR_MATERIAL;
|
||||
}
|
||||
|
||||
default IItemTier getManasteelItemTier() {
|
||||
return DUMMY_ITEM_TIER;
|
||||
}
|
||||
|
||||
default IItemTier getElementiumItemTier() {
|
||||
return DUMMY_ITEM_TIER;
|
||||
}
|
||||
|
||||
default IItemTier getTerrasteelItemTier() {
|
||||
return DUMMY_ITEM_TIER;
|
||||
}
|
||||
|
||||
default Rarity getRelicRarity() {
|
||||
return Rarity.EPIC;
|
||||
}
|
||||
|
||||
// todo 1.15 combine with this and BotaniaAPIClient
|
||||
default IInternalMethodHandler internalHandler() {
|
||||
return new DummyMethodHandler();
|
||||
}
|
||||
|
||||
default IAttribute getPixieSpawnChanceAttribute() {
|
||||
return new RangedAttribute(null, "missingno", 0, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,13 @@
|
||||
*/
|
||||
package vazkii.botania.api;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.LazyValue;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -24,11 +24,19 @@ import java.util.Map;
|
||||
* Class for API calls that must be made clientside
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class BotaniaAPIClient {
|
||||
public interface BotaniaAPIClient {
|
||||
LazyValue<BotaniaAPIClient> INSTANCE = new LazyValue<>(() -> {
|
||||
try {
|
||||
return (BotaniaAPIClient) Class.forName("vazkii.botania.client.impl.BotaniaAPIClientImpl").newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
LogManager.getLogger().warn("Unable to find BotaniaAPIClientImpl, using a dummy");
|
||||
return new BotaniaAPIClient() {};
|
||||
}
|
||||
});
|
||||
|
||||
private static final Map<IFloatingFlower.IslandType, ResourceLocation> islandTypeModels = Maps.newHashMap();
|
||||
|
||||
private BotaniaAPIClient() {}
|
||||
static BotaniaAPIClient instance() {
|
||||
return INSTANCE.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers your model for island type islandType here.
|
||||
@@ -37,15 +45,14 @@ public final class BotaniaAPIClient {
|
||||
* @param islandType The islandtype to register
|
||||
* @param model The model, only {@link ResourceLocation} allowed, no {@link ModelResourceLocation} allowed.
|
||||
*/
|
||||
public static void registerIslandTypeModel(IFloatingFlower.IslandType islandType, ResourceLocation model) {
|
||||
islandTypeModels.put(islandType, model);
|
||||
default void registerIslandTypeModel(IFloatingFlower.IslandType islandType, ResourceLocation model) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An immutable and live view of the registered island type model map
|
||||
*/
|
||||
public static Map<IFloatingFlower.IslandType, ResourceLocation> getRegisteredIslandTypeModels() {
|
||||
return Collections.unmodifiableMap(islandTypeModels);
|
||||
default Map<IFloatingFlower.IslandType, ResourceLocation> getRegisteredIslandTypeModels() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,8 @@
|
||||
package vazkii.botania.api.imc;
|
||||
|
||||
/**
|
||||
* This class defines the IMC methods accepted by Botania and their expected argument types
|
||||
* This class defines the IMC methods accepted by Botania and their expected argument types.
|
||||
* This is just for documentation purposes, IMC is meant to be sent when you don't want to depend on the Botania API classes.
|
||||
*
|
||||
* @see net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent
|
||||
* @see net.minecraftforge.fml.event.lifecycle.InterModProcessEvent
|
||||
@@ -18,21 +19,15 @@ package vazkii.botania.api.imc;
|
||||
public class IMC {
|
||||
/**
|
||||
* Maps a block tag to its weight in world generation. This is used for the Orechid flower.<br />
|
||||
* The argument should be a {@link OreWeightMessage}, any other types are ignored.<br />
|
||||
* The argument should be a {@link com.mojang.datafixers.util.Pair<net.minecraft.util.ResourceLocation, Integer>}, any other types are ignored.<br />
|
||||
* Check the Botania source to see default values.<br>
|
||||
*/
|
||||
public static final String REGISTER_ORE_WEIGHT = "register_ore_weight";
|
||||
|
||||
/**
|
||||
* Maps a block tag to its weight in nether world generation. This is used for the Orechid flower.<br />
|
||||
* The argument should be a {@link OreWeightMessage}, any other types are ignored.<br />
|
||||
* Maps a block tag to its weight in nether world generation. This is used for the Orechid Ignem flower.<br />
|
||||
* The argument should be a {@link com.mojang.datafixers.util.Pair<net.minecraft.util.ResourceLocation, Integer>}, any other types are ignored.<br />
|
||||
* Check the Botania source to see default values.<br>
|
||||
*/
|
||||
public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_ore_weight";
|
||||
|
||||
/**
|
||||
* Registers a block as paintable under the paint lens.<br />
|
||||
* The argument should be a {@link PaintableBlockMessage}, any other types are ignored.
|
||||
*/
|
||||
public static final String REGISTER_PAINTABLE_BLOCK = "register_paintable_block";
|
||||
}
|
||||
@@ -1,33 +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.api.imc;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class OreWeightMessage {
|
||||
private final ResourceLocation blockTag;
|
||||
private final Integer weight;
|
||||
|
||||
/**
|
||||
* @param blockTag ID of a block tag to register
|
||||
* @param weight Weight of the tag
|
||||
*/
|
||||
public OreWeightMessage(ResourceLocation blockTag, Integer weight) {
|
||||
this.blockTag = blockTag;
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
public ResourceLocation getOre() {
|
||||
return blockTag;
|
||||
}
|
||||
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +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.api.imc;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PaintableBlockMessage {
|
||||
private final IRegistryDelegate<Block> block;
|
||||
private final Function<DyeColor, Block> transformer;
|
||||
|
||||
public PaintableBlockMessage(Function<DyeColor, Block> transformer, Block block) {
|
||||
this(transformer, block.delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transformer Lookup function from color to destination block
|
||||
* @param block The block being converted
|
||||
*/
|
||||
public PaintableBlockMessage(Function<DyeColor, Block> transformer, IRegistryDelegate<Block> block) {
|
||||
this.block = block;
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
public IRegistryDelegate<Block> getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public Function<DyeColor, Block> getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
public interface ManaItemHandler {
|
||||
LazyValue<ManaItemHandler> INSTANCE = new LazyValue<>(() -> {
|
||||
try {
|
||||
return (ManaItemHandler) Class.forName("vazkii.botania.common.impl.ManaItemHandlerImpl").newInstance();
|
||||
return (ManaItemHandler) Class.forName("vazkii.botania.common.impl.mana.ManaItemHandlerImpl").newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
LogManager.getLogger().warn("Unable to find ManaItemHandlerImpl, using a dummy");
|
||||
return new ManaItemHandler() {};
|
||||
|
||||
@@ -170,10 +170,10 @@ public class RecipeBrew implements IRecipe<RecipeWrapper> {
|
||||
public RecipeBrew read(@Nonnull ResourceLocation id, @Nonnull JsonObject json) {
|
||||
String brewStr = JSONUtils.getString(json, "brew");
|
||||
ResourceLocation brewId = ResourceLocation.tryCreate(brewStr);
|
||||
if (brewId == null || !BotaniaAPI.brewRegistry.containsKey(brewId)) {
|
||||
if (brewId == null || !BotaniaAPI.instance().getBrewRegistry().containsKey(brewId)) {
|
||||
throw new JsonParseException("Unknown brew " + brewStr);
|
||||
}
|
||||
Brew brew = BotaniaAPI.brewRegistry.getValue(brewId);
|
||||
Brew brew = BotaniaAPI.instance().getBrewRegistry().getValue(brewId);
|
||||
|
||||
JsonArray ingrs = JSONUtils.getJsonArray(json, "ingredients");
|
||||
List<Ingredient> inputs = new ArrayList<>();
|
||||
@@ -185,7 +185,7 @@ public class RecipeBrew implements IRecipe<RecipeWrapper> {
|
||||
|
||||
@Override
|
||||
public RecipeBrew read(@Nonnull ResourceLocation id, @Nonnull PacketBuffer buf) {
|
||||
Brew brew = buf.readRegistryIdUnsafe(BotaniaAPI.brewRegistry);
|
||||
Brew brew = buf.readRegistryIdUnsafe(BotaniaAPI.instance().getBrewRegistry());
|
||||
Ingredient[] inputs = new Ingredient[buf.readVarInt()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = Ingredient.read(buf);
|
||||
@@ -195,7 +195,7 @@ public class RecipeBrew implements IRecipe<RecipeWrapper> {
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buf, @Nonnull RecipeBrew recipe) {
|
||||
buf.writeRegistryIdUnsafe(BotaniaAPI.brewRegistry, recipe.getBrew());
|
||||
buf.writeRegistryIdUnsafe(BotaniaAPI.instance().getBrewRegistry(), recipe.getBrew());
|
||||
buf.writeVarInt(recipe.getIngredients().size());
|
||||
for (Ingredient input : recipe.getIngredients()) {
|
||||
input.write(buf);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
float green = (color >> 8 & 0xFF) / 255F;
|
||||
float blue = (color & 0xFF) / 255F;
|
||||
if (Math.random() > particleChance) {
|
||||
BotaniaAPI.internalHandler.sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
BotaniaAPI.instance().internalHandler().sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,9 +120,9 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
}
|
||||
|
||||
if (needsNew && ticksExisted == 1) { // Only for new flowers
|
||||
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
|
||||
IManaNetwork network = BotaniaAPI.instance().internalHandler().getManaNetworkInstance();
|
||||
int size = network.getAllPoolsInWorld(getWorld()).size();
|
||||
if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
|
||||
if (BotaniaAPI.instance().internalHandler().shouldForceCheck() || size != sizeLastCheck) {
|
||||
linkedPool = network.getClosestPool(getPos(), getWorld(), LINK_RANGE);
|
||||
sizeLastCheck = size;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
|
||||
public void renderHUD(Minecraft mc) {
|
||||
String name = I18n.format(getBlockState().getBlock().getTranslationKey());
|
||||
int color = getColor();
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
BotaniaAPI.instance().internalHandler().drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.instance().internalHandler().getBindDisplayForFlowerType(this), isValidBinding());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -100,13 +100,13 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
double x = getPos().getX() + offset.x;
|
||||
double y = getPos().getY() + offset.y;
|
||||
double z = getPos().getZ() + offset.z;
|
||||
BotaniaAPI.internalHandler.sparkleFX(getWorld(), x + 0.3 + Math.random() * 0.5, y + 0.5 + Math.random() * 0.5, z + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
BotaniaAPI.instance().internalHandler().sparkleFX(getWorld(), x + 0.3 + Math.random() * 0.5, y + 0.5 + Math.random() * 0.5, z + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
boolean passive = isPassiveFlower();
|
||||
if (!getWorld().isRemote) {
|
||||
int muhBalance = BotaniaAPI.internalHandler.getPassiveFlowerDecay();
|
||||
int muhBalance = BotaniaAPI.instance().internalHandler().getPassiveFlowerDecay();
|
||||
|
||||
if (passive && muhBalance > 0 && passiveDecayTicks > muhBalance) {
|
||||
getWorld().destroyBlock(getPos(), false);
|
||||
@@ -146,9 +146,9 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
}
|
||||
|
||||
if (needsNew && ticksExisted == 1) { // New flowers only
|
||||
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
|
||||
IManaNetwork network = BotaniaAPI.instance().internalHandler().getManaNetworkInstance();
|
||||
int size = network.getAllCollectorsInWorld(getWorld()).size();
|
||||
if (BotaniaAPI.internalHandler.shouldForceCheck() || size != sizeLastCheck) {
|
||||
if (BotaniaAPI.instance().internalHandler().shouldForceCheck() || size != sizeLastCheck) {
|
||||
linkedCollector = network.getClosestCollector(getPos(), getWorld(), LINK_RANGE);
|
||||
sizeLastCheck = size;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
|
||||
public void renderHUD(Minecraft mc) {
|
||||
String name = I18n.format(getBlockState().getBlock().getTranslationKey());
|
||||
int color = getColor();
|
||||
BotaniaAPI.internalHandler.drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.internalHandler.getBindDisplayForFlowerType(this), isValidBinding());
|
||||
BotaniaAPI.instance().internalHandler().drawComplexManaHUD(color, getMana(), getMaxMana(), name, BotaniaAPI.instance().internalHandler().getBindDisplayForFlowerType(this), isValidBinding());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -125,7 +125,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
if (cap == BotaniaAPI.FLOATING_FLOWER_CAP) {
|
||||
if (cap == BotaniaAPI.instance().FLOATING_FLOWER_CAP) {
|
||||
if (hasWorld() && getBlockState().isIn(ModTags.Blocks.SPECIAL_FLOATING_FLOWERS)) {
|
||||
return floatingDataCap.cast();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
|
||||
}
|
||||
|
||||
public boolean isFloating() {
|
||||
return getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).isPresent();
|
||||
return getCapability(BotaniaAPI.instance().FLOATING_FLOWER_CAP).isPresent();
|
||||
}
|
||||
|
||||
private boolean isOnSpecialSoil() {
|
||||
@@ -206,7 +206,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
|
||||
*/
|
||||
public void writeToPacketNBT(CompoundNBT cmp) {
|
||||
if (isFloating()) {
|
||||
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
|
||||
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.instance().FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public class TileEntitySpecialFlower extends TileEntity implements ITickableTile
|
||||
*/
|
||||
public void readFromPacketNBT(CompoundNBT cmp) {
|
||||
if (cmp.contains(TAG_FLOATING_DATA)) {
|
||||
BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
|
||||
BotaniaAPI.instance().FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class BoundTileRenderer {
|
||||
|
||||
LazyOptional<IItemHandler> mainInvCap = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP);
|
||||
mainInvCap.ifPresent(mainInv -> {
|
||||
IItemHandlerModifiable acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
IItemHandlerModifiable acc = BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player);
|
||||
IItemHandler joined = acc != null ? new CombinedInvWrapper((IItemHandlerModifiable) mainInv, acc) : mainInv;
|
||||
|
||||
for (int i = 0; i < joined.getSlots(); i++) {
|
||||
|
||||
@@ -24,7 +24,6 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.FoliageColors;
|
||||
import net.minecraft.world.biome.BiomeColors;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
@@ -35,6 +34,7 @@ import vazkii.botania.common.block.decor.BlockPetalBlock;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.block.tile.TilePlatform;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.item.Item16Colors;
|
||||
import vazkii.botania.common.item.ItemManaGun;
|
||||
import vazkii.botania.common.item.ItemManaMirror;
|
||||
@@ -150,7 +150,7 @@ public final class ColorHandler {
|
||||
}
|
||||
|
||||
Brew brew = ((IBrewItem) s.getItem()).getBrew(s);
|
||||
if (brew == BotaniaAPI.fallbackBrew) {
|
||||
if (brew == ModBrews.fallbackBrew) {
|
||||
return s.getItem() instanceof ItemBloodPendant ? 0xC6000E : 0x989898;
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public final class HUDHandler {
|
||||
boolean creative = false;
|
||||
|
||||
IItemHandler mainInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElse(EmptyHandler.INSTANCE);
|
||||
IItemHandler accInv = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
IItemHandler accInv = BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player);
|
||||
|
||||
int invSize = mainInv.getSlots();
|
||||
int size = invSize;
|
||||
|
||||
@@ -173,16 +173,16 @@ public final class ModelHandler {
|
||||
}
|
||||
|
||||
private static void registerSubtiles() {
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.GRASS, prefix("block/islands/island_grass"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.PODZOL, prefix("block/islands/island_podzol"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.MYCEL, prefix("block/islands/island_mycel"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.SNOW, prefix("block/islands/island_snow"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.DRY, prefix("block/islands/island_dry"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.GOLDEN, prefix("block/islands/island_golden"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.VIVID, prefix("block/islands/island_vivid"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.SCORCHED, prefix("block/islands/island_scorched"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.INFUSED, prefix("block/islands/island_infused"));
|
||||
BotaniaAPIClient.registerIslandTypeModel(IFloatingFlower.IslandType.MUTATED, prefix("block/islands/island_mutated"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.GRASS, prefix("block/islands/island_grass"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.PODZOL, prefix("block/islands/island_podzol"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.MYCEL, prefix("block/islands/island_mycel"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.SNOW, prefix("block/islands/island_snow"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.DRY, prefix("block/islands/island_dry"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.GOLDEN, prefix("block/islands/island_golden"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.VIVID, prefix("block/islands/island_vivid"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.SCORCHED, prefix("block/islands/island_scorched"));
|
||||
BotaniaAPIClient.instance().registerIslandTypeModel(IFloatingFlower.IslandType.INFUSED, prefix("block/islands/island_infused"));
|
||||
|
||||
}
|
||||
|
||||
private ModelHandler() {}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.client.impl;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.api.BotaniaAPIClient;
|
||||
import vazkii.botania.api.item.IFloatingFlower;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class BotaniaAPIClientImpl implements BotaniaAPIClient {
|
||||
private final Map<IFloatingFlower.IslandType, ResourceLocation> islandTypeModels = Maps.newHashMap();
|
||||
|
||||
@Override
|
||||
public void registerIslandTypeModel(IFloatingFlower.IslandType islandType, ResourceLocation model) {
|
||||
islandTypeModels.put(islandType, model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<IFloatingFlower.IslandType, ResourceLocation> getRegisteredIslandTypeModels() {
|
||||
return Collections.unmodifiableMap(islandTypeModels);
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
registry.addRecipes(TilePool.manaInfusionRecipes(Minecraft.getInstance().world.getRecipeManager()), ManaPoolRecipeCategory.UID);
|
||||
|
||||
registry.addRecipes(
|
||||
BotaniaAPI.oreWeights.entrySet().stream()
|
||||
BotaniaAPI.instance().getOreWeights().entrySet().stream()
|
||||
.filter(e -> doesOreExist(e.getKey()))
|
||||
.map(OrechidRecipeWrapper::new)
|
||||
.sorted()
|
||||
@@ -137,7 +137,7 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
OrechidRecipeCategory.UID);
|
||||
|
||||
registry.addRecipes(
|
||||
BotaniaAPI.oreWeightsNether.entrySet().stream()
|
||||
BotaniaAPI.instance().getNetherOreWeights().entrySet().stream()
|
||||
.filter(e -> doesOreExist(e.getKey()))
|
||||
.map(OrechidIgnemRecipeWrapper::new)
|
||||
.sorted()
|
||||
|
||||
+1
-1
@@ -46,6 +46,6 @@ public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase<Orechi
|
||||
|
||||
@Override
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeightsNether;
|
||||
return BotaniaAPI.instance().getNetherOreWeights();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class OrechidRecipeCategory extends OrechidRecipeCategoryBase<OrechidReci
|
||||
|
||||
@Override
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.oreWeights;
|
||||
return BotaniaAPI.instance().getOreWeights();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class FloatingFlowerModel implements IModelGeometry<FloatingFlowerModel>
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
Set<Material> ret = new HashSet<>();
|
||||
for (Map.Entry<IFloatingFlower.IslandType, ResourceLocation> e : BotaniaAPIClient.getRegisteredIslandTypeModels().entrySet()) {
|
||||
for (Map.Entry<IFloatingFlower.IslandType, ResourceLocation> e : BotaniaAPIClient.instance().getRegisteredIslandTypeModels().entrySet()) {
|
||||
IUnbakedModel unbakedIsland = modelGetter.apply(e.getValue());
|
||||
ret.addAll(unbakedIsland.getTextureDependencies(modelGetter, missingTextureErrors));
|
||||
unbakedIslands.put(e.getKey(), unbakedIsland);
|
||||
|
||||
@@ -126,8 +126,6 @@ public class Botania {
|
||||
coloredLightsLoaded = ModList.get().isLoaded("easycoloredlights");
|
||||
curiosLoaded = ModList.get().isLoaded("curios");
|
||||
|
||||
BotaniaAPI.internalHandler = new InternalMethodHandler();
|
||||
|
||||
PacketHandler.init();
|
||||
|
||||
if (Botania.thaumcraftLoaded) {
|
||||
@@ -249,7 +247,7 @@ public class Botania {
|
||||
// Overriding the internal method handler will break everything as it changes regularly.
|
||||
// So just don't be a moron and don't override it. Thanks.
|
||||
private void serverAboutToStart(FMLServerAboutToStartEvent event) {
|
||||
String clname = BotaniaAPI.internalHandler.getClass().getName();
|
||||
String clname = BotaniaAPI.instance().internalHandler().getClass().getName();
|
||||
String expect = "vazkii.botania.common.core.handler.InternalMethodHandler";
|
||||
if (!clname.equals(expect)) {
|
||||
throw new IllegalAccessError("The Botania API internal method handler has been overriden. "
|
||||
|
||||
@@ -80,8 +80,8 @@ public class BlockFloatingFlower extends BlockMod {
|
||||
public ActionResultType onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (!stack.isEmpty() && te != null && te.getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).isPresent()) {
|
||||
IFloatingFlower flower = te.getCapability(BotaniaAPI.FLOATING_FLOWER_CAP).orElseThrow(IllegalStateException::new);
|
||||
if (!stack.isEmpty() && te != null && te.getCapability(BotaniaAPI.instance().FLOATING_FLOWER_CAP).isPresent()) {
|
||||
IFloatingFlower flower = te.getCapability(BotaniaAPI.instance().FLOATING_FLOWER_CAP).orElseThrow(IllegalStateException::new);
|
||||
IslandType type = null;
|
||||
if (stack.getItem() == Items.SNOWBALL) {
|
||||
type = IslandType.SNOW;
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class BergamuteEventHandler {
|
||||
float red = (color >> 16 & 0xFF) / 255F;
|
||||
float green = (color >> 8 & 0xFF) / 255F;
|
||||
float blue = (color & 0xFF) / 255F;
|
||||
BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
BotaniaAPI.instance().internalHandler().sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class SubTileExoflame extends TileEntityFunctionalFlower {
|
||||
getEffectivePos().add(RANGE, RANGE_Y, RANGE))) {
|
||||
TileEntity tile = getWorld().getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
LazyOptional<IExoflameHeatable> cap = tile.getCapability(BotaniaAPI.EXOFLAME_HEATABLE_CAP);
|
||||
LazyOptional<IExoflameHeatable> cap = tile.getCapability(BotaniaAPI.instance().EXOFLAME_HEATABLE_CAP);
|
||||
if (cap.isPresent()) {
|
||||
IExoflameHeatable heatable = cap.orElseThrow(NullPointerException::new);
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public class SubTileOrechid extends TileEntityFunctionalFlower {
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, Integer> getOreMap() {
|
||||
return BotaniaAPI.oreWeights;
|
||||
return BotaniaAPI.instance().getOreWeights();
|
||||
}
|
||||
|
||||
public Predicate<BlockState> getReplaceMatcher() {
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class SubTileOrechidIgnem extends SubTileOrechid {
|
||||
|
||||
@Override
|
||||
public Map<ResourceLocation, Integer> getOreMap() {
|
||||
return BotaniaAPI.oreWeightsNether;
|
||||
return BotaniaAPI.instance().getNetherOreWeights();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.items.wrapper.RecipeWrapper;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.IBrewContainer;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
@@ -32,6 +31,7 @@ import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.fx.SparkleParticleData;
|
||||
import vazkii.botania.client.fx.WispParticleData;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.core.handler.ModSounds;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -59,7 +59,7 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
|
||||
}
|
||||
|
||||
public boolean addItem(@Nullable PlayerEntity player, ItemStack stack, @Nullable Hand hand) {
|
||||
if (recipe != null || stack.isEmpty() || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != BotaniaAPI.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer) {
|
||||
if (recipe != null || stack.isEmpty() || stack.getItem() instanceof IBrewItem && ((IBrewItem) stack.getItem()).getBrew(stack) != null && ((IBrewItem) stack.getItem()).getBrew(stack) != ModBrews.fallbackBrew || itemHandler.getStackInSlot(0).isEmpty() != stack.getItem() instanceof IBrewContainer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TileFloatingFlower extends TileMod {
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
if (cap == BotaniaAPI.FLOATING_FLOWER_CAP) {
|
||||
if (cap == BotaniaAPI.instance().FLOATING_FLOWER_CAP) {
|
||||
return floatingDataCap.cast();
|
||||
}
|
||||
return super.getCapability(cap, side);
|
||||
@@ -76,12 +76,12 @@ public class TileFloatingFlower extends TileMod {
|
||||
|
||||
@Override
|
||||
public void writePacketNBT(CompoundNBT cmp) {
|
||||
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
|
||||
cmp.put(TAG_FLOATING_DATA, BotaniaAPI.instance().FLOATING_FLOWER_CAP.writeNBT(floatingData, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readPacketNBT(CompoundNBT cmp) {
|
||||
BotaniaAPI.FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
|
||||
BotaniaAPI.instance().FLOATING_FLOWER_CAP.readNBT(floatingData, null, cmp.getCompound(TAG_FLOATING_DATA));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -20,10 +20,10 @@ import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.client.fx.WispParticleData;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.brew.ItemIncenseStick;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
@@ -137,7 +137,7 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi
|
||||
}
|
||||
|
||||
public boolean acceptsItem(ItemStack stack) {
|
||||
return !stack.isEmpty() && stack.getItem() == ModItems.incenseStick && ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack) != BotaniaAPI.fallbackBrew;
|
||||
return !stack.isEmpty() && stack.getItem() == ModItems.incenseStick && ((ItemIncenseStick) ModItems.incenseStick).getBrew(stack) != ModBrews.fallbackBrew;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,8 @@ 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.IForgeRegistry;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
@@ -31,7 +33,8 @@ 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 IForgeRegistry<Brew> registry;
|
||||
public static Brew fallbackBrew;
|
||||
public static Brew speed;
|
||||
public static Brew strength;
|
||||
public static Brew haste;
|
||||
@@ -58,7 +61,7 @@ public class ModBrews {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRegistry(RegistryEvent.NewRegistry evt) {
|
||||
BotaniaAPI.brewRegistry = new RegistryBuilder<Brew>()
|
||||
registry = new RegistryBuilder<Brew>()
|
||||
.setName(prefix("brews"))
|
||||
.setType(Brew.class)
|
||||
.setDefaultKey(prefix("fallback"))
|
||||
@@ -68,7 +71,7 @@ public class ModBrews {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void register(RegistryEvent.Register<Brew> evt) {
|
||||
fallback = make("fallback", 0, 0);
|
||||
fallbackBrew = 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));
|
||||
@@ -90,7 +93,7 @@ public class ModBrews {
|
||||
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,
|
||||
evt.getRegistry().registerAll(fallbackBrew, speed, strength, haste, healing, jumpBoost, regen, regenWeak, resistance,
|
||||
fireResistance, waterBreathing, invisibility, nightVision, absorption, overload, soulCross, featherfeet,
|
||||
emptiness, bloodthirst, allure, clear);
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class ExoflameFurnaceHandler {
|
||||
TileEntity te = event.getObject();
|
||||
if (te instanceof AbstractFurnaceTileEntity) {
|
||||
AbstractFurnaceTileEntity furnace = (AbstractFurnaceTileEntity) te;
|
||||
SimpleCapProvider.attach(event, ID, BotaniaAPI.EXOFLAME_HEATABLE_CAP, new FurnaceExoflameHeatable(furnace));
|
||||
SimpleCapProvider.attach(event, ID, BotaniaAPI.instance().EXOFLAME_HEATABLE_CAP, new FurnaceExoflameHeatable(furnace));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,43 +10,37 @@ package vazkii.botania.common.core.handler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.DyeColor;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.imc.IMC;
|
||||
import vazkii.botania.api.imc.OreWeightMessage;
|
||||
import vazkii.botania.api.imc.PaintableBlockMessage;
|
||||
import vazkii.botania.common.impl.BotaniaAPIImpl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class IMCHandler {
|
||||
public static void handle(InterModProcessEvent evt) {
|
||||
BotaniaAPI.oreWeights = handleOreWeights(evt.getIMCStream(IMC.REGISTER_ORE_WEIGHT::equals));
|
||||
BotaniaAPI.oreWeightsNether = handleOreWeights(evt.getIMCStream(IMC.REGISTER_NETHER_ORE_WEIGHT::equals));
|
||||
BotaniaAPI.paintableBlocks = handlePaintable(evt.getIMCStream(IMC.REGISTER_PAINTABLE_BLOCK::equals));
|
||||
((BotaniaAPIImpl) BotaniaAPI.instance()).oreWeights = handleOreWeights(evt.getIMCStream(IMC.REGISTER_ORE_WEIGHT::equals));
|
||||
((BotaniaAPIImpl) BotaniaAPI.instance()).netherOreWeights = handleOreWeights(evt.getIMCStream(IMC.REGISTER_NETHER_ORE_WEIGHT::equals));
|
||||
}
|
||||
|
||||
private static Map<ResourceLocation, Integer> handleOreWeights(Stream<InterModComms.IMCMessage> msgs) {
|
||||
Map<ResourceLocation, Integer> map = msgs
|
||||
.filter(msg -> msg.getMessageSupplier().get() instanceof OreWeightMessage)
|
||||
.map(msg -> (OreWeightMessage) msg.getMessageSupplier().get())
|
||||
.collect(Collectors.toMap(OreWeightMessage::getOre, OreWeightMessage::getWeight));
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
|
||||
private static Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> handlePaintable(Stream<InterModComms.IMCMessage> msgs) {
|
||||
Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> map = msgs
|
||||
.filter(msg -> msg.getMessageSupplier().get() instanceof PaintableBlockMessage)
|
||||
.map(msg -> (PaintableBlockMessage) msg.getMessageSupplier().get())
|
||||
.collect(Collectors.toMap(PaintableBlockMessage::getBlock, PaintableBlockMessage::getTransformer));
|
||||
.filter(msg -> {
|
||||
Object thing = msg.getMessageSupplier().get();
|
||||
if (thing instanceof Pair) {
|
||||
return ((Pair) thing).getFirst() instanceof ResourceLocation
|
||||
&& ((Pair) thing).getSecond() instanceof Integer;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.map(msg -> (Pair<ResourceLocation, Integer>) msg.getMessageSupplier().get())
|
||||
.collect(Collectors.toMap(Pair::getFirst, Pair::getSecond));
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.core.handler;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -15,9 +16,8 @@ import net.minecraftforge.fml.InterModComms;
|
||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.imc.IMC;
|
||||
import vazkii.botania.api.imc.OreWeightMessage;
|
||||
import vazkii.botania.api.imc.PaintableBlockMessage;
|
||||
import vazkii.botania.common.core.helper.ColorHelper;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@@ -116,39 +116,39 @@ public class IMCSender {
|
||||
addOreWeightNether("oreHaditeCoal", 500); // Hadite haditeCoal, hadite/coal or coal/hadite?
|
||||
*/
|
||||
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_MAP.get(color).get(), Blocks.GLASS));
|
||||
BotaniaAPI.instance().registerPaintableBlock(Blocks.GLASS, color -> ColorHelper.STAINED_GLASS_MAP.get(color).get());
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.STAINED_GLASS_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.STAINED_GLASS_MAP.get(color).get());
|
||||
}
|
||||
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get(), Blocks.GLASS_PANE));
|
||||
BotaniaAPI.instance().registerPaintableBlock(Blocks.GLASS_PANE, color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get());
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.STAINED_GLASS_PANE_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.STAINED_GLASS_PANE_MAP.get(color).get());
|
||||
}
|
||||
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.TERRACOTTA_MAP.get(color).get(), Blocks.TERRACOTTA));
|
||||
BotaniaAPI.instance().registerPaintableBlock(Blocks.TERRACOTTA, color -> ColorHelper.TERRACOTTA_MAP.get(color).get());
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.TERRACOTTA_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.TERRACOTTA_MAP.get(color).get(), b.get()));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b.get(), color -> ColorHelper.TERRACOTTA_MAP.get(color).get());
|
||||
}
|
||||
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.GLAZED_TERRACOTTA_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.GLAZED_TERRACOTTA_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.GLAZED_TERRACOTTA_MAP.get(color).get());
|
||||
}
|
||||
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.WOOL_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.WOOL_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.WOOL_MAP.get(color).get());
|
||||
}
|
||||
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.CARPET_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CARPET_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.CARPET_MAP.get(color).get());
|
||||
}
|
||||
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.CONCRETE_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CONCRETE_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.CONCRETE_MAP.get(color).get());
|
||||
}
|
||||
|
||||
for (IRegistryDelegate<Block> b : ColorHelper.CONCRETE_POWDER_MAP.values()) {
|
||||
sendToSelf(IMC.REGISTER_PAINTABLE_BLOCK, new PaintableBlockMessage(color -> ColorHelper.CONCRETE_POWDER_MAP.get(color).get(), b));
|
||||
BotaniaAPI.instance().registerPaintableBlock(b, color -> ColorHelper.CONCRETE_POWDER_MAP.get(color).get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ public class IMCSender {
|
||||
}
|
||||
|
||||
private static void addOreWeight(String oreTag, int weight) {
|
||||
sendToSelf(IMC.REGISTER_ORE_WEIGHT, new OreWeightMessage(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
sendToSelf(IMC.REGISTER_ORE_WEIGHT, new Pair<>(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
}
|
||||
|
||||
private static void addOreWeightNether(String oreTag, int weight) {
|
||||
sendToSelf(IMC.REGISTER_NETHER_ORE_WEIGHT, new OreWeightMessage(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
sendToSelf(IMC.REGISTER_NETHER_ORE_WEIGHT, new Pair<>(new ResourceLocation("forge", "ores/" + oreTag), weight));
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class EntitySpark extends EntitySparkBase implements ISparkEntity {
|
||||
stacks.addAll(player.inventory.mainInventory);
|
||||
stacks.addAll(player.inventory.armorInventory);
|
||||
|
||||
IItemHandler inv = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
IItemHandler inv = BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player);
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
stacks.add(inv.getStackInSlot(i));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
package vazkii.botania.common.impl;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.ai.attributes.IAttribute;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.LazyValue;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IRegistryDelegate;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.internal.IInternalMethodHandler;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.core.handler.InternalMethodHandler;
|
||||
import vazkii.botania.common.core.handler.PixieHandler;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BotaniaAPIImpl implements BotaniaAPI {
|
||||
private static final LazyValue<Rarity> RELIC_RARITY = new LazyValue<>(() -> Rarity.create("RELIC", TextFormatting.GOLD));
|
||||
private enum ArmorMaterial implements IArmorMaterial {
|
||||
MANASTEEL("manasteel", 16, new int[]{ 2, 5, 6, 2 }, 18, () -> SoundEvents.ITEM_ARMOR_EQUIP_IRON, () -> ModItems.manaSteel, 0),
|
||||
MANAWEAVE("manaweave", 5, new int[] { 1, 2, 2, 1 }, 18, () -> SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, () -> ModItems.manaweaveCloth, 0),
|
||||
ELEMENTIUM("elementium", 18, new int[] { 2, 5, 6, 2 }, 18, () -> SoundEvents.ITEM_ARMOR_EQUIP_IRON, () -> ModItems.elementium, 0),
|
||||
TERRASTEEL("terrasteel", 34, new int[] { 3, 6, 8, 3 }, 26, () -> SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, () -> ModItems.terrasteel, 3);
|
||||
|
||||
private final String name;
|
||||
private final int durabilityMultiplier;
|
||||
private final int[] damageReduction;
|
||||
private final int enchantability;
|
||||
private final Supplier<SoundEvent> equipSound;
|
||||
private final Supplier<Item> repairItem;
|
||||
private final float toughness;
|
||||
private static final int[] MAX_DAMAGE_ARRAY = new int[] { 13, 15, 16, 11 };
|
||||
|
||||
ArmorMaterial(String name, int durabilityMultiplier, int[] damageReduction, int enchantability, Supplier<SoundEvent> equipSound, Supplier<Item> repairItem, float toughness) {
|
||||
this.name = name;
|
||||
this.durabilityMultiplier = durabilityMultiplier;
|
||||
this.damageReduction = damageReduction;
|
||||
this.enchantability = enchantability;
|
||||
this.equipSound = equipSound;
|
||||
this.repairItem = repairItem;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurability(EquipmentSlotType slot) {
|
||||
return durabilityMultiplier * MAX_DAMAGE_ARRAY[slot.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamageReductionAmount(EquipmentSlotType slot) {
|
||||
return damageReduction[slot.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return enchantability;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SoundEvent getSoundEvent() {
|
||||
return equipSound.get();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(repairItem.get());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToughness() {
|
||||
return toughness;
|
||||
}
|
||||
}
|
||||
|
||||
private enum ItemTier implements IItemTier {
|
||||
MANASTEEL(300, 6.2F, 2, 3, 20, () -> ModItems.manaSteel),
|
||||
ELEMENTIUM(720, 6.2F, 2, 3, 20, () -> ModItems.elementium),
|
||||
TERRASTEEL(2300, 9, 3, 4, 26, () -> ModItems.terrasteel)
|
||||
;
|
||||
|
||||
private final int maxUses;
|
||||
private final float efficiency;
|
||||
private final float attackDamage;
|
||||
private final int harvestLevel;
|
||||
private final int enchantability;
|
||||
private final Supplier<Item> repairItem;
|
||||
|
||||
ItemTier(int maxUses, float efficiency, float attackDamage, int harvestLevel, int enchantability, Supplier<Item> repairItem) {
|
||||
this.maxUses = maxUses;
|
||||
this.efficiency = efficiency;
|
||||
this.attackDamage = attackDamage;
|
||||
this.harvestLevel = harvestLevel;
|
||||
this.enchantability = enchantability;
|
||||
this.repairItem = repairItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxUses() {
|
||||
return maxUses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEfficiency() {
|
||||
return efficiency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackDamage() {
|
||||
return attackDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel() {
|
||||
return harvestLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnchantability() {
|
||||
return enchantability;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ingredient getRepairMaterial() {
|
||||
return Ingredient.fromItems(repairItem.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int apiVersion() {
|
||||
return 94;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IForgeRegistry<Brew> getBrewRegistry() {
|
||||
return ModBrews.registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArmorMaterial getManasteelArmorMaterial() {
|
||||
return ArmorMaterial.MANASTEEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArmorMaterial getElementiumArmorMaterial() {
|
||||
return ArmorMaterial.ELEMENTIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArmorMaterial getManaweaveArmorMaterial() {
|
||||
return ArmorMaterial.MANAWEAVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IArmorMaterial getTerrasteelArmorMaterial() {
|
||||
return ArmorMaterial.TERRASTEEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemTier getManasteelItemTier() {
|
||||
return ItemTier.MANASTEEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemTier getElementiumItemTier() {
|
||||
return ItemTier.ELEMENTIUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemTier getTerrasteelItemTier() {
|
||||
return ItemTier.TERRASTEEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rarity getRelicRarity() {
|
||||
return RELIC_RARITY.getValue();
|
||||
}
|
||||
|
||||
private final InternalMethodHandler tmp = new InternalMethodHandler();
|
||||
@Override
|
||||
public IInternalMethodHandler internalHandler() {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAttribute getPixieSpawnChanceAttribute() {
|
||||
return PixieHandler.PIXIE_SPAWN_CHANCE;
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, Integer> oreWeights = Collections.emptyMap();
|
||||
public Map<ResourceLocation, Integer> netherOreWeights = Collections.emptyMap();
|
||||
private Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> paintableBlocks = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return Collections.unmodifiableMap(oreWeights);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ResourceLocation, Integer> getNetherOreWeights() {
|
||||
return Collections.unmodifiableMap(netherOreWeights);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> getPaintableBlocks() {
|
||||
return Collections.unmodifiableMap(paintableBlocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPaintableBlock(IRegistryDelegate<Block> block, Function<DyeColor, Block> transformer) {
|
||||
paintableBlocks.put(block, transformer);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class CorporeaHelperImpl implements CorporeaHelper {
|
||||
@Override
|
||||
public Map<InvWithLocation, Integer> getInventoriesWithMatchInNetwork(ICorporeaRequestMatcher matcher, List<InvWithLocation> inventories) {
|
||||
Map<InvWithLocation, Integer> countMap = new HashMap<>();
|
||||
List<IWrappedInventory> wrappedInventories = BotaniaAPI.internalHandler.wrapInventory(inventories);
|
||||
List<IWrappedInventory> wrappedInventories = BotaniaAPI.instance().internalHandler().wrapInventory(inventories);
|
||||
for (IWrappedInventory inv : wrappedInventories) {
|
||||
ICorporeaRequest request = new CorporeaRequest(matcher, -1);
|
||||
inv.countItems(request);
|
||||
@@ -127,7 +127,7 @@ public class CorporeaHelperImpl implements CorporeaHelper {
|
||||
|
||||
List<InvWithLocation> inventories = getInventoriesOnNetwork(spark);
|
||||
|
||||
List<IWrappedInventory> inventoriesW = BotaniaAPI.internalHandler.wrapInventory(inventories);
|
||||
List<IWrappedInventory> inventoriesW = BotaniaAPI.instance().internalHandler().wrapInventory(inventories);
|
||||
Map<ICorporeaInterceptor, ICorporeaSpark> interceptors = new HashMap<>();
|
||||
|
||||
ICorporeaRequest request = new CorporeaRequest(matcher, itemCount);
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.impl;
|
||||
package vazkii.botania.common.impl.mana;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ManaItemHandlerImpl implements ManaItemHandler {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
IItemHandler acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
|
||||
IItemHandler acc = BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player);
|
||||
if (acc == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class TCAspects {
|
||||
new ItemStack(ModItems.vial, 1, 1), new ItemStack(ModItems.incenseStick), new ItemStack(ModItems.bloodPendant));
|
||||
|
||||
private void registerBrewAspects() {
|
||||
for(RecipeBrew brewRecipe : BotaniaAPI.brewRecipes) {
|
||||
for(RecipeBrew brewRecipe : BotaniaAPI.instance().brewRecipes) {
|
||||
AspectList aspects = new AspectList();
|
||||
|
||||
for(Object input : brewRecipe.getInputs()) {
|
||||
@@ -470,8 +470,8 @@ public class TCAspects {
|
||||
proxy.registerObjectTag(ItemBlockSpecialFlower.ofType(flowerId), aspects);
|
||||
proxy.registerObjectTag(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), flowerId), floatingAspects);
|
||||
|
||||
if (BotaniaAPI.miniFlowers.containsKey(flowerId)) {
|
||||
ResourceLocation miniFlowerId = BotaniaAPI.miniFlowers.get(flowerId);
|
||||
if (BotaniaAPI.instance().miniFlowers.containsKey(flowerId)) {
|
||||
ResourceLocation miniFlowerId = BotaniaAPI.instance().miniFlowers.get(flowerId);
|
||||
proxy.registerObjectTag(ItemBlockSpecialFlower.ofType(miniFlowerId), petiteAspects(aspects));
|
||||
proxy.registerObjectTag(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), miniFlowerId), petiteAspects(floatingAspects));
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class ItemBlockSpecialFlower extends BlockItem {
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
CompoundNBT tag = stack.getChildTag("BlockEntityTag");
|
||||
if (tag != null) {
|
||||
return tag.getInt(TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS) / (double) BotaniaAPI.internalHandler.getPassiveFlowerDecay();
|
||||
return tag.getInt(TileEntityGeneratingFlower.TAG_PASSIVE_DECAY_TICKS) / (double) BotaniaAPI.instance().internalHandler().getPassiveFlowerDecay();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.brew.Brew;
|
||||
import vazkii.botania.api.brew.IBrewItem;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@@ -122,7 +123,7 @@ public class ItemBrewBase extends Item implements IBrewItem {
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup tab, NonNullList<ItemStack> list) {
|
||||
if (isInGroup(tab)) {
|
||||
for (ResourceLocation id : BotaniaAPI.brewRegistry.getKeys()) {
|
||||
for (ResourceLocation id : BotaniaAPI.instance().getBrewRegistry().getKeys()) {
|
||||
ItemStack stack = new ItemStack(this);
|
||||
setBrew(stack, id);
|
||||
list.add(stack);
|
||||
@@ -201,11 +202,11 @@ public class ItemBrewBase extends Item implements IBrewItem {
|
||||
@Override
|
||||
public Brew getBrew(ItemStack stack) {
|
||||
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
|
||||
return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key));
|
||||
return BotaniaAPI.instance().getBrewRegistry().getValue(ResourceLocation.tryCreate(key));
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, Brew brew) {
|
||||
setBrew(stack, (brew == null ? BotaniaAPI.fallbackBrew : brew).getRegistryName());
|
||||
setBrew(stack, (brew == null ? ModBrews.fallbackBrew : brew).getRegistryName());
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, ResourceLocation brew) {
|
||||
|
||||
@@ -25,6 +25,7 @@ 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.common.brew.ModBrews;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -44,7 +45,7 @@ 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 (Brew brew : BotaniaAPI.brewRegistry) {
|
||||
for (Brew brew : BotaniaAPI.instance().getBrewRegistry()) {
|
||||
ItemStack brewStack = getItemForBrew(brew, new ItemStack(this));
|
||||
if (!brewStack.isEmpty()) {
|
||||
list.add(brewStack);
|
||||
@@ -57,7 +58,7 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
|
||||
Brew brew = getBrew(stack);
|
||||
if (brew == BotaniaAPI.fallbackBrew) {
|
||||
if (brew == ModBrews.fallbackBrew) {
|
||||
list.add(new TranslationTextComponent("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE));
|
||||
return;
|
||||
}
|
||||
@@ -69,7 +70,7 @@ public class ItemIncenseStick extends Item implements IBrewItem, IBrewContainer
|
||||
@Override
|
||||
public Brew getBrew(ItemStack stack) {
|
||||
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
|
||||
return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key));
|
||||
return BotaniaAPI.instance().getBrewRegistry().getValue(ResourceLocation.tryCreate(key));
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, Brew brew) {
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import java.util.List;
|
||||
public abstract class ItemElementiumArmor extends ItemManasteelArmor {
|
||||
|
||||
public ItemElementiumArmor(EquipmentSlotType type, Properties props) {
|
||||
super(type, BotaniaAPI.ELEMENTIUM_ARMOR_MAT, props);
|
||||
super(type, BotaniaAPI.instance().getElementiumArmorMaterial(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
|
||||
public final EquipmentSlotType type;
|
||||
|
||||
public ItemManasteelArmor(EquipmentSlotType type, Properties props) {
|
||||
this(type, BotaniaAPI.MANASTEEL_ARMOR_MAT, props);
|
||||
this(type, BotaniaAPI.instance().getManasteelArmorMaterial(), props);
|
||||
}
|
||||
|
||||
public ItemManasteelArmor(EquipmentSlotType type, IArmorMaterial mat, Properties props) {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
public class ItemManaweaveArmor extends ItemManasteelArmor {
|
||||
|
||||
public ItemManaweaveArmor(EquipmentSlotType type, Properties props) {
|
||||
super(type, BotaniaAPI.MANAWEAVE_ARMOR_MAT, props);
|
||||
super(type, BotaniaAPI.instance().getManaweaveArmorMaterial(), props);
|
||||
addPropertyOverride(new ResourceLocation("botania", "holiday"), (stack, worldIn, entityIn) -> ClientProxy.jingleTheBells ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import java.util.UUID;
|
||||
public class ItemTerrasteelArmor extends ItemManasteelArmor {
|
||||
|
||||
public ItemTerrasteelArmor(EquipmentSlotType type, Properties props) {
|
||||
super(type, BotaniaAPI.TERRASTEEL_ARMOR_MAT, props);
|
||||
super(type, BotaniaAPI.instance().getTerrasteelArmorMaterial(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,6 +42,7 @@ import vazkii.botania.api.mana.IManaUsingItem;
|
||||
import vazkii.botania.api.mana.ManaItemHandler;
|
||||
import vazkii.botania.client.core.handler.BaubleRenderHandler;
|
||||
import vazkii.botania.client.core.handler.MiscellaneousIcons;
|
||||
import vazkii.botania.common.brew.ModBrews;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
|
||||
import java.util.List;
|
||||
@@ -58,7 +59,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
public void fillItemGroup(ItemGroup tab, NonNullList<ItemStack> list) {
|
||||
super.fillItemGroup(tab, list);
|
||||
if (isInGroup(tab)) {
|
||||
for (Brew brew : BotaniaAPI.brewRegistry) {
|
||||
for (Brew brew : BotaniaAPI.instance().getBrewRegistry()) {
|
||||
ItemStack brewStack = getItemForBrew(brew, new ItemStack(this));
|
||||
if (!brewStack.isEmpty()) {
|
||||
list.add(brewStack);
|
||||
@@ -73,7 +74,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
super.addHiddenTooltip(stack, world, list, adv);
|
||||
|
||||
Brew brew = getBrew(stack);
|
||||
if (brew == BotaniaAPI.fallbackBrew) {
|
||||
if (brew == ModBrews.fallbackBrew) {
|
||||
list.add(new TranslationTextComponent("botaniamisc.notInfused").applyTextStyle(TextFormatting.LIGHT_PURPLE));
|
||||
return;
|
||||
}
|
||||
@@ -93,7 +94,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
@Override
|
||||
public void onWornTick(ItemStack stack, LivingEntity player) {
|
||||
Brew brew = ((IBrewItem) stack.getItem()).getBrew(stack);
|
||||
if (brew != BotaniaAPI.fallbackBrew && player instanceof PlayerEntity && !player.world.isRemote) {
|
||||
if (brew != ModBrews.fallbackBrew && player instanceof PlayerEntity && !player.world.isRemote) {
|
||||
PlayerEntity eplayer = (PlayerEntity) player;
|
||||
EffectInstance effect = brew.getPotionEffects(stack).get(0);
|
||||
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
|
||||
@@ -138,7 +139,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
@Override
|
||||
public Brew getBrew(ItemStack stack) {
|
||||
String key = ItemNBTHelper.getString(stack, TAG_BREW_KEY, "");
|
||||
return BotaniaAPI.brewRegistry.getValue(ResourceLocation.tryCreate(key));
|
||||
return BotaniaAPI.instance().getBrewRegistry().getValue(ResourceLocation.tryCreate(key));
|
||||
}
|
||||
|
||||
public static void setBrew(ItemStack stack, Brew brew) {
|
||||
@@ -167,7 +168,7 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
|
||||
|
||||
@Override
|
||||
public boolean usesMana(ItemStack stack) {
|
||||
return getBrew(stack) != BotaniaAPI.fallbackBrew;
|
||||
return getBrew(stack) != ModBrews.fallbackBrew;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import java.util.function.Consumer;
|
||||
public class ItemEnderDagger extends ItemManasteelSword {
|
||||
|
||||
public ItemEnderDagger(Properties props) {
|
||||
super(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getManasteelItemTier(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ItemStarSword extends ItemManasteelSword {
|
||||
private static final int MANA_PER_DAMAGE = 120;
|
||||
|
||||
public ItemStarSword(Properties props) {
|
||||
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getTerrasteelItemTier(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ItemThunderSword extends ItemManasteelSword {
|
||||
private static final String TAG_LIGHTNING_SEED = "lightningSeed";
|
||||
|
||||
public ItemThunderSword(Properties props) {
|
||||
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getTerrasteelItemTier(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -149,13 +149,13 @@ public final class ToolCommons {
|
||||
ToolItem tool = (ToolItem) item;
|
||||
IItemTier material = tool.getTier();
|
||||
int materialLevel = 0;
|
||||
if (material == BotaniaAPI.MANASTEEL_ITEM_TIER) {
|
||||
if (material == BotaniaAPI.instance().getManasteelItemTier()) {
|
||||
materialLevel = 10;
|
||||
}
|
||||
if (material == BotaniaAPI.ELEMENTIUM_ITEM_TIER) {
|
||||
if (material == BotaniaAPI.instance().getElementiumItemTier()) {
|
||||
materialLevel = 11;
|
||||
}
|
||||
if (material == BotaniaAPI.TERRASTEEL_ITEM_TIER) {
|
||||
if (material == BotaniaAPI.instance().getTerrasteelItemTier()) {
|
||||
materialLevel = 20;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import java.util.Random;
|
||||
public class ItemElementiumAxe extends ItemManasteelAxe {
|
||||
|
||||
public ItemElementiumAxe(Properties props) {
|
||||
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getElementiumItemTier(), props);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onEntityDrops);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
public class ItemElementiumPick extends ItemManasteelPick {
|
||||
|
||||
public ItemElementiumPick(Properties props) {
|
||||
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props, -2.8F);
|
||||
super(BotaniaAPI.instance().getElementiumItemTier(), props, -2.8F);
|
||||
}
|
||||
|
||||
public static void filterDisposable(List<ItemStack> drops, Entity e, ItemStack stack) {
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelShovel;
|
||||
public class ItemElementiumShovel extends ItemManasteelShovel {
|
||||
|
||||
public ItemElementiumShovel(Properties props) {
|
||||
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getElementiumItemTier(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import javax.annotation.Nonnull;
|
||||
public class ItemElementiumSword extends ItemManasteelSword {
|
||||
|
||||
public ItemElementiumSword(Properties props) {
|
||||
super(BotaniaAPI.ELEMENTIUM_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getElementiumItemTier(), props);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class ItemManasteelAxe extends AxeItem implements IManaUsingItem, ISortab
|
||||
private static final int MANA_PER_DAMAGE = 60;
|
||||
|
||||
public ItemManasteelAxe(Properties props) {
|
||||
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
|
||||
this(BotaniaAPI.instance().getManasteelItemTier(), props);
|
||||
}
|
||||
|
||||
public ItemManasteelAxe(IItemTier mat, Properties props) {
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class ItemManasteelPick extends PickaxeItem implements IManaUsingItem, IS
|
||||
private static final int MANA_PER_DAMAGE = 60;
|
||||
|
||||
public ItemManasteelPick(Properties props) {
|
||||
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props, -2.8F);
|
||||
this(BotaniaAPI.instance().getManasteelItemTier(), props, -2.8F);
|
||||
}
|
||||
|
||||
public ItemManasteelPick(IItemTier mat, Properties props, float attackSpeed) {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
|
||||
private static final int MANA_PER_DAMAGE = 60;
|
||||
|
||||
public ItemManasteelShovel(Properties props) {
|
||||
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
|
||||
this(BotaniaAPI.instance().getManasteelItemTier(), props);
|
||||
}
|
||||
|
||||
public ItemManasteelShovel(IItemTier mat, Properties props) {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ItemManasteelSword extends SwordItem implements IManaUsingItem {
|
||||
public static final int MANA_PER_DAMAGE = 60;
|
||||
|
||||
public ItemManasteelSword(Properties props) {
|
||||
this(BotaniaAPI.MANASTEEL_ITEM_TIER, props);
|
||||
this(BotaniaAPI.instance().getManasteelItemTier(), props);
|
||||
}
|
||||
|
||||
public ItemManasteelSword(IItemTier mat, Properties props) {
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public class ItemTerraAxe extends ItemManasteelAxe implements ISequentialBreaker
|
||||
private static final Map<DimensionType, Set<BlockSwapper>> blockSwappers = new HashMap<>();
|
||||
|
||||
public ItemTerraAxe(Properties props) {
|
||||
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getTerrasteelItemTier(), props);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::onTickEnd);
|
||||
addPropertyOverride(new ResourceLocation(LibMisc.MOD_ID, "terraaxe_on"), (stack, world, entity) -> {
|
||||
if (entity instanceof PlayerEntity && !shouldBreak((PlayerEntity) entity)) {
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public class ItemTerraPick extends ItemManasteelPick implements IManaItem, ISequ
|
||||
};
|
||||
|
||||
public ItemTerraPick(Properties props) {
|
||||
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props, -2.8F);
|
||||
super(BotaniaAPI.instance().getTerrasteelItemTier(), props, -2.8F);
|
||||
addPropertyOverride(new ResourceLocation("botania", TAG_TIPPED), (itemStack, world, entityLivingBase) -> isTipped(itemStack) ? 1 : 0);
|
||||
addPropertyOverride(new ResourceLocation("botania", TAG_ENABLED), (itemStack, world, entityLivingBase) -> isEnabled(itemStack) ? 1 : 0);
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
private static final int MANA_PER_DAMAGE = 100;
|
||||
|
||||
public ItemTerraSword(Properties props) {
|
||||
super(BotaniaAPI.TERRASTEEL_ITEM_TIER, props);
|
||||
super(BotaniaAPI.instance().getTerrasteelItemTier(), props);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::leftClick);
|
||||
MinecraftForge.EVENT_BUS.addListener(this::attackEntity);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class ItemTerraSword extends ItemManasteelSword implements ILensEffect {
|
||||
int mana = burst.getMana();
|
||||
if (mana >= cost) {
|
||||
burst.setMana(mana - cost);
|
||||
float damage = 4F + BotaniaAPI.TERRASTEEL_ITEM_TIER.getAttackDamage();
|
||||
float damage = 4F + BotaniaAPI.instance().getTerrasteelItemTier().getAttackDamage();
|
||||
if (!burst.isFake() && !entity.world.isRemote) {
|
||||
DamageSource source = DamageSource.MAGIC;
|
||||
if (thrower instanceof PlayerEntity) {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class LensPaint extends Lens {
|
||||
BlockPos hit = ((BlockRayTraceResult) pos).getPos();
|
||||
BlockState state = entity.world.getBlockState(hit);
|
||||
Block block = state.getBlock();
|
||||
if (BotaniaAPI.paintableBlocks.containsKey(block.delegate)) {
|
||||
if (BotaniaAPI.instance().getPaintableBlocks().containsKey(block.delegate)) {
|
||||
List<BlockPos> coordsToPaint = new ArrayList<>();
|
||||
List<BlockPos> coordsFound = new ArrayList<>();
|
||||
coordsFound.add(hit);
|
||||
@@ -79,7 +79,7 @@ public class LensPaint extends Lens {
|
||||
DyeColor placeColor = DyeColor.byId(storedColor == 16 ? entity.world.rand.nextInt(16) : storedColor);
|
||||
BlockState stateThere = entity.world.getBlockState(coords);
|
||||
|
||||
Function<DyeColor, Block> f = BotaniaAPI.paintableBlocks.get(block.delegate);
|
||||
Function<DyeColor, Block> f = BotaniaAPI.instance().getPaintableBlocks().get(block.delegate);
|
||||
Block newBlock = f.apply(placeColor);
|
||||
if (newBlock != stateThere.getBlock()) {
|
||||
entity.world.setBlockState(coords, newBlock.getDefaultState());
|
||||
|
||||
@@ -147,7 +147,7 @@ public class ItemRelic extends Item implements IRelic {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Rarity getRarity(ItemStack stack) {
|
||||
return BotaniaAPI.rarityRelic;
|
||||
return BotaniaAPI.instance().getRelicRarity();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
|
||||
@Nonnull
|
||||
@Override
|
||||
public Rarity getRarity(ItemStack stack) {
|
||||
return BotaniaAPI.rarityRelic;
|
||||
return BotaniaAPI.instance().getRelicRarity();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -268,7 +268,7 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC
|
||||
return new ItemStack(block);
|
||||
}
|
||||
|
||||
ItemStack outStack = removeFromInventory(player, BotaniaAPI.internalHandler.getAccessoriesInventory(player), stack, block, doit);
|
||||
ItemStack outStack = removeFromInventory(player, BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player), stack, block, doit);
|
||||
if (outStack.isEmpty()) {
|
||||
outStack = removeFromInventory(player, player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY), stack, block, doit);
|
||||
}
|
||||
@@ -280,7 +280,7 @@ public class ItemExchangeRod extends Item implements IManaUsingItem, IWireframeC
|
||||
return -1;
|
||||
}
|
||||
|
||||
int baubleCount = getInventoryItemCount(player, BotaniaAPI.internalHandler.getAccessoriesInventory(player), stack, block);
|
||||
int baubleCount = getInventoryItemCount(player, BotaniaAPI.instance().internalHandler().getAccessoriesInventory(player), stack, block);
|
||||
if (baubleCount == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user