Updated the Thaumcraft API
This commit is contained in:
parent
8d66e077b2
commit
47e5633058
33 changed files with 1381 additions and 40 deletions
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
@ -264,13 +265,15 @@ public class ThaumcraftApi {
|
||||||
* @param tags the aspects required to craft this
|
* @param tags the aspects required to craft this
|
||||||
*/
|
*/
|
||||||
public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) {
|
public static CrucibleRecipe addCrucibleRecipe(String key, ItemStack result, Object catalyst, AspectList tags) {
|
||||||
CrucibleRecipe rc = new CrucibleRecipe(key, result, catalyst, tags);
|
return addCrucibleRecipe(new String[] {key},result,catalyst,tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CrucibleRecipe addCrucibleRecipe(String[] keys, ItemStack result, Object catalyst, AspectList tags) {
|
||||||
|
CrucibleRecipe rc = new CrucibleRecipe(keys, result, catalyst, tags);
|
||||||
getCraftingRecipes().add(rc);
|
getCraftingRecipes().add(rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stack the recipe result
|
* @param stack the recipe result
|
||||||
* @return the recipe
|
* @return the recipe
|
||||||
|
@ -539,6 +542,8 @@ public class ThaumcraftApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// PORTABLE HOLE BLACKLIST
|
// PORTABLE HOLE BLACKLIST
|
||||||
/**
|
/**
|
||||||
* You can blacklist blocks that may not be portable holed through using the "portableHoleBlacklist"
|
* You can blacklist blocks that may not be portable holed through using the "portableHoleBlacklist"
|
||||||
|
@ -556,6 +561,25 @@ public class ThaumcraftApi {
|
||||||
|
|
||||||
|
|
||||||
// CROPS
|
// CROPS
|
||||||
|
|
||||||
|
public static HashMap<String,ItemStack> seedList = new HashMap<String,ItemStack>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to register an item that will act as a seed for the specified block.
|
||||||
|
* If your seed items use IPlantable it might not be necessary to do this as I
|
||||||
|
* attempt to automatically detect such links.
|
||||||
|
* @param block
|
||||||
|
* @param seed
|
||||||
|
*/
|
||||||
|
public static void registerSeed(Block block, ItemStack seed) {
|
||||||
|
seedList.put(block.getUnlocalizedName(), seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getSeed(Block block) {
|
||||||
|
return seedList.get(block.getUnlocalizedName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To define mod crops you need to use FMLInterModComms in your @Mod.Init method.
|
* To define mod crops you need to use FMLInterModComms in your @Mod.Init method.
|
||||||
* There are two 'types' of crops you can add. Standard crops and clickable crops.
|
* There are two 'types' of crops you can add. Standard crops and clickable crops.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package thaumcraft.api;
|
package thaumcraft.api;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -326,4 +326,42 @@ public class ThaumcraftApiHelper {
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int setByteInInt(int data, byte b, int index)
|
||||||
|
{
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(4);
|
||||||
|
bb.putInt(0,data);
|
||||||
|
bb.put(index, b);
|
||||||
|
return bb.getInt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getByteInInt(int data, int index) {
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(4);
|
||||||
|
bb.putInt(0,data);
|
||||||
|
return bb.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long setByteInLong(long data, byte b, int index)
|
||||||
|
{
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(8);
|
||||||
|
bb.putLong(0,data);
|
||||||
|
bb.put(index, b);
|
||||||
|
return bb.getLong(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getByteInLong(long data, int index) {
|
||||||
|
ByteBuffer bb = ByteBuffer.allocate(8);
|
||||||
|
bb.putLong(0,data);
|
||||||
|
return bb.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int setNibbleInInt(int data, int nibble, int nibbleIndex)
|
||||||
|
{
|
||||||
|
int shift = nibbleIndex * 4;
|
||||||
|
return (data & ~(0xf << shift)) | (nibble << shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNibbleInInt(int data, int nibbleIndex) {
|
||||||
|
return (data >> (nibbleIndex << 2)) & 0xF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class Aspect {
|
||||||
|
|
||||||
//SECONDARY (PRIMAL + PRIMAL)
|
//SECONDARY (PRIMAL + PRIMAL)
|
||||||
public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771);
|
public static final Aspect VOID = new Aspect("vacuos",0x888888, new Aspect[] {AIR, ENTROPY},771);
|
||||||
public static final Aspect LIGHT = new Aspect("lux",0xfff663, new Aspect[] {AIR, FIRE});
|
public static final Aspect LIGHT = new Aspect("lux",0xffd585, new Aspect[] {AIR, FIRE});
|
||||||
public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER});
|
public static final Aspect MOTION = new Aspect("motus",0xcdccf4, new Aspect[] {AIR, ORDER});
|
||||||
public static final Aspect COLD = new Aspect("gelum",0xe1ffff, new Aspect[] {FIRE, ENTROPY});
|
public static final Aspect COLD = new Aspect("gelum",0xe1ffff, new Aspect[] {FIRE, ENTROPY});
|
||||||
public static final Aspect CRYSTAL = new Aspect("vitreus",0x80ffff, new Aspect[] {EARTH, AIR});
|
public static final Aspect CRYSTAL = new Aspect("vitreus",0x80ffff, new Aspect[] {EARTH, AIR});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package thaumcraft.api.aura;
|
package thaumcraft.api.aura;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.BlockPos;
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thaumcraft.api.ThaumcraftApi;
|
import thaumcraft.api.ThaumcraftApi;
|
||||||
|
@ -66,6 +67,19 @@ public class AuraHelper {
|
||||||
return ThaumcraftApi.internalMethods.getAuraBase(world,pos);
|
return ThaumcraftApi.internalMethods.getAuraBase(world,pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if the local aura for the given aspect is below 10% and that the player has the node preserver research.
|
||||||
|
* If the passed in player is null it will ignore the need for the research to be completed and just assume it is.
|
||||||
|
* @param world
|
||||||
|
* @param player
|
||||||
|
* @param pos
|
||||||
|
* @param aspect
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean shouldPreserveAura(World world, EntityPlayer player, BlockPos pos, Aspect aspect) {
|
||||||
|
return ThaumcraftApi.internalMethods.shouldPreserveAura(world,player,pos,aspect);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds flux to the aura at the specified block position.
|
* Adds flux to the aura at the specified block position.
|
||||||
* @param world
|
* @param world
|
||||||
|
|
|
@ -95,6 +95,10 @@ public class BlocksTC {
|
||||||
public static Block lampArcane;
|
public static Block lampArcane;
|
||||||
public static Block lampFertility;
|
public static Block lampFertility;
|
||||||
public static Block lampGrowth;
|
public static Block lampGrowth;
|
||||||
|
public static Block golemBuilder;
|
||||||
|
public static Block nodeStabilizer;
|
||||||
|
public static Block essentiaTransportInput;
|
||||||
|
public static Block essentiaTransportOutput;
|
||||||
|
|
||||||
// Fluids
|
// Fluids
|
||||||
public static Block fluxGoo;
|
public static Block fluxGoo;
|
||||||
|
@ -125,6 +129,9 @@ public class BlocksTC {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ public class CrucibleRecipe {
|
||||||
|
|
||||||
public Object catalyst;
|
public Object catalyst;
|
||||||
public AspectList aspects;
|
public AspectList aspects;
|
||||||
public String research;
|
public String[] research;
|
||||||
|
|
||||||
public int hash;
|
public int hash;
|
||||||
|
|
||||||
public CrucibleRecipe(String researchKey, ItemStack result, Object cat, AspectList tags) {
|
public CrucibleRecipe(String[] researchKey, ItemStack result, Object cat, AspectList tags) {
|
||||||
recipeOutput = result;
|
recipeOutput = result;
|
||||||
this.aspects = tags;
|
this.aspects = tags;
|
||||||
this.research = researchKey;
|
this.research = researchKey;
|
||||||
|
@ -26,7 +26,8 @@ public class CrucibleRecipe {
|
||||||
if (cat instanceof String) {
|
if (cat instanceof String) {
|
||||||
this.catalyst = OreDictionary.getOres((String) cat);
|
this.catalyst = OreDictionary.getOres((String) cat);
|
||||||
}
|
}
|
||||||
String hc = researchKey;
|
String hc = "";
|
||||||
|
for (String ss:research) hc+=ss;
|
||||||
hc += result.toString();
|
hc += result.toString();
|
||||||
for (Aspect tag:tags.getAspects()) {
|
for (Aspect tag:tags.getAspects()) {
|
||||||
hc += tag.getTag()+tags.getAmount(tag);
|
hc += tag.getTag()+tags.getAmount(tag);
|
||||||
|
|
51
src/api/java/thaumcraft/api/golems/EnumGolemTrait.java
Normal file
51
src/api/java/thaumcraft/api/golems/EnumGolemTrait.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package thaumcraft.api.golems;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
public enum EnumGolemTrait {
|
||||||
|
SMART(new ResourceLocation("thaumcraft","textures/misc/golem/tag_smart.png")),
|
||||||
|
DEFT(new ResourceLocation("thaumcraft","textures/misc/golem/tag_deft.png")),
|
||||||
|
CLUMSY(new ResourceLocation("thaumcraft","textures/misc/golem/tag_clumsy.png")),
|
||||||
|
FIGHTER(new ResourceLocation("thaumcraft","textures/misc/golem/tag_fighter.png")),
|
||||||
|
WHEELED(new ResourceLocation("thaumcraft","textures/misc/golem/tag_wheeled.png")),
|
||||||
|
FLYER(new ResourceLocation("thaumcraft","textures/misc/golem/tag_flyer.png")),
|
||||||
|
CLIMBER(new ResourceLocation("thaumcraft","textures/misc/golem/tag_climber.png")),
|
||||||
|
HEAVY(new ResourceLocation("thaumcraft","textures/misc/golem/tag_heavy.png")),
|
||||||
|
LIGHT(new ResourceLocation("thaumcraft","textures/misc/golem/tag_light.png")),
|
||||||
|
FRAGILE(new ResourceLocation("thaumcraft","textures/misc/golem/tag_fragile.png")),
|
||||||
|
REPAIR(new ResourceLocation("thaumcraft","textures/misc/golem/tag_repair.png")),
|
||||||
|
SCOUT(new ResourceLocation("thaumcraft","textures/misc/golem/tag_scout.png")),
|
||||||
|
ARMORED(new ResourceLocation("thaumcraft","textures/misc/golem/tag_armored.png")),
|
||||||
|
BRUTAL(new ResourceLocation("thaumcraft","textures/misc/golem/tag_brutal.png")),
|
||||||
|
FIREPROOF(new ResourceLocation("thaumcraft","textures/misc/golem/tag_fireproof.png")),
|
||||||
|
BREAKER(new ResourceLocation("thaumcraft","textures/misc/golem/tag_breaker.png")),
|
||||||
|
HAULER(new ResourceLocation("thaumcraft","textures/misc/golem/tag_hauler.png")),
|
||||||
|
RANGED(new ResourceLocation("thaumcraft","textures/misc/golem/tag_ranged.png"));
|
||||||
|
|
||||||
|
static {
|
||||||
|
CLUMSY.opposite = DEFT;
|
||||||
|
DEFT.opposite = CLUMSY;
|
||||||
|
|
||||||
|
HEAVY.opposite = LIGHT;
|
||||||
|
LIGHT.opposite = HEAVY;
|
||||||
|
|
||||||
|
FRAGILE.opposite = ARMORED;
|
||||||
|
ARMORED.opposite = FRAGILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation icon;
|
||||||
|
public EnumGolemTrait opposite;
|
||||||
|
|
||||||
|
private EnumGolemTrait(ResourceLocation icon) {
|
||||||
|
this.icon = icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.trait."+this.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.trait.text."+this.name().toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
107
src/api/java/thaumcraft/api/golems/GolemHelper.java
Normal file
107
src/api/java/thaumcraft/api/golems/GolemHelper.java
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
package thaumcraft.api.golems;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import thaumcraft.api.ThaumcraftApi;
|
||||||
|
import thaumcraft.api.golems.seals.ISeal;
|
||||||
|
import thaumcraft.api.golems.seals.ISealEntity;
|
||||||
|
import thaumcraft.api.golems.seals.SealPos;
|
||||||
|
import thaumcraft.api.golems.tasks.Task;
|
||||||
|
|
||||||
|
public class GolemHelper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make sure to register your seals during the preInit phase.
|
||||||
|
* @param seal
|
||||||
|
*/
|
||||||
|
public static void registerSeal(ISeal seal) {
|
||||||
|
ThaumcraftApi.internalMethods.registerSeal(seal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ISeal getSeal(String key) {
|
||||||
|
return ThaumcraftApi.internalMethods.getSeal(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getSealStack(String key) {
|
||||||
|
return ThaumcraftApi.internalMethods.getSealStack(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ISealEntity getSealEntity(int dim, SealPos pos) {
|
||||||
|
return ThaumcraftApi.internalMethods.getSealEntity(dim, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addGolemTask(int dim, Task task) {
|
||||||
|
ThaumcraftApi.internalMethods.addGolemTask(dim, task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HashMap<Integer,ArrayList<ProvisionRequest>> provisionRequests = new HashMap<Integer,ArrayList<ProvisionRequest>>();
|
||||||
|
|
||||||
|
public static void requestProvisioning(World world, ISealEntity seal, ItemStack stack) {
|
||||||
|
if (!provisionRequests.containsKey(world.provider.getDimensionId()))
|
||||||
|
provisionRequests.put(world.provider.getDimensionId(), new ArrayList<ProvisionRequest>());
|
||||||
|
ArrayList<ProvisionRequest> list = provisionRequests.get(world.provider.getDimensionId());
|
||||||
|
ProvisionRequest pr = new ProvisionRequest(seal,stack);
|
||||||
|
if (!list.contains(pr))
|
||||||
|
list.add(pr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to get a single blockpos from within a designated seal area.
|
||||||
|
* This method is best used if you want to increment through the blocks in the area.
|
||||||
|
* @param seal
|
||||||
|
* @param count a value used to derive a specific pos
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BlockPos getPosInArea(ISealEntity seal, int count) {
|
||||||
|
int xx = 1 + (seal.getArea().getX()-1) * (seal.getSealPos().face.getFrontOffsetX()==0?2:1);
|
||||||
|
int yy = 1 + (seal.getArea().getY()-1) * (seal.getSealPos().face.getFrontOffsetY()==0?2:1);
|
||||||
|
int zz = 1 + (seal.getArea().getZ()-1) * (seal.getSealPos().face.getFrontOffsetZ()==0?2:1);
|
||||||
|
|
||||||
|
int qx = seal.getSealPos().face.getFrontOffsetX()!=0?seal.getSealPos().face.getFrontOffsetX():1;
|
||||||
|
int qy = seal.getSealPos().face.getFrontOffsetY()!=0?seal.getSealPos().face.getFrontOffsetY():1;
|
||||||
|
int qz = seal.getSealPos().face.getFrontOffsetZ()!=0?seal.getSealPos().face.getFrontOffsetZ():1;
|
||||||
|
|
||||||
|
int y = qy*((count/zz)/xx)%yy + seal.getSealPos().face.getFrontOffsetY();
|
||||||
|
int x = qx*(count/zz)%xx + seal.getSealPos().face.getFrontOffsetX();
|
||||||
|
int z = qz*count%zz + seal.getSealPos().face.getFrontOffsetZ();
|
||||||
|
|
||||||
|
BlockPos p = seal.getSealPos().pos.add(
|
||||||
|
x - (seal.getSealPos().face.getFrontOffsetX()==0?xx/2:0),
|
||||||
|
y - (seal.getSealPos().face.getFrontOffsetY()==0?yy/2:0),
|
||||||
|
z - (seal.getSealPos().face.getFrontOffsetZ()==0?zz/2:0));
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the designated seal area as a AxisAlignedBB
|
||||||
|
* @param seal
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static AxisAlignedBB getBoundsForArea(ISealEntity seal) {
|
||||||
|
return AxisAlignedBB.fromBounds(
|
||||||
|
seal.getSealPos().pos.getX(), seal.getSealPos().pos.getY(), seal.getSealPos().pos.getZ(),
|
||||||
|
seal.getSealPos().pos.getX()+1, seal.getSealPos().pos.getY()+1, seal.getSealPos().pos.getZ()+1)
|
||||||
|
.offset(
|
||||||
|
seal.getSealPos().face.getFrontOffsetX(),
|
||||||
|
seal.getSealPos().face.getFrontOffsetY(),
|
||||||
|
seal.getSealPos().face.getFrontOffsetZ())
|
||||||
|
.addCoord(
|
||||||
|
seal.getSealPos().face.getFrontOffsetX()!=0?(seal.getArea().getX()-1) * seal.getSealPos().face.getFrontOffsetX():0,
|
||||||
|
seal.getSealPos().face.getFrontOffsetY()!=0?(seal.getArea().getY()-1) * seal.getSealPos().face.getFrontOffsetY():0,
|
||||||
|
seal.getSealPos().face.getFrontOffsetZ()!=0?(seal.getArea().getZ()-1) * seal.getSealPos().face.getFrontOffsetZ():0)
|
||||||
|
.expand(
|
||||||
|
seal.getSealPos().face.getFrontOffsetX()==0?seal.getArea().getX()-1:0,
|
||||||
|
seal.getSealPos().face.getFrontOffsetY()==0?seal.getArea().getY()-1:0,
|
||||||
|
seal.getSealPos().face.getFrontOffsetZ()==0?seal.getArea().getZ()-1:0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
63
src/api/java/thaumcraft/api/golems/IGolemAPI.java
Normal file
63
src/api/java/thaumcraft/api/golems/IGolemAPI.java
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package thaumcraft.api.golems;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains functions to allow addon devs to access golem internals
|
||||||
|
*/
|
||||||
|
public interface IGolemAPI {
|
||||||
|
|
||||||
|
public EntityLivingBase getGolemEntity();
|
||||||
|
|
||||||
|
public IGolemProperties getProperties();
|
||||||
|
|
||||||
|
public void setProperties(IGolemProperties prop);
|
||||||
|
|
||||||
|
public World getGolemWorld();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes the golem to hold the itemstack supplied.
|
||||||
|
* @param stack
|
||||||
|
* @return anything left over that the golem could not hold. If the golem picked up the entire stack this will be a null.
|
||||||
|
*/
|
||||||
|
public ItemStack holdItem(ItemStack stack);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Causes the golem to remove an itemstack it is holding. It does not actually drop the item in the
|
||||||
|
* world or place it anywhere - that is up to whatever is calling this method.
|
||||||
|
* @param stack the itemstack that the golem will drop. If null is supplied the golem will drop whatever it is holding
|
||||||
|
* @return the stack it 'dropped'
|
||||||
|
*/
|
||||||
|
public ItemStack dropItem(ItemStack stack);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the golem has carrying capacity for the given stack
|
||||||
|
* @param stack the stack the golem has room for - can be null
|
||||||
|
* @param partial does the golem only need to have room for part of the stack?
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canCarry(ItemStack stack, boolean partial);
|
||||||
|
|
||||||
|
public boolean isCarrying(ItemStack stack);
|
||||||
|
|
||||||
|
public ItemStack[] getCarrying();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gives the golem xp towards increasing its rank rating. Default is usually 1 for completing a task.
|
||||||
|
* @param xp
|
||||||
|
*/
|
||||||
|
public void addRankXp(int xp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays arm swinging animated for attacks and such
|
||||||
|
*/
|
||||||
|
public void swingArm();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
57
src/api/java/thaumcraft/api/golems/IGolemProperties.java
Normal file
57
src/api/java/thaumcraft/api/golems/IGolemProperties.java
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package thaumcraft.api.golems;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import thaumcraft.api.golems.parts.GolemAddon;
|
||||||
|
import thaumcraft.api.golems.parts.GolemArm;
|
||||||
|
import thaumcraft.api.golems.parts.GolemHead;
|
||||||
|
import thaumcraft.api.golems.parts.GolemLeg;
|
||||||
|
import thaumcraft.api.golems.parts.GolemMaterial;
|
||||||
|
|
||||||
|
public interface IGolemProperties {
|
||||||
|
|
||||||
|
public abstract Set<EnumGolemTrait> getTraits();
|
||||||
|
|
||||||
|
public abstract boolean hasTrait(EnumGolemTrait tag);
|
||||||
|
|
||||||
|
public abstract long toLong();
|
||||||
|
|
||||||
|
public abstract ItemStack[] generateComponents();
|
||||||
|
|
||||||
|
|
||||||
|
//material
|
||||||
|
public abstract void setMaterial(GolemMaterial mat);
|
||||||
|
|
||||||
|
public abstract GolemMaterial getMaterial();
|
||||||
|
|
||||||
|
//head
|
||||||
|
public abstract void setHead(GolemHead mat);
|
||||||
|
|
||||||
|
public abstract GolemHead getHead();
|
||||||
|
|
||||||
|
//arms
|
||||||
|
public abstract void setArms(GolemArm mat);
|
||||||
|
|
||||||
|
public abstract GolemArm getArms();
|
||||||
|
|
||||||
|
//legs
|
||||||
|
public abstract void setLegs(GolemLeg mat);
|
||||||
|
|
||||||
|
public abstract GolemLeg getLegs();
|
||||||
|
|
||||||
|
//addon
|
||||||
|
public abstract void setAddon(GolemAddon mat);
|
||||||
|
|
||||||
|
public abstract GolemAddon getAddon();
|
||||||
|
|
||||||
|
//rank
|
||||||
|
public abstract void setRank(int r);
|
||||||
|
|
||||||
|
public abstract int getRank();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
41
src/api/java/thaumcraft/api/golems/ProvisionRequest.java
Normal file
41
src/api/java/thaumcraft/api/golems/ProvisionRequest.java
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
package thaumcraft.api.golems;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import thaumcraft.api.golems.seals.ISealEntity;
|
||||||
|
|
||||||
|
public class ProvisionRequest {
|
||||||
|
private ISealEntity seal;
|
||||||
|
private ItemStack stack;
|
||||||
|
|
||||||
|
ProvisionRequest(ISealEntity seal, ItemStack stack) {
|
||||||
|
this.seal = seal;
|
||||||
|
this.stack = stack.copy();
|
||||||
|
this.stack.stackSize=this.stack.getMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISealEntity getSeal() {
|
||||||
|
return seal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getStack() {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object p_equals_1_)
|
||||||
|
{
|
||||||
|
if (this == p_equals_1_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!(p_equals_1_ instanceof ProvisionRequest))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ProvisionRequest pr = (ProvisionRequest)p_equals_1_;
|
||||||
|
return !this.seal.getSealPos().equals(pr.getSeal().getSealPos()) ? false : this.stack.getIsItemStackEqual(pr.getStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
68
src/api/java/thaumcraft/api/golems/parts/GolemAddon.java
Normal file
68
src/api/java/thaumcraft/api/golems/parts/GolemAddon.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
|
||||||
|
public class GolemAddon {
|
||||||
|
|
||||||
|
protected static GolemAddon[] addons = new GolemAddon[1];
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public String key;
|
||||||
|
public String[] research;
|
||||||
|
/**
|
||||||
|
* The icon used in the golem builder
|
||||||
|
*/
|
||||||
|
public ResourceLocation icon;
|
||||||
|
public Object[] components;
|
||||||
|
public EnumGolemTrait[] traits;
|
||||||
|
public IAddonFunction function;
|
||||||
|
public PartModel model;
|
||||||
|
|
||||||
|
public GolemAddon(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, EnumGolemTrait[] tags) {
|
||||||
|
this.key = key;
|
||||||
|
this.research=research;
|
||||||
|
this.icon=icon;
|
||||||
|
this.components = comp;
|
||||||
|
this.traits = tags;
|
||||||
|
this.model = model;
|
||||||
|
this.function = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GolemAddon(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, IAddonFunction function, EnumGolemTrait[] tags) {
|
||||||
|
this(key,research,icon,model,comp,tags);
|
||||||
|
this.function=function;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte lastID = 0;
|
||||||
|
public static void register(GolemAddon thing) {
|
||||||
|
thing.id = lastID;
|
||||||
|
lastID++;
|
||||||
|
// allocate space
|
||||||
|
if (thing.id>=addons.length) {
|
||||||
|
GolemAddon[] temp = new GolemAddon[thing.id+1];
|
||||||
|
System.arraycopy(addons, 0, temp, 0, addons.length);
|
||||||
|
addons = temp;
|
||||||
|
}
|
||||||
|
addons[thing.id] = thing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.addon."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.addon.text."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GolemAddon[] getAddons() {
|
||||||
|
return addons;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This optional interface allows you to create a class that will add functionality for a specific part.
|
||||||
|
*/
|
||||||
|
public interface IAddonFunction extends IGenericFunction {
|
||||||
|
}
|
||||||
|
}
|
79
src/api/java/thaumcraft/api/golems/parts/GolemArm.java
Normal file
79
src/api/java/thaumcraft/api/golems/parts/GolemArm.java
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.IRangedAttackMob;
|
||||||
|
import net.minecraft.entity.ai.EntityAIArrowAttack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
import thaumcraft.api.golems.IGolemAPI;
|
||||||
|
|
||||||
|
public class GolemArm {
|
||||||
|
|
||||||
|
protected static GolemArm[] arms = new GolemArm[1];
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public String key;
|
||||||
|
public String[] research;
|
||||||
|
/**
|
||||||
|
* The icon used in the golem builder
|
||||||
|
*/
|
||||||
|
public ResourceLocation icon;
|
||||||
|
public Object[] components;
|
||||||
|
public EnumGolemTrait[] traits;
|
||||||
|
public IArmFunction function;
|
||||||
|
public PartModel model;
|
||||||
|
|
||||||
|
public GolemArm(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, EnumGolemTrait[] tags) {
|
||||||
|
this.key = key;
|
||||||
|
this.research=research;
|
||||||
|
this.icon=icon;
|
||||||
|
this.components = comp;
|
||||||
|
this.traits = tags;
|
||||||
|
this.model = model;
|
||||||
|
this.function = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GolemArm(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, IArmFunction function, EnumGolemTrait[] tags) {
|
||||||
|
this(key,research,icon,model,comp,tags);
|
||||||
|
this.function = function;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte lastID = 0;
|
||||||
|
public static void register(GolemArm thing) {
|
||||||
|
thing.id = lastID;
|
||||||
|
lastID++;
|
||||||
|
// allocate space
|
||||||
|
if (thing.id>=arms.length) {
|
||||||
|
GolemArm[] temp = new GolemArm[thing.id+1];
|
||||||
|
System.arraycopy(arms, 0, temp, 0, arms.length);
|
||||||
|
arms = temp;
|
||||||
|
}
|
||||||
|
arms[thing.id] = thing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.arm."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.arm.text."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GolemArm[] getArms() {
|
||||||
|
return arms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This optional interface allows you to create a class that will be called whenever
|
||||||
|
* the golem makes a ranged (using IRangedAttackMob) or melee attack.
|
||||||
|
* This will allow you to create your own projectiles
|
||||||
|
*/
|
||||||
|
public interface IArmFunction extends IGenericFunction {
|
||||||
|
public void onMeleeAttack(IGolemAPI golem, Entity ent);
|
||||||
|
public void onRangedAttack(IGolemAPI golem, EntityLivingBase target, float range);
|
||||||
|
public EntityAIArrowAttack getRangedAttackAI(IRangedAttackMob golem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
src/api/java/thaumcraft/api/golems/parts/GolemHead.java
Normal file
70
src/api/java/thaumcraft/api/golems/parts/GolemHead.java
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
|
||||||
|
public class GolemHead {
|
||||||
|
|
||||||
|
protected static GolemHead[] heads = new GolemHead[1];
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public String key;
|
||||||
|
public String[] research;
|
||||||
|
/**
|
||||||
|
* The icon used in the golem builder
|
||||||
|
*/
|
||||||
|
public ResourceLocation icon;
|
||||||
|
public Object[] components;
|
||||||
|
public EnumGolemTrait[] traits;
|
||||||
|
public IHeadFunction function;
|
||||||
|
public PartModel model;
|
||||||
|
|
||||||
|
public GolemHead(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, EnumGolemTrait[] tags) {
|
||||||
|
this.key = key;
|
||||||
|
this.research=research;
|
||||||
|
this.icon=icon;
|
||||||
|
this.components = comp;
|
||||||
|
this.traits = tags;
|
||||||
|
this.model = model;
|
||||||
|
this.function = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GolemHead(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, IHeadFunction function, EnumGolemTrait[] tags) {
|
||||||
|
this(key,research,icon,model,comp,tags);
|
||||||
|
this.function=function;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte lastID = 0;
|
||||||
|
public static void register(GolemHead thing) {
|
||||||
|
thing.id = lastID;
|
||||||
|
lastID++;
|
||||||
|
// allocate space
|
||||||
|
if (thing.id>=heads.length) {
|
||||||
|
GolemHead[] temp = new GolemHead[thing.id+1];
|
||||||
|
System.arraycopy(heads, 0, temp, 0, heads.length);
|
||||||
|
heads = temp;
|
||||||
|
}
|
||||||
|
heads[thing.id] = thing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.head."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.head.text."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GolemHead[] getHeads() {
|
||||||
|
return heads;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This optional interface allows you to create a class that will add functionality for a specific part.
|
||||||
|
*/
|
||||||
|
public interface IHeadFunction extends IGenericFunction {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
src/api/java/thaumcraft/api/golems/parts/GolemLeg.java
Normal file
68
src/api/java/thaumcraft/api/golems/parts/GolemLeg.java
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
|
||||||
|
public class GolemLeg {
|
||||||
|
|
||||||
|
protected static GolemLeg[] legs = new GolemLeg[1];
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public String key;
|
||||||
|
public String[] research;
|
||||||
|
/**
|
||||||
|
* The icon used in the golem builder
|
||||||
|
*/
|
||||||
|
public ResourceLocation icon;
|
||||||
|
public Object[] components;
|
||||||
|
public EnumGolemTrait[] traits;
|
||||||
|
public ILegFunction function;
|
||||||
|
public PartModel model;
|
||||||
|
|
||||||
|
public GolemLeg(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, EnumGolemTrait[] tags) {
|
||||||
|
this.key = key;
|
||||||
|
this.research=research;
|
||||||
|
this.icon=icon;
|
||||||
|
this.components = comp;
|
||||||
|
this.traits = tags;
|
||||||
|
this.model = model;
|
||||||
|
this.function = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GolemLeg(String key,String[] research,ResourceLocation icon, PartModel model, Object[] comp, ILegFunction function, EnumGolemTrait[] tags) {
|
||||||
|
this(key,research,icon,model,comp,tags);
|
||||||
|
this.function=function;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte lastID = 0;
|
||||||
|
public static void register(GolemLeg thing) {
|
||||||
|
thing.id = lastID;
|
||||||
|
lastID++;
|
||||||
|
// allocate space
|
||||||
|
if (thing.id>=legs.length) {
|
||||||
|
GolemLeg[] temp = new GolemLeg[thing.id+1];
|
||||||
|
System.arraycopy(legs, 0, temp, 0, legs.length);
|
||||||
|
legs = temp;
|
||||||
|
}
|
||||||
|
legs[thing.id] = thing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.leg."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.leg.text."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GolemLeg[] getLegs() {
|
||||||
|
return legs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This optional interface allows you to create a class that will add functionality for a specific part.
|
||||||
|
*/
|
||||||
|
public interface ILegFunction extends IGenericFunction {
|
||||||
|
}
|
||||||
|
}
|
71
src/api/java/thaumcraft/api/golems/parts/GolemMaterial.java
Normal file
71
src/api/java/thaumcraft/api/golems/parts/GolemMaterial.java
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
|
||||||
|
public class GolemMaterial {
|
||||||
|
|
||||||
|
protected static GolemMaterial[] materials = new GolemMaterial[1];
|
||||||
|
|
||||||
|
public byte id;
|
||||||
|
public String key;
|
||||||
|
public String[] research;
|
||||||
|
/**
|
||||||
|
* The actual base model texture file that will be used for this material.
|
||||||
|
*/
|
||||||
|
public ResourceLocation texture;
|
||||||
|
/**
|
||||||
|
* The color applied to the item model used by the golem placer and builder.
|
||||||
|
*/
|
||||||
|
public int itemColor;
|
||||||
|
public int healthMod;
|
||||||
|
public int armor;
|
||||||
|
public int damage;
|
||||||
|
public ItemStack componentBase;
|
||||||
|
public ItemStack componentMechanism;
|
||||||
|
public EnumGolemTrait[] traits;
|
||||||
|
|
||||||
|
public GolemMaterial(String key,String[] research,ResourceLocation texture, int itemColor,
|
||||||
|
int hp, int armor, int damage, ItemStack compb, ItemStack compm, EnumGolemTrait[] tags) {
|
||||||
|
|
||||||
|
this.key = key;
|
||||||
|
this.research=research;
|
||||||
|
this.texture=texture;
|
||||||
|
this.itemColor=itemColor;
|
||||||
|
this.componentBase = compb;
|
||||||
|
this.componentMechanism = compm;
|
||||||
|
this.healthMod = hp;
|
||||||
|
this.armor = armor;
|
||||||
|
this.traits = tags;
|
||||||
|
this.damage = damage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte lastID = 0;
|
||||||
|
public static void register(GolemMaterial thing) {
|
||||||
|
thing.id = lastID;
|
||||||
|
lastID++;
|
||||||
|
// allocate space
|
||||||
|
if (thing.id>=materials.length) {
|
||||||
|
GolemMaterial[] temp = new GolemMaterial[thing.id+1];
|
||||||
|
System.arraycopy(materials, 0, temp, 0, materials.length);
|
||||||
|
materials = temp;
|
||||||
|
}
|
||||||
|
materials[thing.id] = thing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedName() {
|
||||||
|
return StatCollector.translateToLocal("golem.material."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLocalizedDescription() {
|
||||||
|
return StatCollector.translateToLocal("golem.material.text."+this.key.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GolemMaterial[] getMaterials() {
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import thaumcraft.api.golems.IGolemAPI;
|
||||||
|
|
||||||
|
public interface IGenericFunction {
|
||||||
|
public void onUpdateTick(IGolemAPI golem);
|
||||||
|
}
|
73
src/api/java/thaumcraft/api/golems/parts/PartModel.java
Normal file
73
src/api/java/thaumcraft/api/golems/parts/PartModel.java
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
package thaumcraft.api.golems.parts;
|
||||||
|
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import thaumcraft.api.golems.IGolemAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This class is used to define a model used by a part. The model needs to be in the .obj format and you may have to provide a texture.
|
||||||
|
* You can specify which model parts use your texture and which should use the material texture.
|
||||||
|
*
|
||||||
|
* You can also specify an attachment point for the entire model.
|
||||||
|
* HANDS will render the model twice - one at the end of each arm.
|
||||||
|
* LEGS will render the model twice (once for each leg) and will apply the normal walking animation tranforms to them
|
||||||
|
* BODY and HEAD should be fairly obvious
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PartModel {
|
||||||
|
|
||||||
|
private ResourceLocation objModel;
|
||||||
|
private ResourceLocation texture;
|
||||||
|
private EnumAttachPoint attachPoint;
|
||||||
|
|
||||||
|
public enum EnumAttachPoint { ARMS, LEGS, BODY, HEAD; }
|
||||||
|
|
||||||
|
public PartModel(ResourceLocation objModel, ResourceLocation objTexture, EnumAttachPoint attachPoint) {
|
||||||
|
this.objModel = objModel;
|
||||||
|
this.texture = objTexture;
|
||||||
|
this.attachPoint = attachPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation getObjModel() {
|
||||||
|
return objModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResourceLocation getTexture() {
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnumAttachPoint getAttachPoint() {
|
||||||
|
return attachPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if you want this named part of your model to use the golem material texture instead you the part texture. You
|
||||||
|
* will obviously need to make sure your model fits the material texture template.
|
||||||
|
* By default it simply checks if the object name starts with "bm", but obviously you can do your own thing if you override this.
|
||||||
|
* @param partName the obj model part name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean useMaterialTextureForObjectPart(String partName) {
|
||||||
|
return partName.startsWith("bm");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called just before a specific part is rendered allowing you to apply custom transforms to it if you wish.
|
||||||
|
* @param partName the obj model part name
|
||||||
|
*/
|
||||||
|
public void preRenderObjectPart(String partName, IGolemAPI golem, float partialTicks, EnumLimbSide side) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will be called just after a specific part is rendered. Used for cleanup mostly.
|
||||||
|
* @param partName the obj model part name
|
||||||
|
*/
|
||||||
|
public void postRenderObjectPart(String partName, IGolemAPI golem, float partialTicks, EnumLimbSide side) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EnumLimbSide {
|
||||||
|
LEFT,RIGHT,MIDDLE;
|
||||||
|
}
|
||||||
|
}
|
60
src/api/java/thaumcraft/api/golems/seals/ISeal.java
Normal file
60
src/api/java/thaumcraft/api/golems/seals/ISeal.java
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import thaumcraft.api.golems.EnumGolemTrait;
|
||||||
|
import thaumcraft.api.golems.IGolemAPI;
|
||||||
|
import thaumcraft.api.golems.tasks.Task;
|
||||||
|
|
||||||
|
public interface ISeal {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
* A unique string identifier for this seal. A good idea would be to append your modid before the identifier.
|
||||||
|
* For example: "thaumcraft:fetch"
|
||||||
|
* This will also be used to create the item model for the seal placer so you will have to define a json using
|
||||||
|
* the key with "seal_" added to the front of the key.
|
||||||
|
* For example: models/item/seal_fetch.json
|
||||||
|
*/
|
||||||
|
public String getKey();
|
||||||
|
|
||||||
|
public boolean canPlaceAt(World world, BlockPos pos, EnumFacing side);
|
||||||
|
|
||||||
|
public void tickSeal(World world, ISealEntity seal);
|
||||||
|
|
||||||
|
public void onTaskStarted(World world, IGolemAPI golem, Task task);
|
||||||
|
|
||||||
|
public boolean onTaskCompletion(World world, IGolemAPI golem, Task task);
|
||||||
|
|
||||||
|
public void onTaskSuspension(World world, Task task);
|
||||||
|
|
||||||
|
public boolean canGolemPerformTask(IGolemAPI golem, Task task);
|
||||||
|
|
||||||
|
public void readCustomNBT(NBTTagCompound nbt);
|
||||||
|
|
||||||
|
public void writeCustomNBT(NBTTagCompound nbt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return icon used to render the seal in world. Usually the same as your seal placer item icon.
|
||||||
|
* If it is not the same you will have to manually stitch it into the texture atlas.
|
||||||
|
*/
|
||||||
|
public ResourceLocation getSealIcon();
|
||||||
|
|
||||||
|
public void onRemoval(World world, BlockPos pos, EnumFacing side);
|
||||||
|
|
||||||
|
public Object returnContainer(World world, EntityPlayer player, BlockPos pos, EnumFacing side, ISealEntity seal);
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public Object returnGui(World world, EntityPlayer player, BlockPos pos, EnumFacing side, ISealEntity seal);
|
||||||
|
|
||||||
|
public EnumGolemTrait[] getRequiredTags();
|
||||||
|
|
||||||
|
public EnumGolemTrait[] getForbiddenTags();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class identifies this seal as using the default area configuration options.
|
||||||
|
*/
|
||||||
|
public interface ISealConfigArea {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public interface ISealConfigFilter {
|
||||||
|
|
||||||
|
public ItemStack[] getInv();
|
||||||
|
|
||||||
|
public int getFilterSize();
|
||||||
|
|
||||||
|
public ItemStack getFilterSlot(int i);
|
||||||
|
|
||||||
|
public void setFilterSlot(int i, ItemStack stack);
|
||||||
|
|
||||||
|
public boolean isBlacklist();
|
||||||
|
|
||||||
|
public void setBlacklist(boolean black);
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ISealConfigToggles {
|
||||||
|
|
||||||
|
|
||||||
|
public SealToggle[] getToggles();
|
||||||
|
public void setToggle(int indx, boolean value);
|
||||||
|
|
||||||
|
|
||||||
|
public class SealToggle {
|
||||||
|
public boolean value;
|
||||||
|
public String key;
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
public SealToggle(boolean value, String key, String name) {
|
||||||
|
this.value = value;
|
||||||
|
this.key = key;
|
||||||
|
this.name=name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(boolean value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
src/api/java/thaumcraft/api/golems/seals/ISealEntity.java
Normal file
37
src/api/java/thaumcraft/api/golems/seals/ISealEntity.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface ISealEntity {
|
||||||
|
|
||||||
|
public void tickSealEntity(World world);
|
||||||
|
|
||||||
|
public ISeal getSeal();
|
||||||
|
|
||||||
|
public SealPos getSealPos();
|
||||||
|
|
||||||
|
public byte getPriority();
|
||||||
|
|
||||||
|
public void setPriority(byte priority);
|
||||||
|
|
||||||
|
public void readNBT(NBTTagCompound nbt);
|
||||||
|
|
||||||
|
public NBTTagCompound writeNBT();
|
||||||
|
|
||||||
|
public void syncToClient(World world);
|
||||||
|
|
||||||
|
public BlockPos getArea();
|
||||||
|
|
||||||
|
public void setArea(BlockPos v);
|
||||||
|
|
||||||
|
boolean isLocked();
|
||||||
|
|
||||||
|
void setLocked(boolean locked);
|
||||||
|
|
||||||
|
String getOwner();
|
||||||
|
|
||||||
|
void setOwner(String owner);
|
||||||
|
|
||||||
|
}
|
12
src/api/java/thaumcraft/api/golems/seals/ISealGui.java
Normal file
12
src/api/java/thaumcraft/api/golems/seals/ISealGui.java
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
public interface ISealGui {
|
||||||
|
final int CAT_PRIORITY = 0;
|
||||||
|
final int CAT_FILTER = 1;
|
||||||
|
final int CAT_AREA = 2;
|
||||||
|
final int CAT_TOGGLES = 3;
|
||||||
|
final int CAT_TAGS = 4;
|
||||||
|
|
||||||
|
public int[] getGuiCategories();
|
||||||
|
|
||||||
|
}
|
43
src/api/java/thaumcraft/api/golems/seals/SealPos.java
Normal file
43
src/api/java/thaumcraft/api/golems/seals/SealPos.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package thaumcraft.api.golems.seals;
|
||||||
|
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
|
public class SealPos {
|
||||||
|
public BlockPos pos;
|
||||||
|
public EnumFacing face;
|
||||||
|
|
||||||
|
public SealPos(BlockPos pos, EnumFacing face) {
|
||||||
|
super();
|
||||||
|
this.pos = pos;
|
||||||
|
this.face = face;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
byte b0 = (byte) (face.ordinal()+1);
|
||||||
|
int i = 31 * b0 + this.pos.getX();
|
||||||
|
i = 31 * i + this.pos.getY();
|
||||||
|
i = 31 * i + this.pos.getZ();
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object p_equals_1_)
|
||||||
|
{
|
||||||
|
if (this == p_equals_1_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (!(p_equals_1_ instanceof SealPos))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SealPos sp = (SealPos)p_equals_1_;
|
||||||
|
return !this.pos.equals(sp.pos) ? false : this.face.equals(sp.face);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
212
src/api/java/thaumcraft/api/golems/tasks/Task.java
Normal file
212
src/api/java/thaumcraft/api/golems/tasks/Task.java
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
package thaumcraft.api.golems.tasks;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import thaumcraft.api.golems.GolemHelper;
|
||||||
|
import thaumcraft.api.golems.IGolemAPI;
|
||||||
|
import thaumcraft.api.golems.seals.ISealEntity;
|
||||||
|
import thaumcraft.api.golems.seals.SealPos;
|
||||||
|
|
||||||
|
public class Task {
|
||||||
|
|
||||||
|
private UUID golemUUID;
|
||||||
|
private int id;
|
||||||
|
private byte type;
|
||||||
|
private SealPos sealPos;
|
||||||
|
private BlockPos pos;
|
||||||
|
private Entity entity;
|
||||||
|
private boolean reserved;
|
||||||
|
private boolean suspended;
|
||||||
|
private boolean completed;
|
||||||
|
private int data;
|
||||||
|
/**
|
||||||
|
* Lifespan in seconds. Default 120 seconds
|
||||||
|
*/
|
||||||
|
private short lifespan;
|
||||||
|
private byte priority=0;
|
||||||
|
|
||||||
|
private Task() {}
|
||||||
|
|
||||||
|
public Task(SealPos sealPos, BlockPos pos) {
|
||||||
|
this.sealPos = sealPos;
|
||||||
|
this.pos = pos;
|
||||||
|
if (sealPos==null) {
|
||||||
|
this.id = (System.currentTimeMillis()+"/BNPOS/"+pos.toString()).hashCode();
|
||||||
|
} else
|
||||||
|
this.id = (System.currentTimeMillis()+"/B/"+sealPos.face.toString()+"/"+sealPos.pos.toString()+"/"+pos.toString()).hashCode();
|
||||||
|
this.type = 0;
|
||||||
|
this.lifespan = 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task(SealPos sealPos, Entity entity) {
|
||||||
|
this.sealPos = sealPos;
|
||||||
|
this.entity = entity;
|
||||||
|
if (sealPos==null) {
|
||||||
|
this.id = (System.currentTimeMillis()+"/ENPOS/"+pos.toString()).hashCode();
|
||||||
|
} else
|
||||||
|
this.id = (System.currentTimeMillis()+"/E/"+sealPos.face.toString()+"/"+sealPos.pos.toString()+"/"+entity.getEntityId()).hashCode();
|
||||||
|
this.type = 1;
|
||||||
|
this.lifespan = 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getPriority() {
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority(byte priority) {
|
||||||
|
this.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCompleted() {
|
||||||
|
return completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCompletion(boolean fulfilled) {
|
||||||
|
this.completed = fulfilled;
|
||||||
|
this.lifespan += 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getGolemUUID() {
|
||||||
|
return golemUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGolemUUID(UUID golemUUID) {
|
||||||
|
this.golemUUID = golemUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos getPos() {
|
||||||
|
return type==1?entity.getPosition():pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity getEntity() {
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReserved() {
|
||||||
|
return reserved;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReserved(boolean res) {
|
||||||
|
this.reserved = res;
|
||||||
|
this.lifespan += 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSuspended() {
|
||||||
|
return suspended;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuspended(boolean suspended) {
|
||||||
|
this.suspended = suspended;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SealPos getSealPos() {
|
||||||
|
return sealPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o)
|
||||||
|
{
|
||||||
|
if (!(o instanceof Task))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Task t = (Task)o;
|
||||||
|
return t.id == this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLifespan() {
|
||||||
|
return lifespan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLifespan(short ls) {
|
||||||
|
this.lifespan = ls;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canGolemPerformTask(IGolemAPI golem) {
|
||||||
|
ISealEntity se = GolemHelper.getSealEntity(golem.getGolemWorld().provider.getDimensionId(), this.sealPos);
|
||||||
|
if (se!=null) {
|
||||||
|
return se.getSeal().canGolemPerformTask(golem,this);
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getData() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(int data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// public static Task readNBT(NBTTagCompound nbt)
|
||||||
|
// {
|
||||||
|
// Task task = new Task();
|
||||||
|
// task.id = nbt.getInteger("id");
|
||||||
|
// task.type = nbt.getByte("type");
|
||||||
|
// if (nbt.hasKey("pos", 4)) task.pos = BlockPos.fromLong(nbt.getLong("pos"));
|
||||||
|
//
|
||||||
|
// if (nbt.hasKey("GUUIDMost", 4) && nbt.hasKey("GUUIDLeast", 4))
|
||||||
|
// task.golemUUID = new UUID(nbt.getLong("GUUIDMost"), nbt.getLong("GUUIDLeast"));
|
||||||
|
//
|
||||||
|
// if (nbt.hasKey("EUUIDMost", 4) && nbt.hasKey("EUUIDLeast", 4))
|
||||||
|
// task.entityUUID = new UUID(nbt.getLong("EUUIDMost"), nbt.getLong("EUUIDLeast"));
|
||||||
|
//
|
||||||
|
// if (task.pos==null && task.entityUUID==null) return null;
|
||||||
|
//
|
||||||
|
// task.reserved = nbt.getBoolean("reserved");
|
||||||
|
// task.waitOnSuspension = nbt.getBoolean("wos");
|
||||||
|
// task.suspended = false;
|
||||||
|
// task.completed = nbt.getBoolean("completed");
|
||||||
|
// task.expireTime = System.currentTimeMillis() + 300000;
|
||||||
|
// if (nbt.hasKey("sealpos", 10)) {
|
||||||
|
// NBTTagCompound sealpos = nbt.getCompoundTag("sealpos");
|
||||||
|
// SealPos sp = new SealPos(BlockPos.fromLong(nbt.getLong("pos")), EnumFacing.VALUES[nbt.getByte("face")]);
|
||||||
|
// TaskHandler.sealTaskCrossRef.put(task.id, sp);
|
||||||
|
// }
|
||||||
|
// return task;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static NBTTagCompound writeNBT(Task task)
|
||||||
|
// {
|
||||||
|
// NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
// nbt.setInteger("id", task.id);
|
||||||
|
// nbt.setByte("type", task.type);
|
||||||
|
// if (task.pos!=null) nbt.setLong("pos", task.pos.toLong());
|
||||||
|
// if (task.entity!=null) {
|
||||||
|
// nbt.setLong("EUUIDMost", task.entity.getUniqueID().getMostSignificantBits());
|
||||||
|
// nbt.setLong("EUUIDLeast", task.entity.getUniqueID().getLeastSignificantBits());
|
||||||
|
// }
|
||||||
|
// if (task.golemUUID!=null) {
|
||||||
|
// nbt.setLong("GUUIDMost", task.golemUUID.getMostSignificantBits());
|
||||||
|
// nbt.setLong("GUUIDLeast", task.golemUUID.getLeastSignificantBits());
|
||||||
|
// }
|
||||||
|
// nbt.setBoolean("reserved", task.reserved);
|
||||||
|
// nbt.setBoolean("wos", task.waitOnSuspension);
|
||||||
|
// nbt.setBoolean("completed", task.completed);
|
||||||
|
//
|
||||||
|
// SealPos sp = TaskHandler.sealTaskCrossRef.get(task.getId());
|
||||||
|
// if (sp!=null) {
|
||||||
|
// NBTTagCompound sealpos = new NBTTagCompound();
|
||||||
|
// sealpos.setLong("pos", sp.pos.toLong());
|
||||||
|
// sealpos.setByte("face", (byte) sp.face.ordinal());
|
||||||
|
// nbt.setTag("sealpos", sealpos);
|
||||||
|
// }
|
||||||
|
// return nbt;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,10 @@ import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thaumcraft.api.aspects.Aspect;
|
import thaumcraft.api.aspects.Aspect;
|
||||||
import thaumcraft.api.aspects.AspectList;
|
import thaumcraft.api.aspects.AspectList;
|
||||||
|
import thaumcraft.api.golems.seals.ISeal;
|
||||||
|
import thaumcraft.api.golems.seals.ISealEntity;
|
||||||
|
import thaumcraft.api.golems.seals.SealPos;
|
||||||
|
import thaumcraft.api.golems.tasks.Task;
|
||||||
|
|
||||||
public class DummyInternalMethodHandler implements IInternalMethodHandler {
|
public class DummyInternalMethodHandler implements IInternalMethodHandler {
|
||||||
|
|
||||||
|
@ -90,4 +94,41 @@ public class DummyInternalMethodHandler implements IInternalMethodHandler {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerSeal(ISeal seal) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ISeal getSeal(String key) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ISealEntity getSealEntity(int dim, SealPos pos) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addGolemTask(int dim, Task task) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldPreserveAura(World world, EntityPlayer player,
|
||||||
|
BlockPos pos, Aspect aspect) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getSealStack(String key) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@ import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thaumcraft.api.aspects.Aspect;
|
import thaumcraft.api.aspects.Aspect;
|
||||||
import thaumcraft.api.aspects.AspectList;
|
import thaumcraft.api.aspects.AspectList;
|
||||||
|
import thaumcraft.api.golems.seals.ISeal;
|
||||||
|
import thaumcraft.api.golems.seals.ISealEntity;
|
||||||
|
import thaumcraft.api.golems.seals.SealPos;
|
||||||
|
import thaumcraft.api.golems.tasks.Task;
|
||||||
|
|
||||||
public interface IInternalMethodHandler {
|
public interface IInternalMethodHandler {
|
||||||
|
|
||||||
|
@ -26,5 +30,11 @@ public interface IInternalMethodHandler {
|
||||||
public void pollute(World world, BlockPos pos, int amount, boolean showEffect);
|
public void pollute(World world, BlockPos pos, int amount, boolean showEffect);
|
||||||
public int getAura(World world, BlockPos pos, Aspect aspect);
|
public int getAura(World world, BlockPos pos, Aspect aspect);
|
||||||
public int getAuraBase(World world, BlockPos pos);
|
public int getAuraBase(World world, BlockPos pos);
|
||||||
|
public void registerSeal(ISeal seal);
|
||||||
|
public ISeal getSeal(String key);
|
||||||
|
public ISealEntity getSealEntity(int dim, SealPos pos);
|
||||||
|
public void addGolemTask(int dim, Task task);
|
||||||
|
public boolean shouldPreserveAura(World world, EntityPlayer player, BlockPos pos, Aspect aspect);
|
||||||
|
public ItemStack getSealStack(String key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class ItemsTC {
|
||||||
/** "clockwork","biothaumic" */
|
/** "clockwork","biothaumic" */
|
||||||
public static Item mind;
|
public static Item mind;
|
||||||
public static Item morphicResonator;
|
public static Item morphicResonator;
|
||||||
|
/** "vision", "aggression" */
|
||||||
|
public static Item modules;
|
||||||
|
|
||||||
//consumables
|
//consumables
|
||||||
public static Item alumentum;
|
public static Item alumentum;
|
||||||
|
@ -45,7 +47,7 @@ public class ItemsTC {
|
||||||
public static Item bottleTaint;
|
public static Item bottleTaint;
|
||||||
public static Item bathSalts;
|
public static Item bathSalts;
|
||||||
public static Item sanitySoap;
|
public static Item sanitySoap;
|
||||||
/** "basic","focus","magnet"*/
|
/** "basic","focus","magnet","advanced"*/
|
||||||
public static Item turretPlacer;
|
public static Item turretPlacer;
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,6 +146,7 @@ public class ItemsTC {
|
||||||
public static Item focusWarding;
|
public static Item focusWarding;
|
||||||
public static Item focusHole;
|
public static Item focusHole;
|
||||||
public static Item focusShard;
|
public static Item focusShard;
|
||||||
|
public static Item focusGrapple;
|
||||||
|
|
||||||
public static Item focusPouch;
|
public static Item focusPouch;
|
||||||
|
|
||||||
|
@ -175,11 +178,16 @@ public class ItemsTC {
|
||||||
//golems
|
//golems
|
||||||
public static Item golemBell;
|
public static Item golemBell;
|
||||||
public static Item golemPlacer;
|
public static Item golemPlacer;
|
||||||
/** "blank","pickup","fill","fill_advanced","empty","empty_advanced" */
|
/**
|
||||||
|
* damage 0 = blank seal
|
||||||
|
* use GolemHelper.getSealStack to return an itemstack of a specific seal
|
||||||
|
* **/
|
||||||
public static Item seals;
|
public static Item seals;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@API(owner = "Thaumcraft", apiVersion = "5.0.0.4", provides = "Thaumcraft|API")
|
@API(owner = "Thaumcraft", apiVersion = "5.1.0.0", provides = "Thaumcraft|API")
|
||||||
package thaumcraft.api;
|
package thaumcraft.api;
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.API;
|
import net.minecraftforge.fml.common.API;
|
||||||
|
|
|
@ -15,9 +15,9 @@ public class PotionFluxTaint extends Potion
|
||||||
public static PotionFluxTaint instance = null; // will be instantiated at runtime
|
public static PotionFluxTaint instance = null; // will be instantiated at runtime
|
||||||
private int statusIconIndex = -1;
|
private int statusIconIndex = -1;
|
||||||
|
|
||||||
public PotionFluxTaint(int par1, boolean par2, int par3)
|
public PotionFluxTaint(boolean par2, int par3)
|
||||||
{
|
{
|
||||||
super(par1,new ResourceLocation("flux_taint"),par2,par3);
|
super(new ResourceLocation("flux_taint"),par2,par3);
|
||||||
setIconIndex(0, 0);
|
setIconIndex(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ public class PotionVisExhaust extends Potion
|
||||||
public static PotionVisExhaust instance = null; // will be instantiated at runtime
|
public static PotionVisExhaust instance = null; // will be instantiated at runtime
|
||||||
private int statusIconIndex = -1;
|
private int statusIconIndex = -1;
|
||||||
|
|
||||||
public PotionVisExhaust(int par1, boolean par2, int par3)
|
public PotionVisExhaust(boolean par2, int par3)
|
||||||
{
|
{
|
||||||
super(par1,new ResourceLocation("vis_exhaust"),par2,par3);
|
super(new ResourceLocation("vis_exhaust"),par2,par3);
|
||||||
setIconIndex(0, 0);
|
setIconIndex(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package thaumcraft.api.wands;
|
package thaumcraft.api.wands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -23,9 +24,19 @@ import net.minecraft.world.World;
|
||||||
*/
|
*/
|
||||||
public class WandTriggerRegistry {
|
public class WandTriggerRegistry {
|
||||||
|
|
||||||
private static HashMap<String,HashMap<IBlockState,List>> triggers = new HashMap<String,HashMap<IBlockState,List>>();
|
private static HashMap<String,LinkedHashMap<IBlockState,List<Trigger>>> triggers = new HashMap<String,LinkedHashMap<IBlockState,List<Trigger>>>();
|
||||||
private static final String DEFAULT = "default";
|
private static final String DEFAULT = "default";
|
||||||
|
|
||||||
|
private static class Trigger {
|
||||||
|
IWandTriggerManager manager;
|
||||||
|
int event;
|
||||||
|
public Trigger(IWandTriggerManager manager, int event) {
|
||||||
|
super();
|
||||||
|
this.manager = manager;
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an action to perform when a casting wand right clicks on a specific block.
|
* 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.
|
* A manager class needs to be created that implements IWandTriggerManager.
|
||||||
|
@ -37,10 +48,13 @@ public class WandTriggerRegistry {
|
||||||
*/
|
*/
|
||||||
public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, IBlockState state, String modid) {
|
public static void registerWandBlockTrigger(IWandTriggerManager manager, int event, IBlockState state, String modid) {
|
||||||
if (!triggers.containsKey(modid)) {
|
if (!triggers.containsKey(modid)) {
|
||||||
triggers.put(modid, new HashMap<IBlockState,List>());
|
triggers.put(modid, new LinkedHashMap<IBlockState,List<Trigger>>());
|
||||||
}
|
}
|
||||||
HashMap<IBlockState,List> temp = triggers.get(modid);
|
LinkedHashMap<IBlockState,List<Trigger>> temp = triggers.get(modid);
|
||||||
temp.put(state,Arrays.asList(manager,event));
|
List<Trigger> ts = temp.get(state);
|
||||||
|
if (ts==null) ts = new ArrayList<Trigger>();
|
||||||
|
ts.add(new Trigger(manager,event));
|
||||||
|
temp.put(state,ts);
|
||||||
triggers.put(modid, temp);
|
triggers.put(modid, temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +73,7 @@ public class WandTriggerRegistry {
|
||||||
*/
|
*/
|
||||||
public static boolean hasTrigger(IBlockState state) {
|
public static boolean hasTrigger(IBlockState state) {
|
||||||
for (String modid:triggers.keySet()) {
|
for (String modid:triggers.keySet()) {
|
||||||
HashMap<IBlockState,List> temp = triggers.get(modid);
|
LinkedHashMap<IBlockState,List<Trigger>> temp = triggers.get(modid);
|
||||||
if (temp.containsKey(state)) return true;
|
if (temp.containsKey(state)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,7 +84,7 @@ public class WandTriggerRegistry {
|
||||||
*/
|
*/
|
||||||
public static boolean hasTrigger(IBlockState state, String modid) {
|
public static boolean hasTrigger(IBlockState state, String modid) {
|
||||||
if (!triggers.containsKey(modid)) return false;
|
if (!triggers.containsKey(modid)) return false;
|
||||||
HashMap<IBlockState,List> temp = triggers.get(modid);
|
LinkedHashMap<IBlockState,List<Trigger>> temp = triggers.get(modid);
|
||||||
if (temp.containsKey(state)) return true;
|
if (temp.containsKey(state)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -92,17 +106,15 @@ public class WandTriggerRegistry {
|
||||||
*/
|
*/
|
||||||
public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
|
public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
|
||||||
BlockPos pos, EnumFacing side, IBlockState state) {
|
BlockPos pos, EnumFacing side, IBlockState state) {
|
||||||
|
|
||||||
for (String modid:triggers.keySet()) {
|
for (String modid:triggers.keySet()) {
|
||||||
HashMap<IBlockState,List> temp = triggers.get(modid);
|
LinkedHashMap<IBlockState,List<Trigger>> temp = triggers.get(modid);
|
||||||
List l = temp.get(state);
|
List<Trigger> l = temp.get(state);
|
||||||
if (l==null) continue;
|
if (l==null || l.size()==0) continue;
|
||||||
|
for (Trigger trig:l) {
|
||||||
IWandTriggerManager manager = (IWandTriggerManager) l.get(0);
|
boolean result = trig.manager.performTrigger(world, wand, player, pos, side, trig.event);
|
||||||
int event = (Integer) l.get(1);
|
|
||||||
boolean result = manager.performTrigger(world, wand, player, pos, side, event);
|
|
||||||
if (result) return true;
|
if (result) return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,13 +124,14 @@ public class WandTriggerRegistry {
|
||||||
public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
|
public static boolean performTrigger(World world, ItemStack wand, EntityPlayer player,
|
||||||
BlockPos pos, EnumFacing side, IBlockState state, String modid) {
|
BlockPos pos, EnumFacing side, IBlockState state, String modid) {
|
||||||
if (!triggers.containsKey(modid)) return false;
|
if (!triggers.containsKey(modid)) return false;
|
||||||
HashMap<IBlockState,List> temp = triggers.get(modid);
|
LinkedHashMap<IBlockState,List<Trigger>> temp = triggers.get(modid);
|
||||||
List l = temp.get(state);
|
List<Trigger> l = temp.get(state);
|
||||||
if (l==null) return false;
|
if (l==null || l.size()==0) return false;
|
||||||
|
for (Trigger trig:l) {
|
||||||
IWandTriggerManager manager = (IWandTriggerManager) l.get(0);
|
boolean result = trig.manager.performTrigger(world, wand, player, pos, side, trig.event);
|
||||||
int event = (Integer) l.get(1);
|
if (result) return true;
|
||||||
return manager.performTrigger(world, wand, player, pos, side, event);
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue