mirror of
https://github.com/GTNewHorizons/BloodMagic.git
synced 2026-11-27 15:23:06 +00:00
remove out commentec code
run SA
This commit is contained in:
795 files changed
+33663
-37253
No files matched your search
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import WayofTime.alchemicalWizardry.common.block.ArmourForge;
|
||||
import WayofTime.alchemicalWizardry.common.block.BlockAlchemicCalcinator;
|
||||
import WayofTime.alchemicalWizardry.common.block.BlockAltar;
|
||||
@@ -50,6 +49,7 @@ import WayofTime.alchemicalWizardry.common.items.ItemSpellModifierBlock;
|
||||
import WayofTime.alchemicalWizardry.common.items.ItemSpellParadigmBlock;
|
||||
import WayofTime.alchemicalWizardry.common.items.ItemStabilityGlyphBlock;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
@@ -57,8 +57,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
* Date: 17/01/14
|
||||
* Time: 19:48
|
||||
*/
|
||||
public class ModBlocks
|
||||
{
|
||||
public class ModBlocks {
|
||||
public static Block bloodStoneBrick;
|
||||
public static Block largeBloodStoneBrick;
|
||||
public static BlockAltar blockAltar;
|
||||
@@ -99,8 +98,7 @@ public class ModBlocks
|
||||
public static Block blockStabilityGlyph;
|
||||
public static Block blockCrucible;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
public static void init() {
|
||||
blockAltar = new BlockAltar();
|
||||
bloodRune = new BloodRune();
|
||||
speedRune = new SpeedRune();
|
||||
@@ -136,17 +134,19 @@ public class ModBlocks
|
||||
blockDemonChest = new BlockDemonChest();
|
||||
blockCrystal = new BlockCrystal();
|
||||
blockMimic = new MimicBlock();
|
||||
|
||||
|
||||
blockLifeEssence = new LifeEssenceBlock();
|
||||
blockEnchantmentGlyph = new BlockEnchantmentGlyph();
|
||||
blockStabilityGlyph = new BlockStabilityGlyph();
|
||||
blockCrucible = new BlockCrucible();
|
||||
}
|
||||
|
||||
public static void registerBlocksInPre()
|
||||
{
|
||||
public static void registerBlocksInPre() {
|
||||
GameRegistry.registerBlock(ModBlocks.blockAltar, "Altar");
|
||||
GameRegistry.registerBlock(ModBlocks.bloodRune, ItemBloodRuneBlock.class, "AlchemicalWizardry" + (ModBlocks.bloodRune.getUnlocalizedName().substring(5)));
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.bloodRune,
|
||||
ItemBloodRuneBlock.class,
|
||||
"AlchemicalWizardry" + (ModBlocks.bloodRune.getUnlocalizedName().substring(5)));
|
||||
GameRegistry.registerBlock(ModBlocks.blockLifeEssence, "lifeEssence");
|
||||
GameRegistry.registerBlock(ModBlocks.speedRune, "speedRune");
|
||||
GameRegistry.registerBlock(ModBlocks.efficiencyRune, "efficiencyRune");
|
||||
@@ -170,10 +170,22 @@ public class ModBlocks
|
||||
GameRegistry.registerBlock(ModBlocks.blockBloodLight, "bloodLight");
|
||||
|
||||
GameRegistry.registerBlock(ModBlocks.blockConduit, "blockConduit");
|
||||
GameRegistry.registerBlock(ModBlocks.blockSpellParadigm, ItemSpellParadigmBlock.class, "AlchemicalWizardry" + (ModBlocks.blockSpellParadigm.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(ModBlocks.blockSpellEnhancement, ItemSpellEnhancementBlock.class, "AlchemicalWizardry" + (ModBlocks.blockSpellEnhancement.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(ModBlocks.blockSpellModifier, ItemSpellModifierBlock.class, "AlchemicalWizardry" + (ModBlocks.blockSpellModifier.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(ModBlocks.blockSpellEffect, ItemSpellEffectBlock.class, "AlchemicalWizardry" + (ModBlocks.blockSpellEffect.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.blockSpellParadigm,
|
||||
ItemSpellParadigmBlock.class,
|
||||
"AlchemicalWizardry" + (ModBlocks.blockSpellParadigm.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.blockSpellEnhancement,
|
||||
ItemSpellEnhancementBlock.class,
|
||||
"AlchemicalWizardry" + (ModBlocks.blockSpellEnhancement.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.blockSpellModifier,
|
||||
ItemSpellModifierBlock.class,
|
||||
"AlchemicalWizardry" + (ModBlocks.blockSpellModifier.getUnlocalizedName()));
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.blockSpellEffect,
|
||||
ItemSpellEffectBlock.class,
|
||||
"AlchemicalWizardry" + (ModBlocks.blockSpellEffect.getUnlocalizedName()));
|
||||
|
||||
GameRegistry.registerBlock(ModBlocks.blockSpectralContainer, "spectralContainer");
|
||||
GameRegistry.registerBlock(ModBlocks.blockDemonPortal, "demonPortalMain");
|
||||
@@ -184,13 +196,12 @@ public class ModBlocks
|
||||
GameRegistry.registerBlock(ModBlocks.blockDemonChest, "blockDemonChest");
|
||||
GameRegistry.registerBlock(ModBlocks.blockCrystal, ItemCrystalBlock.class, "blockCrystal");
|
||||
GameRegistry.registerBlock(ModBlocks.blockMimic, "blockMimic");
|
||||
GameRegistry.registerBlock(ModBlocks.blockEnchantmentGlyph, ItemEnchantmentGlyphBlock.class, "blockEnchantmentGlyph");
|
||||
GameRegistry.registerBlock(
|
||||
ModBlocks.blockEnchantmentGlyph, ItemEnchantmentGlyphBlock.class, "blockEnchantmentGlyph");
|
||||
GameRegistry.registerBlock(ModBlocks.blockStabilityGlyph, ItemStabilityGlyphBlock.class, "blockStabilityGlyph");
|
||||
|
||||
|
||||
GameRegistry.registerBlock(ModBlocks.blockCrucible, "blockCrucible");
|
||||
}
|
||||
|
||||
public static void registerBlocksInInit()
|
||||
{
|
||||
}
|
||||
public static void registerBlocksInInit() {}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.items.*;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
|
||||
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
|
||||
import WayofTime.alchemicalWizardry.common.items.*;
|
||||
import WayofTime.alchemicalWizardry.common.items.armour.BoundArmour;
|
||||
import WayofTime.alchemicalWizardry.common.items.armour.OmegaArmourEarth;
|
||||
import WayofTime.alchemicalWizardry.common.items.armour.OmegaArmourFire;
|
||||
@@ -52,6 +49,9 @@ import WayofTime.alchemicalWizardry.common.items.sigil.SigilVoid;
|
||||
import WayofTime.alchemicalWizardry.common.items.sigil.SigilWater;
|
||||
import WayofTime.alchemicalWizardry.common.items.sigil.holding.SigilOfHolding;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
@@ -59,8 +59,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
* Date: 17/01/14
|
||||
* Time: 19:48
|
||||
*/
|
||||
public class ModItems
|
||||
{
|
||||
public class ModItems {
|
||||
public static Item weakBloodOrb;
|
||||
public static Item apprenticeBloodOrb;
|
||||
public static Item magicianBloodOrb;
|
||||
@@ -207,8 +206,7 @@ public class ModItems
|
||||
|
||||
public static Item ritualDismantler;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
public static void init() {
|
||||
weakBloodOrb = new EnergyBattery(5000).setUnlocalizedName("weakBloodOrb");
|
||||
apprenticeBloodOrb = new ApprenticeBloodOrb(25000).setUnlocalizedName("apprenticeBloodOrb");
|
||||
magicianBloodOrb = new MagicianBloodOrb(150000).setUnlocalizedName("magicianBloodOrb");
|
||||
@@ -270,7 +268,8 @@ public class ModItems
|
||||
sigilOfWind = new SigilOfWind().setUnlocalizedName("sigilOfWind");
|
||||
telepositionFocus = new TelepositionFocus(1).setUnlocalizedName("telepositionFocus");
|
||||
enhancedTelepositionFocus = new EnhancedTelepositionFocus().setUnlocalizedName("enhancedTelepositionFocus");
|
||||
reinforcedTelepositionFocus = new ReinforcedTelepositionFocus().setUnlocalizedName("reinforcedTelepositionFocus");
|
||||
reinforcedTelepositionFocus =
|
||||
new ReinforcedTelepositionFocus().setUnlocalizedName("reinforcedTelepositionFocus");
|
||||
demonicTelepositionFocus = new DemonicTelepositionFocus().setUnlocalizedName("demonicTelepositionFocus");
|
||||
imbuedSlate = new AWBaseItems().setUnlocalizedName("imbuedSlate");
|
||||
demonicSlate = new AWBaseItems().setUnlocalizedName("demonicSlate");
|
||||
@@ -292,7 +291,10 @@ public class ModItems
|
||||
energyBazookaThirdTier = new EnergyBazooka(3).setUnlocalizedName("energyBazookaThirdTier");
|
||||
itemBloodLightSigil = new SigilBloodLight().setUnlocalizedName("bloodLightSigil");
|
||||
itemComplexSpellCrystal = new ItemComplexSpellCrystal().setUnlocalizedName("itemComplexSpellCrystal");
|
||||
bucketLife = new LifeBucket(ModBlocks.blockLifeEssence).setUnlocalizedName("bucketLife").setContainerItem(Items.bucket).setCreativeTab(CreativeTabs.tabMisc);
|
||||
bucketLife = new LifeBucket(ModBlocks.blockLifeEssence)
|
||||
.setUnlocalizedName("bucketLife")
|
||||
.setContainerItem(Items.bucket)
|
||||
.setCreativeTab(CreativeTabs.tabMisc);
|
||||
itemSigilOfEnderSeverance = (new SigilOfEnderSeverance()).setUnlocalizedName("itemSigilOfEnderSeverance");
|
||||
baseItems = new ItemComponents().setUnlocalizedName("baseItems");
|
||||
baseAlchemyItems = new ItemAlchemyBase().setUnlocalizedName("baseAlchemyItems");
|
||||
@@ -343,8 +345,7 @@ public class ModItems
|
||||
ritualDismantler = new ItemRitualDismantler().setUnlocalizedName("ritualDismantler");
|
||||
}
|
||||
|
||||
public static void registerItems()
|
||||
{
|
||||
public static void registerItems() {
|
||||
GameRegistry.registerItem(ModItems.weakBloodOrb, "weakBloodOrb");
|
||||
GameRegistry.registerItem(ModItems.apprenticeBloodOrb, "apprenticeBloodOrb");
|
||||
GameRegistry.registerItem(ModItems.magicianBloodOrb, "magicianBloodOrb");
|
||||
|
||||
@@ -2,8 +2,7 @@ package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ColourAndCoords
|
||||
{
|
||||
public class ColourAndCoords {
|
||||
public int colourRed;
|
||||
public int colourGreen;
|
||||
public int colourBlue;
|
||||
@@ -13,8 +12,7 @@ public class ColourAndCoords
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z)
|
||||
{
|
||||
public ColourAndCoords(int red, int green, int blue, int intensity, int x, int y, int z) {
|
||||
this.colourRed = red;
|
||||
this.colourGreen = green;
|
||||
this.colourBlue = blue;
|
||||
@@ -25,13 +23,18 @@ public class ColourAndCoords
|
||||
this.zCoord = z;
|
||||
}
|
||||
|
||||
public static ColourAndCoords readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
return new ColourAndCoords(tag.getInteger("colourRed"), tag.getInteger("colourGreen"), tag.getInteger("colourBlue"), tag.getInteger("colourIntensity"), tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
|
||||
public static ColourAndCoords readFromNBT(NBTTagCompound tag) {
|
||||
return new ColourAndCoords(
|
||||
tag.getInteger("colourRed"),
|
||||
tag.getInteger("colourGreen"),
|
||||
tag.getInteger("colourBlue"),
|
||||
tag.getInteger("colourIntensity"),
|
||||
tag.getInteger("xCoord"),
|
||||
tag.getInteger("yCoord"),
|
||||
tag.getInteger("zCoord"));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag.setInteger("colourRed", colourRed);
|
||||
tag.setInteger("colourGreen", colourGreen);
|
||||
tag.setInteger("colourBlue", colourBlue);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
public interface ILimitingLogic
|
||||
{
|
||||
public int getRoutingLimit();
|
||||
public interface ILimitingLogic {
|
||||
public int getRoutingLimit();
|
||||
}
|
||||
@@ -2,27 +2,22 @@ package WayofTime.alchemicalWizardry.api;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
|
||||
public class Int3
|
||||
{
|
||||
public class Int3 {
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int zCoord;
|
||||
|
||||
public Int3(int xCoord, int yCoord, 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)
|
||||
{
|
||||
public static Int3 readFromNBT(NBTTagCompound tag) {
|
||||
return new Int3(tag.getInteger("xCoord"), tag.getInteger("yCoord"), tag.getInteger("zCoord"));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag.setInteger("xCoord", xCoord);
|
||||
tag.setInteger("yCoord", yCoord);
|
||||
tag.setInteger("zCoord", zCoord);
|
||||
@@ -31,14 +26,16 @@ public class Int3
|
||||
}
|
||||
|
||||
@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;
|
||||
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()
|
||||
{
|
||||
public int hashCode() {
|
||||
return this.xCoord + this.yCoord << 8 + this.zCoord << 16;
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,18 @@ 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -2,63 +2,52 @@ 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)
|
||||
{
|
||||
if(logic instanceof ILimitingLogic)
|
||||
{
|
||||
maximumAmount += ((ILimitingLogic)logic).getRoutingLimit();
|
||||
}
|
||||
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;
|
||||
}
|
||||
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) {
|
||||
if (logic instanceof ILimitingLogic) {
|
||||
maximumAmount += ((ILimitingLogic) logic).getRoutingLimit();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,20 @@ 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -4,42 +4,40 @@ package WayofTime.alchemicalWizardry.api;
|
||||
* Created in Scala by Alex-Hawks
|
||||
* Translated and implemented by Arcaratus
|
||||
*/
|
||||
public class Vector3
|
||||
{
|
||||
public class Vector3 {
|
||||
public int x, y, z;
|
||||
|
||||
public Vector3(int x, int y, int z)
|
||||
{
|
||||
public Vector3(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vector3 add(Vector3 vec1)
|
||||
{
|
||||
public Vector3 add(Vector3 vec1) {
|
||||
return new Vector3(this.x + vec1.x, this.y + vec1.y, this.z + vec1.z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
public String toString() {
|
||||
return "V3(" + x + "}, " + y + "}," + z + "})";
|
||||
}
|
||||
|
||||
private boolean canEqual(Object object)
|
||||
{
|
||||
private boolean canEqual(Object object) {
|
||||
return object instanceof Vector3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
return object == this || object instanceof Vector3 && canEqual(this) && this.x == ((Vector3) object).x && this.y == ((Vector3) object).y && this.z == ((Vector3) object).z;
|
||||
public boolean equals(Object object) {
|
||||
return object == this
|
||||
|| object instanceof Vector3
|
||||
&& canEqual(this)
|
||||
&& this.x == ((Vector3) object).x
|
||||
&& this.y == ((Vector3) object).y
|
||||
&& this.z == ((Vector3) object).z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
public int hashCode() {
|
||||
return 48131 * x - 95021 * y + z;
|
||||
}
|
||||
}
|
||||
+17
-34
@@ -1,24 +1,18 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AlchemicalPotionCreationHandler
|
||||
{
|
||||
public class AlchemicalPotionCreationHandler {
|
||||
public static ArrayList<AlchemyPotionHandlerComponent> registeredPotionEffects = new ArrayList();
|
||||
|
||||
public static void addPotion(ItemStack itemStack, int potionID, int tickDuration)
|
||||
{
|
||||
public static void addPotion(ItemStack itemStack, int potionID, int tickDuration) {
|
||||
registeredPotionEffects.add(new AlchemyPotionHandlerComponent(itemStack, potionID, tickDuration));
|
||||
}
|
||||
|
||||
public static int getPotionIDForStack(ItemStack itemStack)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(itemStack))
|
||||
{
|
||||
public static int getPotionIDForStack(ItemStack itemStack) {
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) {
|
||||
if (aphc.compareItemStack(itemStack)) {
|
||||
return aphc.getPotionID();
|
||||
}
|
||||
}
|
||||
@@ -26,13 +20,10 @@ public class AlchemicalPotionCreationHandler
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getPotionTickDurationForStack(ItemStack itemStack)
|
||||
{
|
||||
public static int getPotionTickDurationForStack(ItemStack itemStack) {
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(itemStack))
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) {
|
||||
if (aphc.compareItemStack(itemStack)) {
|
||||
return aphc.getTickDuration();
|
||||
}
|
||||
}
|
||||
@@ -41,14 +32,10 @@ public class AlchemicalPotionCreationHandler
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList)
|
||||
{
|
||||
for (ItemStack is : stackList)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(is))
|
||||
{
|
||||
public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList) {
|
||||
for (ItemStack is : stackList) {
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) {
|
||||
if (aphc.compareItemStack(is)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -57,16 +44,12 @@ public class AlchemicalPotionCreationHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList)
|
||||
{
|
||||
public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList) {
|
||||
int i = 0;
|
||||
|
||||
for (ItemStack is : stackList)
|
||||
{
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
|
||||
{
|
||||
if (aphc.compareItemStack(is))
|
||||
{
|
||||
for (ItemStack is : stackList) {
|
||||
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects) {
|
||||
if (aphc.compareItemStack(is)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-22
@@ -3,50 +3,42 @@ package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AlchemyPotionHandlerComponent
|
||||
{
|
||||
public class AlchemyPotionHandlerComponent {
|
||||
private ItemStack itemStack;
|
||||
private int potionID;
|
||||
private int tickDuration;
|
||||
|
||||
public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration)
|
||||
{
|
||||
public AlchemyPotionHandlerComponent(ItemStack itemStack, int potionID, int tickDuration) {
|
||||
this.itemStack = itemStack;
|
||||
this.potionID = potionID;
|
||||
this.tickDuration = tickDuration;
|
||||
}
|
||||
|
||||
public boolean compareItemStack(ItemStack comparedStack)
|
||||
{
|
||||
if (comparedStack != null && itemStack != null)
|
||||
{
|
||||
if (comparedStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
public boolean compareItemStack(ItemStack comparedStack) {
|
||||
if (comparedStack != null && itemStack != null) {
|
||||
if (comparedStack.getItem() instanceof ItemBlock) {
|
||||
if (itemStack.getItem() instanceof ItemBlock) {
|
||||
return comparedStack.getItem().equals(itemStack.getItem())
|
||||
&& comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
}
|
||||
} else if (!(itemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
} else if (!(itemStack.getItem() instanceof ItemBlock)) {
|
||||
return comparedStack.getItem().equals(itemStack.getItem())
|
||||
&& comparedStack.getItemDamage() == itemStack.getItemDamage();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public int getPotionID()
|
||||
{
|
||||
public int getPotionID() {
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public int getTickDuration()
|
||||
{
|
||||
public int getTickDuration() {
|
||||
return this.tickDuration;
|
||||
}
|
||||
}
|
||||
@@ -4,68 +4,63 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
public class AlchemyPotionHelper
|
||||
{
|
||||
public class AlchemyPotionHelper {
|
||||
private int potionID;
|
||||
private int tickDuration;
|
||||
private int concentration;
|
||||
private int durationFactor;
|
||||
|
||||
public AlchemyPotionHelper(int potionID, int tickDuration, int concentration, int durationFactor)
|
||||
{
|
||||
public AlchemyPotionHelper(int potionID, int tickDuration, int concentration, int durationFactor) {
|
||||
this.potionID = potionID;
|
||||
this.tickDuration = tickDuration;
|
||||
this.concentration = concentration;
|
||||
this.durationFactor = durationFactor;
|
||||
}
|
||||
|
||||
public void setConcentration(int concentration)
|
||||
{
|
||||
public void setConcentration(int concentration) {
|
||||
this.concentration = concentration;
|
||||
}
|
||||
|
||||
public void setDurationFactor(int durationFactor)
|
||||
{
|
||||
public void setDurationFactor(int durationFactor) {
|
||||
this.durationFactor = durationFactor;
|
||||
}
|
||||
|
||||
public int getPotionID()
|
||||
{
|
||||
public int getPotionID() {
|
||||
return this.potionID;
|
||||
}
|
||||
|
||||
public int getTickDuration()
|
||||
{
|
||||
public int getTickDuration() {
|
||||
return this.tickDuration;
|
||||
}
|
||||
|
||||
public int getConcentration()
|
||||
{
|
||||
public int getConcentration() {
|
||||
return this.concentration;
|
||||
}
|
||||
|
||||
public int getdurationFactor()
|
||||
{
|
||||
public int getdurationFactor() {
|
||||
return this.durationFactor;
|
||||
}
|
||||
|
||||
public PotionEffect getPotionEffect()
|
||||
{
|
||||
if (potionID == Potion.heal.id || potionID == Potion.harm.id)
|
||||
{
|
||||
public PotionEffect getPotionEffect() {
|
||||
if (potionID == Potion.heal.id || potionID == Potion.harm.id) {
|
||||
return (new PotionEffect(potionID, 1, concentration));
|
||||
}
|
||||
|
||||
return (new PotionEffect(potionID, (int) (tickDuration * Math.pow(0.5f, concentration) * Math.pow(8.0f / 3.0f, durationFactor)), concentration));
|
||||
return (new PotionEffect(
|
||||
potionID,
|
||||
(int) (tickDuration * Math.pow(0.5f, concentration) * Math.pow(8.0f / 3.0f, durationFactor)),
|
||||
concentration));
|
||||
}
|
||||
|
||||
public static AlchemyPotionHelper readEffectFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
return new AlchemyPotionHelper(tagCompound.getInteger("potionID"), tagCompound.getInteger("tickDuration"), tagCompound.getInteger("concentration"), tagCompound.getInteger("durationFactor"));
|
||||
public static AlchemyPotionHelper readEffectFromNBT(NBTTagCompound tagCompound) {
|
||||
return new AlchemyPotionHelper(
|
||||
tagCompound.getInteger("potionID"),
|
||||
tagCompound.getInteger("tickDuration"),
|
||||
tagCompound.getInteger("concentration"),
|
||||
tagCompound.getInteger("durationFactor"));
|
||||
}
|
||||
|
||||
public static NBTTagCompound setEffectToNBT(AlchemyPotionHelper aph)
|
||||
{
|
||||
public static NBTTagCompound setEffectToNBT(AlchemyPotionHelper aph) {
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setInteger("potionID", aph.getPotionID());
|
||||
tagCompound.setInteger("tickDuration", aph.getTickDuration());
|
||||
|
||||
@@ -4,116 +4,96 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class AlchemyRecipe
|
||||
{
|
||||
public class AlchemyRecipe {
|
||||
private ItemStack output;
|
||||
private ItemStack[] recipe;
|
||||
private int bloodOrbLevel;
|
||||
private int amountNeeded;
|
||||
|
||||
public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
|
||||
{
|
||||
public AlchemyRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) {
|
||||
this.output = output;
|
||||
this.recipe = recipe;
|
||||
this.amountNeeded = amountNeeded;
|
||||
this.bloodOrbLevel = bloodOrbLevel;
|
||||
}
|
||||
|
||||
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel)
|
||||
{
|
||||
if (slottedBloodOrbLevel < bloodOrbLevel)
|
||||
{
|
||||
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel) {
|
||||
if (slottedBloodOrbLevel < bloodOrbLevel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] recipe;
|
||||
|
||||
if (items.length < 5)
|
||||
{
|
||||
if (items.length < 5) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.recipe.length != 5)
|
||||
{
|
||||
if (this.recipe.length != 5) {
|
||||
ItemStack[] newRecipe = new ItemStack[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (i + 1 > this.recipe.length)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i + 1 > this.recipe.length) {
|
||||
newRecipe[i] = null;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
newRecipe[i] = this.recipe[i];
|
||||
}
|
||||
}
|
||||
|
||||
recipe = newRecipe;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
recipe = this.recipe;
|
||||
}
|
||||
|
||||
boolean[] checkList = new boolean[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
checkList[i] = false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ItemStack recipeItemStack = recipe[i];
|
||||
|
||||
if (recipeItemStack == null)
|
||||
{
|
||||
if (recipeItemStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean test = false;
|
||||
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
if (checkList[j])
|
||||
{
|
||||
for (int j = 0; j < 5; j++) {
|
||||
if (checkList[j]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack checkedItemStack = items[j];
|
||||
|
||||
if (checkedItemStack == null)
|
||||
{
|
||||
if (checkedItemStack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean quickTest = false;
|
||||
|
||||
if (recipeItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (checkedItemStack.getItem() instanceof ItemBlock)
|
||||
{
|
||||
if (recipeItemStack.getItem() instanceof ItemBlock) {
|
||||
if (checkedItemStack.getItem() instanceof ItemBlock) {
|
||||
quickTest = true;
|
||||
}
|
||||
} else if (!(checkedItemStack.getItem() instanceof ItemBlock))
|
||||
{
|
||||
} else if (!(checkedItemStack.getItem() instanceof ItemBlock)) {
|
||||
quickTest = true;
|
||||
}
|
||||
|
||||
if (!quickTest)
|
||||
{
|
||||
if (!quickTest) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem())
|
||||
{
|
||||
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage()
|
||||
|| OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage())
|
||||
&& checkedItemStack.getItem() == recipeItemStack.getItem()) {
|
||||
test = true;
|
||||
checkList[j] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!test)
|
||||
{
|
||||
if (!test) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -121,23 +101,19 @@ public class AlchemyRecipe
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
public ItemStack getResult() {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
public int getAmountNeeded()
|
||||
{
|
||||
public int getAmountNeeded() {
|
||||
return this.amountNeeded;
|
||||
}
|
||||
|
||||
public ItemStack[] getRecipe()
|
||||
{
|
||||
public ItemStack[] getRecipe() {
|
||||
return this.recipe;
|
||||
}
|
||||
|
||||
public int getOrbLevel()
|
||||
{
|
||||
public int getOrbLevel() {
|
||||
return this.bloodOrbLevel;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +1,30 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class AlchemyRecipeRegistry
|
||||
{
|
||||
public class AlchemyRecipeRegistry {
|
||||
public static List<AlchemyRecipe> recipes = new ArrayList();
|
||||
|
||||
public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel)
|
||||
{
|
||||
public static void registerRecipe(ItemStack output, int amountNeeded, ItemStack[] recipe, int bloodOrbLevel) {
|
||||
recipes.add(new AlchemyRecipe(output, amountNeeded, recipe, bloodOrbLevel));
|
||||
}
|
||||
|
||||
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb)
|
||||
{
|
||||
if (bloodOrb == null)
|
||||
{
|
||||
public static ItemStack getResult(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
if (bloodOrb == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb))
|
||||
{
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
|
||||
{
|
||||
for (AlchemyRecipe ar : recipes) {
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) {
|
||||
return (ar.getResult());
|
||||
}
|
||||
}
|
||||
@@ -40,24 +32,19 @@ public class AlchemyRecipeRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb)
|
||||
{
|
||||
if (bloodOrb == null)
|
||||
{
|
||||
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb) {
|
||||
if (bloodOrb == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb))
|
||||
{
|
||||
if (!(bloodOrb.getItem() instanceof IBloodOrb)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
|
||||
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
|
||||
{
|
||||
for (AlchemyRecipe ar : recipes) {
|
||||
if (ar.doesRecipeMatch(recipe, bloodOrbLevel)) {
|
||||
return (ar.getAmountNeeded());
|
||||
}
|
||||
}
|
||||
@@ -65,16 +52,12 @@ public class AlchemyRecipeRegistry
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack)
|
||||
{
|
||||
for (AlchemyRecipe ar : recipes)
|
||||
{
|
||||
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack) {
|
||||
for (AlchemyRecipe ar : recipes) {
|
||||
ItemStack result = ar.getResult();
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
if (result.isItemEqual(itemStack))
|
||||
{
|
||||
if (result != null) {
|
||||
if (result.isItemEqual(itemStack)) {
|
||||
return ar.getRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IAlchemyGoggles
|
||||
{
|
||||
public interface IAlchemyGoggles {
|
||||
boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player);
|
||||
}
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public interface IReagentContainer
|
||||
{
|
||||
public interface IReagentContainer {
|
||||
ReagentStack getReagent();
|
||||
|
||||
int getReagentStackAmount();
|
||||
|
||||
@@ -2,8 +2,7 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IReagentHandler
|
||||
{
|
||||
public interface IReagentHandler {
|
||||
int fill(ForgeDirection from, ReagentStack resource, boolean doFill);
|
||||
|
||||
ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain);
|
||||
|
||||
+1
-2
@@ -2,8 +2,7 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ISegmentedReagentHandler extends IReagentHandler
|
||||
{
|
||||
public interface ISegmentedReagentHandler extends IReagentHandler {
|
||||
int getNumberOfTanks();
|
||||
|
||||
int getTanksTunedToReagent(Reagent reagent);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public class Reagent
|
||||
{
|
||||
public class Reagent {
|
||||
public final String name;
|
||||
|
||||
public static final int REAGENT_SIZE = 1000;
|
||||
@@ -11,42 +10,35 @@ public class Reagent
|
||||
private int colourBlue = 0;
|
||||
private int colourIntensity = 255;
|
||||
|
||||
public Reagent(String name)
|
||||
{
|
||||
public Reagent(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setColour(int red, int green, int blue, int intensity)
|
||||
{
|
||||
public void setColour(int red, int green, int blue, int intensity) {
|
||||
this.colourRed = red;
|
||||
this.colourGreen = green;
|
||||
this.colourBlue = blue;
|
||||
this.colourIntensity = intensity;
|
||||
}
|
||||
|
||||
public int getColourRed()
|
||||
{
|
||||
public int getColourRed() {
|
||||
return colourRed;
|
||||
}
|
||||
|
||||
public int getColourGreen()
|
||||
{
|
||||
public int getColourGreen() {
|
||||
return colourGreen;
|
||||
}
|
||||
|
||||
public int getColourBlue()
|
||||
{
|
||||
public int getColourBlue() {
|
||||
return colourBlue;
|
||||
}
|
||||
|
||||
public int getColourIntensity()
|
||||
{
|
||||
public int getColourIntensity() {
|
||||
return colourIntensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Reagent && this == o && name.equals(((Reagent) o).name);
|
||||
}
|
||||
}
|
||||
+28
-56
@@ -2,45 +2,36 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ReagentContainer implements IReagentContainer
|
||||
{
|
||||
public class ReagentContainer implements IReagentContainer {
|
||||
protected ReagentStack reagentStack;
|
||||
protected int capacity;
|
||||
|
||||
public ReagentContainer(int capacity)
|
||||
{
|
||||
public ReagentContainer(int capacity) {
|
||||
this(null, capacity);
|
||||
}
|
||||
|
||||
public ReagentContainer(ReagentStack stack, int capacity)
|
||||
{
|
||||
public ReagentContainer(ReagentStack stack, int capacity) {
|
||||
this.reagentStack = stack;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public ReagentContainer(Reagent reagent, int amount, int capacity)
|
||||
{
|
||||
public ReagentContainer(Reagent reagent, int amount, int capacity) {
|
||||
this(new ReagentStack(reagent, amount), capacity);
|
||||
}
|
||||
|
||||
public static ReagentContainer readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
public static ReagentContainer readFromNBT(NBTTagCompound nbt) {
|
||||
ReagentStack reagent = ReagentStack.loadReagentStackFromNBT(nbt);
|
||||
int capacity = nbt.getInteger("capacity");
|
||||
|
||||
if (reagent != null)
|
||||
{
|
||||
if (reagent != null) {
|
||||
return new ReagentContainer(reagent, capacity);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return new ReagentContainer(null, capacity);
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
if (reagentStack != null)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
if (reagentStack != null) {
|
||||
reagentStack.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@@ -50,69 +41,56 @@ public class ReagentContainer implements IReagentContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack getReagent()
|
||||
{
|
||||
public ReagentStack getReagent() {
|
||||
return reagentStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReagentStackAmount()
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
public int getReagentStackAmount() {
|
||||
if (reagentStack == null) {
|
||||
return 0;
|
||||
}
|
||||
return reagentStack.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ReagentStack resource, boolean doFill)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
public int fill(ReagentStack resource, boolean doFill) {
|
||||
if (resource == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill)
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
if (!doFill) {
|
||||
if (reagentStack == null) {
|
||||
return Math.min(capacity, resource.amount);
|
||||
}
|
||||
|
||||
if (!reagentStack.isReagentEqual(resource))
|
||||
{
|
||||
if (!reagentStack.isReagentEqual(resource)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.min(capacity - reagentStack.amount, resource.amount);
|
||||
}
|
||||
|
||||
if (reagentStack == null)
|
||||
{
|
||||
if (reagentStack == null) {
|
||||
reagentStack = new ReagentStack(resource, Math.min(capacity, resource.amount));
|
||||
|
||||
return reagentStack.amount;
|
||||
}
|
||||
|
||||
if (!reagentStack.isReagentEqual(resource))
|
||||
{
|
||||
if (!reagentStack.isReagentEqual(resource)) {
|
||||
return 0;
|
||||
}
|
||||
int filled = capacity - reagentStack.amount;
|
||||
|
||||
if (resource.amount < filled)
|
||||
{
|
||||
if (resource.amount < filled) {
|
||||
reagentStack.amount += resource.amount;
|
||||
filled = resource.amount;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
reagentStack.amount = capacity;
|
||||
}
|
||||
|
||||
@@ -120,25 +98,20 @@ public class ReagentContainer implements IReagentContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(int maxDrain, boolean doDrain)
|
||||
{
|
||||
if (reagentStack == null)
|
||||
{
|
||||
public ReagentStack drain(int maxDrain, boolean doDrain) {
|
||||
if (reagentStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int drained = maxDrain;
|
||||
if (reagentStack.amount < drained)
|
||||
{
|
||||
if (reagentStack.amount < drained) {
|
||||
drained = reagentStack.amount;
|
||||
}
|
||||
|
||||
ReagentStack stack = new ReagentStack(reagentStack, drained);
|
||||
if (doDrain)
|
||||
{
|
||||
if (doDrain) {
|
||||
reagentStack.amount -= drained;
|
||||
if (reagentStack.amount <= 0)
|
||||
{
|
||||
if (reagentStack.amount <= 0) {
|
||||
reagentStack = null;
|
||||
}
|
||||
}
|
||||
@@ -146,8 +119,7 @@ public class ReagentContainer implements IReagentContainer
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo getInfo()
|
||||
{
|
||||
public ReagentContainerInfo getInfo() {
|
||||
return new ReagentContainerInfo(this);
|
||||
}
|
||||
}
|
||||
+3
-6
@@ -1,18 +1,15 @@
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
public final class ReagentContainerInfo
|
||||
{
|
||||
public final class ReagentContainerInfo {
|
||||
public final ReagentStack reagent;
|
||||
public final int capacity;
|
||||
|
||||
public ReagentContainerInfo(ReagentStack reagent, int capacity)
|
||||
{
|
||||
public ReagentContainerInfo(ReagentStack reagent, int capacity) {
|
||||
this.reagent = reagent;
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
public ReagentContainerInfo(IReagentContainer tank)
|
||||
{
|
||||
public ReagentContainerInfo(IReagentContainer tank) {
|
||||
this.reagent = tank.getReagent();
|
||||
this.capacity = tank.getCapacity();
|
||||
}
|
||||
|
||||
+23
-47
@@ -4,11 +4,9 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ReagentRegistry
|
||||
{
|
||||
public class ReagentRegistry {
|
||||
public static Map<String, Reagent> reagentList = new HashMap();
|
||||
public static Map<ItemStack, ReagentStack> itemToReagentMap = new HashMap();
|
||||
|
||||
@@ -29,8 +27,7 @@ public class ReagentRegistry
|
||||
public static Reagent reductusReagent;
|
||||
public static Reagent potentiaReagent;
|
||||
|
||||
public static void initReagents()
|
||||
{
|
||||
public static void initReagents() {
|
||||
sanctusReagent = new Reagent("sanctus");
|
||||
incendiumReagent = new Reagent("incendium");
|
||||
aquasalusReagent = new Reagent("aquasalus");
|
||||
@@ -80,10 +77,8 @@ public class ReagentRegistry
|
||||
registerReagent("potentia", potentiaReagent);
|
||||
}
|
||||
|
||||
public static boolean registerReagent(String key, Reagent reagent)
|
||||
{
|
||||
if (reagentList.containsKey(key) || reagent == null)
|
||||
{
|
||||
public static boolean registerReagent(String key, Reagent reagent) {
|
||||
if (reagentList.containsKey(key) || reagent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,25 +87,19 @@ public class ReagentRegistry
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Reagent getReagentForKey(String key)
|
||||
{
|
||||
if (reagentList.containsKey(key))
|
||||
{
|
||||
public static Reagent getReagentForKey(String key) {
|
||||
if (reagentList.containsKey(key)) {
|
||||
return reagentList.get(key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getKeyForReagent(Reagent reagent)
|
||||
{
|
||||
if (reagentList.containsValue(reagent))
|
||||
{
|
||||
public static String getKeyForReagent(Reagent reagent) {
|
||||
if (reagentList.containsValue(reagent)) {
|
||||
Set<Entry<String, Reagent>> set = reagentList.entrySet();
|
||||
for (Entry<String, Reagent> entry : set)
|
||||
{
|
||||
if (entry.getValue().equals(reagent))
|
||||
{
|
||||
for (Entry<String, Reagent> entry : set) {
|
||||
if (entry.getValue().equals(reagent)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
@@ -119,27 +108,20 @@ public class ReagentRegistry
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void registerItemAndReagent(ItemStack stack, ReagentStack reagentStack)
|
||||
{
|
||||
public static void registerItemAndReagent(ItemStack stack, ReagentStack reagentStack) {
|
||||
itemToReagentMap.put(stack, reagentStack);
|
||||
}
|
||||
|
||||
public static ReagentStack getReagentStackForItem(ItemStack stack)
|
||||
{
|
||||
if (stack == null)
|
||||
{
|
||||
public static ReagentStack getReagentStackForItem(ItemStack stack) {
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet())
|
||||
{
|
||||
if (entry.getKey() != null && entry.getKey().isItemEqual(stack))
|
||||
{
|
||||
if (entry.getValue() == null)
|
||||
{
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet()) {
|
||||
if (entry.getKey() != null && entry.getKey().isItemEqual(stack)) {
|
||||
if (entry.getValue() == null) {
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return entry.getValue().copy();
|
||||
}
|
||||
}
|
||||
@@ -148,22 +130,16 @@ public class ReagentRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForReagent(Reagent reagent)
|
||||
{
|
||||
if (reagent == null)
|
||||
{
|
||||
public static ItemStack getItemForReagent(Reagent reagent) {
|
||||
if (reagent == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet())
|
||||
{
|
||||
if (entry.getValue() != null && entry.getValue().reagent == reagent)
|
||||
{
|
||||
if (entry.getKey() == null)
|
||||
{
|
||||
for (Entry<ItemStack, ReagentStack> entry : itemToReagentMap.entrySet()) {
|
||||
if (entry.getValue() != null && entry.getValue().reagent == reagent) {
|
||||
if (entry.getKey() == null) {
|
||||
return null;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return entry.getKey().copy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,28 +2,23 @@ package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ReagentStack
|
||||
{
|
||||
public class ReagentStack {
|
||||
public Reagent reagent;
|
||||
public int amount;
|
||||
|
||||
public ReagentStack(Reagent reagent, int amount)
|
||||
{
|
||||
public ReagentStack(Reagent reagent, int amount) {
|
||||
this.reagent = reagent;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public ReagentStack(ReagentStack reagentStack, int amount)
|
||||
{
|
||||
public ReagentStack(ReagentStack reagentStack, int amount) {
|
||||
this(reagentStack.reagent, amount);
|
||||
}
|
||||
|
||||
public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag) {
|
||||
Reagent reagent = ReagentRegistry.getReagentForKey(tag.getString("Reagent"));
|
||||
|
||||
if (reagent == null)
|
||||
{
|
||||
if (reagent == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,16 +28,14 @@ public class ReagentStack
|
||||
return stack;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
tag.setString("Reagent", ReagentRegistry.getKeyForReagent(this.reagent));
|
||||
tag.setInteger("amount", this.amount);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public ReagentStack splitStack(int amount)
|
||||
{
|
||||
public ReagentStack splitStack(int amount) {
|
||||
ReagentStack copyStack = this.copy();
|
||||
int splitAmount = Math.min(amount, this.amount);
|
||||
copyStack.amount = splitAmount;
|
||||
@@ -51,13 +44,11 @@ public class ReagentStack
|
||||
return copyStack;
|
||||
}
|
||||
|
||||
public ReagentStack copy()
|
||||
{
|
||||
public ReagentStack copy() {
|
||||
return new ReagentStack(this.reagent, this.amount);
|
||||
}
|
||||
|
||||
public boolean isReagentEqual(ReagentStack other)
|
||||
{
|
||||
public boolean isReagentEqual(ReagentStack other) {
|
||||
return other != null && this.reagent == other.reagent;
|
||||
}
|
||||
}
|
||||
+12
-23
@@ -1,66 +1,55 @@
|
||||
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileReagentHandler extends TileEntity implements IReagentHandler
|
||||
{
|
||||
public class TileReagentHandler extends TileEntity implements IReagentHandler {
|
||||
protected ReagentContainer tank = new ReagentContainer(4000);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
tank.readFromNBT(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
tank.writeToNBT(tag);
|
||||
}
|
||||
|
||||
/* IReagentHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) {
|
||||
return tank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null || !resource.isReagentEqual(tank.getReagent()))
|
||||
{
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain) {
|
||||
if (resource == null || !resource.isReagentEqual(tank.getReagent())) {
|
||||
return null;
|
||||
}
|
||||
return tank.drain(resource.amount, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
|
||||
{
|
||||
return new ReagentContainerInfo[]{tank.getInfo()};
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from) {
|
||||
return new ReagentContainerInfo[] {tank.getInfo()};
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
-97
@@ -1,46 +1,38 @@
|
||||
|
||||
package WayofTime.alchemicalWizardry.api.alchemy.energy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class TileSegmentedReagentHandler extends TileEntity implements ISegmentedReagentHandler
|
||||
{
|
||||
public class TileSegmentedReagentHandler extends TileEntity implements ISegmentedReagentHandler {
|
||||
protected ReagentContainer[] tanks;
|
||||
protected Map<Reagent, Integer> attunedTankMap;
|
||||
|
||||
public TileSegmentedReagentHandler()
|
||||
{
|
||||
public TileSegmentedReagentHandler() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public TileSegmentedReagentHandler(int numberOfTanks)
|
||||
{
|
||||
public TileSegmentedReagentHandler(int numberOfTanks) {
|
||||
this(numberOfTanks, 1000);
|
||||
}
|
||||
|
||||
public TileSegmentedReagentHandler(int numberOfTanks, int tankSize)
|
||||
{
|
||||
public TileSegmentedReagentHandler(int numberOfTanks, int tankSize) {
|
||||
super();
|
||||
|
||||
this.attunedTankMap = new HashMap();
|
||||
this.tanks = new ReagentContainer[numberOfTanks];
|
||||
for (int i = 0; i < numberOfTanks; i++)
|
||||
{
|
||||
for (int i = 0; i < numberOfTanks; i++) {
|
||||
this.tanks[i] = new ReagentContainer(tankSize);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
|
||||
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
|
||||
@@ -48,16 +40,14 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
int size = tagList.tagCount();
|
||||
this.tanks = new ReagentContainer[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int i = 0; i < size; i++) {
|
||||
NBTTagCompound savedTag = tagList.getCompoundTagAt(i);
|
||||
this.tanks[i] = ReagentContainer.readFromNBT(savedTag);
|
||||
}
|
||||
|
||||
NBTTagList attunedTagList = tag.getTagList("attunedTankMap", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < attunedTagList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < attunedTagList.tagCount(); i++) {
|
||||
NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
|
||||
Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
|
||||
this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
|
||||
@@ -65,17 +55,14 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < this.tanks.length; i++)
|
||||
{
|
||||
for (int i = 0; i < this.tanks.length; i++) {
|
||||
NBTTagCompound savedTag = new NBTTagCompound();
|
||||
if (this.tanks[i] != null)
|
||||
{
|
||||
if (this.tanks[i] != null) {
|
||||
this.tanks[i].writeToNBT(savedTag);
|
||||
}
|
||||
tagList.appendTag(savedTag);
|
||||
@@ -85,8 +72,7 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
|
||||
NBTTagList attunedTagList = new NBTTagList();
|
||||
|
||||
for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet())
|
||||
{
|
||||
for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet()) {
|
||||
NBTTagCompound savedTag = new NBTTagCompound();
|
||||
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
|
||||
savedTag.setInteger("amount", entry.getValue());
|
||||
@@ -98,64 +84,55 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
|
||||
/* ISegmentedReagentHandler */
|
||||
@Override
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
|
||||
{
|
||||
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill) {
|
||||
int totalFill = 0;
|
||||
|
||||
boolean useTankLimit = !this.attunedTankMap.isEmpty();
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
if (resource != null) {
|
||||
int totalTanksFillable = useTankLimit ? this.getTanksTunedToReagent(resource.reagent) : this.tanks.length;
|
||||
int tanksFilled = 0;
|
||||
|
||||
int maxFill = resource.amount;
|
||||
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--)
|
||||
{
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--) {
|
||||
ReagentStack remainingStack = resource.copy();
|
||||
remainingStack.amount = maxFill - totalFill;
|
||||
|
||||
boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack);
|
||||
boolean doesReagentMatch = tanks[i].getReagent() == null
|
||||
? false
|
||||
: tanks[i].getReagent().isReagentEqual(remainingStack);
|
||||
|
||||
if (doesReagentMatch)
|
||||
{
|
||||
if (doesReagentMatch) {
|
||||
totalFill += tanks[i].fill(remainingStack, doFill);
|
||||
tanksFilled++;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) {
|
||||
return totalFill;
|
||||
}
|
||||
}
|
||||
|
||||
if (tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
if (tanksFilled >= totalTanksFillable) {
|
||||
return totalFill;
|
||||
}
|
||||
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--)
|
||||
{
|
||||
for (int i = this.tanks.length - 1; i >= 0; i--) {
|
||||
ReagentStack remainingStack = resource.copy();
|
||||
remainingStack.amount = maxFill - totalFill;
|
||||
|
||||
boolean isTankEmpty = tanks[i].getReagent() == null;
|
||||
|
||||
if (isTankEmpty)
|
||||
{
|
||||
if (isTankEmpty) {
|
||||
totalFill += tanks[i].fill(remainingStack, doFill);
|
||||
tanksFilled++;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
|
||||
{
|
||||
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable) {
|
||||
return totalFill;
|
||||
}
|
||||
}
|
||||
@@ -164,10 +141,8 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
|
||||
{
|
||||
if (resource == null)
|
||||
{
|
||||
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain) {
|
||||
if (resource == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -175,18 +150,14 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
Reagent reagent = resource.reagent;
|
||||
int drained = 0;
|
||||
|
||||
for (int i = 0; i < tanks.length; i++)
|
||||
{
|
||||
if (drained >= maxDrain)
|
||||
{
|
||||
for (int i = 0; i < tanks.length; i++) {
|
||||
if (drained >= maxDrain) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (resource.isReagentEqual(tanks[i].getReagent()))
|
||||
{
|
||||
if (resource.isReagentEqual(tanks[i].getReagent())) {
|
||||
ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
|
||||
if (drainStack != null)
|
||||
{
|
||||
if (drainStack != null) {
|
||||
drained += drainStack.amount;
|
||||
}
|
||||
}
|
||||
@@ -197,13 +168,10 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
|
||||
/* Only returns the amount from the first available tank */
|
||||
@Override
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
for (int i = 0; i < tanks.length; i++)
|
||||
{
|
||||
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
for (int i = 0; i < tanks.length; i++) {
|
||||
ReagentStack stack = tanks[i].drain(maxDrain, doDrain);
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack != null) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -212,49 +180,40 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
public boolean canFill(ForgeDirection from, Reagent reagent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent)
|
||||
{
|
||||
public boolean canDrain(ForgeDirection from, Reagent reagent) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
|
||||
{
|
||||
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from) {
|
||||
ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()];
|
||||
for (int i = 0; i < this.getNumberOfTanks(); i++)
|
||||
{
|
||||
for (int i = 0; i < this.getNumberOfTanks(); i++) {
|
||||
info[i] = tanks[i].getInfo();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfTanks()
|
||||
{
|
||||
public int getNumberOfTanks() {
|
||||
return tanks.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTanksTunedToReagent(Reagent reagent)
|
||||
{
|
||||
if (this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null)
|
||||
{
|
||||
public int getTanksTunedToReagent(Reagent reagent) {
|
||||
if (this.attunedTankMap.containsKey(reagent) && this.attunedTankMap.get(reagent) != null) {
|
||||
return this.attunedTankMap.get(reagent);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTanksTunedToReagent(Reagent reagent, int total)
|
||||
{
|
||||
if (total == 0 && this.attunedTankMap.containsKey(reagent))
|
||||
{
|
||||
public void setTanksTunedToReagent(Reagent reagent, int total) {
|
||||
if (total == 0 && this.attunedTankMap.containsKey(reagent)) {
|
||||
this.attunedTankMap.remove(reagent);
|
||||
return;
|
||||
}
|
||||
@@ -263,21 +222,17 @@ public class TileSegmentedReagentHandler extends TileEntity implements ISegmente
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Reagent, Integer> getAttunedTankMap()
|
||||
{
|
||||
public Map<Reagent, Integer> getAttunedTankMap() {
|
||||
return this.attunedTankMap;
|
||||
}
|
||||
|
||||
public boolean areTanksEmpty()
|
||||
{
|
||||
for (int i = 0; i < this.tanks.length; i++)
|
||||
{
|
||||
if (tanks[i] != null && tanks[i].reagentStack != null)
|
||||
{
|
||||
public boolean areTanksEmpty() {
|
||||
for (int i = 0; i < this.tanks.length; i++) {
|
||||
if (tanks[i] != null && tanks[i].reagentStack != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+75
-82
@@ -2,16 +2,14 @@ package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class AltarRecipe
|
||||
{
|
||||
public class AltarRecipe {
|
||||
public int minTier;
|
||||
public int liquidRequired;
|
||||
public boolean canBeFilled; //Tells the system that the item is an orb
|
||||
public boolean canBeFilled; // Tells the system that the item is an orb
|
||||
public int consumptionRate;
|
||||
public int drainRate;
|
||||
public ItemStack requiredItem;
|
||||
@@ -19,14 +17,27 @@ public class AltarRecipe
|
||||
public boolean useTag;
|
||||
public ArrayList<Object> input = new ArrayList<Object>();
|
||||
|
||||
public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
public AltarRecipe(
|
||||
ItemStack result,
|
||||
ItemStack requiredItem,
|
||||
int minTier,
|
||||
int liquidRequired,
|
||||
int consumptionRate,
|
||||
int drainRate,
|
||||
boolean canBeFilled) {
|
||||
this(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled, false);
|
||||
}
|
||||
|
||||
public AltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled, boolean useTag)
|
||||
{
|
||||
this.result = result;
|
||||
|
||||
public AltarRecipe(
|
||||
ItemStack result,
|
||||
ItemStack requiredItem,
|
||||
int minTier,
|
||||
int liquidRequired,
|
||||
int consumptionRate,
|
||||
int drainRate,
|
||||
boolean canBeFilled,
|
||||
boolean useTag) {
|
||||
this.result = result;
|
||||
this.requiredItem = requiredItem;
|
||||
this.minTier = minTier;
|
||||
this.liquidRequired = liquidRequired;
|
||||
@@ -36,101 +47,83 @@ public class AltarRecipe
|
||||
this.useTag = useTag;
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
public ItemStack getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public ItemStack getRequiredItem()
|
||||
{
|
||||
public ItemStack getRequiredItem() {
|
||||
return this.requiredItem;
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, int tierCheck)
|
||||
{
|
||||
if (comparedStack == null || this.requiredItem == null)
|
||||
{
|
||||
public boolean doesRequiredItemMatch(ItemStack comparedStack, int tierCheck) {
|
||||
if (comparedStack == null || this.requiredItem == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tierCheck >= minTier && this.requiredItem.isItemEqual(comparedStack) && (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
|
||||
}
|
||||
|
||||
public boolean areRequiredTagsEqual(ItemStack comparedStack)
|
||||
{
|
||||
if(requiredItem.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = requiredItem.getTagCompound();
|
||||
if(!comparedStack.hasTagCompound())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NBTTagCompound comparedTag = comparedStack.getTagCompound();
|
||||
|
||||
return this.areTagsEqual(tag, comparedTag);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean areTagsEqual(NBTTagCompound tag, NBTTagCompound comparedTag)
|
||||
{
|
||||
Set set = tag.func_150296_c();
|
||||
|
||||
for(Object obj : set)
|
||||
{
|
||||
if(obj instanceof String)
|
||||
{
|
||||
String str = (String)obj;
|
||||
|
||||
NBTBase baseTag = comparedTag.getTag(str);
|
||||
|
||||
if(baseTag instanceof NBTTagCompound)
|
||||
{
|
||||
NBTBase comparedBaseTag = comparedTag.getTag(str);
|
||||
if(comparedBaseTag instanceof NBTTagCompound)
|
||||
{
|
||||
if(!this.areTagsEqual(tag, comparedTag))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(baseTag != null && !baseTag.equals(comparedTag.getTag(str)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return tierCheck >= minTier
|
||||
&& this.requiredItem.isItemEqual(comparedStack)
|
||||
&& (this.useTag ? this.areRequiredTagsEqual(comparedStack) : true);
|
||||
}
|
||||
|
||||
public int getMinTier()
|
||||
{
|
||||
public boolean areRequiredTagsEqual(ItemStack comparedStack) {
|
||||
if (requiredItem.hasTagCompound()) {
|
||||
NBTTagCompound tag = requiredItem.getTagCompound();
|
||||
if (!comparedStack.hasTagCompound()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NBTTagCompound comparedTag = comparedStack.getTagCompound();
|
||||
|
||||
return this.areTagsEqual(tag, comparedTag);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean areTagsEqual(NBTTagCompound tag, NBTTagCompound comparedTag) {
|
||||
Set set = tag.func_150296_c();
|
||||
|
||||
for (Object obj : set) {
|
||||
if (obj instanceof String) {
|
||||
String str = (String) obj;
|
||||
|
||||
NBTBase baseTag = comparedTag.getTag(str);
|
||||
|
||||
if (baseTag instanceof NBTTagCompound) {
|
||||
NBTBase comparedBaseTag = comparedTag.getTag(str);
|
||||
if (comparedBaseTag instanceof NBTTagCompound) {
|
||||
if (!this.areTagsEqual(tag, comparedTag)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (baseTag != null && !baseTag.equals(comparedTag.getTag(str))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMinTier() {
|
||||
return this.minTier;
|
||||
}
|
||||
|
||||
public int getLiquidRequired()
|
||||
{
|
||||
public int getLiquidRequired() {
|
||||
return this.liquidRequired;
|
||||
}
|
||||
|
||||
public int getConsumptionRate()
|
||||
{
|
||||
public int getConsumptionRate() {
|
||||
return this.consumptionRate;
|
||||
}
|
||||
|
||||
public int getDrainRate()
|
||||
{
|
||||
public int getDrainRate() {
|
||||
return this.drainRate;
|
||||
}
|
||||
|
||||
public boolean getCanBeFilled()
|
||||
{
|
||||
public boolean getCanBeFilled() {
|
||||
return this.canBeFilled;
|
||||
}
|
||||
}
|
||||
+40
-40
@@ -4,44 +4,50 @@ 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 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)
|
||||
{
|
||||
altarRecipes.add(new AltarRecipe(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled));
|
||||
}
|
||||
|
||||
public static void registerNBTAltarRecipe(ItemStack result, ItemStack requiredItem, int minTier, int liquidRequired, int consumptionRate, int drainRate, boolean canBeFilled)
|
||||
{
|
||||
altarRecipes.add(new AltarRecipe(result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled, true));
|
||||
public static void registerAltarRecipe(
|
||||
ItemStack result,
|
||||
ItemStack requiredItem,
|
||||
int minTier,
|
||||
int liquidRequired,
|
||||
int consumptionRate,
|
||||
int drainRate,
|
||||
boolean canBeFilled) {
|
||||
altarRecipes.add(new AltarRecipe(
|
||||
result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled));
|
||||
}
|
||||
|
||||
public static void registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
|
||||
{
|
||||
if(!orbMap.containsKey(minTier))
|
||||
{
|
||||
orbMap.put(minTier, orbStack);
|
||||
}
|
||||
public static void registerNBTAltarRecipe(
|
||||
ItemStack result,
|
||||
ItemStack requiredItem,
|
||||
int minTier,
|
||||
int liquidRequired,
|
||||
int consumptionRate,
|
||||
int drainRate,
|
||||
boolean canBeFilled) {
|
||||
altarRecipes.add(new AltarRecipe(
|
||||
result, requiredItem, minTier, liquidRequired, consumptionRate, drainRate, canBeFilled, true));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean isRequiredItemValid(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
if(testItem == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
public static boolean isRequiredItemValid(ItemStack testItem, int currentTierAltar) {
|
||||
if (testItem == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AltarRecipe recipe : altarRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -49,12 +55,9 @@ public class AltarRecipeRegistry
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem, int currentTierAltar) {
|
||||
for (AltarRecipe recipe : altarRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar)) {
|
||||
return ItemStack.copyItemStack(recipe.getResult());
|
||||
}
|
||||
}
|
||||
@@ -62,12 +65,9 @@ public class AltarRecipeRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AltarRecipe getAltarRecipeForItemAndTier(ItemStack testItem, int currentTierAltar)
|
||||
{
|
||||
for (AltarRecipe recipe : altarRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
|
||||
{
|
||||
public static AltarRecipe getAltarRecipeForItemAndTier(ItemStack testItem, int currentTierAltar) {
|
||||
for (AltarRecipe recipe : altarRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
|
||||
|
||||
public interface IFadedRune
|
||||
{
|
||||
int getAltarTierLimit(int meta);
|
||||
public interface IFadedRune {
|
||||
int getAltarTierLimit(int meta);
|
||||
}
|
||||
@@ -2,29 +2,24 @@ package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BindingRecipe
|
||||
{
|
||||
public class BindingRecipe {
|
||||
public ItemStack requiredItem;
|
||||
public ItemStack outputItem;
|
||||
|
||||
public BindingRecipe(ItemStack outputItem, ItemStack requiredItem)
|
||||
{
|
||||
public BindingRecipe(ItemStack outputItem, ItemStack requiredItem) {
|
||||
this.requiredItem = requiredItem;
|
||||
this.outputItem = outputItem;
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack testStack)
|
||||
{
|
||||
public boolean doesRequiredItemMatch(ItemStack testStack) {
|
||||
return !(testStack == null || this.requiredItem == null) && this.requiredItem.isItemEqual(testStack);
|
||||
}
|
||||
|
||||
public ItemStack getResult(ItemStack inputItem)
|
||||
{
|
||||
public ItemStack getResult(ItemStack inputItem) {
|
||||
return this.getResult();
|
||||
}
|
||||
|
||||
public ItemStack getResult()
|
||||
{
|
||||
public ItemStack getResult() {
|
||||
return this.outputItem;
|
||||
}
|
||||
}
|
||||
+14
-28
@@ -1,25 +1,19 @@
|
||||
package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class BindingRegistry
|
||||
{
|
||||
public class BindingRegistry {
|
||||
public static List<BindingRecipe> bindingRecipes = new LinkedList();
|
||||
|
||||
public static void registerRecipe(ItemStack output, ItemStack input)
|
||||
{
|
||||
public static void registerRecipe(ItemStack output, ItemStack input) {
|
||||
bindingRecipes.add(new BindingRecipe(output, input));
|
||||
}
|
||||
|
||||
public static boolean isRequiredItemValid(ItemStack testItem)
|
||||
{
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
public static boolean isRequiredItemValid(ItemStack testItem) {
|
||||
for (BindingRecipe recipe : bindingRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,12 +21,9 @@ public class BindingRegistry
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem)
|
||||
{
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
public static ItemStack getItemForItemAndTier(ItemStack testItem) {
|
||||
for (BindingRecipe recipe : bindingRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem)) {
|
||||
return recipe.getResult(testItem).copy();
|
||||
}
|
||||
}
|
||||
@@ -40,13 +31,10 @@ public class BindingRegistry
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getIndexForItem(ItemStack testItem)
|
||||
{
|
||||
public static int getIndexForItem(ItemStack testItem) {
|
||||
int i = 0;
|
||||
for (BindingRecipe recipe : bindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
for (BindingRecipe recipe : bindingRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem)) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
@@ -55,10 +43,8 @@ public class BindingRegistry
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static ItemStack getOutputForIndex(int index)
|
||||
{
|
||||
if (bindingRecipes.size() <= index)
|
||||
{
|
||||
public static ItemStack getOutputForIndex(int index) {
|
||||
if (bindingRecipes.size() <= index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+6
-12
@@ -1,36 +1,30 @@
|
||||
package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class UnbindingRecipe
|
||||
{
|
||||
public class UnbindingRecipe {
|
||||
public ItemStack requiredItem;
|
||||
public List<ItemStack> outputItem;
|
||||
|
||||
public UnbindingRecipe(ItemStack inputItem, List<ItemStack> outputItem)
|
||||
{
|
||||
public UnbindingRecipe(ItemStack inputItem, List<ItemStack> outputItem) {
|
||||
this.requiredItem = inputItem;
|
||||
this.outputItem = outputItem;
|
||||
}
|
||||
|
||||
public UnbindingRecipe(ItemStack inputItem, ItemStack outputItem)
|
||||
{
|
||||
public UnbindingRecipe(ItemStack inputItem, ItemStack outputItem) {
|
||||
this.requiredItem = inputItem;
|
||||
List<ItemStack> newList = new ArrayList<ItemStack>();
|
||||
newList.add(outputItem);
|
||||
this.outputItem = newList;
|
||||
}
|
||||
|
||||
public boolean doesRequiredItemMatch(ItemStack testStack)
|
||||
{
|
||||
public boolean doesRequiredItemMatch(ItemStack testStack) {
|
||||
return !(testStack == null || this.requiredItem == null) && this.requiredItem.isItemEqual(testStack);
|
||||
}
|
||||
|
||||
public List<ItemStack> getResult()
|
||||
{
|
||||
public List<ItemStack> getResult() {
|
||||
return this.outputItem;
|
||||
}
|
||||
}
|
||||
+17
-32
@@ -1,48 +1,38 @@
|
||||
package WayofTime.alchemicalWizardry.api.bindingRegistry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class UnbindingRegistry
|
||||
{
|
||||
public class UnbindingRegistry {
|
||||
public static List<UnbindingRecipe> unbindingRecipes = new LinkedList<UnbindingRecipe>();
|
||||
|
||||
public static void addAllUnbindingRecipesFromBinding()
|
||||
{
|
||||
for (BindingRecipe bindingRecipe : BindingRegistry.bindingRecipes)
|
||||
{
|
||||
public static void addAllUnbindingRecipesFromBinding() {
|
||||
for (BindingRecipe bindingRecipe : BindingRegistry.bindingRecipes) {
|
||||
List<ItemStack> subList = new ArrayList<ItemStack>();
|
||||
subList.add(bindingRecipe.requiredItem);
|
||||
unbindingRecipes.add(new UnbindingRecipe(bindingRecipe.outputItem, subList));
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerRecipe(ItemStack input, List<ItemStack> output)
|
||||
{
|
||||
public static void registerRecipe(ItemStack input, List<ItemStack> output) {
|
||||
unbindingRecipes.add(new UnbindingRecipe(input, output));
|
||||
}
|
||||
|
||||
public static void registerRecipe(Item input, List<ItemStack> output)
|
||||
{
|
||||
public static void registerRecipe(Item input, List<ItemStack> output) {
|
||||
unbindingRecipes.add(new UnbindingRecipe(new ItemStack(input), output));
|
||||
}
|
||||
|
||||
public static void registerRecipe(Block input, List<ItemStack> output)
|
||||
{
|
||||
public static void registerRecipe(Block input, List<ItemStack> output) {
|
||||
unbindingRecipes.add(new UnbindingRecipe(new ItemStack(input), output));
|
||||
}
|
||||
|
||||
public static boolean isRequiredItemValid(ItemStack testItem)
|
||||
{
|
||||
for (UnbindingRecipe recipe : unbindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
public static boolean isRequiredItemValid(ItemStack testItem) {
|
||||
for (UnbindingRecipe recipe : unbindingRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -50,13 +40,10 @@ public class UnbindingRegistry
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getIndexForItem(ItemStack testItem)
|
||||
{
|
||||
public static int getIndexForItem(ItemStack testItem) {
|
||||
int i = 0;
|
||||
for (UnbindingRecipe recipe : unbindingRecipes)
|
||||
{
|
||||
if (recipe.doesRequiredItemMatch(testItem))
|
||||
{
|
||||
for (UnbindingRecipe recipe : unbindingRecipes) {
|
||||
if (recipe.doesRequiredItemMatch(testItem)) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
@@ -65,10 +52,8 @@ public class UnbindingRegistry
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getOutputForIndex(int index)
|
||||
{
|
||||
if (unbindingRecipes.size() <= index)
|
||||
{
|
||||
public static List<ItemStack> getOutputForIndex(int index) {
|
||||
if (unbindingRecipes.size() <= index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.command;
|
||||
|
||||
import java.util.Locale;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.PlayerNotFoundException;
|
||||
@@ -11,8 +12,6 @@ import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class SubCommandBase implements ISubCommand {
|
||||
|
||||
private ICommand parent;
|
||||
@@ -42,31 +41,37 @@ public abstract class SubCommandBase implements ISubCommand {
|
||||
public void processSubCommand(ICommandSender commandSender, String[] args) {
|
||||
|
||||
if (args.length == 0 && !getSubCommandName().equals("help"))
|
||||
displayErrorString(commandSender, String.format(StatCollector.translateToLocal("commands.format.error"), capitalizeFirstLetter(getSubCommandName()), getArgUsage(commandSender)));
|
||||
displayErrorString(
|
||||
commandSender,
|
||||
String.format(
|
||||
StatCollector.translateToLocal("commands.format.error"),
|
||||
capitalizeFirstLetter(getSubCommandName()),
|
||||
getArgUsage(commandSender)));
|
||||
|
||||
if (isBounded(0, 2, args.length) && args[0].equals("help"))
|
||||
displayHelpString(commandSender, String.format(StatCollector.translateToLocal("commands.format.help"), capitalizeFirstLetter(getSubCommandName()), getHelpText()));
|
||||
displayHelpString(
|
||||
commandSender,
|
||||
String.format(
|
||||
StatCollector.translateToLocal("commands.format.help"),
|
||||
capitalizeFirstLetter(getSubCommandName()),
|
||||
getHelpText()));
|
||||
}
|
||||
|
||||
protected EntityPlayerMP getCommandSenderAsPlayer(ICommandSender commandSender) {
|
||||
if (commandSender instanceof EntityPlayerMP)
|
||||
return (EntityPlayerMP)commandSender;
|
||||
else
|
||||
throw new PlayerNotFoundException(StatCollector.translateToLocal("commands.error.arg.player.missing"));
|
||||
if (commandSender instanceof EntityPlayerMP) return (EntityPlayerMP) commandSender;
|
||||
else throw new PlayerNotFoundException(StatCollector.translateToLocal("commands.error.arg.player.missing"));
|
||||
}
|
||||
|
||||
protected EntityPlayerMP getPlayer(ICommandSender commandSender, String playerName) {
|
||||
EntityPlayerMP entityplayermp = PlayerSelector.matchOnePlayer(commandSender, playerName);
|
||||
|
||||
if (entityplayermp != null)
|
||||
return entityplayermp;
|
||||
if (entityplayermp != null) return entityplayermp;
|
||||
else {
|
||||
entityplayermp = MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
|
||||
entityplayermp =
|
||||
MinecraftServer.getServer().getConfigurationManager().func_152612_a(playerName);
|
||||
|
||||
if (entityplayermp == null)
|
||||
throw new PlayerNotFoundException();
|
||||
else
|
||||
return entityplayermp;
|
||||
if (entityplayermp == null) throw new PlayerNotFoundException();
|
||||
else return entityplayermp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,15 +83,18 @@ public abstract class SubCommandBase implements ISubCommand {
|
||||
return given > low && given < high;
|
||||
}
|
||||
|
||||
protected void displayHelpString(ICommandSender commandSender, String display, Object ... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
|
||||
protected void displayHelpString(ICommandSender commandSender, String display, Object... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info))
|
||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)));
|
||||
}
|
||||
|
||||
protected void displayErrorString(ICommandSender commandSender, String display, Object ... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
protected void displayErrorString(ICommandSender commandSender, String display, Object... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info))
|
||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED)));
|
||||
}
|
||||
|
||||
protected void displaySuccessString(ICommandSender commandSender, String display, Object ... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.BLUE)));
|
||||
protected void displaySuccessString(ICommandSender commandSender, String display, Object... info) {
|
||||
commandSender.addChatMessage(new ChatComponentText(StatCollector.translateToLocalFormatted(display, info))
|
||||
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.BLUE)));
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,11 @@ 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);
|
||||
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);
|
||||
}
|
||||
@@ -5,7 +5,6 @@ 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;
|
||||
|
||||
@@ -13,55 +12,48 @@ 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, 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()));
|
||||
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, 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()));
|
||||
}
|
||||
}
|
||||
@@ -4,35 +4,31 @@ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
@Cancelable
|
||||
public class AddToNetworkEvent extends Event
|
||||
{
|
||||
public String ownerNetwork;
|
||||
public int addedAmount;
|
||||
public int maximum;
|
||||
|
||||
/**
|
||||
* This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY,
|
||||
* the LP will still be drained but the soul network will not be added to.
|
||||
*
|
||||
* @param ownerNetwork Key used for the soul network
|
||||
* @param addedAmount Amount added
|
||||
* @param maximum Ceiling that the network can add to
|
||||
*/
|
||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum)
|
||||
{
|
||||
super();
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.addedAmount = addedAmount;
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
public String getOwnerNetwork()
|
||||
{
|
||||
return this.ownerNetwork;
|
||||
}
|
||||
|
||||
public int getAddedAmount()
|
||||
{
|
||||
return this.addedAmount;
|
||||
}
|
||||
public class AddToNetworkEvent extends Event {
|
||||
public String ownerNetwork;
|
||||
public int addedAmount;
|
||||
public int maximum;
|
||||
|
||||
/**
|
||||
* This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY,
|
||||
* the LP will still be drained but the soul network will not be added to.
|
||||
*
|
||||
* @param ownerNetwork Key used for the soul network
|
||||
* @param addedAmount Amount added
|
||||
* @param maximum Ceiling that the network can add to
|
||||
*/
|
||||
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) {
|
||||
super();
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.addedAmount = addedAmount;
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
public String getOwnerNetwork() {
|
||||
return this.ownerNetwork;
|
||||
}
|
||||
|
||||
public int getAddedAmount() {
|
||||
return this.addedAmount;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
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;
|
||||
public String key;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack)
|
||||
{
|
||||
super();
|
||||
this.player = player;
|
||||
this.key = key;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
public class ItemBindEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public String key;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public ItemBindEvent(EntityPlayer player, String key, ItemStack itemStack) {
|
||||
super();
|
||||
this.player = player;
|
||||
this.key = key;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Cancelable
|
||||
public class ItemDrainInContainerEvent extends SoulNetworkEvent
|
||||
{
|
||||
public ItemStack stack;
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerNetwork, int drainAmount)
|
||||
{
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.stack = stack;
|
||||
}
|
||||
public class ItemDrainInContainerEvent extends SoulNetworkEvent {
|
||||
public ItemStack stack;
|
||||
|
||||
public ItemDrainInContainerEvent(ItemStack stack, String ownerNetwork, int drainAmount) {
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.stack = stack;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,27 @@
|
||||
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.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent
|
||||
{
|
||||
public final ItemStack itemStack;
|
||||
public boolean shouldDamage; //If true, will damage regardless of if the network had enough inside it
|
||||
public float damageAmount; //Amount of damage that would incur if the network could not drain properly
|
||||
|
||||
/**
|
||||
* Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties
|
||||
*
|
||||
* @param player Player using the item
|
||||
* @param ownerNetwork Network that the item is tied to
|
||||
* @param itemStack Item used
|
||||
* @param drainAmount Original drain amount - change to alter cost
|
||||
*/
|
||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount)
|
||||
{
|
||||
super(player, ownerNetwork, drainAmount);
|
||||
this.itemStack = itemStack;
|
||||
this.shouldDamage = false;
|
||||
this.damageAmount = (float)(drainAmount) / 100.0f;
|
||||
}
|
||||
}
|
||||
public class ItemDrainNetworkEvent extends PlayerDrainNetworkEvent {
|
||||
public final ItemStack itemStack;
|
||||
public boolean shouldDamage; // If true, will damage regardless of if the network had enough inside it
|
||||
public float damageAmount; // Amount of damage that would incur if the network could not drain properly
|
||||
|
||||
/**
|
||||
* Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties
|
||||
*
|
||||
* @param player Player using the item
|
||||
* @param ownerNetwork Network that the item is tied to
|
||||
* @param itemStack Item used
|
||||
* @param drainAmount Original drain amount - change to alter cost
|
||||
*/
|
||||
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount) {
|
||||
super(player, ownerNetwork, drainAmount);
|
||||
this.itemStack = itemStack;
|
||||
this.shouldDamage = false;
|
||||
this.damageAmount = (float) (drainAmount) / 100.0f;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
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.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class PlayerAddToNetworkEvent extends AddToNetworkEvent
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
public ItemStack itemStack;
|
||||
public PlayerAddToNetworkEvent(EntityPlayer player, ItemStack itemStack, String ownerNetwork, int addedAmount, int maximum)
|
||||
{
|
||||
super(ownerNetwork, addedAmount, maximum);
|
||||
this.player = player;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
public class PlayerAddToNetworkEvent extends AddToNetworkEvent {
|
||||
public final EntityPlayer player;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public PlayerAddToNetworkEvent(
|
||||
EntityPlayer player, ItemStack itemStack, String ownerNetwork, int addedAmount, int maximum) {
|
||||
super(ownerNetwork, addedAmount, maximum);
|
||||
this.player = player;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,18 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@Cancelable
|
||||
public class PlayerDrainNetworkEvent extends SoulNetworkEvent
|
||||
{
|
||||
public final EntityPlayer player; //Player that activated the event
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount)
|
||||
{
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer()
|
||||
{
|
||||
return player;
|
||||
}
|
||||
public class PlayerDrainNetworkEvent extends SoulNetworkEvent {
|
||||
public final EntityPlayer player; // Player that activated the event
|
||||
|
||||
public PlayerDrainNetworkEvent(EntityPlayer player, String ownerNetwork, int drainAmount) {
|
||||
super(ownerNetwork, drainAmount);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public EntityPlayer getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,27 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Cancelable
|
||||
public class RitualActivatedEvent extends RitualEvent
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack crystalStack;
|
||||
public int crystalTier;
|
||||
|
||||
public RitualActivatedEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, EntityPlayer player, ItemStack activationCrystal, int crystalTier)
|
||||
{
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
|
||||
this.player = player;
|
||||
this.crystalStack = activationCrystal;
|
||||
this.crystalTier = crystalTier;
|
||||
}
|
||||
public class RitualActivatedEvent extends RitualEvent {
|
||||
public final EntityPlayer player;
|
||||
public final ItemStack crystalStack;
|
||||
public int crystalTier;
|
||||
|
||||
public RitualActivatedEvent(
|
||||
IMasterRitualStone mrs,
|
||||
String ownerKey,
|
||||
String ritualKey,
|
||||
EntityPlayer player,
|
||||
ItemStack activationCrystal,
|
||||
int crystalTier) {
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
|
||||
this.player = player;
|
||||
this.crystalStack = activationCrystal;
|
||||
this.crystalTier = crystalTier;
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,14 @@ package WayofTime.alchemicalWizardry.api.event;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class RitualEvent extends Event
|
||||
{
|
||||
public final IMasterRitualStone mrs;
|
||||
public String ownerKey;
|
||||
public final String ritualKey;
|
||||
|
||||
public RitualEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey)
|
||||
{
|
||||
this.mrs = mrs;
|
||||
this.ownerKey = ownerKey;
|
||||
this.ritualKey = ritualKey;
|
||||
}
|
||||
public class RitualEvent extends Event {
|
||||
public final IMasterRitualStone mrs;
|
||||
public String ownerKey;
|
||||
public final String ritualKey;
|
||||
|
||||
public RitualEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey) {
|
||||
this.mrs = mrs;
|
||||
this.ownerKey = ownerKey;
|
||||
this.ritualKey = ritualKey;
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,9 @@ import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
|
||||
@Cancelable
|
||||
public class RitualRunEvent extends RitualEvent
|
||||
{
|
||||
|
||||
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey)
|
||||
{
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
}
|
||||
public class RitualRunEvent extends RitualEvent {
|
||||
|
||||
public RitualRunEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey) {
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,12 @@ package WayofTime.alchemicalWizardry.api.event;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualBreakMethod;
|
||||
|
||||
public class RitualStopEvent extends RitualEvent
|
||||
{
|
||||
public final RitualBreakMethod method;
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, RitualBreakMethod method)
|
||||
{
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
|
||||
this.method = method;
|
||||
}
|
||||
public class RitualStopEvent extends RitualEvent {
|
||||
public final RitualBreakMethod method;
|
||||
|
||||
public RitualStopEvent(IMasterRitualStone mrs, String ownerKey, String ritualKey, RitualBreakMethod method) {
|
||||
super(mrs, ownerKey, ritualKey);
|
||||
|
||||
this.method = method;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,20 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
@Cancelable
|
||||
public class SacrificeKnifeUsedEvent extends Event
|
||||
{
|
||||
public final EntityPlayer player;
|
||||
public boolean shouldDrainHealth;
|
||||
public boolean shouldFillAltar;
|
||||
public final int healthDrained;
|
||||
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp)
|
||||
{
|
||||
this.player = player;
|
||||
this.shouldDrainHealth = shouldDrainHealth;
|
||||
this.shouldFillAltar = shouldFillAltar;
|
||||
this.healthDrained = hp;
|
||||
}
|
||||
public class SacrificeKnifeUsedEvent extends Event {
|
||||
public final EntityPlayer player;
|
||||
public boolean shouldDrainHealth;
|
||||
public boolean shouldFillAltar;
|
||||
public final int healthDrained;
|
||||
|
||||
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) {
|
||||
this.player = player;
|
||||
this.shouldDrainHealth = shouldDrainHealth;
|
||||
this.shouldFillAltar = shouldFillAltar;
|
||||
this.healthDrained = hp;
|
||||
}
|
||||
}
|
||||
@@ -2,25 +2,21 @@ package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class SoulNetworkEvent extends Event
|
||||
{
|
||||
public String ownerNetwork;
|
||||
public int drainAmount;
|
||||
|
||||
public SoulNetworkEvent(String ownerNetwork, int drainAmount)
|
||||
{
|
||||
super();
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.drainAmount = drainAmount;
|
||||
}
|
||||
|
||||
public String getOwnerNetwork()
|
||||
{
|
||||
return this.ownerNetwork;
|
||||
}
|
||||
|
||||
public int getDrainAmount()
|
||||
{
|
||||
return this.drainAmount;
|
||||
}
|
||||
public class SoulNetworkEvent extends Event {
|
||||
public String ownerNetwork;
|
||||
public int drainAmount;
|
||||
|
||||
public SoulNetworkEvent(String ownerNetwork, int drainAmount) {
|
||||
super();
|
||||
this.ownerNetwork = ownerNetwork;
|
||||
this.drainAmount = drainAmount;
|
||||
}
|
||||
|
||||
public String getOwnerNetwork() {
|
||||
return this.ownerNetwork;
|
||||
}
|
||||
|
||||
public int getDrainAmount() {
|
||||
return this.drainAmount;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
package WayofTime.alchemicalWizardry.api.event;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.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. */
|
||||
* 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api.guide;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
|
||||
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
@@ -20,41 +11,59 @@ import amerifrance.guideapi.api.base.Book;
|
||||
import amerifrance.guideapi.api.util.GuiHelper;
|
||||
import amerifrance.guideapi.gui.GuiBase;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class OrbRecipeRenderer implements IRecipeRenderer
|
||||
{
|
||||
public IRecipe recipe;
|
||||
|
||||
public OrbRecipeRenderer(IRecipe recipe)
|
||||
{
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Book book, CategoryAbstract category, EntryAbstract entry,
|
||||
int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase,
|
||||
FontRenderer fontRenderer) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(ModInformation.GUITEXLOC + "recipe_elements.png"));
|
||||
public class OrbRecipeRenderer implements IRecipeRenderer {
|
||||
public IRecipe recipe;
|
||||
|
||||
public OrbRecipeRenderer(IRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(
|
||||
Book book,
|
||||
CategoryAbstract category,
|
||||
EntryAbstract entry,
|
||||
int guiLeft,
|
||||
int guiTop,
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
GuiBase guiBase,
|
||||
FontRenderer fontRenderer) {
|
||||
Minecraft.getMinecraft()
|
||||
.getTextureManager()
|
||||
.bindTexture(new ResourceLocation(ModInformation.GUITEXLOC + "recipe_elements.png"));
|
||||
guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 105, 65);
|
||||
|
||||
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("text.recipe.shapedOrb"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0);
|
||||
if(recipe instanceof ShapelessBloodOrbRecipe)
|
||||
{
|
||||
ShapelessBloodOrbRecipe shapelessBloodOrbRecipe = (ShapelessBloodOrbRecipe) recipe;
|
||||
List<Object> list = shapelessBloodOrbRecipe.getInput();
|
||||
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
StatCollector.translateToLocal("text.recipe.shapedOrb"),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 12,
|
||||
0);
|
||||
if (recipe instanceof ShapelessBloodOrbRecipe) {
|
||||
ShapelessBloodOrbRecipe shapelessBloodOrbRecipe = (ShapelessBloodOrbRecipe) recipe;
|
||||
List<Object> list = shapelessBloodOrbRecipe.getInput();
|
||||
|
||||
int width = 3;
|
||||
int height = 3;
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
if(list.size() - 1 < y * width + x)
|
||||
{
|
||||
continue;
|
||||
if (list.size() - 1 < y * width + x) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int stackX = (x + 1) * 18 + (guiLeft + guiBase.xSize / 7);
|
||||
int stackY = (y + 1) * 18 + (guiTop + guiBase.ySize / 5);
|
||||
|
||||
|
||||
Object component = list.get(y * width + x);
|
||||
if (component != null) {
|
||||
if (component instanceof ItemStack) {
|
||||
@@ -65,7 +74,8 @@ public class OrbRecipeRenderer implements IRecipeRenderer
|
||||
} else if (component instanceof Integer) {
|
||||
GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
|
||||
guiBase.renderToolTip(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
guiBase.renderToolTip(
|
||||
APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
}
|
||||
} else {
|
||||
if (((ArrayList<ItemStack>) component).isEmpty()) return;
|
||||
@@ -83,8 +93,7 @@ public class OrbRecipeRenderer implements IRecipeRenderer
|
||||
if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) {
|
||||
guiBase.renderToolTip(shapelessBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
|
||||
}
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
ShapedBloodOrbRecipe shapedBloodOrbRecipe = (ShapedBloodOrbRecipe) recipe;
|
||||
int width = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 4);
|
||||
int height = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 5);
|
||||
@@ -102,7 +111,8 @@ public class OrbRecipeRenderer implements IRecipeRenderer
|
||||
} else if (component instanceof Integer) {
|
||||
GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
|
||||
guiBase.renderToolTip(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
guiBase.renderToolTip(
|
||||
APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
|
||||
}
|
||||
} else {
|
||||
if (((ArrayList<ItemStack>) component).isEmpty()) return;
|
||||
@@ -121,15 +131,20 @@ public class OrbRecipeRenderer implements IRecipeRenderer
|
||||
guiBase.renderToolTip(shapedBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Book book, CategoryAbstract category,
|
||||
EntryAbstract entry, int guiLeft, int guiTop, int mouseX,
|
||||
int mouseY, GuiBase guiBase, FontRenderer fontRenderer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public void drawExtras(
|
||||
Book book,
|
||||
CategoryAbstract category,
|
||||
EntryAbstract entry,
|
||||
int guiLeft,
|
||||
int guiTop,
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
GuiBase guiBase,
|
||||
FontRenderer fontRenderer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api.guide;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import WayofTime.alchemicalWizardry.api.altarRecipeRegistry.AltarRecipe;
|
||||
import amerifrance.guideapi.api.abstraction.CategoryAbstract;
|
||||
import amerifrance.guideapi.api.abstraction.EntryAbstract;
|
||||
@@ -17,6 +9,13 @@ import amerifrance.guideapi.api.util.GuiHelper;
|
||||
import amerifrance.guideapi.gui.GuiBase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class PageAltarRecipe extends PageBase {
|
||||
|
||||
@@ -34,15 +33,31 @@ public class PageAltarRecipe extends PageBase {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) {
|
||||
public void draw(
|
||||
Book book,
|
||||
CategoryAbstract category,
|
||||
EntryAbstract entry,
|
||||
int guiLeft,
|
||||
int guiTop,
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
GuiBase guiBase,
|
||||
FontRenderer fontRenderer) {
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("alchemicalwizardry" + ":textures/gui/guide/altar.png"));
|
||||
Minecraft.getMinecraft()
|
||||
.getTextureManager()
|
||||
.bindTexture(new ResourceLocation("alchemicalwizardry" + ":textures/gui/guide/altar.png"));
|
||||
guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 87, 146, 104);
|
||||
|
||||
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("text.recipe.altar"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
StatCollector.translateToLocal("text.recipe.altar"),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 12,
|
||||
0);
|
||||
|
||||
int inputX = (1 + 1) * 20 + (guiLeft + guiBase.xSize / 7) + 1;
|
||||
int inputY = (20) + (guiTop + guiBase.ySize / 5) - 1; //1 * 20
|
||||
int inputY = (20) + (guiTop + guiBase.ySize / 5) - 1; // 1 * 20
|
||||
GuiHelper.drawItemStack(input, inputX, inputY);
|
||||
if (GuiHelper.isMouseBetween(mouseX, mouseY, inputX, inputY, 15, 15)) {
|
||||
guiBase.renderToolTip(input, mouseX, mouseY);
|
||||
@@ -59,11 +74,38 @@ public class PageAltarRecipe extends PageBase {
|
||||
}
|
||||
|
||||
if (output.getItem() == Item.getItemFromBlock(Blocks.fire)) {
|
||||
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("text.furnace.error"), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0xED073D);
|
||||
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("bm.string.tier") + ": " + String.valueOf(tier), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 15, 0);
|
||||
guiBase.drawCenteredString(fontRenderer, "LP: " + String.valueOf(bloodRequired), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 30, 0);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
StatCollector.translateToLocal("text.furnace.error"),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 4 * guiBase.ySize / 6,
|
||||
0xED073D);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
StatCollector.translateToLocal("bm.string.tier") + ": " + String.valueOf(tier),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 4 * guiBase.ySize / 6 + 15,
|
||||
0);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
"LP: " + String.valueOf(bloodRequired),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 4 * guiBase.ySize / 6 + 30,
|
||||
0);
|
||||
}
|
||||
guiBase.drawCenteredString(fontRenderer, String.format(StatCollector.translateToLocal("text.recipe.altar.tier"), String.valueOf(tier)), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6, 0);
|
||||
guiBase.drawCenteredString(fontRenderer, String.format(StatCollector.translateToLocal("text.recipe.altar.bloodRequired"), String.valueOf(bloodRequired)), guiLeft + guiBase.xSize / 2, guiTop + 4 * guiBase.ySize / 6 + 15, 0);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
String.format(StatCollector.translateToLocal("text.recipe.altar.tier"), String.valueOf(tier)),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 4 * guiBase.ySize / 6,
|
||||
0);
|
||||
guiBase.drawCenteredString(
|
||||
fontRenderer,
|
||||
String.format(
|
||||
StatCollector.translateToLocal("text.recipe.altar.bloodRequired"),
|
||||
String.valueOf(bloodRequired)),
|
||||
guiLeft + guiBase.xSize / 2,
|
||||
guiTop + 4 * guiBase.ySize / 6 + 15,
|
||||
0);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api.guide;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import amerifrance.guideapi.api.abstraction.CategoryAbstract;
|
||||
import amerifrance.guideapi.api.abstraction.EntryAbstract;
|
||||
import amerifrance.guideapi.api.base.Book;
|
||||
@@ -16,130 +7,131 @@ import amerifrance.guideapi.api.base.PageBase;
|
||||
import amerifrance.guideapi.gui.GuiBase;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class PageMultiBlock extends PageBase
|
||||
{
|
||||
ItemStack[][][] structure;
|
||||
boolean canTick = false;
|
||||
int tick = 0;
|
||||
int showLayer = -1;
|
||||
float scaleFactor = 1;
|
||||
|
||||
boolean renderMouseOver = true;
|
||||
|
||||
public PageMultiBlock(ItemStack[][][] structure)
|
||||
{
|
||||
this.structure = structure;
|
||||
initPage(structure);
|
||||
public class PageMultiBlock extends PageBase {
|
||||
ItemStack[][][] structure;
|
||||
boolean canTick = false;
|
||||
int tick = 0;
|
||||
int showLayer = -1;
|
||||
float scaleFactor = 1;
|
||||
|
||||
boolean renderMouseOver = true;
|
||||
|
||||
public PageMultiBlock(ItemStack[][][] structure) {
|
||||
this.structure = structure;
|
||||
initPage(structure);
|
||||
}
|
||||
|
||||
int blockCount = 0;
|
||||
int[] countPerLevel;
|
||||
int structureHeight = 0;
|
||||
int structureLength = 0;
|
||||
int structureWidth = 0;
|
||||
|
||||
public void initPage(ItemStack[][][] structure) {
|
||||
structureHeight = structure.length;
|
||||
structureWidth = 0;
|
||||
structureLength = 0;
|
||||
countPerLevel = new int[structureHeight];
|
||||
blockCount = 0;
|
||||
for (int h = 0; h < structure.length; h++) {
|
||||
if (structure[h].length - 1 > structureLength) structureLength = structure[h].length - 1;
|
||||
int perLvl = 0;
|
||||
for (int l = 0; l < structure[h].length; l++) {
|
||||
if (structure[h][l].length - 1 > structureWidth) structureWidth = structure[h][l].length - 1;
|
||||
for (ItemStack ss : structure[h][l]) if (ss != null) perLvl++;
|
||||
}
|
||||
countPerLevel[h] = perLvl;
|
||||
blockCount += perLvl;
|
||||
}
|
||||
tick = (showLayer == -1 ? blockCount : countPerLevel[showLayer]) * 40;
|
||||
// int yOff = (structureHeight-1)*12+structureWidth*5+structureLength*5+16;
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+4,y+yOff/2-5, 10,10, 4));
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+4,y+yOff/2-8-16, 10,16, 3));
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 102, x+4,y+yOff/2+8, 10,16, 2));
|
||||
}
|
||||
|
||||
int blockCount=0;
|
||||
int[] countPerLevel;
|
||||
int structureHeight = 0;
|
||||
int structureLength = 0;
|
||||
int structureWidth = 0;
|
||||
|
||||
public void initPage(ItemStack[][][] structure)
|
||||
{
|
||||
structureHeight = structure.length;
|
||||
structureWidth=0;
|
||||
structureLength=0;
|
||||
countPerLevel = new int[structureHeight];
|
||||
blockCount=0;
|
||||
for(int h=0; h<structure.length; h++)
|
||||
{
|
||||
if(structure[h].length-1>structureLength)
|
||||
structureLength = structure[h].length-1;
|
||||
int perLvl=0;
|
||||
for(int l=0; l<structure[h].length; l++)
|
||||
{
|
||||
if(structure[h][l].length-1>structureWidth)
|
||||
structureWidth = structure[h][l].length-1;
|
||||
for(ItemStack ss : structure[h][l])
|
||||
if(ss!=null)
|
||||
perLvl++;
|
||||
}
|
||||
countPerLevel[h] = perLvl;
|
||||
blockCount += perLvl;
|
||||
}
|
||||
tick= (showLayer==-1?blockCount:countPerLevel[showLayer])*40;
|
||||
// int yOff = (structureHeight-1)*12+structureWidth*5+structureLength*5+16;
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+4,y+yOff/2-5, 10,10, 4));
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+4,y+yOff/2-8-16, 10,16, 3));
|
||||
// pageButtons.add(new GuiButtonManualNavigation(gui, 102, x+4,y+yOff/2+8, 10,16, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer)
|
||||
{
|
||||
// if(multiblock.getStructureManual()!=null)
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
int x = guiLeft + 32;
|
||||
int y = guiTop + 30;
|
||||
{
|
||||
if(canTick)
|
||||
tick++;
|
||||
public void draw(
|
||||
Book book,
|
||||
CategoryAbstract category,
|
||||
EntryAbstract entry,
|
||||
int guiLeft,
|
||||
int guiTop,
|
||||
int mouseX,
|
||||
int mouseY,
|
||||
GuiBase guiBase,
|
||||
FontRenderer fontRenderer) {
|
||||
// if(multiblock.getStructureManual()!=null)
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
int prevLayers = 0;
|
||||
if(showLayer!=-1)
|
||||
for(int ll=0; ll<showLayer; ll++)
|
||||
prevLayers+=countPerLevel[ll];
|
||||
int limiter = prevLayers+ (tick/40)% ((showLayer==-1?blockCount:countPerLevel[showLayer])+4);
|
||||
int x = guiLeft + 32;
|
||||
int y = guiTop + 30;
|
||||
{
|
||||
if (canTick) tick++;
|
||||
|
||||
int xHalf = (structureWidth*5 - structureLength*5);
|
||||
int yOffPartial = (structureHeight-1)*12+structureWidth*5+structureLength*5;
|
||||
// int yOffTotal = yOffPartial+16;
|
||||
int prevLayers = 0;
|
||||
if (showLayer != -1) for (int ll = 0; ll < showLayer; ll++) prevLayers += countPerLevel[ll];
|
||||
int limiter = prevLayers + (tick / 40) % ((showLayer == -1 ? blockCount : countPerLevel[showLayer]) + 4);
|
||||
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((1-scaleFactor)*(guiLeft + 64), (1-scaleFactor)*(guiTop+60), 0);
|
||||
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderWithColor=true;
|
||||
int i=0;
|
||||
ItemStack highlighted = null;
|
||||
for(int h=0; h<structure.length; h++)
|
||||
if(showLayer==-1 || h<=showLayer)
|
||||
{
|
||||
ItemStack[][] level = structure[h];
|
||||
for(int l=level.length-1; l>=0; l--)
|
||||
{
|
||||
ItemStack[] row = level[l];
|
||||
for(int w=row.length-1; w>=0; w--)
|
||||
{
|
||||
int xx = 60 +xHalf -10*w +10*l -7;
|
||||
int yy = yOffPartial - 5*w - 5*l -12*h;
|
||||
GL11.glTranslated(0, 0, 1);
|
||||
if(row[w]!=null && i<=limiter)
|
||||
{
|
||||
i++;
|
||||
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, row[w], x+xx, y+yy);
|
||||
if(mouseX>=x+xx&&mouseX<x+xx+16 && mouseY>=y+yy&&mouseY<y+yy+16)
|
||||
highlighted = row[w];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glTranslated(0, 0, -i);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
int xHalf = (structureWidth * 5 - structureLength * 5);
|
||||
int yOffPartial = (structureHeight - 1) * 12 + structureWidth * 5 + structureLength * 5;
|
||||
// int yOffTotal = yOffPartial+16;
|
||||
|
||||
mc.fontRenderer.setUnicodeFlag(false);
|
||||
if(highlighted!=null && renderMouseOver)
|
||||
guiBase.renderToolTip(highlighted, mouseX, mouseY);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
// mc.fontRenderer.setUnicodeFlag(true);
|
||||
// if(localizedText!=null&&!localizedText.isEmpty())
|
||||
// manual.fontRenderer.drawSplitString(localizedText, x,y+yOffTotal, 120, manual.getTextColour());
|
||||
}
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((1 - scaleFactor) * (guiLeft + 64), (1 - scaleFactor) * (guiTop + 60), 0);
|
||||
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderWithColor = true;
|
||||
int i = 0;
|
||||
ItemStack highlighted = null;
|
||||
for (int h = 0; h < structure.length; h++)
|
||||
if (showLayer == -1 || h <= showLayer) {
|
||||
ItemStack[][] level = structure[h];
|
||||
for (int l = level.length - 1; l >= 0; l--) {
|
||||
ItemStack[] row = level[l];
|
||||
for (int w = row.length - 1; w >= 0; w--) {
|
||||
int xx = 60 + xHalf - 10 * w + 10 * l - 7;
|
||||
int yy = yOffPartial - 5 * w - 5 * l - 12 * h;
|
||||
GL11.glTranslated(0, 0, 1);
|
||||
if (row[w] != null && i <= limiter) {
|
||||
i++;
|
||||
RenderItem.getInstance()
|
||||
.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, row[w], x + xx, y + yy);
|
||||
if (mouseX >= x + xx
|
||||
&& mouseX < x + xx + 16
|
||||
&& mouseY >= y + yy
|
||||
&& mouseY < y + yy + 16) highlighted = row[w];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GL11.glTranslated(0, 0, -i);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
mc.fontRenderer.setUnicodeFlag(false);
|
||||
if (highlighted != null && renderMouseOver) guiBase.renderToolTip(highlighted, mouseX, mouseY);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
// mc.fontRenderer.setUnicodeFlag(true);
|
||||
// if(localizedText!=null&&!localizedText.isEmpty())
|
||||
// manual.fontRenderer.drawSplitString(localizedText, x,y+yOffTotal, 120, manual.getTextColour());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +1,89 @@
|
||||
package WayofTime.alchemicalWizardry.api.guide;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
|
||||
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class PageRitualMultiBlock extends PageMultiBlock
|
||||
{
|
||||
private static ItemStack blankStone;
|
||||
private static ItemStack waterStone;
|
||||
private static ItemStack fireStone;
|
||||
private static ItemStack earthStone;
|
||||
private static ItemStack airStone;
|
||||
private static ItemStack duskStone;
|
||||
private static ItemStack dawnStone;
|
||||
static
|
||||
{
|
||||
// blankStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.BLANK);
|
||||
// waterStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.WATER);
|
||||
// fireStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.FIRE);
|
||||
// earthStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.EARTH);
|
||||
// airStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.AIR);
|
||||
// duskStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DUSK);
|
||||
// dawnStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DAWN);
|
||||
}
|
||||
|
||||
private PageRitualMultiBlock(ItemStack[][][] structure)
|
||||
{
|
||||
super(structure);
|
||||
}
|
||||
|
||||
public static PageRitualMultiBlock getPageForRitual(String ritualID)
|
||||
{
|
||||
return getPageForRitual(Rituals.getRitualList(ritualID));
|
||||
}
|
||||
|
||||
public static PageRitualMultiBlock getPageForRitual(List<RitualComponent> ritualComponents)
|
||||
{
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
|
||||
for(RitualComponent comp : ritualComponents)
|
||||
{
|
||||
minX = Math.min(comp.getX(), minX);
|
||||
minY = Math.min(comp.getY(), minY);
|
||||
minZ = Math.min(comp.getZ(), minZ);
|
||||
public class PageRitualMultiBlock extends PageMultiBlock {
|
||||
private static ItemStack blankStone;
|
||||
private static ItemStack waterStone;
|
||||
private static ItemStack fireStone;
|
||||
private static ItemStack earthStone;
|
||||
private static ItemStack airStone;
|
||||
private static ItemStack duskStone;
|
||||
private static ItemStack dawnStone;
|
||||
|
||||
maxX = Math.max(comp.getX(), maxX);
|
||||
maxY = Math.max(comp.getY(), maxY);
|
||||
maxZ = Math.max(comp.getZ(), maxZ);
|
||||
}
|
||||
|
||||
System.out.println("Min: (" + minX + ", " + minY + ", " + minZ + "), Max: (" + maxX + ", " + maxY + ", " + maxZ + ")");
|
||||
|
||||
ItemStack[][][] tempStructure = new ItemStack[maxY-minY+1][maxX-minX+1][maxZ-minZ+1]; //First value is vertical, second is down to the left, third is down to the right
|
||||
|
||||
for(RitualComponent comp : ritualComponents)
|
||||
{
|
||||
tempStructure[comp.getY() - minY][comp.getX() - minX][comp.getZ() - minZ] = getStackForRitualStone(comp.getStoneType());
|
||||
}
|
||||
|
||||
// tempStructure[-minY][-minX][-minZ] = new ItemStack(ModBlocks.blockMasterStone);
|
||||
static {
|
||||
// blankStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.BLANK);
|
||||
// waterStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.WATER);
|
||||
// fireStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.FIRE);
|
||||
// earthStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.EARTH);
|
||||
// airStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.AIR);
|
||||
// duskStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DUSK);
|
||||
// dawnStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DAWN);
|
||||
}
|
||||
|
||||
return new PageRitualMultiBlock(tempStructure);
|
||||
}
|
||||
|
||||
private static ItemStack getStackForRitualStone(int type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case RitualComponent.BLANK:
|
||||
return blankStone;
|
||||
case RitualComponent.WATER:
|
||||
return waterStone;
|
||||
case RitualComponent.FIRE:
|
||||
return fireStone;
|
||||
case RitualComponent.EARTH:
|
||||
return earthStone;
|
||||
case RitualComponent.AIR:
|
||||
return airStone;
|
||||
case RitualComponent.DUSK:
|
||||
return duskStone;
|
||||
case RitualComponent.DAWN:
|
||||
return dawnStone;
|
||||
}
|
||||
return blankStone;
|
||||
}
|
||||
private PageRitualMultiBlock(ItemStack[][][] structure) {
|
||||
super(structure);
|
||||
}
|
||||
|
||||
public static PageRitualMultiBlock getPageForRitual(String ritualID) {
|
||||
return getPageForRitual(Rituals.getRitualList(ritualID));
|
||||
}
|
||||
|
||||
public static PageRitualMultiBlock getPageForRitual(List<RitualComponent> ritualComponents) {
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
|
||||
for (RitualComponent comp : ritualComponents) {
|
||||
minX = Math.min(comp.getX(), minX);
|
||||
minY = Math.min(comp.getY(), minY);
|
||||
minZ = Math.min(comp.getZ(), minZ);
|
||||
|
||||
maxX = Math.max(comp.getX(), maxX);
|
||||
maxY = Math.max(comp.getY(), maxY);
|
||||
maxZ = Math.max(comp.getZ(), maxZ);
|
||||
}
|
||||
|
||||
System.out.println(
|
||||
"Min: (" + minX + ", " + minY + ", " + minZ + "), Max: (" + maxX + ", " + maxY + ", " + maxZ + ")");
|
||||
|
||||
ItemStack[][][] tempStructure = new ItemStack[maxY - minY + 1][maxX - minX + 1]
|
||||
[maxZ - minZ + 1]; // First value is vertical, second is down to the left, third is down to the right
|
||||
|
||||
for (RitualComponent comp : ritualComponents) {
|
||||
tempStructure[comp.getY() - minY][comp.getX() - minX][comp.getZ() - minZ] =
|
||||
getStackForRitualStone(comp.getStoneType());
|
||||
}
|
||||
|
||||
// tempStructure[-minY][-minX][-minZ] = new ItemStack(ModBlocks.blockMasterStone);
|
||||
|
||||
return new PageRitualMultiBlock(tempStructure);
|
||||
}
|
||||
|
||||
private static ItemStack getStackForRitualStone(int type) {
|
||||
switch (type) {
|
||||
case RitualComponent.BLANK:
|
||||
return blankStone;
|
||||
case RitualComponent.WATER:
|
||||
return waterStone;
|
||||
case RitualComponent.FIRE:
|
||||
return fireStone;
|
||||
case RitualComponent.EARTH:
|
||||
return earthStone;
|
||||
case RitualComponent.AIR:
|
||||
return airStone;
|
||||
case RitualComponent.DUSK:
|
||||
return duskStone;
|
||||
case RitualComponent.DAWN:
|
||||
return dawnStone;
|
||||
}
|
||||
return blankStone;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,23 @@
|
||||
package WayofTime.alchemicalWizardry.api.harvest;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class HarvestRegistry
|
||||
{
|
||||
public class HarvestRegistry {
|
||||
public static List<IHarvestHandler> handlerList = new ArrayList();
|
||||
|
||||
public static void registerHarvestHandler(IHarvestHandler handler)
|
||||
{
|
||||
public static void registerHarvestHandler(IHarvestHandler handler) {
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
||||
public static boolean harvestBlock(World world, int xCoord, int yCoord, int zCoord)
|
||||
{
|
||||
public static boolean harvestBlock(World world, int xCoord, int yCoord, int zCoord) {
|
||||
Block block = world.getBlock(xCoord, yCoord, zCoord);
|
||||
int meta = world.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
|
||||
for (IHarvestHandler handler : handlerList)
|
||||
{
|
||||
if (handler.harvestAndPlant(world, xCoord, yCoord, zCoord, block, meta))
|
||||
{
|
||||
for (IHarvestHandler handler : handlerList) {
|
||||
if (handler.harvestAndPlant(world, xCoord, yCoord, zCoord, block, meta)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package WayofTime.alchemicalWizardry.api.harvest;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IHarvestHandler
|
||||
{
|
||||
public interface IHarvestHandler {
|
||||
/**
|
||||
* A handler that is used to harvest and replant the block at the specified location
|
||||
*
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
public interface IAltarManipulator
|
||||
{
|
||||
|
||||
}
|
||||
public interface IAltarManipulator {}
|
||||
@@ -1,11 +1,14 @@
|
||||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.api.spell.SpellEffect;
|
||||
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -24,20 +27,14 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.api.spell.SpellEffect;
|
||||
import WayofTime.alchemicalWizardry.api.spell.SpellParadigmTool;
|
||||
|
||||
public class ItemSpellMultiTool extends Item
|
||||
{
|
||||
public class ItemSpellMultiTool extends Item {
|
||||
private static final String harvestLevelSuffix = "harvestLvl";
|
||||
private static final String digLevelSuffix = "digLvl";
|
||||
private static final String tagName = "BloodMagicTool";
|
||||
private Random rand = new Random();
|
||||
|
||||
public ItemSpellMultiTool()
|
||||
{
|
||||
public ItemSpellMultiTool() {
|
||||
super();
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(1);
|
||||
@@ -45,39 +42,37 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister)
|
||||
{
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundTool");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
|
||||
{
|
||||
public boolean hitEntity(
|
||||
ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase) {
|
||||
float damage = this.getCustomItemAttack(par1ItemStack);
|
||||
|
||||
float f = (float)par3EntityLivingBase.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
|
||||
|
||||
|
||||
float f = (float) par3EntityLivingBase
|
||||
.getEntityAttribute(SharedMonsterAttributes.attackDamage)
|
||||
.getAttributeValue();
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack);
|
||||
|
||||
if (parad != null)
|
||||
{
|
||||
if (parad != null) {
|
||||
parad.onLeftClickEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase);
|
||||
}
|
||||
|
||||
damage += parad.getAddedDamageForEntity(par2EntityLivingBase);
|
||||
|
||||
if (rand.nextFloat() < this.getCritChance(par1ItemStack))
|
||||
{
|
||||
if (rand.nextFloat() < this.getCritChance(par1ItemStack)) {
|
||||
damage *= 1.75f;
|
||||
}
|
||||
|
||||
damage *= f;
|
||||
|
||||
if (par3EntityLivingBase instanceof EntityPlayer)
|
||||
{
|
||||
par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage);
|
||||
} else
|
||||
{
|
||||
|
||||
if (par3EntityLivingBase instanceof EntityPlayer) {
|
||||
par2EntityLivingBase.attackEntityFrom(
|
||||
DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage);
|
||||
} else {
|
||||
par2EntityLivingBase.attackEntityFrom(DamageSource.causeMobDamage(par3EntityLivingBase), damage);
|
||||
}
|
||||
|
||||
@@ -85,12 +80,10 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(stack);
|
||||
|
||||
if (parad != null && entity instanceof EntityLivingBase)
|
||||
{
|
||||
if (parad != null && entity instanceof EntityLivingBase) {
|
||||
parad.onLeftClickEntity(stack, (EntityLivingBase) entity, player);
|
||||
}
|
||||
|
||||
@@ -98,21 +91,17 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
|
||||
if (player.worldObj.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
return false;
|
||||
if (!stack.hasTagCompound()) return false;
|
||||
|
||||
World world = player.worldObj;
|
||||
Block block = player.worldObj.getBlock(x, y, z);
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (block == null || block == Blocks.air)
|
||||
return false;
|
||||
if (block == null || block == Blocks.air) return false;
|
||||
int hlvl = -1;
|
||||
float blockHardness = block.getBlockHardness(world, x, y, z);
|
||||
|
||||
@@ -121,54 +110,51 @@ public class ItemSpellMultiTool extends Item
|
||||
Block localBlock = world.getBlock(x, y, z);
|
||||
int localMeta = world.getBlockMetadata(x, y, z);
|
||||
String toolClass = block.getHarvestTool(meta);
|
||||
if (toolClass != null && this.getHarvestLevel(stack, toolClass) != -1)
|
||||
hlvl = block.getHarvestLevel(meta);
|
||||
if (toolClass != null && this.getHarvestLevel(stack, toolClass) != -1) hlvl = block.getHarvestLevel(meta);
|
||||
int toolLevel = this.getHarvestLevel(stack, toolClass);
|
||||
|
||||
float localHardness = localBlock == null ? Float.MAX_VALUE : localBlock.getBlockHardness(world, x, y, z);
|
||||
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness)
|
||||
{
|
||||
if (hlvl <= toolLevel && localHardness - 1.5 <= blockHardness) {
|
||||
boolean cancelHarvest = false;
|
||||
|
||||
if (!cancelHarvest)
|
||||
{
|
||||
if (localBlock != null && !(localHardness < 0))
|
||||
{
|
||||
if (!cancelHarvest) {
|
||||
if (localBlock != null && !(localHardness < 0)) {
|
||||
boolean isEffective = false;
|
||||
|
||||
String localToolClass = this.getToolClassForMaterial(localBlock.getMaterial());
|
||||
|
||||
if (localToolClass != null && this.getHarvestLevel(stack, toolClass) >= localBlock.getHarvestLevel(localMeta))
|
||||
{
|
||||
if (localToolClass != null
|
||||
&& this.getHarvestLevel(stack, toolClass) >= localBlock.getHarvestLevel(localMeta)) {
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
|
||||
if (localBlock.getMaterial().isToolNotRequired())
|
||||
{
|
||||
if (localBlock.getMaterial().isToolNotRequired()) {
|
||||
isEffective = true;
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (isEffective)
|
||||
{
|
||||
if (localBlock.removedByPlayer(world, player, x, y, z, true))
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
if (isEffective) {
|
||||
if (localBlock.removedByPlayer(world, player, x, y, z, true)) {
|
||||
localBlock.onBlockDestroyedByPlayer(world, x, y, z, localMeta);
|
||||
}
|
||||
localBlock.onBlockHarvested(world, x, y, z, localMeta, player);
|
||||
if (blockHardness > 0f)
|
||||
onBlockDestroyed(stack, world, localBlock, x, y, z, player);
|
||||
if (blockHardness > 0f) onBlockDestroyed(stack, world, localBlock, x, y, z, player);
|
||||
|
||||
List<ItemStack> items = APISpellHelper.getItemsFromBlock(world, localBlock, x, y, z, localMeta, this.getSilkTouch(stack), this.getFortuneLevel(stack));
|
||||
List<ItemStack> items = APISpellHelper.getItemsFromBlock(
|
||||
world,
|
||||
localBlock,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
localMeta,
|
||||
this.getSilkTouch(stack),
|
||||
this.getFortuneLevel(stack));
|
||||
|
||||
SpellParadigmTool parad = this.loadParadigmFromStack(stack);
|
||||
List<ItemStack> newItems = parad.handleItemList(stack, items);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
APISpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f);
|
||||
}
|
||||
|
||||
@@ -176,22 +162,29 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
int cost = 0;
|
||||
|
||||
cost += parad.digSurroundingArea(stack, world, player, mop, localToolClass, localHardness, toolLevel, this);
|
||||
cost += parad.digSurroundingArea(
|
||||
stack, world, player, mop, localToolClass, localHardness, toolLevel, this);
|
||||
|
||||
cost += parad.onBreakBlock(stack, world, player, localBlock, localMeta, x, y, z, ForgeDirection.getOrientation(mop.sideHit));
|
||||
cost += parad.onBreakBlock(
|
||||
stack,
|
||||
world,
|
||||
player,
|
||||
localBlock,
|
||||
localMeta,
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
ForgeDirection.getOrientation(mop.sideHit));
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(stack, player, cost);
|
||||
if (cost > 0) {
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(stack, player, cost);
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.func_147479_m(x, y, z);
|
||||
}
|
||||
@@ -199,56 +192,54 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
// if (!world.isRemote)
|
||||
// world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
// if (!world.isRemote)
|
||||
// world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public Material[] getMaterialsForToolclass(String toolClass)
|
||||
{
|
||||
if ("pickaxe".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.rock, Material.iron, Material.ice, Material.glass, Material.piston, Material.anvil, Material.circuits};
|
||||
} else if ("shovel".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay};
|
||||
} else if ("axe".equals(toolClass))
|
||||
{
|
||||
return new Material[]{Material.wood, Material.vine, Material.circuits, Material.cactus};
|
||||
public Material[] getMaterialsForToolclass(String toolClass) {
|
||||
if ("pickaxe".equals(toolClass)) {
|
||||
return new Material[] {
|
||||
Material.rock,
|
||||
Material.iron,
|
||||
Material.ice,
|
||||
Material.glass,
|
||||
Material.piston,
|
||||
Material.anvil,
|
||||
Material.circuits
|
||||
};
|
||||
} else if ("shovel".equals(toolClass)) {
|
||||
return new Material[] {
|
||||
Material.grass, Material.ground, Material.sand, Material.snow, Material.craftedSnow, Material.clay
|
||||
};
|
||||
} else if ("axe".equals(toolClass)) {
|
||||
return new Material[] {Material.wood, Material.vine, Material.circuits, Material.cactus};
|
||||
}
|
||||
return new Material[0];
|
||||
}
|
||||
|
||||
public String getToolClassForMaterial(Material mat)
|
||||
{
|
||||
public String getToolClassForMaterial(Material mat) {
|
||||
String testString = "pickaxe";
|
||||
|
||||
Material[] matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
for (int i = 0; i < matList.length; i++) {
|
||||
if (matList[i] == mat) {
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
|
||||
testString = "shovel";
|
||||
matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
for (int i = 0; i < matList.length; i++) {
|
||||
if (matList[i] == mat) {
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
|
||||
testString = "axe";
|
||||
matList = this.getMaterialsForToolclass(testString);
|
||||
for (int i = 0; i < matList.length; i++)
|
||||
{
|
||||
if (matList[i] == mat)
|
||||
{
|
||||
for (int i = 0; i < matList.length; i++) {
|
||||
if (matList[i] == mat) {
|
||||
return testString;
|
||||
}
|
||||
}
|
||||
@@ -256,22 +247,18 @@ public class ItemSpellMultiTool extends Item
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
public Set<String> getToolClasses(ItemStack stack) {
|
||||
Set<String> set = new HashSet();
|
||||
|
||||
if (this.getHarvestLevel(stack, "pickaxe") > -1)
|
||||
{
|
||||
if (this.getHarvestLevel(stack, "pickaxe") > -1) {
|
||||
set.add("pickaxe");
|
||||
}
|
||||
|
||||
if (this.getHarvestLevel(stack, "axe") > -1)
|
||||
{
|
||||
if (this.getHarvestLevel(stack, "axe") > -1) {
|
||||
set.add("axe");
|
||||
}
|
||||
|
||||
if (this.getHarvestLevel(stack, "shovel") > -1)
|
||||
{
|
||||
if (this.getHarvestLevel(stack, "shovel") > -1) {
|
||||
set.add("shovel");
|
||||
}
|
||||
|
||||
@@ -279,70 +266,56 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta)
|
||||
{
|
||||
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
||||
String toolClass = block.getHarvestTool(meta);
|
||||
|
||||
if (toolClass == null || toolClass.equals(""))
|
||||
{
|
||||
toolClass = getToolClassOfMaterial(block.getMaterial());
|
||||
|
||||
if(toolClass == "")
|
||||
{
|
||||
if (toolClass == null || toolClass.equals("")) {
|
||||
toolClass = getToolClassOfMaterial(block.getMaterial());
|
||||
|
||||
if (toolClass == "") {
|
||||
return 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat(digLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public String getToolClassOfMaterial(Material mat)
|
||||
{
|
||||
if(mat == Material.iron || mat == Material.anvil || mat == Material.rock)
|
||||
{
|
||||
return "pickaxe";
|
||||
|
||||
public String getToolClassOfMaterial(Material mat) {
|
||||
if (mat == Material.iron || mat == Material.anvil || mat == Material.rock) {
|
||||
return "pickaxe";
|
||||
}
|
||||
|
||||
if(mat == Material.wood || mat == Material.plants || mat == Material.vine)
|
||||
{
|
||||
return "axe";
|
||||
if (mat == Material.wood || mat == Material.plants || mat == Material.vine) {
|
||||
return "axe";
|
||||
}
|
||||
|
||||
if(mat == Material.ground || mat == Material.grass)
|
||||
{
|
||||
return "shovel";
|
||||
|
||||
if (mat == Material.ground || mat == Material.grass) {
|
||||
return "shovel";
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
if (tag.hasKey(harvestLevelSuffix + toolClass))
|
||||
{
|
||||
if (tag.hasKey(harvestLevelSuffix + toolClass)) {
|
||||
return tag.getInteger(harvestLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@@ -350,23 +323,19 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
|
||||
{
|
||||
public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack toolStack, World world, Entity par3Entity, int par4, boolean par5)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
public void onUpdate(ItemStack toolStack, World world, Entity par3Entity, int par4, boolean par5) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -378,8 +347,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
int duration = Math.max(this.getDuration(toolStack, world), 0);
|
||||
|
||||
if (duration <= 0 && par3Entity instanceof EntityPlayer)
|
||||
{
|
||||
if (duration <= 0 && par3Entity instanceof EntityPlayer) {
|
||||
int banishCost = parad.onBanishTool(toolStack, world, par3Entity, par4, par5);
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, banishCost);
|
||||
((EntityPlayer) par3Entity).inventory.mainInventory[par4] = this.getContainedCrystal(toolStack);
|
||||
@@ -387,10 +355,8 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
||||
{
|
||||
if (par3EntityPlayer.isSneaking())
|
||||
{
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
|
||||
if (par3EntityPlayer.isSneaking()) {
|
||||
par3EntityPlayer.setCurrentItemOrArmor(0, this.getContainedCrystal(par1ItemStack));
|
||||
return par1ItemStack;
|
||||
}
|
||||
@@ -401,36 +367,29 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
int cost = 0;
|
||||
|
||||
if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK))
|
||||
{
|
||||
if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK)) {
|
||||
cost = parad.onRightClickBlock(par1ItemStack, par3EntityPlayer, par2World, mop);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
cost = parad.onRightClickAir(par1ItemStack, par2World, par3EntityPlayer);
|
||||
}
|
||||
|
||||
if (cost > 0)
|
||||
{
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(par1ItemStack, par3EntityPlayer, cost);
|
||||
if (cost > 0) {
|
||||
SoulNetworkHandler.syphonAndDamageFromNetwork(par1ItemStack, par3EntityPlayer, cost);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
|
||||
{
|
||||
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) {
|
||||
par3List.add("A mace filled with ancient alchemy");
|
||||
|
||||
if (!(par1ItemStack.getTagCompound() == null))
|
||||
{
|
||||
if (!par1ItemStack.getTagCompound().getString("ownerName").equals(""))
|
||||
{
|
||||
if (!(par1ItemStack.getTagCompound() == null)) {
|
||||
if (!par1ItemStack.getTagCompound().getString("ownerName").equals("")) {
|
||||
par3List.add("Current owner: " + par1ItemStack.getTagCompound().getString("ownerName"));
|
||||
}
|
||||
|
||||
for (String str : this.getToolListString(par1ItemStack))
|
||||
{
|
||||
for (String str : this.getToolListString(par1ItemStack)) {
|
||||
par3List.add(str);
|
||||
}
|
||||
|
||||
@@ -442,19 +401,16 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
//--------------Custom methods--------------//
|
||||
// --------------Custom methods--------------//
|
||||
|
||||
public void setHarvestLevel(ItemStack stack, String toolClass, int harvestLevel)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public void setHarvestLevel(ItemStack stack, String toolClass, int harvestLevel) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel));
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -465,17 +421,14 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public void setDigSpeed(ItemStack stack, String toolClass, float digSpeed)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public void setDigSpeed(ItemStack stack, String toolClass, float digSpeed) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat(digLevelSuffix + toolClass, digSpeed);
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -486,32 +439,26 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public float getDigSpeed(ItemStack stack, String toolClass)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public float getDigSpeed(ItemStack stack, String toolClass) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat(digLevelSuffix + toolClass);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemAttack(ItemStack stack, float damage)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public void setItemAttack(ItemStack stack, float damage) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -522,40 +469,33 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public float getCustomItemAttack(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public float getCustomItemAttack(ItemStack stack) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat("itemAttack");
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getContainedCrystal(ItemStack container)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName).getCompoundTag("heldItem");
|
||||
public ItemStack getContainedCrystal(ItemStack container) {
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound tag =
|
||||
container.getTagCompound().getCompoundTag(tagName).getCompoundTag("heldItem");
|
||||
|
||||
return ItemStack.loadItemStackFromNBT(tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContainedCrystal(ItemStack container, ItemStack crystal)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
public void setContainedCrystal(ItemStack container, ItemStack crystal) {
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
|
||||
NBTTagCompound tag = compTag.getCompoundTag("heldItem");
|
||||
|
||||
@@ -563,8 +503,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
compTag.setTag("heldItem", tag);
|
||||
container.getTagCompound().setTag(tagName, compTag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -577,25 +516,20 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public void setDuration(ItemStack container, World world, int duration)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
public void setDuration(ItemStack container, World world, int duration) {
|
||||
if (world.isRemote) {
|
||||
return;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
World overWorld = DimensionManager.getWorld(0);
|
||||
long worldtime = overWorld.getTotalWorldTime();
|
||||
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setLong("duration", Math.max(duration + worldtime, worldtime));
|
||||
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -607,23 +541,18 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public int getDuration(ItemStack container, World world)
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
public int getDuration(ItemStack container, World world) {
|
||||
if (world.isRemote) {
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
World overWorld = DimensionManager.getWorld(0);
|
||||
long worldtime = overWorld.getTotalWorldTime();
|
||||
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return (int) (tag.getLong("duration") - worldtime);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
@@ -631,10 +560,8 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public void loadParadigmIntoStack(ItemStack container, List<SpellEffect> list)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
public void loadParadigmIntoStack(ItemStack container, List<SpellEffect> list) {
|
||||
if (!container.hasTagCompound()) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@@ -642,8 +569,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
|
||||
for (SpellEffect eff : list)
|
||||
{
|
||||
for (SpellEffect eff : list) {
|
||||
effectList.appendTag(eff.getTag());
|
||||
}
|
||||
|
||||
@@ -652,10 +578,8 @@ public class ItemSpellMultiTool extends Item
|
||||
container.getTagCompound().setTag(tagName, tagiest);
|
||||
}
|
||||
|
||||
public SpellParadigmTool loadParadigmFromStack(ItemStack container)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
public SpellParadigmTool loadParadigmFromStack(ItemStack container) {
|
||||
if (!container.hasTagCompound()) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -663,13 +587,11 @@ public class ItemSpellMultiTool extends Item
|
||||
NBTTagList tagList = tagiest.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
List<SpellEffect> spellEffectList = new LinkedList();
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
|
||||
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
|
||||
if (eff != null)
|
||||
{
|
||||
if (eff != null) {
|
||||
spellEffectList.add(eff);
|
||||
}
|
||||
}
|
||||
@@ -677,17 +599,14 @@ public class ItemSpellMultiTool extends Item
|
||||
return SpellParadigmTool.getParadigmForEffectArray(spellEffectList);
|
||||
}
|
||||
|
||||
public void setSilkTouch(ItemStack stack, boolean silkTouch)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public void setSilkTouch(ItemStack stack, boolean silkTouch) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setBoolean("silkTouch", silkTouch);
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -698,32 +617,26 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getSilkTouch(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public boolean getSilkTouch(ItemStack stack) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getBoolean("silkTouch");
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setFortuneLevel(ItemStack stack, int fortune)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public void setFortuneLevel(ItemStack stack, int fortune) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
|
||||
|
||||
stack.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -734,25 +647,20 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public int getFortuneLevel(ItemStack stack)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public int getFortuneLevel(ItemStack stack) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getInteger("fortuneLevel");
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getToolListString(ItemStack container)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
public List<String> getToolListString(ItemStack container) {
|
||||
if (!container.hasTagCompound()) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -760,13 +668,11 @@ public class ItemSpellMultiTool extends Item
|
||||
NBTTagList tagList = tagiest.getTagList("ToolTips", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
List<String> toolTipList = new LinkedList();
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
|
||||
|
||||
String str = tag.getString("tip");
|
||||
if (str != null)
|
||||
{
|
||||
if (str != null) {
|
||||
toolTipList.add(str);
|
||||
}
|
||||
}
|
||||
@@ -774,10 +680,8 @@ public class ItemSpellMultiTool extends Item
|
||||
return toolTipList;
|
||||
}
|
||||
|
||||
public void setToolListString(ItemStack container, List<String> toolTipString)
|
||||
{
|
||||
if (!container.hasTagCompound())
|
||||
{
|
||||
public void setToolListString(ItemStack container, List<String> toolTipString) {
|
||||
if (!container.hasTagCompound()) {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@@ -785,8 +689,7 @@ public class ItemSpellMultiTool extends Item
|
||||
|
||||
NBTTagList stringList = new NBTTagList();
|
||||
|
||||
for (String str : toolTipString)
|
||||
{
|
||||
for (String str : toolTipString) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setString("tip", str);
|
||||
|
||||
@@ -798,17 +701,14 @@ public class ItemSpellMultiTool extends Item
|
||||
container.getTagCompound().setTag(tagName, tagiest);
|
||||
}
|
||||
|
||||
public void setCritChance(ItemStack container, float chance)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
public void setCritChance(ItemStack container, float chance) {
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
tag.setFloat("critChance", Math.max(chance, 0));
|
||||
|
||||
container.getTagCompound().setTag(tagName, tag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
@@ -819,18 +719,15 @@ public class ItemSpellMultiTool extends Item
|
||||
}
|
||||
}
|
||||
|
||||
public float getCritChance(ItemStack container)
|
||||
{
|
||||
if (container.hasTagCompound())
|
||||
{
|
||||
public float getCritChance(ItemStack container) {
|
||||
if (container.hasTagCompound()) {
|
||||
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
|
||||
|
||||
return tag.getFloat("critChance");
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
container.setTagCompound(new NBTTagCompound());
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -10,17 +15,10 @@ import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Shaped Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
public class ShapedBloodOrbRecipe implements IRecipe
|
||||
{
|
||||
public class ShapedBloodOrbRecipe implements IRecipe {
|
||||
private static final int MAX_CRAFT_GRID_WIDTH = 3;
|
||||
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
|
||||
|
||||
@@ -30,50 +28,40 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
public int height = 0;
|
||||
private boolean mirrored = true;
|
||||
|
||||
public ShapedBloodOrbRecipe(Block result, Object... recipe)
|
||||
{
|
||||
public ShapedBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(Item result, Object... recipe)
|
||||
{
|
||||
public ShapedBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
|
||||
String shape = "";
|
||||
int idx = 0;
|
||||
|
||||
if (recipe[idx] instanceof Boolean)
|
||||
{
|
||||
if (recipe[idx] instanceof Boolean) {
|
||||
mirrored = (Boolean) recipe[idx];
|
||||
if (recipe[idx + 1] instanceof Object[])
|
||||
{
|
||||
if (recipe[idx + 1] instanceof Object[]) {
|
||||
recipe = (Object[]) recipe[idx + 1];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (recipe[idx] instanceof String[])
|
||||
{
|
||||
if (recipe[idx] instanceof String[]) {
|
||||
String[] parts = ((String[]) recipe[idx++]);
|
||||
|
||||
for (String s : parts)
|
||||
{
|
||||
for (String s : parts) {
|
||||
width = s.length();
|
||||
shape += s;
|
||||
}
|
||||
|
||||
height = parts.length;
|
||||
} else
|
||||
{
|
||||
while (recipe[idx] instanceof String)
|
||||
{
|
||||
} else {
|
||||
while (recipe[idx] instanceof String) {
|
||||
String s = (String) recipe[idx++];
|
||||
shape += s;
|
||||
width = s.length();
|
||||
@@ -81,11 +69,9 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
}
|
||||
}
|
||||
|
||||
if (width * height != shape.length())
|
||||
{
|
||||
if (width * height != shape.length()) {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
@@ -94,33 +80,29 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
|
||||
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
|
||||
|
||||
for (; idx < recipe.length; idx += 2)
|
||||
{
|
||||
for (; idx < recipe.length; idx += 2) {
|
||||
Character chr = (Character) recipe[idx];
|
||||
Object in = recipe[idx + 1];
|
||||
|
||||
if (in instanceof IBloodOrb || (in instanceof ItemStack && ((ItemStack) in).getItem() instanceof IBloodOrb))
|
||||
{ //If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
if (in instanceof ItemStack)
|
||||
itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel());
|
||||
if (in instanceof IBloodOrb
|
||||
|| (in instanceof ItemStack
|
||||
&& ((ItemStack) in).getItem()
|
||||
instanceof
|
||||
IBloodOrb)) { // If the item is an instanceof IBloodOrb then save the level of the
|
||||
// orb
|
||||
if (in instanceof ItemStack) itemMap.put(chr, ((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel());
|
||||
else itemMap.put(chr, ((IBloodOrb) in).getOrbLevel());
|
||||
} else if (in instanceof ItemStack)
|
||||
{
|
||||
} else if (in instanceof ItemStack) {
|
||||
itemMap.put(chr, ((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
} else if (in instanceof Item) {
|
||||
itemMap.put(chr, new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
} else if (in instanceof Block) {
|
||||
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
} else if (in instanceof String) {
|
||||
itemMap.put(chr, OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
String ret = "Invalid shaped ore recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
@@ -130,33 +112,27 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
|
||||
input = new Object[width * height];
|
||||
int x = 0;
|
||||
for (char chr : shape.toCharArray())
|
||||
{
|
||||
for (char chr : shape.toCharArray()) {
|
||||
input[x++] = itemMap.get(chr);
|
||||
}
|
||||
}
|
||||
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
|
||||
{
|
||||
ShapedBloodOrbRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
width = recipe.recipeWidth;
|
||||
height = recipe.recipeHeight;
|
||||
|
||||
input = new Object[recipe.recipeItems.length];
|
||||
|
||||
for (int i = 0; i < input.length; i++)
|
||||
{
|
||||
for (int i = 0; i < input.length; i++) {
|
||||
ItemStack ingred = recipe.recipeItems[i];
|
||||
|
||||
if (ingred == null)
|
||||
continue;
|
||||
if (ingred == null) continue;
|
||||
|
||||
input[i] = recipe.recipeItems[i];
|
||||
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet())
|
||||
{
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, true))
|
||||
{
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) {
|
||||
input[i] = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
@@ -165,37 +141,29 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1)
|
||||
{
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
public int getRecipeSize() {
|
||||
return input.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world)
|
||||
{
|
||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
|
||||
{
|
||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
|
||||
{
|
||||
if (checkMatch(inv, x, y, false))
|
||||
{
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) {
|
||||
for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) {
|
||||
if (checkMatch(inv, x, y, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mirrored && checkMatch(inv, x, y, true))
|
||||
{
|
||||
if (mirrored && checkMatch(inv, x, y, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -205,61 +173,46 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
|
||||
{
|
||||
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
|
||||
{
|
||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
|
||||
{
|
||||
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) {
|
||||
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) {
|
||||
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) {
|
||||
int subX = x - startX;
|
||||
int subY = y - startY;
|
||||
Object target = null;
|
||||
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
|
||||
{
|
||||
if (mirror)
|
||||
{
|
||||
if (subX >= 0 && subY >= 0 && subX < width && subY < height) {
|
||||
if (mirror) {
|
||||
target = input[width - subX - 1 + subY * width];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
target = input[subX + subY * width];
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack slot = inv.getStackInRowAndColumn(x, y);
|
||||
//If target is integer, then we should be check the blood orb value of the item instead
|
||||
if (target instanceof Integer)
|
||||
{
|
||||
if (slot != null && slot.getItem() instanceof IBloodOrb)
|
||||
{
|
||||
// If target is integer, then we should be check the blood orb value of the item instead
|
||||
if (target instanceof Integer) {
|
||||
if (slot != null && slot.getItem() instanceof IBloodOrb) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel() < (Integer) target)
|
||||
{
|
||||
if (orb.getOrbLevel() < (Integer) target) {
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
} else if (target instanceof ItemStack)
|
||||
{
|
||||
if (!OreDictionary.itemMatches((ItemStack) target, slot, false))
|
||||
{
|
||||
} else if (target instanceof ItemStack) {
|
||||
if (!OreDictionary.itemMatches((ItemStack) target, slot, false)) {
|
||||
return false;
|
||||
}
|
||||
} else if (target instanceof ArrayList)
|
||||
{
|
||||
} else if (target instanceof ArrayList) {
|
||||
boolean matched = false;
|
||||
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
|
||||
while (itr.hasNext() && !matched)
|
||||
{
|
||||
while (itr.hasNext() && !matched) {
|
||||
matched = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
|
||||
if (!matched)
|
||||
{
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
} else if (target == null && slot != null)
|
||||
{
|
||||
} else if (target == null && slot != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -268,14 +221,12 @@ public class ShapedBloodOrbRecipe implements IRecipe
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror)
|
||||
{
|
||||
public ShapedBloodOrbRecipe setMirrored(boolean mirror) {
|
||||
mirrored = mirror;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object[] getInput()
|
||||
{
|
||||
public Object[] getInput() {
|
||||
return this.input;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package WayofTime.alchemicalWizardry.api.items;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -10,60 +15,39 @@ import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Shapeless Blood Orb Recipe Handler by joshie *
|
||||
*/
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
{
|
||||
public class ShapelessBloodOrbRecipe implements IRecipe {
|
||||
private ItemStack output = null;
|
||||
private ArrayList<Object> input = new ArrayList<Object>();
|
||||
|
||||
public ShapelessBloodOrbRecipe(Block result, Object... recipe)
|
||||
{
|
||||
public ShapelessBloodOrbRecipe(Block result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(Item result, Object... recipe)
|
||||
{
|
||||
public ShapelessBloodOrbRecipe(Item result, Object... recipe) {
|
||||
this(new ItemStack(result), recipe);
|
||||
}
|
||||
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe)
|
||||
{
|
||||
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe) {
|
||||
output = result.copy();
|
||||
for (Object in : recipe)
|
||||
{
|
||||
if (in instanceof IBloodOrb)
|
||||
{ //If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
for (Object in : recipe) {
|
||||
if (in instanceof IBloodOrb) { // If the item is an instanceof IBloodOrb then save the level of the orb
|
||||
input.add(((IBloodOrb) in).getOrbLevel());
|
||||
}
|
||||
else if (in instanceof ItemStack)
|
||||
{
|
||||
if (((ItemStack)in).getItem() instanceof IBloodOrb)
|
||||
{
|
||||
input.add(((IBloodOrb) ((ItemStack)in).getItem()).getOrbLevel());
|
||||
}
|
||||
else input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item)
|
||||
{
|
||||
} else if (in instanceof ItemStack) {
|
||||
if (((ItemStack) in).getItem() instanceof IBloodOrb) {
|
||||
input.add(((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel());
|
||||
} else input.add(((ItemStack) in).copy());
|
||||
} else if (in instanceof Item) {
|
||||
input.add(new ItemStack((Item) in));
|
||||
} else if (in instanceof Block)
|
||||
{
|
||||
} else if (in instanceof Block) {
|
||||
input.add(new ItemStack((Block) in));
|
||||
} else if (in instanceof String)
|
||||
{
|
||||
} else if (in instanceof String) {
|
||||
input.add(OreDictionary.getOres((String) in));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
String ret = "Invalid shapeless ore recipe: ";
|
||||
for (Object tmp : recipe)
|
||||
{
|
||||
for (Object tmp : recipe) {
|
||||
ret += tmp + ", ";
|
||||
}
|
||||
ret += output;
|
||||
@@ -73,17 +57,13 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements)
|
||||
{
|
||||
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements) {
|
||||
output = recipe.getRecipeOutput();
|
||||
|
||||
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems))
|
||||
{
|
||||
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems)) {
|
||||
Object finalObj = ingred;
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet())
|
||||
{
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, false))
|
||||
{
|
||||
for (Entry<ItemStack, String> replace : replacements.entrySet()) {
|
||||
if (OreDictionary.itemMatches(replace.getKey(), ingred, false)) {
|
||||
finalObj = OreDictionary.getOres(replace.getValue());
|
||||
break;
|
||||
}
|
||||
@@ -93,78 +73,63 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize()
|
||||
{
|
||||
public int getRecipeSize() {
|
||||
return input.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
public ItemStack getRecipeOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1)
|
||||
{
|
||||
public ItemStack getCraftingResult(InventoryCrafting var1) {
|
||||
return output.copy();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting var1, World world)
|
||||
{
|
||||
public boolean matches(InventoryCrafting var1, World world) {
|
||||
ArrayList<Object> required = new ArrayList<Object>(input);
|
||||
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++)
|
||||
{
|
||||
for (int x = 0; x < var1.getSizeInventory(); x++) {
|
||||
ItemStack slot = var1.getStackInSlot(x);
|
||||
|
||||
if (slot != null)
|
||||
{
|
||||
if (slot != null) {
|
||||
boolean inRecipe = false;
|
||||
Iterator<Object> req = required.iterator();
|
||||
|
||||
while (req.hasNext())
|
||||
{
|
||||
while (req.hasNext()) {
|
||||
boolean match = false;
|
||||
|
||||
Object next = req.next();
|
||||
|
||||
//If target is integer, then we should be check the blood orb value of the item instead
|
||||
if (next instanceof Integer)
|
||||
{
|
||||
if (slot != null && slot.getItem() instanceof IBloodOrb)
|
||||
{
|
||||
// If target is integer, then we should be check the blood orb value of the item instead
|
||||
if (next instanceof Integer) {
|
||||
if (slot != null && slot.getItem() instanceof IBloodOrb) {
|
||||
IBloodOrb orb = (IBloodOrb) slot.getItem();
|
||||
if (orb.getOrbLevel() < (Integer) next)
|
||||
{
|
||||
if (orb.getOrbLevel() < (Integer) next) {
|
||||
return false;
|
||||
}
|
||||
} else return false;
|
||||
match = true;
|
||||
} else if (next instanceof ItemStack)
|
||||
{
|
||||
} else if (next instanceof ItemStack) {
|
||||
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
|
||||
} else if (next instanceof ArrayList)
|
||||
{
|
||||
} else if (next instanceof ArrayList) {
|
||||
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
|
||||
while (itr.hasNext() && !match)
|
||||
{
|
||||
while (itr.hasNext() && !match) {
|
||||
match = OreDictionary.itemMatches(itr.next(), slot, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
if (match) {
|
||||
inRecipe = true;
|
||||
required.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inRecipe)
|
||||
{
|
||||
if (!inRecipe) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -173,8 +138,7 @@ public class ShapelessBloodOrbRecipe implements IRecipe
|
||||
return required.isEmpty();
|
||||
}
|
||||
|
||||
public ArrayList<Object> getInput()
|
||||
{
|
||||
public ArrayList<Object> getInput() {
|
||||
return this.input;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ArmourUpgrade
|
||||
{
|
||||
//Called when the armour ticks
|
||||
public interface ArmourUpgrade {
|
||||
// Called when the armour ticks
|
||||
void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack);
|
||||
|
||||
boolean isUpgrade();
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IBindable
|
||||
{
|
||||
}
|
||||
public interface IBindable {}
|
||||
@@ -1,7 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IBloodOrb
|
||||
{
|
||||
public interface IBloodOrb {
|
||||
int getMaxEssence();
|
||||
|
||||
int getOrbLevel();
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface IHolding
|
||||
{
|
||||
|
||||
}
|
||||
public interface IHolding {}
|
||||
@@ -2,7 +2,6 @@ package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ILPGauge
|
||||
{
|
||||
boolean canSeeLPBar(ItemStack itemStack);
|
||||
public interface ILPGauge {
|
||||
boolean canSeeLPBar(ItemStack itemStack);
|
||||
}
|
||||
+1
-4
@@ -3,7 +3,4 @@ package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
/**
|
||||
* Implement this interface to have reagent blocks return false on activating them, to allow manipulation of said block
|
||||
*/
|
||||
public interface IReagentManipulator
|
||||
{
|
||||
|
||||
}
|
||||
public interface IReagentManipulator {}
|
||||
+15
-8
@@ -3,12 +3,19 @@ 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);
|
||||
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,4 +1,3 @@
|
||||
package WayofTime.alchemicalWizardry.api.items.interfaces;
|
||||
|
||||
public interface ISigil {
|
||||
}
|
||||
public interface ISigil {}
|
||||
@@ -1,3 +1,4 @@
|
||||
@API(owner = "BloodMagic", apiVersion = "1.3.3-13", provides = "BloodMagicAPI")
|
||||
package WayofTime.alchemicalWizardry.api;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
@@ -1,20 +1,17 @@
|
||||
package WayofTime.alchemicalWizardry.api.renderer;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
|
||||
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 class MRSRenderer {
|
||||
public abstract void renderAt(IMasterRitualStone tile, double x, double y, double z);
|
||||
|
||||
protected void bindTexture(ResourceLocation p_147499_1_)
|
||||
{
|
||||
protected void bindTexture(ResourceLocation p_147499_1_) {
|
||||
TextureManager texturemanager = TileEntityRendererDispatcher.instance.field_147553_e;
|
||||
|
||||
if (texturemanager != null)
|
||||
{
|
||||
if (texturemanager != null) {
|
||||
texturemanager.bindTexture(p_147499_1_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import WayofTime.alchemicalWizardry.api.alchemy.energy.ISegmentedReagentHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMasterRitualStone extends ISegmentedReagentHandler
|
||||
{
|
||||
public interface IMasterRitualStone extends ISegmentedReagentHandler {
|
||||
void performRitual(World world, int x, int y, int z, String ritualID);
|
||||
|
||||
String getOwner();
|
||||
@@ -33,12 +32,12 @@ public interface IMasterRitualStone extends ISegmentedReagentHandler
|
||||
NBTTagCompound getCustomRitualTag();
|
||||
|
||||
void setCustomRitualTag(NBTTagCompound tag);
|
||||
|
||||
|
||||
boolean areTanksEmpty();
|
||||
|
||||
|
||||
int getRunningTime();
|
||||
|
||||
|
||||
LocalRitualStorage getLocalStorage();
|
||||
|
||||
|
||||
void setLocalStorage(LocalRitualStorage storage);
|
||||
}
|
||||
@@ -2,17 +2,16 @@ package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IRitualStone
|
||||
{
|
||||
/**
|
||||
* x, y, and z give the position of the Ritual Stone
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param meta
|
||||
* @param runeType
|
||||
* @return
|
||||
*/
|
||||
boolean isRuneType(World world, int x, int y, int z, int meta, int runeType);
|
||||
public interface IRitualStone {
|
||||
/**
|
||||
* x, y, and z give the position of the Ritual Stone
|
||||
* @param world
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @param meta
|
||||
* @param runeType
|
||||
* @return
|
||||
*/
|
||||
boolean isRuneType(World world, int x, int y, int z, int meta, int runeType);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public interface ITileRitualStone
|
||||
{
|
||||
public interface ITileRitualStone {
|
||||
boolean isRuneType(int runeType);
|
||||
}
|
||||
@@ -1,42 +1,37 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import WayofTime.alchemicalWizardry.api.Int3;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* 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 class LocalRitualStorage {
|
||||
public int xCoord;
|
||||
public int yCoord;
|
||||
public int 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;
|
||||
}
|
||||
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,11 +1,10 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public enum RitualBreakMethod
|
||||
{
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE, //When an activation crystal activates the MRS, overwriting the current ritual
|
||||
DEACTIVATE,
|
||||
EXPLOSION, //When the MRS is destroyed by an explosion
|
||||
public enum RitualBreakMethod {
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE, // When an activation crystal activates the MRS, overwriting the current ritual
|
||||
DEACTIVATE,
|
||||
EXPLOSION, // When the MRS is destroyed by an explosion
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public class RitualComponent
|
||||
{
|
||||
public class RitualComponent {
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
@@ -14,59 +13,52 @@ public class RitualComponent
|
||||
public static final int DUSK = 5;
|
||||
public static final int DAWN = 6;
|
||||
|
||||
public RitualComponent(int x, int y, int z, int stoneType)
|
||||
{
|
||||
public RitualComponent(int x, int y, int z, int stoneType) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.stoneType = stoneType;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public int getX(int direction)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case 2:
|
||||
return -this.getZ();
|
||||
case 3:
|
||||
return -this.getX();
|
||||
case 4:
|
||||
return this.getZ();
|
||||
default: return this.getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getZ(int direction)
|
||||
{
|
||||
switch(direction)
|
||||
{
|
||||
case 2:
|
||||
return this.getX();
|
||||
case 3:
|
||||
return -this.getZ();
|
||||
case 4:
|
||||
return -this.getX();
|
||||
default: return this.getZ();
|
||||
|
||||
public int getX(int direction) {
|
||||
switch (direction) {
|
||||
case 2:
|
||||
return -this.getZ();
|
||||
case 3:
|
||||
return -this.getX();
|
||||
case 4:
|
||||
return this.getZ();
|
||||
default:
|
||||
return this.getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getStoneType()
|
||||
{
|
||||
public int getZ(int direction) {
|
||||
switch (direction) {
|
||||
case 2:
|
||||
return this.getX();
|
||||
case 3:
|
||||
return -this.getZ();
|
||||
case 4:
|
||||
return -this.getX();
|
||||
default:
|
||||
return this.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public int getStoneType() {
|
||||
return this.stoneType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,31 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class RitualEffect
|
||||
{
|
||||
public abstract class RitualEffect {
|
||||
public abstract void performEffect(IMasterRitualStone ritualStone);
|
||||
|
||||
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player)
|
||||
{
|
||||
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone, RitualBreakMethod method)
|
||||
{
|
||||
|
||||
}
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone, RitualBreakMethod method) {}
|
||||
|
||||
public abstract int getCostPerRefresh();
|
||||
|
||||
public int getInitialCooldown()
|
||||
{
|
||||
public int getInitialCooldown() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract List<RitualComponent> getRitualComponentList();
|
||||
|
||||
public boolean canDrainReagent(IMasterRitualStone ritualStone, Reagent reagent, int amount, boolean doDrain)
|
||||
{
|
||||
if (ritualStone == null || reagent == null || amount == 0)
|
||||
{
|
||||
public boolean canDrainReagent(IMasterRitualStone ritualStone, Reagent reagent, int amount, boolean doDrain) {
|
||||
if (ritualStone == null || reagent == null || amount == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,10 +33,8 @@ public abstract class RitualEffect
|
||||
|
||||
ReagentStack stack = ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, false);
|
||||
|
||||
if (stack != null && stack.amount >= amount)
|
||||
{
|
||||
if (doDrain)
|
||||
{
|
||||
if (stack != null && stack.amount >= amount) {
|
||||
if (doDrain) {
|
||||
ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, true);
|
||||
}
|
||||
|
||||
@@ -54,37 +43,33 @@ public abstract class RitualEffect
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public LocalRitualStorage getNewLocalStorage()
|
||||
{
|
||||
return new LocalRitualStorage();
|
||||
|
||||
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 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 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));
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,22 @@
|
||||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.RitualStopEvent;
|
||||
import WayofTime.alchemicalWizardry.api.renderer.MRSRenderer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
|
||||
import WayofTime.alchemicalWizardry.api.event.RitualStopEvent;
|
||||
import WayofTime.alchemicalWizardry.api.renderer.MRSRenderer;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
|
||||
public class Rituals
|
||||
{
|
||||
public final int crystalLevel;
|
||||
public class Rituals {
|
||||
public final int crystalLevel;
|
||||
public final int actCost;
|
||||
public final RitualEffect effect;
|
||||
public final String name;
|
||||
@@ -29,8 +27,7 @@ public class Rituals
|
||||
public static Map<String, Rituals> ritualMap = new HashMap();
|
||||
public static List<String> keyList = new LinkedList();
|
||||
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer)
|
||||
{
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer) {
|
||||
this.crystalLevel = crystalLevel;
|
||||
this.actCost = actCost;
|
||||
this.effect = effect;
|
||||
@@ -40,8 +37,7 @@ public class Rituals
|
||||
this.customRenderer = renderer;
|
||||
}
|
||||
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name)
|
||||
{
|
||||
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name) {
|
||||
this(crystalLevel, actCost, effect, name, null);
|
||||
}
|
||||
|
||||
@@ -55,13 +51,11 @@ public class Rituals
|
||||
* @param name The name of the ritual
|
||||
* @return Returns true if properly registered, or false if the key is already used
|
||||
*/
|
||||
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer)
|
||||
{
|
||||
if (ritualMap.containsKey(key))
|
||||
{
|
||||
public static boolean registerRitual(
|
||||
String key, int crystalLevel, int actCost, RitualEffect effect, String name, MRSRenderer renderer) {
|
||||
if (ritualMap.containsKey(key)) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name, renderer);
|
||||
ritual.removeRitualFromList();
|
||||
ritualMap.put(key, ritual);
|
||||
@@ -71,13 +65,10 @@ public class Rituals
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name)
|
||||
{
|
||||
if (ritualMap.containsKey(key))
|
||||
{
|
||||
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name) {
|
||||
if (ritualMap.containsKey(key)) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name);
|
||||
ritual.removeRitualFromList();
|
||||
ritualMap.put(key, ritual);
|
||||
@@ -87,24 +78,18 @@ public class Rituals
|
||||
}
|
||||
}
|
||||
|
||||
public void removeRitualFromList()
|
||||
{
|
||||
if (ritualMap.containsValue(this))
|
||||
{
|
||||
public void removeRitualFromList() {
|
||||
if (ritualMap.containsValue(this)) {
|
||||
ritualMap.remove(ritualMap.remove(this.name));
|
||||
}
|
||||
if (keyList.contains(this.name))
|
||||
{
|
||||
if (keyList.contains(this.name)) {
|
||||
keyList.remove(this.name);
|
||||
}
|
||||
}
|
||||
|
||||
public static String checkValidRitual(World world, int x, int y, int z)
|
||||
{
|
||||
for (String key : ritualMap.keySet())
|
||||
{
|
||||
if (checkRitualIsValid(world, x, y, z, key))
|
||||
{
|
||||
public static String checkValidRitual(World world, int x, int y, int z) {
|
||||
for (String key : ritualMap.keySet()) {
|
||||
if (checkRitualIsValid(world, x, y, z, key)) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
@@ -112,13 +97,10 @@ public class Rituals
|
||||
return "";
|
||||
}
|
||||
|
||||
public static boolean canCrystalActivate(String ritualID, int crystalLevel)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static boolean canCrystalActivate(String ritualID, int crystalLevel) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.getCrystalLevel() <= crystalLevel;
|
||||
}
|
||||
}
|
||||
@@ -126,8 +108,7 @@ public class Rituals
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkRitualIsValid(World world, int x, int y, int z, String ritualID)
|
||||
{
|
||||
public static boolean checkRitualIsValid(World world, int x, int y, int z, String ritualID) {
|
||||
int direction = Rituals.getDirectionOfRitual(world, x, y, z, ritualID);
|
||||
|
||||
return direction != -1;
|
||||
@@ -139,26 +120,32 @@ public class Rituals
|
||||
* 3 - SOUTH
|
||||
* 4 - WEST
|
||||
*/
|
||||
public static boolean checkDirectionOfRitualValid(World world, int x, int y, int z, String ritualID, int direction)
|
||||
{
|
||||
public static boolean checkDirectionOfRitualValid(
|
||||
World world, int x, int y, int z, String ritualID, int direction) {
|
||||
List<RitualComponent> ritual = Rituals.getRitualList(ritualID);
|
||||
|
||||
if (ritual == null)
|
||||
{
|
||||
if (ritual == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block test;
|
||||
TileEntity te;
|
||||
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
for (RitualComponent rc : ritual) {
|
||||
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 && ((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())))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -166,12 +153,9 @@ public class Rituals
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID)
|
||||
{
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
if (Rituals.checkDirectionOfRitualValid(world, x, y, z, ritualID, i))
|
||||
{
|
||||
public static int getDirectionOfRitual(World world, int x, int y, int z, String ritualID) {
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
if (Rituals.checkDirectionOfRitualValid(world, x, y, z, ritualID, i)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -179,13 +163,10 @@ public class Rituals
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getCostForActivation(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static int getCostForActivation(String ritualID) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.actCost;
|
||||
}
|
||||
}
|
||||
@@ -193,13 +174,10 @@ public class Rituals
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getInitialCooldown(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static int getInitialCooldown(String ritualID) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
if (ritual != null && ritual.effect != null) {
|
||||
return ritual.effect.getInitialCooldown();
|
||||
}
|
||||
}
|
||||
@@ -207,67 +185,52 @@ public class Rituals
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static List<RitualComponent> getRitualList(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static List<RitualComponent> getRitualList(String ritualID) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.obtainComponents();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private List<RitualComponent> obtainComponents()
|
||||
{
|
||||
private List<RitualComponent> obtainComponents() {
|
||||
return this.effect.getRitualComponentList();
|
||||
}
|
||||
|
||||
private int getCrystalLevel()
|
||||
{
|
||||
private int getCrystalLevel() {
|
||||
return this.crystalLevel;
|
||||
}
|
||||
|
||||
private MRSRenderer getRenderer()
|
||||
{
|
||||
private MRSRenderer getRenderer() {
|
||||
return this.customRenderer;
|
||||
}
|
||||
|
||||
public static void performEffect(IMasterRitualStone ritualStone, String ritualID)
|
||||
{
|
||||
String ownerName = ritualStone.getOwner();
|
||||
|
||||
RitualRunEvent event = new RitualRunEvent(ritualStone, ownerName, ritualID);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ritualMap.containsKey(event.ritualKey))
|
||||
{
|
||||
public static void performEffect(IMasterRitualStone ritualStone, String ritualID) {
|
||||
String ownerName = ritualStone.getOwner();
|
||||
|
||||
RitualRunEvent event = new RitualRunEvent(ritualStone, ownerName, ritualID);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ritualMap.containsKey(event.ritualKey)) {
|
||||
Rituals ritual = ritualMap.get(event.ritualKey);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
if (ritual != null && ritual.effect != null) {
|
||||
ritual.effect.performEffect(ritualStone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean startRitual(IMasterRitualStone ritualStone, String ritualID, EntityPlayer player)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static boolean startRitual(IMasterRitualStone ritualStone, String ritualID, EntityPlayer player) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
if (ritual != null && ritual.effect != null) {
|
||||
return ritual.effect.startRitual(ritualStone, player);
|
||||
}
|
||||
}
|
||||
@@ -275,57 +238,46 @@ public class Rituals
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID, RitualBreakMethod method)
|
||||
{
|
||||
String ownerName = ritualStone.getOwner();
|
||||
RitualStopEvent event = new RitualStopEvent(ritualStone, ownerName, ritualID, method);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static void onRitualBroken(IMasterRitualStone ritualStone, String ritualID, RitualBreakMethod method) {
|
||||
String ownerName = ritualStone.getOwner();
|
||||
RitualStopEvent event = new RitualStopEvent(ritualStone, ownerName, ritualID, method);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
if (ritual != null && ritual.effect != null) {
|
||||
ritual.effect.onRitualBroken(ritualStone, method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getRitualName()
|
||||
{
|
||||
public String getRitualName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setRitualLocalizedName(String localizedName)
|
||||
{
|
||||
|
||||
public void setRitualLocalizedName(String localizedName) {
|
||||
this.localizedName = localizedName;
|
||||
}
|
||||
public String getRitualLocalizedName()
|
||||
{
|
||||
|
||||
public String getRitualLocalizedName() {
|
||||
return localizedName.isEmpty() ? this.name : localizedName;
|
||||
}
|
||||
|
||||
public static String getNameOfRitual(String id)
|
||||
{
|
||||
if (ritualMap.containsKey(id))
|
||||
{
|
||||
public static String getNameOfRitual(String id) {
|
||||
if (ritualMap.containsKey(id)) {
|
||||
Rituals ritual = ritualMap.get(id);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.getRitualName();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getLocalizedNameOfRitual(String id)
|
||||
{
|
||||
if (ritualMap.containsKey(id))
|
||||
{
|
||||
|
||||
public static String getLocalizedNameOfRitual(String id) {
|
||||
if (ritualMap.containsKey(id)) {
|
||||
Rituals ritual = ritualMap.get(id);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.getRitualLocalizedName();
|
||||
}
|
||||
}
|
||||
@@ -333,23 +285,18 @@ public class Rituals
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getNextRitualKey(String key)
|
||||
{
|
||||
public static String getNextRitualKey(String key) {
|
||||
boolean hasSpotted = false;
|
||||
String firstKey = "";
|
||||
|
||||
for (String str : keyList)
|
||||
{
|
||||
if (firstKey.equals(""))
|
||||
{
|
||||
for (String str : keyList) {
|
||||
if (firstKey.equals("")) {
|
||||
firstKey = str;
|
||||
}
|
||||
if (hasSpotted)
|
||||
{
|
||||
if (hasSpotted) {
|
||||
return str;
|
||||
}
|
||||
if (str.equals(key))
|
||||
{
|
||||
if (str.equals(key)) {
|
||||
hasSpotted = true;
|
||||
}
|
||||
}
|
||||
@@ -357,19 +304,15 @@ public class Rituals
|
||||
return firstKey;
|
||||
}
|
||||
|
||||
public static String getPreviousRitualKey(String key)
|
||||
{
|
||||
public static String getPreviousRitualKey(String key) {
|
||||
boolean hasSpotted = false;
|
||||
String lastKey = keyList.get(keyList.size() - 1);
|
||||
|
||||
for (String str : keyList)
|
||||
{
|
||||
if (str.equals(key))
|
||||
{
|
||||
for (String str : keyList) {
|
||||
if (str.equals(key)) {
|
||||
hasSpotted = true;
|
||||
}
|
||||
if (hasSpotted)
|
||||
{
|
||||
if (hasSpotted) {
|
||||
return lastKey;
|
||||
}
|
||||
lastKey = str;
|
||||
@@ -378,35 +321,28 @@ public class Rituals
|
||||
return lastKey;
|
||||
}
|
||||
|
||||
public static MRSRenderer getRendererForKey(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
public static MRSRenderer getRendererForKey(String ritualID) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
return ritual.getRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LocalRitualStorage getLocalStorage(String ritualID)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
|
||||
public static LocalRitualStorage getLocalStorage(String ritualID) {
|
||||
if (ritualMap.containsKey(ritualID)) {
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
RitualEffect eff = ritual.effect;
|
||||
if(eff != null)
|
||||
{
|
||||
return eff.getNewLocalStorage();
|
||||
if (eff != null) {
|
||||
return eff.getNewLocalStorage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,22 @@ package WayofTime.alchemicalWizardry.api.sacrifice;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IIncense
|
||||
{
|
||||
int getMinLevel(ItemStack stack);
|
||||
|
||||
int getMaxLevel(ItemStack stack);
|
||||
|
||||
int getIncenseDuration(ItemStack stack);
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
* @return a float from 0 to 1
|
||||
*/
|
||||
float getRedColour(ItemStack stack);
|
||||
float getGreenColour(ItemStack stack);
|
||||
float getBlueColour(ItemStack stack);
|
||||
float getTickRate(ItemStack stack);
|
||||
public interface IIncense {
|
||||
int getMinLevel(ItemStack stack);
|
||||
|
||||
int getMaxLevel(ItemStack stack);
|
||||
|
||||
int getIncenseDuration(ItemStack stack);
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
* @return a float from 0 to 1
|
||||
*/
|
||||
float getRedColour(ItemStack stack);
|
||||
|
||||
float getGreenColour(ItemStack stack);
|
||||
|
||||
float getBlueColour(ItemStack stack);
|
||||
|
||||
float getTickRate(ItemStack stack);
|
||||
}
|
||||
+55
-71
@@ -1,91 +1,80 @@
|
||||
package WayofTime.alchemicalWizardry.api.sacrifice;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
|
||||
|
||||
public class PlayerSacrificeHandler
|
||||
{
|
||||
public static float scalingOfSacrifice = 0.001f;
|
||||
public static int soulFrayDuration = 400;
|
||||
public static Potion soulFrayId;
|
||||
public static float getPlayerIncense(EntityPlayer player)
|
||||
{
|
||||
return APISpellHelper.getCurrentIncense(player);
|
||||
}
|
||||
public class PlayerSacrificeHandler {
|
||||
public static float scalingOfSacrifice = 0.001f;
|
||||
public static int soulFrayDuration = 400;
|
||||
public static Potion soulFrayId;
|
||||
|
||||
public static void setPlayerIncense(EntityPlayer player, float amount)
|
||||
{
|
||||
APISpellHelper.setCurrentIncense(player, amount);
|
||||
}
|
||||
public static float getPlayerIncense(EntityPlayer player) {
|
||||
return APISpellHelper.getCurrentIncense(player);
|
||||
}
|
||||
|
||||
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment)
|
||||
{
|
||||
float amount = getPlayerIncense(player);
|
||||
if(amount < min || amount >= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public static void setPlayerIncense(EntityPlayer player, float amount) {
|
||||
APISpellHelper.setCurrentIncense(player, amount);
|
||||
}
|
||||
|
||||
amount = amount + Math.min(increment, max - amount);
|
||||
setPlayerIncense(player, amount);
|
||||
public static boolean incrementIncense(EntityPlayer player, float min, float max, float increment) {
|
||||
float amount = getPlayerIncense(player);
|
||||
if (amount < min || amount >= max) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
|
||||
amount = amount + Math.min(increment, max - amount);
|
||||
setPlayerIncense(player, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
|
||||
|
||||
public static boolean sacrificePlayerHealth(EntityPlayer player)
|
||||
{
|
||||
if(player.isPotionActive(soulFrayId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
float amount = getPlayerIncense(player);
|
||||
public static boolean sacrificePlayerHealth(EntityPlayer player) {
|
||||
if (player.isPotionActive(soulFrayId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(amount >= 0)
|
||||
{
|
||||
float health = player.getHealth();
|
||||
float maxHealth = player.getMaxHealth();
|
||||
float amount = getPlayerIncense(player);
|
||||
|
||||
if(health > maxHealth/10.0)
|
||||
{
|
||||
float sacrificedHealth = health - maxHealth/10.0f;
|
||||
if (amount >= 0) {
|
||||
float health = player.getHealth();
|
||||
float maxHealth = player.getMaxHealth();
|
||||
|
||||
if(findAndFillAltar(player.getEntityWorld(), player, (int)(sacrificedHealth * AlchemicalWizardry.lpPerSacrificeIncense * getModifier(amount))))
|
||||
{
|
||||
player.setHealth(maxHealth/10.0f);
|
||||
setPlayerIncense(player, 0);
|
||||
player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration));
|
||||
if (health > maxHealth / 10.0) {
|
||||
float sacrificedHealth = health - maxHealth / 10.0f;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (findAndFillAltar(player.getEntityWorld(), player, (int)
|
||||
(sacrificedHealth * AlchemicalWizardry.lpPerSacrificeIncense * getModifier(amount)))) {
|
||||
player.setHealth(maxHealth / 10.0f);
|
||||
setPlayerIncense(player, 0);
|
||||
player.addPotionEffect(new PotionEffect(soulFrayId.id, soulFrayDuration));
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static float getModifier(float amount)
|
||||
{
|
||||
return 1 + amount*scalingOfSacrifice;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount)
|
||||
{
|
||||
public static float getModifier(float amount) {
|
||||
return 1 + amount * scalingOfSacrifice;
|
||||
}
|
||||
|
||||
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount) {
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
IBloodAltar altarEntity = getAltar(world, posX, posY, posZ);
|
||||
|
||||
if (altarEntity == null)
|
||||
{
|
||||
if (altarEntity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -95,21 +84,16 @@ public class PlayerSacrificeHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IBloodAltar getAltar(World world, int x, int y, int z)
|
||||
{
|
||||
public static IBloodAltar getAltar(World world, int x, int y, int z) {
|
||||
TileEntity tileEntity;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
for (int j = -2; j <= 2; j++) {
|
||||
for (int k = -2; k <= 1; k++) {
|
||||
tileEntity = world.getTileEntity(i + x, k + y, j + z);
|
||||
|
||||
if(tileEntity instanceof IBloodAltar)
|
||||
{
|
||||
return (IBloodAltar)tileEntity;
|
||||
if (tileEntity instanceof IBloodAltar) {
|
||||
return (IBloodAltar) tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+57
-77
@@ -1,5 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@@ -10,117 +13,94 @@ 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.
|
||||
* 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
// TODO ServerConfigurationManager d.createPlayerForUser
|
||||
UUID.fromString(str);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getKeyForPlayer(EntityPlayer player)
|
||||
{
|
||||
return "";
|
||||
|
||||
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 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 String assignKeyToPlayer(EntityPlayer player) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
keyMap.put(new UUID(0, 0), "test");
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
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
|
||||
{
|
||||
try {
|
||||
writer = new FileWriter(fileName + ".json");
|
||||
writer.write(json);
|
||||
writer.close();
|
||||
} catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
File save = new File(fileName + ".json");
|
||||
|
||||
if(save.canRead())
|
||||
{
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
public static void load() {
|
||||
File save = new File(fileName + ".json");
|
||||
|
||||
if (save.canRead()) {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
BufferedReader br;
|
||||
|
||||
try
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
if (keyMap != null) {
|
||||
for (Entry<UUID, String> entry : keyMap.entrySet()) {
|
||||
System.out.println("" + entry.getValue() + " gave: " + entry.getKey());
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e)
|
||||
{
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
keyMap = null;
|
||||
}
|
||||
} else {
|
||||
keyMap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,24 @@ package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData
|
||||
{
|
||||
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData {
|
||||
public int currentEssence;
|
||||
public int maxOrb;
|
||||
|
||||
public LifeEssenceNetwork(String par1Str)
|
||||
{
|
||||
public LifeEssenceNetwork(String par1Str) {
|
||||
super(par1Str);
|
||||
currentEssence = 0;
|
||||
maxOrb = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
currentEssence = nbttagcompound.getInteger("currentEssence");
|
||||
maxOrb = nbttagcompound.getInteger("maxOrb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setInteger("currentEssence", currentEssence);
|
||||
nbttagcompound.setInteger("maxOrb", maxOrb);
|
||||
}
|
||||
|
||||
+141
-197
@@ -1,5 +1,11 @@
|
||||
package WayofTime.alchemicalWizardry.api.soulNetwork;
|
||||
|
||||
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 cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -9,98 +15,79 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.DamageSource;
|
||||
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 cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class SoulNetworkHandler
|
||||
{
|
||||
public static boolean syphonFromNetworkWhileInContainer(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
String ownerName = "";
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
public class SoulNetworkHandler {
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone) {
|
||||
if (ist.getTagCompound() != null
|
||||
&& !(ist.getTagCompound().getString("ownerName").equals(""))) {
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
return syphonFromNetwork(ownerName, damageToBeDone);
|
||||
@@ -108,24 +95,20 @@ public class SoulNetworkHandler
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int syphonFromNetwork(String ownerName, int damageToBeDone)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static int syphonFromNetwork(String ownerName, int damageToBeDone) {
|
||||
if (MinecraftServer.getServer() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
|
||||
if (data.currentEssence >= damageToBeDone)
|
||||
{
|
||||
if (data.currentEssence >= damageToBeDone) {
|
||||
data.currentEssence -= damageToBeDone;
|
||||
data.markDirty();
|
||||
return damageToBeDone;
|
||||
@@ -143,31 +126,30 @@ public class SoulNetworkHandler
|
||||
* @param drain
|
||||
* @return True if the action should be executed and false if it should not. Always returns false if client-sided.
|
||||
*/
|
||||
public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int drain)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
public static boolean syphonAndDamageFromNetwork(ItemStack ist, EntityPlayer player, int drain) {
|
||||
if (player.worldObj.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
|
||||
if (ist.getTagCompound() != null
|
||||
&& !(ist.getTagCompound().getString("ownerName").equals(""))) {
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
|
||||
ItemDrainNetworkEvent event = new ItemDrainNetworkEvent(player, ownerName, ist, drain);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return false;
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int drainAmount = syphonFromNetwork(event.ownerNetwork, event.drainAmount);
|
||||
if(drainAmount == 0 || event.shouldDamage)
|
||||
{
|
||||
hurtPlayer(player, event.damageAmount);
|
||||
if (drainAmount == 0 || event.shouldDamage) {
|
||||
hurtPlayer(player, event.damageAmount);
|
||||
}
|
||||
|
||||
return (event.getResult() != Event.Result.DENY); //The event has been told to prevent the action but allow all repercussions of using the item.
|
||||
|
||||
return (event.getResult()
|
||||
!= Event.Result
|
||||
.DENY); // The event has been told to prevent the action but allow all repercussions of
|
||||
// using the item.
|
||||
}
|
||||
|
||||
int amount = SoulNetworkHandler.syphonFromNetwork(ist, drain);
|
||||
@@ -176,20 +158,23 @@ public class SoulNetworkHandler
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer player, int damageToBeDone)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
|
||||
public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer player, int damageToBeDone) {
|
||||
if (player.worldObj.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = player.worldObj;
|
||||
if (world != null)
|
||||
{
|
||||
world.playSoundEffect((double) ((float) player.posX + 0.5F), (double) ((float) player.posY + 0.5F), (double) ((float) player.posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
if (world != null) {
|
||||
world.playSoundEffect(
|
||||
(double) ((float) player.posX + 0.5F),
|
||||
(double) ((float) player.posY + 0.5F),
|
||||
(double) ((float) player.posZ + 0.5F),
|
||||
"random.fizz",
|
||||
0.5F,
|
||||
2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
|
||||
|
||||
int amount = SoulNetworkHandler.syphonFromNetwork(ownerName, damageToBeDone);
|
||||
|
||||
hurtPlayer(player, damageToBeDone - amount);
|
||||
@@ -197,10 +182,9 @@ public class SoulNetworkHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canSyphonFromOnlyNetwork(ItemStack ist, int damageToBeDone)
|
||||
{
|
||||
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
public static boolean canSyphonFromOnlyNetwork(ItemStack ist, int damageToBeDone) {
|
||||
if (ist.getTagCompound() != null
|
||||
&& !(ist.getTagCompound().getString("ownerName").equals(""))) {
|
||||
String ownerName = ist.getTagCompound().getString("ownerName");
|
||||
|
||||
return canSyphonFromOnlyNetwork(ownerName, damageToBeDone);
|
||||
@@ -209,18 +193,15 @@ public class SoulNetworkHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static boolean canSyphonFromOnlyNetwork(String ownerName, int damageToBeDone) {
|
||||
if (MinecraftServer.getServer() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
@@ -228,18 +209,15 @@ public class SoulNetworkHandler
|
||||
return data.currentEssence >= damageToBeDone;
|
||||
}
|
||||
|
||||
public static int getCurrentEssence(String ownerName)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static int getCurrentEssence(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)
|
||||
{
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
@@ -247,18 +225,15 @@ public class SoulNetworkHandler
|
||||
return data.currentEssence;
|
||||
}
|
||||
|
||||
public static void setCurrentEssence(String ownerName, int essence)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static void setCurrentEssence(String ownerName, int essence) {
|
||||
if (MinecraftServer.getServer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(ownerName);
|
||||
world.setItemData(ownerName, data);
|
||||
}
|
||||
@@ -275,68 +250,54 @@ public class SoulNetworkHandler
|
||||
* @param maximum
|
||||
* @return amount added to the network
|
||||
*/
|
||||
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum)
|
||||
{
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) {
|
||||
AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (MinecraftServer.getServer() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = MinecraftServer.getServer().worldServers[0];
|
||||
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, event.ownerNetwork);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
if (data == null) {
|
||||
data = new LifeEssenceNetwork(event.ownerNetwork);
|
||||
world.setItemData(event.ownerNetwork, data);
|
||||
}
|
||||
|
||||
int currEss = data.currentEssence;
|
||||
|
||||
if (currEss >= event.maximum)
|
||||
{
|
||||
if (currEss >= event.maximum) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int newEss = Math.min(event.maximum, currEss + event.addedAmount);
|
||||
if(event.getResult() != Event.Result.DENY)
|
||||
{
|
||||
if (event.getResult() != Event.Result.DENY) {
|
||||
data.currentEssence = newEss;
|
||||
}
|
||||
|
||||
return newEss - currEss;
|
||||
}
|
||||
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned)
|
||||
{
|
||||
if (energySyphoned < 100 && energySyphoned > 0)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned) {
|
||||
if (energySyphoned < 100 && energySyphoned > 0) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
if (user.getHealth() <= 0.0005f) {
|
||||
user.onDeath(DamageSource.generic);
|
||||
}
|
||||
}
|
||||
} else if (energySyphoned >= 100)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++)
|
||||
{
|
||||
} else if (energySyphoned >= 100) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
for (int i = 0; i < ((energySyphoned + 99) / 100); i++) {
|
||||
user.setHealth((user.getHealth() - 1));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
if (user.getHealth() <= 0.0005f) {
|
||||
user.onDeath(DamageSource.generic);
|
||||
break;
|
||||
}
|
||||
@@ -344,35 +305,29 @@ public class SoulNetworkHandler
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void hurtPlayer(EntityPlayer user, float damage)
|
||||
{
|
||||
if (!user.capabilities.isCreativeMode)
|
||||
{
|
||||
user.setHealth((user.getHealth() - damage));
|
||||
|
||||
if (user.getHealth() <= 0.0005f)
|
||||
{
|
||||
user.onDeath(DamageSource.generic);
|
||||
}
|
||||
|
||||
public static void hurtPlayer(EntityPlayer user, float damage) {
|
||||
if (!user.capabilities.isCreativeMode) {
|
||||
user.setHealth((user.getHealth() - damage));
|
||||
|
||||
if (user.getHealth() <= 0.0005f) {
|
||||
user.onDeath(DamageSource.generic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
public static void checkAndSetItemOwner(ItemStack item, EntityPlayer player) {
|
||||
checkAndSetItemPlayer(item, player);
|
||||
}
|
||||
|
||||
public static boolean checkAndSetItemPlayer(ItemStack item, EntityPlayer player)
|
||||
{
|
||||
if (item.hasTagCompound() && !item.getTagCompound().getString("ownerName").equals("")) return true;
|
||||
public static boolean checkAndSetItemPlayer(ItemStack item, EntityPlayer player) {
|
||||
if (item.hasTagCompound()
|
||||
&& !item.getTagCompound().getString("ownerName").equals("")) return true;
|
||||
|
||||
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
|
||||
|
||||
if(!MinecraftForge.EVENT_BUS.post(event))
|
||||
{
|
||||
if (!item.hasTagCompound())
|
||||
{
|
||||
if (!MinecraftForge.EVENT_BUS.post(event)) {
|
||||
if (!item.hasTagCompound()) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
item.getTagCompound().setString("ownerName", event.key);
|
||||
@@ -381,59 +336,48 @@ public class SoulNetworkHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
|
||||
{
|
||||
if (item.getTagCompound() == null)
|
||||
{
|
||||
public static void checkAndSetItemOwner(ItemStack item, String ownerName) {
|
||||
if (item.getTagCompound() == null) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
if (item.getTagCompound().getString("ownerName").equals(""))
|
||||
{
|
||||
if (item.getTagCompound().getString("ownerName").equals("")) {
|
||||
item.getTagCompound().setString("ownerName", ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getUsername(EntityPlayer player)
|
||||
{
|
||||
public static String getUsername(EntityPlayer player) {
|
||||
return player.getCommandSenderName();
|
||||
}
|
||||
|
||||
public static EntityPlayer getPlayerForUsername(String str)
|
||||
{
|
||||
if (MinecraftServer.getServer() == null)
|
||||
{
|
||||
public static EntityPlayer getPlayerForUsername(String str) {
|
||||
if (MinecraftServer.getServer() == null) {
|
||||
return null;
|
||||
}
|
||||
return MinecraftServer.getServer().getConfigurationManager().func_152612_a(str);
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(ItemStack stack)
|
||||
{
|
||||
if (stack.getTagCompound() != null && !(stack.getTagCompound().getString("ownerName").equals("")))
|
||||
{
|
||||
public static void causeNauseaToPlayer(ItemStack stack) {
|
||||
if (stack.getTagCompound() != null
|
||||
&& !(stack.getTagCompound().getString("ownerName").equals(""))) {
|
||||
String ownerName = stack.getTagCompound().getString("ownerName");
|
||||
|
||||
SoulNetworkHandler.causeNauseaToPlayer(ownerName);
|
||||
}
|
||||
}
|
||||
|
||||
public static void causeNauseaToPlayer(String ownerName)
|
||||
{
|
||||
public static void causeNauseaToPlayer(String ownerName) {
|
||||
EntityPlayer entityOwner = SoulNetworkHandler.getPlayerForUsername(ownerName);
|
||||
|
||||
if (entityOwner == null)
|
||||
{
|
||||
if (entityOwner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
|
||||
}
|
||||
|
||||
public static String getOwnerName(ItemStack item)
|
||||
{
|
||||
if (item.getTagCompound() == null)
|
||||
{
|
||||
|
||||
public static String getOwnerName(ItemStack item) {
|
||||
if (item.getTagCompound() == null) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -17,218 +20,181 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.ModItems;
|
||||
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");
|
||||
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);
|
||||
// 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 float getCurrentIncense(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if(data.hasKey("BM:CurrentIncense"))
|
||||
{
|
||||
return data.getFloat("BM:CurrentIncense");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentIncense(EntityPlayer player, float amount)
|
||||
{
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setFloat("BM:CurrentIncense", amount);
|
||||
}
|
||||
|
||||
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 int getPlayerReagentRegenCooldownTag(EntityPlayer player)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if(data.hasKey("BM:ReagentRegenCooldown"))
|
||||
{
|
||||
return data.getInteger("BM:ReagentRegenCooldown");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerReagentRegenCooldownTag(EntityPlayer player, int amount)
|
||||
{
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setInteger("BM:ReagentRegenCooldown", amount);
|
||||
}
|
||||
|
||||
public static ItemStack getOrbForLevel(int level)
|
||||
{
|
||||
switch(level)
|
||||
{
|
||||
case 1:
|
||||
return new ItemStack(ModItems.weakBloodOrb);
|
||||
case 2:
|
||||
return new ItemStack(ModItems.apprenticeBloodOrb);
|
||||
case 3:
|
||||
return new ItemStack(ModItems.magicianBloodOrb);
|
||||
case 4:
|
||||
return new ItemStack(ModItems.masterBloodOrb);
|
||||
case 5:
|
||||
return new ItemStack(ModItems.archmageBloodOrb);
|
||||
case 6:
|
||||
return new ItemStack(ModItems.transcendentBloodOrb);
|
||||
default:
|
||||
return new ItemStack(Blocks.fire);
|
||||
}
|
||||
}
|
||||
|
||||
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range)
|
||||
{
|
||||
return beaconData;
|
||||
}
|
||||
|
||||
public static float getCurrentIncense(EntityPlayer player) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
if (data.hasKey("BM:CurrentIncense")) {
|
||||
return data.getFloat("BM:CurrentIncense");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setCurrentIncense(EntityPlayer player, float amount) {
|
||||
NBTTagCompound data = player.getEntityData();
|
||||
data.setFloat("BM:CurrentIncense", amount);
|
||||
}
|
||||
|
||||
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 int getPlayerReagentRegenCooldownTag(EntityPlayer player) {
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
if (data.hasKey("BM:ReagentRegenCooldown")) {
|
||||
return data.getInteger("BM:ReagentRegenCooldown");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void setPlayerReagentRegenCooldownTag(EntityPlayer player, int amount) {
|
||||
NBTTagCompound data = APISpellHelper.getPersistentDataTag(player);
|
||||
data.setInteger("BM:ReagentRegenCooldown", amount);
|
||||
}
|
||||
|
||||
public static ItemStack getOrbForLevel(int level) {
|
||||
switch (level) {
|
||||
case 1:
|
||||
return new ItemStack(ModItems.weakBloodOrb);
|
||||
case 2:
|
||||
return new ItemStack(ModItems.apprenticeBloodOrb);
|
||||
case 3:
|
||||
return new ItemStack(ModItems.magicianBloodOrb);
|
||||
case 4:
|
||||
return new ItemStack(ModItems.masterBloodOrb);
|
||||
case 5:
|
||||
return new ItemStack(ModItems.archmageBloodOrb);
|
||||
case 6:
|
||||
return new ItemStack(ModItems.transcendentBloodOrb);
|
||||
default:
|
||||
return new ItemStack(Blocks.fire);
|
||||
}
|
||||
}
|
||||
|
||||
public static MovingObjectPosition raytraceFromEntity(World world, Entity player, boolean par3, double range) {
|
||||
float f = 1.0F;
|
||||
float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
|
||||
float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
|
||||
double d0 = player.prevPosX + (player.posX - player.prevPosX) * (double) f;
|
||||
double d1 = player.prevPosY + (player.posY - player.prevPosY) * (double) f;
|
||||
if (!world.isRemote && player instanceof EntityPlayer)
|
||||
d1 += 1.62D;
|
||||
if (!world.isRemote && player instanceof EntityPlayer) d1 += 1.62D;
|
||||
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
|
||||
Vec3 vec3 = APISpellHelper.createVec3(d0, d1, d2);
|
||||
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
|
||||
@@ -237,69 +203,59 @@ public class APISpellHelper
|
||||
float f6 = MathHelper.sin(-f1 * 0.017453292F);
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
// if (player instanceof EntityPlayerMP)
|
||||
// if (player instanceof EntityPlayerMP)
|
||||
{
|
||||
// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
|
||||
}
|
||||
Vec3 vec31 = vec3.addVector((double) f7 * range, (double) f6 * range, (double) f8 * range);
|
||||
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)
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
if (canSilk && silkTouch)
|
||||
{
|
||||
if (canSilk && silkTouch) {
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
ItemStack item = createStackedBlock(block, meta);
|
||||
|
||||
|
||||
items.add(item);
|
||||
|
||||
return items;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return block.getDrops(world, x, y, z, meta, fortune);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack createStackedBlock(Block block, int meta)
|
||||
{
|
||||
|
||||
public static ItemStack createStackedBlock(Block block, int meta) {
|
||||
int j = 0;
|
||||
if(block == Blocks.lit_redstone_ore)
|
||||
{
|
||||
block = Blocks.redstone_ore;
|
||||
if (block == Blocks.lit_redstone_ore) {
|
||||
block = Blocks.redstone_ore;
|
||||
}
|
||||
|
||||
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
|
||||
if (item != null && item.getHasSubtypes())
|
||||
{
|
||||
if (item != null && item.getHasSubtypes()) {
|
||||
j = meta;
|
||||
}
|
||||
|
||||
return new ItemStack(item, 1, j);
|
||||
}
|
||||
|
||||
public static void spawnItemListInWorld(List<ItemStack> items, World world, float x, float y, float z)
|
||||
{
|
||||
for (ItemStack stack : items)
|
||||
{
|
||||
|
||||
public static void spawnItemListInWorld(List<ItemStack> items, World world, float x, float y, float z) {
|
||||
for (ItemStack stack : items) {
|
||||
EntityItem itemEntity = new EntityItem(world, x, y, z, stack);
|
||||
itemEntity.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(itemEntity);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getNumeralForInt(int num)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
|
||||
public static String getNumeralForInt(int num) {
|
||||
switch (num) {
|
||||
case 1:
|
||||
return "I";
|
||||
case 2:
|
||||
@@ -324,75 +280,66 @@ public class APISpellHelper
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static Block getBlockForString(String str)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
if (item != null) {
|
||||
return new ItemStack(item, 1, meta);
|
||||
}
|
||||
|
||||
|
||||
Block block = APISpellHelper.getBlockForString(itemString);
|
||||
if(block != null)
|
||||
{
|
||||
return new ItemStack(block, 1, meta);
|
||||
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;
|
||||
|
||||
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,92 +1,86 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
public abstract class ComplexSpellEffect {
|
||||
public final ComplexSpellType type;
|
||||
public final ComplexSpellModifier modifier;
|
||||
|
||||
public abstract class ComplexSpellEffect
|
||||
{
|
||||
public final ComplexSpellType type;
|
||||
public final ComplexSpellModifier modifier;
|
||||
|
||||
protected int powerEnhancement;
|
||||
protected int powerEnhancement;
|
||||
protected int costEnhancement;
|
||||
protected int potencyEnhancement;
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier)
|
||||
{
|
||||
this.type = type;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier, int power, int cost, int potency)
|
||||
{
|
||||
this(type, modifier);
|
||||
|
||||
this.powerEnhancement = power;
|
||||
this.costEnhancement = cost;
|
||||
this.potencyEnhancement = potency;
|
||||
}
|
||||
|
||||
public abstract void modifyParadigm(SpellParadigm parad);
|
||||
|
||||
public ComplexSpellType getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public ComplexSpellModifier getModifier()
|
||||
{
|
||||
return this.modifier;
|
||||
}
|
||||
|
||||
public abstract ComplexSpellEffect copy(int power, int cost, int potency);
|
||||
|
||||
public abstract int getCostOfEffect();
|
||||
|
||||
// public NBTTagCompound getTag()
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", this.getClass().getName());
|
||||
// tag.setInteger("modifier", modifierState);
|
||||
// tag.setInteger("power", powerEnhancement);
|
||||
// tag.setInteger("cost", costEnhancement);
|
||||
// tag.setInteger("potency", potencyEnhancement);
|
||||
//
|
||||
// return tag;
|
||||
// }
|
||||
//
|
||||
// public static SpellEffect getEffectFromTag(NBTTagCompound tag)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Class clazz = Class.forName(tag.getString("Class"));
|
||||
// if (clazz != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Object obj = clazz.newInstance();
|
||||
// if (obj instanceof SpellEffect)
|
||||
// {
|
||||
// SpellEffect eff = (SpellEffect) obj;
|
||||
//
|
||||
// eff.modifierState = tag.getInteger("modifier");
|
||||
// eff.powerEnhancement = tag.getInteger("power");
|
||||
// eff.costEnhancement = tag.getInteger("cost");
|
||||
// eff.potencyEnhancement = tag.getInteger("potency");
|
||||
//
|
||||
// return eff;
|
||||
// }
|
||||
// } catch (InstantiationException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// } catch (ClassNotFoundException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier) {
|
||||
this.type = type;
|
||||
this.modifier = modifier;
|
||||
}
|
||||
|
||||
public ComplexSpellEffect(ComplexSpellType type, ComplexSpellModifier modifier, int power, int cost, int potency) {
|
||||
this(type, modifier);
|
||||
|
||||
this.powerEnhancement = power;
|
||||
this.costEnhancement = cost;
|
||||
this.potencyEnhancement = potency;
|
||||
}
|
||||
|
||||
public abstract void modifyParadigm(SpellParadigm parad);
|
||||
|
||||
public ComplexSpellType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public ComplexSpellModifier getModifier() {
|
||||
return this.modifier;
|
||||
}
|
||||
|
||||
public abstract ComplexSpellEffect copy(int power, int cost, int potency);
|
||||
|
||||
public abstract int getCostOfEffect();
|
||||
|
||||
// public NBTTagCompound getTag()
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", this.getClass().getName());
|
||||
// tag.setInteger("modifier", modifierState);
|
||||
// tag.setInteger("power", powerEnhancement);
|
||||
// tag.setInteger("cost", costEnhancement);
|
||||
// tag.setInteger("potency", potencyEnhancement);
|
||||
//
|
||||
// return tag;
|
||||
// }
|
||||
//
|
||||
// public static SpellEffect getEffectFromTag(NBTTagCompound tag)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Class clazz = Class.forName(tag.getString("Class"));
|
||||
// if (clazz != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Object obj = clazz.newInstance();
|
||||
// if (obj instanceof SpellEffect)
|
||||
// {
|
||||
// SpellEffect eff = (SpellEffect) obj;
|
||||
//
|
||||
// eff.modifierState = tag.getInteger("modifier");
|
||||
// eff.powerEnhancement = tag.getInteger("power");
|
||||
// eff.costEnhancement = tag.getInteger("cost");
|
||||
// eff.potencyEnhancement = tag.getInteger("potency");
|
||||
//
|
||||
// return eff;
|
||||
// }
|
||||
// } catch (InstantiationException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// } catch (IllegalAccessException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// } catch (ClassNotFoundException e)
|
||||
// {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
public class ComplexSpellModifier
|
||||
{
|
||||
public static ComplexSpellModifier DEFAULT = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier OFFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier DEFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier ENVIRONMENTAL = new ComplexSpellModifier();
|
||||
public class ComplexSpellModifier {
|
||||
public static ComplexSpellModifier DEFAULT = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier OFFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier DEFENSIVE = new ComplexSpellModifier();
|
||||
public static ComplexSpellModifier ENVIRONMENTAL = new ComplexSpellModifier();
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
public class ComplexSpellType
|
||||
{
|
||||
public static ComplexSpellType FIRE = new ComplexSpellType();
|
||||
public static ComplexSpellType ICE = new ComplexSpellType();
|
||||
public static ComplexSpellType EARTH = new ComplexSpellType();
|
||||
public static ComplexSpellType WIND = new ComplexSpellType();
|
||||
public class ComplexSpellType {
|
||||
public static ComplexSpellType FIRE = new ComplexSpellType();
|
||||
public static ComplexSpellType ICE = new ComplexSpellType();
|
||||
public static ComplexSpellType EARTH = new ComplexSpellType();
|
||||
public static ComplexSpellType WIND = new ComplexSpellType();
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
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;
|
||||
@@ -18,11 +19,8 @@ import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
{
|
||||
public class EntitySpellProjectile extends Entity implements IProjectile {
|
||||
private int xTile = -1;
|
||||
private int yTile = -1;
|
||||
private int zTile = -1;
|
||||
@@ -33,12 +31,13 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* The owner of this arrow.
|
||||
*/
|
||||
public EntityPlayer shootingEntity;
|
||||
|
||||
private int ticksInAir = 0;
|
||||
private int ricochetCounter = 0;
|
||||
private boolean scheduledForDeath = false;
|
||||
private boolean isSilkTouch = false;
|
||||
|
||||
//Custom variables
|
||||
// Custom variables
|
||||
private int maxRicochet = 0;
|
||||
private float damage = 1;
|
||||
public List<IProjectileImpactEffect> impactList = new ArrayList();
|
||||
@@ -47,42 +46,44 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
public List<SpellEffect> spellEffectList = new LinkedList();
|
||||
private int blocksBroken = 0;
|
||||
|
||||
public EntitySpellProjectile(World par1World)
|
||||
{
|
||||
public EntitySpellProjectile(World par1World) {
|
||||
super(par1World);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
public EntitySpellProjectile(World par1World, double par2, double par4, double par6)
|
||||
{
|
||||
public EntitySpellProjectile(World par1World, double par2, double par4, double par6) {
|
||||
super(par1World);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setPosition(par2, par4, par6);
|
||||
yOffset = 0.0F;
|
||||
}
|
||||
|
||||
public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer)
|
||||
{
|
||||
public EntitySpellProjectile(World par1World, EntityPlayer par2EntityPlayer) {
|
||||
super(par1World);
|
||||
shootingEntity = par2EntityPlayer;
|
||||
float par3 = 0.8F;
|
||||
this.setSize(0.1F, 0.1F);
|
||||
this.setLocationAndAngles(par2EntityPlayer.posX, par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(), par2EntityPlayer.posZ, par2EntityPlayer.rotationYaw, par2EntityPlayer.rotationPitch);
|
||||
this.setLocationAndAngles(
|
||||
par2EntityPlayer.posX,
|
||||
par2EntityPlayer.posY + par2EntityPlayer.getEyeHeight(),
|
||||
par2EntityPlayer.posZ,
|
||||
par2EntityPlayer.rotationYaw,
|
||||
par2EntityPlayer.rotationPitch);
|
||||
posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
posY -= 0.2D;
|
||||
posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F;
|
||||
this.setPosition(posX, posY, posZ);
|
||||
yOffset = 0.0F;
|
||||
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionX = -MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI)
|
||||
* MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionZ = MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI)
|
||||
* MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI);
|
||||
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
|
||||
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
protected void entityInit() {
|
||||
dataWatcher.addObject(16, 0);
|
||||
}
|
||||
|
||||
@@ -91,8 +92,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* direction.
|
||||
*/
|
||||
@Override
|
||||
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8)
|
||||
{
|
||||
public void setThrowableHeading(double var1, double var3, double var5, float var7, float var8) {
|
||||
float var9 = MathHelper.sqrt_double(var1 * var1 + var3 * var3 + var5 * var5);
|
||||
var1 /= var9;
|
||||
var3 /= var9;
|
||||
@@ -117,8 +117,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
|
||||
* posY, posZ, yaw, pitch
|
||||
*/
|
||||
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
|
||||
{
|
||||
public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9) {
|
||||
this.setPosition(par1, par3, par5);
|
||||
this.setRotation(par7, par8);
|
||||
}
|
||||
@@ -128,13 +127,11 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
/**
|
||||
* Sets the velocity to the args. Args: x, y, z
|
||||
*/
|
||||
public void setVelocity(double par1, double par3, double par5)
|
||||
{
|
||||
public void setVelocity(double par1, double par3, double par5) {
|
||||
motionX = par1;
|
||||
motionY = par3;
|
||||
motionZ = par5;
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
|
||||
{
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
|
||||
float var7 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
|
||||
prevRotationYaw = rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
|
||||
prevRotationPitch = rotationPitch = (float) (Math.atan2(par3, var7) * 180.0D / Math.PI);
|
||||
@@ -148,72 +145,62 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* Called to update the entity's position/logic.
|
||||
*/
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
this.performUpdateEffects();
|
||||
if (ticksInAir > 600)
|
||||
{
|
||||
if (ticksInAir > 600) {
|
||||
this.setDead();
|
||||
}
|
||||
if (shootingEntity == null)
|
||||
{
|
||||
List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
|
||||
if (shootingEntity == null) {
|
||||
List players = worldObj.getEntitiesWithinAABB(
|
||||
EntityPlayer.class,
|
||||
AxisAlignedBB.getBoundingBox(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
|
||||
Iterator i = players.iterator();
|
||||
double closestDistance = Double.MAX_VALUE;
|
||||
EntityPlayer closestPlayer = null;
|
||||
while (i.hasNext())
|
||||
{
|
||||
while (i.hasNext()) {
|
||||
EntityPlayer e = (EntityPlayer) i.next();
|
||||
double distance = e.getDistanceToEntity(this);
|
||||
if (distance < closestDistance)
|
||||
{
|
||||
if (distance < closestDistance) {
|
||||
closestPlayer = e;
|
||||
}
|
||||
}
|
||||
if (closestPlayer != null)
|
||||
{
|
||||
if (closestPlayer != null) {
|
||||
shootingEntity = closestPlayer;
|
||||
}
|
||||
}
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F)
|
||||
{
|
||||
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
|
||||
float var1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
|
||||
prevRotationYaw = rotationYaw = (float) (Math.atan2(motionX, motionZ) * 180.0D / Math.PI);
|
||||
prevRotationPitch = rotationPitch = (float) (Math.atan2(motionY, var1) * 180.0D / Math.PI);
|
||||
}
|
||||
Block var16 = worldObj.getBlock(xTile, yTile, zTile);
|
||||
|
||||
if (var16 != null)
|
||||
{
|
||||
if (var16 != null) {
|
||||
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
|
||||
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
|
||||
|
||||
if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ)))
|
||||
{
|
||||
if (var2 != null && var2.isVecInside(APISpellHelper.createVec3(posX, posY, posZ))) {
|
||||
inGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (inGround)
|
||||
{
|
||||
if (inGround) {
|
||||
Block var18 = worldObj.getBlock(xTile, yTile, zTile);
|
||||
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
|
||||
|
||||
// if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
|
||||
// if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
|
||||
{
|
||||
// this.groundImpact();
|
||||
// this.setDead();
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
++ticksInAir;
|
||||
|
||||
if (ticksInAir > 1 && ticksInAir < 3)
|
||||
{
|
||||
//worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0D, 0D, 0D);
|
||||
for (int particles = 0; particles < 3; particles++)
|
||||
{
|
||||
if (ticksInAir > 1 && ticksInAir < 3) {
|
||||
// worldObj.spawnParticle("flame", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ +
|
||||
// smallGauss(0.1D), 0D, 0D, 0D);
|
||||
for (int particles = 0; particles < 3; particles++) {
|
||||
this.doFiringParticles();
|
||||
}
|
||||
}
|
||||
@@ -224,33 +211,29 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
var17 = APISpellHelper.createVec3(posX, posY, posZ);
|
||||
var3 = APISpellHelper.createVec3(posX + motionX, posY + motionY, posZ + motionZ);
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
if (var4 != null) {
|
||||
var3 = APISpellHelper.createVec3(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
|
||||
}
|
||||
|
||||
Entity var5 = null;
|
||||
List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
List var6 = worldObj.getEntitiesWithinAABBExcludingEntity(
|
||||
this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
|
||||
double var7 = 0.0D;
|
||||
Iterator var9 = var6.iterator();
|
||||
float var11;
|
||||
|
||||
while (var9.hasNext())
|
||||
{
|
||||
while (var9.hasNext()) {
|
||||
Entity var10 = (Entity) var9.next();
|
||||
|
||||
if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5))
|
||||
{
|
||||
if (var10.canBeCollidedWith() && (var10 != shootingEntity || ticksInAir >= 5)) {
|
||||
var11 = 0.3F;
|
||||
AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
|
||||
MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
|
||||
|
||||
if (var13 != null)
|
||||
{
|
||||
if (var13 != null) {
|
||||
double var14 = var17.distanceTo(var13.hitVec);
|
||||
|
||||
if (var14 < var7 || var7 == 0.0D)
|
||||
{
|
||||
if (var14 < var7 || var7 == 0.0D) {
|
||||
var5 = var10;
|
||||
var7 = var14;
|
||||
}
|
||||
@@ -258,17 +241,14 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
}
|
||||
}
|
||||
|
||||
if (var5 != null)
|
||||
{
|
||||
if (var5 != null) {
|
||||
var4 = new MovingObjectPosition(var5);
|
||||
}
|
||||
|
||||
if (var4 != null)
|
||||
{
|
||||
if (var4 != null) {
|
||||
this.onImpact(var4);
|
||||
|
||||
if (scheduledForDeath)
|
||||
{
|
||||
if (scheduledForDeath) {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
@@ -278,22 +258,26 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
posZ += motionZ;
|
||||
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
|
||||
this.setPosition(posX, posY, posZ);
|
||||
//this.doBlockCollisions();
|
||||
// this.doBlockCollisions();
|
||||
}
|
||||
}
|
||||
|
||||
private void doFlightParticles()
|
||||
{
|
||||
if (ticksInAir % 3 == 0)
|
||||
{
|
||||
private void doFlightParticles() {
|
||||
if (ticksInAir % 3 == 0) {
|
||||
double gauss = gaussian(1.0F);
|
||||
worldObj.spawnParticle("mobSpell", posX, posY, posZ, gauss, gauss, 0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
private void doFiringParticles()
|
||||
{
|
||||
worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), 0.5D, 0.5D, 0.5D);
|
||||
private void doFiringParticles() {
|
||||
worldObj.spawnParticle(
|
||||
"mobSpellAmbient",
|
||||
posX + smallGauss(0.1D),
|
||||
posY + smallGauss(0.1D),
|
||||
posZ + smallGauss(0.1D),
|
||||
0.5D,
|
||||
0.5D,
|
||||
0.5D);
|
||||
worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
|
||||
}
|
||||
|
||||
@@ -301,8 +285,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* (abstract) Protected helper method to write subclass entity data to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
par1NBTTagCompound.setShort("xTile", (short) xTile);
|
||||
par1NBTTagCompound.setShort("yTile", (short) yTile);
|
||||
par1NBTTagCompound.setShort("zTile", (short) zTile);
|
||||
@@ -312,21 +295,20 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
|
||||
for (SpellEffect eff : spellEffectList)
|
||||
{
|
||||
for (SpellEffect eff : spellEffectList) {
|
||||
effectList.appendTag(eff.getTag());
|
||||
}
|
||||
|
||||
// for (String str : this.effectList)
|
||||
// {
|
||||
// if (str != null)
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", str);
|
||||
// effectList.appendTag(tag);
|
||||
// }
|
||||
// }
|
||||
// for (String str : this.effectList)
|
||||
// {
|
||||
// if (str != null)
|
||||
// {
|
||||
// NBTTagCompound tag = new NBTTagCompound();
|
||||
//
|
||||
// tag.setString("Class", str);
|
||||
// effectList.appendTag(tag);
|
||||
// }
|
||||
// }
|
||||
|
||||
par1NBTTagCompound.setTag("Effects", effectList);
|
||||
par1NBTTagCompound.setInteger("blocksBroken", blocksBroken);
|
||||
@@ -337,8 +319,7 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* (abstract) Protected helper method to read subclass entity data from NBT.
|
||||
*/
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
xTile = par1NBTTagCompound.getShort("xTile");
|
||||
yTile = par1NBTTagCompound.getShort("yTile");
|
||||
zTile = par1NBTTagCompound.getShort("zTile");
|
||||
@@ -351,28 +332,25 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
NBTTagList tagList = par1NBTTagCompound.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
List<SpellEffect> spellEffectList = new LinkedList();
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound tag = tagList.getCompoundTagAt(i);
|
||||
|
||||
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
|
||||
if (eff != null)
|
||||
{
|
||||
if (eff != null) {
|
||||
spellEffectList.add(eff);
|
||||
}
|
||||
}
|
||||
this.spellEffectList = spellEffectList;
|
||||
|
||||
// this.effectList = new LinkedList();
|
||||
// for (int i = 0; i < tagList.tagCount(); i++)
|
||||
// {
|
||||
// NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
|
||||
//
|
||||
// this.effectList.add(tag.getString("Class"));
|
||||
// }
|
||||
|
||||
// this.effectList = new LinkedList();
|
||||
// for (int i = 0; i < tagList.tagCount(); i++)
|
||||
// {
|
||||
// NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
|
||||
//
|
||||
// this.effectList.add(tag.getString("Class"));
|
||||
// }
|
||||
|
||||
//SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForStringArray(effectList);
|
||||
// SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForStringArray(effectList);
|
||||
SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForEffectArray(spellEffectList);
|
||||
parad.applyAllSpellEffects();
|
||||
parad.prepareProjectile(this);
|
||||
@@ -383,31 +361,26 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* walk on. used for spiders and wolves to prevent them from trampling crops
|
||||
*/
|
||||
@Override
|
||||
protected boolean canTriggerWalking()
|
||||
{
|
||||
protected boolean canTriggerWalking() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getShadowSize()
|
||||
{
|
||||
public float getShadowSize() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount of knockback the arrow applies when it hits a mob.
|
||||
*/
|
||||
public void setKnockbackStrength(int par1)
|
||||
{
|
||||
}
|
||||
public void setKnockbackStrength(int par1) {}
|
||||
|
||||
/**
|
||||
* If returns false, the item will not inflict any damage against entities.
|
||||
*/
|
||||
@Override
|
||||
public boolean canAttackWithItem()
|
||||
{
|
||||
public boolean canAttackWithItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -415,14 +388,11 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* Whether the arrow has a stream of critical hit particles flying behind
|
||||
* it.
|
||||
*/
|
||||
public void setIsCritical(boolean par1)
|
||||
{
|
||||
public void setIsCritical(boolean par1) {
|
||||
byte var2 = dataWatcher.getWatchableObjectByte(16);
|
||||
if (par1)
|
||||
{
|
||||
if (par1) {
|
||||
dataWatcher.updateObject(16, var2 | 1);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
dataWatcher.updateObject(16, var2 & -2);
|
||||
}
|
||||
}
|
||||
@@ -431,86 +401,75 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
* Whether the arrow has a stream of critical hit particles flying behind
|
||||
* it.
|
||||
*/
|
||||
public boolean getIsCritical()
|
||||
{
|
||||
public boolean getIsCritical() {
|
||||
byte var1 = dataWatcher.getWatchableObjectByte(16);
|
||||
return (var1 & 1) != 0;
|
||||
}
|
||||
|
||||
private void onImpact(MovingObjectPosition mop)
|
||||
{
|
||||
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null)
|
||||
{
|
||||
private void onImpact(MovingObjectPosition mop) {
|
||||
if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY && mop.entityHit != null) {
|
||||
if (mop.entityHit == shootingEntity) return;
|
||||
this.onImpact(mop.entityHit);
|
||||
this.performEntityImpactEffects(mop.entityHit);
|
||||
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
if (!this.penetration)
|
||||
{
|
||||
} else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
if (!this.penetration) {
|
||||
this.groundImpact(mop.sideHit);
|
||||
this.performTileImpactEffects(mop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onImpact(Entity mop) //TODO
|
||||
{
|
||||
if (mop == shootingEntity && ticksInAir > 3)
|
||||
{
|
||||
private void onImpact(Entity mop) // TODO
|
||||
{
|
||||
if (mop == shootingEntity && ticksInAir > 3) {
|
||||
shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
|
||||
this.setDead();
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
doDamage(this.damage, mop);
|
||||
}
|
||||
spawnHitParticles("exorcism", 8);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
|
||||
private void spawnHitParticles(String string, int i)
|
||||
{
|
||||
for (int particles = 0; particles < i; particles++)
|
||||
{
|
||||
worldObj.spawnParticle("mobSpellAmbient", posX + smallGauss(0.1D), posY + smallGauss(0.1D), posZ + smallGauss(0.1D), posGauss(1.0F), posGauss(1.0F), 0.0F);
|
||||
private void spawnHitParticles(String string, int i) {
|
||||
for (int particles = 0; particles < i; particles++) {
|
||||
worldObj.spawnParticle(
|
||||
"mobSpellAmbient",
|
||||
posX + smallGauss(0.1D),
|
||||
posY + smallGauss(0.1D),
|
||||
posZ + smallGauss(0.1D),
|
||||
posGauss(1.0F),
|
||||
posGauss(1.0F),
|
||||
0.0F);
|
||||
}
|
||||
}
|
||||
|
||||
private void doDamage(float f, Entity mop)
|
||||
{
|
||||
private void doDamage(float f, Entity mop) {
|
||||
mop.attackEntityFrom(this.getDamageSource(), f);
|
||||
}
|
||||
|
||||
private DamageSource getDamageSource()
|
||||
{
|
||||
private DamageSource getDamageSource() {
|
||||
return DamageSource.causePlayerDamage(shootingEntity);
|
||||
}
|
||||
|
||||
private void groundImpact(int sideHit)
|
||||
{
|
||||
private void groundImpact(int sideHit) {
|
||||
this.ricochet(sideHit);
|
||||
}
|
||||
|
||||
private double smallGauss(double d)
|
||||
{
|
||||
private double smallGauss(double d) {
|
||||
return (worldObj.rand.nextFloat() - 0.5D) * d;
|
||||
}
|
||||
|
||||
private double posGauss(double d)
|
||||
{
|
||||
private double posGauss(double d) {
|
||||
return rand.nextFloat() * 0.5D * d;
|
||||
}
|
||||
|
||||
private double gaussian(double d)
|
||||
{
|
||||
private double gaussian(double d) {
|
||||
return d + d * ((rand.nextFloat() - 0.5D) / 4);
|
||||
}
|
||||
|
||||
private void ricochet(int sideHit)
|
||||
{
|
||||
switch (sideHit)
|
||||
{
|
||||
private void ricochet(int sideHit) {
|
||||
switch (sideHit) {
|
||||
case 0:
|
||||
case 1:
|
||||
// topHit, bottomHit, reflect Y
|
||||
@@ -528,127 +487,109 @@ public class EntitySpellProjectile extends Entity implements IProjectile
|
||||
break;
|
||||
}
|
||||
ricochetCounter++;
|
||||
if (ricochetCounter > this.getRicochetMax())
|
||||
{
|
||||
if (ricochetCounter > this.getRicochetMax()) {
|
||||
scheduledForDeath = true;
|
||||
for (int particles = 0; particles < 4; particles++)
|
||||
{
|
||||
switch (sideHit)
|
||||
{
|
||||
for (int particles = 0; particles < 4; particles++) {
|
||||
switch (sideHit) {
|
||||
case 0:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, gaussian(0.1D), -gaussian(0.1D), gaussian(0.1D));
|
||||
break;
|
||||
case 1:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
break;
|
||||
case 2:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), -gaussian(0.1D));
|
||||
break;
|
||||
case 3:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
break;
|
||||
case 4:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, -gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
break;
|
||||
case 5:
|
||||
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
worldObj.spawnParticle(
|
||||
"smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Custom stuff
|
||||
public int getRicochetMax()
|
||||
{
|
||||
// Custom stuff
|
||||
public int getRicochetMax() {
|
||||
return this.maxRicochet;
|
||||
}
|
||||
|
||||
public void setRicochetMax(int ricochet)
|
||||
{
|
||||
public void setRicochetMax(int ricochet) {
|
||||
this.maxRicochet = ricochet;
|
||||
}
|
||||
|
||||
public void setImpactList(List<IProjectileImpactEffect> list)
|
||||
{
|
||||
public void setImpactList(List<IProjectileImpactEffect> list) {
|
||||
this.impactList = list;
|
||||
}
|
||||
|
||||
public void setUpdateEffectList(List<IProjectileUpdateEffect> list)
|
||||
{
|
||||
public void setUpdateEffectList(List<IProjectileUpdateEffect> list) {
|
||||
this.updateEffectList = list;
|
||||
}
|
||||
|
||||
private void performEntityImpactEffects(Entity mop)
|
||||
{
|
||||
if (impactList != null)
|
||||
{
|
||||
for (IProjectileImpactEffect impactEffect : impactList)
|
||||
{
|
||||
private void performEntityImpactEffects(Entity mop) {
|
||||
if (impactList != null) {
|
||||
for (IProjectileImpactEffect impactEffect : impactList) {
|
||||
impactEffect.onEntityImpact(mop, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void performTileImpactEffects(MovingObjectPosition mop)
|
||||
{
|
||||
if (impactList != null)
|
||||
{
|
||||
for (IProjectileImpactEffect impactEffect : impactList)
|
||||
{
|
||||
private void performTileImpactEffects(MovingObjectPosition mop) {
|
||||
if (impactList != null) {
|
||||
for (IProjectileImpactEffect impactEffect : impactList) {
|
||||
impactEffect.onTileImpact(worldObj, mop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void performUpdateEffects()
|
||||
{
|
||||
if (updateEffectList != null)
|
||||
{
|
||||
for (IProjectileUpdateEffect updateEffect : updateEffectList)
|
||||
{
|
||||
private void performUpdateEffects() {
|
||||
if (updateEffectList != null) {
|
||||
for (IProjectileUpdateEffect updateEffect : updateEffectList) {
|
||||
updateEffect.onUpdateEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPenetration(boolean penetration)
|
||||
{
|
||||
public void setPenetration(boolean penetration) {
|
||||
this.penetration = penetration;
|
||||
}
|
||||
|
||||
public float getDamage()
|
||||
{
|
||||
public float getDamage() {
|
||||
return this.damage;
|
||||
}
|
||||
|
||||
public void setDamage(float damage)
|
||||
{
|
||||
public void setDamage(float damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public void setSpellEffectList(List<SpellEffect> list)
|
||||
{
|
||||
public void setSpellEffectList(List<SpellEffect> list) {
|
||||
this.spellEffectList = list;
|
||||
}
|
||||
|
||||
public int getBlocksBroken()
|
||||
{
|
||||
public int getBlocksBroken() {
|
||||
return this.blocksBroken;
|
||||
}
|
||||
|
||||
public void setBlocksBroken(int blocksBroken)
|
||||
{
|
||||
public void setBlocksBroken(int blocksBroken) {
|
||||
this.blocksBroken = blocksBroken;
|
||||
}
|
||||
|
||||
public boolean getIsSilkTouch()
|
||||
{
|
||||
public boolean getIsSilkTouch() {
|
||||
return this.isSilkTouch;
|
||||
}
|
||||
|
||||
public void setIsSilkTouch(boolean bool)
|
||||
{
|
||||
public void setIsSilkTouch(boolean bool) {
|
||||
this.isSilkTouch = bool;
|
||||
}
|
||||
}
|
||||
+15
-23
@@ -1,15 +1,13 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntityEffect
|
||||
{
|
||||
public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntityEffect {
|
||||
protected float range;
|
||||
protected float radius;
|
||||
protected int powerUpgrades;
|
||||
@@ -17,8 +15,7 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
|
||||
protected int costUpgrades;
|
||||
protected int maxHit;
|
||||
|
||||
public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost)
|
||||
{
|
||||
public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost) {
|
||||
this.powerUpgrades = power;
|
||||
this.potencyUpgrades = potency;
|
||||
this.costUpgrades = cost;
|
||||
@@ -28,24 +25,22 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityImpact(World world, EntityPlayer entityPlayer)
|
||||
{
|
||||
public void onEntityImpact(World world, EntityPlayer entityPlayer) {
|
||||
Vec3 lookVec = entityPlayer.getLook(range);
|
||||
double x = entityPlayer.posX + lookVec.xCoord;
|
||||
double y = entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord;
|
||||
double z = entityPlayer.posZ + lookVec.zCoord;
|
||||
|
||||
List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x - 0.5f, y - 0.5f, z - 0.5f, x + 0.5f, y + 0.5f, z + 0.5f).expand(radius, radius, radius));
|
||||
List<Entity> entities = world.getEntitiesWithinAABB(
|
||||
Entity.class,
|
||||
AxisAlignedBB.getBoundingBox(x - 0.5f, y - 0.5f, z - 0.5f, x + 0.5f, y + 0.5f, z + 0.5f)
|
||||
.expand(radius, radius, radius));
|
||||
int hit = 0;
|
||||
|
||||
if (entities != null)
|
||||
{
|
||||
for (Entity entity : entities)
|
||||
{
|
||||
if (hit < maxHit && !entity.equals(entityPlayer))
|
||||
{
|
||||
if (this.entityEffect(world, entity, entityPlayer))
|
||||
{
|
||||
if (entities != null) {
|
||||
for (Entity entity : entities) {
|
||||
if (hit < maxHit && !entity.equals(entityPlayer)) {
|
||||
if (this.entityEffect(world, entity, entityPlayer)) {
|
||||
hit++;
|
||||
}
|
||||
}
|
||||
@@ -55,18 +50,15 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity
|
||||
|
||||
protected abstract boolean entityEffect(World world, Entity entity, EntityPlayer player);
|
||||
|
||||
public void setRange(float range)
|
||||
{
|
||||
public void setRange(float range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public void setRadius(float radius)
|
||||
{
|
||||
public void setRadius(float radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public void setMaxNumberHit(int maxHit)
|
||||
{
|
||||
public void setMaxNumberHit(int maxHit) {
|
||||
this.maxHit = maxHit;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IDigAreaEffect
|
||||
{
|
||||
int digSurroundingArea(ItemStack container, World world, EntityPlayer player, MovingObjectPosition blockPos, String usedToolClass, float blockHardness, int harvestLvl, ItemSpellMultiTool itemTool);
|
||||
public interface IDigAreaEffect {
|
||||
int digSurroundingArea(
|
||||
ItemStack container,
|
||||
World world,
|
||||
EntityPlayer player,
|
||||
MovingObjectPosition blockPos,
|
||||
String usedToolClass,
|
||||
float blockHardness,
|
||||
int harvestLvl,
|
||||
ItemSpellMultiTool itemTool);
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IItemManipulator
|
||||
{
|
||||
public interface IItemManipulator {
|
||||
public List<ItemStack> handleItemsOnBlockBroken(ItemStack toolStack, List<ItemStack> itemList);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package WayofTime.alchemicalWizardry.api.spell;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ILeftClickEffect
|
||||
{
|
||||
public interface ILeftClickEffect {
|
||||
int onLeftClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package WayofTime.alchemicalWizardry.api.spell;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMeleeSpellEntityEffect
|
||||
{
|
||||
public interface IMeleeSpellEntityEffect {
|
||||
void onEntityImpact(World world, EntityPlayer entityPlayer);
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package WayofTime.alchemicalWizardry.api.spell;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IMeleeSpellWorldEffect
|
||||
{
|
||||
public interface IMeleeSpellWorldEffect {
|
||||
void onWorldEffect(World world, EntityPlayer entityPlayer);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IOnBanishTool
|
||||
{
|
||||
public interface IOnBanishTool {
|
||||
int onBanishTool(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand);
|
||||
}
|
||||
@@ -6,7 +6,15 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public interface IOnBreakBlock
|
||||
{
|
||||
int onBlockBroken(ItemStack container, World world, EntityPlayer player, Block block, int meta, int x, int y, int z, ForgeDirection sideBroken);
|
||||
public interface IOnBreakBlock {
|
||||
int onBlockBroken(
|
||||
ItemStack container,
|
||||
World world,
|
||||
EntityPlayer player,
|
||||
Block block,
|
||||
int meta,
|
||||
int x,
|
||||
int y,
|
||||
int z,
|
||||
ForgeDirection sideBroken);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IOnSummonTool
|
||||
{
|
||||
public interface IOnSummonTool {
|
||||
int onSummonTool(ItemStack toolStack, World world, Entity entity);
|
||||
}
|
||||
@@ -4,8 +4,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IProjectileImpactEffect
|
||||
{
|
||||
public interface IProjectileImpactEffect {
|
||||
void onEntityImpact(Entity mop, Entity projectile);
|
||||
|
||||
void onTileImpact(World world, MovingObjectPosition mop);
|
||||
|
||||
@@ -2,7 +2,6 @@ package WayofTime.alchemicalWizardry.api.spell;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IProjectileUpdateEffect
|
||||
{
|
||||
public interface IProjectileUpdateEffect {
|
||||
void onUpdateEffect(Entity projectile);
|
||||
}
|
||||
@@ -5,9 +5,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IRightClickEffect
|
||||
{
|
||||
//public abstract int onRightClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
|
||||
public interface IRightClickEffect {
|
||||
// public abstract int onRightClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
|
||||
|
||||
int onRightClickBlock(ItemStack stack, EntityLivingBase weilder, World world, MovingObjectPosition mop);
|
||||
|
||||
|
||||
Loaded 100 of 795 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user