Initial Git

This commit is contained in:
oitsjustjose 2013-06-21 16:47:54 -05:00
commit a12f6ddce8
347 changed files with 16443 additions and 0 deletions

View file

@ -0,0 +1,9 @@
package thaumcraft.api.research;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IScanEventHandler {
ScanResult scanPhenomena(ItemStack stack, World world, EntityPlayer player);
}

View file

@ -0,0 +1,274 @@
package thaumcraft.api.research;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import thaumcraft.api.ObjectTags;
import thaumcraft.api.ThaumcraftApi;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ResearchItem
{
/**
* A short string used as a key for this research. Must be unique
*/
public final String key;
/**
* The name of the research shown in the thaumonomicon
*/
public String name;
/**
* The blurb text shown below the research name in the thaumonomicon
*/
public String popupText;
/**
* A longer description of the research. This is the text shown in the handheld research scroll and the research table.
*/
public String longText;
/**
* The aspect tags and their values required to complete this research
*/
public final ObjectTags tags;
/**
* This links to any research that needs to be completed before this research can be discovered or learnt.
*/
public ResearchItem[] parents = null;
/**
* Like parent above, but a line will not be displayed in the thaumonomicon linking them. Just used to prevent clutter.
*/
public ResearchItem[] parentsHidden = null;
/**
* any research linked to this that will be unlocked automatically when this research is complete
*/
public ResearchItem[] siblings = null;
/**
* the horizontal position of the research icon
*/
public final int displayColumn;
/**
* the vertical position of the research icon
*/
public final int displayRow;
/**
* the itemstack of an item or block that will be used as the icon for this research
*/
public final ItemStack itemStack;
/**
* the index within the research.png file used for this research if it does not use an item icon
*/
public final int iconIndex;
/**
* Special research has a spiky border. Used for important research milestones.
*/
private boolean isSpecial;
/**
* This indicates if the research should use a circular icon border. Usually used for research that doesn't
* have recipes or that unlocks automatically via the sibling system
*/
private boolean isStub;
/**
* Indicates research that cannot be gained by normal means (either via normal or lost research),
* but still uses a normal icon. Works much like isStub but is handy for mods that wish to add research
* through their own means and keep a normal icon.
*/
private boolean isAlternate;
/**
* Hidden research does not display in the thaumonomicon until discovered
*/
private boolean isHidden;
/**
* Lost research can only be discovered via knowledge fragments
*/
private boolean isLost;
/**
* These research items will automatically unlock for all players on game start
*/
private boolean isAutoUnlock;
public ResearchItem(String par1, ObjectTags tags, int par3, int par4, int icon)
{
this(par1, tags, par3, par4, (ItemStack)null, icon);
}
public ResearchItem(String par1, ObjectTags tags, int par3, int par4, ItemStack par5Item)
{
this(par1, tags, par3, par4, par5Item, -1);
}
public ResearchItem(String par1, ObjectTags tags, int par3, int par4, Item par5Item)
{
this(par1, tags, par3, par4, new ItemStack(par5Item), -1);
}
public ResearchItem(String par1, ObjectTags tags, int par3, int par4, Block par5Block)
{
this(par1, tags, par3, par4, new ItemStack(par5Block), -1);
}
public ResearchItem(String par1, ObjectTags tags, int par3, int par4, ItemStack par5ItemStack, int icon)
{
this.key = par1;
this.tags = tags;
this.name = "";
this.longText = "";
this.popupText = "";
Element el = ThaumcraftApi.researchDoc.getElementById(key);
if (el!=null) {
NodeList children = el.getChildNodes();
for (int a=0;a<children.getLength();a++) {
if (children.item(a).getNodeName().equals("name")) {
this.name = children.item(a).getTextContent();
} else
if (children.item(a).getNodeName().equals("longText")) {
this.longText = children.item(a).getTextContent();
} else
if (children.item(a).getNodeName().equals("popupText") ) {
this.popupText = children.item(a).getTextContent();
}
}
}
this.itemStack = par5ItemStack;
this.iconIndex = icon;
this.displayColumn = par3;
this.displayRow = par4;
if (par3 < ResearchList.minDisplayColumn)
{
ResearchList.minDisplayColumn = par3;
}
if (par4 < ResearchList.minDisplayRow)
{
ResearchList.minDisplayRow = par4;
}
if (par3 > ResearchList.maxDisplayColumn)
{
ResearchList.maxDisplayColumn = par3;
}
if (par4 > ResearchList.maxDisplayRow)
{
ResearchList.maxDisplayRow = par4;
}
}
public ResearchItem setSpecial()
{
this.isSpecial = true;
return this;
}
public ResearchItem setStub()
{
this.isStub = true;
return this;
}
public ResearchItem setAlternate()
{
this.isAlternate = true;
return this;
}
public ResearchItem setHidden()
{
this.isHidden = true;
return this;
}
public ResearchItem setLost()
{
this.isLost = true;
return this;
}
public ResearchItem setParents(ResearchItem... par)
{
this.parents = par;
return this;
}
public ResearchItem setParentsHidden(ResearchItem... par)
{
this.parentsHidden = par;
return this;
}
public ResearchItem setSiblings(ResearchItem... sib)
{
this.siblings = sib;
return this;
}
public ResearchItem registerResearchItem()
{
ResearchList.research.put(key, this);
return this;
}
@SideOnly(Side.CLIENT)
public String getName()
{
return this.name;
}
@SideOnly(Side.CLIENT)
public boolean getSpecial()
{
return this.isSpecial;
}
public boolean getStub()
{
return this.isStub;
}
public boolean getAlternate()
{
return this.isAlternate;
}
public boolean getHidden()
{
return this.isHidden;
}
public boolean getLost()
{
return this.isLost;
}
public boolean getAutoUnlock() {
return isAutoUnlock;
}
public ResearchItem setAutoUnlock()
{
this.isAutoUnlock = true;
return this;
}
}

