This commit is contained in:
WayofTime 2014-01-17 14:12:49 -05:00
commit 8601e9faff
498 changed files with 45817 additions and 0 deletions

View file

@ -0,0 +1,59 @@
package thaumcraft.api.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import thaumcraft.api.aspects.AspectList;
public interface IWandFocus
{
public enum WandFocusAnimation
{
WAVE, CHARGE;
}
/**
* @return The color the focus should be changed to.
*/
public int getFocusColor();
/**
* @return An icon that will be drawn as a block inside the focus "block".
*/
Icon getFocusDepthLayerIcon();
public Icon getOrnament();
public WandFocusAnimation getAnimation();
/**
* Gets the amount of vis used per aspect per click or tick. This cost is actually listed as
* a hundredth of a single point of vis, so a cost of 100 will equal one vis per tick/click.
* It is returned as an AspectList to allow for multiple vis types in different ratios.
*/
public AspectList getVisCost();
public boolean isVisCostPerTick();
public ItemStack onFocusRightClick(ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition movingobjectposition);
public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player, int count);
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world, EntityPlayer player, int count);
/**
* Helper method to determine in what order foci should be iterated through when
* the user presses the 'change focus' keybinding.
* @return a string of characters that foci will be sorted against.
* For example AA00 will be placed before FG12
* <br>As a guide build the sort string from two alphanumeric characters followed by
* two numeric characters based on... whatever.
*/
public String getSortingHelper(ItemStack itemstack);
boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player);
public boolean acceptsEnchant(int id);
}

View file

@ -0,0 +1,17 @@
package thaumcraft.api.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
/**
*
* @author azanor
*
* Implemented by a class that you wish to be called whenever a wand with this rod performs its
* update tick.
*
*/
public interface IWandRodOnUpdate
{
void onUpdate(ItemStack itemstack, EntityPlayer player);
}

View file

@ -0,0 +1,11 @@
package thaumcraft.api.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IWandTriggerManager
{
public boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
int x, int y, int z, int side, int event);
}

View file

@ -0,0 +1,24 @@
package thaumcraft.api.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
*
* @author azanor
*
* Add this to a tile entity that you wish wands to interact with in some way.
*
*/
public interface IWandable
{
public int onWandRightClick(World world, ItemStack wandstack, EntityPlayer player, int x, int y, int z, int side, int md);
public ItemStack onWandRightClick(World world, ItemStack wandstack, EntityPlayer player);
public void onUsingWandTick(ItemStack wandstack, EntityPlayer player, int count);
public void onWandStoppedUsing(ItemStack wandstack, World world, EntityPlayer player, int count);
}

View file

