Run Spotless, cleanup unused imports, add braces to one line for/if/etc.

This commit is contained in:
Hubry committed 2020-03-07 22:39:15 +01:00
1 parent 21d9d95611
commit 2152473edb
757 files changed
+14429 -12341

No files matched your search

@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)]
*/
package vazkii.botania.api;
@@ -27,6 +25,7 @@ import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.IRegistryDelegate;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.internal.DummyMethodHandler;
import vazkii.botania.api.internal.IInternalMethodHandler;
@@ -41,6 +40,7 @@ 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;
@@ -51,17 +51,15 @@ public final class BotaniaAPI {
return 94;
}
@CapabilityInject(IFloatingFlower.class)
public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP;
@CapabilityInject(IFloatingFlower.class) public static Capability<IFloatingFlower> FLOATING_FLOWER_CAP;
@CapabilityInject(IExoflameHeatable.class)
public static Capability<IExoflameHeatable> EXOFLAME_HEATABLE_CAP;
@CapabilityInject(IExoflameHeatable.class) public static Capability<IExoflameHeatable> EXOFLAME_HEATABLE_CAP;
public static final Map<String, Brew> brewMap = new LinkedHashMap<>();
/*
* These maps are not meant to be mutated!
*/
* These maps are not meant to be mutated!
*/
public static Map<ResourceLocation, RecipePetals> petalRecipes = Collections.emptyMap();
public static Map<ResourceLocation, RecipePureDaisy> pureDaisyRecipes = Collections.emptyMap();
public static Map<ResourceLocation, RecipeManaInfusion> manaInfusionRecipes = Collections.emptyMap();
@@ -74,9 +72,10 @@ public final class BotaniaAPI {
public static Map<IRegistryDelegate<Block>, Function<DyeColor, Block>> paintableBlocks = Collections.emptyMap();
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
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 };
@Override
public int getDurability(EquipmentSlotType slotIn) {
return 16 * MAX_DAMAGE_ARRAY[slotIn.getIndex()];
@@ -149,6 +148,7 @@ public final class BotaniaAPI {
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()];
@@ -221,6 +221,7 @@ public final class BotaniaAPI {
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()];
@@ -292,6 +293,7 @@ public final class BotaniaAPI {
};
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()];
@@ -337,6 +339,7 @@ public final class BotaniaAPI {
* 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();
@@ -354,8 +357,9 @@ public final class BotaniaAPI {
* it's not in the map.
*/
public static Brew getBrewFromKey(String key) {
if(brewMap.containsKey(key))
if (brewMap.containsKey(key)) {
return brewMap.get(key);
}
return fallbackBrew;
}
@@ -1,18 +1,20 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p>
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.api;
import com.google.common.collect.Maps;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IFloatingFlower;
import java.util.Collections;
@@ -26,8 +28,7 @@ public final class BotaniaAPIClient {
private static final Map<IFloatingFlower.IslandType, ResourceLocation> islandTypeModels = Maps.newHashMap();
private BotaniaAPIClient() {
}
private BotaniaAPIClient() {}
/**
* Registers your model for island type islandType here.
+156 -147
View File
@@ -1,159 +1,168 @@
/*
* 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;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.DyeColor;
import net.minecraftforge.registries.IRegistryDelegate;
public final class ColorHelper {
public static final BiMap<DyeColor, IRegistryDelegate<Block>> STAINED_GLASS_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> STAINED_GLASS_PANE_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> TERRACOTTA_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> GLAZED_TERRACOTTA_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> WOOL_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CARPET_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CONCRETE_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CONCRETE_POWDER_MAP = HashBiMap.create();
public static void init() {
STAINED_GLASS_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS_PANE.delegate);
TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_GLAZED_TERRACOTTA.delegate);
WOOL_MAP.put(DyeColor.WHITE, Blocks.WHITE_WOOL.delegate);
WOOL_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_WOOL.delegate);
WOOL_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_WOOL.delegate);
WOOL_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIME, Blocks.LIME_WOOL.delegate);
WOOL_MAP.put(DyeColor.PINK, Blocks.PINK_WOOL.delegate);
WOOL_MAP.put(DyeColor.GRAY, Blocks.GRAY_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_WOOL.delegate);
WOOL_MAP.put(DyeColor.CYAN, Blocks.CYAN_WOOL.delegate);
WOOL_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_WOOL.delegate);
WOOL_MAP.put(DyeColor.BLUE, Blocks.BLUE_WOOL.delegate);
WOOL_MAP.put(DyeColor.BROWN, Blocks.BROWN_WOOL.delegate);
WOOL_MAP.put(DyeColor.GREEN, Blocks.GREEN_WOOL.delegate);
WOOL_MAP.put(DyeColor.RED, Blocks.RED_WOOL.delegate);
WOOL_MAP.put(DyeColor.BLACK, Blocks.BLACK_WOOL.delegate);
CARPET_MAP.put(DyeColor.WHITE, Blocks.WHITE_CARPET.delegate);
CARPET_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CARPET.delegate);
CARPET_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CARPET.delegate);
CARPET_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIME, Blocks.LIME_CARPET.delegate);
CARPET_MAP.put(DyeColor.PINK, Blocks.PINK_CARPET.delegate);
CARPET_MAP.put(DyeColor.GRAY, Blocks.GRAY_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CARPET.delegate);
CARPET_MAP.put(DyeColor.CYAN, Blocks.CYAN_CARPET.delegate);
CARPET_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CARPET.delegate);
CARPET_MAP.put(DyeColor.BLUE, Blocks.BLUE_CARPET.delegate);
CARPET_MAP.put(DyeColor.BROWN, Blocks.BROWN_CARPET.delegate);
CARPET_MAP.put(DyeColor.GREEN, Blocks.GREEN_CARPET.delegate);
CARPET_MAP.put(DyeColor.RED, Blocks.RED_CARPET.delegate);
CARPET_MAP.put(DyeColor.BLACK, Blocks.BLACK_CARPET.delegate);
CONCRETE_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE_POWDER.delegate);
}
public static final BiMap<DyeColor, IRegistryDelegate<Block>> STAINED_GLASS_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> STAINED_GLASS_PANE_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> TERRACOTTA_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> GLAZED_TERRACOTTA_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> WOOL_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CARPET_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CONCRETE_MAP = HashBiMap.create();
public static final BiMap<DyeColor, IRegistryDelegate<Block>> CONCRETE_POWDER_MAP = HashBiMap.create();
private ColorHelper() {}
public static void init() {
STAINED_GLASS_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS.delegate);
STAINED_GLASS_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.WHITE, Blocks.WHITE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIME, Blocks.LIME_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.PINK, Blocks.PINK_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.GRAY, Blocks.GRAY_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.CYAN, Blocks.CYAN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BLUE, Blocks.BLUE_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BROWN, Blocks.BROWN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.GREEN, Blocks.GREEN_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.RED, Blocks.RED_STAINED_GLASS_PANE.delegate);
STAINED_GLASS_PANE_MAP.put(DyeColor.BLACK, Blocks.BLACK_STAINED_GLASS_PANE.delegate);
TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_TERRACOTTA.delegate);
TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.WHITE, Blocks.WHITE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIME, Blocks.LIME_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.PINK, Blocks.PINK_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.GRAY, Blocks.GRAY_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.CYAN, Blocks.CYAN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BLUE, Blocks.BLUE_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BROWN, Blocks.BROWN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.GREEN, Blocks.GREEN_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.RED, Blocks.RED_GLAZED_TERRACOTTA.delegate);
GLAZED_TERRACOTTA_MAP.put(DyeColor.BLACK, Blocks.BLACK_GLAZED_TERRACOTTA.delegate);
WOOL_MAP.put(DyeColor.WHITE, Blocks.WHITE_WOOL.delegate);
WOOL_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_WOOL.delegate);
WOOL_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_WOOL.delegate);
WOOL_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIME, Blocks.LIME_WOOL.delegate);
WOOL_MAP.put(DyeColor.PINK, Blocks.PINK_WOOL.delegate);
WOOL_MAP.put(DyeColor.GRAY, Blocks.GRAY_WOOL.delegate);
WOOL_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_WOOL.delegate);
WOOL_MAP.put(DyeColor.CYAN, Blocks.CYAN_WOOL.delegate);
WOOL_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_WOOL.delegate);
WOOL_MAP.put(DyeColor.BLUE, Blocks.BLUE_WOOL.delegate);
WOOL_MAP.put(DyeColor.BROWN, Blocks.BROWN_WOOL.delegate);
WOOL_MAP.put(DyeColor.GREEN, Blocks.GREEN_WOOL.delegate);
WOOL_MAP.put(DyeColor.RED, Blocks.RED_WOOL.delegate);
WOOL_MAP.put(DyeColor.BLACK, Blocks.BLACK_WOOL.delegate);
CARPET_MAP.put(DyeColor.WHITE, Blocks.WHITE_CARPET.delegate);
CARPET_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CARPET.delegate);
CARPET_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CARPET.delegate);
CARPET_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIME, Blocks.LIME_CARPET.delegate);
CARPET_MAP.put(DyeColor.PINK, Blocks.PINK_CARPET.delegate);
CARPET_MAP.put(DyeColor.GRAY, Blocks.GRAY_CARPET.delegate);
CARPET_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CARPET.delegate);
CARPET_MAP.put(DyeColor.CYAN, Blocks.CYAN_CARPET.delegate);
CARPET_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CARPET.delegate);
CARPET_MAP.put(DyeColor.BLUE, Blocks.BLUE_CARPET.delegate);
CARPET_MAP.put(DyeColor.BROWN, Blocks.BROWN_CARPET.delegate);
CARPET_MAP.put(DyeColor.GREEN, Blocks.GREEN_CARPET.delegate);
CARPET_MAP.put(DyeColor.RED, Blocks.RED_CARPET.delegate);
CARPET_MAP.put(DyeColor.BLACK, Blocks.BLACK_CARPET.delegate);
CONCRETE_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE.delegate);
CONCRETE_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.WHITE, Blocks.WHITE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.ORANGE, Blocks.ORANGE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.MAGENTA, Blocks.MAGENTA_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_BLUE, Blocks.LIGHT_BLUE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.YELLOW, Blocks.YELLOW_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIME, Blocks.LIME_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.PINK, Blocks.PINK_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.GRAY, Blocks.GRAY_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.LIGHT_GRAY, Blocks.LIGHT_GRAY_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.CYAN, Blocks.CYAN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.PURPLE, Blocks.PURPLE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BLUE, Blocks.BLUE_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BROWN, Blocks.BROWN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.GREEN, Blocks.GREEN_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.RED, Blocks.RED_CONCRETE_POWDER.delegate);
CONCRETE_POWDER_MAP.put(DyeColor.BLACK, Blocks.BLACK_CONCRETE_POWDER.delegate);
}
private ColorHelper() {}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 29, 2014, 6:09:48 PM (GMT)]
*/
package vazkii.botania.api.boss;
@@ -14,6 +12,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.world.server.ServerBossInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.internal.ShaderCallback;
import java.awt.*;
@@ -49,6 +48,7 @@ public interface IBotaniaBoss {
/**
* A callback for when this boss's boss bar renders, you can do additional rendering
* here if needed.
*
* @return How tall your auxiliary renders were
*/
@OnlyIn(Dist.CLIENT)
@@ -58,6 +58,7 @@ public interface IBotaniaBoss {
* Get the serverside UUID of the {@link ServerBossInfo} instance tracking this boss
* Note that this is NOT the entity's UUID, nor is it the clientside UUID of the BossInfoServer instance!
* You will most likely need to sync this yourself using IEntityAdditionalSpawnData or similar.
*
* @return The uuid.
*/
public UUID getBossInfoUuid();
@@ -66,15 +67,18 @@ public interface IBotaniaBoss {
* The Shader Program to use for this boss's bar. Return 0 case
* you don't want a shader to be used. You can use separate shaders
* for the background and foreground.
* @param background True if rendering the background of the boss bar,
* false if rendering the bar itself that shows the HP.
* @return OpenGL program ID of the shader to use
*
* @param background True if rendering the background of the boss bar,
* false if rendering the bar itself that shows the HP.
* @return OpenGL program ID of the shader to use
*/
public int getBossBarShaderProgram(boolean background);
/**
* A callback for the shader, used to pass in uniforms. Return null for no callback.
* @return a ShaderCallback to use. If getBossBarShaderProgram returns an invalid shader the result of this method is ignored.
*
* @return a ShaderCallback to use. If getBossBarShaderProgram returns an invalid shader the result of this method
* is ignored.
*/
public ShaderCallback getBossBarShaderCallback(boolean background, int shader);
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 1, 2014, 6:22:54 PM (GMT)]
*/
package vazkii.botania.api.brew;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
@@ -30,10 +29,10 @@ 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.
* @param cost The cost, in Mana for this brew.
* @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.
* @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) {
@@ -91,7 +90,7 @@ public class Brew {
}
/**
* Gets the display color for the ItemStack passed in. Note that for
* Gets the display color for the ItemStack passed in. Note that for
* the lexicon, this passes in a botania Managlass Vial or an
* Alfglass Flask at all times.
*/
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 1, 2014, 6:26:40 PM (GMT)]
*/
package vazkii.botania.api.brew;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 1, 2014, 9:20:33 PM (GMT)]
*/
package vazkii.botania.api.brew;
@@ -1,23 +1,32 @@
/*
* 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.capability;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.item.IFloatingFlower;
public class FloatingFlowerImpl implements IFloatingFlower {
private IslandType type = IslandType.GRASS;
private IslandType type = IslandType.GRASS;
@Override
public ItemStack getDisplayStack() {
return ItemStack.EMPTY;
}
@Override
public ItemStack getDisplayStack() {
return ItemStack.EMPTY;
}
@Override
public IslandType getIslandType() {
return type;
}
@Override
public IslandType getIslandType() {
return type;
}
@Override
public void setIslandType(IslandType type) {
this.type = type;
}
@Override
public void setIslandType(IslandType type) {
this.type = type;
}
}
@@ -1,17 +1,16 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 14, 2015, 3:28:54 PM (GMT)]
*/
package vazkii.botania.api.corporea;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@@ -20,6 +19,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.BotaniaAPI;
import java.util.ArrayList;
@@ -50,24 +50,29 @@ public final class CorporeaHelper {
*/
public static List<InvWithLocation> getInventoriesOnNetwork(ICorporeaSpark spark) {
ICorporeaSpark master = spark.getMaster();
if(master == null)
if (master == null) {
return empty;
}
List<ICorporeaSpark> network = master.getConnections();
if(cachedNetworks.containsKey(network)) {
if (cachedNetworks.containsKey(network)) {
List<InvWithLocation> cache = cachedNetworks.get(network);
if(cache != null)
if (cache != null) {
return cache;
}
}
List<InvWithLocation> inventories = new ArrayList<>();
if(network != null)
for(ICorporeaSpark otherSpark : network)
if(otherSpark != null) {
if (network != null) {
for (ICorporeaSpark otherSpark : network) {
if (otherSpark != null) {
InvWithLocation inv = otherSpark.getSparkInventory();
if(inv != null)
if (inv != null) {
inventories.add(inv);
}
}
}
}
cachedNetworks.put(network, inventories);
return inventories;
@@ -99,8 +104,9 @@ public final class CorporeaHelper {
public static int getCountInNetwork(ICorporeaRequestMatcher matcher, Map<InvWithLocation, Integer> inventories) {
int count = 0;
for(int value : inventories.values())
for (int value : inventories.values()) {
count += value;
}
return count;
}
@@ -129,6 +135,7 @@ public final class CorporeaHelper {
if (request.foundItems > 0) {
countMap.put(inv.getWrappedObject(), request.foundItems);
}
}
return countMap;
@@ -167,19 +174,22 @@ public final class CorporeaHelper {
* This will remove the items from the adequate inventories unless the "doit" parameter is false.
* Returns a new list of ItemStacks of the items acquired or an empty list if none was found.
* Case itemCount is -1 it'll find EVERY item it can.
* <br><br>
* <br>
* <br>
* The "matcher" parameter has to be an ItemStack or a String, if the first it'll check if the
* two stacks are similar using the "checkNBT" parameter, else it'll check if the name of the item
* equals or matches (case a regex is passed in) the matcher string.
* <br><br>
* <br>
* <br>
* When requesting counting of items, individual stacks may exceed maxStackSize for
* purposes of counting huge amounts.
*/
public static List<ItemStack> requestItem(ICorporeaRequestMatcher matcher, int itemCount, ICorporeaSpark spark, boolean doit) {
List<ItemStack> stacks = new ArrayList<>();
CorporeaRequestEvent event = new CorporeaRequestEvent(matcher, itemCount, spark, doit);
if(MinecraftForge.EVENT_BUS.post(event))
if (MinecraftForge.EVENT_BUS.post(event)) {
return stacks;
}
List<InvWithLocation> inventories = getInventoriesOnNetwork(spark);
@@ -187,25 +197,26 @@ public final class CorporeaHelper {
Map<ICorporeaInterceptor, ICorporeaSpark> interceptors = new HashMap<ICorporeaInterceptor, ICorporeaSpark>();
CorporeaRequest request = new CorporeaRequest(matcher, itemCount);
for(IWrappedInventory inv : inventoriesW) {
for (IWrappedInventory inv : inventoriesW) {
ICorporeaSpark invSpark = inv.getSpark();
InvWithLocation originalInventory = inv.getWrappedObject();
if(originalInventory.world.getTileEntity(originalInventory.pos) instanceof ICorporeaInterceptor) {
if (originalInventory.world.getTileEntity(originalInventory.pos) instanceof ICorporeaInterceptor) {
ICorporeaInterceptor interceptor = (ICorporeaInterceptor) originalInventory.world.getTileEntity(originalInventory.pos);
interceptor.interceptRequest(matcher, itemCount, invSpark, spark, stacks, inventories, doit);
interceptors.put(interceptor, invSpark);
}
if(doit) {
if (doit) {
stacks.addAll(inv.extractItems(request));
} else {
stacks.addAll(inv.countItems(request));
}
}
for(ICorporeaInterceptor interceptor : interceptors.keySet())
for (ICorporeaInterceptor interceptor : interceptors.keySet()) {
interceptor.interceptRequestLast(matcher, itemCount, interceptors.get(interceptor), spark, stacks, inventories, doit);
}
lastRequestMatches = request.foundItems;
lastRequestExtractions = request.extractedItems;
@@ -245,13 +256,18 @@ public final class CorporeaHelper {
public static void clearCache() {
cachedNetworks.clear();
}
/**
* Returns the comparator strength for a corporea request that corporea crystal cubes and retainers use, following the usual "each step up requires double the items" formula.
/**
* Returns the comparator strength for a corporea request that corporea crystal cubes and retainers use, following
* the usual "each step up requires double the items" formula.
*/
public static int signalStrengthForRequestSize(int requestSize) {
if(requestSize <= 0) return 0;
else if (requestSize >= 16384) return 15;
else return Math.min(15, MathHelper.log2(requestSize) + 1);
if (requestSize <= 0) {
return 0;
} else if (requestSize >= 16384) {
return 15;
} else {
return Math.min(15, MathHelper.log2(requestSize) + 1);
}
}
}
@@ -1,11 +1,10 @@
/**
* This class was created by <quaternary>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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.corporea;
@@ -13,17 +12,17 @@ import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
/**
/**
* CorporeaIndexRequestEvent is fired when a player attempts to request an item from a corporea index.
* If the event is cancelled, the request will not be performed.
* */
*/
@Cancelable
public class CorporeaIndexRequestEvent extends Event {
public final ServerPlayerEntity requester;
public ICorporeaRequestMatcher request;
public int requestCount;
public ICorporeaSpark indexSpark;
public CorporeaIndexRequestEvent(ServerPlayerEntity requester, ICorporeaRequestMatcher request, int requestCount, ICorporeaSpark indexSpark) {
this.requester = requester;
this.request = request;
@@ -1,11 +1,10 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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.corporea;
@@ -1,12 +1,10 @@
/**
* This class was created by <Alwinfy>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Dec 22, 2019, 11:13:14 PM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -14,21 +12,24 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import org.apache.commons.lang3.text.WordUtils;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import java.util.regex.Pattern;
/**
* An interface for a Corporea Request matcher. Accepts an ItemStack and returns whether it fulfills the request.
* Needs to be registered over in {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}.
* Needs to be registered over in
* {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}.
*/
public final class CorporeaRequestDefaultMatchers {
public static class CorporeaStringMatcher implements ICorporeaRequestMatcher {
private static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
public static final String[] WILDCARD_STRINGS = { "...", "~", "+", "?" , "*" };
public static final String[] WILDCARD_STRINGS = { "...", "~", "+", "?", "*" };
private static final String TAG_REQUEST_CONTENTS = "requestContents";
private static final String TAG_REQUEST_CONTAINS = "requestContains";
@@ -37,22 +38,23 @@ public final class CorporeaRequestDefaultMatchers {
public CorporeaStringMatcher(String expression) {
boolean contains = false;
for(String wc : WILDCARD_STRINGS) {
if(expression.endsWith(wc)) {
for (String wc : WILDCARD_STRINGS) {
if (expression.endsWith(wc)) {
contains = true;
expression = expression.substring(0, expression.length() - wc.length());
}
else if(expression.startsWith(wc)) {
} else if (expression.startsWith(wc)) {
contains = true;
expression = expression.substring(wc.length());
}
if(contains)
if (contains) {
break;
}
}
this.expression = expression;
this.contains = contains;
}
private CorporeaStringMatcher(String expression, boolean contains) {
this.expression = expression;
this.contains = contains;
@@ -60,14 +62,15 @@ public final class CorporeaRequestDefaultMatchers {
@Override
public boolean isStackValid(ItemStack stack) {
if(stack.isEmpty())
if (stack.isEmpty()) {
return false;
}
String name = stripControlCodes(stack.getDisplayName().getString().toLowerCase().trim());
return equalOrContain(name)
|| equalOrContain(name + "s")
|| equalOrContain(name + "es")
|| name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies");
|| equalOrContain(name + "s")
|| equalOrContain(name + "es")
|| name.endsWith("y") && equalOrContain(name.substring(0, name.length() - 1) + "ies");
}
public static ICorporeaRequestMatcher createFromNBT(CompoundNBT tag) {
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 30, 2015, 2:55:57 PM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -34,5 +32,4 @@ public class CorporeaRequestEvent extends Event {
realRequest = real;
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 19, 2015, 6:23:31 PM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -1,12 +1,10 @@
/**
* This class was created by <Alwinfy>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Dec 22, 2019, 11:13:14 PM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -16,8 +14,10 @@ import net.minecraft.util.text.ITextComponent;
/**
* An interface for a Corporea Request matcher. Accepts an ItemStack and returns whether it fulfills the request.
* Needs to be registered over in {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}.
* Needs one additional (static) method for deserialization, which can't really go here because Java doesn't like static abstract's.
* Needs to be registered over in
* {@link vazkii.botania.common.block.tile.corporea.TileCorporeaRetainer#addCorporeaRequestMatcher}.
* Needs one additional (static) method for deserialization, which can't really go here because Java doesn't like static
* abstract's.
*/
public interface ICorporeaRequestMatcher {
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Sep 28, 2015, 11:25:48 AM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -18,8 +16,8 @@ package vazkii.botania.api.corporea;
public interface ICorporeaRequestor {
/*
* Executes the passed in request.
*/
* Executes the passed in request.
*/
public void doCorporeaRequest(ICorporeaRequestMatcher request, int count, ICorporeaSpark spark);
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 13, 2015, 10:53:05 PM (GMT)]
*/
package vazkii.botania.api.corporea;
@@ -26,7 +24,8 @@ public interface ICorporeaSpark {
* which is the one that initiated the chain call, the referrer which passed the call to this instance
* and the List of sparks connected. Normal behavior should be to find any sparks around that are not
* already present in the list of connections and add them to it, passing the function call to them.
* <br><br>
* <br>
* <br>
* The connections List and the master Spark should be kept in this instance as pointers for use in
* getConnections() and getMaster() and passed in to any subsequent registerConnections calls on sparks
* found nearby. This is only called whenever a new spark is added or removed from and to the network,
@@ -1,11 +1,10 @@
/**
* This class was created by <Vindex>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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.corporea;
@@ -16,7 +15,6 @@ import java.util.List;
/**
* This interface wraps IInventory corporea works with in order to provide
* compatibility with different storage mods.
*
*/
public interface IWrappedInventory {
@@ -28,11 +26,11 @@ public interface IWrappedInventory {
/**
* Counts items in the inventory matching the request
*
* @param request
* - specifies what should be found
* @return List of ItemStack, individual stacks may exceed maxStackSize for
* purposes of counting huge amounts. To get final count requestor
* should sum stackSize of all stacks.
* @param request
* - specifies what should be found
* @return List of ItemStack, individual stacks may exceed maxStackSize for
* purposes of counting huge amounts. To get final count requestor
* should sum stackSize of all stacks.
*/
List<ItemStack> countItems(CorporeaRequest request);
@@ -49,8 +47,8 @@ public interface IWrappedInventory {
* {@link CorporeaRequest#extractedItems} are updated to reflect how many
* items were found and extracted.
*
* @param request
* @return List of ItemStacks to be delivered to the destination.
* @param request
* @return List of ItemStacks to be delivered to the destination.
*/
List<ItemStack> extractItems(CorporeaRequest request);
}
@@ -1,3 +1,11 @@
/*
* 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.corporea;
import net.minecraft.util.math.BlockPos;
+21 -22
View File
@@ -1,39 +1,38 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 06, 2019]
*/
package vazkii.botania.api.imc;
/**
* This class defines the IMC methods accepted by Botania and their expected argument types
*
* @see net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent
* @see net.minecraftforge.fml.event.lifecycle.InterModProcessEvent
* @see net.minecraftforge.fml.InterModComms
*/
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 />
* 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 world generation. This is used for the Orechid flower.<br />
* The argument should be a {@link OreWeightMessage}, 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 />
* Check the Botania source to see default values.<br>
*/
public static final String REGISTER_NETHER_ORE_WEIGHT = "register_nether_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 />
* 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";
/**
* 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,25 +1,33 @@
/*
* 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;
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;
}
/**
* @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 ResourceLocation getOre() {
return blockTag;
}
public Integer getWeight() {
return weight;
}
public Integer getWeight() {
return weight;
}
}
@@ -1,3 +1,11 @@
/*
* 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;
@@ -7,27 +15,27 @@ import net.minecraftforge.registries.IRegistryDelegate;
import java.util.function.Function;
public class PaintableBlockMessage {
private final IRegistryDelegate<Block> block;
private final Function<DyeColor, Block> transformer;
private final IRegistryDelegate<Block> block;
private final Function<DyeColor, Block> transformer;
public PaintableBlockMessage(Function<DyeColor, Block> transformer, Block block) {
this(transformer, block.delegate);
}
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;
}
/**
* @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 IRegistryDelegate<Block> getBlock() {
return block;
}
public Function<DyeColor, Block> getTransformer() {
return transformer;
}
public Function<DyeColor, Block> getTransformer() {
return transformer;
}
}
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)]
*/
package vazkii.botania.api.internal;
import com.google.common.collect.ImmutableSet;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -19,6 +17,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
@@ -79,7 +78,7 @@ public class DummyMethodHandler implements IInternalMethodHandler {
return 0;
}
@Override
@Override
public List<IWrappedInventory> wrapInventory(List<InvWithLocation> inventories) {
return null;
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -21,6 +19,7 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.corporea.IWrappedInventory;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -18,6 +16,7 @@ import java.util.Set;
/**
* A basic interface for a world's Mana Network.
*
* @see IInternalMethodHandler#getManaNetworkInstance()
*/
public interface IManaNetwork {
@@ -34,8 +33,9 @@ public interface IManaNetwork {
* A way of getting the dimension is via world.provider.dimensionId<br>
* Note that this function *can* get performance intensive, it's reccomended you
* call it sparingly and take cache of the value returned.
*
* @param limit The maximum distance the closest block can be, if the closest block
* is farther away than that, null will be returned instead.
* is farther away than that, null will be returned instead.
*/
public TileEntity getClosestCollector(BlockPos pos, World world, int limit);
@@ -45,8 +45,9 @@ public interface IManaNetwork {
* A way of getting the dimension is via world.provider.dimensionId<br>
* Note that this function *can* get performance intensive, it's reccomended you
* call it sparingly and take cache of the value returned.
*
* @param limit The maximum distance the closest block can be, if the closest block
* is farther away than that, null will be returned instead.
* is farther away than that, null will be returned instead.
*/
public TileEntity getClosestPool(BlockPos pos, World world, int limit);
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 29, 2014, 6:31:35 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 9, 2015, 9:38:44 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -24,8 +22,8 @@ public final class VanillaPacketDispatcher {
SUpdateTileEntityPacket packet = tile.getUpdatePacket();
BlockPos pos = tile.getPos();
if(packet != null && tile.getWorld() instanceof ServerWorld) {
((ServerChunkProvider)tile.getWorld().getChunkProvider()).chunkManager
if (packet != null && tile.getWorld() instanceof ServerWorld) {
((ServerChunkProvider) tile.getWorld().getChunkProvider()).chunkManager
.getTrackingPlayers(new ChunkPos(pos), false)
.forEach(e -> e.connection.sendPacket(packet));
}
@@ -33,8 +31,9 @@ public final class VanillaPacketDispatcher {
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
if(tile != null)
if (tile != null) {
dispatchTEToNearbyPlayers(tile);
}
}
}
@@ -1,6 +1,15 @@
/*
* 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.item;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.entity.LivingEntity;
@@ -9,66 +18,67 @@ import net.minecraft.entity.LivingEntity;
*/
public final class AccessoryRenderHelper {
/**
* Rotates the render for a bauble correctly if the player is sneaking.
*/
public static void rotateIfSneaking(MatrixStack ms, LivingEntity player) {
if(player.isCrouching())
applySneakingRotation(ms);
}
/**
* Rotates the render for a bauble correctly if the player is sneaking.
*/
public static void rotateIfSneaking(MatrixStack ms, LivingEntity player) {
if (player.isCrouching()) {
applySneakingRotation(ms);
}
}
/**
* Rotates the render for a bauble correctly for a sneaking player.
*/
public static void applySneakingRotation(MatrixStack ms) {
ms.translate(0F, 0.2F, 0F);
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90F / (float) Math.PI));
}
/**
* Rotates the render for a bauble correctly for a sneaking player.
*/
public static void applySneakingRotation(MatrixStack ms) {
ms.translate(0F, 0.2F, 0F);
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(90F / (float) Math.PI));
}
/**
* Shifts the render for a bauble correctly to the head, including sneaking rotation.
*/
public static void translateToHeadLevel(MatrixStack ms, LivingEntity player, float partialTicks) {
/**
* Shifts the render for a bauble correctly to the head, including sneaking rotation.
*/
public static void translateToHeadLevel(MatrixStack ms, LivingEntity player, float partialTicks) {
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks;
float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks;
float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks;
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-yawOffset));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw - 270));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(pitch));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(-yawOffset));
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(yaw - 270));
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(pitch));
ms.translate(0, -player.getEyeHeight(), 0);
ms.translate(0, -player.getEyeHeight(), 0);
// if (player.shouldRenderSneaking()) TODO Sneaking needs a different adjustment now
// GlStateManager.translatef(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F);
}
}
/**
* Shifts the render for a bauble correctly to the face.
* Use for renders after calling {@link AccessoryRenderHelper#translateToHeadLevel}.
*/
public static void translateToFace(MatrixStack ms) {
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180));
ms.translate(0f, -4.35f, -1.27f);
}
/**
* Shifts the render for a bauble correctly to the face.
* Use for renders after calling {@link AccessoryRenderHelper#translateToHeadLevel}.
*/
public static void translateToFace(MatrixStack ms) {
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(90));
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180));
ms.translate(0f, -4.35f, -1.27f);
}
/**
* Scales down the render to a correct size.
* Use for any render.
*/
public static void defaultTransforms(MatrixStack ms) {
ms.translate(0.0, 3.0, 1.0);
ms.scale(0.55F, 0.55F, 0.55F);
}
/**
* Scales down the render to a correct size.
* Use for any render.
*/
public static void defaultTransforms(MatrixStack ms) {
ms.translate(0.0, 3.0, 1.0);
ms.scale(0.55F, 0.55F, 0.55F);
}
/**
* Shifts the render for a bauble correctly to the chest.
* Use for renders after calling {@link AccessoryRenderHelper#rotateIfSneaking}.
*/
public static void translateToChest(MatrixStack ms) {
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180));
ms.translate(0F, -3.2F, -0.85F);
}
/**
* Shifts the render for a bauble correctly to the chest.
* Use for renders after calling {@link AccessoryRenderHelper#rotateIfSneaking}.
*/
public static void translateToChest(MatrixStack ms) {
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(180));
ms.translate(0F, -3.2F, -0.85F);
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 30, 2015, 11:24:54 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,17 +1,16 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 24, 2015, 7:00:21 PM (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.util.Direction;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.api.mana.IManaReceiver;
/**
@@ -21,6 +20,7 @@ public interface IAvatarTile extends IManaReceiver {
/**
* Gets the avatar's inventory
*
* @return An IItemhandler representing the avatar's inventory
*/
public IItemHandler getInventory();
@@ -41,5 +41,4 @@ public interface IAvatarTile extends IManaReceiver {
*/
public boolean isEnabled();
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 24, 2015, 6:45:50 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 20, 2015, 10:31:54 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 24, 2015, 3:08:40 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 22, 2015, 8:31:39 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 22, 2015, 2:02:02 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 30, 2014, 4:28:29 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 17, 2014, 6:05:18 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -17,6 +15,7 @@ import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
@@ -45,9 +44,9 @@ public interface IFloatingFlower {
@Override
public void readNBT(Capability<IFloatingFlower> capability, IFloatingFlower instance, Direction side, INBT nbt) {
if(nbt instanceof CompoundNBT) {
if (nbt instanceof CompoundNBT) {
IslandType t = IslandType.ofType(((CompoundNBT) nbt).getString("islandType"));
if(t != null) {
if (t != null) {
instance.setIslandType(t);
}
}
@@ -73,12 +72,15 @@ public interface IFloatingFlower {
/**
* Instantiates and registers a new floating flower island type
* Note that you need to register the model for this island type, see BotaniaAPIClient
*
* @param name The name of this floating flower island type
*/
public IslandType(String name) {
typeName = name;
synchronized (registry) {
if (registry.containsKey(name)) throw new IllegalArgumentException(name+" already registered!");
if (registry.containsKey(name)) {
throw new IllegalArgumentException(name + " already registered!");
}
registry.put(name, this);
}
}
@@ -1,15 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [17/11/2015, 20:10:53 (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.item.BlockItemUseContext;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
/**
@@ -18,8 +18,8 @@ import vazkii.botania.api.subtile.TileEntitySpecialFlower;
public interface IFlowerPlaceable {
/**
* @param ctx The placement context, aiming downwards towards the downward neighbor position
* @return Whether the block was placed successfully
* @param ctx The placement context, aiming downwards towards the downward neighbor position
* @return Whether the block was placed successfully
*/
boolean tryPlace(TileEntitySpecialFlower flower, BlockItemUseContext ctx);
}
@@ -1,14 +1,13 @@
/**
* This class was created by <SpitefulFox>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.world.IWorld;
/**
@@ -19,4 +18,4 @@ public interface IFlowerlessBiome {
* @return Should this world be allowed to generate flowers?
*/
public boolean canGenerateFlowers(IWorld world, int x, int z);
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <TheLoneDevil>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 24, 2015, 11:16:00 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [28/09/2016, 20:01:14 (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,17 +1,16 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 18, 2015, 12:10:00 AM (GMT)]
*/
package vazkii.botania.api.item;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaPool;
/**
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 28, 2015, 9:04:53 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -15,6 +13,7 @@ import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.mana.ManaProficiencyEvent;
/**
@@ -33,13 +32,14 @@ public interface IManaProficiencyArmor {
static boolean hasProficiency(PlayerEntity player, ItemStack rod) {
boolean proficient = false;
for(EquipmentSlotType e: EquipmentSlotType.values()) {
if(e.getSlotType() != EquipmentSlotType.Group.ARMOR)
for (EquipmentSlotType e : EquipmentSlotType.values()) {
if (e.getSlotType() != EquipmentSlotType.Group.ARMOR) {
continue;
}
ItemStack armor = player.getItemStackFromSlot(e);
if(!armor.isEmpty()) {
if (!armor.isEmpty()) {
Item item = armor.getItem();
if(item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) {
if (item instanceof IManaProficiencyArmor && ((IManaProficiencyArmor) item).shouldGiveProficiency(armor, e, player, rod)) {
proficient = true;
break;
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 30, 2014, 4:22:15 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 17, 2015, 4:57:44 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 29, 2015, 7:17:41 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -14,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
import java.util.UUID;
/**
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 30, 2015, 2:46:05 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 23, 2015, 7:03:48 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -22,17 +20,19 @@ public interface ISortableTool {
* Gets the priority that this tool should have when being sorted. The
* tool with the highest priority will be picked. The way this is specified
* should be (tool-level) * 100 + (tool-modifier) * 10 + (efficiency-level).
* <br><br>
* <br>
* <br>
* For example, a <b>Manasteel Pickaxe</b> is tool-level 10 and it doesn't have
* modifiers. Assuming Efficiency 4, the priority should be 10 * 100 + 4 = <b>1004</b>.
* This will rate higher than a similar pickaxe with Efficiency 3.<br>
* A <b>Terra Shatterer</b> has a modifier, its rank and is tool-level 20. With Efficiency
* 5 and rank B (2) the priority should be 20 * 100 + 2 * 10 + 5 = <b>2025</b>.
* <br><br>
* <br>
* <br>
* All intermediate tool levels are there for other mod tools that wish to occupy the spots inbetween.
* Of course, you don't have to always adhere to this. Tools like the <b>Vitreous Pickaxe</b> don't,
* that one in particular is priority 0 so it's never picked.
*/
public int getSortingPriority(ItemStack stack);
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 29, 2015, 11:30:41 PM (GMT)]
*/
package vazkii.botania.api.item;
@@ -15,6 +13,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import javax.annotation.Nullable;
import java.util.List;
/**
@@ -33,6 +32,7 @@ public interface IWireframeCoordinateListProvider {
/**
* Gets a wireframe to draw thicker than the rest.
* This is useful to indicate the precedence of some position over the others.
*
* @return The position of a single wireframe to draw thicker than all the others.
*/
@Nullable
@@ -40,5 +40,4 @@ public interface IWireframeCoordinateListProvider {
return null;
}
}
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 25, 2015, 8:02:41 PM (GMT)]
*/
package vazkii.botania.api.item;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.text.ITextComponent;
@@ -38,4 +37,4 @@ public class TinyPotatoRenderEvent extends Event {
this.light = light;
this.overlay = overlay;
}
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 2, 2014, 5:26:02 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <WireSegal>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 23, 2015, 10:30:34 AM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -28,5 +26,3 @@ public interface ICompositableLens extends ILens {
public boolean isCombinable(ItemStack stack);
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [May 25, 2014, 7:34:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -22,4 +20,3 @@ public interface ICreativeManaProvider {
public boolean isCreative(ItemStack stack);
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [15/11/2015, 19:27:07 (GMT)]
*/
package vazkii.botania.api.mana;
@@ -29,12 +27,14 @@ public interface IDirectioned {
/**
* Set the X rotation
*
* @param rot X rotation, in degrees
*/
public void setRotationX(float rot);
/**
* Set the Y rotation
*
* @param rot Y rotation, in degrees
*/
public void setRotationY(float rot);
@@ -1,22 +1,20 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 11, 2014, 4:29:32 PM (GMT)]
*/
package vazkii.botania.api.mana;
/**
* A TileEntity that implements this interface has an IO key lock. This
* interface defines an input and output key.<br><br>
*
* interface defines an input and output key.<br>
* <br>
* A Spreader can only shoot mana into a IKeyLocked interfaced TE if the Input
* key of the TE is equal to the Output key of the Spreader.<br><br>
*
* key of the TE is equal to the Output key of the Spreader.<br>
* <br>
* A Spreader can only pull mana from a IKeyLocked interfaced IManaPool TE if the
* Output key of the IManaPool is equal to the Input key of the Spreader.
*/
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 26, 2014, 9:51:58 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [15/11/2015, 21:00:32 (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,18 +1,17 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
import net.minecraft.entity.projectile.ThrowableEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.internal.IManaBurst;
/**
@@ -30,6 +29,7 @@ public interface ILensEffect {
/**
* Called when a mana burst fired from a mana spreader with this focus collides against
* any block. This is called after the collision is handled.
*
* @return True to kill the burst. False to keep it alive.
*/
public boolean collideBurst(IManaBurst burst, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack);
@@ -52,5 +52,5 @@ public interface ILensEffect {
public default int getManaToTransfer(IManaBurst burst, ThrowableEntity entity, ItemStack stack, IManaReceiver receiver) {
return burst.getMana();
}
}
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -14,11 +12,12 @@ import vazkii.botania.api.internal.IManaBurst;
/**
* Any TileEntity that implements this is considered a mana collector, by
* which nearby generating flowers will pump mana into it.<br><br>
*
* which nearby generating flowers will pump mana into it.<br>
* <br>
* <b>Implementation Instructions:</b><br>
* - Override invalidate() and onChunkUnload(), calling <i>ManaNetworkEvent.removeCollector(this);</i> on both.<br>
* - On the first tick of update() (or onLoad() in Forge build 1606 or higher), call </i>ManaNetworkEvent.addCollector(this);<i>
* - On the first tick of update() (or onLoad() in Forge build 1606 or higher), call
* </i>ManaNetworkEvent.addCollector(this);<i>
*/
public interface IManaCollector extends IManaReceiver {
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 28, 2015, 9:22:53 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [08/12/2015, 18:10:29 (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -36,8 +34,9 @@ public interface IManaItem {
/**
* Can this item receive mana from a mana Pool?
*
* @param pool The pool it's receiving mana from, can be casted to IManaPool.
* @see IManaPool#isOutputtingPower()
* @see IManaPool#isOutputtingPower()
*/
public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool);
@@ -48,10 +47,11 @@ public interface IManaItem {
/**
* Can this item export mana to a mana Pool?
*
* @param pool The pool it's exporting mana to, can be casted to IManaPool.
* @see IManaPool#isOutputtingPower()
* @see IManaPool#isOutputtingPower()
*/
public boolean canExportManaToPool(ItemStack stack,TileEntity pool);
public boolean canExportManaToPool(ItemStack stack, TileEntity pool);
/**
* Can this item export mana to another item?
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -15,8 +13,8 @@ import net.minecraft.item.DyeColor;
/**
* Any TileEntity that implements this is considered a Mana Pool,
* by which nearby functional flowers will pull mana from it.<br>
* Mana Distributors will also accept it as valid output.<br><br>
*
* Mana Distributors will also accept it as valid output.<br>
* <br>
* <b>Implementation Instructions:</b><br>
* - Override invalidate() and onChunkUnload(), calling <i>ManaNetworkEvent.removePool(this);</i> on both.<br>
* - On the first tick of onUpdate(), call <i>ManaNetworkEvent.addPool(this);</i>
@@ -36,6 +34,7 @@ public interface IManaPool extends IManaReceiver {
/**
* Sets the color of this pool.
*
* @param color The color to set.
*/
public void setColor(DyeColor color);
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <SoundLogic>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 18, 2015, 7:30:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 23, 2015, 3:54:03 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,17 +1,16 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [May 16, 2014, 7:52:53 PM (GMT)]
*/
package vazkii.botania.api.mana;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.api.internal.IManaBurst;
/**
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [May 25, 2014, 7:32:10 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jun 19, 2015, 9:52:05 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 2, 2014, 6:36:54 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 12, 2015, 3:08:09 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 22, 2014, 2:26:14 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Flaxbeard>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jul 25, 2016, 9:02:12 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -19,7 +17,7 @@ public class ManaDiscountEvent extends Event {
private final PlayerEntity entityPlayer;
private float discount;
private ItemStack tool;
public ManaDiscountEvent(PlayerEntity entityPlayer, float discount, ItemStack tool) {
this.entityPlayer = entityPlayer;
this.discount = discount;
@@ -1,29 +1,26 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)]
*/
package vazkii.botania.api.mana;
import com.google.common.collect.Iterables;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.api.BotaniaAPI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public final class ManaItemHandler {
@@ -31,20 +28,22 @@ public final class ManaItemHandler {
* Gets a list containing all mana-holding items in a player's inventory.
* Also includes a call to ManaItemsEvent, so other mods can add items from
* their player-associated inventories.
*
* @return The list of items
*/
public static List<ItemStack> getManaItems(PlayerEntity player) {
if (player == null)
if (player == null) {
return Collections.emptyList();
}
List<ItemStack> toReturn = new ArrayList<>();
player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(mainInv -> {
int size = mainInv.getSlots();
for(int slot = 0; slot < size; slot++) {
for (int slot = 0; slot < size; slot++) {
ItemStack stackInSlot = mainInv.getStackInSlot(slot);
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
toReturn.add(stackInSlot);
}
}
@@ -57,23 +56,25 @@ public final class ManaItemHandler {
/**
* Gets a list containing all mana-holding items in a player's accessories inventory.
*
* @return The list of items
*/
public static List<ItemStack> getManaAccesories(PlayerEntity player) {
if (player == null)
if (player == null) {
return Collections.emptyList();
}
IItemHandler acc = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
if (acc == null)
if (acc == null) {
return Collections.emptyList();
}
List<ItemStack> toReturn = new ArrayList<>(acc.getSlots());
for(int slot = 0; slot < acc.getSlots(); slot++) {
for (int slot = 0; slot < acc.getSlots(); slot++) {
ItemStack stackInSlot = acc.getStackInSlot(slot);
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IManaItem) {
toReturn.add(stackInSlot);
}
}
@@ -83,29 +84,35 @@ public final class ManaItemHandler {
/**
* Requests mana from items in a given player's inventory.
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* the amount of mana existent will be returned instead, if you want exact values use requestManaExact.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return The amount of mana received from the request.
*
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* the amount of mana existent will be returned instead, if you want exact values use
* requestManaExact.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return The amount of mana received from the request.
*/
public static int requestMana(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
if(stack.isEmpty())
if (stack.isEmpty()) {
return 0;
}
List<ItemStack> items = getManaItems(player);
List<ItemStack> acc = getManaAccesories(player);
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
if(stackInSlot == stack)
if (stackInSlot == stack) {
continue;
}
IManaItem manaItem = (IManaItem) stackInSlot.getItem();
if(manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) {
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot))
if (manaItem.canExportManaToItem(stackInSlot, stack) && manaItem.getMana(stackInSlot) > 0) {
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
continue;
}
int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot));
if(remove)
if (remove) {
manaItem.addMana(stackInSlot, -mana);
}
return mana;
}
@@ -116,27 +123,32 @@ public final class ManaItemHandler {
/**
* Requests an exact amount of mana from items in a given player's inventory.
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* false will be returned instead, and nothing will happen.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return If the request was succesful.
*
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* false will be returned instead, and nothing will happen.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return If the request was succesful.
*/
public static boolean requestManaExact(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
if(stack.isEmpty())
if (stack.isEmpty()) {
return false;
}
List<ItemStack> items = getManaItems(player);
List<ItemStack> acc = getManaAccesories(player);
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
if(stackInSlot == stack)
if (stackInSlot == stack) {
continue;
}
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
if(manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) {
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot))
if (manaItemSlot.canExportManaToItem(stackInSlot, stack) && manaItemSlot.getMana(stackInSlot) > manaToGet) {
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canReceiveManaFromItem(stack, stackInSlot)) {
continue;
}
if(remove)
if (remove) {
manaItemSlot.addMana(stackInSlot, -manaToGet);
}
return true;
}
@@ -148,32 +160,38 @@ public final class ManaItemHandler {
/**
* Dispatches mana to items in a given player's inventory. Note that this method
* does not automatically remove mana from the item which is exporting.
* @param manaToSend How much mana is to be sent.
* @param add If true, the mana will be added from the target item. Set to false to just check.
* @return The amount of mana actually sent.
*
* @param manaToSend How much mana is to be sent.
* @param add If true, the mana will be added from the target item. Set to false to just check.
* @return The amount of mana actually sent.
*/
public static int dispatchMana(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
if(stack.isEmpty())
if (stack.isEmpty()) {
return 0;
}
List<ItemStack> items = getManaItems(player);
List<ItemStack> acc = getManaAccesories(player);
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
if(stackInSlot == stack)
if (stackInSlot == stack) {
continue;
}
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
if(manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot))
if (manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
continue;
}
int received;
if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot))
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot)) {
received = manaToSend;
else received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot));
} else {
received = manaToSend - (manaItemSlot.getMana(stackInSlot) + manaToSend - manaItemSlot.getMaxMana(stackInSlot));
}
if(add)
if (add) {
manaItemSlot.addMana(stackInSlot, manaToSend);
}
return received;
}
@@ -185,26 +203,31 @@ public final class ManaItemHandler {
/**
* Dispatches an exact amount of mana to items in a given player's inventory. Note that this method
* does not automatically remove mana from the item which is exporting.
* @param manaToSend How much mana is to be sent.
* @param add If true, the mana will be added from the target item. Set to false to just check.
* @return If an item received the mana sent.
*
* @param manaToSend How much mana is to be sent.
* @param add If true, the mana will be added from the target item. Set to false to just check.
* @return If an item received the mana sent.
*/
public static boolean dispatchManaExact(ItemStack stack, PlayerEntity player, int manaToSend, boolean add) {
if(stack.isEmpty())
if (stack.isEmpty()) {
return false;
}
List<ItemStack> items = getManaItems(player);
List<ItemStack> acc = getManaAccesories(player);
for (ItemStack stackInSlot : Iterables.concat(items, acc)) {
if(stackInSlot == stack)
if (stackInSlot == stack) {
continue;
}
IManaItem manaItemSlot = (IManaItem) stackInSlot.getItem();
if(manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
if(stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot))
if (manaItemSlot.getMana(stackInSlot) + manaToSend <= manaItemSlot.getMaxMana(stackInSlot) && manaItemSlot.canReceiveManaFromItem(stackInSlot, stack)) {
if (stack.getItem() instanceof IManaItem && !((IManaItem) stack.getItem()).canExportManaToItem(stack, stackInSlot)) {
continue;
}
if(add)
if (add) {
manaItemSlot.addMana(stackInSlot, manaToSend);
}
return true;
}
@@ -216,10 +239,12 @@ public final class ManaItemHandler {
/**
* Requests mana from items in a given player's inventory. This version also
* checks for IManaDiscountArmor items equipped to lower the cost.
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* the amount of mana existent will be returned instead, if you want exact values use requestManaExact.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return The amount of mana received from the request.
*
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* the amount of mana existent will be returned instead, if you want exact values use
* requestManaExact.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return The amount of mana received from the request.
*/
public static int requestManaForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
@@ -230,27 +255,29 @@ public final class ManaItemHandler {
/**
* Requests an exact amount of mana from items in a given player's inventory. This version also
* checks for IManaDiscountArmor items equipped to lower the cost.
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* false will be returned instead, and nothing will happen.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return If the request was succesful.
*
* @param manaToGet How much mana is to be requested, if less mana exists than this amount,
* false will be returned instead, and nothing will happen.
* @param remove If true, the mana will be removed from the target item. Set to false to just check.
* @return If the request was succesful.
*/
public static boolean requestManaExactForTool(ItemStack stack, PlayerEntity player, int manaToGet, boolean remove) {
float multiplier = Math.max(0F, 1F - getFullDiscountForTools(player, stack));
int cost = (int) (manaToGet * multiplier);
return requestManaExact(stack, player, cost, remove);
}
/**
* Gets the sum of all the discounts on IManaDiscountArmor items equipped
* on the player passed in. This discount can vary based on what the passed tool is.
*/
public static float getFullDiscountForTools(PlayerEntity player, ItemStack tool) {
float discount = 0F;
for(int i = 0; i < player.inventory.armorInventory.size(); i++) {
for (int i = 0; i < player.inventory.armorInventory.size(); i++) {
ItemStack armor = player.inventory.armorInventory.get(i);
if(!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor)
if (!armor.isEmpty() && armor.getItem() instanceof IManaDiscountArmor) {
discount += ((IManaDiscountArmor) armor.getItem()).getDiscount(armor, i, player, tool);
}
}
ManaDiscountEvent event = new ManaDiscountEvent(player, discount, tool);
@@ -1,12 +1,10 @@
/**
* This class was created by <Flaxbeard>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Sep 23, 2016, 11:59:12 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -1,12 +1,10 @@
/**
* This class was created by <Flaxbeard>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Oct 4, 2016, 10:46:12 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -25,19 +23,19 @@ public class ManaProficiencyEvent extends Event {
this.rod = rod;
this.proficient = proficient;
}
public PlayerEntity getEntityPlayer() {
return entityPlayer;
}
public ItemStack getRod() {
return rod;
}
public boolean isProficient() {
return proficient;
}
public void setProficient(boolean proficient) {
this.proficient = proficient;
}
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 21, 2014, 5:44:13 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaReceiver;
/**
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 21, 2014, 5:44:07 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Aug 21, 2014, 7:16:11 PM (GMT)]
*/
package vazkii.botania.api.mana.spark;
import com.google.common.base.Predicates;
import net.minecraft.entity.Entity;
import net.minecraft.item.DyeColor;
import net.minecraft.util.math.AxisAlignedBB;
@@ -1,3 +1,11 @@
/*
* 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.mana.spark;
public enum SparkUpgradeType {
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 17, 2015, 4:58:30 PM (GMT)]
*/
package vazkii.botania.api.recipe;
@@ -1,12 +1,10 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)]
*/
package vazkii.botania.api.recipe;
@@ -1,3 +1,11 @@
/*
* 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.recipe;
import net.minecraft.item.ItemStack;
@@ -1,3 +1,11 @@
/*
* 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.recipe;
import net.minecraft.item.ItemStack;
@@ -10,7 +18,7 @@ import java.util.List;
* Implementation detail, you shouldn't need to use this.
*/
public interface IModRecipe {
List<Ingredient> getInputs();
ItemStack getOutput();
ResourceLocation getId();
List<Ingredient> getInputs();
ItemStack getOutput();
ResourceLocation getId();
}
@@ -1,22 +1,22 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Nov 1, 2014, 8:52:00 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.api.brew.IBrewContainer;
@@ -39,28 +39,31 @@ public class RecipeBrew {
public boolean matches(IItemHandler inv) {
List<Ingredient> inputsMissing = new ArrayList<>(inputs);
for(int i = 0; i < inv.getSlots(); i++) {
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack.isEmpty())
if (stack.isEmpty()) {
break;
}
if(stack.getItem() instanceof IBrewContainer)
if (stack.getItem() instanceof IBrewContainer) {
continue;
}
boolean matchedOne = false;
Iterator<Ingredient> iter = inputsMissing.iterator();
while (iter.hasNext()) {
Ingredient input = iter.next();
if(input.test(stack)) {
if (input.test(stack)) {
iter.remove();
matchedOne = true;
break;
}
}
if(!matchedOne)
if (!matchedOne) {
return false;
}
}
return inputsMissing.isEmpty();
@@ -83,8 +86,9 @@ public class RecipeBrew {
}
public ItemStack getOutput(ItemStack stack) {
if(stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer))
if (stack.isEmpty() || !(stack.getItem() instanceof IBrewContainer)) {
return new ItemStack(Items.GLASS_BOTTLE); // Fallback...
}
IBrewContainer container = (IBrewContainer) stack.getItem();
return container.getItemForBrew(brew, stack);
@@ -1,6 +1,15 @@
/*
* 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.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
@@ -27,34 +36,39 @@ public class RecipeElvenTrade {
/**
* Attempts to match the recipe
* @param stacks Entire contents of the portal's buffer
* @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe otherwise
*
* @param stacks Entire contents of the portal's buffer
* @return {@link Optional#empty()} if recipe doesn't match, Optional with a set of items used by recipe
* otherwise
*/
public Optional<List<ItemStack>> match(List<ItemStack> stacks) {
List<Ingredient> inputsMissing = new ArrayList<>(inputs);
List<ItemStack> stacksToRemove = new ArrayList<>();
for(ItemStack stack : stacks) {
if(stack.isEmpty()) {
for (ItemStack stack : stacks) {
if (stack.isEmpty()) {
continue;
}
if(inputsMissing.isEmpty())
if (inputsMissing.isEmpty()) {
break;
}
int stackIndex = -1;
for (int i = 0; i < inputsMissing.size(); i++) {
Ingredient ingr = inputsMissing.get(i);
if (ingr.test(stack)) {
if(!stacksToRemove.contains(stack))
if (!stacksToRemove.contains(stack)) {
stacksToRemove.add(stack);
}
stackIndex = i;
break;
}
}
if(stackIndex != -1)
if (stackIndex != -1) {
inputsMissing.remove(stackIndex);
}
}
return inputsMissing.isEmpty() ? Optional.of(stacksToRemove) : Optional.empty();
@@ -64,8 +78,8 @@ public class RecipeElvenTrade {
* If the recipe does not contain the item, it will be destroyed upon entering the portal.
*/
public boolean containsItem(ItemStack stack) {
for(Ingredient input : inputs) {
if(input.test(stack)) {
for (Ingredient input : inputs) {
if (input.test(stack)) {
return true;
}
}
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
@@ -22,18 +21,15 @@ import net.minecraftforge.registries.ObjectHolder;
import javax.annotation.Nullable;
public class RecipeManaInfusion {
@ObjectHolder("botania:alchemy_catalyst")
public static Block alchemy;
@ObjectHolder("botania:alchemy_catalyst") public static Block alchemy;
@ObjectHolder("botania:conjuration_catalyst")
public static Block conjuration;
@ObjectHolder("botania:conjuration_catalyst") public static Block conjuration;
private final ResourceLocation id;
private final ItemStack output;
private final Ingredient input;
private final int mana;
@Nullable
private BlockState catalystState;
@Nullable private BlockState catalystState;
private final String group;
public static RecipeManaInfusion conjuration(ResourceLocation id, ItemStack output, Ingredient input, int mana) {
@@ -119,4 +115,3 @@ public class RecipeManaInfusion {
return ret;
}
}
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
@@ -34,24 +33,27 @@ public class RecipePetals implements IModRecipe {
public boolean matches(IItemHandler inv) {
List<Ingredient> ingredientsMissing = new ArrayList<>(inputs);
for(int i = 0; i < inv.getSlots(); i++) {
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack input = inv.getStackInSlot(i);
if(input.isEmpty())
if (input.isEmpty()) {
break;
}
int stackIndex = -1;
for(int j = 0; j < ingredientsMissing.size(); j++) {
for (int j = 0; j < ingredientsMissing.size(); j++) {
Ingredient ingr = ingredientsMissing.get(j);
if(ingr.test(input)) {
if (ingr.test(input)) {
stackIndex = j;
break;
}
}
if(stackIndex != -1)
if (stackIndex != -1) {
ingredientsMissing.remove(stackIndex);
else return false;
} else {
return false;
}
}
return ingredientsMissing.isEmpty();
@@ -1,16 +1,15 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Apr 17, 2015, 5:07:25 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import com.google.common.base.Preconditions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.network.PacketBuffer;
@@ -20,6 +19,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
public class RecipePureDaisy {
@@ -39,7 +39,8 @@ public class RecipePureDaisy {
* @param id The ID for this recipe.
* @param input The input for the recipe. Can be a Block, BlockState, or Tag&lt;Block&gt;.
* @param state The blockstate to be placed upon recipe completion.
* @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not total time.
* @param time The amount of time in ticks to complete this recipe. Note that this is ticks on your block, not
* total time.
* The Pure Daisy only ticks one block at a time in a round robin fashion.
*/
public RecipePureDaisy(ResourceLocation id, Object input, BlockState state, int time) {
@@ -48,11 +49,12 @@ public class RecipePureDaisy {
this.input = input;
this.outputState = state;
this.time = time;
if(input != null
if (input != null
&& !(input instanceof Block)
&& !(input instanceof BlockState)
&& !(input instanceof Tag && checkBlockTag((Tag) input)))
&& !(input instanceof Tag && checkBlockTag((Tag) input))) {
throw new IllegalArgumentException("input must be a Tag<Block>, Block, or IBlockState");
}
}
private static boolean checkBlockTag(Tag<?> tag) {
@@ -63,11 +65,13 @@ public class RecipePureDaisy {
* This gets called every tick, please be careful with your checks.
*/
public boolean matches(World world, BlockPos pos, TileEntitySpecialFlower pureDaisy, BlockState state) {
if(input instanceof Block)
if (input instanceof Block) {
return state.getBlock() == input;
}
if(input instanceof BlockState)
if (input instanceof BlockState) {
return state == input;
}
return ((Tag<Block>) input).contains(state.getBlock());
}
@@ -78,8 +82,9 @@ public class RecipePureDaisy {
* it otherwise. You may return false to cancel the normal particles and do your own.
*/
public boolean set(World world, BlockPos pos, TileEntitySpecialFlower pureDaisy) {
if(!world.isRemote)
if (!world.isRemote) {
world.setBlockState(pos, outputState);
}
return true;
}
@@ -119,10 +124,17 @@ public class RecipePureDaisy {
ResourceLocation id = buf.readResourceLocation();
Object input;
switch (buf.readVarInt()) {
case 0: input = new BlockTags.Wrapper(buf.readResourceLocation()); break;
case 1: input = Registry.BLOCK.getByValue(buf.readVarInt()); break;
case 2: input = Block.getStateById(buf.readVarInt()); break;
default: throw new RuntimeException("Unknown input discriminator");
case 0:
input = new BlockTags.Wrapper(buf.readResourceLocation());
break;
case 1:
input = Registry.BLOCK.getByValue(buf.readVarInt());
break;
case 2:
input = Block.getStateById(buf.readVarInt());
break;
default:
throw new RuntimeException("Unknown input discriminator");
}
BlockState output = Block.getStateById(buf.readVarInt());
int time = buf.readVarInt();
@@ -1,17 +1,16 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* 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
*
* File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
@@ -39,24 +38,27 @@ public class RecipeRuneAltar implements IModRecipe {
public boolean matches(IItemHandler inv) {
List<Ingredient> ingredientsMissing = new ArrayList<>(inputs);
for(int i = 0; i < inv.getSlots(); i++) {
for (int i = 0; i < inv.getSlots(); i++) {
ItemStack input = inv.getStackInSlot(i);
if(input.isEmpty())
if (input.isEmpty()) {
break;
}
int stackIndex = -1;
for(int j = 0; j < ingredientsMissing.size(); j++) {
for (int j = 0; j < ingredientsMissing.size(); j++) {
Ingredient ingr = ingredientsMissing.get(j);
if(ingr.test(input)) {
if (ingr.test(input)) {
stackIndex = j;
break;
}
}
if(stackIndex != -1)
if (stackIndex != -1) {
ingredientsMissing.remove(stackIndex);
else return false;
} else {
return false;
}
}
return ingredientsMissing.isEmpty();
@@ -1,3 +1,11 @@
/*
* 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.recipe;
import net.minecraftforge.eventbus.api.Event;
@@ -7,52 +15,50 @@ import java.util.function.Consumer;
/**
* Fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
* whenever Botania wants to receive recipe registrations, i.e. on server start and every /reload.
*
* The handles to register recipes are simple {@link Consumer}s that accept the recipe to register it.
*
* This will be fired many times during the lifecycle of the game, it's highly encouraged you keep your event
* handlers as stateless as possible.
*/
public class RegisterRecipesEvent extends Event {
private final Consumer<RecipePureDaisy> pureDaisy;
private final Consumer<RecipeManaInfusion> manaInfusion;
private final Consumer<RecipeBrew> brew;
private final Consumer<RecipeElvenTrade> elvenTrade;
private final Consumer<RecipePetals> apothecary;
private final Consumer<RecipeRuneAltar> runeAltar;
private final Consumer<RecipePureDaisy> pureDaisy;
private final Consumer<RecipeManaInfusion> manaInfusion;
private final Consumer<RecipeBrew> brew;
private final Consumer<RecipeElvenTrade> elvenTrade;
private final Consumer<RecipePetals> apothecary;
private final Consumer<RecipeRuneAltar> runeAltar;
public RegisterRecipesEvent(Consumer<RecipePureDaisy> pureDaisy, Consumer<RecipeManaInfusion> manaInfusion,
Consumer<RecipeBrew> brew, Consumer<RecipeElvenTrade> elvenTrade,
Consumer<RecipePetals> apothecary, Consumer<RecipeRuneAltar> runeAltar) {
this.pureDaisy = pureDaisy;
this.manaInfusion = manaInfusion;
this.brew = brew;
this.elvenTrade = elvenTrade;
this.apothecary = apothecary;
this.runeAltar = runeAltar;
}
public RegisterRecipesEvent(Consumer<RecipePureDaisy> pureDaisy, Consumer<RecipeManaInfusion> manaInfusion,
Consumer<RecipeBrew> brew, Consumer<RecipeElvenTrade> elvenTrade,
Consumer<RecipePetals> apothecary, Consumer<RecipeRuneAltar> runeAltar) {
this.pureDaisy = pureDaisy;
this.manaInfusion = manaInfusion;
this.brew = brew;
this.elvenTrade = elvenTrade;
this.apothecary = apothecary;
this.runeAltar = runeAltar;
}
public Consumer<RecipePureDaisy> pureDaisy() {
return pureDaisy;
}
public Consumer<RecipePureDaisy> pureDaisy() {
return pureDaisy;
}
public Consumer<RecipeManaInfusion> manaInfusion() {
return manaInfusion;
}
public Consumer<RecipeManaInfusion> manaInfusion() {
return manaInfusion;
}
public Consumer<RecipeBrew> brew() {
return brew;
}
public Consumer<RecipeBrew> brew() {
return brew;
}
public Consumer<RecipeElvenTrade> elvenTrade() {
return elvenTrade;
}
public Consumer<RecipeElvenTrade> elvenTrade() {
return elvenTrade;
}
public Consumer<RecipePetals> apothecary() {
return apothecary;
}
public Consumer<RecipePetals> apothecary() {
return apothecary;
}
public Consumer<RecipeRuneAltar> runeAltar() {
return runeAltar;
}
public Consumer<RecipeRuneAltar> runeAltar() {
return runeAltar;
}
}
@@ -1,19 +1,21 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p>
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.api.state;
import com.google.common.base.Predicates;
import net.minecraft.item.DyeColor;
import net.minecraft.state.BooleanProperty;
import net.minecraft.state.EnumProperty;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.ModelProperty;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.state.enums.AlfPortalState;
import vazkii.botania.api.state.enums.CratePattern;
@@ -45,7 +47,6 @@ public final class BotaniaStateProps {
// BlockPrism
public static final BooleanProperty HAS_LENS = BooleanProperty.create("has_lens");
private BotaniaStateProps() {
}
private BotaniaStateProps() {}
}
Loaded 100 of 757 files, more files were not shown because too many files have changed in this diff. Show more