View file

@ -0,0 +1,91 @@
package thaumcraft.api.research;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import thaumcraft.api.EnumTag;
public class ResearchList {
/** Is the smallest column used on the GUI. */
public static int minDisplayColumn;
/** Is the smallest row used on the GUI. */
public static int minDisplayRow;
/** Is the biggest column used on the GUI. */
public static int maxDisplayColumn;
/** Is the biggest row used on the GUI. */
public static int maxDisplayRow;
//Research
public static Map<String, ResearchItem> research = new HashMap<String,ResearchItem>();
public static Map<String, List> craftingRecipesForResearch = new HashMap<String, List>();
//
/**
* @param key
* @return the research item linked to this key
*/
public static ResearchItem getResearch(String key) {
return research.get(key);
}
/**
* @param key
* @return the name of the research linked to this key
*/
public static String getResearchName(String key) {
ResearchItem rr = research.get(key);
if (rr==null) return "";
return rr.name;
}
/**
* @param key
* @return a list of the enumtags used in this research. returns the numeric values and not the actual enum
*/
public static byte[] getResearchTags(String key) {
ResearchItem rr = research.get(key);
if (rr==null) return null;
byte[] output = new byte[rr.tags.size()];
EnumTag[] et = rr.tags.getAspects();
for (int a=0;a<rr.tags.size();a++) {
output[a] = (byte) et[a].id;
}
return output;
}
/**
* @param key
* @return the aspect enumtag ordinal with the highest value. Used to determine scroll color and similar things
*/
public static int getResearchPrimaryTag(String key) {
int t=0;
int amt=0;
ResearchItem rr = research.get(key);
if (rr==null) return 0;
for (EnumTag tag:rr.tags.getAspects()) {
if (rr.tags.getAmount(tag)>amt) {
t=tag.id;
amt=rr.tags.getAmount(tag);
};
}
return t;
}
public static int getResearchAmount(String key, EnumTag tag) {
ResearchItem rr = research.get(key);
if (rr==null) return 0;
return rr.tags.getAmount(tag);
}
}

View file

@ -0,0 +1,14 @@
package thaumcraft.api.research;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ResearchPlayer {
public Map<String,List<String>> researchCompleted = new HashMap<String,List<String>>();
public Map<String,List<Short[]>> objectsScanned = new HashMap<String,List<Short[]>>();
public Map<String,List<String>> entitiesScanned = new HashMap<String,List<String>>();
public Map<String,List<String>> phenomenaScanned = new HashMap<String,List<String>>();
}

View file

@ -0,0 +1,39 @@
package thaumcraft.api.research;
import net.minecraft.entity.Entity;
public class ScanResult {
public byte type = 0; //1=blocks,2=entities,3=phenomena
public int blockId;
public int blockMeta;
public Entity entity;
public String phenomena;
public ScanResult(byte type, int blockId, int blockMeta, Entity entity,
String phenomena) {
super();
this.type = type;
this.blockId = blockId;
this.blockMeta = blockMeta;
this.entity = entity;
this.phenomena = phenomena;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof ScanResult) {
ScanResult sr = (ScanResult) obj;
if (type != sr.type)
return false;
if (type == 1
&& (blockId != sr.blockId || blockMeta != sr.blockMeta))
return false;
if (type == 2 && entity.entityId != sr.entity.entityId)
return false;
if (type == 3 && !phenomena.equals(sr.phenomena))
return false;
}
return true;
}
}