@ -0,0 +1,185 @@
package thaumcraft.api.wands;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Map;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemFocusBasic extends Item implements IWandFocus
{
public ItemFocusBasic(int i)
{
super(i);
maxStackSize = 1;
canRepair = false;
this.setMaxDamage(1);
}
public Icon icon;
@SideOnly(Side.CLIENT)
@Override
public Icon getIconFromDamage(int par1)
{
return icon;
}
@Override
public boolean isItemTool(ItemStack par1ItemStack)
{
return true;
}
@Override
public boolean isDamageable()
{
return true;
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
AspectList al = this.getVisCost();
if (al != null && al.size() > 0)
{
list.add(StatCollector.translateToLocal(isVisCostPerTick() ? "item.Focus.cost2" : "item.Focus.cost1"));
for (Aspect aspect: al.getAspectsSorted())
{
DecimalFormat myFormatter = new DecimalFormat("#####.##");
String amount = myFormatter.format(al.getAmount(aspect) / 100f);
list.add(" \u00A7" + aspect.getChatcolor() + aspect.getName() + "\u00A7r x " + amount);
}
}
}
@Override
public int getItemEnchantability()
{
return 5;
}
@Override
public EnumRarity getRarity(ItemStack itemstack)
{
return EnumRarity.rare;
}
@Override
public int getFocusColor()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public AspectList getVisCost()
{
// TODO Auto-generated method stub
return null;
}
@Override
public ItemStack onFocusRightClick(ItemStack itemstack, World world,
EntityPlayer player, MovingObjectPosition movingobjectposition)
{
// TODO Auto-generated method stub
return null;
}
@Override
public void onUsingFocusTick(ItemStack itemstack, EntityPlayer player,
int count)
{
// TODO Auto-generated method stub
}
@Override
public void onPlayerStoppedUsingFocus(ItemStack itemstack, World world,
EntityPlayer player, int count)
{
// TODO Auto-generated method stub
}
/**
* Just insert two alphanumeric characters before this string in your focus item class
*/
@Override
public String getSortingHelper(ItemStack itemstack)
{
Map<Integer, Integer> ench = EnchantmentHelper.getEnchantments(itemstack);
String out = "";
for (Integer lvl: ench.values())
{
out = out + lvl + "";
}
return out;
}
@Override
public boolean isVisCostPerTick()
{
return false;
}
@Override
public Icon getOrnament()
{
// TODO Auto-generated method stub
return null;
}
@Override
public boolean onFocusBlockStartBreak(ItemStack itemstack, int x, int y,
int z, EntityPlayer player)
{
// TODO Auto-generated method stub
return false;
}
@Override
public WandFocusAnimation getAnimation()
{
return WandFocusAnimation.WAVE;
}
@Override
public Icon getFocusDepthLayerIcon()
{
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see thaumcraft.api.wands.IWandFocus#acceptsEnchant(int)
* By default fortune is off for all wands
*/
@Override
public boolean acceptsEnchant(int id)
{
if (id == ThaumcraftApi.enchantFrugal ||
id == ThaumcraftApi.enchantPotency)
{
return true;
}
return false;
}
}

View file

@ -0,0 +1,133 @@
package thaumcraft.api.wands;
import java.util.LinkedHashMap;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import thaumcraft.api.aspects.Aspect;
/**
* This class is used to keep the material information for the various caps.
* It is also used to generate the wand recipes ingame.
* @author Azanor
*
*/
public class WandCap
{
private String tag;
/**
* Cost to craft this wand. Combined with the rod cost.
*/
private int craftCost;
/**
* the amount by which all aspect costs are multiplied
*/
float baseCostModifier;
/**
* specifies a list of primal aspects that use the special discount figure instead of the normal discount.
*/
List<Aspect> specialCostModifierAspects;
/**
* the amount by which the specified aspect costs are multiplied
*/
float specialCostModifier;
/**
* The texture that will be used for the ingame wand cap
*/
ResourceLocation texture;
/**
* the actual item that makes up this cap and will be used to generate the wand recipes
*/
ItemStack item;
public static LinkedHashMap<String, WandCap> caps = new LinkedHashMap<String, WandCap>();
public WandCap(String tag, float discount, ItemStack item, int craftCost)
{
this.setTag(tag);
this.baseCostModifier = discount;
this.specialCostModifierAspects = null;
texture = new ResourceLocation("thaumcraft", "textures/models/wand_cap_" + getTag() + ".png");
this.item = item;
this.setCraftCost(craftCost);
caps.put(tag, this);
}
public WandCap(String tag, float discount, List<Aspect> specialAspects, float discountSpecial, ItemStack item, int craftCost)
{
this.setTag(tag);
this.baseCostModifier = discount;
this.specialCostModifierAspects = specialAspects;
this.specialCostModifier = discountSpecial;
texture = new ResourceLocation("thaumcraft", "textures/models/wand_cap_" + getTag() + ".png");
this.item = item;
this.setCraftCost(craftCost);
caps.put(tag, this);
}
public float getBaseCostModifier()
{
return baseCostModifier;
}
public List<Aspect> getSpecialCostModifierAspects()
{
return specialCostModifierAspects;
}
public float getSpecialCostModifier()
{
return specialCostModifier;
}
public ResourceLocation getTexture()
{
return texture;
}
public void setTexture(ResourceLocation texture)
{
this.texture = texture;
}
public String getTag()
{
return tag;
}
public void setTag(String tag)
{
this.tag = tag;
}
public ItemStack getItem()
{
return item;
}
public void setItem(ItemStack item)
{
this.item = item;
}
public int getCraftCost()
{
return craftCost;
}
public void setCraftCost(int craftCost)
{
this.craftCost = craftCost;
}
// Some examples:
// WandCap WAND_CAP_IRON = new WandCap("iron", 1.1f, Arrays.asList(Aspect.ORDER),1, new ItemStack(ConfigItems.itemWandCap,1,0),1);
// WandCap WAND_CAP_GOLD = new WandCap("gold", 1f, new ItemStack(ConfigItems.itemWandCap,1,1),3);
}

View file

@ -0,0 +1,168 @@
package thaumcraft.api.wands;
import java.util.LinkedHashMap;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
/**
*
* @author Azanor
*
* This class is used to keep the material information for the various rods.
* It is also used to generate the wand recipes ingame.
*
*/
public class WandRod
{
private String tag;
/**
* Cost to craft this wand. Combined with the rod cost.
*/
private int craftCost;
/**
* The amount of vis that can be stored - this number is actually multiplied
* by 100 for use by the wands internals
*/
int capacity;
/**
* The texture that will be used for the ingame wand rod
*/
ResourceLocation texture;
/**
* the actual item that makes up this rod and will be used to generate the wand recipes
*/
ItemStack item;
/**
* A class that will be called whenever the wand onUpdate tick is run
*/
IWandRodOnUpdate onUpdate;
/**
* Does the rod glow in the dark?
*/
boolean glow;
public static LinkedHashMap<String, WandRod> rods = new LinkedHashMap<String, WandRod>();
public WandRod(String tag, int capacity, ItemStack item, int craftCost, ResourceLocation texture)
{
this.setTag(tag);
this.capacity = capacity;
this.texture = texture;
this.item = item;
this.setCraftCost(craftCost);
rods.put(tag, this);
}
public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate, ResourceLocation texture)
{
this.setTag(tag);
this.capacity = capacity;
this.texture = texture;
this.item = item;
this.setCraftCost(craftCost);
rods.put(tag, this);
this.onUpdate = onUpdate;
}
public WandRod(String tag, int capacity, ItemStack item, int craftCost)
{
this.setTag(tag);
this.capacity = capacity;
this.texture = new ResourceLocation("thaumcraft", "textures/models/wand_rod_" + getTag() + ".png");
this.item = item;
this.setCraftCost(craftCost);
rods.put(tag, this);
}
public WandRod(String tag, int capacity, ItemStack item, int craftCost, IWandRodOnUpdate onUpdate)
{
this.setTag(tag);
this.capacity = capacity;
this.texture = new ResourceLocation("thaumcraft", "textures/models/wand_rod_" + getTag() + ".png");
this.item = item;
this.setCraftCost(craftCost);
rods.put(tag, this);
this.onUpdate = onUpdate;
}
public String getTag()
{
return tag;
}
public void setTag(String tag)
{
this.tag = tag;
}
public int getCapacity()
{
return capacity;
}
public void setCapacity(int capacity)
{
this.capacity = capacity;
}
public ResourceLocation getTexture()
{
return texture;
}
public void setTexture(ResourceLocation texture)
{
this.texture = texture;
}
public ItemStack getItem()
{
return item;
}
public void setItem(ItemStack item)
{
this.item = item;
}
public int getCraftCost()
{
return craftCost;
}
public void setCraftCost(int craftCost)
{
this.craftCost = craftCost;
}
public IWandRodOnUpdate getOnUpdate()
{
return onUpdate;
}
public void setOnUpdate(IWandRodOnUpdate onUpdate)
{
this.onUpdate = onUpdate;
}
public boolean isGlowing()
{
return glow;
}
public void setGlowing(boolean hasGlow)
{
this.glow = hasGlow;
}
// Some examples:
// WandRod WAND_ROD_WOOD = new WandRod("wood",25,new ItemStack(Item.stick),1);
// WandRod WAND_ROD_BLAZE = new WandRod("blaze",100,new ItemStack(Item.blazeRod),7,new WandRodBlazeOnUpdate());
}

