mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 18:55:03 -04:00
Updated Thaumcraft API and, as per request, added converter for items including apsect info.
Keeping TC converters disabled by default, though, because this seems kind of cheaty to me (usually you'd have to research aspects to see them on items).
This commit is contained in:
parent
a1ec488588
commit
febcabdde9
@ -1,5 +1,5 @@
|
||||
minecraft.version=1.7.10
|
||||
forge.version=10.13.1.1217
|
||||
forge.version=10.13.1.1224
|
||||
|
||||
oc.version=1.4.0
|
||||
oc.subversion=dev
|
||||
|
@ -1,6 +1,5 @@
|
||||
package thaumcraft.api;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package thaumcraft.api;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
@ -134,13 +135,37 @@ public class ThaumcraftApiHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean areItemStackTagsEqualForCrafting(ItemStack slotItem,ItemStack recipeItem)
|
||||
{
|
||||
if (recipeItem == null || slotItem == null) return false;
|
||||
if (recipeItem.stackTagCompound!=null && slotItem.stackTagCompound==null ) return false;
|
||||
if (recipeItem.stackTagCompound==null ) return true;
|
||||
|
||||
Iterator iterator = recipeItem.stackTagCompound.func_150296_c().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s = (String)iterator.next();
|
||||
if (slotItem.stackTagCompound.hasKey(s)) {
|
||||
if (!slotItem.stackTagCompound.getTag(s).toString().equals(
|
||||
recipeItem.stackTagCompound.getTag(s).toString())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean itemMatches(ItemStack target, ItemStack input, boolean strict)
|
||||
{
|
||||
if (input == null && target != null || input != null && target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (target.getItem() == input.getItem() && ((target.getItemDamage() == OreDictionary.WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage()));
|
||||
return (target.getItem() == input.getItem() &&
|
||||
((target.getItemDamage() == OreDictionary.WILDCARD_VALUE && !strict) || target.getItemDamage() == input.getItemDamage()));
|
||||
}
|
||||
|
||||
|
||||
@ -265,4 +290,47 @@ public class ThaumcraftApiHelper {
|
||||
}
|
||||
return ot;
|
||||
}
|
||||
|
||||
|
||||
static Method addWarpToPlayer;
|
||||
/**
|
||||
* This adds permanents or temporary warp to a player. It will automatically be synced clientside
|
||||
* @param player the player using the wand
|
||||
* @param amount how much warp to add. Negative amounts are only valid for temporary warp
|
||||
* @param temporary add temporary warp instead of permanent
|
||||
*/
|
||||
public static void addWarpToPlayer(EntityPlayer player, int amount, boolean temporary) {
|
||||
boolean ot = false;
|
||||
try {
|
||||
if(addWarpToPlayer == null) {
|
||||
Class fake = Class.forName("thaumcraft.common.Thaumcraft");
|
||||
addWarpToPlayer = fake.getMethod("addWarpToPlayer",
|
||||
EntityPlayer.class, int.class, boolean.class);
|
||||
}
|
||||
addWarpToPlayer.invoke(null, player, amount, temporary);
|
||||
} catch(Exception ex) {
|
||||
FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.Thaumcraft method addWarpToPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
static Method addStickyWarpToPlayer;
|
||||
/**
|
||||
* This "sticky" warp to a player. Sticky warp is permanent warp that can be removed.
|
||||
* It will automatically be synced clientside
|
||||
* @param player the player using the wand
|
||||
* @param amount how much warp to add. Can have negative amounts.
|
||||
*/
|
||||
public static void addStickyWarpToPlayer(EntityPlayer player, int amount) {
|
||||
boolean ot = false;
|
||||
try {
|
||||
if(addStickyWarpToPlayer == null) {
|
||||
Class fake = Class.forName("thaumcraft.common.Thaumcraft");
|
||||
addStickyWarpToPlayer = fake.getMethod("addStickyWarpToPlayer",
|
||||
EntityPlayer.class, int.class);
|
||||
}
|
||||
addStickyWarpToPlayer.invoke(null, player, amount);
|
||||
} catch(Exception ex) {
|
||||
FMLLog.warning("[Thaumcraft API] Could not invoke thaumcraft.common.Thaumcraft method addStickyWarpToPlayer");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -233,6 +233,19 @@ public class AspectList implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound, String label)
|
||||
{
|
||||
aspects.clear();
|
||||
NBTTagList tlist = nbttagcompound.getTagList(label,(byte)10);
|
||||
for (int j = 0; j < tlist.tagCount(); j++) {
|
||||
NBTTagCompound rs = (NBTTagCompound) tlist.getCompoundTagAt(j);
|
||||
if (rs.hasKey("key")) {
|
||||
add( Aspect.getAspect(rs.getString("key")),
|
||||
rs.getInteger("amount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the list of aspects to nbt
|
||||
* @param nbttagcompound
|
||||
@ -251,6 +264,17 @@ public class AspectList implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound, String label)
|
||||
{
|
||||
NBTTagList tlist = new NBTTagList();
|
||||
nbttagcompound.setTag(label, tlist);
|
||||
for (Aspect aspect : getAspects())
|
||||
if (aspect != null) {
|
||||
NBTTagCompound f = new NBTTagCompound();
|
||||
f.setString("key", aspect.getTag());
|
||||
f.setInteger("amount", getAmount(aspect));
|
||||
tlist.appendTag(f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class DamageSourceThaumcraft extends DamageSource
|
||||
public static DamageSource taint = new DamageSourceThaumcraft("taint").setDamageBypassesArmor().setMagicDamage();
|
||||
public static DamageSource tentacle = new DamageSourceThaumcraft("tentacle");
|
||||
public static DamageSource swarm = new DamageSourceThaumcraft("swarm");
|
||||
public static DamageSource dissolve = new DamageSourceThaumcraft("dissolve").setDamageBypassesArmor();
|
||||
|
||||
protected DamageSourceThaumcraft(String par1Str) {
|
||||
super(par1Str);
|
||||
|
@ -40,7 +40,7 @@ public class PotionFluxTaint extends Potion
|
||||
return super.getStatusIconIndex();
|
||||
}
|
||||
|
||||
ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png");
|
||||
static final ResourceLocation rl = new ResourceLocation("thaumcraft","textures/misc/potions.png");
|
||||
|
||||
@Override
|
||||
public void performEffect(EntityLivingBase target, int par2) {
|
||||
|
@ -20,6 +20,7 @@
|
||||
"ProjRed|Transmission",
|
||||
"RedLogic",
|
||||
"StargateTech2",
|
||||
"Thaumcraft",
|
||||
"ThermalExpansion",
|
||||
"UniversalElectricity"
|
||||
],
|
||||
|
@ -15,7 +15,7 @@ object ConverterSafariNet extends Converter {
|
||||
"MineFactoryReloaded:item.mfr.safarinet.singleuse",
|
||||
"MineFactoryReloaded:item.mfr.safarinet.jailer")
|
||||
|
||||
override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]) = value match {
|
||||
override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]): Unit = value match {
|
||||
case stack: ItemStack =>
|
||||
val name = Item.itemRegistry.getNameForObject(stack.getItem)
|
||||
if (SafariNetNames.contains(name)) {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package li.cil.oc.integration.thaumcraft
|
||||
|
||||
import java.util
|
||||
|
||||
import li.cil.oc.api.driver.Converter
|
||||
import net.minecraft.item.ItemStack
|
||||
import thaumcraft.api.aspects.AspectList
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
|
||||
object ConverterAspectItem extends Converter {
|
||||
override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]): Unit = value match {
|
||||
case stack: ItemStack if stack.hasTagCompound =>
|
||||
val aspects = new AspectList()
|
||||
aspects.readFromNBT(stack.getTagCompound)
|
||||
output += "aspects" -> aspects
|
||||
case _ =>
|
||||
}
|
||||
}
|
@ -14,17 +14,17 @@ public class ConverterIAspectContainer implements Converter {
|
||||
public void convert(final Object value, final Map<Object, Object> output) {
|
||||
if (value instanceof IAspectContainer) {
|
||||
final IAspectContainer container = (IAspectContainer) value;
|
||||
output.put("aspectList", container.getAspects());
|
||||
output.put("aspects", container.getAspects());
|
||||
}
|
||||
|
||||
if (value instanceof AspectList) {
|
||||
final AspectList aspectList = (AspectList) value;
|
||||
final AspectList aspects = (AspectList) value;
|
||||
int i = 0;
|
||||
for (Aspect aspect : aspectList.getAspects()) {
|
||||
for (Aspect aspect : aspects.getAspects()) {
|
||||
if (aspect == null) continue;
|
||||
final HashMap<Object, Object> aspectMap = Maps.newHashMap();
|
||||
aspectMap.put("name", aspect.getName());
|
||||
aspectMap.put("quantity", aspectList.getAmount(aspect));
|
||||
aspectMap.put("amount", aspects.getAmount(aspect));
|
||||
output.put(++i, aspectMap);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ object ModThaumcraft extends ModProxy {
|
||||
|
||||
override def initialize() {
|
||||
Driver.add(new DriverAspectContainer)
|
||||
|
||||
Driver.add(new ConverterIAspectContainer)
|
||||
Driver.add(ConverterAspectItem)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user