Revert back to eclipse, IDEA is having subpar performace.

This commit is contained in:
Vasco Lavos committed 2014-04-20 19:35:14 +01:00
1 parent 46b0a26832
commit a90384e40b
223 files changed
+13042 -13881

No files matched your search

+169 -167
View File
@@ -2,20 +2,17 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:15:28 PM (GMT)]
*/
package vazkii.botania.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;
@@ -32,190 +29,195 @@ import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
import vazkii.botania.api.subtile.SubTileEntity;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public final class BotaniaAPI {
private static List<LexiconCategory> categories = new ArrayList<LexiconCategory>();
private static List<LexiconEntry> allEntries = new ArrayList<LexiconEntry>();
private static List<LexiconCategory> categories = new ArrayList<LexiconCategory>();
private static List<LexiconEntry> allEntries = new ArrayList<LexiconEntry>();
public static List<RecipePetals> petalRecipes = new ArrayList<RecipePetals>();
public static List<RecipeRuneAltar> runeAltarRecipes = new ArrayList<RecipeRuneAltar>();
public static List<RecipeManaInfusion> manaInfusionRecipes = new ArrayList<RecipeManaInfusion>();
public static List<RecipePetals> petalRecipes = new ArrayList<RecipePetals>();
public static List<RecipeRuneAltar> runeAltarRecipes = new ArrayList<RecipeRuneAltar>();
public static List<RecipeManaInfusion> manaInfusionRecipes = new ArrayList<RecipeManaInfusion>();
private static BiMap<String, Class<? extends SubTileEntity>> subTiles = HashBiMap.<String, Class<? extends SubTileEntity>> create();
private static BiMap<String, Class<? extends SubTileEntity>> subTiles = HashBiMap.<String, Class<? extends SubTileEntity>>create();
public static Map<String, Integer> oreWeights = new HashMap<String, Integer>();
public static Map<String, Integer> oreWeights = new HashMap<String, Integer>();
public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18);
public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20);
public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[]{2, 6, 5, 2}, 18);
public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20);
public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[] {3, 8, 6, 3}, 26);
public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 3, 2300, 9F, 3F, 26);
public static ArmorMaterial terrasteelArmorMaterial = EnumHelper.addArmorMaterial("TERRASTEEL", 34, new int[]{3, 8, 6, 3}, 26);
public static ToolMaterial terrasteelToolMaterial = EnumHelper.addToolMaterial("TERRASTEEL", 3, 2300, 9F, 3F, 26);
static {
registerSubTile("", DummySubTile.class);
static {
registerSubTile("", DummySubTile.class);
addOreWeight("oreAluminum", 3940); // Tinkers' Construct
addOreWeight("oreAmber", 2075); // Thaumcraft
addOreWeight("oreApatite", 1595); // Forestry
addOreWeight("oreBlueTopaz", 3195); // Ars Magica
addOreWeight("oreCassiterite", 1634); // GregTech
addOreWeight("oreCertusQuartz", 3975); // Applied Energistics
addOreWeight("oreChimerite", 3970); // Ars Magica
addOreWeight("oreCinnabar", 2585); // Thaumcraft
addOreWeight("oreCoal", 46525); // Vanilla
addOreWeight("oreCooperite", 5); // GregTech
addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc.
addOreWeight("oreDarkIron", 1700); // Factorization
addOreWeight("oreDiamond", 1265); // Vanilla
addOreWeight("oreEmerald", 780); // Vanilla
addOreWeight("oreEmery", 415); // GregTech
addOreWeight("oreGalena", 1000); // Factorization
addOreWeight("oreGold", 2970); // Vanilla
addOreWeight("oreInfusedAir", 925); // Thaumcraft
addOreWeight("oreInfusedEarth", 925); // Thaumcraft
addOreWeight("oreInfusedEntropy", 925); // Thaumcraft
addOreWeight("oreInfusedFire", 925); // Thaumcraft
addOreWeight("oreInfusedOrder", 925); // Thaumcraft
addOreWeight("oreInfusedWater", 925); // Thaumcraft
addOreWeight("oreIridium", 30); // GregTech
addOreWeight("oreIron", 20665); // Vanilla
addOreWeight("oreLapis", 1285); // Vanilla
addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc.
addOreWeight("oreMCropsEssence", 3085); // Magical Crops
addOreWeight("oreNickel", 2275); // Thermal Expansion
addOreWeight("oreOlivine", 1100); // Project RED
addOreWeight("oreRedstone", 6885); // Vanilla
addOreWeight("oreRuby", 1100); // Project RED
addOreWeight("oreSapphire", 1100); // Project RED
addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc.
addOreWeight("oreSphalerite", 25); // GregTech
addOreWeight("oreSulfur", 1105); // Railcraft
addOreWeight("oreTetrahedrite", 4040); // GregTech
addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc.
addOreWeight("oreTungstate", 20); // GregTech
addOreWeight("oreUranium", 1337); // IC2
addOreWeight("oreVinteum", 5925); // Ars Magica
addOreWeight("oreYellorite", 3520); // Big Reactors
}
addOreWeight("oreAluminum", 3940); // Tinkers' Construct
addOreWeight("oreAmber", 2075); // Thaumcraft
addOreWeight("oreApatite", 1595); // Forestry
addOreWeight("oreBlueTopaz", 3195); // Ars Magica
addOreWeight("oreCassiterite", 1634); // GregTech
addOreWeight("oreCertusQuartz", 3975); // Applied Energistics
addOreWeight("oreChimerite", 3970); // Ars Magica
addOreWeight("oreCinnabar", 2585); // Thaumcraft
addOreWeight("oreCoal", 46525); // Vanilla
addOreWeight("oreCooperite", 5); // GregTech
addOreWeight("oreCopper", 8325); // IC2, Thermal Expansion, Tinkers' Construct, etc.
addOreWeight("oreDarkIron", 1700); // Factorization
addOreWeight("oreDiamond", 1265); // Vanilla
addOreWeight("oreEmerald", 780); // Vanilla
addOreWeight("oreEmery", 415); // GregTech
addOreWeight("oreGalena", 1000); // Factorization
addOreWeight("oreGold", 2970); // Vanilla
addOreWeight("oreInfusedAir", 925); // Thaumcraft
addOreWeight("oreInfusedEarth", 925); // Thaumcraft
addOreWeight("oreInfusedEntropy", 925); // Thaumcraft
addOreWeight("oreInfusedFire", 925); // Thaumcraft
addOreWeight("oreInfusedOrder", 925); // Thaumcraft
addOreWeight("oreInfusedWater", 925); // Thaumcraft
addOreWeight("oreIridium", 30); // GregTech
addOreWeight("oreIron", 20665); // Vanilla
addOreWeight("oreLapis", 1285); // Vanilla
addOreWeight("oreLead", 7985); // IC2, Thermal Expansion, Factorization, etc.
addOreWeight("oreMCropsEssence", 3085); // Magical Crops
addOreWeight("oreNickel", 2275); // Thermal Expansion
addOreWeight("oreOlivine", 1100); // Project RED
addOreWeight("oreRedstone", 6885); // Vanilla
addOreWeight("oreRuby", 1100); // Project RED
addOreWeight("oreSapphire", 1100); // Project RED
addOreWeight("oreSilver", 6300); // Thermal Expansion, Factorization, etc.
addOreWeight("oreSphalerite", 25); // GregTech
addOreWeight("oreSulfur", 1105); // Railcraft
addOreWeight("oreTetrahedrite", 4040); // GregTech
addOreWeight("oreTin", 9450); // IC2, Thermal Expansion, etc.
addOreWeight("oreTungstate", 20); // GregTech
addOreWeight("oreUranium", 1337); // IC2
addOreWeight("oreVinteum", 5925); // Ars Magica
addOreWeight("oreYellorite", 3520); // Big Reactors
}
/**
* The internal method handler in use. Do not overwrite.
* @see IInternalMethodHandler
*/
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
/**
* The internal method handler in use. Do not overwrite.
*
* @see IInternalMethodHandler
*/
public static IInternalMethodHandler internalHandler = new DummyMethodHandler();
/**
* Registers a Petal Recipe.
* @param output The ItemStack to craft.
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
* or String (case for Ore Dictionary). The array can't be larger than 16.
* @return The recipe created.
*/
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
RecipePetals recipe = new RecipePetals(output, inputs);
petalRecipes.add(recipe);
return recipe;
}
/**
* Registers a Petal Recipe.
*
* @param output The ItemStack to craft.
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
* or String (case for Ore Dictionary). The array can't be larger than 16.
* @return The recipe created.
*/
public static RecipePetals registerPetalRecipe(ItemStack output, Object... inputs) {
RecipePetals recipe = new RecipePetals(output, inputs);
petalRecipes.add(recipe);
return recipe;
}
/**
* Registers a Rune Altar
* @param output The ItemStack to craft.
* @param mana The amount of mana required. Don't go over 100000!
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
* or String (case for Ore Dictionary). The array can't be larger than 16.
* @return The recipe created.
*/
public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) {
RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs);
runeAltarRecipes.add(recipe);
return recipe;
}
/**
* Registers a Rune Altar
*
* @param output The ItemStack to craft.
* @param mana The amount of mana required. Don't go over 100000!
* @param inputs The objects for crafting. Can be ItemStack, MappableStackWrapper
* or String (case for Ore Dictionary). The array can't be larger than 16.
* @return The recipe created.
*/
public static RecipeRuneAltar registerRuneAltarRecipe(ItemStack output, int mana, Object... inputs) {
RecipeRuneAltar recipe = new RecipeRuneAltar(output, mana, inputs);
runeAltarRecipes.add(recipe);
return recipe;
}
/**
* Registers a Mana Infusion Recipe (throw an item in a mana pool)
* @param output The ItemStack to craft
* @param input The input item, be it an ItemStack or an ore dictionary entry String.
* @param mana The amount of mana required. Don't go over 100000!
* @return The recipe created.
*/
public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana);
manaInfusionRecipes.add(recipe);
return recipe;
}
/**
* Registers a Mana Infusion Recipe (throw an item in a mana pool)
*
* @param output The ItemStack to craft
* @param input The input item, be it an ItemStack or an ore dictionary entry String.
* @param mana The amount of mana required. Don't go over 100000!
* @return The recipe created.
*/
public static RecipeManaInfusion registerManaInfusionRecipe(ItemStack output, Object input, int mana) {
RecipeManaInfusion recipe = new RecipeManaInfusion(output, input, mana);
manaInfusionRecipes.add(recipe);
return recipe;
}
public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) {
subTiles.put(key, subtileClass);
}
public static void registerSubTile(String key, Class<? extends SubTileEntity> subtileClass) {
subTiles.put(key, subtileClass);
}
/**
* Adds a category to the list of registered categories to appear in the Lexicon.
*/
public static void addCategory(LexiconCategory category) {
categories.add(category);
}
/**
* Adds a category to the list of registered categories to appear in the Lexicon.
*/
public static void addCategory(LexiconCategory category) {
categories.add(category);
}
/**
* Gets all registered categories.
*/
public static List<LexiconCategory> getAllCategories() {
return categories;
}
/**
* Gets all registered categories.
*/
public static List<LexiconCategory> getAllCategories() {
return categories;
}
/**
* Registers a Lexicon Entry and adds it to the category passed in.
*/
public static void addEntry(LexiconEntry entry, LexiconCategory category) {
allEntries.add(entry);
category.entries.add(entry);
}
/**
* Registers a Lexicon Entry and adds it to the category passed in.
*/
public static void addEntry(LexiconEntry entry, LexiconCategory category) {
allEntries.add(entry);
category.entries.add(entry);
}
/**
* Maps an ore (ore dictionary key) to it's weight on the world generation. This
* is used for the Orechid flower. Check the static block in the BotaniaAPI class
* to get the weights for the vanilla blocks.<br>
* Alternatively get the values with the OreDetector mod:<br>
* https://gist.github.com/Vazkii/9493322
*/
public static void addOreWeight(String ore, int weight) {
oreWeights.put(ore, weight);
}
/**
* Maps an ore (ore dictionary key) to it's weight on the world generation. This
* is used for the Orechid flower. Check the static block in the BotaniaAPI class
* to get the weights for the vanilla blocks.<br>
* Alternatively get the values with the OreDetector mod:<br>
* https://gist.github.com/Vazkii/9493322
*/
public static void addOreWeight(String ore, int weight) {
oreWeights.put(ore, weight);
}
public static int getOreWeight(String ore) {
return oreWeights.get(ore);
}
public static int getOreWeight(String ore) {
return oreWeights.get(ore);
}
/**
* Gets the last recipe to have been added to the recipe list.
*/
public static IRecipe getLatestAddedRecipe() {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
return list.get(list.size() - 1);
}
/**
* Gets the last recipe to have been added to the recipe list.
*/
public static IRecipe getLatestAddedRecipe() {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
return list.get(list.size() - 1);
}
/**
* Gets the last x recipes added to the recipe list.
*/
public static List<IRecipe> getLatestAddedRecipes(int x) {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
List<IRecipe> newList = new ArrayList();
for(int i = x - 1; i >= 0; i--)
newList.add(list.get(list.size() - 1 - i));
/**
* Gets the last x recipes added to the recipe list.
*/
public static List<IRecipe> getLatestAddedRecipes(int x) {
List<IRecipe> list = CraftingManager.getInstance().getRecipeList();
List<IRecipe> newList = new ArrayList();
for(int i = x - 1; i >= 0; i--)
newList.add(list.get(list.size() - 1 - i));
return newList;
}
return newList;
}
public static Class<? extends SubTileEntity> getSubTileMapping(String key) {
if(!subTiles.containsKey(key))
key = "";
public static Class<? extends SubTileEntity> getSubTileMapping(String key) {
if(!subTiles.containsKey(key)) key = "";
return subTiles.get(key);
}
return subTiles.get(key);
}
public static String getSubTileStringMapping(Class<? extends SubTileEntity> clazz) {
return subTiles.inverse().get(clazz);
}
public static String getSubTileStringMapping(Class<? extends SubTileEntity> clazz) {
return subTiles.inverse().get(clazz);
}
}
+6 -6
View File
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 20, 2014, 7:05:44 PM (GMT)]
*/
package vazkii.botania.api;
@@ -22,9 +22,9 @@ import vazkii.botania.api.lexicon.LexiconEntry;
*/
public interface ILexiconable {
/**
* Gets the lexicon entry to open at this location. null works too.
*/
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon);
/**
* Gets the lexicon entry to open at this location. null works too.
*/
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 7:12:28 PM (GMT)]
*/
package vazkii.botania.api;
+8 -8
View File
@@ -2,18 +2,18 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 24, 2014, 6:47:53 PM (GMT)]
*/
package vazkii.botania.api;
import net.minecraft.util.ChunkCoordinates;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.ChunkCoordinates;
/**
* Any TileEntity that implements this is technically bound
@@ -22,10 +22,10 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public interface ITileBound {
/**
* Gets where this block is bound to, can return null.
*/
@SideOnly(Side.CLIENT)
public ChunkCoordinates getBinding();
/**
* Gets where this block is bound to, can return null.
*/
@SideOnly(Side.CLIENT)
public ChunkCoordinates getBinding();
}
+3 -3
View File
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 5, 2014, 1:34:44 PM (GMT)]
*/
package vazkii.botania.api;
@@ -21,6 +21,6 @@ import net.minecraft.world.World;
*/
public interface IWandHUD {
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z);
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z);
}
+3 -3
View File
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 5:12:53 PM (GMT)]
*/
package vazkii.botania.api;
@@ -20,6 +20,6 @@ import net.minecraft.world.World;
*/
public interface IWandable {
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side);
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Apr 19, 2014, 7:23:59 PM (GMT)]
*/
package vazkii.botania.api;
@@ -20,6 +20,6 @@ import net.minecraft.world.World;
*/
public interface IWireframeAABBProvider {
public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z);
public AxisAlignedBB getWireframeAABB(World world, int x, int y, int z);
}
@@ -2,48 +2,48 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 7, 2014, 3:47:43 PM (GMT)]
*/
package vazkii.botania.api.internal;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import java.util.ArrayList;
import java.util.List;
public class DummyManaNetwork implements IManaNetwork {
public static final DummyManaNetwork instance = new DummyManaNetwork();
public static final DummyManaNetwork instance = new DummyManaNetwork();
@Override
public void clear() {
// NO-OP
}
@Override
public void clear() {
// NO-OP
}
@Override
public TileEntity getClosestPool(ChunkCoordinates pos, int dimension, int limit) {
return null;
}
@Override
public TileEntity getClosestPool(ChunkCoordinates pos, int dimension, int limit) {
return null;
}
@Override
public TileEntity getClosestCollector(ChunkCoordinates pos, int dimension, int limit) {
return null;
}
@Override
public TileEntity getClosestCollector(ChunkCoordinates pos, int dimension, int limit) {
return null;
}
@Override
public List<TileEntity> getAllCollectorsInWorld(int dim) {
return new ArrayList();
}
@Override
public List<TileEntity> getAllCollectorsInWorld(int dim) {
return new ArrayList();
}
@Override
public List<TileEntity> getAllPoolsInWorld(int dim) {
return new ArrayList();
}
@Override
public List<TileEntity> getAllPoolsInWorld(int dim) {
return new ArrayList();
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:43:03 PM (GMT)]
*/
package vazkii.botania.api.internal;
import java.util.List;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
@@ -24,85 +22,87 @@ import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
import java.util.List;
public class DummyMethodHandler implements IInternalMethodHandler {
@Override
public LexiconPage textPage(String key) {
return dummyPage(key);
}
@Override
public LexiconPage textPage(String key) {
return dummyPage(key);
}
@Override
public LexiconPage imagePage(String key, String resource) {
return dummyPage(key);
}
@Override
public LexiconPage imagePage(String key, String resource) {
return dummyPage(key);
}
@Override
public LexiconPage craftingRecipesPage(String key, List<IRecipe> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage craftingRecipesPage(String key, List<IRecipe> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage craftingRecipePage(String key, IRecipe recipe) {
return dummyPage(key);
}
@Override
public LexiconPage craftingRecipePage(String key, IRecipe recipe) {
return dummyPage(key);
}
@Override
public LexiconPage petalRecipesPage(String key, List<RecipePetals> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage petalRecipesPage(String key, List<RecipePetals> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage petalRecipePage(String key, RecipePetals recipe) {
return dummyPage(key);
}
@Override
public LexiconPage petalRecipePage(String key, RecipePetals recipe) {
return dummyPage(key);
}
@Override
public LexiconPage runeRecipesPage(String key, List<RecipeRuneAltar> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage runeRecipesPage(String key, List<RecipeRuneAltar> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) {
return dummyPage(key);
}
@Override
public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe) {
return dummyPage(key);
}
@Override
public LexiconPage manaInfusionRecipesPage(String key, List<RecipeManaInfusion> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage manaInfusionRecipesPage(String key, List<RecipeManaInfusion> recipes) {
return dummyPage(key);
}
@Override
public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) {
return dummyPage(key);
}
@Override
public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe) {
return dummyPage(key);
}
private LexiconPage dummyPage(String key) {
return new DummyPage(key);
}
private LexiconPage dummyPage(String key) {
return new DummyPage(key);
}
@Override
public ItemStack getSubTileAsStack(String subTile) {
return new ItemStack(Blocks.stone, 0, 0);
}
@Override
public ItemStack getSubTileAsStack(String subTile) {
return new ItemStack(Blocks.stone, 0, 0);
}
@Override
public IIcon getSubTileIconForName(String name) {
return Blocks.red_flower.getIcon(0, 0);
}
@Override
public IIcon getSubTileIconForName(String name) {
return Blocks.red_flower.getIcon(0, 0);
}
@Override
public IManaNetwork getManaNetworkInstance() {
return DummyManaNetwork.instance;
}
@Override
public IManaNetwork getManaNetworkInstance() {
return DummyManaNetwork.instance;
}
@Override
public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
// NO-OP
}
@Override
public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
// NO-OP
}
@Override
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) {
// NO-OP
}
@Override
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m) {
// NO-OP
}
}
@@ -2,18 +2,18 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:41:23 PM (GMT)]
*/
package vazkii.botania.api.internal;
import vazkii.botania.api.lexicon.LexiconPage;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import vazkii.botania.api.lexicon.LexiconPage;
/**
* A dummy page. It does absolutely nothing and is only
@@ -22,14 +22,14 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public class DummyPage extends LexiconPage {
public DummyPage(String unlocalizedName) {
super(unlocalizedName);
}
public DummyPage(String unlocalizedName) {
super(unlocalizedName);
}
@Override
@SideOnly(Side.CLIENT)
public void renderScreen(IGuiLexiconEntry gui, int x, int y) {
// NO-OP
}
@Override
@SideOnly(Side.CLIENT)
public void renderScreen(IGuiLexiconEntry gui, int x, int y) {
// NO-OP
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 24, 2014, 4:17:33 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:48:41 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -20,38 +20,38 @@ import vazkii.botania.api.lexicon.LexiconEntry;
*/
public interface IGuiLexiconEntry {
/**
* Gets the entry currently portrayed in this gui.
*/
public LexiconEntry getEntry();
/**
* Gets the entry currently portrayed in this gui.
*/
public LexiconEntry getEntry();
/**
* Gets the current page the lexicon GUI is browsing.
*/
public int getPageOn();
/**
* Gets the current page the lexicon GUI is browsing.
*/
public int getPageOn();
/**
* Gets the leftmost part of the GUI.
*/
public int getLeft();
/**
* Gets the leftmost part of the GUI.
*/
public int getLeft();
/**
* Gets the topmost part of the GUI.
*/
public int getTop();
/**
* Gets the topmost part of the GUI.
*/
public int getTop();
/**
* Gets the GUI's width.
*/
public int getWidth();
/**
* Gets the GUI's width.
*/
public int getWidth();
/**
* Gets the GUI's height
*/
public int getHeight();
/**
* Gets the GUI's height
*/
public int getHeight();
/**
* Gets the GUI's Z level for rendering.
*/
public float getZLevel();
/**
* Gets the GUI's Z level for rendering.
*/
public float getZLevel();
}
@@ -2,17 +2,17 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:34:34 PM (GMT)]
*/
package vazkii.botania.api.internal;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
@@ -22,8 +22,8 @@ import vazkii.botania.api.lexicon.LexiconPage;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
/**
* Any methods that refer to internal methods in Botania are here.
@@ -34,35 +34,35 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public interface IInternalMethodHandler {
public LexiconPage textPage(String key);
public LexiconPage textPage(String key);
public LexiconPage imagePage(String key, String resource);
public LexiconPage imagePage(String key, String resource);
public LexiconPage craftingRecipesPage(String key, List<IRecipe> recipes);
public LexiconPage craftingRecipesPage(String key, List<IRecipe> recipes);
public LexiconPage craftingRecipePage(String key, IRecipe recipe);
public LexiconPage craftingRecipePage(String key, IRecipe recipe);
public LexiconPage petalRecipesPage(String key, List<RecipePetals> recipes);
public LexiconPage petalRecipesPage(String key, List<RecipePetals> recipes);
public LexiconPage petalRecipePage(String key, RecipePetals recipe);
public LexiconPage petalRecipePage(String key, RecipePetals recipe);
public LexiconPage runeRecipesPage(String key, List<RecipeRuneAltar> recipes);
public LexiconPage runeRecipesPage(String key, List<RecipeRuneAltar> recipes);
public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe);
public LexiconPage runeRecipePage(String key, RecipeRuneAltar recipe);
public LexiconPage manaInfusionRecipesPage(String key, List<RecipeManaInfusion> recipes);
public LexiconPage manaInfusionRecipesPage(String key, List<RecipeManaInfusion> recipes);
public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe);
public LexiconPage manaInfusionRecipePage(String key, RecipeManaInfusion recipe);
public IManaNetwork getManaNetworkInstance();
public IManaNetwork getManaNetworkInstance();
public ItemStack getSubTileAsStack(String subTile);
public ItemStack getSubTileAsStack(String subTile);
public IIcon getSubTileIconForName(String name);
public IIcon getSubTileIconForName(String name);
@SideOnly(Side.CLIENT)
public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res);
@SideOnly(Side.CLIENT)
public void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res);
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m);
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 31, 2014, 4:36:13 PM (GMT)]
*/
package vazkii.botania.api.internal;
@@ -19,42 +19,42 @@ import net.minecraft.util.ChunkCoordinates;
*/
public interface IManaBurst {
public boolean isFake();
public boolean isFake();
public void setMotion(double x, double y, double z);
public void setMotion(double x, double y, double z);
public int getColor();
public int getColor();
public void setColor(int color);
public void setColor(int color);
public int getMana();
public int getMana();
public void setMana(int mana);
public void setMana(int mana);
public int getStartingMana();
public int getStartingMana();
public void setStartingMana(int mana);
public void setStartingMana(int mana);
public int getMinManaLoss();
public int getMinManaLoss();
public void setMinManaLoss(int minManaLoss);
public void setMinManaLoss(int minManaLoss);
public float getManaLossPerTick();
public float getManaLossPerTick();
public void setManaLossPerTick(float mana);
public void setManaLossPerTick(float mana);
public float getGravity();
public float getGravity();
public void setGravity(float gravity);
public void setGravity(float gravity);
public ChunkCoordinates getBurstSourceChunkCoordinates();
public ChunkCoordinates getBurstSourceChunkCoordinates();
public void setBurstSourceCoords(int x, int y, int z);
public void setBurstSourceCoords(int x, int y, int z);
public ItemStack getSourceLens();
public ItemStack getSourceLens();
public void setSourceLens(ItemStack lens);
public void setSourceLens(ItemStack lens);
public boolean hasAlreadyCollidedAt(int x, int y, int z);
public boolean hasAlreadyCollidedAt(int x, int y, int z);
}
@@ -2,65 +2,68 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 7, 2014, 3:39:48 PM (GMT)]
*/
package vazkii.botania.api.internal;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import java.util.List;
/**
* A basic interface for a world's Mana Network.
*
* @see IInternalMethodHandler#getManaNetworkInstance()
*/
public interface IManaNetwork {
/**
* Clears the entire Mana Network of all it's contents, you probably
* don't want to call this unless you have a very good reason.
*/
public void clear();
/**
* Clears the entire Mana Network of all it's contents, you probably
* don't want to call this unless you have a very good reason.
*/
public void clear();
/**
* Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk
* Coordinates passed in, in the given dimension.<br>
* A way of getting the dimension is via worldObj.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.
*/
public TileEntity getClosestCollector(ChunkCoordinates pos, int dim, int limit);
/**
* Gets the closest Mana Collector (eg. Mana Spreader) in the network to the Chunk
* Coordinates passed in, in the given dimension.<br>
* A way of getting the dimension is via worldObj.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.
*/
public TileEntity getClosestCollector(ChunkCoordinates pos, int dim, int limit);
/**
* Gets the closest Mana Pool in the network to the Chunk Coordinates passed in,
* in the given dimension.<br>
* A way of getting the dimension is via worldObj.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.
*/
public TileEntity getClosestPool(ChunkCoordinates pos, int dim, int limit);
/**
* Gets the closest Mana Pool in the network to the Chunk Coordinates passed in,
* in the given dimension.<br>
* A way of getting the dimension is via worldObj.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.
*/
public TileEntity getClosestPool(ChunkCoordinates pos, int dim, int limit);
/**
* Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension
* passed in. Note that this is the actual list and not a copy, make sure to
* clone the list if you intend to change it in any way.
*/
public List<TileEntity> getAllCollectorsInWorld(int dim);
/**
* Gets the list of all Mana Collectors (eg. Mana Spreader) in the dimension
* passed in. Note that this is the actual list and not a copy, make sure to
* clone the list if you intend to change it in any way.
*/
public List<TileEntity> getAllCollectorsInWorld(int dim);
/**
* Gets the list of all Mana Pools in the dimension passed in. Note that this
* is the actual list and not a copy, make sure to clone the list if you intend
* to change it in any way.
*/
public List<TileEntity> getAllPoolsInWorld(int dim);
/**
* Gets the list of all Mana Pools in the dimension passed in. Note that this
* is the actual list and not a copy, make sure to clone the list if you intend
* to change it in any way.
*/
public List<TileEntity> getAllPoolsInWorld(int dim);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 20, 2014, 6:08:48 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
@@ -19,6 +19,6 @@ import net.minecraft.item.ItemStack;
*/
public interface IRecipeKeyProvider {
public String getKey(ItemStack stack);
public String getKey(ItemStack stack);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:23:47 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
@@ -16,17 +16,17 @@ import java.util.List;
public final class LexiconCategory {
public final String unlocalizedName;
public final List<LexiconEntry> entries = new ArrayList<LexiconEntry>();
public final String unlocalizedName;
public final List<LexiconEntry> entries = new ArrayList<LexiconEntry>();
/**
* @param unlocalizedName The unlocalized name of this category. This will be localized by the client display.
*/
public LexiconCategory(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
/**
* @param unlocalizedName The unlocalized name of this category. This will be localized by the client display.
*/
public LexiconCategory(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
}
@@ -2,78 +2,78 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:17:06 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.util.StatCollector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.util.StatCollector;
public class LexiconEntry implements Comparable<LexiconEntry> {
public class LexiconEntry implements Comparable<LexiconEntry>{
public final String unlocalizedName;
public final LexiconCategory category;
public final String unlocalizedName;
public final LexiconCategory category;
public List<LexiconPage> pages = new ArrayList<LexiconPage>();
private boolean priority = false;
public List<LexiconPage> pages = new ArrayList<LexiconPage>();
private boolean priority = false;
/**
* @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display.
*/
public LexiconEntry(String unlocalizedName, LexiconCategory category) {
this.unlocalizedName = unlocalizedName;
this.category = category;
}
/**
* @param unlocalizedName The unlocalized name of this entry. This will be localized by the client display.
*/
public LexiconEntry(String unlocalizedName, LexiconCategory category) {
this.unlocalizedName = unlocalizedName;
this.category = category;
}
/**
* Sets this page as prioritized, as in, will appear before others in the lexicon.
*/
public LexiconEntry setPriority() {
priority = true;
return this;
}
/**
* Sets this page as prioritized, as in, will appear before others in the lexicon.
*/
public LexiconEntry setPriority() {
priority = true;
return this;
}
public boolean isPriority() {
return priority;
}
public boolean isPriority() {
return priority;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
/**
* Sets what pages you want this entry to have.
*/
public LexiconEntry setLexiconPages(LexiconPage... pages) {
this.pages.addAll(Arrays.asList(pages));
/**
* Sets what pages you want this entry to have.
*/
public LexiconEntry setLexiconPages(LexiconPage... pages) {
this.pages.addAll(Arrays.asList(pages));
for(int i = 0; i < this.pages.size(); i++)
this.pages.get(i).onPageAdded(this, i);
for(int i = 0; i < this.pages.size(); i++)
this.pages.get(i).onPageAdded(this, i);
return this;
}
return this;
}
/**
* Adds a page to the list of pages.
*/
public void addPage(LexiconPage page) {
pages.add(page);
}
/**
* Adds a page to the list of pages.
*/
public void addPage(LexiconPage page) {
pages.add(page);
}
public final String getNameForSorting() {
return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName());
}
public final String getNameForSorting() {
return (priority ? 0 : 1) + StatCollector.translateToLocal(getUnlocalizedName());
}
@Override
public int compareTo(LexiconEntry o) {
return getNameForSorting().compareTo(o.getNameForSorting());
}
@Override
public int compareTo(LexiconEntry o) {
return getNameForSorting().compareTo(o.getNameForSorting());
}
}
@@ -2,52 +2,53 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:17:24 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import vazkii.botania.api.internal.IGuiLexiconEntry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import vazkii.botania.api.internal.IGuiLexiconEntry;
public abstract class LexiconPage {
public String unlocalizedName;
public String unlocalizedName;
public LexiconPage(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
public LexiconPage(String unlocalizedName) {
this.unlocalizedName = unlocalizedName;
}
/**
* Does the rendering for this page.
* @param gui The active GuiScreen
* @param mx The mouse's relative X position.
* @param my The mouse's relative Y position.
*/
@SideOnly(Side.CLIENT)
public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my);
/**
* Does the rendering for this page.
*
* @param gui The active GuiScreen
* @param mx The mouse's relative X position.
* @param my The mouse's relative Y position.
*/
@SideOnly(Side.CLIENT)
public abstract void renderScreen(IGuiLexiconEntry gui, int mx, int my);
/**
* Called per update tick.
*/
@SideOnly(Side.CLIENT)
public void updateScreen() {
// NO-OP
}
/**
* Called per update tick.
*/
@SideOnly(Side.CLIENT)
public void updateScreen() {
// NO-OP
}
/**
* Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called.
*/
public void onPageAdded(LexiconEntry entry, int index) {
// NO-OP
}
/**
* Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called.
*/
public void onPageAdded(LexiconEntry entry, int index) {
// NO-OP
}
public String getUnlocalizedName() {
return unlocalizedName;
}
public String getUnlocalizedName() {
return unlocalizedName;
}
}
@@ -2,20 +2,20 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 6, 2014, 3:54:12 PM (GMT)]
*/
package vazkii.botania.api.lexicon;
import net.minecraft.item.ItemStack;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.item.ItemStack;
/**
* This class contains mappings for which entry and page correspond to each
* craftable ItemStack. Use the map method to map an ItemStack to a page in
@@ -23,44 +23,43 @@ import net.minecraft.item.ItemStack;
*/
public final class LexiconRecipeMappings {
private static Map<String, EntryData> mappings = new HashMap();
private static Map<String, EntryData> mappings = new HashMap();
/**
* Maps the given stack to the given page of the entry.
*/
public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) {
EntryData data = new EntryData(entry, page);
String str = stackToString(stack);
/**
* Maps the given stack to the given page of the entry.
*/
public static void map(ItemStack stack, LexiconEntry entry, int page, boolean force) {
EntryData data = new EntryData(entry, page);
String str = stackToString(stack);
if(force || !mappings.containsKey(str))
mappings.put(str, data);
}
if(force || !mappings.containsKey(str)) mappings.put(str, data);
}
public static void map(ItemStack stack, LexiconEntry entry, int page) {
map(stack, entry, page, false);
}
public static void map(ItemStack stack, LexiconEntry entry, int page) {
map(stack, entry, page, false);
}
public static EntryData getDataForStack(ItemStack stack) {
return mappings.get(stackToString(stack));
}
public static EntryData getDataForStack(ItemStack stack) {
return mappings.get(stackToString(stack));
}
public static String stackToString(ItemStack stack) {
if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
public static String stackToString(ItemStack stack) {
if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider)
return ((IRecipeKeyProvider) stack.getItem()).getKey(stack);
return stack.getUnlocalizedName() + "~" + stack.getItemDamage();
}
return stack.getUnlocalizedName() + "~" + stack.getItemDamage();
}
public static class EntryData {
public static class EntryData {
public final LexiconEntry entry;
public final int page;
public final LexiconEntry entry;
public final int page;
public EntryData(LexiconEntry entry, int page) {
this.entry = entry;
this.page = page;
}
public EntryData(LexiconEntry entry, int page) {
this.entry = entry;
this.page = page;
}
}
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 31, 2014, 3:49:30 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -17,21 +17,21 @@ package vazkii.botania.api.mana;
*/
public final class BurstProperties {
public int maxMana;
public int ticksBeforeManaLoss;
public float manaLossPerTick;
public float gravity;
public float motionModifier;
public int maxMana;
public int ticksBeforeManaLoss;
public float manaLossPerTick;
public float gravity;
public float motionModifier;
public int color;
public int color;
public BurstProperties(int maxMana, int ticksBeforeManaLoss, float manaLossPerTick, float gravity, float motionModifier, int color) {
this.maxMana = maxMana;
this.ticksBeforeManaLoss = ticksBeforeManaLoss;
this.manaLossPerTick = manaLossPerTick;
this.gravity = gravity;
this.motionModifier = motionModifier;
this.color = color;
}
public BurstProperties(int maxMana, int ticksBeforeManaLoss, float manaLossPerTick, float gravity, float motionModifier, int color) {
this.maxMana = maxMana;
this.ticksBeforeManaLoss = ticksBeforeManaLoss;
this.manaLossPerTick = manaLossPerTick;
this.gravity = gravity;
this.motionModifier = motionModifier;
this.color = color;
}
}
+20 -22
View File
@@ -2,44 +2,42 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 31, 2014, 3:03:04 PM (GMT)]
*/
package vazkii.botania.api.mana;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import vazkii.botania.api.internal.IManaBurst;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.item.ItemStack;
/**
* Have an Item implement this to be counted as a lens for the mana spreader.
*/
public interface ILens extends ILensEffect {
@SideOnly(Side.CLIENT)
public int getLensColor(ItemStack stack);
@SideOnly(Side.CLIENT)
public int getLensColor(ItemStack stack);
/**
* Can the source lens be combined with the composite lens? This is called
* for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens.
*/
public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens);
/**
* Gets the composite lens in the stack passed in, return null for none.
*/
public ItemStack getCompositeLens(ItemStack stack);
/**
* Can the source lens be combined with the composite lens? This is called
* for both the ILens instance of ItemStack.getItem() of sourceLens and compositeLens.
*/
public boolean canCombineLenses(ItemStack sourceLens, ItemStack compositeLens);
/**
* Sets the composite lens for the sourceLens as the compositeLens, returns
* the ItemStack with the combination.
*/
public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens);
/**
* Gets the composite lens in the stack passed in, return null for none.
*/
public ItemStack getCompositeLens(ItemStack stack);
/**
* Sets the composite lens for the sourceLens as the compositeLens, returns
* the ItemStack with the combination.
*/
public ItemStack setCompositeLens(ItemStack sourceLens, ItemStack compositeLens);
}
+25 -24
View File
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Apr 14, 2014, 7:30:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -21,29 +21,30 @@ import vazkii.botania.api.internal.IManaBurst;
*/
public interface ILensEffect {
/**
* Called when a mana spreader that has this focus shoots a burst. This is where
* you change the properties of the burst.
*/
public void apply(ItemStack stack, BurstProperties props);
/**
* Called when a mana spreader that has this focus shoots a burst. This is where
* you change the properties of the burst.
*/
public void apply(ItemStack stack, BurstProperties props);
/**
* 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, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack);
/**
* 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, MovingObjectPosition pos, boolean isManaBlock, boolean dead, ItemStack stack);
/**
* Called when a mana burst fired from a mana spreader with this focus is updated.
* This is called before the update is handled.
*/
public void updateBurst(IManaBurst burst, ItemStack stack);
/**
* Called when a mana burst fired from a mana spreader with this focus is updated.
* This is called before the update is handled.
*/
public void updateBurst(IManaBurst burst, ItemStack stack);
/**
* Called when the mana burst should do it's particles. Return false to not
* do any particles.
*/
public boolean doParticles(IManaBurst burst, ItemStack stack);
/**
* Called when the mana burst should do it's particles. Return false to not
* do any particles.
*/
public boolean doParticles(IManaBurst burst, ItemStack stack);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 4:59:05 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -18,9 +18,9 @@ package vazkii.botania.api.mana;
*/
public interface IManaBlock {
/**
* Gets the amount of mana currently in this block.
*/
public int getCurrentMana();
/**
* Gets the amount of mana currently in this block.
*/
public int getCurrentMana();
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 5:01:19 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -16,23 +16,23 @@ 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>
*
* <p/>
* <b>Implementation Instructions:</b><br>
* - Override invalidate() and onChunkUnload(), calling <i>ManaNetworkEvent.removeCollector(this);</i> on both.<br>
* - On the first tick of onUpdate(), call </i>ManaNetworkEvent.addCollector(this);<i>
*/
public interface IManaCollector extends IManaReceiver {
/**
* Called every tick on the client case the player is holding a Wand of the Forest.
*/
public void onClientDisplayTick();
/**
* Called every tick on the client case the player is holding a Wand of the Forest.
*/
public void onClientDisplayTick();
/**
* Get the multiplier of mana to input into the block, 1.0 is the original amount of mana
* in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get
* dissipated.
*/
public float getManaYieldMultiplier(IManaBurst burst);
/**
* Get the multiplier of mana to input into the block, 1.0 is the original amount of mana
* in the burst. 0.9, for example, is 90%, so 10% of the mana in the burst will get
* dissipated.
*/
public float getManaYieldMultiplier(IManaBurst burst);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 10, 2014, 7:49:19 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -17,6 +17,6 @@ package vazkii.botania.api.mana;
*/
public interface IManaCollisionGhost {
public boolean isGhost();
public boolean isGhost();
}
+38 -36
View File
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 6, 2014, 9:07:40 AM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -20,45 +20,47 @@ import net.minecraft.tileentity.TileEntity;
*/
public interface IManaItem {
/**
* Gets the amount of mana this item contains
*/
public int getMana(ItemStack stack);
/**
* Gets the amount of mana this item contains
*/
public int getMana(ItemStack stack);
/**
* Gets the max amount of mana this item can hold.
*/
public int getMaxMana(ItemStack stack);
/**
* Gets the max amount of mana this item can hold.
*/
public int getMaxMana(ItemStack stack);
/**
* Adds mana to this item.
*/
public void addMana(ItemStack stack, int mana);
/**
* Adds mana to this item.
*/
public void addMana(ItemStack stack, int mana);
/**
* 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()
*/
public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool);
/**
* 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()
*/
public boolean canReceiveManaFromPool(ItemStack stack, TileEntity pool);
/**
* Can this item recieve mana from another item?
* The getItem() of both stacks can be casted to IManaItem.
*/
public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack);
/**
* Can this item recieve mana from another item?
* The getItem() of both stacks can be casted to IManaItem.
*/
public boolean canReceiveManaFromItem(ItemStack stack, ItemStack otherStack);
/**
* 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()
*/
public boolean canExportManaToPool(ItemStack stack,TileEntity pool);
/**
* 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()
*/
public boolean canExportManaToPool(ItemStack stack, TileEntity pool);
/**
* Can this item export mana to another item?
* The getItem() of both stacks can be casted to IManaItem.
*/
public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack);
/**
* Can this item export mana to another item?
* The getItem() of both stacks can be casted to IManaItem.
*/
public boolean canExportManaToItem(ItemStack stack, ItemStack otherStack);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 5:03:09 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -15,17 +15,17 @@ package vazkii.botania.api.mana;
* 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>
*
* <p/>
* <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>
*/
public interface IManaPool extends IManaReceiver {
/**
* Returns false if the mana pool is accepting power from other power items,
* true if it's sending power into them.
*/
public boolean isOutputtingPower();
/**
* Returns false if the mana pool is accepting power from other power items,
* true if it's sending power into them.
*/
public boolean isOutputtingPower();
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 4:55:00 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -16,20 +16,20 @@ package vazkii.botania.api.mana;
*/
public interface IManaReceiver extends IManaBlock {
/**
* Is this Mana Receiver is full? Being full means no mana bursts will be sent.
*/
public boolean isFull();
/**
* Is this Mana Receiver is full? Being full means no mana bursts will be sent.
*/
public boolean isFull();
/**
* Called when this receiver receives mana.
*/
public void recieveMana(int mana);
/**
* Called when this receiver receives mana.
*/
public void recieveMana(int mana);
/**
* Can this tile receive mana from bursts? Generally set to false for
* implementations of IManaCollector.
*/
public boolean canRecieveManaFromBursts();
/**
* Can this tile receive mana from bursts? Generally set to false for
* implementations of IManaCollector.
*/
public boolean canRecieveManaFromBursts();
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 13, 2014, 5:32:24 PM (GMT)]
*/
package vazkii.botania.api.mana;
@@ -16,72 +16,68 @@ import net.minecraft.item.ItemStack;
public final class ManaItemHandler {
/**
* Requests mana from items in a given player's inventory. Note that stack.getItem()
* must be instanceof IManaItem.
* @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, EntityPlayer player, int manaToGet, boolean remove) {
if(stack == null)
return 0;
/**
* Requests mana from items in a given player's inventory. Note that stack.getItem()
* must be instanceof IManaItem.
*
* @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, EntityPlayer player, int manaToGet, boolean remove) {
if(stack == null) return 0;
for(ItemStack stackInSlot : player.inventory.mainInventory) {
if(stackInSlot == stack)
continue;
for(ItemStack stackInSlot : player.inventory.mainInventory) {
if(stackInSlot == stack) continue;
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
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))
continue;
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
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))
continue;
int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot));
int mana = Math.min(manaToGet, manaItem.getMana(stackInSlot));
if(remove)
manaItem.addMana(stackInSlot, -mana);
if(remove) manaItem.addMana(stackInSlot, -mana);
return mana;
}
}
}
return mana;
}
}
}
return 0;
}
return 0;
}
/**
* Requests an exact amount of mana from items in a given player's inventory.
* Note that stack.getItem() must be instanceof IManaItem.
* @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, EntityPlayer player, int manaToGet, boolean remove) {
if(stack == null)
return false;
/**
* Requests an exact amount of mana from items in a given player's inventory.
* Note that stack.getItem() must be instanceof IManaItem.
*
* @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, EntityPlayer player, int manaToGet, boolean remove) {
if(stack == null) return false;
for(ItemStack stackInSlot : player.inventory.mainInventory) {
if(stackInSlot == stack)
continue;
for(ItemStack stackInSlot : player.inventory.mainInventory) {
if(stackInSlot == stack) continue;
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
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))
continue;
if(stackInSlot != null && stackInSlot.getItem() instanceof IManaItem) {
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))
continue;
if(remove)
manaItemSlot.addMana(stackInSlot, -manaToGet);
if(remove) manaItemSlot.addMana(stackInSlot, -manaToGet);
return true;
}
}
}
return true;
}
}
}
return false;
}
return false;
}
}
@@ -2,56 +2,56 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 5:04:30 PM (GMT)]
*/
package vazkii.botania.api.mana;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.eventhandler.Event;
public class ManaNetworkEvent extends Event {
public final TileEntity tile;
public final ManaBlockType type;
public final Action action;
public final TileEntity tile;
public final ManaBlockType type;
public final Action action;
public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) {
this.tile = tile;
this.type = type;
this.action = action;
}
public ManaNetworkEvent(TileEntity tile, ManaBlockType type, Action action) {
this.tile = tile;
this.type = type;
this.action = action;
}
public static void addCollector(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD);
MinecraftForge.EVENT_BUS.post(event);
}
public static void addCollector(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.ADD);
MinecraftForge.EVENT_BUS.post(event);
}
public static void removeCollector(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE);
MinecraftForge.EVENT_BUS.post(event);
}
public static void removeCollector(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.COLLECTOR, Action.REMOVE);
MinecraftForge.EVENT_BUS.post(event);
}
public static void addPool(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD);
MinecraftForge.EVENT_BUS.post(event);
}
public static void addPool(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.ADD);
MinecraftForge.EVENT_BUS.post(event);
}
public static void removePool(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE);
MinecraftForge.EVENT_BUS.post(event);
}
public static void removePool(TileEntity tile) {
ManaNetworkEvent event = new ManaNetworkEvent(tile, ManaBlockType.POOL, Action.REMOVE);
MinecraftForge.EVENT_BUS.post(event);
}
public enum ManaBlockType {
POOL, COLLECTOR
}
public enum ManaBlockType {
POOL, COLLECTOR
}
public enum Action {
REMOVE, ADD
}
public enum Action {
REMOVE, ADD
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 15, 2014, 2:36:35 PM (GMT)]
*/
package vazkii.botania.api.recipe;
@@ -19,8 +19,8 @@ import net.minecraft.item.ItemStack;
*/
public interface IFlowerComponent {
public boolean canFit(ItemStack stack, IInventory apothecary);
public boolean canFit(ItemStack stack, IInventory apothecary);
public int getParticleColor(ItemStack stack);
public int getParticleColor(ItemStack stack);
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 30, 2014, 5:57:07 PM (GMT)]
*/
package vazkii.botania.api.recipe;
@@ -16,34 +16,33 @@ import net.minecraftforge.oredict.OreDictionary;
public class RecipeManaInfusion {
ItemStack output;
Object input;
int mana;
ItemStack output;
Object input;
int mana;
public RecipeManaInfusion(ItemStack output, Object input, int mana) {
this.output = output;
this.input = input;
this.mana = mana;
}
public RecipeManaInfusion(ItemStack output, Object input, int mana) {
this.output = output;
this.input = input;
this.mana = mana;
}
public boolean matches(ItemStack stack) {
if(input instanceof ItemStack)
return stack.isItemEqual((ItemStack) input);
public boolean matches(ItemStack stack) {
if(input instanceof ItemStack) return stack.isItemEqual((ItemStack) input);
String oredict = OreDictionary.getOreName(OreDictionary.getOreID(stack));
return oredict.equals(input);
}
String oredict = OreDictionary.getOreName(OreDictionary.getOreID(stack));
return oredict.equals(input);
}
public Object getInput() {
return input;
}
public Object getInput() {
return input;
}
public ItemStack getOutput() {
return output;
}
public ItemStack getOutput() {
return output;
}
public int getManaToConsume() {
return mana;
}
public int getManaToConsume() {
return mana;
}
}
@@ -2,83 +2,79 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 2:02:44 PM (GMT)]
*/
package vazkii.botania.api.recipe;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
public class RecipePetals {
ItemStack output;
List<Object> inputs;
ItemStack output;
List<Object> inputs;
public RecipePetals(ItemStack output, Object... inputs) {
this.output = output;
public RecipePetals(ItemStack output, Object... inputs) {
this.output = output;
List<Object> inputsToSet = new ArrayList();
for(Object obj : inputs) {
if(obj instanceof String || obj instanceof ItemStack)
inputsToSet.add(obj);
else throw new IllegalArgumentException("Invalid input");
}
List<Object> inputsToSet = new ArrayList();
for(Object obj : inputs) {
if(obj instanceof String || obj instanceof ItemStack) inputsToSet.add(obj);
else throw new IllegalArgumentException("Invalid input");
}
this.inputs = inputsToSet;
}
this.inputs = inputsToSet;
}
public boolean matches(IInventory inv) {
List<Object> inputsMissing = new ArrayList(inputs);
public boolean matches(IInventory inv) {
List<Object> inputsMissing = new ArrayList(inputs);
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null)
break;
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack == null) break;
String oredict = OreDictionary.getOreName(OreDictionary.getOreID(stack));
String oredict = OreDictionary.getOreName(OreDictionary.getOreID(stack));
int stackIndex = -1, oredictIndex = -1;
int stackIndex = -1, oredictIndex = -1;
for(int j = 0; j < inputsMissing.size(); j++) {
Object input = inputsMissing.get(j);
if(input instanceof String && input.equals(oredict)) {
oredictIndex = j;
break;
} else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) {
stackIndex = j;
break;
}
}
for(int j = 0; j < inputsMissing.size(); j++) {
Object input = inputsMissing.get(j);
if(input instanceof String && input.equals(oredict)) {
oredictIndex = j;
break;
} else if(input instanceof ItemStack && simpleAreStacksEqual((ItemStack) input, stack)) {
stackIndex = j;
break;
}
}
if(stackIndex != -1)
inputsMissing.remove(stackIndex);
else if(oredictIndex != -1)
inputsMissing.remove(oredictIndex);
else return false;
}
if(stackIndex != -1) inputsMissing.remove(stackIndex);
else if(oredictIndex != -1) inputsMissing.remove(oredictIndex);
else return false;
}
return inputsMissing.isEmpty();
}
return inputsMissing.isEmpty();
}
boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) {
return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage();
}
boolean simpleAreStacksEqual(ItemStack stack, ItemStack stack2) {
return stack.getItem() == stack2.getItem() && stack.getItemDamage() == stack2.getItemDamage();
}
public List<Object> getInputs() {
return new ArrayList(inputs);
}
public List<Object> getInputs() {
return new ArrayList(inputs);
}
public ItemStack getOutput() {
return output;
}
public ItemStack getOutput() {
return output;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 5, 2014, 1:41:14 PM (GMT)]
*/
package vazkii.botania.api.recipe;
@@ -15,17 +15,17 @@ import net.minecraft.item.ItemStack;
public class RecipeRuneAltar extends RecipePetals {
ItemStack output;
int mana;
ItemStack output;
int mana;
public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) {
super(output, inputs);
this.output = output;
this.mana = mana;
}
public RecipeRuneAltar(ItemStack output, int mana, Object... inputs) {
super(output, inputs);
this.output = output;
this.mana = mana;
}
public int getManaUsage() {
return mana;
}
public int getManaUsage() {
return mana;
}
}
@@ -2,15 +2,17 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 24, 2014, 3:59:06 PM (GMT)]
*/
package vazkii.botania.api.subtile;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
@@ -21,8 +23,6 @@ import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.IIcon;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconEntry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* A Sub-TileEntity, this is used for the flower system. Make sure to map subclasses
@@ -31,80 +31,85 @@ import cpw.mods.fml.relauncher.SideOnly;
*/
public class SubTileEntity {
protected TileEntity supertile;
protected TileEntity supertile;
/** The Tag items should use to store which sub tile they are. **/
public static final String TAG_TYPE = "type";
/**
* The Tag items should use to store which sub tile they are. *
*/
public static final String TAG_TYPE = "type";
public void setSupertile(TileEntity tile) {
supertile = tile;
}
public void setSupertile(TileEntity tile) {
supertile = tile;
}
public boolean canUpdate() {
return false;
}
public boolean canUpdate() {
return false;
}
public void onUpdate() { }
public void onUpdate() {
}
/**
* Writes some extra data to a network packet. This data is read
* by readFromPacketNBT on the client that receives the packet.
* Note: This method is also used to write to the world NBT.
*/
public void writeToPacketNBT(NBTTagCompound cmp) { }
/**
* Writes some extra data to a network packet. This data is read
* by readFromPacketNBT on the client that receives the packet.
* Note: This method is also used to write to the world NBT.
*/
public void writeToPacketNBT(NBTTagCompound cmp) {
}
/**
* Reads data from a network packet. This data is written by
* writeToPacketNBT in the server. Note: This method is also used
* to read from the world NBT.
*/
public void readFromPacketNBT(NBTTagCompound cmp) { }
/**
* Reads data from a network packet. This data is written by
* writeToPacketNBT in the server. Note: This method is also used
* to read from the world NBT.
*/
public void readFromPacketNBT(NBTTagCompound cmp) {
}
public void sync() {
supertile.getWorldObj().markBlockForUpdate(supertile.xCoord, supertile.yCoord, supertile.zCoord);
}
public String getUnlocalizedName() {
return BotaniaAPI.getSubTileStringMapping(getClass());
}
public void sync() {
supertile.getWorldObj().markBlockForUpdate(supertile.xCoord, supertile.yCoord, supertile.zCoord);
}
/**
* Gets the icon for this SubTileEntity, this is a block icon.
*/
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName());
}
public String getUnlocalizedName() {
return BotaniaAPI.getSubTileStringMapping(getClass());
}
/**
* Called when a Wand of the Forest is used on this sub tile.
*/
public boolean onWanded(EntityPlayer player, ItemStack wand) {
return false;
}
/**
* Gets the icon for this SubTileEntity, this is a block icon.
*/
@SideOnly(Side.CLIENT)
public IIcon getIcon() {
return BotaniaAPI.internalHandler.getSubTileIconForName(getUnlocalizedName());
}
/**
* Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon.
*/
public LexiconEntry getEntry() {
return null;
}
/**
* Called when a Wand of the Forest is used on this sub tile.
*/
public boolean onWanded(EntityPlayer player, ItemStack wand) {
return false;
}
/**
* Gets the block coordinates this is bound to, for use with the wireframe render
* when the sub tile is being hovered with a wand of the forest.
*/
@SideOnly(Side.CLIENT)
public ChunkCoordinates getBinding() {
return null;
}
/**
* Gets which Lexicon Entry to open when this sub tile is right clicked with a lexicon.
*/
public LexiconEntry getEntry() {
return null;
}
/**
* Called on the client when the block being pointed at is the one with this sub tile.
* Used to render a HUD portraying some data from this sub tile.
*/
@SideOnly(Side.CLIENT)
public void renderHUD(Minecraft mc, ScaledResolution res) {
// NO-OP
}
/**
* Gets the block coordinates this is bound to, for use with the wireframe render
* when the sub tile is being hovered with a wand of the forest.
*/
@SideOnly(Side.CLIENT)
public ChunkCoordinates getBinding() {
return null;
}
/**
* Called on the client when the block being pointed at is the one with this sub tile.
* Used to render a HUD portraying some data from this sub tile.
*/
@SideOnly(Side.CLIENT)
public void renderHUD(Minecraft mc, ScaledResolution res) {
// NO-OP
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 24, 2014, 8:03:44 PM (GMT)]
*/
package vazkii.botania.api.subtile;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,145 +23,146 @@ import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaNetwork;
import vazkii.botania.api.mana.IManaPool;
import java.awt.*;
/**
* The basic class for a Functional Flower.
*/
public class SubTileFunctional extends SubTileEntity {
private static final String TAG_MANA = "mana";
private static final String TAG_MANA = "mana";
private static final String TAG_POOL_X = "poolX";
private static final String TAG_POOL_Y = "poolY";
private static final String TAG_POOL_Z = "poolZ";
private static final String TAG_POOL_X = "poolX";
private static final String TAG_POOL_Y = "poolY";
private static final String TAG_POOL_Z = "poolZ";
public int mana;
public int mana;
int sizeLastCheck = -1;
TileEntity linkedPool = null;
public int knownMana = -1;
int sizeLastCheck = -1;
TileEntity linkedPool = null;
public int knownMana = -1;
ChunkCoordinates cachedPoolCoordinates = null;
ChunkCoordinates cachedPoolCoordinates = null;
@Override
public boolean canUpdate() {
return true;
}
@Override
public boolean canUpdate() {
return true;
}
@Override
public void onUpdate() {
super.onUpdate();
@Override
public void onUpdate() {
super.onUpdate();
linkPool();
linkPool();
if(linkedPool != null) {
IManaPool pool = (IManaPool) linkedPool;
int manaInPool = pool.getCurrentMana();
int manaMissing = getMaxMana() - mana;
int manaToRemove = Math.min(manaMissing, manaInPool);
pool.recieveMana(-manaToRemove);
addMana(manaToRemove);
}
if(linkedPool != null) {
IManaPool pool = (IManaPool) linkedPool;
int manaInPool = pool.getCurrentMana();
int manaMissing = getMaxMana() - mana;
int manaToRemove = Math.min(manaMissing, manaInPool);
pool.recieveMana(-manaToRemove);
addMana(manaToRemove);
}
if(supertile.getWorldObj().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 2F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
if(supertile.getWorldObj().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 2F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
public void linkPool() {
final int range = 10;
public void linkPool() {
final int range = 10;
boolean needsNew = false;
if(linkedPool == null) {
needsNew = true;
boolean needsNew = false;
if(linkedPool == null) {
needsNew = true;
if(cachedPoolCoordinates != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaPool) {
linkedPool = tileAt;
needsNew = false;
}
cachedPoolCoordinates = null;
}
}
if(cachedPoolCoordinates != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedPoolCoordinates.posX, cachedPoolCoordinates.posY, cachedPoolCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaPool) {
linkedPool = tileAt;
needsNew = false;
}
cachedPoolCoordinates = null;
}
}
if(!needsNew) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
if(!(tileAt instanceof IManaPool)) {
linkedPool = null;
needsNew = true;
} else linkedPool = tileAt;
}
if(!needsNew) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
if(!(tileAt instanceof IManaPool)) {
linkedPool = null;
needsNew = true;
} else linkedPool = tileAt;
}
if(needsNew) {
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
int size = network.getAllPoolsInWorld(supertile.getWorldObj().provider.dimensionId).size();
if(size != sizeLastCheck) {
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord);
linkedPool = network.getClosestPool(coords, supertile.getWorldObj().provider.dimensionId, range);
sizeLastCheck = size;
}
}
}
if(needsNew) {
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
int size = network.getAllPoolsInWorld(supertile.getWorldObj().provider.dimensionId).size();
if(size != sizeLastCheck) {
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord);
linkedPool = network.getClosestPool(coords, supertile.getWorldObj().provider.dimensionId, range);
sizeLastCheck = size;
}
}
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
}
@Override
public boolean onWanded(EntityPlayer player, ItemStack wand) {
knownMana = mana;
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F);
@Override
public boolean onWanded(EntityPlayer player, ItemStack wand) {
knownMana = mana;
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F);
return super.onWanded(player, wand);
}
return super.onWanded(player, wand);
}
public int getMaxMana() {
return 20;
}
public int getMaxMana() {
return 20;
}
public int getColor() {
return 0xFFFFFF;
}
public int getColor() {
return 0xFFFFFF;
}
@Override
public void readFromPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
@Override
public void readFromPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
int x = cmp.getInteger(TAG_POOL_X);
int y = cmp.getInteger(TAG_POOL_Y);
int z = cmp.getInteger(TAG_POOL_Z);
int x = cmp.getInteger(TAG_POOL_X);
int y = cmp.getInteger(TAG_POOL_Y);
int z = cmp.getInteger(TAG_POOL_Z);
cachedPoolCoordinates = new ChunkCoordinates(x, y, z);
}
cachedPoolCoordinates = new ChunkCoordinates(x, y, z);
}
@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
int x = linkedPool == null ? 0 : linkedPool.xCoord;
int y = linkedPool == null ? -1 : linkedPool.yCoord;
int z = linkedPool == null ? 0 : linkedPool.zCoord;
int x = linkedPool == null ? 0 : linkedPool.xCoord;
int y = linkedPool == null ? -1 : linkedPool.yCoord;
int z = linkedPool == null ? 0 : linkedPool.zCoord;
cmp.setInteger(TAG_POOL_X, x);
cmp.setInteger(TAG_POOL_Y, y);
cmp.setInteger(TAG_POOL_Z, z);
}
cmp.setInteger(TAG_POOL_X, x);
cmp.setInteger(TAG_POOL_Y, y);
cmp.setInteger(TAG_POOL_Z, z);
}
@Override
public ChunkCoordinates getBinding() {
if(linkedPool == null)
return null;
return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
}
@Override
public ChunkCoordinates getBinding() {
if(linkedPool == null) return null;
return new ChunkCoordinates(linkedPool.xCoord, linkedPool.yCoord, linkedPool.zCoord);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name");
int color = 0x66000000 | getColor();
BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name");
int color = 0x66000000 | getColor();
BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 24, 2014, 8:03:36 PM (GMT)]
*/
package vazkii.botania.api.subtile;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,176 +23,175 @@ import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.internal.IManaNetwork;
import vazkii.botania.api.mana.IManaCollector;
import java.awt.*;
/**
* The basic class for a Generating Flower.
*/
public class SubTileGenerating extends SubTileEntity {
private static final String TAG_MANA = "mana";
private static final String TAG_MANA = "mana";
private static final String TAG_COLLECTOR_X = "collectorX";
private static final String TAG_COLLECTOR_Y = "collectorY";
private static final String TAG_COLLECTOR_Z = "collectorZ";
private static final String TAG_COLLECTOR_X = "collectorX";
private static final String TAG_COLLECTOR_Y = "collectorY";
private static final String TAG_COLLECTOR_Z = "collectorZ";
protected int mana;
protected int mana;
int sizeLastCheck = -1;
protected TileEntity linkedCollector = null;
public int knownMana = -1;
int sizeLastCheck = -1;
protected TileEntity linkedCollector = null;
public int knownMana = -1;
ChunkCoordinates cachedCollectorCoordinates = null;
ChunkCoordinates cachedCollectorCoordinates = null;
@Override
public boolean canUpdate() {
return true;
}
@Override
public boolean canUpdate() {
return true;
}
@Override
public void onUpdate() {
super.onUpdate();
@Override
public void onUpdate() {
super.onUpdate();
linkCollector();
linkCollector();
if(canGeneratePassively()) {
int delay = getDelayBetweenPassiveGeneration();
if(delay > 0 && supertile.getWorldObj().getWorldTime() % delay == 0) {
if(shouldSyncPassiveGeneration())
sync();
addMana(getValueForPassiveGeneration());
}
emptyManaIntoCollector();
}
if(canGeneratePassively()) {
int delay = getDelayBetweenPassiveGeneration();
if(delay > 0 && supertile.getWorldObj().getWorldTime() % delay == 0) {
if(shouldSyncPassiveGeneration()) sync();
addMana(getValueForPassiveGeneration());
}
emptyManaIntoCollector();
}
if(supertile.getWorldObj().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 2F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
if(supertile.getWorldObj().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 2F;
Color color = new Color(getColor());
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(supertile.getWorldObj(), supertile.xCoord + 0.3 + Math.random() * 0.5, supertile.yCoord + 0.5 + Math.random() * 0.5, supertile.zCoord + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
}
}
public void linkCollector() {
final int range = 4;
public void linkCollector() {
final int range = 4;
boolean needsNew = false;
if(linkedCollector == null) {
needsNew = true;
boolean needsNew = false;
if(linkedCollector == null) {
needsNew = true;
if(cachedCollectorCoordinates != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaCollector) {
linkedCollector = tileAt;
needsNew = false;
}
cachedCollectorCoordinates = null;
}
}
if(cachedCollectorCoordinates != null) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(cachedCollectorCoordinates.posX, cachedCollectorCoordinates.posY, cachedCollectorCoordinates.posZ);
if(tileAt != null && tileAt instanceof IManaCollector) {
linkedCollector = tileAt;
needsNew = false;
}
cachedCollectorCoordinates = null;
}
}
if(!needsNew) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
if(!(tileAt instanceof IManaCollector)) {
linkedCollector = null;
needsNew = true;
} else linkedCollector = tileAt;
}
if(!needsNew) {
TileEntity tileAt = supertile.getWorldObj().getTileEntity(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
if(!(tileAt instanceof IManaCollector)) {
linkedCollector = null;
needsNew = true;
} else linkedCollector = tileAt;
}
if(needsNew) {
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
int size = network.getAllCollectorsInWorld(supertile.getWorldObj().provider.dimensionId).size();
if(size != sizeLastCheck) {
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord);
linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj().provider.dimensionId, range);
sizeLastCheck = size;
}
}
}
if(needsNew) {
IManaNetwork network = BotaniaAPI.internalHandler.getManaNetworkInstance();
int size = network.getAllCollectorsInWorld(supertile.getWorldObj().provider.dimensionId).size();
if(size != sizeLastCheck) {
ChunkCoordinates coords = new ChunkCoordinates(supertile.xCoord, supertile.yCoord, supertile.zCoord);
linkedCollector = network.getClosestCollector(coords, supertile.getWorldObj().provider.dimensionId, range);
sizeLastCheck = size;
}
}
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
}
public void addMana(int mana) {
this.mana = Math.min(getMaxMana(), this.mana + mana);
}
public void emptyManaIntoCollector() {
if(linkedCollector != null) {
IManaCollector collector = (IManaCollector) linkedCollector;
if(!collector.isFull()) {
collector.recieveMana(mana);
mana = 0;
}
}
}
public void emptyManaIntoCollector() {
if(linkedCollector != null) {
IManaCollector collector = (IManaCollector) linkedCollector;
if(!collector.isFull()) {
collector.recieveMana(mana);
mana = 0;
}
}
}
public boolean shouldSyncPassiveGeneration() {
return false;
}
public boolean shouldSyncPassiveGeneration() {
return false;
}
public boolean canGeneratePassively() {
boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering());
return !supertile.getWorldObj().isRemote && supertile.getWorldObj().isDaytime() && !rain && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord);
}
public boolean canGeneratePassively() {
boolean rain = supertile.getWorldObj().getWorldChunkManager().getBiomeGenAt(supertile.xCoord, supertile.zCoord).getIntRainfall() > 0 && (supertile.getWorldObj().isRaining() || supertile.getWorldObj().isThundering());
return !supertile.getWorldObj().isRemote && supertile.getWorldObj().isDaytime() && !rain && supertile.getWorldObj().canBlockSeeTheSky(supertile.xCoord, supertile.yCoord + 1, supertile.zCoord);
}
public int getDelayBetweenPassiveGeneration() {
return 20;
}
public int getDelayBetweenPassiveGeneration() {
return 20;
}
public int getValueForPassiveGeneration() {
return 1;
}
public int getValueForPassiveGeneration() {
return 1;
}
@Override
public boolean onWanded(EntityPlayer player, ItemStack wand) {
if(!player.worldObj.isRemote)
sync();
@Override
public boolean onWanded(EntityPlayer player, ItemStack wand) {
if(!player.worldObj.isRemote) sync();
knownMana = mana;
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F);
knownMana = mana;
player.worldObj.playSoundAtEntity(player, "random.orb", 0.1F, 1F);
return super.onWanded(player, wand);
}
return super.onWanded(player, wand);
}
public int getMaxMana() {
return 20;
}
public int getMaxMana() {
return 20;
}
public int getColor() {
return 0xFFFFFF;
}
public int getColor() {
return 0xFFFFFF;
}
@Override
public void readFromPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
@Override
public void readFromPacketNBT(NBTTagCompound cmp) {
mana = cmp.getInteger(TAG_MANA);
int x = cmp.getInteger(TAG_COLLECTOR_X);
int y = cmp.getInteger(TAG_COLLECTOR_Y);
int z = cmp.getInteger(TAG_COLLECTOR_Z);
int x = cmp.getInteger(TAG_COLLECTOR_X);
int y = cmp.getInteger(TAG_COLLECTOR_Y);
int z = cmp.getInteger(TAG_COLLECTOR_Z);
cachedCollectorCoordinates = new ChunkCoordinates(x, y, z);
}
cachedCollectorCoordinates = new ChunkCoordinates(x, y, z);
}
@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
@Override
public void writeToPacketNBT(NBTTagCompound cmp) {
cmp.setInteger(TAG_MANA, mana);
int x = linkedCollector == null ? 0 : linkedCollector.xCoord;
int y = linkedCollector == null ? -1 : linkedCollector.yCoord;
int z = linkedCollector == null ? 0 : linkedCollector.zCoord;
int x = linkedCollector == null ? 0 : linkedCollector.xCoord;
int y = linkedCollector == null ? -1 : linkedCollector.yCoord;
int z = linkedCollector == null ? 0 : linkedCollector.zCoord;
cmp.setInteger(TAG_COLLECTOR_X, x);
cmp.setInteger(TAG_COLLECTOR_Y, y);
cmp.setInteger(TAG_COLLECTOR_Z, z);
}
cmp.setInteger(TAG_COLLECTOR_X, x);
cmp.setInteger(TAG_COLLECTOR_Y, y);
cmp.setInteger(TAG_COLLECTOR_Z, z);
}
@Override
public ChunkCoordinates getBinding() {
if(linkedCollector == null)
return null;
return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
}
@Override
public ChunkCoordinates getBinding() {
if(linkedCollector == null) return null;
return new ChunkCoordinates(linkedCollector.xCoord, linkedCollector.yCoord, linkedCollector.zCoord);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name");
int color = 0x66000000 | getColor();
BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res) {
String name = StatCollector.translateToLocal("tile.botania:flower." + getUnlocalizedName() + ".name");
int color = 0x66000000 | getColor();
BotaniaAPI.internalHandler.drawSimpleManaHUD(color, knownMana, getMaxMana(), name, res);
}
}
@@ -2,17 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 24, 2014, 7:02:37 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import java.awt.Color;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
@@ -25,116 +24,115 @@ import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.ITileBound;
import vazkii.botania.api.IWireframeAABBProvider;
import vazkii.botania.common.item.ItemTwigWand;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.awt.*;
public final class BoundTileRenderer {
@SubscribeEvent
public void onWorldRenderLast(RenderWorldLastEvent event) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
@SubscribeEvent
public void onWorldRenderLast(RenderWorldLastEvent event) {
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
Tessellator.renderingWorldRenderer = false;
Tessellator.renderingWorldRenderer = false;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
World world = player.worldObj;
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof ItemTwigWand) {
MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver;
if(pos != null) {
TileEntity tile = world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
if(tile != null && tile instanceof ITileBound) {
ChunkCoordinates coords = ((ITileBound) tile).getBinding();
if(coords != null)
renderBlockOutlineAt(coords, Color.HSBtoRGB(world.getTotalWorldTime() % 200 / 200F, 0.6F, 1F));
}
}
}
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
World world = player.worldObj;
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof ItemTwigWand) {
MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver;
if(pos != null) {
TileEntity tile = world.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
if(tile != null && tile instanceof ITileBound) {
ChunkCoordinates coords = ((ITileBound) tile).getBinding();
if(coords != null)
renderBlockOutlineAt(coords, Color.HSBtoRGB(world.getTotalWorldTime() % 200 / 200F, 0.6F, 1F));
}
}
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
private void renderBlockOutlineAt(ChunkCoordinates pos, int color) {
GL11.glPushMatrix();
GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY - RenderManager.renderPosY, pos.posZ - RenderManager.renderPosZ + 1);
Color colorRGB = new Color(color);
GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255);
private void renderBlockOutlineAt(ChunkCoordinates pos, int color) {
GL11.glPushMatrix();
GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY - RenderManager.renderPosY, pos.posZ - RenderManager.renderPosZ + 1);
Color colorRGB = new Color(color);
GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255);
World world = Minecraft.getMinecraft().theWorld;
Block block = world.getBlock(pos.posX, pos.posY, pos.posZ);
drawWireframe : {
if(block != null) {
AxisAlignedBB axis;
World world = Minecraft.getMinecraft().theWorld;
Block block = world.getBlock(pos.posX, pos.posY, pos.posZ);
drawWireframe:
{
if(block != null) {
AxisAlignedBB axis;
if(block instanceof IWireframeAABBProvider)
axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ);
else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ);
if(block instanceof IWireframeAABBProvider)
axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos.posX, pos.posY, pos.posZ);
else axis = block.getSelectedBoundingBoxFromPool(world, pos.posX, pos.posY, pos.posZ);
if(axis == null)
break drawWireframe;
if(axis == null) break drawWireframe;
axis.minX -= pos.posX;
axis.maxX -= pos.posX;
axis.minY -= pos.posY;
axis.maxY -= pos.posY;
axis.minZ -= pos.posZ;
axis.maxZ -= pos.posZ;
axis.minX -= pos.posX;
axis.maxX -= pos.posX;
axis.minY -= pos.posY;
axis.maxY -= pos.posY;
axis.minZ -= pos.posZ;
axis.maxZ -= pos.posZ;
GL11.glTranslated(axis.minX, axis.minY, axis.minZ);
GL11.glScaled(axis.maxX - axis.minX, axis.maxY - axis.minY, axis.maxZ - axis.minZ);
GL11.glTranslated(axis.minX, axis.minY, axis.minZ);
GL11.glScaled(axis.maxX - axis.minX, axis.maxY - axis.minY, axis.maxZ - axis.minZ);
GL11.glLineWidth(1F);
renderBlockOutline();
GL11.glLineWidth(1F);
renderBlockOutline();
GL11.glLineWidth(4F);
GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64);
renderBlockOutline();
}
}
GL11.glLineWidth(4F);
GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64);
renderBlockOutline();
}
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
private void renderBlockOutline() {
Tessellator tessellator = Tessellator.instance;
private void renderBlockOutline() {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawing(GL11.GL_LINES);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 1, -1);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(1, 1, -1);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 1, -1);
tessellator.startDrawing(GL11.GL_LINES);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 1, -1);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(1, 1, -1);
tessellator.addVertex(0, 0, 0);
tessellator.addVertex(0, 0, -1);
tessellator.addVertex(0, 1, 0);
tessellator.addVertex(0, 1, -1);
tessellator.addVertex(1, 0, 0);
tessellator.addVertex(1, 0, -1);
tessellator.addVertex(1, 1, 0);
tessellator.addVertex(1, 1, -1);
tessellator.draw();
}
tessellator.draw();
}
}
@@ -2,77 +2,75 @@
* This class was created by <The TConstruct Team>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.client.core.handler;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraftforge.client.event.RenderPlayerEvent;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibObfuscation;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
public class CapeHandler {
private ArrayList<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
private ArrayList<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
public static CapeHandler instance;
public static CapeHandler instance;
public CapeHandler() {
instance = this;
}
public CapeHandler() {
instance = this;
}
@SubscribeEvent
public void onPreRenderSpecials (RenderPlayerEvent.Specials.Pre event) {
if(Loader.isModLoaded("shadersmod"))
return;
@SubscribeEvent
public void onPreRenderSpecials(RenderPlayerEvent.Specials.Pre event) {
if(Loader.isModLoaded("shadersmod")) return;
if(event.entityPlayer instanceof AbstractClientPlayer && (event.entityPlayer.getCommandSenderName().equals("Vazkii"))) {
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
if(event.entityPlayer instanceof AbstractClientPlayer && (event.entityPlayer.getCommandSenderName().equals("Vazkii"))) {
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
if (!capePlayers.contains(abstractClientPlayer)) {
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, LibObfuscation.TEXTURE_UPLOADED);
new Thread(new CloakThread(abstractClientPlayer)).start();
event.renderCape = true;
}
}
}
if(!capePlayers.contains(abstractClientPlayer)) {
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, LibObfuscation.TEXTURE_UPLOADED);
new Thread(new CloakThread(abstractClientPlayer)).start();
event.renderCape = true;
}
}
}
private class CloakThread implements Runnable {
private class CloakThread implements Runnable {
AbstractClientPlayer abstractClientPlayer;
AbstractClientPlayer abstractClientPlayer;
public CloakThread(AbstractClientPlayer player) {
abstractClientPlayer = player;
}
public CloakThread(AbstractClientPlayer player) {
abstractClientPlayer = player;
}
@Override
public void run() {
try {
BufferedImage bo = ImageIO.read(Botania.class.getResourceAsStream(LibResources.MODEL_CAPE));
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, LibObfuscation.BUFFERED_IMAGE);
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void run() {
try {
BufferedImage bo = ImageIO.read(Botania.class.getResourceAsStream(LibResources.MODEL_CAPE));
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, LibObfuscation.BUFFERED_IMAGE);
} catch(IOException e) {
e.printStackTrace();
}
}
}
public void refreshCapes() {
capePlayers.clear();
}
public void refreshCapes() {
capePlayers.clear();
}
}
@@ -2,19 +2,19 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 3, 2014, 9:59:17 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,65 +25,56 @@ import vazkii.botania.client.core.handler.LightningHandler.LightningBolt;
import vazkii.botania.client.gui.GuiLexicon;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.item.ItemTwigWand;
import vazkii.botania.common.lib.LibMisc;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
import java.util.ArrayList;
import java.util.List;
public class ClientTickHandler {
public static int ticksWithLexicaOpen = 0;
public static int pageFlipTicks = 0;
public static int ticksInGame = 0;
public static int ticksWithLexicaOpen = 0;
public static int pageFlipTicks = 0;
public static int ticksInGame = 0;
@SubscribeEvent
public void tickEnd(ClientTickEvent event) {
if(event.phase == Phase.END && event.type == Type.CLIENT) {
LightningBolt.update();
@SubscribeEvent
public void tickEnd(ClientTickEvent event) {
if(event.phase == Phase.END && event.type == Type.CLIENT) {
LightningBolt.update();
if(Minecraft.getMinecraft().theWorld == null)
ManaNetworkHandler.instance.clear();
if(Minecraft.getMinecraft().theWorld == null) ManaNetworkHandler.instance.clear();
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if(gui == null || !gui.doesGuiPauseGame()) {
ticksInGame++;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null) {
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof ItemTwigWand) {
List<TileEntity> list = new ArrayList(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld.provider.dimensionId));
for(TileEntity tile : list) {
if(tile instanceof IManaCollector)
((IManaCollector) tile).onClientDisplayTick();
}
}
}
}
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
if(gui == null || !gui.doesGuiPauseGame()) {
ticksInGame++;
int ticksToOpen = 10;
if(gui instanceof GuiLexicon) {
if(ticksWithLexicaOpen < 0)
ticksWithLexicaOpen = 0;
if(ticksWithLexicaOpen < ticksToOpen)
ticksWithLexicaOpen++;
if(pageFlipTicks > 0)
pageFlipTicks--;
} else {
pageFlipTicks = 0;
if(ticksWithLexicaOpen > 0) {
if(ticksWithLexicaOpen > ticksToOpen)
ticksWithLexicaOpen = ticksToOpen;
ticksWithLexicaOpen--;
}
}
}
}
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null) {
ItemStack stack = player.getCurrentEquippedItem();
if(stack != null && stack.getItem() instanceof ItemTwigWand) {
List<TileEntity> list = new ArrayList(ManaNetworkHandler.instance.getAllCollectorsInWorld(Minecraft.getMinecraft().theWorld.provider.dimensionId));
for(TileEntity tile : list) {
if(tile instanceof IManaCollector) ((IManaCollector) tile).onClientDisplayTick();
}
}
}
}
public static void notifyPageChange() {
if(pageFlipTicks == 0)
pageFlipTicks = 5;
}
int ticksToOpen = 10;
if(gui instanceof GuiLexicon) {
if(ticksWithLexicaOpen < 0) ticksWithLexicaOpen = 0;
if(ticksWithLexicaOpen < ticksToOpen) ticksWithLexicaOpen++;
if(pageFlipTicks > 0) pageFlipTicks--;
} else {
pageFlipTicks = 0;
if(ticksWithLexicaOpen > 0) {
if(ticksWithLexicaOpen > ticksToOpen) ticksWithLexicaOpen = ticksToOpen;
ticksWithLexicaOpen--;
}
}
}
}
public static void notifyPageChange() {
if(pageFlipTicks == 0) pageFlipTicks = 5;
}
}
@@ -2,17 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 6:11:10 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import java.awt.Color;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@@ -23,103 +22,98 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.ILexiconable;
import vazkii.botania.api.IWandHUD;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.item.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.awt.*;
public final class HUDHandler {
private static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD);
private static final RenderItem itemRender = new RenderItem();
private static final ResourceLocation manaBar = new ResourceLocation(LibResources.GUI_MANA_HUD);
private static final RenderItem itemRender = new RenderItem();
@SubscribeEvent
public void onDrawScreen(RenderGameOverlayEvent.Post event) {
if(event.type == ElementType.ALL) {
Minecraft mc = Minecraft.getMinecraft();
MovingObjectPosition pos = mc.objectMouseOver;
if(pos != null && mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() == ModItems.twigWand) {
Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(block instanceof IWandHUD)
((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ);
}
@SubscribeEvent
public void onDrawScreen(RenderGameOverlayEvent.Post event) {
if(event.type == ElementType.ALL) {
Minecraft mc = Minecraft.getMinecraft();
MovingObjectPosition pos = mc.objectMouseOver;
if(pos != null && mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() == ModItems.twigWand) {
Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(block instanceof IWandHUD)
((IWandHUD) block).renderHUD(mc, event.resolution, mc.theWorld, pos.blockX, pos.blockY, pos.blockZ);
} else if(pos != null && mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() == ModItems.lexicon) {
Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(block instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) block).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem());
if(entry != null) drawLexiconGUI(entry, event.resolution);
}
}
}
}
else if(pos != null && mc.thePlayer.getCurrentEquippedItem() != null && mc.thePlayer.getCurrentEquippedItem().getItem() == ModItems.lexicon) {
Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
if(block instanceof ILexiconable) {
LexiconEntry entry = ((ILexiconable) block).getEntry(mc.theWorld, pos.blockX, pos.blockY, pos.blockZ, mc.thePlayer, mc.thePlayer.getCurrentEquippedItem());
if(entry != null)
drawLexiconGUI(entry, event.resolution);
}
}
}
}
private void drawLexiconGUI(LexiconEntry entry, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft mc = Minecraft.getMinecraft();
int x = res.getScaledWidth() / 2 + 8;
int y = res.getScaledHeight() / 2 - 4;
private void drawLexiconGUI(LexiconEntry entry, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft mc = Minecraft.getMinecraft();
int x = res.getScaledWidth() / 2 + 8;
int y = res.getScaledHeight() / 2 - 4;
int color = 0x6600FF00;
int color = 0x6600FF00;
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal(entry.getUnlocalizedName()), x + 18, y, color);
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc.shiftToRead"), x + 18, y + 11, color);
itemRender.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y);
GL11.glDisable(GL11.GL_LIGHTING);
mc.fontRenderer.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal(entry.getUnlocalizedName()), x + 18, y, color);
mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("botaniamisc.shiftToRead"), x + 18, y + 11, color);
itemRender.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.lexicon), x, y);
GL11.glDisable(GL11.GL_LIGHTING);
mc.fontRenderer.drawStringWithShadow("?", x + 10, y + 8, 0xFFFFFF);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 1F);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 1F);
}
public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft mc = Minecraft.getMinecraft();
int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2;
int y = res.getScaledHeight() / 2 + 10;
public static void drawSimpleManaHUD(int color, int mana, int maxMana, String name, ScaledResolution res) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Minecraft mc = Minecraft.getMinecraft();
int x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(name) / 2;
int y = res.getScaledHeight() / 2 + 10;
mc.fontRenderer.drawStringWithShadow(name, x, y, color);
mc.fontRenderer.drawStringWithShadow(name, x, y, color);
x = res.getScaledWidth() / 2 - 51;
y += 10;
x = res.getScaledWidth() / 2 - 51;
y += 10;
renderManaBar(x, y, color, 0.5F, mana, maxMana);
renderManaBar(x, y, color, 0.5F, mana, maxMana);
if(mana < 0) {
String text = StatCollector.translateToLocal("botaniamisc.statusUnknown");
x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2;
y -= 1;
mc.fontRenderer.drawStringWithShadow(text, x, y, color);
}
if(mana < 0) {
String text = StatCollector.translateToLocal("botaniamisc.statusUnknown");
x = res.getScaledWidth() / 2 - mc.fontRenderer.getStringWidth(text) / 2;
y -= 1;
mc.fontRenderer.drawStringWithShadow(text, x, y, color);
}
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glDisable(GL11.GL_BLEND);
}
public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) {
Minecraft mc = Minecraft.getMinecraft();
public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) {
Minecraft mc = Minecraft.getMinecraft();
GL11.glColor4f(1F, 1F, 1F, alpha);
mc.renderEngine.bindTexture(manaBar);
RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5);
GL11.glColor4f(1F, 1F, 1F, alpha);
mc.renderEngine.bindTexture(manaBar);
RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5);
int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100));
int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100));
if(manaPercentage == 0 && mana > 0) manaPercentage = 1;
if(manaPercentage == 0 && mana > 0)
manaPercentage = 1;
RenderHelper.drawTexturedModalRect(x + 1 + manaPercentage, y + 1, 0, 0, 5, 100 - manaPercentage, 3);
RenderHelper.drawTexturedModalRect(x + 1 + manaPercentage, y + 1, 0, 0, 5, 100 - manaPercentage, 3);
Color color_ = new Color(color);
GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(),(byte) color_.getBlue(), (byte) (255F * alpha));
RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, manaPercentage, 3);
}
Color color_ = new Color(color);
GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(), (byte) color_.getBlue(), (byte) (255F * alpha));
RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, manaPercentage, 3);
}
}
@@ -2,23 +2,16 @@
* This class was created by <Vazkii/ChickenBones>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 3, 2014, 9:05:38 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
@@ -32,450 +25,437 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import vazkii.botania.client.core.handler.LightningHandler.LightningBolt.Segment;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.Vector3;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
public class LightningHandler {
private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE);
private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL);
private static final ResourceLocation outsideResource = new ResourceLocation(LibResources.MISC_WISP_LARGE);
private static final ResourceLocation insideResource = new ResourceLocation(LibResources.MISC_WISP_SMALL);
static double interpPosX;
static double interpPosY;
static double interpPosZ;
static double interpPosX;
static double interpPosY;
static double interpPosZ;
private static Vector3 getRelativeViewVector(Vector3 pos) {
Entity renderEntity = Minecraft.getMinecraft().renderViewEntity;
return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
}
private static Vector3 getRelativeViewVector(Vector3 pos) {
Entity renderEntity = Minecraft.getMinecraft().renderViewEntity;
return new Vector3((float) renderEntity.posX - pos.x, (float) renderEntity.posY + renderEntity.getEyeHeight() - pos.y, (float) renderEntity.posZ - pos.z);
}
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
float frame = event.partialTicks;
Entity entity = Minecraft.getMinecraft().thePlayer;
@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
float frame = event.partialTicks;
Entity entity = Minecraft.getMinecraft().thePlayer;
interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;
interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame;
interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame;
interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame;
GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ);
GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ);
Tessellator tessellator = Tessellator.instance;
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
TextureManager render = Minecraft.getMinecraft().renderEngine;
Tessellator tessellator = Tessellator.instance;
render.bindTexture(outsideResource);
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
for (LightningBolt bolt : LightningBolt.boltlist)
renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false);
tessellator.draw();
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
render.bindTexture(insideResource);
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
for (LightningBolt bolt : LightningBolt.boltlist)
renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true);
tessellator.draw();
TextureManager render = Minecraft.getMinecraft().renderEngine;
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
render.bindTexture(outsideResource);
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
for(LightningBolt bolt : LightningBolt.boltlist)
renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false);
tessellator.draw();
GL11.glTranslated(interpPosX, interpPosY, interpPosZ);
}
render.bindTexture(insideResource);
tessellator.startDrawingQuads();
tessellator.setBrightness(0xF000F0);
for(LightningBolt bolt : LightningBolt.boltlist)
renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true);
tessellator.draw();
public static void spawnLightningBolt(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
LightningBolt bolt = new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner);
bolt.defaultFractal();
bolt.finalizeBolt();
LightningBolt.boltlist.add(bolt);
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
private void renderBolt(LightningBolt bolt, Tessellator tessellator, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass, boolean inner) {
float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge;
float mainalpha = 1;
if(pass == 0)
mainalpha = (1 - boltage) * 0.4F;
else mainalpha = 1 - boltage * 0.5F;
GL11.glTranslated(interpPosX, interpPosY, interpPosZ);
}
int expandTime = (int) (bolt.length * bolt.speed);
public static void spawnLightningBolt(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
LightningBolt bolt = new LightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner);
bolt.defaultFractal();
bolt.finalizeBolt();
LightningBolt.boltlist.add(bolt);
}
int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) / (float) (expandTime / 2) * bolt.numsegments0);
int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0);
private void renderBolt(LightningBolt bolt, Tessellator tessellator, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass, boolean inner) {
float boltage = bolt.particleAge < 0 ? 0 : (float) bolt.particleAge / (float) bolt.particleMaxAge;
float mainalpha = 1;
if(pass == 0) mainalpha = (1 - boltage) * 0.4F;
else mainalpha = 1 - boltage * 0.5F;
for(Segment rendersegment : bolt.segments) {
if(rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend)
continue;
Vector3 playervec = getRelativeViewVector(rendersegment.startpoint.point).multiply(-1);
double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F;
Vector3 diff1 = playervec.copy().crossProduct(rendersegment.prevdiff).normalize().multiply(width / rendersegment.sinprev);
Vector3 diff2 = playervec.copy().crossProduct(rendersegment.nextdiff).normalize().multiply(width / rendersegment.sinnext);
Vector3 startvec = rendersegment.startpoint.point;
Vector3 endvec = rendersegment.endpoint.point;
tessellator.setColorRGBA_I(inner ? bolt.colorInner : bolt.colorOuter, (int) (mainalpha * rendersegment.light * 255));
tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);
if(rendersegment.next == null) {
Vector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().multiply(width));
tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0);
tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);
tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1);
}
if(rendersegment.prev == null) {
Vector3 roundend = rendersegment.startpoint.point.copy().subtract(rendersegment.diff.copy().normalize().multiply(width));
tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0);
tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1);
tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
}
}
}
public static class LightningBolt {
public ArrayList<Segment> segments = new ArrayList<Segment>();
public Vector3 start;
public Vector3 end;
ChunkCoordinates target;
HashMap<Integer, Integer> splitparents = new HashMap<Integer, Integer>();
public double length;
public int numsegments0;
private int numsplits;
private boolean finalized;
private Random rand;
public long seed;
public int particleAge;
public int particleMaxAge;
public boolean isDead;
private AxisAlignedBB boundingBox;
private World world;
private Entity source;
public static ConcurrentLinkedQueue<LightningBolt> boltlist = new ConcurrentLinkedQueue<LightningBolt>();
public float speed = 1.5F;
public static final int fadetime = 20;
public static int playerdamage = 1;
public static int entitydamage = 1;
public int colorOuter;
public int colorInner;
public class BoltPoint {
public BoltPoint(Vector3 basepoint, Vector3 offsetvec) {
point = basepoint.copy().add(offsetvec);
this.basepoint = basepoint;
this.offsetvec = offsetvec;
}
public Vector3 point;
Vector3 basepoint;
Vector3 offsetvec;
}
int expandTime = (int) (bolt.length * bolt.speed);
public class SegmentSorter implements Comparator<Segment> {
@Override
public int compare(Segment o1, Segment o2) {
int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno);
if(comp == 0)
return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno);
else return comp;
}
}
int renderstart = (int) ((expandTime / 2 - bolt.particleMaxAge + bolt.particleAge) / (float) (expandTime / 2) * bolt.numsegments0);
int renderend = (int) ((bolt.particleAge + expandTime) / (float) expandTime * bolt.numsegments0);
public class SegmentLightSorter implements Comparator<Segment> {
@Override
public int compare(Segment o1, Segment o2) {
return Float.compare(o2.light, o1.light);
}
}
public class Segment {
public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
startpoint = start;
endpoint = end;
this.light = light;
segmentno = segmentnumber;
splitno = splitnumber;
calcDiff();
}
public Segment(Vector3 start, Vector3 end) {
this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
}
public void calcDiff() {
diff = endpoint.point.copy().subtract(startpoint.point);
}
public void calcEndDiffs() {
if(prev != null) {
Vector3 prevdiffnorm = prev.diff.copy().normalize();
Vector3 thisdiffnorm = diff.copy().normalize();
for(Segment rendersegment : bolt.segments) {
if(rendersegment.segmentno < renderstart || rendersegment.segmentno > renderend) continue;
Vector3 playervec = getRelativeViewVector(rendersegment.startpoint.point).multiply(-1);
prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2);
} else {
prevdiff = diff.copy().normalize();
sinprev = 1;
}
double width = 0.025F * (playervec.mag() / 5 + 1) * (1 + rendersegment.light) * 0.5F;
Vector3 diff1 = playervec.copy().crossProduct(rendersegment.prevdiff).normalize().multiply(width / rendersegment.sinprev);
Vector3 diff2 = playervec.copy().crossProduct(rendersegment.nextdiff).normalize().multiply(width / rendersegment.sinnext);
Vector3 startvec = rendersegment.startpoint.point;
Vector3 endvec = rendersegment.endpoint.point;
tessellator.setColorRGBA_I(inner ? bolt.colorInner : bolt.colorOuter, (int) (mainalpha * rendersegment.light * 255));
tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);
if(rendersegment.next == null) {
Vector3 roundend = rendersegment.endpoint.point.copy().add(rendersegment.diff.copy().normalize().multiply(width));
tessellator.addVertexWithUV(roundend.x - diff2.x, roundend.y - diff2.y, roundend.z - diff2.z, 0, 0);
tessellator.addVertexWithUV(endvec.x - diff2.x, endvec.y - diff2.y, endvec.z - diff2.z, 0.5, 0);
tessellator.addVertexWithUV(endvec.x + diff2.x, endvec.y + diff2.y, endvec.z + diff2.z, 0.5, 1);
tessellator.addVertexWithUV(roundend.x + diff2.x, roundend.y + diff2.y, roundend.z + diff2.z, 0, 1);
}
if(rendersegment.prev == null) {
Vector3 roundend = rendersegment.startpoint.point.copy().subtract(rendersegment.diff.copy().normalize().multiply(width));
tessellator.addVertexWithUV(startvec.x - diff1.x, startvec.y - diff1.y, startvec.z - diff1.z, 0.5, 0);
tessellator.addVertexWithUV(roundend.x - diff1.x, roundend.y - diff1.y, roundend.z - diff1.z, 0, 0);
tessellator.addVertexWithUV(roundend.x + diff1.x, roundend.y + diff1.y, roundend.z + diff1.z, 0, 1);
tessellator.addVertexWithUV(startvec.x + diff1.x, startvec.y + diff1.y, startvec.z + diff1.z, 0.5, 1);
}
}
}
public static class LightningBolt {
public ArrayList<Segment> segments = new ArrayList<Segment>();
public Vector3 start;
public Vector3 end;
ChunkCoordinates target;
HashMap<Integer, Integer> splitparents = new HashMap<Integer, Integer>();
public double length;
public int numsegments0;
private int numsplits;
private boolean finalized;
private Random rand;
public long seed;
public int particleAge;
public int particleMaxAge;
public boolean isDead;
private AxisAlignedBB boundingBox;
private World world;
private Entity source;
public static ConcurrentLinkedQueue<LightningBolt> boltlist = new ConcurrentLinkedQueue<LightningBolt>();
public float speed = 1.5F;
public static final int fadetime = 20;
public static int playerdamage = 1;
public static int entitydamage = 1;
public int colorOuter;
public int colorInner;
public class BoltPoint {
public BoltPoint(Vector3 basepoint, Vector3 offsetvec) {
point = basepoint.copy().add(offsetvec);
this.basepoint = basepoint;
this.offsetvec = offsetvec;
}
public Vector3 point;
Vector3 basepoint;
Vector3 offsetvec;
}
if(next != null) {
Vector3 nextdiffnorm = next.diff.copy().normalize();
Vector3 thisdiffnorm = diff.copy().normalize();
public class SegmentSorter implements Comparator<Segment> {
nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2);
} else {
nextdiff = diff.copy().normalize();
sinnext = 1;
}
}
@Override
public int compare(Segment o1, Segment o2) {
int comp = Integer.valueOf(o1.splitno).compareTo(o2.splitno);
if(comp == 0) return Integer.valueOf(o1.segmentno).compareTo(o2.segmentno);
else return comp;
}
}
@Override
public String toString() {
return startpoint.point.toString() + " " + endpoint.point.toString();
}
public class SegmentLightSorter implements Comparator<Segment> {
@Override
public int compare(Segment o1, Segment o2) {
return Float.compare(o2.light, o1.light);
}
}
public class Segment {
public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
startpoint = start;
endpoint = end;
this.light = light;
segmentno = segmentnumber;
splitno = splitnumber;
calcDiff();
}
public Segment(Vector3 start, Vector3 end) {
this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
}
public void calcDiff() {
diff = endpoint.point.copy().subtract(startpoint.point);
}
public BoltPoint startpoint;
public BoltPoint endpoint;
public void calcEndDiffs() {
if(prev != null) {
Vector3 prevdiffnorm = prev.diff.copy().normalize();
Vector3 thisdiffnorm = diff.copy().normalize();
public Vector3 diff;
prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.multiply(-1)) / 2);
} else {
prevdiff = diff.copy().normalize();
sinprev = 1;
}
public Segment prev;
public Segment next;
if(next != null) {
Vector3 nextdiffnorm = next.diff.copy().normalize();
Vector3 thisdiffnorm = diff.copy().normalize();
public Vector3 nextdiff;
public Vector3 prevdiff;
nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.multiply(-1)) / 2);
} else {
nextdiff = diff.copy().normalize();
sinnext = 1;
}
}
public float sinprev;
public float sinnext;
public float light;
@Override
public String toString() {
return startpoint.point.toString() + " " + endpoint.point.toString();
}
public int segmentno;
public int splitno;
}
public BoltPoint startpoint;
public BoltPoint endpoint;
public LightningBolt(World world, Vector3 sourcevec, Vector3 targetvec, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
this.world = world;
this.seed = seed;
rand = new Random(seed);
start = sourcevec;
end = targetvec;
public Vector3 diff;
speed = ticksPerMeter;
public Segment prev;
public Segment next;
this.colorOuter = colorOuter;
this.colorInner = colorInner;
public Vector3 nextdiff;
public Vector3 prevdiff;
numsegments0 = 1;
public float sinprev;
public float sinnext;
public float light;
length = end.copy().subtract(start).mag();
particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2;
particleAge = -(int) (length * speed);
public int segmentno;
public int splitno;
}
boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
boundingBox.setBB(AxisAlignedBB.getBoundingBox(Math.min(start.x, end.x), Math.min(start.y, end.y), Math.min(start.z, end.z), Math.max(start.x, end.x), Math.max(start.y, end.y), Math.max(start.z, end.z)).expand(length / 2, length / 2, length / 2));
public LightningBolt(World world, Vector3 sourcevec, Vector3 targetvec, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
this.world = world;
this.seed = seed;
rand = new Random(seed);
segments.add(new Segment(start, end));
}
start = sourcevec;
end = targetvec;
public static Vector3 getFocalPoint(TileEntity tile) {
return Vector3.fromTileEntityCenter(tile);
}
speed = ticksPerMeter;
public LightningBolt(World world, Vector3 sourcevec, TileEntity target, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner);
this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord);
}
this.colorOuter = colorOuter;
this.colorInner = colorInner;
public void setWrapper(Entity entity) {
source = entity;
}
numsegments0 = 1;
public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) {
if(finalized)
return;
length = end.copy().subtract(start).mag();
particleMaxAge = fadetime + rand.nextInt(fadetime) - fadetime / 2;
particleAge = -(int) (length * speed);
ArrayList<Segment> oldsegments = segments;
segments = new ArrayList<Segment>();
boundingBox = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
boundingBox.setBB(AxisAlignedBB.getBoundingBox(Math.min(start.x, end.x), Math.min(start.y, end.y), Math.min(start.z, end.z), Math.max(start.x, end.x), Math.max(start.y, end.y), Math.max(start.z, end.z)).expand(length / 2, length / 2, length / 2));
Segment prev = null;
segments.add(new Segment(start, end));
}
for(Segment segment : oldsegments) {
prev = segment.prev;
public static Vector3 getFocalPoint(TileEntity tile) {
return Vector3.fromTileEntityCenter(tile);
}
Vector3 subsegment = segment.diff.copy().multiply(1F / splits);
public LightningBolt(World world, Vector3 sourcevec, TileEntity target, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
this(world, sourcevec, getFocalPoint(target), ticksPerMeter, seed, colorOuter, colorInner);
this.target = new ChunkCoordinates(target.xCoord, target.yCoord, target.zCoord);
}
BoltPoint[] newpoints = new BoltPoint[splits + 1];
public void setWrapper(Entity entity) {
source = entity;
}
Vector3 startpoint = segment.startpoint.point;
newpoints[0] = segment.startpoint;
newpoints[splits] = segment.endpoint;
public void fractal(int splits, double amount, double splitchance, double splitlength, double splitangle) {
if(finalized) return;
for(int i = 1; i < splits; i++) {
Vector3 randoff = segment.diff.copy().perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff);
randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2);
ArrayList<Segment> oldsegments = segments;
segments = new ArrayList<Segment>();
Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i));
Segment prev = null;
newpoints[i] = new BoltPoint(basepoint, randoff);
}
for(Segment segment : oldsegments) {
prev = segment.prev;
for(int i = 0; i < splits; i++) {
Segment next = new Segment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentno * splits + i, segment.splitno);
next.prev = prev;
if (prev != null)
prev.next = next;
Vector3 subsegment = segment.diff.copy().multiply(1F / splits);
if(i != 0 && rand.nextFloat() < splitchance) {
Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff);
Vector3 diff = next.diff.copy().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).multiply(splitlength);
BoltPoint[] newpoints = new BoltPoint[splits + 1];
numsplits++;
splitparents.put(numsplits, next.splitno);
Vector3 startpoint = segment.startpoint.point;
newpoints[0] = segment.startpoint;
newpoints[splits] = segment.endpoint;
Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[i + 1].basepoint, newpoints[i + 1].offsetvec.copy().add(diff)), segment.light / 2F, next.segmentno, numsplits);
split.prev = prev;
for(int i = 1; i < splits; i++) {
Vector3 randoff = segment.diff.copy().perpendicular().normalize().rotate(rand.nextFloat() * 360, segment.diff);
randoff.multiply((rand.nextFloat() - 0.5F) * amount * 2);
segments.add(split);
}
Vector3 basepoint = startpoint.copy().add(subsegment.copy().multiply(i));
prev = next;
segments.add(next);
}
newpoints[i] = new BoltPoint(basepoint, randoff);
}
if(segment.next != null)
segment.next.prev = prev;
}
for(int i = 0; i < splits; i++) {
Segment next = new Segment(newpoints[i], newpoints[i + 1], segment.light, segment.segmentno * splits + i, segment.splitno);
next.prev = prev;
if(prev != null) prev.next = next;
numsegments0 *= splits;
}
if(i != 0 && rand.nextFloat() < splitchance) {
Vector3 splitrot = next.diff.copy().xCrossProduct().rotate(rand.nextFloat() * 360, next.diff);
Vector3 diff = next.diff.copy().rotate((rand.nextFloat() * 0.66F + 0.33F) * splitangle, splitrot).multiply(splitlength);
public void defaultFractal() {
fractal(2, length / 1.5, 0.7F, 0.7F, 45);
fractal(2, length / 4, 0.5F, 0.8F, 50);
fractal(2, length / 15, 0.5F, 0.9F, 55);
fractal(2, length / 30, 0.5F, 1.0F, 60);
fractal(2, length / 60, 0, 0, 0);
fractal(2, length / 100, 0, 0, 0);
fractal(2, length / 400, 0, 0, 0);
}
numsplits++;
splitparents.put(numsplits, next.splitno);
private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
Segment split = new Segment(newpoints[i], new BoltPoint(newpoints[i + 1].basepoint, newpoints[i + 1].offsetvec.copy().add(diff)), segment.light / 2F, next.segmentno, numsplits);
split.prev = prev;
if(mop == null)
return prevresistance;
segments.add(split);
}
if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
prev = next;
segments.add(next);
}
if(world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ))
return prevresistance;
if(segment.next != null) segment.next.prev = prev;
}
return prevresistance + block.getExplosionResistance(source) + 0.3F;
} else return prevresistance;
}
numsegments0 *= splits;
}
private void calculateCollisionAndDiffs() {
HashMap<Integer, Integer> lastactivesegment = new HashMap<Integer, Integer>();
public void defaultFractal() {
fractal(2, length / 1.5, 0.7F, 0.7F, 45);
fractal(2, length / 4, 0.5F, 0.8F, 50);
fractal(2, length / 15, 0.5F, 0.9F, 55);
fractal(2, length / 30, 0.5F, 1.0F, 60);
fractal(2, length / 60, 0, 0, 0);
fractal(2, length / 100, 0, 0, 0);
fractal(2, length / 400, 0, 0, 0);
}
Collections.sort(segments, new SegmentSorter());
private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());
int lastsplitcalc = 0;
int lastactiveseg = 0;// unterminated
float splitresistance = 0;
if(mop == null) return prevresistance;
for(Segment segment : segments) {
if(segment.splitno > lastsplitcalc) {
lastactivesegment.put(lastsplitcalc, lastactiveseg);
lastsplitcalc = segment.splitno;
lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno));
splitresistance = lastactiveseg < segment.segmentno ? 50 : 0;
}
if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
if(splitresistance >= 40 * segment.light)
continue;
if(world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) return prevresistance;
splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance);
lastactiveseg = segment.segmentno;
}
lastactivesegment.put(lastsplitcalc, lastactiveseg);
return prevresistance + block.getExplosionResistance(source) + 0.3F;
} else return prevresistance;
}
lastsplitcalc = 0;
lastactiveseg = lastactivesegment.get(0);
for(Iterator<Segment> iterator = segments.iterator(); iterator.hasNext();) {
Segment segment = iterator.next();
if(lastsplitcalc != segment.splitno) {
lastsplitcalc = segment.splitno;
lastactiveseg = lastactivesegment.get(segment.splitno);
}
if(segment.segmentno > lastactiveseg)
iterator.remove();
segment.calcEndDiffs();
}
}
public void finalizeBolt() {
if(finalized)
return;
finalized = true;
calculateCollisionAndDiffs();
Collections.sort(segments, new SegmentLightSorter());
boltlist.add(this);
}
public void onUpdate() {
particleAge++;
if (particleAge >= particleMaxAge)
isDead = true;
}
// Called in ClientTickHandler
public static void update() {
for(Iterator<LightningBolt> iterator = boltlist.iterator(); iterator.hasNext();) {
LightningBolt bolt = iterator.next();
bolt.onUpdate();
if(bolt.isDead)
iterator.remove();
}
}
}
private void calculateCollisionAndDiffs() {
HashMap<Integer, Integer> lastactivesegment = new HashMap<Integer, Integer>();
Collections.sort(segments, new SegmentSorter());
int lastsplitcalc = 0;
int lastactiveseg = 0;// unterminated
float splitresistance = 0;
for(Segment segment : segments) {
if(segment.splitno > lastsplitcalc) {
lastactivesegment.put(lastsplitcalc, lastactiveseg);
lastsplitcalc = segment.splitno;
lastactiveseg = lastactivesegment.get(splitparents.get(segment.splitno));
splitresistance = lastactiveseg < segment.segmentno ? 50 : 0;
}
if(splitresistance >= 40 * segment.light) continue;
splitresistance = rayTraceResistance(segment.startpoint.point, segment.endpoint.point, splitresistance);
lastactiveseg = segment.segmentno;
}
lastactivesegment.put(lastsplitcalc, lastactiveseg);
lastsplitcalc = 0;
lastactiveseg = lastactivesegment.get(0);
for(Iterator<Segment> iterator = segments.iterator(); iterator.hasNext(); ) {
Segment segment = iterator.next();
if(lastsplitcalc != segment.splitno) {
lastsplitcalc = segment.splitno;
lastactiveseg = lastactivesegment.get(segment.splitno);
}
if(segment.segmentno > lastactiveseg) iterator.remove();
segment.calcEndDiffs();
}
}
public void finalizeBolt() {
if(finalized) return;
finalized = true;
calculateCollisionAndDiffs();
Collections.sort(segments, new SegmentLightSorter());
boltlist.add(this);
}
public void onUpdate() {
particleAge++;
if(particleAge >= particleMaxAge) isDead = true;
}
// Called in ClientTickHandler
public static void update() {
for(Iterator<LightningBolt> iterator = boltlist.iterator(); iterator.hasNext(); ) {
LightningBolt bolt = iterator.next();
bolt.onUpdate();
if(bolt.isDead) iterator.remove();
}
}
}
}
@@ -2,23 +2,23 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:04:31 PM (GMT)]
*/
package vazkii.botania.client.core.handler;
import vazkii.botania.client.lib.LibResources;
import cpw.mods.fml.common.registry.LanguageRegistry;
import vazkii.botania.client.lib.LibResources;
public final class LocalizationHandler {
public static void loadLocalizations() {
for(String locale : LibResources.LANGS)
LanguageRegistry.instance().loadLocalization(LibResources.PREFIX_LANG + locale + ".lang", locale, false);
}
public static void loadLocalizations() {
for(String locale : LibResources.LANGS)
LanguageRegistry.instance().loadLocalization(LibResources.PREFIX_LANG + locale + ".lang", locale, false);
}
}
@@ -2,42 +2,40 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 16, 2014, 5:30:52 PM (GMT)]
*/
package vazkii.botania.client.core.helper;
public final class FontHelper {
public static boolean isFormatColor(char par0) {
return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70;
}
public static boolean isFormatColor(char par0) {
return par0 >= 48 && par0 <= 57 || par0 >= 97 && par0 <= 102 || par0 >= 65 && par0 <= 70;
}
public static boolean isFormatSpecial(char par0) {
return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82;
}
public static boolean isFormatSpecial(char par0) {
return par0 >= 107 && par0 <= 111 || par0 >= 75 && par0 <= 79 || par0 == 114 || par0 == 82;
}
public static String getFormatFromString(String par0Str) {
String s1 = "";
int i = -1;
int j = par0Str.length();
public static String getFormatFromString(String par0Str) {
String s1 = "";
int i = -1;
int j = par0Str.length();
while ((i = par0Str.indexOf(167, i + 1)) != -1) {
if (i < j - 1) {
char c0 = par0Str.charAt(i + 1);
while((i = par0Str.indexOf(167, i + 1)) != -1) {
if(i < j - 1) {
char c0 = par0Str.charAt(i + 1);
if (isFormatColor(c0))
s1 = "\u00a7" + c0;
else if (isFormatSpecial(c0))
s1 = s1 + "\u00a7" + c0;
}
}
if(isFormatColor(c0)) s1 = "\u00a7" + c0;
else if(isFormatSpecial(c0)) s1 = s1 + "\u00a7" + c0;
}
}
return s1;
}
return s1;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 5:28:21 PM (GMT)]
*/
package vazkii.botania.client.core.helper;
@@ -20,36 +20,36 @@ import vazkii.botania.client.lib.LibResources;
public final class IconHelper {
public static IIcon forName(IIconRegister ir, String name) {
return ir.registerIcon(LibResources.PREFIX_MOD + name);
}
public static IIcon forName(IIconRegister ir, String name) {
return ir.registerIcon(LibResources.PREFIX_MOD + name);
}
public static IIcon forNameRaw(IIconRegister ir, String name) {
return ir.registerIcon(name);
}
public static IIcon forNameRaw(IIconRegister ir, String name) {
return ir.registerIcon(name);
}
public static IIcon forBlock(IIconRegister ir, Block block) {
return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", ""));
}
public static IIcon forBlock(IIconRegister ir, Block block) {
return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", ""));
}
public static IIcon forBlock(IIconRegister ir, Block block, int i) {
return forBlock(ir, block, Integer.toString(i));
}
public static IIcon forBlock(IIconRegister ir, Block block, int i) {
return forBlock(ir, block, Integer.toString(i));
}
public static IIcon forBlock(IIconRegister ir, Block block, String s) {
return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", "") + s);
}
public static IIcon forBlock(IIconRegister ir, Block block, String s) {
return forNameRaw(ir, block.getUnlocalizedName().replaceAll("tile.", "") + s);
}
public static IIcon forItem(IIconRegister ir, Item item) {
return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", ""));
}
public static IIcon forItem(IIconRegister ir, Item item) {
return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", ""));
}
public static IIcon forItem(IIconRegister ir, Item item, int i) {
return forItem(ir, item, Integer.toString(i));
}
public static IIcon forItem(IIconRegister ir, Item item, int i) {
return forItem(ir, item, Integer.toString(i));
}
public static IIcon forItem(IIconRegister ir, Item item, String s) {
return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", "") + s);
}
public static IIcon forItem(IIconRegister ir, Item item, String s) {
return forNameRaw(ir, item.getUnlocalizedName().replaceAll("item.", "") + s);
}
}
@@ -2,186 +2,178 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 19, 2014, 5:40:38 PM (GMT)]
*/
package vazkii.botania.client.core.helper;
import java.util.List;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import java.util.List;
import java.util.Random;
public final class RenderHelper {
public static void renderTooltip(int x, int y, List<String> tooltipData) {
int color = 0x505000ff;
int color2 = 0xf0100010;
public static void renderTooltip(int x, int y, List<String> tooltipData) {
int color = 0x505000ff;
int color2 = 0xf0100010;
renderTooltip(x, y, tooltipData, color, color2);
}
renderTooltip(x, y, tooltipData, color, color2);
}
public static void renderTooltipOrange(int x, int y, List<String> tooltipData) {
int color = 0x50a06600;
int color2 = 0xf01e1200;
public static void renderTooltipOrange(int x, int y, List<String> tooltipData) {
int color = 0x50a06600;
int color2 = 0xf01e1200;
renderTooltip(x, y, tooltipData, color, color2);
}
renderTooltip(x, y, tooltipData, color, color2);
}
public static void renderTooltipGreen(int x, int y, List<String> tooltipData) {
int color = 0x5000a000;
int color2 = 0xf0001e00;
public static void renderTooltipGreen(int x, int y, List<String> tooltipData) {
int color = 0x5000a000;
int color2 = 0xf0001e00;
renderTooltip(x, y, tooltipData, color, color2);
}
renderTooltip(x, y, tooltipData, color, color2);
}
public static void renderTooltip(int x, int y, List<String> tooltipData, int color, int color2) {
boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
if(lighting)
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
public static void renderTooltip(int x, int y, List<String> tooltipData, int color, int color2) {
boolean lighting = GL11.glGetBoolean(GL11.GL_LIGHTING);
if(lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
if (!tooltipData.isEmpty()) {
int var5 = 0;
int var6;
int var7;
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
for (var6 = 0; var6 < tooltipData.size(); ++var6) {
var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
if (var7 > var5)
var5 = var7;
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if (tooltipData.size() > 1)
var9 += 2 + (tooltipData.size() - 1) * 10;
float z = 300F;
drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216;
drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color);
drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
if(!tooltipData.isEmpty()) {
int var5 = 0;
int var6;
int var7;
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
for(var6 = 0; var6 < tooltipData.size(); ++var6) {
var7 = fontRenderer.getStringWidth(tooltipData.get(var6));
if(var7 > var5) var5 = var7;
}
var6 = x + 12;
var7 = y - 12;
int var9 = 8;
if(tooltipData.size() > 1) var9 += 2 + (tooltipData.size() - 1) * 10;
float z = 300F;
drawGradientRect(var6 - 3, var7 - 4, z, var6 + var5 + 3, var7 - 3, color2, color2);
drawGradientRect(var6 - 3, var7 + var9 + 3, z, var6 + var5 + 3, var7 + var9 + 4, color2, color2);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 - 4, var7 - 3, z, var6 - 3, var7 + var9 + 3, color2, color2);
drawGradientRect(var6 + var5 + 3, var7 - 3, z, var6 + var5 + 4, var7 + var9 + 3, color2, color2);
int var12 = (color & 0xFFFFFF) >> 1 | color & -16777216;
drawGradientRect(var6 - 3, var7 - 3 + 1, z, var6 - 3 + 1, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, z, var6 + var5 + 3, var7 + var9 + 3 - 1, color, var12);
drawGradientRect(var6 - 3, var7 - 3, z, var6 + var5 + 3, var7 - 3 + 1, color, color);
drawGradientRect(var6 - 3, var7 + var9 + 2, z, var6 + var5 + 3, var7 + var9 + 3, var12, var12);
GL11.glDisable(GL11.GL_DEPTH_TEST);
for (int var13 = 0; var13 < tooltipData.size(); ++var13) {
String var14 = tooltipData.get(var13);
fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
if (var13 == 0)
var7 += 2;
var7 += 10;
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
if(!lighting)
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
GL11.glDisable(GL11.GL_DEPTH_TEST);
for(int var13 = 0; var13 < tooltipData.size(); ++var13) {
String var14 = tooltipData.get(var13);
fontRenderer.drawStringWithShadow(var14, var6, var7, -1);
if(var13 == 0) var7 += 2;
var7 += 10;
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
}
if(!lighting) net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
float var7 = (par5 >> 24 & 255) / 255F;
float var8 = (par5 >> 16 & 255) / 255F;
float var9 = (par5 >> 8 & 255) / 255F;
float var10 = (par5 & 255) / 255F;
float var11 = (par6 >> 24 & 255) / 255F;
float var12 = (par6 >> 16 & 255) / 255F;
float var13 = (par6 >> 8 & 255) / 255F;
float var14 = (par6 & 255) / 255F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator var15 = Tessellator.instance;
var15.startDrawingQuads();
var15.setColorRGBA_F(var8, var9, var10, var7);
var15.addVertex(par3, par2, z);
var15.addVertex(par1, par2, z);
var15.setColorRGBA_F(var12, var13, var14, var11);
var15.addVertex(par1, par4, z);
var15.addVertex(par3, par4, z);
var15.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
float var7 = (par5 >> 24 & 255) / 255F;
float var8 = (par5 >> 16 & 255) / 255F;
float var9 = (par5 >> 8 & 255) / 255F;
float var10 = (par5 & 255) / 255F;
float var11 = (par6 >> 24 & 255) / 255F;
float var12 = (par6 >> 16 & 255) / 255F;
float var13 = (par6 >> 8 & 255) / 255F;
float var14 = (par6 & 255) / 255F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glShadeModel(GL11.GL_SMOOTH);
Tessellator var15 = Tessellator.instance;
var15.startDrawingQuads();
var15.setColorRGBA_F(var8, var9, var10, var7);
var15.addVertex(par3, par2, z);
var15.addVertex(par1, par2, z);
var15.setColorRGBA_F(var12, var13, var14, var11);
var15.addVertex(par1, par4, z);
var15.addVertex(par3, par4, z);
var15.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1);
tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1);
tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1);
tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1);
tessellator.draw();
}
public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
float f = 0.00390625F;
float f1 = 0.00390625F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1);
tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1);
tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1);
tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1);
tessellator.draw();
}
public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
Tessellator tessellator = Tessellator.instance;
public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
Tessellator tessellator = Tessellator.instance;
int ticks = (int) (Minecraft.getMinecraft().theWorld.getTotalWorldTime() % 200);
if (ticks >= 100)
ticks = 200 - ticks - 1;
int ticks = (int) (Minecraft.getMinecraft().theWorld.getTotalWorldTime() % 200);
if(ticks >= 100) ticks = 200 - ticks - 1;
float f1 = ticks / 200F;
float f2 = 0F;
if (f1 > 0.7F)
f2 = (f1 - 0.7F) / 0.2F;
Random random = new Random(seed);
float f1 = ticks / 200F;
float f2 = 0F;
if(f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F;
Random random = new Random(seed);
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(770, 1);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1F, -2F);
GL11.glScalef(xScale, yScale, zScale);
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(770, 1);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(false);
GL11.glTranslatef(0F, -1F, -2F);
GL11.glScalef(xScale, yScale, zScale);
for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F);
GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
tessellator.startDrawing(GL11.GL_TRIANGLE_FAN);
float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2)));
tessellator.addVertex(0, 0, 0);
tessellator.setColorRGBA_F(0F, 0F, 0F, 0);
tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
tessellator.addVertex(0.866D * f4, f3, -0.5F * f4);
tessellator.addVertex(0, f3, 1F * f4);
tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
tessellator.draw();
}
for(int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F);
GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
tessellator.startDrawing(GL11.GL_TRIANGLE_FAN);
float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2)));
tessellator.addVertex(0, 0, 0);
tessellator.setColorRGBA_F(0F, 0F, 0F, 0);
tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
tessellator.addVertex(0.866D * f4, f3, -0.5F * f4);
tessellator.addVertex(0, f3, 1F * f4);
tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
tessellator.draw();
}
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPopMatrix();
}
GL11.glDepthMask(true);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPopMatrix();
}
}
@@ -2,178 +2,160 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Apr 9, 2014, 11:20:26 PM (GMT)]
*/
package vazkii.botania.client.core.helper;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import cpw.mods.fml.common.FMLLog;
import net.minecraft.client.renderer.OpenGlHelper;
import org.apache.logging.log4j.Level;
import org.lwjgl.opengl.ARBFragmentShader;
import org.lwjgl.opengl.ARBShaderObjects;
import org.lwjgl.opengl.ARBVertexShader;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.handler.ConfigHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public final class ShaderHelper {
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
private static final int VERT = ARBVertexShader.GL_VERTEX_SHADER_ARB;
private static final int FRAG = ARBFragmentShader.GL_FRAGMENT_SHADER_ARB;
public static int pylonGlow = 0;
public static int enchanterRune = 0;
public static int manaPool = 0;
public static int pylonGlow = 0;
public static int enchanterRune = 0;
public static int manaPool = 0;
public static void initShaders() {
if(!useShaders())
return;
pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG);
enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG);
manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG);
}
public static void initShaders() {
if(!useShaders()) return;
public static void useShader(int shader) {
if(!useShaders())
return;
ARBShaderObjects.glUseProgramObjectARB(shader);
if(shader != 0) {
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame);
}
}
pylonGlow = createProgram(null, LibResources.SHADER_PYLON_GLOW_FRAG);
enchanterRune = createProgram(null, LibResources.SHADER_ENCHANTER_RUNE_FRAG);
manaPool = createProgram(null, LibResources.SHADER_MANA_POOL_FRAG);
}
public static void releaseShader() {
useShader(0);
}
public static boolean useShaders() {
return ConfigHandler.useShaders && OpenGlHelper.shadersSupported;
}
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
public static void useShader(int shader) {
if(!useShaders()) return;
private static int createProgram(String vert, String frag) {
int vertId = 0, fragId = 0, program = 0;
if(vert != null)
vertId = createShader(vert, VERT);
if(frag != null)
fragId = createShader(frag, FRAG);
ARBShaderObjects.glUseProgramObjectARB(shader);
program = ARBShaderObjects.glCreateProgramObjectARB();
if(program == 0)
return 0;
if(shader != 0) {
int time = ARBShaderObjects.glGetUniformLocationARB(shader, "time");
ARBShaderObjects.glUniform1iARB(time, ClientTickHandler.ticksInGame);
}
}
if(vert != null)
ARBShaderObjects.glAttachObjectARB(program, vertId);
if(frag != null)
ARBShaderObjects.glAttachObjectARB(program, fragId);
public static void releaseShader() {
useShader(0);
}
ARBShaderObjects.glLinkProgramARB(program);
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
FMLLog.log(Level.ERROR, getLogInfo(program));
return 0;
}
ARBShaderObjects.glValidateProgramARB(program);
if (ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
FMLLog.log(Level.ERROR, getLogInfo(program));
return 0;
}
return program;
}
public static boolean useShaders() {
return ConfigHandler.useShaders && OpenGlHelper.shadersSupported;
}
private static int createShader(String filename, int shaderType){
int shader = 0;
try {
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
// Most of the code taken from the LWJGL wiki
// http://lwjgl.org/wiki/index.php?title=GLSL_Shaders_with_LWJGL
if(shader == 0)
return 0;
private static int createProgram(String vert, String frag) {
int vertId = 0, fragId = 0, program = 0;
if(vert != null) vertId = createShader(vert, VERT);
if(frag != null) fragId = createShader(frag, FRAG);
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
program = ARBShaderObjects.glCreateProgramObjectARB();
if(program == 0) return 0;
if (ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
if(vert != null) ARBShaderObjects.glAttachObjectARB(program, vertId);
if(frag != null) ARBShaderObjects.glAttachObjectARB(program, fragId);
return shader;
}
catch(Exception e) {
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
ARBShaderObjects.glLinkProgramARB(program);
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_LINK_STATUS_ARB) == GL11.GL_FALSE) {
FMLLog.log(Level.ERROR, getLogInfo(program));
return 0;
}
private static String getLogInfo(int obj) {
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
ARBShaderObjects.glValidateProgramARB(program);
if(ARBShaderObjects.glGetObjectParameteriARB(program, ARBShaderObjects.GL_OBJECT_VALIDATE_STATUS_ARB) == GL11.GL_FALSE) {
FMLLog.log(Level.ERROR, getLogInfo(program));
return 0;
}
private static String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
return program;
}
if(in == null)
return "";
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
private static int createShader(String filename, int shaderType) {
int shader = 0;
try {
shader = ARBShaderObjects.glCreateShaderObjectARB(shaderType);
Exception innerExc= null;
try {
String line;
while((line = reader.readLine()) != null)
source.append(line).append('\n');
} catch(Exception exc) {
exception = exc;
} finally {
try {
reader.close();
} catch(Exception exc) {
if(innerExc == null)
innerExc = exc;
else exc.printStackTrace();
}
}
if(shader == 0) return 0;
if(innerExc != null)
throw innerExc;
} catch(Exception exc) {
exception = exc;
} finally {
try {
in.close();
} catch(Exception exc) {
if(exception == null)
exception = exc;
else exc.printStackTrace();
}
ARBShaderObjects.glShaderSourceARB(shader, readFileAsString(filename));
ARBShaderObjects.glCompileShaderARB(shader);
if(exception != null)
throw exception;
}
if(ARBShaderObjects.glGetObjectParameteriARB(shader, ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB) == GL11.GL_FALSE)
throw new RuntimeException("Error creating shader: " + getLogInfo(shader));
return source.toString();
}
return shader;
} catch(Exception e) {
ARBShaderObjects.glDeleteObjectARB(shader);
e.printStackTrace();
return -1;
}
}
private static String getLogInfo(int obj) {
return ARBShaderObjects.glGetInfoLogARB(obj, ARBShaderObjects.glGetObjectParameteriARB(obj, ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB));
}
private static String readFileAsString(String filename) throws Exception {
StringBuilder source = new StringBuilder();
InputStream in = ShaderHelper.class.getResourceAsStream(filename);
Exception exception = null;
BufferedReader reader;
if(in == null) return "";
try {
reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
Exception innerExc = null;
try {
String line;
while((line = reader.readLine()) != null) source.append(line).append('\n');
} catch(Exception exc) {
exception = exc;
} finally {
try {
reader.close();
} catch(Exception exc) {
if(innerExc == null) innerExc = exc;
else exc.printStackTrace();
}
}
if(innerExc != null) throw innerExc;
} catch(Exception exc) {
exception = exc;
} finally {
try {
in.close();
} catch(Exception exc) {
if(exception == null) exception = exc;
else exc.printStackTrace();
}
if(exception != null) throw exception;
}
return source.toString();
}
}
@@ -2,25 +2,25 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 13, 2014, 7:46:05 PM (GMT)]
*/
package vazkii.botania.client.core.proxy;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.client.core.handler.BoundTileRenderer;
import vazkii.botania.client.core.handler.CapeHandler;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.client.core.handler.LightningHandler;
import vazkii.botania.client.core.handler.*;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.fx.FXSparkle;
import vazkii.botania.client.fx.FXWisp;
@@ -28,114 +28,94 @@ import vazkii.botania.client.gui.GuiLexicon;
import vazkii.botania.client.gui.GuiLexiconEntry;
import vazkii.botania.client.gui.GuiLexiconIndex;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.client.render.block.RenderAltar;
import vazkii.botania.client.render.block.RenderPool;
import vazkii.botania.client.render.block.RenderPylon;
import vazkii.botania.client.render.block.RenderSpecialFlower;
import vazkii.botania.client.render.block.RenderSpreader;
import vazkii.botania.client.render.block.*;
import vazkii.botania.client.render.item.RenderLens;
import vazkii.botania.client.render.item.RenderLexicon;
import vazkii.botania.client.render.tile.RenderTileAltar;
import vazkii.botania.client.render.tile.RenderTileEnchanter;
import vazkii.botania.client.render.tile.RenderTilePool;
import vazkii.botania.client.render.tile.RenderTilePylon;
import vazkii.botania.client.render.tile.RenderTileRuneAltar;
import vazkii.botania.client.render.tile.RenderTileSpreader;
import vazkii.botania.common.block.tile.TileAltar;
import vazkii.botania.common.block.tile.TileEnchanter;
import vazkii.botania.common.block.tile.TilePool;
import vazkii.botania.common.block.tile.TilePylon;
import vazkii.botania.common.block.tile.TileRuneAltar;
import vazkii.botania.common.block.tile.TileSpreader;
import vazkii.botania.client.render.tile.*;
import vazkii.botania.common.block.tile.*;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.item.ModItems;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.relauncher.Side;
public class ClientProxy extends CommonProxy {
@Override
public void init(FMLInitializationEvent event) {
super.init(event);
@Override
public void init(FMLInitializationEvent event) {
super.init(event);
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
MinecraftForge.EVENT_BUS.register(new HUDHandler());
MinecraftForge.EVENT_BUS.register(new LightningHandler());
MinecraftForge.EVENT_BUS.register(new CapeHandler());
if(ConfigHandler.boundBlockWireframe)
MinecraftForge.EVENT_BUS.register(new BoundTileRenderer());
FMLCommonHandler.instance().bus().register(new ClientTickHandler());
MinecraftForge.EVENT_BUS.register(new HUDHandler());
MinecraftForge.EVENT_BUS.register(new LightningHandler());
MinecraftForge.EVENT_BUS.register(new CapeHandler());
if(ConfigHandler.boundBlockWireframe) MinecraftForge.EVENT_BUS.register(new BoundTileRenderer());
initRenderers();
}
initRenderers();
}
private void initRenderers() {
LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId();
private void initRenderers() {
LibRenderIDs.idAltar = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idSpecialFlower = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idSpreader = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idPool = RenderingRegistry.getNextAvailableRenderId();
LibRenderIDs.idPylon = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(new RenderAltar());
RenderingRegistry.registerBlockHandler(new RenderSpecialFlower(LibRenderIDs.idSpecialFlower));
RenderingRegistry.registerBlockHandler(new RenderSpreader());
RenderingRegistry.registerBlockHandler(new RenderPool());
RenderingRegistry.registerBlockHandler(new RenderPylon());
RenderingRegistry.registerBlockHandler(new RenderAltar());
RenderingRegistry.registerBlockHandler(new RenderSpecialFlower(LibRenderIDs.idSpecialFlower));
RenderingRegistry.registerBlockHandler(new RenderSpreader());
RenderingRegistry.registerBlockHandler(new RenderPool());
RenderingRegistry.registerBlockHandler(new RenderPylon());
MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens());
if(ConfigHandler.lexicon3dModel)
MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon());
MinecraftForgeClient.registerItemRenderer(ModItems.lens, new RenderLens());
if(ConfigHandler.lexicon3dModel)
MinecraftForgeClient.registerItemRenderer(ModItems.lexicon, new RenderLexicon());
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader());
ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool());
ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter());
ShaderHelper.initShaders();
}
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderTileAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TileSpreader.class, new RenderTileSpreader());
ClientRegistry.bindTileEntitySpecialRenderer(TilePool.class, new RenderTilePool());
ClientRegistry.bindTileEntitySpecialRenderer(TileRuneAltar.class, new RenderTileRuneAltar());
ClientRegistry.bindTileEntitySpecialRenderer(TilePylon.class, new RenderTilePylon());
ClientRegistry.bindTileEntitySpecialRenderer(TileEnchanter.class, new RenderTileEnchanter());
@Override
public void setEntryToOpen(LexiconEntry entry) {
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category));
}
ShaderHelper.initShaders();
}
@Override
public long getWorldElapsedTicks() {
return Minecraft.getMinecraft().theWorld == null ? 0 : Minecraft.getMinecraft().theWorld.getTotalWorldTime();
}
@Override
public void setEntryToOpen(LexiconEntry entry) {
GuiLexicon.currentOpenLexicon = new GuiLexiconEntry(entry, new GuiLexiconIndex(entry.category));
}
@Override
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) {
FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m);
sparkle.fake = sparkle.noClip = fake;
Minecraft.getMinecraft().effectRenderer.addEffect(sparkle);
}
@Override
public long getWorldElapsedTicks() {
return Minecraft.getMinecraft().theWorld == null ? 0 : Minecraft.getMinecraft().theWorld.getTotalWorldTime();
}
private static boolean distanceLimit = true;
@Override
public void sparkleFX(World world, double x, double y, double z, float r, float g, float b, float size, int m, boolean fake) {
FXSparkle sparkle = new FXSparkle(world, x, y, z, size, r, g, b, m);
sparkle.fake = sparkle.noClip = fake;
Minecraft.getMinecraft().effectRenderer.addEffect(sparkle);
}
@Override
public void setWispFXDistanceLimit(boolean limit) {
distanceLimit = limit;
}
private static boolean distanceLimit = true;
@Override
public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) {
FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, maxAgeMul);
wisp.motionX = motionx;
wisp.motionY = motiony;
wisp.motionZ = motionz;
@Override
public void setWispFXDistanceLimit(boolean limit) {
distanceLimit = limit;
}
Minecraft.getMinecraft().effectRenderer.addEffect(wisp);
}
@Override
public void wispFX(World world, double x, double y, double z, float r, float g, float b, float size, float motionx, float motiony, float motionz, float maxAgeMul) {
FXWisp wisp = new FXWisp(world, x, y, z, size, r, g, b, distanceLimit, maxAgeMul);
wisp.motionX = motionx;
wisp.motionY = motiony;
wisp.motionZ = motionz;
@Override
public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner);
}
Minecraft.getMinecraft().effectRenderer.addEffect(wisp);
}
@Override
public void lightningFX(World world, Vector3 vectorStart, Vector3 vectorEnd, float ticksPerMeter, long seed, int colorOuter, int colorInner) {
LightningHandler.spawnLightningBolt(world, vectorStart, vectorEnd, ticksPerMeter, seed, colorOuter, colorInner);
}
}
+155 -160
View File
@@ -2,11 +2,11 @@
* This class was created by <Azanor>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.client.fx;
@@ -17,206 +17,201 @@ import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.ObfuscationHelper;
public class FXSparkle extends EntityFX {
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES);
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_PARTICLES);
public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
public FXSparkle(World world, double x, double y, double z, float size, float red, float green, float blue, int m) {
super(world, x, y, z, 0.0D, 0.0D, 0.0D);
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleGravity = 0;
motionX = motionY = motionZ = 0;
particleScale *= size;
particleMaxAge = 3 * m;
multiplier = m;
noClip = false;
setSize(0.01F, 0.01F);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleGravity = 0;
motionX = motionY = motionZ = 0;
particleScale *= size;
particleMaxAge = 3 * m;
multiplier = m;
noClip = false;
setSize(0.01F, 0.01F);
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
tessellator.draw();
GL11.glPushMatrix();
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
tessellator.draw();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
int part = particle + particleAge/multiplier;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
int part = particle + particleAge / multiplier;
float var8 = part % 8 / 8.0F;
float var9 = var8 + 0.0624375F*2;
float var10 = part / 8 / 8.0F;
float var11 = var10 + 0.0624375F*2;
float var12 = 0.1F * particleScale;
if (shrink) var12 *= (particleMaxAge-particleAge+1)/(float)particleMaxAge;
float var13 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX);
float var14 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY);
float var15 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
float var16 = 1.0F;
float var8 = part % 8 / 8.0F;
float var9 = var8 + 0.0624375F * 2;
float var10 = part / 8 / 8.0F;
float var11 = var10 + 0.0624375F * 2;
float var12 = 0.1F * particleScale;
if(shrink) var12 *= (particleMaxAge - particleAge + 1) / (float) particleMaxAge;
float var13 = (float) (prevPosX + (posX - prevPosX) * f - interpPosX);
float var14 = (float) (prevPosY + (posY - prevPosY) * f - interpPosY);
float var15 = (float) (prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
float var16 = 1.0F;
tessellator.startDrawingQuads();
tessellator.setBrightness(0x0000f0);
tessellator.startDrawingQuads();
tessellator.setBrightness(0x0000f0);
tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1);
tessellator.addVertexWithUV(var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11);
tessellator.addVertexWithUV(var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11);
tessellator.setColorRGBA_F(particleRed * var16, particleGreen * var16, particleBlue * var16, 1);
tessellator.addVertexWithUV(var13 - f1 * var12 - f4 * var12, var14 - f2 * var12, var15 - f3 * var12 - f5 * var12, var9, var11);
tessellator.addVertexWithUV(var13 - f1 * var12 + f4 * var12, var14 + f2 * var12, var15 - f3 * var12 + f5 * var12, var9, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 + f4 * var12, var14 + f2 * var12, var15 + f3 * var12 + f5 * var12, var8, var10);
tessellator.addVertexWithUV(var13 + f1 * var12 - f4 * var12, var14 - f2 * var12, var15 + f3 * var12 - f5 * var12, var8, var11);
tessellator.draw();
tessellator.draw();
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
@Override
public void onUpdate() {
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
@Override
public void onUpdate() {
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
if (particleAge++ >= particleMaxAge)
setDead();
if(particleAge++ >= particleMaxAge) setDead();
motionY -= 0.04D * particleGravity;
motionY -= 0.04D * particleGravity;
if (!noClip && !fake)
pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ);
if(!noClip && !fake) pushOutOfBlocks(posX, (boundingBox.minY + boundingBox.maxY) / 2.0D, posZ);
posX += motionX;
posY += motionY;
posZ += motionZ;
posX += motionX;
posY += motionY;
posZ += motionZ;
if (slowdown) {
motionX *= 0.908000001907348633D;
motionY *= 0.908000001907348633D;
motionZ *= 0.908000001907348633D;
if(slowdown) {
motionX *= 0.908000001907348633D;
motionY *= 0.908000001907348633D;
motionZ *= 0.908000001907348633D;
if (onGround) {
motionX *= 0.69999998807907104D;
motionZ *= 0.69999998807907104D;
}
}
if(onGround) {
motionX *= 0.69999998807907104D;
motionZ *= 0.69999998807907104D;
}
}
if(fake && particleAge > 1)
setDead();
}
if(fake && particleAge > 1) setDead();
}
public void setGravity(float value) {
particleGravity = value;
}
public void setGravity(float value) {
particleGravity = value;
}
protected boolean pushOutOfBlocks(double par1, double par3, double par5) {
int var7 = MathHelper.floor_double(par1);
int var8 = MathHelper.floor_double(par3);
int var9 = MathHelper.floor_double(par5);
double var10 = par1 - var7;
double var12 = par3 - var8;
double var14 = par5 - var9;
protected boolean pushOutOfBlocks(double par1, double par3, double par5) {
int var7 = MathHelper.floor_double(par1);
int var8 = MathHelper.floor_double(par3);
int var9 = MathHelper.floor_double(par5);
double var10 = par1 - var7;
double var12 = par3 - var8;
double var14 = par5 - var9;
if (!worldObj.isAirBlock(var7, var8, var9)) {
boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false);
boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false);
boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false);
boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false);
boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false);
boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false);
byte var22 = -1;
double var23 = 9999.0D;
if(!worldObj.isAirBlock(var7, var8, var9)) {
boolean var16 = !worldObj.isBlockNormalCubeDefault(var7 - 1, var8, var9, false);
boolean var17 = !worldObj.isBlockNormalCubeDefault(var7 + 1, var8, var9, false);
boolean var18 = !worldObj.isBlockNormalCubeDefault(var7, var8 - 1, var9, false);
boolean var19 = !worldObj.isBlockNormalCubeDefault(var7, var8 + 1, var9, false);
boolean var20 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 - 1, false);
boolean var21 = !worldObj.isBlockNormalCubeDefault(var7, var8, var9 + 1, false);
byte var22 = -1;
double var23 = 9999.0D;
if (var16 && var10 < var23) {
var23 = var10;
var22 = 0;
}
if(var16 && var10 < var23) {
var23 = var10;
var22 = 0;
}
if (var17 && 1.0D - var10 < var23) {
var23 = 1.0D - var10;
var22 = 1;
}
if(var17 && 1.0D - var10 < var23) {
var23 = 1.0D - var10;
var22 = 1;
}
if (var18 && var12 < var23) {
var23 = var12;
var22 = 2;
}
if(var18 && var12 < var23) {
var23 = var12;
var22 = 2;
}
if (var19 && 1.0D - var12 < var23) {
var23 = 1.0D - var12;
var22 = 3;
}
if(var19 && 1.0D - var12 < var23) {
var23 = 1.0D - var12;
var22 = 3;
}
if (var20 && var14 < var23) {
var23 = var14;
var22 = 4;
}
if(var20 && var14 < var23) {
var23 = var14;
var22 = 4;
}
if (var21 && 1.0D - var14 < var23) {
var23 = 1.0D - var14;
var22 = 5;
}
if(var21 && 1.0D - var14 < var23) {
var23 = 1.0D - var14;
var22 = 5;
}
float var25 = rand.nextFloat() * 0.05F + 0.025F;
float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F;
float var25 = rand.nextFloat() * 0.05F + 0.025F;
float var26 = (rand.nextFloat() - rand.nextFloat()) * 0.1F;
if (var22 == 0) {
motionX = -var25;
motionY=motionZ=var26;
}
if(var22 == 0) {
motionX = -var25;
motionY = motionZ = var26;
}
if (var22 == 1) {
motionX = var25;
motionY=motionZ=var26;
}
if(var22 == 1) {
motionX = var25;
motionY = motionZ = var26;
}
if (var22 == 2) {
motionY = -var25;
motionX=motionZ=var26;
}
if(var22 == 2) {
motionY = -var25;
motionX = motionZ = var26;
}
if (var22 == 3) {
motionY = var25;
motionX=motionZ=var26;
}
if(var22 == 3) {
motionY = var25;
motionX = motionZ = var26;
}
if (var22 == 4) {
motionZ = -var25;
motionY=motionX=var26;
}
if(var22 == 4) {
motionZ = -var25;
motionY = motionX = var26;
}
if (var22 == 5) {
motionZ = var25;
motionY=motionX=var26;
}
if(var22 == 5) {
motionZ = var25;
motionY = motionX = var26;
}
return true;
} else return false;
}
return true;
} else return false;
}
public boolean fake = false;
public int multiplier = 2;
public boolean shrink = true;
public int particle = 16;
public boolean tinkle = false;
public int blendmode = 1;
public boolean slowdown = true;
public int currentColor = 0;
public boolean fake = false;
public int multiplier = 2;
public boolean shrink = true;
public int particle = 16;
public boolean tinkle = false;
public int blendmode = 1;
public boolean slowdown = true;
public int currentColor = 0;
}
+80 -86
View File
@@ -2,130 +2,124 @@
* This class was created by <Azanor>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [? (GMT)]
*/
package vazkii.botania.client.fx;
import cpw.mods.fml.client.FMLClientHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.ObfuscationHelper;
import cpw.mods.fml.client.FMLClientHandler;
public class FXWisp extends EntityFX {
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE);
public static final ResourceLocation particles = new ResourceLocation(LibResources.MISC_WISP_LARGE);
public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, float maxAgeMul) {
super(world, d, d1, d2, 0.0D, 0.0D, 0.0D);
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleGravity = 0;
motionX = motionY = motionZ = 0;
particleScale *= size;
moteParticleScale = particleScale;
particleMaxAge = (int)(28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul);
public FXWisp(World world, double d, double d1, double d2, float size, float red, float green, float blue, boolean distanceLimit, float maxAgeMul) {
super(world, d, d1, d2, 0.0D, 0.0D, 0.0D);
particleRed = red;
particleGreen = green;
particleBlue = blue;
particleGravity = 0;
motionX = motionY = motionZ = 0;
particleScale *= size;
moteParticleScale = particleScale;
particleMaxAge = (int) (28D / (Math.random() * 0.3D + 0.7D) * maxAgeMul);
moteHalfLife = particleMaxAge / 2;
noClip = true;
setSize(0.01F, 0.01F);
EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
moteHalfLife = particleMaxAge / 2;
noClip = true;
setSize(0.01F, 0.01F);
EntityLivingBase renderentity = FMLClientHandler.instance().getClient().renderViewEntity;
if(distanceLimit) {
int visibleDistance = 50;
if (!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics)
visibleDistance = 25;
if(distanceLimit) {
int visibleDistance = 50;
if(!FMLClientHandler.instance().getClient().gameSettings.fancyGraphics) visibleDistance = 25;
if (renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance)
particleMaxAge = 0;
}
if(renderentity == null || renderentity.getDistance(posX, posY, posZ) > visibleDistance) particleMaxAge = 0;
}
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
}
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
float agescale = 0;
agescale = (float)particleAge / (float) moteHalfLife;
if (agescale > 1F)
agescale = 2 - agescale;
@Override
public void renderParticle(Tessellator tessellator, float f, float f1, float f2, float f3, float f4, float f5) {
float agescale = 0;
agescale = (float) particleAge / (float) moteHalfLife;
if(agescale > 1F) agescale = 2 - agescale;
particleScale = moteParticleScale * agescale;
particleScale = moteParticleScale * agescale;
tessellator.draw();
GL11.glPushMatrix();
tessellator.draw();
GL11.glPushMatrix();
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
GL11.glDepthMask(false);
GL11.glEnable(3042);
GL11.glBlendFunc(770, blendmode);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
Minecraft.getMinecraft().renderEngine.bindTexture(particles);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.75F);
float f10 = 0.5F * particleScale;
float f11 = (float)(prevPosX + (posX - prevPosX) * f - interpPosX);
float f12 = (float)(prevPosY + (posY - prevPosY) * f - interpPosY);
float f13 = (float)(prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
float f10 = 0.5F * particleScale;
float f11 = (float) (prevPosX + (posX - prevPosX) * f - interpPosX);
float f12 = (float) (prevPosY + (posY - prevPosY) * f - interpPosY);
float f13 = (float) (prevPosZ + (posZ - prevPosZ) * f - interpPosZ);
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F);
tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
tessellator.addVertexWithUV(f11 - f1 * f10 + f4 * f10, f12 + f2 * f10, f13 - f3 * f10 + f5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
tessellator.addVertexWithUV(f11 + f1 * f10 - f4 * f10, f12 - f2 * f10, f13 + f3 * f10 - f5 * f10, 0, 0);
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, 0.5F);
tessellator.addVertexWithUV(f11 - f1 * f10 - f4 * f10, f12 - f2 * f10, f13 - f3 * f10 - f5 * f10, 0, 1);
tessellator.addVertexWithUV(f11 - f1 * f10 + f4 * f10, f12 + f2 * f10, f13 - f3 * f10 + f5 * f10, 1, 1);
tessellator.addVertexWithUV(f11 + f1 * f10 + f4 * f10, f12 + f2 * f10, f13 + f3 * f10 + f5 * f10, 1, 0);
tessellator.addVertexWithUV(f11 + f1 * f10 - f4 * f10, f12 - f2 * f10, f13 + f3 * f10 - f5 * f10, 0, 0);
tessellator.draw();
tessellator.draw();
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glDisable(3042);
GL11.glDepthMask(true);
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
GL11.glPopMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(ObfuscationHelper.getParticleTexture());
tessellator.startDrawingQuads();
}
@Override
public void onUpdate() {
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
@Override
public void onUpdate() {
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
if (particleAge++ >= particleMaxAge)
setDead();
if(particleAge++ >= particleMaxAge) setDead();
motionY -= 0.04D * particleGravity;
posX += motionX;
posY += motionY;
posZ += motionZ;
motionX *= 0.98000001907348633D;
motionY *= 0.98000001907348633D;
motionZ *= 0.98000001907348633D;
}
motionY -= 0.04D * particleGravity;
posX += motionX;
posY += motionY;
posZ += motionZ;
motionX *= 0.98000001907348633D;
motionY *= 0.98000001907348633D;
motionZ *= 0.98000001907348633D;
}
public void setGravity(float value) {
particleGravity = value;
}
public void setGravity(float value) {
particleGravity = value;
}
public boolean distanceLimit = true;
float moteParticleScale;
int moteHalfLife;
public boolean tinkle = false;
public int blendmode = 1;
public boolean distanceLimit = true;
float moteParticleScale;
int moteHalfLife;
public boolean tinkle = false;
public int blendmode = 1;
}
@@ -2,24 +2,20 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:48:05 PM (GMT)]
*/
package vazkii.botania.client.gui;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.LexiconCategory;
import vazkii.botania.client.core.handler.ClientTickHandler;
@@ -27,92 +23,92 @@ import vazkii.botania.client.gui.button.GuiButtonInvisible;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.item.ModItems;
import java.util.List;
public class GuiLexicon extends GuiScreen {
public static GuiLexicon currentOpenLexicon = new GuiLexicon();
public static GuiLexicon currentOpenLexicon = new GuiLexicon();
public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON);
public static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_LEXICON);
int guiWidth = 146;
int guiHeight = 180;
int left, top;
int guiWidth = 146;
int guiHeight = 180;
int left, top;
@Override
public void initGui() {
super.initGui();
currentOpenLexicon = this;
@Override
public void initGui() {
super.initGui();
currentOpenLexicon = this;
left = width / 2 - guiWidth / 2;
top = height / 2 - guiHeight / 2;
left = width / 2 - guiWidth / 2;
top = height / 2 - guiHeight / 2;
buttonList.clear();
if(isIndex()) {
int x = 18;
for(int i = 0; i < 12; i++) {
int y = 16 + i * 12;
buttonList.add(new GuiButtonInvisible(i, left + x, top + y, 110, 10, ""));
}
populateIndex();
}
}
buttonList.clear();
if(isIndex()) {
int x = 18;
for(int i = 0; i < 12; i++) {
int y = 16 + i * 12;
buttonList.add(new GuiButtonInvisible(i, left + x, top + y, 110, 10, ""));
}
populateIndex();
}
}
@Override
public void drawScreen(int par1, int par2, float par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight);
drawCenteredString(fontRendererObj, getTitle(), left + guiWidth / 2, top - 12, 0x00FF00);
@Override
public void drawScreen(int par1, int par2, float par3) {
GL11.glColor4f(1F, 1F, 1F, 1F);
mc.renderEngine.bindTexture(texture);
drawTexturedModalRect(left, top, 0, 0, guiWidth, guiHeight);
drawCenteredString(fontRendererObj, getTitle(), left + guiWidth / 2, top - 12, 0x00FF00);
drawHeader();
drawHeader();
super.drawScreen(par1, par2, par3);
}
super.drawScreen(par1, par2, par3);
}
void drawHeader() {
boolean unicode = fontRendererObj.getUnicodeFlag();
fontRendererObj.setUnicodeFlag(true);
fontRendererObj.drawSplitString(StatCollector.translateToLocal("botania.gui.lexicon.header"), left + 15, top + 20, 110, 0);
fontRendererObj.setUnicodeFlag(unicode);
}
void drawHeader() {
boolean unicode = fontRendererObj.getUnicodeFlag();
fontRendererObj.setUnicodeFlag(true);
fontRendererObj.drawSplitString(StatCollector.translateToLocal("botania.gui.lexicon.header"), left + 15, top + 20, 110, 0);
fontRendererObj.setUnicodeFlag(unicode);
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
int i = par1GuiButton.id - 3;
if(i < 0)
return;
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
int i = par1GuiButton.id - 3;
if(i < 0) return;
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
LexiconCategory category = i >= categoryList.size() ? null : categoryList.get(i);
if(category != null) {
mc.displayGuiScreen(new GuiLexiconIndex(category));
ClientTickHandler.notifyPageChange();
}
}
if(category != null) {
mc.displayGuiScreen(new GuiLexiconIndex(category));
ClientTickHandler.notifyPageChange();
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
String getTitle() {
return ModItems.lexicon.getItemStackDisplayName(null);
}
String getTitle() {
return ModItems.lexicon.getItemStackDisplayName(null);
}
boolean isIndex() {
return true;
}
boolean isIndex() {
return true;
}
void populateIndex() {
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
for(int i = 3; i < 12; i++) {
int i_ = i - 3;
GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i);
LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_);
if(category != null)
button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName());
else button.displayString = "";
}
}
void populateIndex() {
List<LexiconCategory> categoryList = BotaniaAPI.getAllCategories();
for(int i = 3; i < 12; i++) {
int i_ = i - 3;
GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i);
LexiconCategory category = i_ >= categoryList.size() ? null : categoryList.get(i_);
if(category != null) button.displayString = StatCollector.translateToLocal(category.getUnlocalizedName());
else button.displayString = "";
}
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:47:06 PM (GMT)]
*/
package vazkii.botania.client.gui;
@@ -23,117 +23,117 @@ import vazkii.botania.client.gui.button.GuiButtonPage;
public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry {
public int page = 0;
LexiconEntry entry;
GuiScreen parent;
String title;
public int page = 0;
LexiconEntry entry;
GuiScreen parent;
String title;
GuiButton leftButton, rightButton;
GuiButton leftButton, rightButton;
public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) {
this.entry = entry;
this.parent = parent;
public GuiLexiconEntry(LexiconEntry entry, GuiScreen parent) {
this.entry = entry;
this.parent = parent;
title = StatCollector.translateToLocal(entry.getUnlocalizedName());
}
title = StatCollector.translateToLocal(entry.getUnlocalizedName());
}
@Override
public void initGui() {
super.initGui();
@Override
public void initGui() {
super.initGui();
buttonList.add(new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
buttonList.add(new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
buttonList.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
updatePageButtons();
}
updatePageButtons();
}
@Override
public LexiconEntry getEntry() {
return entry;
}
@Override
public LexiconEntry getEntry() {
return entry;
}
@Override
public int getPageOn() {
return page;
}
@Override
public int getPageOn() {
return page;
}
@Override
boolean isIndex() {
return false;
}
@Override
boolean isIndex() {
return false;
}
@Override
void drawHeader() {
// NO-OP
}
@Override
void drawHeader() {
// NO-OP
}
@Override
String getTitle() {
return String.format("%s (%s/%s)", title, page + 1, entry.pages.size());
}
@Override
String getTitle() {
return String.format("%s (%s/%s)", title, page + 1, entry.pages.size());
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
switch(par1GuiButton.id) {
case 0 :
mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent);
ClientTickHandler.notifyPageChange();
break;
case 1 :
page--;
ClientTickHandler.notifyPageChange();
break;
case 2 :
page++;
ClientTickHandler.notifyPageChange();
break;
}
updatePageButtons();
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
switch(par1GuiButton.id) {
case 0:
mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent);
ClientTickHandler.notifyPageChange();
break;
case 1:
page--;
ClientTickHandler.notifyPageChange();
break;
case 2:
page++;
ClientTickHandler.notifyPageChange();
break;
}
updatePageButtons();
}
public void updatePageButtons() {
leftButton.enabled = page != 0;
rightButton.enabled = page + 1 < entry.pages.size();
}
public void updatePageButtons() {
leftButton.enabled = page != 0;
rightButton.enabled = page + 1 < entry.pages.size();
}
@Override
public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
@Override
public void drawScreen(int par1, int par2, float par3) {
super.drawScreen(par1, par2, par3);
LexiconPage page = entry.pages.get(this.page);
page.renderScreen(this, par1, par2);
}
LexiconPage page = entry.pages.get(this.page);
page.renderScreen(this, par1, par2);
}
@Override
public void updateScreen() {
LexiconPage page = entry.pages.get(this.page);
page.updateScreen();
}
@Override
public void updateScreen() {
LexiconPage page = entry.pages.get(this.page);
page.updateScreen();
}
@Override
public int getLeft() {
return left;
}
@Override
public int getLeft() {
return left;
}
@Override
public int getTop() {
return top;
}
@Override
public int getTop() {
return top;
}
@Override
public int getWidth() {
return guiWidth;
}
@Override
public int getWidth() {
return guiWidth;
}
@Override
public int getHeight() {
return guiHeight;
}
@Override
public int getHeight() {
return guiHeight;
}
@Override
public float getZLevel() {
return zLevel;
}
@Override
public float getZLevel() {
return zLevel;
}
}
@@ -2,19 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 6:46:59 PM (GMT)]
*/
package vazkii.botania.client.gui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
@@ -25,89 +21,92 @@ import vazkii.botania.client.gui.button.GuiButtonBack;
import vazkii.botania.client.gui.button.GuiButtonInvisible;
import vazkii.botania.client.gui.button.GuiButtonPage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class GuiLexiconIndex extends GuiLexicon {
LexiconCategory category;
String title;
int page = 0;
LexiconCategory category;
String title;
int page = 0;
GuiButton leftButton, rightButton;
GuiButton leftButton, rightButton;
List<LexiconEntry> entriesToDisplay = new ArrayList();
List<LexiconEntry> entriesToDisplay = new ArrayList();
public GuiLexiconIndex(LexiconCategory category) {
this.category = category;
title = StatCollector.translateToLocal(category.getUnlocalizedName());
}
public GuiLexiconIndex(LexiconCategory category) {
this.category = category;
title = StatCollector.translateToLocal(category.getUnlocalizedName());
}
@Override
void drawHeader() {
// NO-OP
}
@Override
void drawHeader() {
// NO-OP
}
@Override
String getTitle() {
return title;
}
@Override
String getTitle() {
return title;
}
@Override
public void initGui() {
super.initGui();
buttonList.add(new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true));
@Override
public void initGui() {
super.initGui();
buttonList.add(new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false));
buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true));
entriesToDisplay.clear();
entriesToDisplay.addAll(category.entries);
Collections.sort(entriesToDisplay);
entriesToDisplay.clear();
entriesToDisplay.addAll(category.entries);
Collections.sort(entriesToDisplay);
updatePageButtons();
populateIndex();
}
updatePageButtons();
populateIndex();
}
@Override
void populateIndex() {
for(int i = page * 12; i < (page + 1) * 12; i++) {
GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12);
LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i);
if(entry != null)
button.displayString = (entry.isPriority() ? EnumChatFormatting.ITALIC : "") + StatCollector.translateToLocal(entry.getUnlocalizedName());
else button.displayString = "";
}
}
@Override
void populateIndex() {
for(int i = page * 12; i < (page + 1) * 12; i++) {
GuiButtonInvisible button = (GuiButtonInvisible) buttonList.get(i - page * 12);
LexiconEntry entry = i >= entriesToDisplay.size() ? null : entriesToDisplay.get(i);
if(entry != null)
button.displayString = (entry.isPriority() ? EnumChatFormatting.ITALIC : "") + StatCollector.translateToLocal(entry.getUnlocalizedName());
else button.displayString = "";
}
}
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
switch(par1GuiButton.id) {
case 12 :
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
break;
case 13 :
page--;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
case 14 :
page++;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
default :
int index = par1GuiButton.id + page * 12;
if(index >= entriesToDisplay.size())
return;
@Override
protected void actionPerformed(GuiButton par1GuiButton) {
switch(par1GuiButton.id) {
case 12:
mc.displayGuiScreen(new GuiLexicon());
ClientTickHandler.notifyPageChange();
break;
case 13:
page--;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
case 14:
page++;
updatePageButtons();
populateIndex();
ClientTickHandler.notifyPageChange();
break;
default:
int index = par1GuiButton.id + page * 12;
if(index >= entriesToDisplay.size()) return;
LexiconEntry entry = entriesToDisplay.get(index);
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
ClientTickHandler.notifyPageChange();
}
}
LexiconEntry entry = entriesToDisplay.get(index);
mc.displayGuiScreen(new GuiLexiconEntry(entry, this));
ClientTickHandler.notifyPageChange();
}
}
public void updatePageButtons() {
leftButton.enabled = page != 0;
rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12;
}
public void updatePageButtons() {
leftButton.enabled = page != 0;
rightButton.enabled = page < (entriesToDisplay.size() - 1) / 12;
}
}
@@ -2,50 +2,47 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 9:54:21 PM (GMT)]
*/
package vazkii.botania.client.gui.button;
import java.util.Arrays;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.GuiLexicon;
import java.util.Arrays;
import java.util.List;
public class GuiButtonBack extends GuiButton {
public GuiButtonBack(int par1, int par2, int par3) {
super(par1, par2, par3, 18, 9, "");
}
public GuiButtonBack(int par1, int par2, int par3) {
super(par1, par2, par3, 18, 9, "");
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, 36, k == 2 ? 180 : 189, 18, 9);
List<String> tooltip = getTooltip();
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2)
RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
List<String> tooltip = getTooltip();
int tooltipY = (tooltip.size() - 1) * 10;
if(k == 2) RenderHelper.renderTooltip(par2, par3 + tooltipY, tooltip);
}
public List<String> getTooltip() {
return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"));
}
public List<String> getTooltip() {
return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"));
}
}
@@ -2,30 +2,30 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 6, 2014, 6:35:32 PM (GMT)]
*/
package vazkii.botania.client.gui.button;
import java.util.Arrays;
import java.util.List;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import java.util.Arrays;
import java.util.List;
public class GuiButtonBackWithShift extends GuiButtonBack {
public GuiButtonBackWithShift(int par1, int par2, int par3) {
super(par1, par2, par3);
}
public GuiButtonBackWithShift(int par1, int par2, int par3) {
super(par1, par2, par3);
}
@Override
public List<String> getTooltip() {
return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"), EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex"));
}
@Override
public List<String> getTooltip() {
return Arrays.asList(StatCollector.translateToLocal("botaniamisc.back"), EnumChatFormatting.GRAY + StatCollector.translateToLocal("botaniamisc.clickToIndex"));
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 8:34:01 PM (GMT)]
*/
package vazkii.botania.client.gui.button;
@@ -16,19 +16,19 @@ import net.minecraft.client.gui.GuiButton;
public class GuiButtonInvisible extends GuiButton {
public GuiButtonInvisible(int par1, int par2, int par3, int par4, int par5, String par6Str) {
super(par1, par2, par3, par4, par5, par6Str);
}
public GuiButtonInvisible(int par1, int par2, int par3, int par4, int par5, String par6Str) {
super(par1, par2, par3, par4, par5, par6Str);
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag();
par1Minecraft.fontRenderer.setUnicodeFlag(true);
par1Minecraft.fontRenderer.drawString(displayString, xPosition + (k == 2 ? 5 : 0), yPosition + (height - 8) / 2, 0);
par1Minecraft.fontRenderer.setUnicodeFlag(unicode);
}
boolean unicode = par1Minecraft.fontRenderer.getUnicodeFlag();
par1Minecraft.fontRenderer.setUnicodeFlag(true);
par1Minecraft.fontRenderer.drawString(displayString, xPosition + (k == 2 ? 5 : 0), yPosition + (height - 8) / 2, 0);
par1Minecraft.fontRenderer.setUnicodeFlag(unicode);
}
}
@@ -2,48 +2,46 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 16, 2014, 4:52:06 PM (GMT)]
*/
package vazkii.botania.client.gui.button;
import java.util.Arrays;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.gui.GuiLexicon;
import java.util.Arrays;
public class GuiButtonPage extends GuiButton {
boolean right;
boolean right;
public GuiButtonPage(int par1, int par2, int par3, boolean right) {
super(par1, par2, par3, 18, 10, "");
this.right = right;
}
public GuiButtonPage(int par1, int par2, int par3, boolean right) {
super(par1, par2, par3, 18, 10, "");
this.right = right;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if(enabled) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3) {
if(enabled) {
field_146123_n = par2 >= xPosition && par3 >= yPosition && par2 < xPosition + width && par3 < yPosition + height;
int k = getHoverState(field_146123_n);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10);
par1Minecraft.renderEngine.bindTexture(GuiLexicon.texture);
GL11.glColor4f(1F, 1F, 1F, 1F);
drawTexturedModalRect(xPosition, yPosition, k == 2 ? 18 : 0, right ? 180 : 190, 18, 10);
if(k == 2)
RenderHelper.renderTooltip(par2, par3, Arrays.asList(StatCollector.translateToLocal(right ? "botaniamisc.nextPage" : "botaniamisc.prevPage")));
}
}
if(k == 2)
RenderHelper.renderTooltip(par2, par3, Arrays.asList(StatCollector.translateToLocal(right ? "botaniamisc.nextPage" : "botaniamisc.prevPage")));
}
}
}
@@ -2,21 +2,21 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 21, 2014, 8:03:06 PM (GMT)]
*/
package vazkii.botania.client.lib;
public final class LibRenderIDs {
public static int idAltar = -1;
public static int idSpecialFlower = -1;
public static int idSpreader = -1;
public static int idPool = -1;
public static int idPylon = -1;
public static int idAltar = -1;
public static int idSpecialFlower = -1;
public static int idSpreader = -1;
public static int idPool = -1;
public static int idPylon = -1;
}
@@ -2,74 +2,72 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 5:29:31 PM (GMT)]
*/
package vazkii.botania.client.lib;
public final class LibResources {
public static final String PREFIX_MOD = "botania:";
public static final String PREFIX_MOD = "botania:";
public static final String PREFIX_LANG = "/assets/botania/lang/";
public static final String PREFIX_SHADER = "/assets/botania/shader/";
public static final String PREFIX_LANG = "/assets/botania/lang/";
public static final String PREFIX_SHADER = "/assets/botania/shader/";
public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/";
public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/";
public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/";
public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/";
public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/";
public static final String EMTPY_TEXTURE = "emptyTexture";
public static final String PREFIX_GUI = PREFIX_MOD + "textures/gui/";
public static final String PREFIX_ENTRIES = PREFIX_GUI + "entries/";
public static final String PREFIX_MODEL = PREFIX_MOD + "textures/model/";
public static final String PREFIX_MISC = PREFIX_MOD + "textures/misc/";
public static final String PREFIX_OBJ_MODEL = PREFIX_MOD + "model/";
public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png";
public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png";
public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png";
public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png";
public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png";
public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png";
public static final String EMTPY_TEXTURE = "emptyTexture";
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png";
public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png";
public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png";
public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png";
public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png";
public static final String ENTRY_ENCHANTER0 = PREFIX_ENTRIES + "enchanter0.png";
public static final String ENTRY_ENCHANTER1 = PREFIX_ENTRIES + "enchanter1.png";
public static final String ENTRY_ENCHANTER2 = PREFIX_ENTRIES + "enchanter2.png";
public static final String ENTRY_ENCHANTER3 = PREFIX_ENTRIES + "enchanter3.png";
public static final String GUI_MANA_HUD = PREFIX_GUI + "manaHud.png";
public static final String GUI_LEXICON = PREFIX_GUI + "lexicon.png";
public static final String GUI_CRAFTING_OVERLAY = PREFIX_GUI + "craftingOverlay.png";
public static final String GUI_MANA_INFUSION_OVERLAY = PREFIX_GUI + "manaInfusionOverlay.png";
public static final String GUI_PETAL_OVERLAY = PREFIX_GUI + "petalOverlay.png";
public static final String GUI_TERRASTEEL_OVERLAY = PREFIX_GUI + "terrasteelOverlay.png";
public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png";
public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png";
public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png";
public static final String MODEL_POOL = PREFIX_MODEL + "pool.png";
public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png";
public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png";
public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png";
public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png";
public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png";
public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png";
public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png";
public static final String MODEL_CAPE = "/assets/botania/textures/model/cape.png";
public static final String ENTRY_FLOWERS = PREFIX_ENTRIES + "flowers.png";
public static final String ENTRY_APOTHECARY = PREFIX_ENTRIES + "apothecary.png";
public static final String ENTRY_PURE_DAISY = PREFIX_ENTRIES + "pureDaisy.png";
public static final String ENTRY_SPREADER = PREFIX_ENTRIES + "spreader.png";
public static final String ENTRY_UNSTABLE_BLOCK = PREFIX_ENTRIES + "unstableBlock.png";
public static final String ENTRY_UNSTABLE_BEACON = PREFIX_ENTRIES + "unstableBeacon.png";
public static final String ENTRY_ENCHANTER0 = PREFIX_ENTRIES + "enchanter0.png";
public static final String ENTRY_ENCHANTER1 = PREFIX_ENTRIES + "enchanter1.png";
public static final String ENTRY_ENCHANTER2 = PREFIX_ENTRIES + "enchanter2.png";
public static final String ENTRY_ENCHANTER3 = PREFIX_ENTRIES + "enchanter3.png";
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png";
public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png";
public static final String MODEL_ALTAR = PREFIX_MODEL + "altar.png";
public static final String MODEL_SPREADER = PREFIX_MODEL + "spreader.png";
public static final String MODEL_SPREADER_REDSTONE = PREFIX_MODEL + "spreaderRedstone.png";
public static final String MODEL_POOL = PREFIX_MODEL + "pool.png";
public static final String MODEL_PYLON_OLD = PREFIX_MODEL + "pylonOld.png";
public static final String MODEL_PYLON = PREFIX_MODEL + "pylon.png";
public static final String MODEL_LEXICA = PREFIX_MODEL + "lexica.png";
public static final String MODEL_MANASTEEL_0 = PREFIX_MODEL + "manasteel0.png";
public static final String MODEL_MANASTEEL_1 = PREFIX_MODEL + "manasteel1.png";
public static final String MODEL_TERRASTEEL_0 = PREFIX_MODEL + "terrasteel0.png";
public static final String MODEL_TERRASTEEL_1 = PREFIX_MODEL + "terrasteel1.png";
public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj";
public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag";
public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag";
public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag";
public static final String MODEL_CAPE = "/assets/botania/textures/model/cape.png";
public static final String[] LANGS = new String[] {
"en_US", "de_DE"
};
public static final String MISC_PARTICLES = PREFIX_MISC + "particles.png";
public static final String MISC_WISP_LARGE = PREFIX_MISC + "wispLarge.png";
public static final String MISC_WISP_SMALL = PREFIX_MISC + "wispSmall.png";
public static final String OBJ_MODEL_PYLON = PREFIX_OBJ_MODEL + "pylon.obj";
public static final String SHADER_PYLON_GLOW_FRAG = PREFIX_SHADER + "pylon_glow.frag";
public static final String SHADER_ENCHANTER_RUNE_FRAG = PREFIX_SHADER + "enchanter_rune.frag";
public static final String SHADER_MANA_POOL_FRAG = PREFIX_SHADER + "mana_pool.frag";
public static final String[] LANGS = new String[]{"en_US", "de_DE"};
}
@@ -2,19 +2,21 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Apr 1, 2014, 6:23:24 PM (GMT)]
*/
package vazkii.botania.client.model;
public interface IPylonModel {
public void renderCrystal();
public void renderRing();
public void renderGems();
public void renderCrystal();
public void renderRing();
public void renderGems();
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 21, 2014, 7:56:15 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -16,74 +16,74 @@ import net.minecraft.client.model.ModelRenderer;
public class ModelAltar extends ModelBase {
ModelRenderer gobletBase;
ModelRenderer gobletBase2;
ModelRenderer gobletBase3;
ModelRenderer gobletStand;
ModelRenderer kelkBase;
ModelRenderer kelkBase2;
ModelRenderer kelkWall1;
ModelRenderer kelkWall2;
ModelRenderer kelkWall3;
ModelRenderer kelkWall4;
ModelRenderer gobletBase;
ModelRenderer gobletBase2;
ModelRenderer gobletBase3;
ModelRenderer gobletStand;
ModelRenderer kelkBase;
ModelRenderer kelkBase2;
ModelRenderer kelkWall1;
ModelRenderer kelkWall2;
ModelRenderer kelkWall3;
ModelRenderer kelkWall4;
public ModelAltar() {
textureWidth = 256;
textureHeight = 128;
public ModelAltar() {
textureWidth = 256;
textureHeight = 128;
gobletBase = new ModelRenderer(this, 0, 0);
gobletBase.addBox(0F, 0F, 0F, 16, 2, 16);
gobletBase.setRotationPoint(-8F, 22F, -8F);
gobletBase.setTextureSize(256, 128);
gobletBase2 = new ModelRenderer(this, 0, 18);
gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14);
gobletBase2.setRotationPoint(-7F, 21F, -7F);
gobletBase2.setTextureSize(256, 128);
gobletStand = new ModelRenderer(this, 68, 0);
gobletStand.addBox(0F, 0F, 0F, 6, 8, 6);
gobletStand.setRotationPoint(-3F, 12F, -3F);
gobletStand.setTextureSize(256, 128);
gobletBase3 = new ModelRenderer(this, 0, 33);
gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12);
gobletBase3.setRotationPoint(-6F, 20F, -6F);
gobletBase3.setTextureSize(256, 128);
kelkBase = new ModelRenderer(this, 72, 45);
kelkBase.addBox(0F, 0F, 0F, 8, 1, 8);
kelkBase.setRotationPoint(-4F, 11F, -4F);
kelkBase.setTextureSize(256, 128);
kelkBase2 = new ModelRenderer(this, 72, 34);
kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10);
kelkBase2.setRotationPoint(-5F, 10F, -5F);
kelkBase2.setTextureSize(256, 128);
kelkWall1 = new ModelRenderer(this, 72, 18);
kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10);
kelkWall1.setRotationPoint(5F, 4F, -5F);
kelkWall1.setTextureSize(256, 128);
kelkWall2 = new ModelRenderer(this, 72, 18);
kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10);
kelkWall2.setRotationPoint(-6F, 4F, -5F);
kelkWall2.setTextureSize(256, 128);
kelkWall3 = new ModelRenderer(this, 94, 18);
kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1);
kelkWall3.setRotationPoint(-5F, 4F, 5F);
kelkWall3.setTextureSize(256, 128);
kelkWall4 = new ModelRenderer(this, 94, 18);
kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1);
kelkWall4.setRotationPoint(-5F, 4F, -6F);
kelkWall4.setTextureSize(256, 128);
}
gobletBase = new ModelRenderer(this, 0, 0);
gobletBase.addBox(0F, 0F, 0F, 16, 2, 16);
gobletBase.setRotationPoint(-8F, 22F, -8F);
gobletBase.setTextureSize(256, 128);
gobletBase2 = new ModelRenderer(this, 0, 18);
gobletBase2.addBox(0F, 0F, 0F, 14, 1, 14);
gobletBase2.setRotationPoint(-7F, 21F, -7F);
gobletBase2.setTextureSize(256, 128);
gobletStand = new ModelRenderer(this, 68, 0);
gobletStand.addBox(0F, 0F, 0F, 6, 8, 6);
gobletStand.setRotationPoint(-3F, 12F, -3F);
gobletStand.setTextureSize(256, 128);
gobletBase3 = new ModelRenderer(this, 0, 33);
gobletBase3.addBox(0F, 0F, 0F, 12, 1, 12);
gobletBase3.setRotationPoint(-6F, 20F, -6F);
gobletBase3.setTextureSize(256, 128);
kelkBase = new ModelRenderer(this, 72, 45);
kelkBase.addBox(0F, 0F, 0F, 8, 1, 8);
kelkBase.setRotationPoint(-4F, 11F, -4F);
kelkBase.setTextureSize(256, 128);
kelkBase2 = new ModelRenderer(this, 72, 34);
kelkBase2.addBox(0F, 0F, 0F, 10, 1, 10);
kelkBase2.setRotationPoint(-5F, 10F, -5F);
kelkBase2.setTextureSize(256, 128);
kelkWall1 = new ModelRenderer(this, 72, 18);
kelkWall1.addBox(0F, 0F, 0F, 1, 6, 10);
kelkWall1.setRotationPoint(5F, 4F, -5F);
kelkWall1.setTextureSize(256, 128);
kelkWall2 = new ModelRenderer(this, 72, 18);
kelkWall2.addBox(0F, 0F, 0F, 1, 6, 10);
kelkWall2.setRotationPoint(-6F, 4F, -5F);
kelkWall2.setTextureSize(256, 128);
kelkWall3 = new ModelRenderer(this, 94, 18);
kelkWall3.addBox(0F, 0F, 0F, 10, 6, 1);
kelkWall3.setRotationPoint(-5F, 4F, 5F);
kelkWall3.setTextureSize(256, 128);
kelkWall4 = new ModelRenderer(this, 94, 18);
kelkWall4.addBox(0F, 0F, 0F, 10, 6, 1);
kelkWall4.setRotationPoint(-5F, 4F, -6F);
kelkWall4.setTextureSize(256, 128);
}
public void render() {
float f = 1F / 16F;
gobletBase.render(f);
gobletBase2.render(f);
gobletBase3.render(f);
gobletStand.render(f);
kelkBase.render(f);
kelkBase2.render(f);
kelkWall1.render(f);
kelkWall2.render(f);
kelkWall3.render(f);
kelkWall4.render(f);
}
public void render() {
float f = 1F / 16F;
gobletBase.render(f);
gobletBase2.render(f);
gobletBase3.render(f);
gobletStand.render(f);
kelkBase.render(f);
kelkBase2.render(f);
kelkWall1.render(f);
kelkWall2.render(f);
kelkWall3.render(f);
kelkWall4.render(f);
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 1:53:32 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -16,44 +16,44 @@ import net.minecraft.client.model.ModelRenderer;
public class ModelPool extends ModelBase {
ModelRenderer base;
ModelRenderer side1;
ModelRenderer side2;
ModelRenderer side3;
ModelRenderer side4;
ModelRenderer base;
ModelRenderer side1;
ModelRenderer side2;
ModelRenderer side3;
ModelRenderer side4;
public ModelPool() {
textureWidth = 64;
textureHeight = 32;
public ModelPool() {
textureWidth = 64;
textureHeight = 32;
base = new ModelRenderer(this, 0, 0);
base.addBox(0F, 0F, 0F, 16, 1, 16);
base.setRotationPoint(-8F, 23F, -8F);
base.setTextureSize(64, 32);
side1 = new ModelRenderer(this, 0, 0);
side1.addBox(0F, 0F, 0F, 16, 7, 1);
side1.setRotationPoint(-8F, 16F, 7F);
side1.setTextureSize(64, 32);
side2 = new ModelRenderer(this, 0, 0);
side2.addBox(0F, 0F, 0F, 16, 7, 1);
side2.setRotationPoint(-8F, 16F, -8F);
side2.setTextureSize(64, 32);
side3 = new ModelRenderer(this, 0, 0);
side3.addBox(0F, 0F, 0F, 1, 7, 14);
side3.setRotationPoint(-8F, 16F, -7F);
side3.setTextureSize(64, 32);
side4 = new ModelRenderer(this, 0, 0);
side4.addBox(0F, 0F, 0F, 1, 7, 14);
side4.setRotationPoint(7F, 16F, -7F);
side4.setTextureSize(64, 32);
}
base = new ModelRenderer(this, 0, 0);
base.addBox(0F, 0F, 0F, 16, 1, 16);
base.setRotationPoint(-8F, 23F, -8F);
base.setTextureSize(64, 32);
side1 = new ModelRenderer(this, 0, 0);
side1.addBox(0F, 0F, 0F, 16, 7, 1);
side1.setRotationPoint(-8F, 16F, 7F);
side1.setTextureSize(64, 32);
side2 = new ModelRenderer(this, 0, 0);
side2.addBox(0F, 0F, 0F, 16, 7, 1);
side2.setRotationPoint(-8F, 16F, -8F);
side2.setTextureSize(64, 32);
side3 = new ModelRenderer(this, 0, 0);
side3.addBox(0F, 0F, 0F, 1, 7, 14);
side3.setRotationPoint(-8F, 16F, -7F);
side3.setTextureSize(64, 32);
side4 = new ModelRenderer(this, 0, 0);
side4.addBox(0F, 0F, 0F, 1, 7, 14);
side4.setRotationPoint(7F, 16F, -7F);
side4.setTextureSize(64, 32);
}
public void render() {
float f = 1F / 16F;
base.render(f);
side1.render(f);
side2.render(f);
side3.render(f);
side4.render(f);
}
public void render() {
float f = 1F / 16F;
base.render(f);
side1.render(f);
side2.render(f);
side3.render(f);
side4.render(f);
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Apr 1, 2014, 6:21:48 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -14,31 +14,29 @@ package vazkii.botania.client.model;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.client.model.obj.GroupObject;
import net.minecraftforge.client.model.obj.WavefrontObject;
import vazkii.botania.client.lib.LibResources;
public class ModelPylon implements IPylonModel {
private IModelCustom model;
public ModelPylon() {
model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON));
}
@Override
public void renderCrystal() {
model.renderPart("Crystal");
}
private IModelCustom model;
@Override
public void renderRing() {
model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04");
}
@Override
public void renderGems() {
for(int i = 1; i < 5; i++)
model.renderPart("Ring_Gem0" + i);
}
public ModelPylon() {
model = AdvancedModelLoader.loadModel(new ResourceLocation(LibResources.OBJ_MODEL_PYLON));
}
@Override
public void renderCrystal() {
model.renderPart("Crystal");
}
@Override
public void renderRing() {
model.renderAllExcept("Crystal", "Ring_Gem01", "Ring_Gem02", "Ring_Gem03", "Ring_Gem04");
}
@Override
public void renderGems() {
for(int i = 1; i < 5; i++)
model.renderPart("Ring_Gem0" + i);
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 18, 2014, 10:05:39 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -16,144 +16,144 @@ import net.minecraft.client.model.ModelRenderer;
public class ModelPylonOld extends ModelBase implements IPylonModel {
ModelRenderer crystal1;
ModelRenderer crystal2;
ModelRenderer crystal3;
ModelRenderer crystal4;
ModelRenderer crystal5;
ModelRenderer crystal6;
ModelRenderer crystal7;
ModelRenderer crystal8;
ModelRenderer outside1;
ModelRenderer outside2;
ModelRenderer outside3;
ModelRenderer outside4;
ModelRenderer outside5;
ModelRenderer outside6;
ModelRenderer outside7;
ModelRenderer outside8;
ModelRenderer crystal1;
ModelRenderer crystal2;
ModelRenderer crystal3;
ModelRenderer crystal4;
ModelRenderer crystal5;
ModelRenderer crystal6;
ModelRenderer crystal7;
ModelRenderer crystal8;
ModelRenderer outside1;
ModelRenderer outside2;
ModelRenderer outside3;
ModelRenderer outside4;
ModelRenderer outside5;
ModelRenderer outside6;
ModelRenderer outside7;
ModelRenderer outside8;
public ModelPylonOld() {
textureWidth = 64;
textureHeight = 32;
public ModelPylonOld() {
textureWidth = 64;
textureHeight = 32;
crystal1 = new ModelRenderer(this, 0, 0);
crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal1.setRotationPoint(0F, 23F, 0F);
crystal1.setTextureSize(256, 128);
setRotation(crystal1, 0.1396263F, -0.418879F, 0F);
crystal2 = new ModelRenderer(this, 0, 0);
crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal2.setRotationPoint(0F, 23F, 0F);
crystal2.setTextureSize(256, 128);
setRotation(crystal2, -0.1396263F, 0.418879F, 0F);
crystal3 = new ModelRenderer(this, 0, 0);
crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal3.setRotationPoint(0F, 23F, 0F);
crystal3.setTextureSize(256, 128);
setRotation(crystal3, 0.1396263F, 0.418879F, 0F);
crystal4 = new ModelRenderer(this, 0, 0);
crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal4.setRotationPoint(0F, 23F, 0F);
crystal4.setTextureSize(256, 128);
setRotation(crystal4, -0.1396263F, -0.418879F, 0F);
crystal5 = new ModelRenderer(this, 0, 0);
crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal5.setRotationPoint(0F, 10F, 0F);
crystal5.setTextureSize(256, 128);
setRotation(crystal5, 0.1396263F, 0.418879F, 0F);
crystal6 = new ModelRenderer(this, 0, 0);
crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal6.setRotationPoint(0F, 10F, 0F);
crystal6.setTextureSize(256, 128);
setRotation(crystal6, 0.1396263F, -0.418879F, 0F);
crystal7 = new ModelRenderer(this, 0, 0);
crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal7.setRotationPoint(0F, 10F, 0F);
crystal7.setTextureSize(256, 128);
setRotation(crystal7, -0.1396263F, -0.418879F, 0F);
crystal8 = new ModelRenderer(this, 0, 0);
crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal8.setRotationPoint(0F, 10F, 0F);
crystal8.setTextureSize(256, 128);
setRotation(crystal8, -0.1396263F, 0.418879F, 0F);
outside1 = new ModelRenderer(this, 17, 0);
outside1.addBox(0F, -4F, -1.5F, 1, 8, 3);
outside1.setRotationPoint(4F, 18F, 0F);
outside1.setTextureSize(256, 128);
setRotation(outside1, 0F, 0F, 0.1396263F);
outside2 = new ModelRenderer(this, 17, 0);
outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3);
outside2.setRotationPoint(-4F, 18F, 0F);
outside2.setTextureSize(256, 128);
setRotation(outside2, 0F, 0F, -0.1396263F);
outside3 = new ModelRenderer(this, 26, 0);
outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1);
outside3.setRotationPoint(0F, 18F, -4F);
outside3.setTextureSize(256, 128);
setRotation(outside3, 0.0698132F, 0F, 0F);
outside4 = new ModelRenderer(this, 26, 0);
outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1);
outside4.setRotationPoint(0F, 18F, 4F);
outside4.setTextureSize(256, 128);
setRotation(outside4, -0.0698132F, 0F, 0F);
outside5 = new ModelRenderer(this, 27, 0);
outside5.addBox(0F, 0F, -4F, 1, 2, 8);
outside5.setRotationPoint(3F, 18F, 0F);
outside5.setTextureSize(256, 128);
setRotation(outside5, 0F, 0F, 0F);
outside6 = new ModelRenderer(this, 27, 0);
outside6.addBox(-1F, -1F, -4F, 1, 2, 8);
outside6.setRotationPoint(-3F, 19F, 0F);
outside6.setTextureSize(256, 128);
setRotation(outside6, 0F, 0F, 0F);
outside7 = new ModelRenderer(this, 17, 12);
outside7.addBox(-3F, -1F, 0F, 6, 2, 1);
outside7.setRotationPoint(0F, 19F, 3F);
outside7.setTextureSize(256, 128);
setRotation(outside7, 0F, 0F, 0F);
outside8 = new ModelRenderer(this, 17, 12);
outside8.addBox(-3F, -1F, -1F, 6, 2, 1);
outside8.setRotationPoint(0F, 19F, -3F);
outside8.setTextureSize(256, 128);
setRotation(outside8, 0F, 0F, 0F);
}
crystal1 = new ModelRenderer(this, 0, 0);
crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal1.setRotationPoint(0F, 23F, 0F);
crystal1.setTextureSize(256, 128);
setRotation(crystal1, 0.1396263F, -0.418879F, 0F);
crystal2 = new ModelRenderer(this, 0, 0);
crystal2.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal2.setRotationPoint(0F, 23F, 0F);
crystal2.setTextureSize(256, 128);
setRotation(crystal2, -0.1396263F, 0.418879F, 0F);
crystal3 = new ModelRenderer(this, 0, 0);
crystal3.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal3.setRotationPoint(0F, 23F, 0F);
crystal3.setTextureSize(256, 128);
setRotation(crystal3, 0.1396263F, 0.418879F, 0F);
crystal4 = new ModelRenderer(this, 0, 0);
crystal4.addBox(-1.5F, -7F, -1F, 3, 7, 2);
crystal4.setRotationPoint(0F, 23F, 0F);
crystal4.setTextureSize(256, 128);
setRotation(crystal4, -0.1396263F, -0.418879F, 0F);
crystal5 = new ModelRenderer(this, 0, 0);
crystal5.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal5.setRotationPoint(0F, 10F, 0F);
crystal5.setTextureSize(256, 128);
setRotation(crystal5, 0.1396263F, 0.418879F, 0F);
crystal6 = new ModelRenderer(this, 0, 0);
crystal6.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal6.setRotationPoint(0F, 10F, 0F);
crystal6.setTextureSize(256, 128);
setRotation(crystal6, 0.1396263F, -0.418879F, 0F);
crystal7 = new ModelRenderer(this, 0, 0);
crystal7.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal7.setRotationPoint(0F, 10F, 0F);
crystal7.setTextureSize(256, 128);
setRotation(crystal7, -0.1396263F, -0.418879F, 0F);
crystal8 = new ModelRenderer(this, 0, 0);
crystal8.addBox(-1.5F, 0F, -1F, 3, 7, 2);
crystal8.setRotationPoint(0F, 10F, 0F);
crystal8.setTextureSize(256, 128);
setRotation(crystal8, -0.1396263F, 0.418879F, 0F);
outside1 = new ModelRenderer(this, 17, 0);
outside1.addBox(0F, -4F, -1.5F, 1, 8, 3);
outside1.setRotationPoint(4F, 18F, 0F);
outside1.setTextureSize(256, 128);
setRotation(outside1, 0F, 0F, 0.1396263F);
outside2 = new ModelRenderer(this, 17, 0);
outside2.addBox(-1F, -4F, -1.5F, 1, 8, 3);
outside2.setRotationPoint(-4F, 18F, 0F);
outside2.setTextureSize(256, 128);
setRotation(outside2, 0F, 0F, -0.1396263F);
outside3 = new ModelRenderer(this, 26, 0);
outside3.addBox(-1.5F, -3F, -1F, 3, 6, 1);
outside3.setRotationPoint(0F, 18F, -4F);
outside3.setTextureSize(256, 128);
setRotation(outside3, 0.0698132F, 0F, 0F);
outside4 = new ModelRenderer(this, 26, 0);
outside4.addBox(-1.5F, -3F, 0F, 3, 6, 1);
outside4.setRotationPoint(0F, 18F, 4F);
outside4.setTextureSize(256, 128);
setRotation(outside4, -0.0698132F, 0F, 0F);
outside5 = new ModelRenderer(this, 27, 0);
outside5.addBox(0F, 0F, -4F, 1, 2, 8);
outside5.setRotationPoint(3F, 18F, 0F);
outside5.setTextureSize(256, 128);
setRotation(outside5, 0F, 0F, 0F);
outside6 = new ModelRenderer(this, 27, 0);
outside6.addBox(-1F, -1F, -4F, 1, 2, 8);
outside6.setRotationPoint(-3F, 19F, 0F);
outside6.setTextureSize(256, 128);
setRotation(outside6, 0F, 0F, 0F);
outside7 = new ModelRenderer(this, 17, 12);
outside7.addBox(-3F, -1F, 0F, 6, 2, 1);
outside7.setRotationPoint(0F, 19F, 3F);
outside7.setTextureSize(256, 128);
setRotation(outside7, 0F, 0F, 0F);
outside8 = new ModelRenderer(this, 17, 12);
outside8.addBox(-3F, -1F, -1F, 6, 2, 1);
outside8.setRotationPoint(0F, 19F, -3F);
outside8.setTextureSize(256, 128);
setRotation(outside8, 0F, 0F, 0F);
}
@Override
public void renderCrystal() {
float f = 1F / 16F;
crystal1.render(f);
crystal2.render(f);
crystal3.render(f);
crystal4.render(f);
crystal5.render(f);
crystal6.render(f);
crystal7.render(f);
crystal8.render(f);
}
@Override
public void renderCrystal() {
float f = 1F / 16F;
crystal1.render(f);
crystal2.render(f);
crystal3.render(f);
crystal4.render(f);
crystal5.render(f);
crystal6.render(f);
crystal7.render(f);
crystal8.render(f);
}
@Override
public void renderRing() {
float f = 1F / 16F;
outside1.render(f);
outside2.render(f);
outside3.render(f);
outside4.render(f);
outside5.render(f);
outside6.render(f);
outside7.render(f);
outside8.render(f);
}
@Override
public void renderRing() {
float f = 1F / 16F;
outside1.render(f);
outside2.render(f);
outside3.render(f);
outside4.render(f);
outside5.render(f);
outside6.render(f);
outside7.render(f);
outside8.render(f);
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
private void setRotation(ModelRenderer model, float x, float y, float z) {
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
@Override
public void renderGems() {
// NO-OP
}
@Override
public void renderGems() {
// NO-OP
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 2, 2014, 6:37:00 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -15,74 +15,71 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;
public class ModelSpinningCubes extends ModelBase {
ModelRenderer spinningCube;
ModelRenderer spinningCube;
public ModelSpinningCubes() {
spinningCube = new ModelRenderer(this, 42, 0);
spinningCube.addBox(0F, 0F, 0F, 1, 1, 1);
spinningCube.setRotationPoint(0F, 0F, 0F);
spinningCube.setTextureSize(64, 64);
}
public ModelSpinningCubes() {
spinningCube = new ModelRenderer(this, 42, 0);
spinningCube.addBox(0F, 0F, 0F, 1, 1, 1);
spinningCube.setRotationPoint(0F, 0F, 0F);
spinningCube.setTextureSize(64, 64);
}
public void renderSpinningCubes(int cubes, int repeat, int origRepeat) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
public void renderSpinningCubes(int cubes, int repeat, int origRepeat) {
GL11.glDisable(GL11.GL_TEXTURE_2D);
final float modifier = 6F;
final float rotationModifier = 0.2F;
final float radiusBase = 0.35F;
final float radiusMod = 0.05F;
final float modifier = 6F;
final float rotationModifier = 0.2F;
final float radiusBase = 0.35F;
final float radiusMod = 0.05F;
double ticks = Minecraft.getMinecraft().thePlayer.ticksExisted - 1.3 * (origRepeat - repeat);
float offsetPerCube = 360 / cubes;
double ticks = Minecraft.getMinecraft().thePlayer.ticksExisted - 1.3 * (origRepeat - repeat);
float offsetPerCube = 360 / cubes;
GL11.glPushMatrix();
GL11.glTranslatef(-0.025F, 0.85F, -0.025F);
for(int i = 0; i < cubes; i++) {
float offset = offsetPerCube * i;
float deg = (int) (ticks / rotationModifier % 360F + offset);
float rad = deg * (float) Math.PI / 180F;
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
float x = (float) (radiusX * Math.cos(rad));
float z = (float) (radiusZ * Math.sin(rad));
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
GL11.glPushMatrix();
GL11.glTranslatef(-0.025F, 0.85F, -0.025F);
for(int i = 0; i < cubes; i++) {
float offset = offsetPerCube * i;
float deg = (int) (ticks / rotationModifier % 360F + offset);
float rad = deg * (float) Math.PI / 180F;
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
float x = (float) (radiusX * Math.cos(rad));
float z = (float) (radiusZ * Math.sin(rad));
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
GL11.glRotatef(deg, xRotate, yRotate, zRotate);
if(repeat < origRepeat) {
GL11.glColor4f(1F, 1F, 1F, 0.2F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} else GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glRotatef(deg, xRotate, yRotate, zRotate);
if(repeat < origRepeat) {
GL11.glColor4f(1F, 1F, 1F, 0.2F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
} else GL11.glColor4f(1F, 1F, 1F, 1F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
spinningCube.render(1F / 16F);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
spinningCube.render(1F / 16F);
if(repeat < origRepeat)
GL11.glDisable(GL11.GL_BLEND);
if(repeat < origRepeat) GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
GL11.glPopMatrix();
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_TEXTURE_2D);
if(repeat != 0)
renderSpinningCubes(cubes, repeat - 1, origRepeat);
}
if(repeat != 0) renderSpinningCubes(cubes, repeat - 1, origRepeat);
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 1:55:05 PM (GMT)]
*/
package vazkii.botania.client.model;
@@ -16,74 +16,74 @@ import net.minecraft.client.model.ModelRenderer;
public class ModelSpreader extends ModelBase {
ModelRenderer cubeSide1;
ModelRenderer cubeSide2;
ModelRenderer cubeSide3;
ModelRenderer cubeSide4;
ModelRenderer cubeSide5;
ModelRenderer cubeHole1;
ModelRenderer cubeHole2;
ModelRenderer cubeHole3;
ModelRenderer cubeHole4;
ModelRenderer cubeInside;
ModelRenderer cubeSide1;
ModelRenderer cubeSide2;
ModelRenderer cubeSide3;
ModelRenderer cubeSide4;
ModelRenderer cubeSide5;
ModelRenderer cubeHole1;
ModelRenderer cubeHole2;
ModelRenderer cubeHole3;
ModelRenderer cubeHole4;
ModelRenderer cubeInside;
public ModelSpreader() {
textureWidth = 64;
textureHeight = 32;
public ModelSpreader() {
textureWidth = 64;
textureHeight = 32;
cubeSide1 = new ModelRenderer(this, 0, 0);
cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14);
cubeSide1.setRotationPoint(-7F, 22F, -7F);
cubeSide1.setTextureSize(64, 32);
cubeSide2 = new ModelRenderer(this, 0, 0);
cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1);
cubeSide2.setRotationPoint(-7F, 9F, -7F);
cubeSide2.setTextureSize(64, 32);
cubeSide3 = new ModelRenderer(this, 0, 0);
cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13);
cubeSide3.setRotationPoint(-7F, 9F, -6F);
cubeSide3.setTextureSize(64, 32);
cubeSide4 = new ModelRenderer(this, 0, 0);
cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13);
cubeSide4.setRotationPoint(6F, 9F, -6F);
cubeSide4.setTextureSize(64, 32);
cubeSide5 = new ModelRenderer(this, 0, 0);
cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13);
cubeSide5.setRotationPoint(-6F, 9F, -6F);
cubeSide5.setTextureSize(64, 32);
cubeHole1 = new ModelRenderer(this, 0, 0);
cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1);
cubeHole1.setRotationPoint(2F, 10F, 6F);
cubeHole1.setTextureSize(64, 32);
cubeHole2 = new ModelRenderer(this, 0, 0);
cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1);
cubeHole2.setRotationPoint(-6F, 10F, 6F);
cubeHole2.setTextureSize(64, 32);
cubeHole3 = new ModelRenderer(this, 0, 0);
cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1);
cubeHole3.setRotationPoint(-2F, 18F, 6F);
cubeHole3.setTextureSize(64, 32);
cubeHole4 = new ModelRenderer(this, 0, 0);
cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1);
cubeHole4.setRotationPoint(-2F, 10F, 6F);
cubeHole4.setTextureSize(64, 32);
cubeInside = new ModelRenderer(this, 30, 17);
cubeInside.addBox(0F, 0F, 0F, 6, 6, 6);
cubeInside.setRotationPoint(-3F, 13F, -3F);
cubeInside.setTextureSize(64, 32);
}
cubeSide1 = new ModelRenderer(this, 0, 0);
cubeSide1.addBox(0F, 0F, 0F, 14, 1, 14);
cubeSide1.setRotationPoint(-7F, 22F, -7F);
cubeSide1.setTextureSize(64, 32);
cubeSide2 = new ModelRenderer(this, 0, 0);
cubeSide2.addBox(0F, 0F, 0F, 14, 13, 1);
cubeSide2.setRotationPoint(-7F, 9F, -7F);
cubeSide2.setTextureSize(64, 32);
cubeSide3 = new ModelRenderer(this, 0, 0);
cubeSide3.addBox(0F, 0F, 0F, 1, 13, 13);
cubeSide3.setRotationPoint(-7F, 9F, -6F);
cubeSide3.setTextureSize(64, 32);
cubeSide4 = new ModelRenderer(this, 0, 0);
cubeSide4.addBox(0F, 0F, 0F, 1, 13, 13);
cubeSide4.setRotationPoint(6F, 9F, -6F);
cubeSide4.setTextureSize(64, 32);
cubeSide5 = new ModelRenderer(this, 0, 0);
cubeSide5.addBox(0F, 0F, 0F, 12, 1, 13);
cubeSide5.setRotationPoint(-6F, 9F, -6F);
cubeSide5.setTextureSize(64, 32);
cubeHole1 = new ModelRenderer(this, 0, 0);
cubeHole1.addBox(0F, 0F, 0F, 4, 12, 1);
cubeHole1.setRotationPoint(2F, 10F, 6F);
cubeHole1.setTextureSize(64, 32);
cubeHole2 = new ModelRenderer(this, 0, 0);
cubeHole2.addBox(0F, 0F, 0F, 4, 12, 1);
cubeHole2.setRotationPoint(-6F, 10F, 6F);
cubeHole2.setTextureSize(64, 32);
cubeHole3 = new ModelRenderer(this, 0, 0);
cubeHole3.addBox(0F, 0F, 0F, 4, 4, 1);
cubeHole3.setRotationPoint(-2F, 18F, 6F);
cubeHole3.setTextureSize(64, 32);
cubeHole4 = new ModelRenderer(this, 0, 0);
cubeHole4.addBox(0F, 0F, 0F, 4, 4, 1);
cubeHole4.setRotationPoint(-2F, 10F, 6F);
cubeHole4.setTextureSize(64, 32);
cubeInside = new ModelRenderer(this, 30, 17);
cubeInside.addBox(0F, 0F, 0F, 6, 6, 6);
cubeInside.setRotationPoint(-3F, 13F, -3F);
cubeInside.setTextureSize(64, 32);
}
public void render() {
float f = 1F / 16F;
cubeSide1.render(f);
cubeSide2.render(f);
cubeSide3.render(f);
cubeSide4.render(f);
cubeSide5.render(f);
cubeHole1.render(f);
cubeHole2.render(f);
cubeHole3.render(f);
cubeHole4.render(f);
cubeInside.render(f);
}
public void render() {
float f = 1F / 16F;
cubeSide1.render(f);
cubeSide2.render(f);
cubeSide3.render(f);
cubeSide4.render(f);
cubeSide5.render(f);
cubeHole1.render(f);
cubeHole2.render(f);
cubeHole3.render(f);
cubeHole4.render(f);
cubeInside.render(f);
}
}
@@ -2,49 +2,47 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 21, 2014, 8:02:01 PM (GMT)]
*/
package vazkii.botania.client.render.block;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.tile.TileAltar;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderAltar implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.6F, -0.5F);
GL11.glScalef(0.9F, 0.9F, 0.9F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.6F, -0.5F);
GL11.glScalef(0.9F, 0.9F, 0.9F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileAltar(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public int getRenderId() {
return LibRenderIDs.idAltar;
}
@Override
public int getRenderId() {
return LibRenderIDs.idAltar;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
}
@@ -2,49 +2,47 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 26, 2014, 12:25:06 AM (GMT)]
*/
package vazkii.botania.client.render.block;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.tile.TilePool;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderPool implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePool(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public int getRenderId() {
return LibRenderIDs.idPool;
}
@Override
public int getRenderId() {
return LibRenderIDs.idPool;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
}
@@ -2,49 +2,47 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 18, 2014, 10:20:06 PM (GMT)]
*/
package vazkii.botania.client.render.block;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.tile.TilePylon;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderPylon implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.7F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.7F, -0.5F);
TileEntityRendererDispatcher.instance.renderTileEntityAt(new TilePylon(), 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public int getRenderId() {
return LibRenderIDs.idPylon;
}
@Override
public int getRenderId() {
return LibRenderIDs.idPylon;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
}
@@ -2,112 +2,112 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 4:15:46 PM (GMT)]
*/
package vazkii.botania.client.render.block;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
int id;
int id;
public RenderSpecialFlower(int id) {
this.id = id;
}
public RenderSpecialFlower(int id) {
this.id = id;
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// NO-OP
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
// NO-OP
}
@Override
public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return renderCrossedSquares(blockAccess, block, x, y, z, renderer);
}
@Override
public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return renderCrossedSquares(blockAccess, block, x, y, z, renderer);
}
// Copied from RenderBlocks
public boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4));
float f = 1.0F;
int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4);
float f1 = (l >> 16 & 255) / 255.0F;
float f2 = (l >> 8 & 255) / 255.0F;
float f3 = (l & 255) / 255.0F;
// Copied from RenderBlocks
public boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
Tessellator tessellator = Tessellator.instance;
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4));
float f = 1.0F;
int l = par1Block.colorMultiplier(blockAccess, par2, par3, par4);
float f1 = (l >> 16 & 255) / 255.0F;
float f2 = (l >> 8 & 255) / 255.0F;
float f3 = (l & 255) / 255.0F;
if(EntityRenderer.anaglyphEnable) {
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
f1 = f4;
f2 = f5;
f3 = f6;
}
if(EntityRenderer.anaglyphEnable) {
float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
f1 = f4;
f2 = f5;
f3 = f6;
}
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
double d0 = par2;
double d1 = par3;
double d2 = par4;
tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
double d0 = par2;
double d1 = par3;
double d2 = par4;
drawCrossedSquares(blockAccess, par1Block, par2, par3, par4, d0, d1, d2, 1.0F, render);
drawCrossedSquares(blockAccess, par1Block, par2, par3, par4, d0, d1, d2, 1.0F, render);
return true;
}
return true;
}
// Copied from RenderBlocks
public void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) {
Tessellator tessellator = Tessellator.instance;
// Copied from RenderBlocks
public void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) {
Tessellator tessellator = Tessellator.instance;
// Only change here, to use xyz rather than side/meta
IIcon icon = render.getBlockIcon(par1Block, blockAccess, x, y, z, 0);
// Only change here, to use xyz rather than side/meta
IIcon icon = render.getBlockIcon(par1Block, blockAccess, x, y, z, 0);
double d3 = icon.getMinU();
double d4 = icon.getMinV();
double d5 = icon.getMaxU();
double d6 = icon.getMaxV();
double d7 = 0.45D * par9;
double d8 = par3 + 0.5D - d7;
double d9 = par3 + 0.5D + d7;
double d10 = par7 + 0.5D - d7;
double d11 = par7 + 0.5D + d7;
tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6);
tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4);
tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6);
tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4);
tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6);
tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4);
tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6);
tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4);
}
double d3 = icon.getMinU();
double d4 = icon.getMinV();
double d5 = icon.getMaxU();
double d6 = icon.getMaxV();
double d7 = 0.45D * par9;
double d8 = par3 + 0.5D - d7;
double d9 = par3 + 0.5D + d7;
double d10 = par7 + 0.5D - d7;
double d11 = par7 + 0.5D + d7;
tessellator.addVertexWithUV(d8, par5 + par9, d10, d3, d4);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d3, d6);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d5, d6);
tessellator.addVertexWithUV(d9, par5 + par9, d11, d5, d4);
tessellator.addVertexWithUV(d9, par5 + par9, d11, d3, d4);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d11, d3, d6);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d10, d5, d6);
tessellator.addVertexWithUV(d8, par5 + par9, d10, d5, d4);
tessellator.addVertexWithUV(d8, par5 + par9, d11, d3, d4);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d3, d6);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d5, d6);
tessellator.addVertexWithUV(d9, par5 + par9, d10, d5, d4);
tessellator.addVertexWithUV(d9, par5 + par9, d10, d3, d4);
tessellator.addVertexWithUV(d9, par5 + 0.0D, d10, d3, d6);
tessellator.addVertexWithUV(d8, par5 + 0.0D, d11, d5, d6);
tessellator.addVertexWithUV(d8, par5 + par9, d11, d5, d4);
}
@Override
public int getRenderId() {
return id;
}
@Override
public int getRenderId() {
return id;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return false;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return false;
}
}
@@ -2,52 +2,50 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 9:45:58 PM (GMT)]
*/
package vazkii.botania.client.render.block;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.world.IBlockAccess;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.lib.LibRenderIDs;
import vazkii.botania.common.block.tile.TileSpreader;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
public class RenderSpreader implements ISimpleBlockRenderingHandler {
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileSpreader.staticRedstone = (metadata & 1) == 1;
TileSpreader spreader = new TileSpreader();
spreader.rotationX = -180F;
TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
TileSpreader.staticRedstone = (metadata & 1) == 1;
TileSpreader spreader = new TileSpreader();
spreader.rotationX = -180F;
TileEntityRendererDispatcher.instance.renderTileEntityAt(spreader, 0.0D, 0.0D, 0.0D, 0.0F);
GL11.glPopMatrix();
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
return false;
}
@Override
public int getRenderId() {
return LibRenderIDs.idSpreader;
}
@Override
public int getRenderId() {
return LibRenderIDs.idSpreader;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
@Override
public boolean shouldRender3DInInventory(int modelId) {
return true;
}
}
@@ -2,120 +2,117 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 31, 2014, 3:08:00 PM (GMT)]
*/
package vazkii.botania.client.render.item;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.mana.ILens;
import vazkii.botania.common.item.ItemLens;
import java.awt.*;
public class RenderLens implements IItemRenderer {
static RenderItem render = new RenderItem();
ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft());
static RenderItem render = new RenderItem();
ItemRenderer renderer = new ItemRenderer(Minecraft.getMinecraft());
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.INVENTORY;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type != ItemRenderType.INVENTORY;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return helper == ItemRendererHelper.ENTITY_ROTATION || helper == ItemRendererHelper.ENTITY_BOBBING;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch(type) {
case ENTITY : {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, 0F, 0F);
render(item);
GL11.glPopMatrix();
break;
}
case EQUIPPED : {
render(item);
break;
}
case EQUIPPED_FIRST_PERSON : {
render(item);
break;
}
default : break;
}
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
switch(type) {
case ENTITY: {
GL11.glPushMatrix();
GL11.glTranslatef(-0.5F, 0F, 0F);
render(item);
GL11.glPopMatrix();
break;
}
case EQUIPPED: {
render(item);
break;
}
case EQUIPPED_FIRST_PERSON: {
render(item);
break;
}
default:
break;
}
}
public static void render(ItemStack item) {
Color color = new Color(((ILens) item.getItem()).getLensColor(item));
render(item, color.getRGB());
}
public static void render(ItemStack item) {
Color color = new Color(((ILens) item.getItem()).getLensColor(item));
render(item, color.getRGB());
}
public static void render(ItemStack item, int color_) {
int dmg = item.getItemDamage();
IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1);
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
float scale = 1F / 16F;
public static void render(ItemStack item, int color_) {
int dmg = item.getItemDamage();
IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1);
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
float scale = 1F / 16F;
GL11.glColor4f(1F, 1F, 1F, 1F);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
GL11.glColor4f(1F, 1F, 1F, 1F);
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), scale);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Color color = new Color(color_);
GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Color color = new Color(color_);
GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255);
boolean shiny = ItemLens.getStoredColor(item) != -1;
icon = ItemLens.iconGlass;
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(0F, 0F, -0.5F);
renderShinyLensIcon(icon, shiny);
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glTranslatef(-16F, 0F, 0F);
renderShinyLensIcon(icon, shiny);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
boolean shiny = ItemLens.getStoredColor(item) != -1;
icon = ItemLens.iconGlass;
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(0F, 0F, -0.5F);
renderShinyLensIcon(icon, shiny);
GL11.glRotatef(180F, 0F, 1F, 0F);
GL11.glTranslatef(-16F, 0F, 0F);
renderShinyLensIcon(icon, shiny);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
}
public static void renderShinyLensIcon(IIcon icon, boolean shiny) {
float par1 = 0;
float par2 = 0;
float par4 = 16;
float par5 = 16;
float zLevel = 0F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
if(shiny)
tessellator.setBrightness(240);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV());
tessellator.draw();
}
public static void renderShinyLensIcon(IIcon icon, boolean shiny) {
float par1 = 0;
float par2 = 0;
float par4 = 16;
float par5 = 16;
float zLevel = 0F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
if(shiny) tessellator.setBrightness(240);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, icon.getMinU(), icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, icon.getMaxU(), icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, icon.getMaxU(), icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, icon.getMinU(), icon.getMinV());
tessellator.draw();
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 25, 2014, 8:49:01 PM (GMT)]
*/
package vazkii.botania.client.render.item;
@@ -16,46 +16,44 @@ import net.minecraft.client.model.ModelBook;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
public class RenderLexicon implements IItemRenderer {
ModelBook model = new ModelBook();
ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA);
ModelBook model = new ModelBook();
ResourceLocation texture = new ResourceLocation(LibResources.MODEL_LEXICA);
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
return type == ItemRenderType.EQUIPPED_FIRST_PERSON;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
return false;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(texture);
float opening = 0F;
float pageFlip = 0F;
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
GL11.glPushMatrix();
Minecraft mc = Minecraft.getMinecraft();
mc.renderEngine.bindTexture(texture);
float opening = 0F;
float pageFlip = 0F;
int ticks = ClientTickHandler.ticksWithLexicaOpen;
GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks);
GL11.glRotatef(95F + ticks * 5, 0F, 1F, 0F);
GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F);
GL11.glScalef(0.9F, 0.9F, 0.9F);
opening = ticks / 12F;
pageFlip = ClientTickHandler.pageFlipTicks / 5F;
int ticks = ClientTickHandler.ticksWithLexicaOpen;
GL11.glTranslatef(0.3F + 0.02F * ticks, 0.475F + 0.01F * ticks, -0.2F - 0.01F * ticks);
GL11.glRotatef(95F + ticks * 5, 0F, 1F, 0F);
GL11.glRotatef(ticks * 2.5F, 0F, 0F, 1F);
GL11.glScalef(0.9F, 0.9F, 0.9F);
opening = ticks / 12F;
pageFlip = ClientTickHandler.pageFlipTicks / 5F;
model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F);
model.render(null, 0F, 0F, pageFlip, opening, 0F, 1F / 16F);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
}
@@ -2,18 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 21, 2014, 7:55:47 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
import java.awt.Color;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
@@ -25,118 +22,117 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelAltar;
import vazkii.botania.common.block.tile.TileAltar;
import java.awt.*;
public class RenderTileAltar extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_ALTAR);
ModelAltar model = new ModelAltar();
RenderItem renderItem = new RenderItem();
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_ALTAR);
ModelAltar model = new ModelAltar();
RenderItem renderItem = new RenderItem();
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
TileAltar altar = (TileAltar) tileentity;
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
TileAltar altar = (TileAltar) tileentity;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslated(d0 + 0.5, d1 + 1.5, d2 + 0.5);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
if(altar.hasWater) {
GL11.glPushMatrix();
float s = 1F / 256F * 10F;
float v = 1F / 8F;
float w = -v * 2.5F;
if(altar.hasWater) {
GL11.glPushMatrix();
float s = 1F / 256F * 10F;
float v = 1F / 8F;
float w = -v * 2.5F;
int petals = 0;
for(int i = 0; i < altar.getSizeInventory(); i++)
if(altar.getStackInSlot(i) != null)
petals++;
else break;
int petals = 0;
for(int i = 0; i < altar.getSizeInventory(); i++)
if(altar.getStackInSlot(i) != null) petals++;
else break;
if(petals > 0) {
final float modifier = 6F;
final float rotationModifier = 0.25F;
final float radiusBase = 1.2F;
final float radiusMod = 0.1F;
if(petals > 0) {
final float modifier = 6F;
final float rotationModifier = 0.25F;
final float radiusBase = 1.2F;
final float radiusMod = 0.1F;
double ticks = Minecraft.getMinecraft().thePlayer.ticksExisted * 0.5;
float offsetPerPetal = 360 / petals;
double ticks = Minecraft.getMinecraft().thePlayer.ticksExisted * 0.5;
float offsetPerPetal = 360 / petals;
GL11.glPushMatrix();
GL11.glTranslatef(-0.05F, -0.5F, 0F);
GL11.glScalef(v, v, v);
for(int i = 0; i < petals; i++) {
float offset = offsetPerPetal * i;
float deg = (int) (ticks / rotationModifier % 360F + offset);
float rad = deg * (float) Math.PI / 180F;
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
float x = (float) (radiusX * Math.cos(rad));
float z = (float) (radiusZ * Math.sin(rad));
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
GL11.glPushMatrix();
GL11.glTranslatef(-0.05F, -0.5F, 0F);
GL11.glScalef(v, v, v);
for(int i = 0; i < petals; i++) {
float offset = offsetPerPetal * i;
float deg = (int) (ticks / rotationModifier % 360F + offset);
float rad = deg * (float) Math.PI / 180F;
float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
float x = (float) (radiusX * Math.cos(rad));
float z = (float) (radiusZ * Math.sin(rad));
float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
float yRotate = (float) Math.max(0.6F, Math.sin(ticks * 0.1F) / 2F + 0.5F);
float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;
v /= 2F;
GL11.glTranslatef(v, v, v);
GL11.glRotatef(deg, xRotate, yRotate, zRotate);
GL11.glTranslatef(-v, -v, -v);
v *= 2F;
v /= 2F;
GL11.glTranslatef(v, v, v);
GL11.glRotatef(deg, xRotate, yRotate, zRotate);
GL11.glTranslatef(-v, -v, -v);
v *= 2F;
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glColor4f(1F, 1F, 1F, 1F);
ItemStack stack = altar.getStackInSlot(i);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
IIcon icon = stack.getItem().getIcon(stack, 0);
if(icon != null) {
Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
GL11.glColor3f(1F, 1F, 1F);
}
ItemStack stack = altar.getStackInSlot(i);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
IIcon icon = stack.getItem().getIcon(stack, 0);
if(icon != null) {
Color color = new Color(stack.getItem().getColorFromItemStack(stack, 0));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
GL11.glColor3f(1F, 1F, 1F);
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glColor4f(1F, 1F, 1F, 0.7F);
GL11.glTranslatef(w, -0.3F, w);
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glScalef(s, s, s);
renderItem.renderIcon(0, 0, Blocks.water.getIcon(0, 0), 16, 16);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glColor4f(1F, 1F, 1F, 0.7F);
GL11.glTranslatef(w, -0.3F, w);
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glScalef(s, s, s);
renderItem.renderIcon(0, 0, Blocks.water.getIcon(0, 0), 16, 16);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 15, 2014, 5:04:42 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
@@ -22,98 +22,91 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.common.block.BlockEnchanter;
import vazkii.botania.common.block.tile.TileEnchanter;
import vazkii.botania.common.core.handler.ConfigHandler;
public class RenderTileEnchanter extends TileEntitySpecialRenderer {
RenderItem renderItem = new RenderItem();
EntityItem item;
RenderItem renderItem = new RenderItem();
EntityItem item;
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TileEnchanter enchanter = (TileEnchanter) tileentity;
float alphaMod = 0F;
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TileEnchanter enchanter = (TileEnchanter) tileentity;
float alphaMod = 0F;
if(enchanter.stage == 2)
alphaMod = Math.min(20, enchanter.stageTicks) / 20F;
else if(enchanter.stage == 4)
alphaMod = (20 - enchanter.stageTicks) / 20F;
else if(enchanter.stage > 2)
alphaMod = 1F;
if(enchanter.stage == 2) alphaMod = Math.min(20, enchanter.stageTicks) / 20F;
else if(enchanter.stage == 4) alphaMod = (20 - enchanter.stageTicks) / 20F;
else if(enchanter.stage > 2) alphaMod = 1F;
if(enchanter.itemToEnchant != null) {
if(item == null)
item = new EntityItem(enchanter.getWorldObj(), enchanter.xCoord, enchanter.yCoord + 1, enchanter.zCoord, enchanter.itemToEnchant);
if(enchanter.itemToEnchant != null) {
if(item == null)
item = new EntityItem(enchanter.getWorldObj(), enchanter.xCoord, enchanter.yCoord + 1, enchanter.zCoord, enchanter.itemToEnchant);
item.age = (int) tileentity.getWorldObj().getTotalWorldTime();
item.setEntityItemStack(enchanter.itemToEnchant);
item.age = (int) tileentity.getWorldObj().getTotalWorldTime();
item.setEntityItemStack(enchanter.itemToEnchant);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef(0.5F, 1.25F, 0.5F);
((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f);
GL11.glTranslatef(-0.5F, -1.25F, -0.5F);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef(0.5F, 1.25F, 0.5F);
((Render) RenderManager.instance.entityRenderMap.get(EntityItem.class)).doRender(item, d0, d1, d2, 1F, f);
GL11.glTranslatef(-0.5F, -1.25F, -0.5F);
}
GL11.glPushMatrix();
GL11.glTranslated(d0, d1, d2);
GL11.glPushMatrix();
GL11.glTranslated(d0, d1, d2);
GL11.glRotated(90F, 1F, 0F, 0F);
GL11.glTranslatef(-2F, -2F, -0.001F);
GL11.glRotated(90F, 1F, 0F, 0F);
GL11.glTranslatef(-2F, -2F, -0.001F);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glDisable(GL11.GL_ALPHA_TEST);
float alpha = (float) ((Math.sin(enchanter.getWorldObj().getTotalWorldTime() / 8D) + 1D) / 5D + 0.4D) * alphaMod;
if(ShaderHelper.useShaders())
GL11.glColor4f(1F, 1F, 1F, alpha);
else {
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
GL11.glColor4f(0.6F + (float) ((Math.cos(enchanter.getWorldObj().getTotalWorldTime() / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha);
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glDisable(GL11.GL_ALPHA_TEST);
float alpha = (float) ((Math.sin(enchanter.getWorldObj().getTotalWorldTime() / 8D) + 1D) / 5D + 0.4D) * alphaMod;
if(ShaderHelper.useShaders()) GL11.glColor4f(1F, 1F, 1F, alpha);
else {
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
GL11.glColor4f(0.6F + (float) ((Math.cos(enchanter.getWorldObj().getTotalWorldTime() / 6D) + 1D) / 5D), 0.1F, 0.9F, alpha);
}
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
if(enchanter.stage == 3 || enchanter.stage == 4) {
int ticks = enchanter.stageTicks + enchanter.stage3EndTicks;
int angle = ticks * 2;
float yTranslation = Math.min(20, ticks) / 20F * 1.15F;
float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F;
if(enchanter.stage == 3 || enchanter.stage == 4) {
int ticks = enchanter.stageTicks + enchanter.stage3EndTicks;
int angle = ticks * 2;
float yTranslation = Math.min(20, ticks) / 20F * 1.15F;
float scale = ticks < 10 ? 1F : 1F - Math.min(20, ticks - 10) / 20F * 0.75F;
GL11.glTranslatef(2.5F, 2.5F, -yTranslation);
GL11.glScalef(scale, scale, 1F);
GL11.glRotatef(angle, 0F, 0F, 1F);
GL11.glTranslatef(-2.5F, -2.5F, 0F);
}
GL11.glTranslatef(2.5F, 2.5F, -yTranslation);
GL11.glScalef(scale, scale, 1F);
GL11.glRotatef(angle, 0F, 0F, 1F);
GL11.glTranslatef(-2.5F, -2.5F, 0F);
}
ShaderHelper.useShader(ShaderHelper.enchanterRune);
renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240);
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glPopMatrix();
}
ShaderHelper.useShader(ShaderHelper.enchanterRune);
renderIcon(0, 0, BlockEnchanter.overlay, 5, 5, 240);
ShaderHelper.releaseShader();
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setBrightness(brightness);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV());
tessellator.draw();
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glPopMatrix();
}
public void renderIcon(int par1, int par2, IIcon par3Icon, int par4, int par5, int brightness) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setBrightness(brightness);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, 0, par3Icon.getMinU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, 0, par3Icon.getMaxU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, 0, par3Icon.getMaxU(), par3Icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, 0, par3Icon.getMinU(), par3Icon.getMinV());
tessellator.draw();
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 26, 2014, 12:25:11 AM (GMT)]
*/
package vazkii.botania.client.render.tile;
@@ -20,10 +20,8 @@ import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelPool;
@@ -31,64 +29,64 @@ import vazkii.botania.common.block.tile.TilePool;
public class RenderTilePool extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL);
private static final ModelPool model = new ModelPool();
RenderItem renderItem = new RenderItem();
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL);
private static final ModelPool model = new ModelPool();
RenderItem renderItem = new RenderItem();
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TilePool pool = (TilePool) tileentity;
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TilePool pool = (TilePool) tileentity;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(d0, d1, d2);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(d0, d1, d2);
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
float waterLevel = (float) pool.getCurrentMana() / (float) TilePool.MAX_MANA * 0.40F;
if(waterLevel > 0) {
float s = 1F / 256F * 14F;
float v = 1F / 8F;
float w = -v * 3.5F;
float waterLevel = (float) pool.getCurrentMana() / (float) TilePool.MAX_MANA * 0.40F;
if(waterLevel > 0) {
float s = 1F / 256F * 14F;
float v = 1F / 8F;
float w = -v * 3.5F;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w);
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glScalef(s, s, s);
float par1 = 0;
float par2 = 0;
IIcon par3Icon = Blocks.water.getIcon(0, 0);
float par4 = 16;
float par5 = 16;
float zLevel = 0F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, par3Icon.getMinU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, par3Icon.getMaxU(), par3Icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, par3Icon.getMinU(), par3Icon.getMinV());
ShaderHelper.useShader(ShaderHelper.manaPool);
tessellator.draw();
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslatef(w, -1F - (0.43F - waterLevel), w);
GL11.glRotatef(90F, 1F, 0F, 0F);
GL11.glScalef(s, s, s);
float par1 = 0;
float par2 = 0;
IIcon par3Icon = Blocks.water.getIcon(0, 0);
float par4 = 16;
float par5 = 16;
float zLevel = 0F;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setBrightness(240);
tessellator.addVertexWithUV(par1 + 0, par2 + par5, zLevel, par3Icon.getMinU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + par5, zLevel, par3Icon.getMaxU(), par3Icon.getMaxV());
tessellator.addVertexWithUV(par1 + par4, par2 + 0, zLevel, par3Icon.getMaxU(), par3Icon.getMinV());
tessellator.addVertexWithUV(par1 + 0, par2 + 0, zLevel, par3Icon.getMinU(), par3Icon.getMinV());
ShaderHelper.useShader(ShaderHelper.manaPool);
tessellator.draw();
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
}
@@ -2,26 +2,22 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 18, 2014, 10:18:36 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.IPylonModel;
@@ -29,91 +25,87 @@ import vazkii.botania.client.model.ModelPylon;
import vazkii.botania.client.model.ModelPylonOld;
import vazkii.botania.common.core.handler.ConfigHandler;
import java.util.Random;
public class RenderTilePylon extends TileEntitySpecialRenderer {
private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD);
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON);
private static final ResourceLocation textureOld = new ResourceLocation(LibResources.MODEL_PYLON_OLD);
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON);
IPylonModel model;
IPylonModel model;
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
if(model == null)
model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon();
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
if(model == null) model = ConfigHandler.oldPylonModel ? new ModelPylonOld() : new ModelPylon();
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.oldPylonModel ? textureOld : texture);
int worldTime = (int) (tileentity.getWorldObj() == null ? 0 : tileentity.getWorldObj().getTotalWorldTime());
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1F, 1F, 1F, 1F);
Minecraft.getMinecraft().renderEngine.bindTexture(ConfigHandler.oldPylonModel ? textureOld : texture);
int worldTime = (int) (tileentity.getWorldObj() == null ? 0 : tileentity.getWorldObj().getTotalWorldTime());
if(tileentity != null)
worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360);
if(tileentity != null)
worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360);
if(ConfigHandler.oldPylonModel) {
GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5);
GL11.glScalef(1F, -1.5F, -1F);
} else {
GL11.glTranslated(d0 + 0.2, d1 + 0.05, d2 + 0.8);
GL11.glScalef(0.6F, 0.6F, 0.6F);
}
if(ConfigHandler.oldPylonModel) {
GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5);
GL11.glScalef(1F, -1.5F, -1F);
} else {
GL11.glTranslated(d0 + 0.2, d1 + 0.05, d2 + 0.8);
GL11.glScalef(0.6F, 0.6F, 0.6F);
}
GL11.glPushMatrix();
if(!ConfigHandler.oldPylonModel)
GL11.glTranslatef(0.5F, 0F, -0.5F);
GL11.glRotatef(worldTime * 1.5F, 0F, 1F, 0F);
if(!ConfigHandler.oldPylonModel)
GL11.glTranslatef(-0.5F, 0F, 0.5F);
GL11.glPushMatrix();
if(!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F);
GL11.glRotatef(worldTime * 1.5F, 0F, 1F, 0F);
if(!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F);
model.renderRing();
GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D);
model.renderGems();
GL11.glPopMatrix();
model.renderRing();
GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 20 - 0.025, 0D);
model.renderGems();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D);
GL11.glPushMatrix();
GL11.glTranslated(0D, Math.sin(worldTime / 20D) / 17.5, 0D);
if(!ConfigHandler.oldPylonModel)
GL11.glTranslatef(0.5F, 0F, -0.5F);
if(!ConfigHandler.oldPylonModel) GL11.glTranslatef(0.5F, 0F, -0.5F);
GL11.glRotatef(-worldTime, 0F, 1F, 0F);
if(!ConfigHandler.oldPylonModel)
GL11.glTranslatef(-0.5F, 0F, 0.5F);
GL11.glRotatef(-worldTime, 0F, 1F, 0F);
if(!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.5F, 0F, 0.5F);
GL11.glDisable(GL11.GL_CULL_FACE);
model.renderCrystal();
GL11.glDisable(GL11.GL_CULL_FACE);
model.renderCrystal();
GL11.glColor4f(1F, 1F, 1F, 1F);
if(!ShaderHelper.useShaders()) {
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D));
GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F);
}
GL11.glColor4f(1F, 1F, 1F, 1F);
if(!ShaderHelper.useShaders()) {
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
float alpha = (float) ((Math.sin(worldTime / 20D) / 2D + 0.5) / (ConfigHandler.oldPylonModel ? 1D : 2D));
GL11.glColor4f(1F, 1F, 1F, alpha + 0.183F);
}
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glScalef(1.1F, 1.1F, 1.1F);
if(!ConfigHandler.oldPylonModel)
GL11.glTranslatef(-0.05F, -0.1F, 0.05F);
else GL11.glTranslatef(0F, -0.09F, 0F);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glScalef(1.1F, 1.1F, 1.1F);
if(!ConfigHandler.oldPylonModel) GL11.glTranslatef(-0.05F, -0.1F, 0.05F);
else GL11.glTranslatef(0F, -0.09F, 0F);
ShaderHelper.useShader(ShaderHelper.pylonGlow);
model.renderCrystal();
ShaderHelper.releaseShader();
ShaderHelper.useShader(ShaderHelper.pylonGlow);
model.renderCrystal();
ShaderHelper.releaseShader();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 2, 2014, 6:34:45 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
import java.awt.Color;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
@@ -26,100 +24,99 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.client.model.ModelSpinningCubes;
import vazkii.botania.common.block.tile.TileRuneAltar;
import java.awt.*;
public class RenderTileRuneAltar extends TileEntitySpecialRenderer {
ModelSpinningCubes cubes = new ModelSpinningCubes();
RenderBlocks renderBlocks = new RenderBlocks();
ModelSpinningCubes cubes = new ModelSpinningCubes();
RenderBlocks renderBlocks = new RenderBlocks();
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) {
TileRuneAltar altar = (TileRuneAltar) tileentity;
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) {
TileRuneAltar altar = (TileRuneAltar) tileentity;
GL11.glPushMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(x, y, z);
GL11.glPushMatrix();
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(x, y, z);
int items = 0;
for(int i = 0; i < altar.getSizeInventory(); i++)
if(altar.getStackInSlot(i) == null)
break;
else items++;
float[] angles = new float[altar.getSizeInventory()];
int items = 0;
for(int i = 0; i < altar.getSizeInventory(); i++)
if(altar.getStackInSlot(i) == null) break;
else items++;
float[] angles = new float[altar.getSizeInventory()];
float anglePer = 360F / items;
float totalAngle = 0F;
for(int i = 0; i < angles.length; i++)
angles[i] = totalAngle += anglePer;
float anglePer = 360F / items;
float totalAngle = 0F;
for(int i = 0; i < angles.length; i++)
angles[i] = totalAngle += anglePer;
for(int i = 0; i < altar.getSizeInventory(); i++) {
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(1F, 2.5F, 1F);
GL11.glRotatef(angles[i] + altar.getWorldObj().getTotalWorldTime(), 0F, 1F, 0F);
GL11.glTranslatef(2.25F, 0F, 0.5F);
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glTranslated(0D, 0.15 * Math.sin((tileentity.getWorldObj().getTotalWorldTime() + i * 10) / 5D), 0F);
ItemStack stack = altar.getStackInSlot(i);
Minecraft mc = Minecraft.getMinecraft();
if(stack != null) {
mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
for(int i = 0; i < altar.getSizeInventory(); i++) {
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(1F, 2.5F, 1F);
GL11.glRotatef(angles[i] + altar.getWorldObj().getTotalWorldTime(), 0F, 1F, 0F);
GL11.glTranslatef(2.25F, 0F, 0.5F);
GL11.glRotatef(90F, 0F, 1F, 0F);
GL11.glTranslated(0D, 0.15 * Math.sin((tileentity.getWorldObj().getTotalWorldTime() + i * 10) / 5D), 0F);
ItemStack stack = altar.getStackInSlot(i);
Minecraft mc = Minecraft.getMinecraft();
if(stack != null) {
mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
GL11.glScalef(2F, 2F, 2F);
if(!ForgeHooksClient.renderEntityItem(new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), stack, 0F, 0F, altar.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
GL11.glScalef(0.5F, 0.5F, 0.5F);
if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) {
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(1F, 1.1F, 0F);
renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F);
GL11.glTranslatef(-1F, -1.1F, 0F);
GL11.glScalef(2F, 2F, 2F);
} else {
int renderPass = 0;
do {
IIcon icon = stack.getItem().getIcon(stack, renderPass);
if(icon != null) {
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
GL11.glColor3f(1F, 1F, 1F);
}
renderPass++;
} while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
}
}
}
GL11.glPopMatrix();
}
GL11.glScalef(2F, 2F, 2F);
if(!ForgeHooksClient.renderEntityItem(new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), stack, 0F, 0F, altar.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
GL11.glScalef(0.5F, 0.5F, 0.5F);
if(stack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) {
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(1F, 1.1F, 0F);
renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F);
GL11.glTranslatef(-1F, -1.1F, 0F);
GL11.glScalef(2F, 2F, 2F);
} else {
int renderPass = 0;
do {
IIcon icon = stack.getItem().getIcon(stack, renderPass);
if(icon != null) {
Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
GL11.glColor3f(1F, 1F, 1F);
}
renderPass++;
} while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
}
}
}
GL11.glPopMatrix();
}
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 1.8F, 0.5F);
GL11.glRotatef(180F, 1F, 0F, 1F);
int repeat = 15;
cubes.renderSpinningCubes(2, repeat, repeat);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 1.8F, 0.5F);
GL11.glRotatef(180F, 1F, 0F, 1F);
int repeat = 15;
cubes.renderSpinningCubes(2, repeat, repeat);
GL11.glPopMatrix();
GL11.glTranslatef(0F, 1.2F, 2F);
float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F;
GL11.glTranslatef(0F, 1.2F, 2F);
float scale = altar.getTargetMana() == 0 ? 0 : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F;
if(scale != 0) {
int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord;
GL11.glTranslatef(0.5F, 0.7F, 0.5F);
RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed);
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
if(scale != 0) {
int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord;
GL11.glTranslatef(0.5F, 0.7F, 0.5F);
RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed);
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glPopMatrix();
}
GL11.glPopMatrix();
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 9:42:31 PM (GMT)]
*/
package vazkii.botania.client.render.tile;
@@ -17,10 +17,8 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import vazkii.botania.api.mana.ILens;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelSpreader;
@@ -29,42 +27,42 @@ import vazkii.botania.common.block.tile.TileSpreader;
public class RenderTileSpreader extends TileEntitySpecialRenderer {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER);
private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE);
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_SPREADER);
private static final ResourceLocation textureRs = new ResourceLocation(LibResources.MODEL_SPREADER_REDSTONE);
private static final ModelSpreader model = new ModelSpreader();
private static final ModelSpreader model = new ModelSpreader();
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TileSpreader spreader = (TileSpreader) tileentity;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(d0, d1, d2);
@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
TileSpreader spreader = (TileSpreader) tileentity;
GL11.glPushMatrix();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glTranslated(d0, d1, d2);
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F);
GL11.glTranslatef(0F, -1F, 0F);
GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F);
GL11.glTranslatef(0F, 1F, 0F);
GL11.glTranslatef(0.5F, 1.5F, 0.5F);
GL11.glRotatef(spreader.rotationX + 90F, 0F, 1F, 0F);
GL11.glTranslatef(0F, -1F, 0F);
GL11.glRotatef(spreader.rotationY, 1F, 0F, 0F);
GL11.glTranslatef(0F, 1F, 0F);
Minecraft.getMinecraft().renderEngine.bindTexture(spreader.isRedstone() ? textureRs : texture);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
ItemStack stack = spreader.getStackInSlot(0);
Minecraft.getMinecraft().renderEngine.bindTexture(spreader.isRedstone() ? textureRs : texture);
GL11.glScalef(1F, -1F, -1F);
model.render();
GL11.glScalef(1F, -1F, -1F);
ItemStack stack = spreader.getStackInSlot(0);
if(stack != null) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
ILens lens = (ILens) stack.getItem();
GL11.glPushMatrix();
GL11.glTranslatef(-0.4F, -1.4F, -0.4375F);
GL11.glScalef(0.8F, 0.8F, 0.8F);
RenderLens.render(stack, lens.getLensColor(stack));
GL11.glPopMatrix();
}
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
if(stack != null) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
ILens lens = (ILens) stack.getItem();
GL11.glPushMatrix();
GL11.glTranslatef(-0.4F, -1.4F, -0.4375F);
GL11.glScalef(0.8F, 0.8F, 0.8F);
RenderLens.render(stack, lens.getLensColor(stack));
GL11.glPopMatrix();
}
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
}
+25 -25
View File
@@ -2,18 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 13, 2014, 6:32:39 PM (GMT)]
*/
package vazkii.botania.common;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.lib.LibMisc;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
@@ -22,33 +19,36 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import vazkii.botania.common.core.handler.ManaNetworkHandler;
import vazkii.botania.common.core.proxy.CommonProxy;
import vazkii.botania.common.lib.LibMisc;
@Mod(modid = LibMisc.MOD_ID, name = LibMisc.MOD_NAME, version = LibMisc.VERSION)
public class Botania {
@Instance(LibMisc.MOD_ID)
public static Botania instance;
@Instance(LibMisc.MOD_ID)
public static Botania instance;
@SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT)
public static CommonProxy proxy;
@SidedProxy(serverSide = LibMisc.PROXY_COMMON, clientSide = LibMisc.PROXY_CLIENT)
public static CommonProxy proxy;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
}
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
proxy.init(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
ManaNetworkHandler.instance.clear();
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
ManaNetworkHandler.instance.clear();
}
}
+103 -105
View File
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 21, 2014, 7:48:54 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -34,131 +32,131 @@ import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.Random;
public class BlockAltar extends BlockModContainer implements ILexiconable {
Random random;
Random random;
protected BlockAltar() {
super(Material.rock);
setHardness(3.5F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.ALTAR);
protected BlockAltar() {
super(Material.rock);
setHardness(3.5F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.ALTAR);
float f = 1F / 16F * 2F;
setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f);
float f = 1F / 16F * 2F;
setBlockBounds(f, f, f, 1F - f, 1F / 16F * 20F, 1F - f);
random = new Random();
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
random = new Random();
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if(par5Entity instanceof EntityItem) {
TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4);
if(tile.collideEntityItem((EntityItem) par5Entity))
par1World.markBlockForUpdate(par2, par3, par4);
}
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4);
if(stack != null && stack.getItem() == Items.water_bucket) {
if(!tile.hasWater) {
if(!par5EntityPlayer.capabilities.isCreativeMode)
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, new ItemStack(Items.bucket));
tile.hasWater = true;
par1World.func_147453_f(par2, par3, par4, this);
par1World.markBlockForUpdate(par2, par3, par4);
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if(par5Entity instanceof EntityItem) {
TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4);
if(tile.collideEntityItem((EntityItem) par5Entity)) par1World.markBlockForUpdate(par2, par3, par4);
}
}
return true;
}
return false;
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4);
if(stack != null && stack.getItem() == Items.water_bucket) {
if(!tile.hasWater) {
if(!par5EntityPlayer.capabilities.isCreativeMode)
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, new ItemStack(Items.bucket));
tile.hasWater = true;
par1World.func_147453_f(par2, par3, par4, this);
par1World.markBlockForUpdate(par2, par3, par4);
}
@Override
public IIcon getIcon(int par1, int par2) {
return Blocks.cobblestone.getIcon(par1, par2);
}
return true;
}
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public IIcon getIcon(int par1, int par2) {
return Blocks.cobblestone.getIcon(par1, par2);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return LibRenderIDs.idAltar;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileAltar();
}
@Override
public int getRenderType() {
return LibRenderIDs.idAltar;
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileAltar();
}
if (inv != null) {
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
if(inv != null) {
for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if(itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
for(float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3;
if(k1 > itemstack.stackSize) k1 = itemstack.stackSize;
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
par1World.func_147453_f(par2, par3, par4, par5);
}
if(itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
}
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
par1World.func_147453_f(par2, par3, par4, par5);
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
@Override
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4);
return altar.hasWater ? 15 : 0;
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.apothecary;
}
@Override
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TileAltar altar = (TileAltar) par1World.getTileEntity(par2, par3, par4);
return altar.hasWater ? 15 : 0;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.apothecary;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 3, 2014, 1:44:29 AM (GMT)]
*/
package vazkii.botania.common.block;
@@ -27,35 +27,35 @@ import vazkii.botania.common.lib.LibBlockNames;
public class BlockDistributor extends BlockModContainer implements ILexiconable {
IIcon iconSide, iconTop;
IIcon iconSide, iconTop;
protected BlockDistributor() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.DISTRIBUTOR);
}
protected BlockDistributor() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.DISTRIBUTOR);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconTop = IconHelper.forBlock(par1IconRegister, this, 0);
iconSide = IconHelper.forBlock(par1IconRegister, this, 1);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
iconTop = IconHelper.forBlock(par1IconRegister, this, 0);
iconSide = IconHelper.forBlock(par1IconRegister, this, 1);
}
@Override
public IIcon getIcon(int par1, int par2) {
return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide;
}
@Override
public IIcon getIcon(int par1, int par2) {
return par1 == 0 ? ModBlocks.livingrock.getIcon(0, 0) : par1 == 1 ? iconTop : iconSide;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileDistributor();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileDistributor();
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.distributor;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.distributor;
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 15, 2014, 4:08:26 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -35,111 +33,111 @@ import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.Random;
public class BlockEnchanter extends BlockModContainer implements IWandable, ILexiconable {
Random random;
public static IIcon overlay;
Random random;
public static IIcon overlay;
public BlockEnchanter() {
super(Material.rock);
setHardness(3.0F);
setResistance(5.0F);
setLightLevel(1.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.ENCHANTER);
public BlockEnchanter() {
super(Material.rock);
setHardness(3.0F);
setResistance(5.0F);
setLightLevel(1.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.ENCHANTER);
random = new Random();
}
random = new Random();
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
super.registerBlockIcons(par1IconRegister);
overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay");
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
super.registerBlockIcons(par1IconRegister);
overlay = IconHelper.forBlock(par1IconRegister, this, "Overlay");
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEnchanter();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEnchanter();
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(Blocks.lapis_block);
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(Blocks.lapis_block);
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4);
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
if(stack != null && stack.getItem() == ModItems.twigWand)
return false;
@Override
public boolean isOpaqueCube() {
return false;
}
boolean stackEnchantable = stack != null && stack.isItemEnchantable() && stack.stackSize == 1 && stack.getItem().getItemEnchantability() > 0;
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4);
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
if(stack != null && stack.getItem() == ModItems.twigWand) return false;
if(enchanter.itemToEnchant == null) {
if(stackEnchantable) {
enchanter.itemToEnchant = stack.copy();
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
enchanter.sync();
}
} else if(enchanter.stage == 0) {
if(par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) {
enchanter.itemToEnchant = null;
enchanter.sync();
} else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull"));
}
boolean stackEnchantable = stack != null && stack.isItemEnchantable() && stack.stackSize == 1 && stack.getItem().getItemEnchantability() > 0;
return true;
}
if(enchanter.itemToEnchant == null) {
if(stackEnchantable) {
enchanter.itemToEnchant = stack.copy();
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
enchanter.sync();
}
} else if(enchanter.stage == 0) {
if(par5EntityPlayer.inventory.addItemStackToInventory(enchanter.itemToEnchant.copy())) {
enchanter.itemToEnchant = null;
enchanter.sync();
} else par5EntityPlayer.addChatMessage(new ChatComponentTranslation("botaniamisc.invFull"));
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4);
return true;
}
ItemStack itemstack = enchanter.itemToEnchant;
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileEnchanter enchanter = (TileEnchanter) par1World.getTileEntity(par2, par3, par4);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
ItemStack itemstack = enchanter.itemToEnchant;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if(itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
for(float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3 * 0.5;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3 * 0.5;
if(k1 > itemstack.stackSize) k1 = itemstack.stackSize;
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3 * 0.5;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3 * 0.5;
par1World.func_147453_f(par2, par3, par4, par5);
if(itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
par1World.func_147453_f(par2, par3, par4, par5);
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaEnchanting;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileEnchanter) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaEnchanting;
}
}
@@ -2,17 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 10:03:04 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -29,65 +28,66 @@ import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.List;
public class BlockLivingrock extends BlockMod implements ILexiconable {
private static final int TYPES = 5;
IIcon[] icons;
private static final int TYPES = 5;
IIcon[] icons;
public BlockLivingrock() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.LIVING_ROCK);
}
public BlockLivingrock() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.LIVING_ROCK);
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < TYPES; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < TYPES; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[TYPES];
for(int i = 0; i < TYPES; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[TYPES];
for(int i = 0; i < TYPES; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(TYPES - 1, par2)];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(TYPES - 1, par2)];
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(this, 1, meta);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(this, 1, meta);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
}
@@ -2,19 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 10:04:25 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.List;
import javax.swing.Icon;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -32,69 +29,70 @@ import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.List;
public class BlockLivingwood extends BlockMod implements ILexiconable {
private static final int TYPES = 6;
IIcon[] icons;
private static final int TYPES = 6;
IIcon[] icons;
public BlockLivingwood() {
super( Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.LIVING_WOOD);
}
public BlockLivingwood() {
super(Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.LIVING_WOOD);
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < TYPES; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < TYPES; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[TYPES];
for(int i = 0; i < TYPES; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[TYPES];
for(int i = 0; i < TYPES; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(TYPES - 1, par2)];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(TYPES - 1, par2)];
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(this, 1, meta);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(this, 1, meta);
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0;
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
return world.getBlockMetadata(x, y, z) == 5 ? 12 : 0;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.pureDaisy : LexiconData.decorativeBlocks;
}
}
@@ -2,18 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 3, 2014, 4:53:59 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.awt.Color;
import java.util.List;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -33,84 +31,86 @@ import vazkii.botania.common.block.tile.TileManaBeacon;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import java.awt.*;
import java.util.List;
public class BlockManaBeacon extends BlockModContainer implements ILexiconable {
IIcon[] icons;
IIcon[] icons;
public BlockManaBeacon() {
super(Material.iron);
setHardness(5.0F);
setResistance(10.0F);
setStepSound(soundTypeMetal);
float size = 3F / 16F;
setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size);
setBlockName(LibBlockNames.MANA_BEACON);
}
public BlockManaBeacon() {
super(Material.iron);
setHardness(5.0F);
setResistance(10.0F);
setStepSound(soundTypeMetal);
float size = 3F / 16F;
setBlockBounds(size, size, size, 1F - size, 1F - size, 1F - size);
setBlockName(LibBlockNames.MANA_BEACON);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < 2; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < 2; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[par1 == 1 ? 1 : 0];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[par1 == 1 ? 1 : 0];
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int getRenderColor(int par1) {
float[] color = EntitySheep.fleeceColorTable[par1];
return new Color(color[0], color[1], color[2]).getRGB();
}
@Override
public int getRenderColor(int par1) {
float[] color = EntitySheep.fleeceColorTable[par1];
return new Color(color[0], color[1], color[2]).getRGB();
}
@Override
public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4));
}
@Override
public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4));
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.unstableBlocks;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.unstableBlocks;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaBeacon();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaBeacon();
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 10, 2014, 7:57:38 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -32,54 +30,56 @@ import vazkii.botania.common.block.tile.TileManaDetector;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.List;
public class BlockManaDetector extends BlockModContainer implements ILexiconable {
IIcon[] icons;
IIcon[] icons;
protected BlockManaDetector() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(Block.soundTypeStone);
setBlockName(LibBlockNames.MANA_DETECTOR);
}
protected BlockManaDetector() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(Block.soundTypeStone);
setBlockName(LibBlockNames.MANA_DETECTOR);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(icons.length - 1, par2)];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(icons.length - 1, par2)];
}
@Override
public boolean canProvidePower() {
return true;
}
@Override
public boolean canProvidePower() {
return true;
}
@Override
public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0;
}
@Override
public int isProvidingWeakPower(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return par1iBlockAccess.getBlockMetadata(par2, par3, par4) != 0 ? 15 : 0;
}
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
if(par7Entity != null && !(par7Entity instanceof IManaBurst))
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@Override
public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) {
if(par7Entity != null && !(par7Entity instanceof IManaBurst))
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaDetector();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileManaDetector();
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaDetector;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaDetector;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 5, 2014, 12:55:47 AM (GMT)]
*/
package vazkii.botania.common.block;
@@ -25,22 +25,22 @@ import vazkii.botania.common.lib.LibBlockNames;
public class BlockManaVoid extends BlockModContainer implements ILexiconable {
protected BlockManaVoid() {
super(Material.rock);
setHardness(2.0F);
setResistance(2000F);
setStepSound(Block.soundTypeStone);
setBlockName(LibBlockNames.MANA_VOID);
}
protected BlockManaVoid() {
super(Material.rock);
setHardness(2.0F);
setResistance(2000F);
setStepSound(Block.soundTypeStone);
setBlockName(LibBlockNames.MANA_VOID);
}
@Override
public TileEntity createNewTileEntity(World world, int id) {
return new TileManaVoid();
}
@Override
public TileEntity createNewTileEntity(World world, int id) {
return new TileManaVoid();
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaVoid;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.manaVoid;
}
}
@@ -2,52 +2,50 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 5:31:15 PM (GMT)]
*/
package vazkii.botania.common.block;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.core.BotaniaCreativeTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockMod extends Block {
public BlockMod(Material par2Material) {
super(par2Material);
if(registerInCreative())
setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
public BlockMod(Material par2Material) {
super(par2Material);
if(registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
@Override
public Block setBlockName(String par1Str) {
if(shouldRegisterInNameSet())
GameRegistry.registerBlock(this, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
if(shouldRegisterInNameSet()) GameRegistry.registerBlock(this, par1Str);
return super.setBlockName(par1Str);
}
protected boolean shouldRegisterInNameSet() {
return true;
}
protected boolean shouldRegisterInNameSet() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
blockIcon = IconHelper.forBlock(par1IconRegister, this);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
blockIcon = IconHelper.forBlock(par1IconRegister, this);
}
boolean registerInCreative() {
return true;
}
boolean registerInCreative() {
return true;
}
}
@@ -2,15 +2,18 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 14, 2014, 5:32:55 PM (GMT)]
*/
package vazkii.botania.common.block;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
@@ -19,40 +22,35 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.core.BotaniaCreativeTab;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class BlockModContainer<T extends TileEntity> extends BlockContainer {
protected BlockModContainer(Material par2Material) {
super(par2Material);
if(registerInCreative())
setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
protected BlockModContainer(Material par2Material) {
super(par2Material);
if(registerInCreative()) setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
@Override
public Block setBlockName(String par1Str) {
if(shouldRegisterInNameSet())
GameRegistry.registerBlock(this, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
if(shouldRegisterInNameSet()) GameRegistry.registerBlock(this, par1Str);
return super.setBlockName(par1Str);
}
protected boolean shouldRegisterInNameSet() {
return true;
}
protected boolean shouldRegisterInNameSet() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
blockIcon = IconHelper.forBlock(par1IconRegister, this);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
blockIcon = IconHelper.forBlock(par1IconRegister, this);
}
boolean registerInCreative() {
return true;
}
boolean registerInCreative() {
return true;
}
@Override
public abstract T createNewTileEntity(World world, int meta);
@Override
public abstract T createNewTileEntity(World world, int meta);
}
@@ -2,20 +2,18 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 16, 2014, 5:50:31 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.List;
import java.util.Random;
import javax.swing.Icon;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -36,70 +34,70 @@ import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
public class BlockModFlower extends BlockFlower implements ILexiconable {
public static IIcon[] icons;
public static IIcon[] icons;
protected BlockModFlower() {
super(0);
setBlockName(LibBlockNames.FLOWER);
setHardness(0F);
setStepSound(soundTypeGrass);
setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F);
setTickRandomly(true);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
protected BlockModFlower() {
super(0);
setBlockName(LibBlockNames.FLOWER);
setHardness(0F);
setStepSound(soundTypeGrass);
setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F);
setTickRandomly(true);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[17];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[17];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[par2];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[par2];
}
@Override
public int getRenderType() {
return LibRenderIDs.idSpecialFlower;
}
@Override
public int getRenderType() {
return LibRenderIDs.idSpecialFlower;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
int meta = par1World.getBlockMetadata(par2, par3, par4);
float[] color = EntitySheep.fleeceColorTable[meta];
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
int meta = par1World.getBlockMetadata(par2, par3, par4);
float[] color = EntitySheep.fleeceColorTable[meta];
if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency)
Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5);
}
if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency)
Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.flowers;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.flowers;
}
}
@@ -2,23 +2,20 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 20, 2014, 4:57:36 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
@@ -39,209 +36,201 @@ import vazkii.botania.api.IWandable;
import vazkii.botania.api.lexicon.LexiconEntry;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
import java.util.*;
public class BlockPistonRelay extends BlockMod implements IWandable, ILexiconable {
public static Map<String, String> playerPositions = new HashMap();
public static Map<String, String> mappedPositions = new HashMap();
public static Map<String, String> playerPositions = new HashMap();
public static Map<String, String> mappedPositions = new HashMap();
static List<String> removeThese = new ArrayList();
static Map<String, Integer> coordsToCheck = new HashMap();
static List<String> removeThese = new ArrayList();
static Map<String, Integer> coordsToCheck = new HashMap();
public BlockPistonRelay() {
super(Material.gourd);
setBlockName(LibBlockNames.PISTON_RELAY);
setHardness(2F);
setResistance(10F);
setStepSound(soundTypeMetal);
public BlockPistonRelay() {
super(Material.gourd);
setBlockName(LibBlockNames.PISTON_RELAY);
setHardness(2F);
setResistance(10F);
setStepSound(soundTypeMetal);
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
}
MinecraftForge.EVENT_BUS.register(this);
FMLCommonHandler.instance().bus().register(this);
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 0;
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 0;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2);
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
mapCoords(par1World.provider.dimensionId, par2, par3, par4, 2);
}
public static String getCoordsAsString(int world, int x, int y, int z) {
return world + ":" + x + ":" + y + ":" + z;
}
public static String getCoordsAsString(int world, int x, int y, int z) {
return world + ":" + x + ":" + y + ":" + z;
}
static void mapCoords(int world, int x, int y, int z, int time) {
coordsToCheck.put(getCoordsAsString(world, x, y, z), time);
}
static void mapCoords(int world, int x, int y, int z, int time) {
coordsToCheck.put(getCoordsAsString(world, x, y, z), time);
}
static void decrCoords(String key) {
int time = getTimeInCoords(key);
static void decrCoords(String key) {
int time = getTimeInCoords(key);
if(time <= 0)
removeThese.add(key);
else coordsToCheck.put(key, time - 1);
}
if(time <= 0) removeThese.add(key);
else coordsToCheck.put(key, time - 1);
}
static int getTimeInCoords(String key) {
return coordsToCheck.get(key);
}
static int getTimeInCoords(String key) {
return coordsToCheck.get(key);
}
static Block getBlockAt(String key) {
MinecraftServer server = MinecraftServer.getServer();
if(server == null)
return Blocks.air;
static Block getBlockAt(String key) {
MinecraftServer server = MinecraftServer.getServer();
if(server == null) return Blocks.air;
String[] tokens = key.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
return world.getBlock(x, y, z);
}
String[] tokens = key.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
return world.getBlock(x, y, z);
}
static int getBlockMetaAt(String key) {
MinecraftServer server = MinecraftServer.getServer();
if(server == null)
return 0;
static int getBlockMetaAt(String key) {
MinecraftServer server = MinecraftServer.getServer();
if(server == null) return 0;
String[] tokens = key.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
return world.getBlockMetadata(x, y, z);
}
String[] tokens = key.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
return world.getBlockMetadata(x, y, z);
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
if(!player.isSneaking()) {
playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z));
world.playSoundEffect(x, y, z, "random.orb", 0.5F, 1F);
} else {
dropBlockAsItem(world, x, y, z, new ItemStack(this));
world.setBlockToAir(x, y, z);
if(!world.isRemote)
world.playAuxSFX(2001, x, y , z, Block.getIdFromBlock(this));
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
if(!player.isSneaking()) {
playerPositions.put(player.getCommandSenderName(), getCoordsAsString(world.provider.dimensionId, x, y, z));
world.playSoundEffect(x, y, z, "random.orb", 0.5F, 1F);
} else {
dropBlockAsItem(world, x, y, z, new ItemStack(this));
world.setBlockToAir(x, y, z);
if(!world.isRemote) world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(this));
}
return true;
}
return true;
}
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
WorldData.get(event.world);
}
@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
WorldData.get(event.world);
}
public static class WorldData extends WorldSavedData {
public static class WorldData extends WorldSavedData {
private static final String ID = "PistonRelayPairs";
private static final String ID = "PistonRelayPairs";
public WorldData(String id) {
super(id);
}
public WorldData(String id) {
super(id);
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
mappedPositions.clear();
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
mappedPositions.clear();
Collection<String> tags = nbttagcompound.func_150296_c();
for(String key : tags) {
NBTBase tag = nbttagcompound.getTag(key);
if(tag instanceof NBTTagString) {
String value = ((NBTTagString) tag).func_150285_a_();
Collection<String> tags = nbttagcompound.func_150296_c();
for(String key : tags) {
NBTBase tag = nbttagcompound.getTag(key);
if(tag instanceof NBTTagString) {
String value = ((NBTTagString) tag).func_150285_a_();
mappedPositions.put(key, value);
}
}
}
mappedPositions.put(key, value);
}
}
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
for(String s : mappedPositions.keySet())
nbttagcompound.setString(s, mappedPositions.get(s));
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
for(String s : mappedPositions.keySet())
nbttagcompound.setString(s, mappedPositions.get(s));
}
public static WorldData get(World world) {
WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID);
public static WorldData get(World world) {
WorldData data = (WorldData) world.mapStorage.loadData(WorldData.class, ID);
if (data == null) {
data = new WorldData(ID);
data.markDirty();
world.mapStorage.setData(ID, data);
}
return data;
}
}
if(data == null) {
data = new WorldData(ID);
data.markDirty();
world.mapStorage.setData(ID, data);
}
return data;
}
}
@SubscribeEvent
public void tickEnd(TickEvent event) {
if(event.type == Type.SERVER && event.phase == Phase.END)
for(String s : coordsToCheck.keySet()) {
Block block = getBlockAt(s);
decrCoords(s);
@SubscribeEvent
public void tickEnd(TickEvent event) {
if(event.type == Type.SERVER && event.phase == Phase.END) for(String s : coordsToCheck.keySet()) {
Block block = getBlockAt(s);
decrCoords(s);
if(block == Blocks.piston_extension) {
int meta = getBlockMetaAt(s);
ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8);
if(block == Blocks.piston_extension) {
int meta = getBlockMetaAt(s);
ForgeDirection dir = ForgeDirection.getOrientation(meta & ~8);
MinecraftServer server = MinecraftServer.getServer();
MinecraftServer server = MinecraftServer.getServer();
if(server != null && getTimeInCoords(s) == 0) {
String newPos;
if(server != null && getTimeInCoords(s) == 0) {
String newPos;
{
String[] tokens = s.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay);
newPos = getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
}
{
String[] tokens = s.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, ModBlocks.pistonRelay);
newPos = getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
}
if(mappedPositions.containsKey(s)) {
String pos = mappedPositions.get(s);
String[] tokens = pos.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
if(mappedPositions.containsKey(s)) {
String pos = mappedPositions.get(s);
String[] tokens = pos.split(":");
int worldId = Integer.parseInt(tokens[0]), x = Integer.parseInt(tokens[1]), y = Integer.parseInt(tokens[2]), z = Integer.parseInt(tokens[3]);
World world = server.worldServerForDimension(worldId);
Block srcBlock = world.getBlock(x, y, z);
int srcMeta = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
Material mat = srcBlock.getMaterial();
Block srcBlock = world.getBlock(x, y, z);
int srcMeta = world.getBlockMetadata(x, y, z);
TileEntity tile = world.getTileEntity(x, y, z);
Material mat = srcBlock.getMaterial();
if(tile == null && mat.getMaterialMobility() == 0 && !srcBlock.isAir(world, x, y, z)) {
Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).getMaterial();
if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) || destMat.isReplaceable()) {
world.setBlock(x, y, z, Blocks.air);
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, srcBlock, srcMeta, 1 | 2);
mappedPositions.put(s, getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ));
}
}
if(tile == null && mat.getMaterialMobility() == 0 && !srcBlock.isAir(world, x, y, z)) {
Material destMat = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ).getMaterial();
if(world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ) || destMat.isReplaceable()) {
world.setBlock(x, y, z, Blocks.air);
world.setBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, srcBlock, srcMeta, 1 | 2);
mappedPositions.put(s, getCoordsAsString(world.provider.dimensionId, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ));
}
}
pos = mappedPositions.get(s);
mappedPositions.remove(s);
mappedPositions.put(newPos, pos);
WorldData.get(world).markDirty();
}
}
}
}
pos = mappedPositions.get(s);
mappedPositions.remove(s);
mappedPositions.put(newPos, pos);
WorldData.get(world).markDirty();
}
}
}
}
for(String s : removeThese)
coordsToCheck.remove(s);
removeThese.clear();
}
for(String s : removeThese)
coordsToCheck.remove(s);
removeThese.clear();
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pistonRelay;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pistonRelay;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 26, 2014, 12:22:58 AM (GMT)]
*/
package vazkii.botania.common.block;
@@ -33,82 +33,80 @@ import vazkii.botania.common.lib.LibBlockNames;
public class BlockPool extends BlockModContainer implements IWandHUD, IWandable, ILexiconable {
protected BlockPool() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.POOL);
setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
protected BlockPool() {
super(Material.rock);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.POOL);
setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TilePool();
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if(par5Entity instanceof EntityItem) {
TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4);
if(tile.collideEntityItem((EntityItem) par5Entity))
par1World.markBlockForUpdate(par2, par3, par4);
}
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TilePool();
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) {
if(par5Entity instanceof EntityItem) {
TilePool tile = (TilePool) par1World.getTileEntity(par2, par3, par4);
if(tile.collideEntityItem((EntityItem) par5Entity)) par1World.markBlockForUpdate(par2, par3, par4);
}
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.livingrock.getIcon(par1, par2);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType() {
return LibRenderIDs.idPool;
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.livingrock.getIcon(par1, par2);
}
@Override
public boolean hasComparatorInputOverride() {
return true;
}
@Override
public int getRenderType() {
return LibRenderIDs.idPool;
}
@Override
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4);
int val = (int) ((double) pool.getCurrentMana() / (double) TilePool.MAX_MANA * 15.0);
if(pool.getCurrentMana() > 0)
val = Math.max(val, 1);
@Override
public boolean hasComparatorInputOverride() {
return true;
}
return val;
}
@Override
public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) {
TilePool pool = (TilePool) par1World.getTileEntity(par2, par3, par4);
int val = (int) ((double) pool.getCurrentMana() / (double) TilePool.MAX_MANA * 15.0);
if(pool.getCurrentMana() > 0) val = Math.max(val, 1);
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
return val;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TilePool) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pool;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TilePool) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pool;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 18, 2014, 10:13:02 PM (GMT)]
*/
package vazkii.botania.common.block;
@@ -28,53 +28,53 @@ import vazkii.botania.common.lib.LibBlockNames;
public class BlockPylon extends BlockModContainer implements ILexiconable {
public BlockPylon() {
super(Material.iron);
setHardness(5.5F);
setStepSound(soundTypeMetal);
setBlockName(LibBlockNames.PYLON);
public BlockPylon() {
super(Material.iron);
setHardness(5.5F);
setStepSound(soundTypeMetal);
setBlockName(LibBlockNames.PYLON);
float f = 1F / 16F * 2F;
setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
float f = 1F / 16F * 2F;
setBlockBounds(f, 0F, f, 1F - f, 1F / 16F * 21F, 1F - f);
}
@Override
public IIcon getIcon(int par1, int par2) {
return Blocks.diamond_block.getIcon(par1, par2);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public IIcon getIcon(int par1, int par2) {
return Blocks.diamond_block.getIcon(par1, par2);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return LibRenderIDs.idPylon;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public float getEnchantPowerBonus(World world, int x, int y, int z) {
return 8;
}
@Override
public int getRenderType() {
return LibRenderIDs.idPylon;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TilePylon();
}
@Override
public float getEnchantPowerBonus(World world, int x, int y, int z) {
return 8;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pylon;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TilePylon();
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.pylon;
}
}
@@ -2,17 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 2, 2014, 2:10:14 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -32,105 +30,106 @@ import vazkii.botania.common.block.tile.TileSimpleInventory;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.Random;
public class BlockRuneAltar extends BlockModContainer implements IWandable, ILexiconable {
Random random;
IIcon[] icons;
Random random;
IIcon[] icons;
public BlockRuneAltar() {
super(Material.rock);
setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.RUNE_ALTAR);
public BlockRuneAltar() {
super(Material.rock);
setBlockBounds(0F, 0F, 0F, 1F, 0.75F, 1F);
setHardness(2.0F);
setResistance(10.0F);
setStepSound(soundTypeStone);
setBlockName(LibBlockNames.RUNE_ALTAR);
random = new Random();
}
random = new Random();
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[3];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[3];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
if(stack != null)
return ((TileRuneAltar) par1World.getTileEntity(par2, par3, par4)).addItem(par5EntityPlayer, stack);
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
if(stack != null)
return ((TileRuneAltar) par1World.getTileEntity(par2, par3, par4)).addItem(par5EntityPlayer, stack);
return false;
}
return false;
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
if (inv != null) {
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
if(inv != null) {
for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
if(itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
for(float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
if(k1 > itemstack.stackSize) k1 = itemstack.stackSize;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
if(itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
}
}
par1World.func_147453_f(par2, par3, par4, par5);
}
par1World.func_147453_f(par2, par3, par4, par5);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(2, par1)];
}
@Override
public IIcon getIcon(int par1, int par2) {
return icons[Math.min(2, par1)];
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileRuneAltar();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileRuneAltar();
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileRuneAltar) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.runicAltar;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.runicAltar;
}
}
@@ -2,21 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 22, 2014, 7:06:38 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.ITileEntityProvider;
@@ -43,136 +38,120 @@ import vazkii.botania.common.block.tile.TileSpecialFlower;
import vazkii.botania.common.core.BotaniaCreativeTab;
import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import java.util.*;
public class BlockSpecialFlower extends BlockFlower implements ITileEntityProvider, ISpecialFlower, IWandable, ILexiconable, IWandHUD {
public static Map<String, IIcon> icons = new HashMap();
private static String[] subtypes = {
// Misc
LibBlockNames.SUBTILE_PUREDAISY,
public static Map<String, IIcon> icons = new HashMap();
// Generating
LibBlockNames.SUBTILE_DAYBLOOM,
LibBlockNames.SUBTILE_NIGHTSHADE,
LibBlockNames.SUBTILE_ENDOFLAME,
LibBlockNames.SUBTILE_HYDROANGEAS,
LibBlockNames.SUBTILE_THERMALILY,
LibBlockNames.SUBTILE_ARCANE_ROSE,
private static String[] subtypes = {
// Misc
LibBlockNames.SUBTILE_PUREDAISY,
// Functional
LibBlockNames.SUBTILE_JADED_AMARANTHUS,
LibBlockNames.SUBTILE_BELLETHORN,
LibBlockNames.SUBTILE_HEISEI_DREAM,
LibBlockNames.SUBTILE_TIGERSEYE,
LibBlockNames.SUBTILE_ORECHID,
LibBlockNames.SUBTILE_FALLEN_KANADE,
LibBlockNames.SUBTILE_EXOFLAME,
LibBlockNames.SUBTILE_AGRICARNATION,
LibBlockNames.SUBTILE_HOPPERHOCK,
LibBlockNames.SUBTILE_TANGLEBERRIE,
LibBlockNames.SUBTILE_JIYUULIA
};
// Generating
LibBlockNames.SUBTILE_DAYBLOOM, LibBlockNames.SUBTILE_NIGHTSHADE, LibBlockNames.SUBTILE_ENDOFLAME, LibBlockNames.SUBTILE_HYDROANGEAS, LibBlockNames.SUBTILE_THERMALILY, LibBlockNames.SUBTILE_ARCANE_ROSE,
protected BlockSpecialFlower() {
super(0);
setBlockName(LibBlockNames.SPECIAL_FLOWER);
setHardness(0F);
setStepSound(soundTypeGrass);
setTickRandomly(true);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F);
}
// Functional
LibBlockNames.SUBTILE_JADED_AMARANTHUS, LibBlockNames.SUBTILE_BELLETHORN, LibBlockNames.SUBTILE_HEISEI_DREAM, LibBlockNames.SUBTILE_TIGERSEYE, LibBlockNames.SUBTILE_ORECHID, LibBlockNames.SUBTILE_FALLEN_KANADE, LibBlockNames.SUBTILE_EXOFLAME, LibBlockNames.SUBTILE_AGRICARNATION, LibBlockNames.SUBTILE_HOPPERHOCK, LibBlockNames.SUBTILE_TANGLEBERRIE, LibBlockNames.SUBTILE_JIYUULIA};
@Override
public int getRenderType() {
return LibRenderIDs.idSpecialFlower;
}
protected BlockSpecialFlower() {
super(0);
setBlockName(LibBlockNames.SPECIAL_FLOWER);
setHardness(0F);
setStepSound(soundTypeGrass);
setTickRandomly(true);
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setBlockBounds(0.3F, 0.0F, 0.3F, 0.8F, 1, 0.8F);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public int getRenderType() {
return LibRenderIDs.idSpecialFlower;
}
@Override
public int quantityDropped(Random par1Random) {
return 0;
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockSpecialFlower.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(String s : subtypes)
par3List.add(ItemBlockSpecialFlower.ofType(s));
}
@Override
public int quantityDropped(Random par1Random) {
return 0;
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
for(String s : subtypes)
icons.put(s, IconHelper.forName(par1IconRegister, s));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(String s : subtypes)
par3List.add(ItemBlockSpecialFlower.ofType(s));
}
@Override
public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon();
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
for(String s : subtypes)
icons.put(s, IconHelper.forName(par1IconRegister, s));
}
@Override
public IIcon getIcon(int par1, int par2) {
return BlockModFlower.icons[16];
}
@Override
public IIcon getIcon(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) {
return ((TileSpecialFlower) par1iBlockAccess.getTileEntity(par2, par3, par4)).getIcon();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName;
return ItemBlockSpecialFlower.ofType(name);
}
@Override
public IIcon getIcon(int par1, int par2) {
return BlockModFlower.icons[16];
}
@Override
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode)
dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
String name = ((TileSpecialFlower) world.getTileEntity(x, y, z)).subTileName;
return ItemBlockSpecialFlower.ofType(name);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> list = new ArrayList();
TileEntity tile = world.getTileEntity(x, y, z);
@Override
public void onBlockHarvested(World par1World, int par2, int par3, int par4, int par5, EntityPlayer par6EntityPlayer) {
if(!par6EntityPlayer.capabilities.isCreativeMode) dropBlockAsItem(par1World, par2, par3, par4, par5, 0);
}
if(tile != null) {
String name = ((TileSpecialFlower) tile).subTileName;
list.add(ItemBlockSpecialFlower.ofType(name));
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> list = new ArrayList();
TileEntity tile = world.getTileEntity(x, y, z);
return list;
}
if(tile != null) {
String name = ((TileSpecialFlower) tile).subTileName;
list.add(ItemBlockSpecialFlower.ofType(name));
}
@Override
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) {
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
}
return list;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileSpecialFlower();
}
@Override
public boolean onBlockEventReceived(World par1World, int par2, int par3, int par4, int par5, int par6) {
super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6);
TileEntity tileentity = par1World.getTileEntity(par2, par3, par4);
return tileentity != null ? tileentity.receiveClientEvent(par5, par6) : false;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileSpecialFlower();
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).getEntry();
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
return ((TileSpecialFlower) world.getTileEntity(x, y, z)).onWanded(stack, player);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileSpecialFlower) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
}
@@ -2,18 +2,15 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Jan 25, 2014, 9:38:23 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
@@ -25,7 +22,6 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -45,178 +41,178 @@ import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import java.util.List;
import java.util.Random;
public class BlockSpreader extends BlockModContainer implements IWandable, IWandHUD, ILexiconable {
Random random;
Random random;
protected BlockSpreader() {
super(Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.SPREADER);
protected BlockSpreader() {
super(Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.SPREADER);
random = new Random();
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
random = new Random();
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2, List par3) {
for(int i = 0; i < 2; i++)
par3.add(new ItemStack(par1, 1, i));
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() & 1, 1 | 2);
switch(orientation) {
case 0:
spreader.rotationY = -90F;
break;
case 1:
spreader.rotationY = 90F;
break;
case 2:
spreader.rotationX = 270F;
break;
case 3:
spreader.rotationX = 90F;
break;
case 4:
break;
default:
spreader.rotationX = 180F;
break;
}
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
// NO-OP
}
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.livingwood.getIcon(par1, par2);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2, List par3) {
for(int i = 0; i < 2; i++)
par3.add(new ItemStack(par1, 1, i));
}
@Override
public int getRenderType() {
return LibRenderIDs.idSpreader;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int orientation = BlockPistonBase.determineOrientation(par1World, par2, par3, par4, par5EntityLivingBase);
TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() & 1, 1 | 2);
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4);
ItemStack lens = spreader.getStackInSlot(0);
ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem();
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
switch(orientation) {
case 0:
spreader.rotationY = -90F;
break;
case 1:
spreader.rotationY = 90F;
break;
case 2:
spreader.rotationX = 270F;
break;
case 3:
spreader.rotationX = 90F;
break;
case 4:
break;
default:
spreader.rotationX = 180F;
break;
}
}
if(heldItem != null)
if(heldItem.getItem() == ModItems.twigWand)
return false;
@Override
public int damageDropped(int par1) {
return par1;
}
if(lens == null && isHeldItemLens) {
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
spreader.setInventorySlotContents(0, heldItem.copy());
spreader.markDirty();
} else if(lens != null) {
ItemStack add = lens.copy();
if(!par5EntityPlayer.inventory.addItemStackToInventory(add))
par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false);
spreader.setInventorySlotContents(0, null);
spreader.markDirty();
}
@Override
public boolean isOpaqueCube() {
return false;
}
return true;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
@Override
public IIcon getIcon(int par1, int par2) {
return ModBlocks.livingwood.getIcon(par1, par2);
}
if (inv != null) {
for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
@Override
public int getRenderType() {
return LibRenderIDs.idSpreader;
}
if (itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) {
TileSpreader spreader = (TileSpreader) par1World.getTileEntity(par2, par3, par4);
ItemStack lens = spreader.getStackInSlot(0);
ItemStack heldItem = par5EntityPlayer.getCurrentEquippedItem();
boolean isHeldItemLens = heldItem != null && heldItem.getItem() instanceof ILens;
for (float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if(heldItem != null) if(heldItem.getItem() == ModItems.twigWand) return false;
if (k1 > itemstack.stackSize)
k1 = itemstack.stackSize;
if(lens == null && isHeldItemLens) {
par5EntityPlayer.inventory.setInventorySlotContents(par5EntityPlayer.inventory.currentItem, null);
spreader.setInventorySlotContents(0, heldItem.copy());
spreader.markDirty();
} else if(lens != null) {
ItemStack add = lens.copy();
if(!par5EntityPlayer.inventory.addItemStackToInventory(add))
par5EntityPlayer.dropPlayerItemWithRandomChoice(add, false);
spreader.setInventorySlotContents(0, null);
spreader.markDirty();
}
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float)random.nextGaussian() * f3;
entityitem.motionY = (float)random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float)random.nextGaussian() * f3;
return true;
}
if (itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
}
}
}
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
TileSimpleInventory inv = (TileSimpleInventory) par1World.getTileEntity(par2, par3, par4);
par1World.func_147453_f(par2, par3, par4, par5);
}
if(inv != null) {
for(int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
ItemStack itemstack = inv.getStackInSlot(j1);
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
if(itemstack != null) {
float f = random.nextFloat() * 0.8F + 0.1F;
float f1 = random.nextFloat() * 0.8F + 0.1F;
EntityItem entityitem;
for(float f2 = random.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; par1World.spawnEntityInWorld(entityitem)) {
int k1 = random.nextInt(21) + 10;
if(k1 > itemstack.stackSize) k1 = itemstack.stackSize;
itemstack.stackSize -= k1;
entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
if(itemstack.hasTagCompound())
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
}
}
par1World.func_147453_f(par2, par3, par4, par5);
}
super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileSpreader) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileSpreader();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileSpreader();
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileSpreader) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.spreader : LexiconData.redstoneSpreader;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
int meta = world.getBlockMetadata(x, y, z);
return meta == 0 ? LexiconData.spreader : LexiconData.redstoneSpreader;
}
}
@@ -2,11 +2,11 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Mar 16, 2014, 10:08:14 PM (GMT)]
*/
package vazkii.botania.common.block;
@@ -31,46 +31,46 @@ import vazkii.botania.common.lib.LibBlockNames;
public class BlockTurntable extends BlockModContainer implements IWandable, IWandHUD, ILexiconable {
IIcon[] icons;
IIcon[] icons;
protected BlockTurntable() {
super(Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.TURNTABLE);
}
protected BlockTurntable() {
super(Material.wood);
setHardness(2.0F);
setStepSound(soundTypeWood);
setBlockName(LibBlockNames.TURNTABLE);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public void registerBlockIcons(IIconRegister par1IconRegister) {
icons = new IIcon[2];
for(int i = 0; i < icons.length; i++)
icons[i] = IconHelper.forBlock(par1IconRegister, this, i);
}
@Override
public IIcon getIcon(int par1, int par2) {
return par1 == 1 ? icons[0] : icons[1];
}
@Override
public IIcon getIcon(int par1, int par2) {
return par1 == 1 ? icons[0] : icons[1];
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileTurntable();
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileTurntable();
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public void renderHUD(Minecraft mc, ScaledResolution res, World world, int x, int y, int z) {
((TileTurntable) world.getTileEntity(x, y, z)).renderHUD(mc, res);
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public boolean onUsedByWand(EntityPlayer player, ItemStack stack, World world, int x, int y, int z, int side) {
((TileTurntable) world.getTileEntity(x, y, z)).onWanded(player, stack);
return true;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.turntable;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.turntable;
}
}
@@ -2,19 +2,16 @@
* This class was created by <Vazkii>. It's 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 a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
*
* File Created @ [Feb 4, 2014, 6:00:44 PM (GMT)]
*/
package vazkii.botania.common.block;
import java.awt.Color;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
@@ -31,77 +28,80 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibBlockNames;
import cpw.mods.fml.common.registry.GameRegistry;
import java.awt.*;
import java.util.List;
import java.util.Random;
public class BlockUnstable extends BlockMod implements ILexiconable {
public BlockUnstable() {
super(Material.iron);
setHardness(5.0F);
setResistance(10.0F);
setStepSound(soundTypeMetal);
setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F);
setBlockName(LibBlockNames.UNSTABLE_BLOCK);
setTickRandomly(true);
}
public BlockUnstable() {
super(Material.iron);
setHardness(5.0F);
setResistance(10.0F);
setStepSound(soundTypeMetal);
setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.75F, 0.75F);
setBlockName(LibBlockNames.UNSTABLE_BLOCK);
setTickRandomly(true);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
public Block setBlockName(String par1Str) {
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
return super.setBlockName(par1Str);
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
protected boolean shouldRegisterInNameSet() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4));
int colorBright = new Color(color).brighter().getRGB();
int colorDark = new Color(color).darker().getRGB();
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
int color = getRenderColor(par1World.getBlockMetadata(par2, par3, par4));
int colorBright = new Color(color).brighter().getRGB();
int colorDark = new Color(color).darker().getRGB();
Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5);
Vector3 endVector = origVector.copy().add(par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1);
Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright);
}
Vector3 origVector = new Vector3(par2 + 0.5, par3 + 0.5, par4 + 0.5);
Vector3 endVector = origVector.copy().add(par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1, par1World.rand.nextDouble() * 2 - 1);
Botania.proxy.lightningFX(par1World, origVector, endVector, 5F, colorDark, colorBright);
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public int getRenderColor(int par1) {
float[] color = EntitySheep.fleeceColorTable[par1];
return new Color(color[0], color[1], color[2]).getRGB();
}
@Override
public int getRenderColor(int par1) {
float[] color = EntitySheep.fleeceColorTable[par1];
return new Color(color[0], color[1], color[2]).getRGB();
}
@Override
public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4));
}
@Override
public int colorMultiplier(IBlockAccess par1iBlockAccess, int par2, int par3, int par4) {
return getRenderColor(par1iBlockAccess.getBlockMetadata(par2, par3, par4));
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.unstableBlocks;
}
@Override
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
return LexiconData.unstableBlocks;
}
}
Loaded 100 of 223 files, more files were not shown because too many files have changed in this diff. Show more