mirror of
https://github.com/GTNewHorizons/ForbiddenMagic.git
synced 2026-11-11 15:57:37 +00:00
API stuff
This commit is contained in:
1 parent
897caadcf0
commit
be2c7ea668
32 files changed
+1015
-138
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
public class Int3
|
||||
{
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public Int3(int xCoord, int yCoord, int zCoord)
|
||||
{
|
||||
this.xCoord = xCoord;
|
||||
this.yCoord = yCoord;
|
||||
this.zCoord = zCoord;
|
||||
}
|
||||
|
||||
public static Int3 readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
return new Int3(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger("xCoord", xCoord);
|
||||
tag.setInteger("yCoord", yCoord);
|
||||
tag.setInteger("zCoord", zCoord);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
return o instanceof Int3 ? ((Int3) o).xCoord == this.xCoord && ((Int3) o).yCoord == this.yCoord && ((Int3) o).zCoord == this.zCoord : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return this.xCoord + this.yCoord << 8 + this.zCoord << 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RoutingFocusLogic
|
||||
{
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) : false);
|
||||
}
|
||||
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return previous || this.getDefaultMatch(keyStack, checkedStack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RoutingFocusLogicIgnMeta extends RoutingFocusLogic
|
||||
{
|
||||
@Override
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() : false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RoutingFocusLogicMatchNBT extends RoutingFocusLogic
|
||||
{
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return (keyStack != null ? checkedStack != null && keyStack.getItem() == checkedStack.getItem() && (keyStack.getItem().getHasSubtypes() ? keyStack.getItemDamage() == checkedStack.getItemDamage() : true) && keyStack.areItemStackTagsEqual(keyStack, checkedStack) : false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesItemMatch(boolean previous, ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
return previous && this.getDefaultMatch(keyStack, checkedStack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
|
||||
|
||||
public class RoutingFocusLogicModItems extends RoutingFocusLogic
|
||||
{
|
||||
@Override
|
||||
public boolean getDefaultMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
if(keyStack != null && checkedStack != null)
|
||||
{
|
||||
UniqueIdentifier keyId = GameRegistry.findUniqueIdentifierFor(keyStack.getItem());
|
||||
UniqueIdentifier checkedId = GameRegistry.findUniqueIdentifierFor(checkedStack.getItem());
|
||||
return keyId.modId.equals(checkedId.modId);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class RoutingFocusParadigm
|
||||
{
|
||||
public List<RoutingFocusLogic> logicList = new LinkedList();
|
||||
|
||||
public List<RoutingFocusPosAndFacing> locationList = new LinkedList();
|
||||
|
||||
public int maximumAmount = 0;
|
||||
|
||||
public void addRoutingFocusPosAndFacing(RoutingFocusPosAndFacing facing)
|
||||
{
|
||||
locationList.add(facing);
|
||||
}
|
||||
|
||||
public void addLogic(RoutingFocusLogic logic)
|
||||
{
|
||||
logicList.add(logic);
|
||||
}
|
||||
|
||||
public boolean doesItemMatch(ItemStack keyStack, ItemStack checkedStack)
|
||||
{
|
||||
boolean isGood = false;
|
||||
boolean isFirst = true;
|
||||
for(RoutingFocusLogic logic : logicList)
|
||||
{
|
||||
if(isFirst)
|
||||
{
|
||||
isGood = logic.getDefaultMatch(keyStack, checkedStack);
|
||||
isFirst = false;
|
||||
continue;
|
||||
}
|
||||
isGood = logic.doesItemMatch(isGood, keyStack, checkedStack);
|
||||
}
|
||||
|
||||
return isGood;
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
logicList.clear();
|
||||
locationList.clear();
|
||||
maximumAmount = 0;
|
||||
}
|
||||
|
||||
public void setMaximumAmount(int amt)
|
||||
{
|
||||
this.maximumAmount = amt;
|
||||
}
|
||||
|
||||
public int getMaximumAmount()
|
||||
{
|
||||
return this.maximumAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class RoutingFocusPosAndFacing
|
||||
{
|
||||
public Int3 location;
|
||||
public ForgeDirection facing;
|
||||
|
||||
public RoutingFocusPosAndFacing(Int3 location, ForgeDirection facing)
|
||||
{
|
||||
this.location = location;
|
||||
this.facing = facing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj instanceof RoutingFocusPosAndFacing ? facing.equals(((RoutingFocusPosAndFacing)obj).facing) && location.equals(((RoutingFocusPosAndFacing)obj).location) : false;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class ReagentRegistry
|
||||
|
||||
sanctusReagent.setColour(255, 255, 0, 255);
|
||||
incendiumReagent.setColour(255, 0, 0, 255);
|
||||
aquasalusReagent.setColour(47, 0, 196, 255);
|
||||
aquasalusReagent.setColour(0, 0, 255, 255);
|
||||
magicalesReagent.setColour(150, 0, 146, 255);
|
||||
aetherReagent.setColour(105, 223, 86, 255);
|
||||
crepitousReagent.setColour(145, 145, 145, 255);
|
||||
|
||||
+9
-2
@@ -1,13 +1,16 @@
|
||||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AltarRecipeRegistry
|
||||
{
|
||||
public static List<AltarRecipe> altarRecipes = new LinkedList();
|
||||
public static Map<Integer, ItemStack> orbMap = new HashMap();
|
||||
|
||||
public static void registerAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
@@ -21,6 +24,10 @@ public class AltarRecipeRegistry
|
||||
|
||||
public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
|
||||
{
|
||||
if(!orbMap.containsKey(minTier))
|
||||
{
|
||||
orbMap.put(minTier, orbStack);
|
||||
}
|
||||
registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
public interface IFadedRune
|
||||
{
|
||||
public int getAltarTierLimit(int meta);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package WayofTime.alchemicalWizardry.api.compress;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class CompressionHandler
|
||||
{
|
||||
/**
|
||||
* Called to look at the inventory and syphons the required stack. Returns resultant stack if successful, and null if not.
|
||||
* @param inv The inventory iterated through
|
||||
* @return The result of the compression
|
||||
*/
|
||||
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package WayofTime.alchemicalWizardry.api.compress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A registry aimed to help compress items in an inventory into its compressible form.
|
||||
*
|
||||
*/
|
||||
public class CompressionRegistry
|
||||
{
|
||||
public static List<CompressionHandler> compressionRegistry = new ArrayList();
|
||||
public static Map<ItemStack, Integer> thresholdMap = new HashMap();
|
||||
|
||||
public static void registerHandler(CompressionHandler handler)
|
||||
{
|
||||
compressionRegistry.add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an item so that it only compresses while above this threshold
|
||||
* @param stack
|
||||
* @param threshold
|
||||
*/
|
||||
public static void registerItemThreshold(ItemStack stack, int threshold)
|
||||
{
|
||||
thresholdMap.put(stack, new Integer(threshold));
|
||||
}
|
||||
|
||||
public static ItemStack compressInventory(ItemStack[] inv, World world)
|
||||
{
|
||||
for(CompressionHandler handler : compressionRegistry)
|
||||
{
|
||||
ItemStack stack = handler.compressInventory(inv, world);
|
||||
if(stack != null)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getItemThreshold(ItemStack stack)
|
||||
{
|
||||
for(Entry<ItemStack, Integer> entry : thresholdMap.entrySet())
|
||||
{
|
||||
if(areItemStacksEqual(entry.getKey(), stack))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
|
||||
{
|
||||
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class ItemBindEvent extends Event
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class ItemDrainInContainerEvent extends SoulNetworkEvent
|
||||
{
|
||||
public ItemStack stack;
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerNetwork, int drainAmount)
|
||||
{
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
/** Fired when a teleposer attempts to transpose two blocks. Use this to perform special cleanup or compensation,
|
||||
or cancel it entirely to prevent the transposition. */
|
||||
@Cancelable
|
||||
public class TeleposeEvent extends Event {
|
||||
|
||||
public final World initialWorld;
|
||||
public final int initialX;
|
||||
public final int initialY;
|
||||
public final int initialZ;
|
||||
|
||||
public final Block initialBlock;
|
||||
public final int initialMetadata;
|
||||
|
||||
public final World finalWorld;
|
||||
public final int finalX;
|
||||
public final int finalY;
|
||||
public final int finalZ;
|
||||
|
||||
public final Block finalBlock;
|
||||
public final int finalMetadata;
|
||||
|
||||
public TeleposeEvent(World wi, int xi, int yi, int zi, Block bi, int mi, World wf, int xf, int yf, int zf, Block bf, int mf) {
|
||||
initialWorld = wi;
|
||||
initialX = xi;
|
||||
initialY = yi;
|
||||
initialZ = zi;
|
||||
|
||||
initialBlock = bi;
|
||||
initialMetadata = mi;
|
||||
|
||||
finalWorld = wf;
|
||||
finalX = xf;
|
||||
finalY = yf;
|
||||
finalZ = zf;
|
||||
|
||||
finalBlock = bf;
|
||||
finalMetadata = mf;
|
||||
}
|
||||
|
||||
public TileEntity getInitialTile() {
|
||||
return initialWorld.getTileEntity(initialX, initialY, initialZ);
|
||||
}
|
||||
|
||||
public TileEntity getFinalTile() {
|
||||
return finalWorld.getTileEntity(finalX, finalY, finalZ);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -392,11 +392,11 @@ public class ItemSpellMultiTool extends Item
|
||||
{
|
||||
par3List.add("A mace filled with ancient alchemy");
|
||||
|
||||
if (!(par1ItemStack.stackTagCompound == null))
|
||||
if (!(par1ItemStack.getTagCompound() == null))
|
||||
{
|
||||
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
|
||||
if (!par1ItemStack.getTagCompound().getString("ownerName").equals(""))
|
||||
{
|
||||
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
|
||||
par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName"));
|
||||
}
|
||||
|
||||
for (String str : this.getToolListString(par1ItemStack))
|
||||
@@ -479,7 +479,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
@@ -488,7 +488,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setBoolean("silkTouch", silkTouch);
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
@@ -664,7 +664,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setBoolean("silkTouch", silkTouch);
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
@@ -700,7 +700,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
|
||||
|
||||
stack.stackTagCompound.setTag(tagName, tag);
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setFloat("critChance", Math.max(chance, 0));
|
||||
|
||||
container.stackTagCompound.setTag(tagName, tag);
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
@@ -785,7 +785,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
tag.setFloat("critChance", Math.max(chance, 0));
|
||||
|
||||
container.stackTagCompound.setTag(tagName, tag);
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,17 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
output = result.copy();
|
||||
for (Object in : recipe)
|
||||
{
|
||||
if (in instanceof ItemStack)
|
||||
{
|
||||
input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof IBloodOrb)
|
||||
if (in instanceof IBloodOrb)
|
||||
{ //If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
input.add((Integer) (((IBloodOrb) in).getOrbLevel()));
|
||||
}
|
||||
else if (in instanceof ItemStack)
|
||||
{
|
||||
if (((ItemStack)in).getItem() instanceof IBloodOrb)
|
||||
{
|
||||
input.add((Integer) (((IBloodOrb) ((ItemStack)in).getItem()).getOrbLevel()));
|
||||
}
|
||||
else input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
input.add(new ItemStack((Item) in));
|
||||
@@ -137,6 +142,7 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
match = true;
|
||||
} else if (next instanceof ItemStack)
|
||||
{
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ILPGauge
|
||||
{
|
||||
public boolean canSeeLPBar(ItemStack itemStack);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IRitualDiviner {
|
||||
int cycleDirection(ItemStack stack);
|
||||
String getCurrentRitual(ItemStack stack);
|
||||
int getDirection(ItemStack stack);
|
||||
int getMaxRuneDisplacement(ItemStack stack);
|
||||
String getNameForDirection(int direction);
|
||||
void setCurrentRitual(ItemStack stack, String ritualID);
|
||||
void setDirection(ItemStack stack, int direction);
|
||||
void setMaxRuneDisplacement(ItemStack stack, int displacement);
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package WayofTime.alchemicalWizardry.api.renderer;
|
||||
|
||||
//import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
|
||||
public abstract class MRSRenderer
|
||||
{
|
||||
//public abstract void renderAt(TEMasterStone tile, double x, double y, double z);
|
||||
public abstract void renderAt(IMasterRitualStone tile, double x, double y, double z);
|
||||
|
||||
protected void bindTexture(ResourceLocation p_147499_1_)
|
||||
{
|
||||
|
||||
@@ -33,4 +33,12 @@ public interface IMasterRitualStone extends ISegmentedReagentHandler
|
||||
public NBTTagCompound getCustomRitualTag();
|
||||
|
||||
public void setCustomRitualTag(NBTTagCompound tag);
|
||||
|
||||
public boolean areTanksEmpty();
|
||||
|
||||
public int getRunningTime();
|
||||
|
||||
public LocalRitualStorage getLocalStorage();
|
||||
|
||||
public void setLocalStorage(LocalRitualStorage storage);
|
||||
}
|
||||
@@ -4,5 +4,15 @@ import net.minecraft.world.World;
|
||||
|
||||
public interface IRitualStone
|
||||
{
|
||||
public int getRuneType(World world, int x, int y, int z, int meta);
|
||||
/**
|
||||
* x, y, and z give the position of the Ritual Stone
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param meta
|
||||
* @param runeType
|
||||
* @return
|
||||
*/
|
||||
public boolean isRuneType(World world, int x, int y, int z, int meta, int runeType);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public interface ITileRitualStone
|
||||
{
|
||||
public boolean isRuneType(int runeType);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import WayofTime.alchemicalWizardry.api.Int3;
|
||||
|
||||
/**
|
||||
* This class is used to pass ritual-specific data into the RitualEffect from the containing Master Ritual Stone. This is basically used as auxillarary storage,
|
||||
* for when simply storing to NBT becomes... difficult.
|
||||
*
|
||||
*/
|
||||
public class LocalRitualStorage
|
||||
{
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger("xCoord", xCoord);
|
||||
tag.setInteger("yCoord", yCoord);
|
||||
tag.setInteger("zCoord", zCoord);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
this.xCoord = tag.getInteger("xCoord");
|
||||
this.yCoord = tag.getInteger("yCoord");
|
||||
this.zCoord = tag.getInteger("zCoord");
|
||||
}
|
||||
|
||||
public Int3 getLocation()
|
||||
{
|
||||
return new Int3(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public void setLocation(Int3 location)
|
||||
{
|
||||
this.xCoord = location.xCoord;
|
||||
this.yCoord = location.yCoord;
|
||||
this.zCoord = location.zCoord;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -53,4 +54,37 @@ public abstract class RitualEffect
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public LocalRitualStorage getNewLocalStorage()
|
||||
{
|
||||
return new LocalRitualStorage();
|
||||
}
|
||||
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> ritualList, int off1, int off2, int y, int rune)
|
||||
{
|
||||
ritualList.add(new RitualComponent(off1, y, off2, rune));
|
||||
ritualList.add(new RitualComponent(off2, y, off1, rune));
|
||||
ritualList.add(new RitualComponent(off1, y, -off2, rune));
|
||||
ritualList.add(new RitualComponent(-off2, y, off1, rune));
|
||||
ritualList.add(new RitualComponent(-off1, y, off2, rune));
|
||||
ritualList.add(new RitualComponent(off2, y, -off1, rune));
|
||||
ritualList.add(new RitualComponent(-off1, y, -off2, rune));
|
||||
ritualList.add(new RitualComponent(-off2, y, -off1, rune));
|
||||
}
|
||||
|
||||
public void addCornerRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
|
||||
{
|
||||
ritualList.add(new RitualComponent(off1, y, off1, rune));
|
||||
ritualList.add(new RitualComponent(off1, y, -off1, rune));
|
||||
ritualList.add(new RitualComponent(-off1, y, -off1, rune));
|
||||
ritualList.add(new RitualComponent(-off1, y, off1, rune));
|
||||
}
|
||||
|
||||
public void addParallelRunes(ArrayList<RitualComponent> ritualList, int off1, int y, int rune)
|
||||
{
|
||||
ritualList.add(new RitualComponent(off1, y, 0, rune));
|
||||
ritualList.add(new RitualComponent(-off1, y, 0, rune));
|
||||
ritualList.add(new RitualComponent(0, y, -off1, rune));
|
||||
ritualList.add(new RitualComponent(0, y, off1, rune));
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
|
||||
@@ -16,12 +17,12 @@ import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class Rituals
|
||||
{
|
||||
private int crystalLevel;
|
||||
private int actCost;
|
||||
private RitualEffect effect;
|
||||
private String name;
|
||||
public final int crystalLevel;
|
||||
public final int actCost;
|
||||
public final RitualEffect effect;
|
||||
public final String name;
|
||||
|
||||
private MRSRenderer customRenderer;
|
||||
public final MRSRenderer customRenderer;
|
||||
|
||||
public static Map<String, Rituals> ritualMap = new HashMap();
|
||||
public static List<String> keyList = new LinkedList();
|
||||
@@ -149,83 +150,21 @@ public class Rituals
|
||||
}
|
||||
|
||||
Block test = null;
|
||||
TileEntity te = null;
|
||||
|
||||
switch (direction)
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
case 1:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getX(), y + rc.getY(), z + rc.getZ());
|
||||
test = world.getBlock(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
|
||||
te = world.getTileEntity(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction));
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ())) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getZ(), y + rc.getY(), z + rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX())) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getX(), y + rc.getY(), z - rc.getZ());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ())) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getZ(), y + rc.getY(), z - rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (((IRitualStone)test).getRuneType(world, x, y, z, world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX())) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
if (!(test instanceof IRitualStone && ((IRitualStone)test).isRuneType(world, x + rc.getX(direction), y, z+ rc.getZ(direction), world.getBlockMetadata(x + rc.getX(direction), y + rc.getY(), z + rc.getZ(direction)), rc.getStoneType()))
|
||||
&& !(te instanceof ITileRitualStone && ((ITileRitualStone)te).isRuneType(rc.getStoneType())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID)
|
||||
@@ -350,9 +289,7 @@ public class Rituals
|
||||
{
|
||||
ritual.effect.onRitualBroken(ritualStone, method);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(method);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumberOfRituals()
|
||||
@@ -437,4 +374,22 @@ public class Rituals
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LocalRitualStorage getLocalStorage(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
RitualEffect eff = ritual.effect;
|
||||
if(eff != null)
|
||||
{
|
||||
return eff.getNewLocalStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
|
||||
/**
|
||||
* Temporary class to hash-out how to create a network not completely tied to the player.
|
||||
*/
|
||||
public class ComplexNetworkHandler
|
||||
{
|
||||
public static String fileName = "config/BloodMagic/soulnetworkKeys";
|
||||
static HashMap<UUID, String> keyMap = new HashMap();
|
||||
public static UUID getUUIDFromPlayer(EntityPlayer player)
|
||||
{
|
||||
return player.getPersistentID();
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerFromUUID(UUID uuid)
|
||||
{
|
||||
MinecraftServer server = MinecraftServer.getServer();
|
||||
GameProfile gameProfile;
|
||||
gameProfile = server.func_152358_ax().func_152652_a(uuid);
|
||||
String str = uuid.toString();
|
||||
//TODO ServerConfigurationManager d.createPlayerForUser
|
||||
UUID.fromString(str);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getKeyForPlayer(EntityPlayer player)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public static UUID getUUIDForKey(String key)
|
||||
{
|
||||
// if (MinecraftServer.getServer() == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// World world = MinecraftServer.getServer().worldServers[0];
|
||||
// UUIDKeyMap data = (UUIDKeyMap) world.loadItemData(UUIDKeyMap.class, key);
|
||||
//
|
||||
// if (data == null)
|
||||
// {
|
||||
// data = new UUIDKeyMap(key);
|
||||
// world.setItemData(key, data);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String assignKeyToPlayer(EntityPlayer player)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
keyMap.put(new UUID(0, 0), "test");
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(keyMap);
|
||||
Writer writer;
|
||||
try
|
||||
{
|
||||
writer = new FileWriter(fileName + ".json");
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
File save = new File(fileName + ".json");
|
||||
|
||||
if(save.canRead())
|
||||
{
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
BufferedReader br;
|
||||
|
||||
try
|
||||
{
|
||||
br = new BufferedReader(new FileReader(save));
|
||||
HashMap schema = gson.fromJson(br, keyMap.getClass());
|
||||
|
||||
keyMap = schema;
|
||||
|
||||
if(keyMap != null)
|
||||
{
|
||||
for(Entry<UUID, String> entry : keyMap.entrySet())
|
||||
{
|
||||
System.out.println("" + entry.getValue() + " gave: "+ entry.getKey());
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
keyMap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,22 +5,26 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData
|
||||
{
|
||||
public int currentEssence;
|
||||
public int maxOrb;
|
||||
|
||||
public LifeEssenceNetwork(String par1Str)
|
||||
{
|
||||
super(par1Str);
|
||||
currentEssence = 0;
|
||||
maxOrb = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
currentEssence = nbttagcompound.getInteger("currentEssence");
|
||||
maxOrb = nbttagcompound.getInteger("maxOrb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
nbttagcompound.setInteger("currentEssence", currentEssence);
|
||||
nbttagcompound.setInteger("maxOrb", maxOrb);
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,13 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import WayofTime.alchemicalWizardry.api.event.AddToNetworkEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.ItemBindEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.ItemDrainInContainerEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.ItemDrainNetworkEvent;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class SoulNetworkHandler
|
||||
{
|
||||
@@ -33,6 +35,84 @@ public class SoulNetworkHandler
|
||||
gameProfile = server.func_152358_ax().func_152652_a(uuid);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean syphonFromNetworkWhileInContainer(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
String ownerName = "";
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
ownerName = ist.getTagCompound().getString("ownerName");
|
||||
}
|
||||
|
||||
ItemDrainInContainerEvent event = new ItemDrainInContainerEvent(ist, ownerName, damageToBeDone);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return syphonFromNetwork(event.ownerNetwork, event.drainAmount) >= damageToBeDone;
|
||||
}
|
||||
|
||||
public static int getCurrentMaxOrb(String ownerName)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
return data.maxOrb;
|
||||
}
|
||||
|
||||
public static void setMaxOrbToMax(String ownerName, int maxOrb)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
data.maxOrb = Math.max(maxOrb, data.maxOrb);
|
||||
data.markDirty();
|
||||
}
|
||||
|
||||
public static int getMaximumForOrbTier(int maxOrb)
|
||||
{
|
||||
switch(maxOrb)
|
||||
{
|
||||
case 1:
|
||||
return 5000;
|
||||
case 2:
|
||||
return 25000;
|
||||
case 3:
|
||||
return 150000;
|
||||
case 4:
|
||||
return 1000000;
|
||||
case 5:
|
||||
return 10000000;
|
||||
case 6:
|
||||
return 30000000;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
@@ -299,34 +379,34 @@ public class SoulNetworkHandler
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
public static boolean checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true;
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
if(!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
if(!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", event.key);
|
||||
}
|
||||
if (!item.hasTagCompound())
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
item.getTagCompound().setString("ownerName", event.key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
if (item.getTagCompound() == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.stackTagCompound.getString("ownerName").equals(""))
|
||||
if (item.getTagCompound().getString("ownerName").equals(""))
|
||||
{
|
||||
item.stackTagCompound.setString("ownerName", ownerName);
|
||||
item.getTagCompound().setString("ownerName", ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,11 +448,11 @@ public class SoulNetworkHandler
|
||||
|
||||
public static String getOwnerName(ItemStack item)
|
||||
{
|
||||
if (item.stackTagCompound == null)
|
||||
if (item.getTagCompound() == null)
|
||||
{
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return item.stackTagCompound.getString("ownerName");
|
||||
return item.getTagCompound().getString("ownerName");
|
||||
}
|
||||
}
|
||||
@@ -8,14 +8,162 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class APISpellHelper
|
||||
{
|
||||
/**
|
||||
* Thanks Kihira! <3
|
||||
* @param player
|
||||
* @return persistent data tag
|
||||
*/
|
||||
private static NBTTagCompound getPersistentDataTag(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound forgeData = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
|
||||
NBTTagCompound beaconData = forgeData.getCompoundTag("BloodMagic");
|
||||
|
||||
//Creates/sets the tags if they don't exist
|
||||
if (!forgeData.hasKey("BloodMagic")) forgeData.setTag("BloodMagic", beaconData);
|
||||
if (!player.getEntityData().hasKey(EntityPlayer.PERSISTED_NBT_TAG)) player.getEntityData().setTag(EntityPlayer.PERSISTED_NBT_TAG, forgeData);
|
||||
|
||||
return beaconData;
|
||||
}
|
||||
|
||||
public static int getPlayerLPTag(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:StoredLP"))
|
||||
{
|
||||
return data.getInteger("BM:StoredLP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerLPTag(EntityPlayer player, int amount)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setInteger("BM:StoredLP", amount);
|
||||
}
|
||||
|
||||
public static int getPlayerMaxLPTag(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:MaxStoredLP"))
|
||||
{
|
||||
return data.getInteger("BM:MaxStoredLP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerMaxLPTag(EntityPlayer player, int amount)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setInteger("BM:MaxStoredLP", amount);
|
||||
}
|
||||
|
||||
public static float getPlayerCurrentReagentAmount(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:StoredReagentAmount"))
|
||||
{
|
||||
return data.getFloat("BM:StoredReagentAmount");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerCurrentReagentAmount(EntityPlayer player, float amount)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setFloat("BM:StoredReagentAmount", amount);
|
||||
}
|
||||
|
||||
public static float getPlayerMaxReagentAmount(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:MaxReagentAmount"))
|
||||
{
|
||||
return data.getFloat("BM:MaxReagentAmount");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerMaxReagentAmount(EntityPlayer player, float amount)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setFloat("BM:MaxReagentAmount", amount);
|
||||
}
|
||||
|
||||
public static Reagent getPlayerReagentType(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:ReagentType"))
|
||||
{
|
||||
return ReagentRegistry.getReagentForKey(data.getString("BM:ReagentType"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void setPlayerReagentType(EntityPlayer player, String str)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setString("BM:ReagentType", str);
|
||||
}
|
||||
|
||||
public static void setPlayerReagentType(EntityPlayer player, Reagent reagent)
|
||||
{
|
||||
setPlayerReagentType(player, ReagentRegistry.getKeyForReagent(reagent));
|
||||
}
|
||||
|
||||
public static float getCurrentAdditionalHP(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if(data.hasKey("BM:CurrentAddedHP"))
|
||||
{
|
||||
return data.getFloat("BM:CurrentAddedHP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentAdditionalHP(EntityPlayer player, float amount)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setFloat("BM:CurrentAddedHP", amount);
|
||||
}
|
||||
|
||||
public static float getCurrentAdditionalMaxHP(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if(data.hasKey("BM:MaxAddedHP"))
|
||||
{
|
||||
return data.getFloat("BM:MaxAddedHP");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentAdditionalMaxHP(EntityPlayer player, float maxHP)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setFloat("BM:MaxAddedHP", maxHP);
|
||||
}
|
||||
|
||||
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range)
|
||||
{
|
||||
float f = 1.0F;
|
||||
@@ -26,7 +174,7 @@ public class APISpellHelper
|
||||
if (!world.isRemote && player instanceof EntityPlayer)
|
||||
d1 += 1.62D;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
|
||||
Vec3 vec3 = APISpellHelper.createVec3(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
|
||||
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
|
||||
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
|
||||
@@ -36,12 +184,17 @@ public class APISpellHelper
|
||||
double d3 = range;
|
||||
if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
|
||||
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
|
||||
}
|
||||
|
||||
public static Vec3 createVec3(double x, double y, double z)
|
||||
{
|
||||
return Vec3.createVectorHelper(x, y, z);
|
||||
}
|
||||
|
||||
public static List<ItemStack> getItemsFromBlock(World world, Block block, int x, int y, int z, int meta, boolean silkTouch, int fortune)
|
||||
{
|
||||
boolean canSilk = block.canSilkHarvest(world, null, x, y, z, meta);
|
||||
@@ -98,4 +251,75 @@ public class APISpellHelper
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static Block getBlockForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
return GameRegistry.findBlock(modId, name);
|
||||
}
|
||||
|
||||
public static Item getItemForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
return GameRegistry.findItem(modId, name);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackForString(String str)
|
||||
{
|
||||
String[] parts = str.split(":");
|
||||
int meta = 0;
|
||||
if(parts.length >= 3)
|
||||
{
|
||||
meta = Integer.decode(parts[2]);
|
||||
}else if(parts.length < 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String modId = parts[0];
|
||||
String name = parts[1];
|
||||
|
||||
String itemString = modId + ":" + name;
|
||||
Item item = APISpellHelper.getItemForString(itemString);
|
||||
if(item != null)
|
||||
{
|
||||
return new ItemStack(item, 1, meta);
|
||||
}
|
||||
|
||||
Block block = APISpellHelper.getBlockForString(itemString);
|
||||
if(block != null)
|
||||
{
|
||||
return new ItemStack(block, 1, meta);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IRecipe getRecipeForItemStack(ItemStack reqStack) //Does not match NBT. Durrr! -smack-
|
||||
{
|
||||
if(reqStack == null)
|
||||
{
|
||||
return null; //Why are you even doing this to yourself!? You know this can't be healthy!
|
||||
}
|
||||
List craftingList = CraftingManager.getInstance().getRecipeList();
|
||||
for(Object posRecipe : craftingList)
|
||||
{
|
||||
if(posRecipe instanceof IRecipe)
|
||||
{
|
||||
ItemStack outputStack = ((IRecipe) posRecipe).getRecipeOutput();
|
||||
if(outputStack != null)
|
||||
{
|
||||
if(outputStack.getItem() == reqStack.getItem() && (outputStack.getItem().getHasSubtypes() ? outputStack.getItemDamage() == reqStack.getItemDamage() : true))
|
||||
{
|
||||
return (IRecipe)posRecipe;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,25 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IProjectile;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
{
|
||||
@@ -185,7 +189,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
|
||||
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
|
||||
|
||||
if (var2 != null && var2.isVecInside(Vec3.createVectorHelper(posX, posY, posZ)))
|
||||
if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ)))
|
||||
{
|
||||
inGround = true;
|
||||
}
|
||||
@@ -214,15 +218,15 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
}
|
||||
}
|
||||
|
||||
Vec3 var17 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
Vec3 var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
Vec3 var17 = APISpellHelper.createVec3(posX, posY, posZ);
|
||||
Vec3 var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
|
||||
var17 = Vec3.createVectorHelper(posX, posY, posZ);
|
||||
var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
var17 = APISpellHelper.createVec3(posX, posY, posZ);
|
||||
var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
|
||||
var3 = APISpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
|
||||
}
|
||||
|
||||
Entity var5 = null;
|
||||
|
||||
@@ -63,8 +63,6 @@ public class SpellEffectRegistry
|
||||
|
||||
public static ComplexSpellEffect getSpellEffect(Class<? extends SpellParadigm> paraClass, ComplexSpellType type, ComplexSpellModifier mod, int power, int potency, int cost)
|
||||
{
|
||||
System.out.println("Debuging");
|
||||
|
||||
if(paraClass == null || type == null || mod == null)
|
||||
{
|
||||
return null;
|
||||
@@ -147,9 +145,9 @@ public class SpellEffectRegistry
|
||||
public static void initiateRegistry()
|
||||
{
|
||||
SpellEffectRegistry.registerSpellType("FIRE", ComplexSpellType.FIRE);
|
||||
SpellEffectRegistry.registerSpellType("WATER", ComplexSpellType.ICE);
|
||||
SpellEffectRegistry.registerSpellType("ICE", ComplexSpellType.ICE);
|
||||
SpellEffectRegistry.registerSpellType("EARTH", ComplexSpellType.EARTH);
|
||||
SpellEffectRegistry.registerSpellType("AIR", ComplexSpellType.WIND);
|
||||
SpellEffectRegistry.registerSpellType("WIND", ComplexSpellType.WIND);
|
||||
|
||||
SpellEffectRegistry.registerSpellModifier("DEFAULT", ComplexSpellModifier.DEFAULT);
|
||||
SpellEffectRegistry.registerSpellModifier("OFFENSIVE", ComplexSpellModifier.OFFENSIVE);
|
||||
|
||||
Reference in new issue
Block a user