View file

@ -0,0 +1,83 @@
package thaumcraft.api.wands;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* This class serves a similar function to IWandable in that it allows wands to interact
* with object in the world. In this case it is most useful for adding interaction with non-mod
* blocks where you can't control what happens in their code.
* Example where it is used is in crafting the thaumonomicon from a bookshelf and the
* crucible from a cauldron
*
* @author azanor
*
*/
public class WandTriggerRegistry
{
/**
* Registers an action to perform when a casting wand right clicks on a specific block.
* A manager class needs to be created that implements IWandTriggerManager.
* @param manager
* @param event a logical number that you can use to differentiate different events or actions
* @param blockid
* @param meta send -1 as a wildcard value for all possible meta values
*/
public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, int blockid, int meta)
{
triggers.put(Arrays.asList(blockid, meta),
Arrays.asList(manager, event));
}
private static HashMap<List<Integer>, List> triggers = new HashMap<List<Integer>, List>();
public static boolean hasTrigger(int blockid, int meta)
{
if (triggers.containsKey(Arrays.asList(blockid, meta)) ||
triggers.containsKey(Arrays.asList(blockid, -1)))
{
return true;
}
return false;
}
/**
* This is called by the onItemUseFirst function in wands.
* Parameters and return value functions like you would expect for that function.
* @param world
* @param wand
* @param player
* @param x
* @param y
* @param z
* @param side
* @param blockid
* @param meta
* @return
*/
public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
int x, int y, int z, int side, int blockid, int meta)
{
List l = triggers.get(Arrays.asList(blockid, meta));
if (l == null)
{
l = triggers.get(Arrays.asList(blockid, -1));
}
if (l == null)
{
return false;
}
IWandTriggerManager manager = (IWandTriggerManager) l.get(0);
int event = (Integer) l.get(1);
return manager.performTrigger(world, wand, player, x, y, z, side, event);
}
}