Initial Comment

This commit is contained in:
jaredlll08 2015-01-11 21:59:45 +02:00
commit 419ac849d0
276 changed files with 17939 additions and 0 deletions

19
.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
/LICENSE-fml.txt
/MinecraftForge-Credits.txt
/MinecraftForge-License.txt
/README.txt
/CREDITS-fml.txt
/forge-1.7.2*
/build
/common
/eclipse/*
/.gradle
/bin/*
.classpath
.project
.settings/*
src/api/resources/*
run/
.metadata/
/.nb-gradle/private/
/mods/*

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 joshiejack
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3
README.md Normal file
View File

@ -0,0 +1,3 @@
ModTweaker
==========
ModTweaker is an addon for MineTweaker 3. Minetweaker lets you adjust recipes, remove them entirely, or add new recipes. While it has decent mod support, there are many mods that use custom crafting handlers that are not supported natively. ModTweaker plans to provide additional support for as many of these mods over time as possible.

47
build.gradle Normal file
View File

@ -0,0 +1,47 @@
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
apply plugin: 'forge'
version = "${mod_version}"
group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "ModTweaker 2"
minecraft {
version = "${mc_version}-${forge_version}"
runDir = "eclipse"
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

3
gradle.properties Normal file
View File

@ -0,0 +1,3 @@
mc_version=1.7.10
forge_version=10.13.2.1284
mod_version=0.3.0

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Wed Jul 02 15:54:47 CDT 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip

164
gradlew vendored Normal file
View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
libs/Ex-Nihilo-1.37-dev.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,45 @@
package WayofTime.alchemicalWizardry.api;
import net.minecraft.nbt.NBTTagCompound;
public class ColourAndCoords
{
public int colourRed;
public int colourGreen;
public int colourBlue;
public int colourIntensity;
public int xCoord;
public int yCoord;
public int zCoord;
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;
this.colourIntensity = intensity;
this.xCoord = x;
this.yCoord = y;
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 NBTTagCompound writeToNBT(NBTTagCompound tag)
{
tag.setInteger("colourRed", colourRed);
tag.setInteger("colourGreen", colourGreen);
tag.setInteger("colourBlue", colourBlue);
tag.setInteger("colourIntensity", colourIntensity);
tag.setInteger("xCoord", xCoord);
tag.setInteger("yCoord", yCoord);
tag.setInteger("zCoord", zCoord);
return tag;
}
}

View File

@ -0,0 +1,79 @@
package WayofTime.alchemicalWizardry.api.alchemy;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
public class AlchemicalPotionCreationHandler
{
public static ArrayList<AlchemyPotionHandlerComponent> registeredPotionEffects = new ArrayList();
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))
{
return aphc.getPotionID();
}
}
return -1;
}
public static int getPotionTickDurationForStack(ItemStack itemStack)
{
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(itemStack))
{
return aphc.getTickDuration();
}
}
return -1;
}
}
public static boolean containsRegisteredPotionIngredient(ItemStack[] stackList)
{
for (ItemStack is : stackList)
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(is))
{
return true;
}
}
}
return false;
}
public static int getRegisteredPotionIngredientPosition(ItemStack[] stackList)
{
int i = 0;
for (ItemStack is : stackList)
{
for (AlchemyPotionHandlerComponent aphc : registeredPotionEffects)
{
if (aphc.compareItemStack(is))
{
return i;
}
}
i++;
}
return -1;
}
}

View File

@ -0,0 +1,52 @@
package WayofTime.alchemicalWizardry.api.alchemy;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
public class AlchemyPotionHandlerComponent
{
private ItemStack itemStack;
private int potionID;
private 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();
}
} else if (!(itemStack.getItem() instanceof ItemBlock))
{
return comparedStack.getItem().equals(itemStack.getItem()) && comparedStack.getItemDamage() == itemStack.getItemDamage();
}
}
return false;
}
public ItemStack getItemStack()
{
return itemStack;
}
public int getPotionID()
{
return this.potionID;
}
public int getTickDuration()
{
return this.tickDuration;
}
}

View File

@ -0,0 +1,76 @@
package WayofTime.alchemicalWizardry.api.alchemy;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
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)
{
this.potionID = potionID;
this.tickDuration = tickDuration;
this.concentration = concentration;
this.durationFactor = durationFactor;
}
public void setConcentration(int concentration)
{
this.concentration = concentration;
}
public void setDurationFactor(int durationFactor)
{
this.durationFactor = durationFactor;
}
public int getPotionID()
{
return this.potionID;
}
public int getTickDuration()
{
return this.tickDuration;
}
public int getConcentration()
{
return this.concentration;
}
public int getdurationFactor()
{
return this.durationFactor;
}
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));
}
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)
{
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setInteger("potionID", aph.getPotionID());
tagCompound.setInteger("tickDuration", aph.getTickDuration());
tagCompound.setInteger("concentration", aph.getConcentration());
tagCompound.setInteger("durationFactor", aph.getdurationFactor());
return tagCompound;
}
}

View File

@ -0,0 +1,143 @@
package WayofTime.alchemicalWizardry.api.alchemy;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
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)
{
this.output = output;
this.recipe = recipe;
this.amountNeeded = amountNeeded;
this.bloodOrbLevel = bloodOrbLevel;
}
public boolean doesRecipeMatch(ItemStack[] items, int slottedBloodOrbLevel)
{
if (slottedBloodOrbLevel < bloodOrbLevel)
{
return false;
}
ItemStack[] recipe = new ItemStack[5];
if (items.length < 5)
{
return false;
}
if (this.recipe.length != 5)
{
ItemStack[] newRecipe = new ItemStack[5];
for (int i = 0; i < 5; i++)
{
if (i + 1 > this.recipe.length)
{
newRecipe[i] = null;
} else
{
newRecipe[i] = this.recipe[i];
}
}
recipe = newRecipe;
} else
{
recipe = this.recipe;
}
boolean[] checkList = new boolean[5];
for (int i = 0; i < 5; i++)
{
checkList[i] = false;
}
for (int i = 0; i < 5; i++)
{
ItemStack recipeItemStack = recipe[i];
if (recipeItemStack == null)
{
continue;
}
boolean test = false;
for (int j = 0; j < 5; j++)
{
if (checkList[j])
{
continue;
}
ItemStack checkedItemStack = items[j];
if (checkedItemStack == null)
{
continue;
}
boolean quickTest = false;
if (recipeItemStack.getItem() instanceof ItemBlock)
{
if (checkedItemStack.getItem() instanceof ItemBlock)
{
quickTest = true;
}
} else if (!(checkedItemStack.getItem() instanceof ItemBlock))
{
quickTest = true;
}
if (!quickTest)
{
continue;
}
if ((checkedItemStack.getItemDamage() == recipeItemStack.getItemDamage() || OreDictionary.WILDCARD_VALUE == recipeItemStack.getItemDamage()) && checkedItemStack.getItem() == recipeItemStack.getItem())
{
test = true;
checkList[j] = true;
break;
}
}
if (!test)
{
return false;
}
}
return true;
}
public ItemStack getResult()
{
return output.copy();
}
public int getAmountNeeded()
{
return this.amountNeeded;
}
public ItemStack[] getRecipe()
{
return this.recipe;
}
public int getOrbLevel()
{
return this.bloodOrbLevel;
}
}

View File

@ -0,0 +1,85 @@
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;
public class AlchemyRecipeRegistry
{
public static List<AlchemyRecipe> recipes = new ArrayList();
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)
{
return null;
}
if (!(bloodOrb.getItem() instanceof IBloodOrb))
{
return null;
}
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
for (AlchemyRecipe ar : recipes)
{
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
{
return (ar.getResult());
}
}
return null;
}
public static int getAmountNeeded(ItemStack[] recipe, ItemStack bloodOrb)
{
if (bloodOrb == null)
{
return 0;
}
if (!(bloodOrb.getItem() instanceof IBloodOrb))
{
return 0;
}
int bloodOrbLevel = ((IBloodOrb) bloodOrb.getItem()).getOrbLevel();
for (AlchemyRecipe ar : recipes)
{
if (ar.doesRecipeMatch(recipe, bloodOrbLevel))
{
return (ar.getAmountNeeded());
}
}
return 0;
}
public static ItemStack[] getRecipeForItemStack(ItemStack itemStack)
{
for (AlchemyRecipe ar : recipes)
{
ItemStack result = ar.getResult();
if (result != null)
{
if (result.isItemEqual(itemStack))
{
return ar.getRecipe();
}
}
}
return null;
}
}

View File

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IAlchemyGoggles
{
public boolean showIngameHUD(World world, ItemStack stack, EntityPlayer player);
}

View File

@ -0,0 +1,16 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
public interface IReagentContainer
{
public ReagentStack getReagent();
public int getReagentStackAmount();
public int getCapacity();
public int fill(ReagentStack resource, boolean doFill);
public ReagentStack drain(int maxDrain, boolean doDrain);
public ReagentContainerInfo getInfo();
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
import net.minecraftforge.common.util.ForgeDirection;
public interface IReagentHandler
{
int fill(ForgeDirection from, ReagentStack resource, boolean doFill);
ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain);
ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain);
boolean canFill(ForgeDirection from, Reagent reagent);
boolean canDrain(ForgeDirection from, Reagent reagent);
ReagentContainerInfo[] getContainerInfo(ForgeDirection from);
}

View File

@ -0,0 +1,14 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
import java.util.Map;
public interface ISegmentedReagentHandler extends IReagentHandler
{
public int getNumberOfTanks();
public int getTanksTunedToReagent(Reagent reagent);
public void setTanksTunedToReagent(Reagent reagent, int total);
public Map<Reagent, Integer> getAttunedTankMap();
}

View File

@ -0,0 +1,52 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
public class Reagent
{
public final String name;
public static final int REAGENT_SIZE = 1000;
private int colourRed = 0;
private int colourGreen = 0;
private int colourBlue = 0;
private int colourIntensity = 255;
public Reagent(String name)
{
this.name = name;
}
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()
{
return colourRed;
}
public int getColourGreen()
{
return colourGreen;
}
public int getColourBlue()
{
return colourBlue;
}
public int getColourIntensity()
{
return colourIntensity;
}
@Override
public boolean equals(Object o)
{
return o instanceof Reagent ? this == o && name.equals(((Reagent) o).name) : false;
}
}

View File

@ -0,0 +1,153 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
import net.minecraft.nbt.NBTTagCompound;
public class ReagentContainer implements IReagentContainer
{
protected ReagentStack reagentStack;
protected int capacity;
public ReagentContainer(int capacity)
{
this(null, capacity);
}
public ReagentContainer(ReagentStack stack, int capacity)
{
this.reagentStack = stack;
this.capacity = capacity;
}
public ReagentContainer(Reagent reagent, int amount, int capacity)
{
this(new ReagentStack(reagent, amount), capacity);
}
public static ReagentContainer readFromNBT(NBTTagCompound nbt)
{
ReagentStack reagent = ReagentStack.loadReagentStackFromNBT(nbt);
int capacity = nbt.getInteger("capacity");
if (reagent != null)
{
return new ReagentContainer(reagent, capacity);
} else
{
return new ReagentContainer(null, capacity);
}
}
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
if (reagentStack != null)
{
reagentStack.writeToNBT(nbt);
}
nbt.setInteger("capacity", capacity);
return nbt;
}
@Override
public ReagentStack getReagent()
{
return reagentStack;
}
@Override
public int getReagentStackAmount()
{
if (reagentStack == null)
{
return 0;
}
return reagentStack.amount;
}
@Override
public int getCapacity()
{
return capacity;
}
@Override
public int fill(ReagentStack resource, boolean doFill)
{
if (resource == null)
{
return 0;
}
if (!doFill)
{
if (reagentStack == null)
{
return Math.min(capacity, resource.amount);
}
if (!reagentStack.isReagentEqual(resource))
{
return 0;
}
return Math.min(capacity - reagentStack.amount, resource.amount);
}
if (reagentStack == null)
{
reagentStack = new ReagentStack(resource, Math.min(capacity, resource.amount));
return reagentStack.amount;
}
if (!reagentStack.isReagentEqual(resource))
{
return 0;
}
int filled = capacity - reagentStack.amount;
if (resource.amount < filled)
{
reagentStack.amount += resource.amount;
filled = resource.amount;
} else
{
reagentStack.amount = capacity;
}
return filled;
}
@Override
public ReagentStack drain(int maxDrain, boolean doDrain)
{
if (reagentStack == null)
{
return null;
}
int drained = maxDrain;
if (reagentStack.amount < drained)
{
drained = reagentStack.amount;
}
ReagentStack stack = new ReagentStack(reagentStack, drained);
if (doDrain)
{
reagentStack.amount -= drained;
if (reagentStack.amount <= 0)
{
reagentStack = null;
}
}
return stack;
}
@Override
public ReagentContainerInfo getInfo()
{
return new ReagentContainerInfo(this);
}
}

View File

@ -0,0 +1,19 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
public final class ReagentContainerInfo
{
public final ReagentStack reagent;
public final int capacity;
public ReagentContainerInfo(ReagentStack reagent, int capacity)
{
this.reagent = reagent;
this.capacity = capacity;
}
public ReagentContainerInfo(IReagentContainer tank)
{
this.reagent = tank.getReagent();
this.capacity = tank.getCapacity();
}
}

View File

@ -0,0 +1,174 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
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 static Map<String, Reagent> reagentList = new HashMap();
public static Map<ItemStack, ReagentStack> itemToReagentMap = new HashMap();
public static Reagent sanctusReagent;
public static Reagent incendiumReagent;
public static Reagent aquasalusReagent;
public static Reagent magicalesReagent;
public static Reagent aetherReagent;
public static Reagent crepitousReagent;
public static Reagent crystallosReagent;
public static Reagent terraeReagent;
public static Reagent tenebraeReagent;
public static Reagent offensaReagent;
public static Reagent praesidiumReagent;
public static Reagent orbisTerraeReagent;
public static Reagent virtusReagent;
public static Reagent reductusReagent;
public static Reagent potentiaReagent;
public static void initReagents()
{
sanctusReagent = new Reagent("sanctus");
incendiumReagent = new Reagent("incendium");
aquasalusReagent = new Reagent("aquasalus");
magicalesReagent = new Reagent("magicales");
aetherReagent = new Reagent("aether");
crepitousReagent = new Reagent("crepitous");
crystallosReagent = new Reagent("crystallos");
terraeReagent = new Reagent("terrae");
tenebraeReagent = new Reagent("tenebrae");
offensaReagent = new Reagent("offensa");
praesidiumReagent = new Reagent("praesidium");
orbisTerraeReagent = new Reagent("orbisTerrae");
virtusReagent = new Reagent("virtus");
reductusReagent = new Reagent("reductus");
potentiaReagent = new Reagent("potentia");
sanctusReagent.setColour(255, 255, 0, 255);
incendiumReagent.setColour(255, 0, 0, 255);
aquasalusReagent.setColour(0, 0, 255, 255);
magicalesReagent.setColour(150, 0, 146, 255);
aetherReagent.setColour(105, 223, 86, 255);
crepitousReagent.setColour(145, 145, 145, 255);
crystallosReagent.setColour(135, 255, 231, 255);
terraeReagent.setColour(147, 48, 13, 255);
tenebraeReagent.setColour(86, 86, 86, 255);
offensaReagent.setColour(126, 0, 0, 255);
praesidiumReagent.setColour(135, 135, 135, 255);
orbisTerraeReagent.setColour(32, 94, 14, 255);
virtusReagent.setColour(180, 0, 0, 255);
reductusReagent.setColour(20, 93, 2, 255);
potentiaReagent.setColour(64, 81, 208, 255);
registerReagent("sanctus", sanctusReagent);
registerReagent("incendium", incendiumReagent);
registerReagent("aquasalus", aquasalusReagent);
registerReagent("magicales", magicalesReagent);
registerReagent("aether", aetherReagent);
registerReagent("crepitous", crepitousReagent);
registerReagent("crystallos", crystallosReagent);
registerReagent("terrae", terraeReagent);
registerReagent("tenebrae", tenebraeReagent);
registerReagent("offensa", offensaReagent);
registerReagent("praesidium", praesidiumReagent);
registerReagent("orbisTerrae", orbisTerraeReagent);
registerReagent("virtus", virtusReagent);
registerReagent("reductus", reductusReagent);
registerReagent("potentia", potentiaReagent);
}
public static boolean registerReagent(String key, Reagent reagent)
{
if (reagentList.containsKey(key) || reagent == null)
{
return false;
}
reagentList.put(key, reagent);
return true;
}
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))
{
Set<Entry<String, Reagent>> set = reagentList.entrySet();
for (Entry<String, Reagent> entry : set)
{
if (entry.getValue().equals(reagent))
{
return entry.getKey();
}
}
}
return "";
}
public static void registerItemAndReagent(ItemStack stack, ReagentStack reagentStack)
{
itemToReagentMap.put(stack, reagentStack);
}
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)
{
return null;
} else
{
return entry.getValue().copy();
}
}
}
return 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)
{
return null;
} else
{
return entry.getKey().copy();
}
}
}
return null;
}
}

View File

@ -0,0 +1,63 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
import net.minecraft.nbt.NBTTagCompound;
public class ReagentStack
{
public Reagent reagent;
public int amount;
public ReagentStack(Reagent reagent, int amount)
{
this.reagent = reagent;
this.amount = amount;
}
public ReagentStack(ReagentStack reagentStack, int amount)
{
this(reagentStack.reagent, amount);
}
public static ReagentStack loadReagentStackFromNBT(NBTTagCompound tag)
{
Reagent reagent = ReagentRegistry.getReagentForKey(tag.getString("Reagent"));
if (reagent == null)
{
return null;
}
int amount = tag.getInteger("amount");
ReagentStack stack = new ReagentStack(reagent, amount);
return stack;
}
public NBTTagCompound writeToNBT(NBTTagCompound tag)
{
tag.setString("Reagent", ReagentRegistry.getKeyForReagent(this.reagent));
tag.setInteger("amount", this.amount);
return tag;
}
public ReagentStack splitStack(int amount)
{
ReagentStack copyStack = this.copy();
int splitAmount = Math.min(amount, this.amount);
copyStack.amount = splitAmount;
this.amount -= splitAmount;
return copyStack;
}
public ReagentStack copy()
{
return new ReagentStack(this.reagent, this.amount);
}
public boolean isReagentEqual(ReagentStack other)
{
return other != null && this.reagent == other.reagent;
}
}

View File

@ -0,0 +1,66 @@
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
{
protected ReagentContainer tank = new ReagentContainer(4000);
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
tank.readFromNBT(tag);
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
tank.writeToNBT(tag);
}
/* IReagentHandler */
@Override
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()))
{
return null;
}
return tank.drain(resource.amount, doDrain);
}
@Override
public ReagentStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return tank.drain(maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection from, Reagent reagent)
{
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Reagent reagent)
{
return true;
}
@Override
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
{
return new ReagentContainerInfo[]{tank.getInfo()};
}
}

View File

@ -0,0 +1,283 @@
package WayofTime.alchemicalWizardry.api.alchemy.energy;
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
{
protected ReagentContainer[] tanks;
protected Map<Reagent, Integer> attunedTankMap;
public TileSegmentedReagentHandler()
{
this(1);
}
public TileSegmentedReagentHandler(int numberOfTanks)
{
this(numberOfTanks, 1000);
}
public TileSegmentedReagentHandler(int numberOfTanks, int tankSize)
{
super();
this.attunedTankMap = new HashMap();
this.tanks = new ReagentContainer[numberOfTanks];
for (int i = 0; i < numberOfTanks; i++)
{
this.tanks[i] = new ReagentContainer(tankSize);
}
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
super.readFromNBT(tag);
NBTTagList tagList = tag.getTagList("reagentTanks", Constants.NBT.TAG_COMPOUND);
int size = tagList.tagCount();
this.tanks = new ReagentContainer[size];
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++)
{
NBTTagCompound savedTag = attunedTagList.getCompoundTagAt(i);
Reagent reagent = ReagentRegistry.getReagentForKey(savedTag.getString("reagent"));
this.attunedTankMap.put(reagent, savedTag.getInteger("amount"));
}
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
super.writeToNBT(tag);
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < this.tanks.length; i++)
{
NBTTagCompound savedTag = new NBTTagCompound();
if (this.tanks[i] != null)
{
this.tanks[i].writeToNBT(savedTag);
}
tagList.appendTag(savedTag);
}
tag.setTag("reagentTanks", tagList);
NBTTagList attunedTagList = new NBTTagList();
for (Entry<Reagent, Integer> entry : this.attunedTankMap.entrySet())
{
NBTTagCompound savedTag = new NBTTagCompound();
savedTag.setString("reagent", ReagentRegistry.getKeyForReagent(entry.getKey()));
savedTag.setInteger("amount", entry.getValue());
attunedTagList.appendTag(savedTag);
}
tag.setTag("attunedTankMap", attunedTagList);
}
/* ISegmentedReagentHandler */
@Override
public int fill(ForgeDirection from, ReagentStack resource, boolean doFill)
{
int totalFill = 0;
boolean useTankLimit = !this.attunedTankMap.isEmpty();
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--)
{
ReagentStack remainingStack = resource.copy();
remainingStack.amount = maxFill - totalFill;
boolean doesReagentMatch = tanks[i].getReagent() == null ? false : tanks[i].getReagent().isReagentEqual(remainingStack);
if (doesReagentMatch)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
} else
{
continue;
}
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
if (tanksFilled >= totalTanksFillable)
{
return totalFill;
}
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)
{
totalFill += tanks[i].fill(remainingStack, doFill);
tanksFilled++;
} else
{
continue;
}
if (totalFill >= maxFill || tanksFilled >= totalTanksFillable)
{
return totalFill;
}
}
}
return totalFill;
}
@Override
public ReagentStack drain(ForgeDirection from, ReagentStack resource, boolean doDrain)
{
if (resource == null)
{
return null;
}
int maxDrain = resource.amount;
Reagent reagent = resource.reagent;
int drained = 0;
for (int i = 0; i < tanks.length; i++)
{
if (drained >= maxDrain)
{
break;
}
if (resource.isReagentEqual(tanks[i].getReagent()))
{
ReagentStack drainStack = tanks[i].drain(maxDrain - drained, doDrain);
if (drainStack != null)
{
drained += drainStack.amount;
}
}
}
return new ReagentStack(reagent, drained);
}
/* 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++)
{
ReagentStack stack = tanks[i].drain(maxDrain, doDrain);
if (stack != null)
{
return stack;
}
}
return null;
}
@Override
public boolean canFill(ForgeDirection from, Reagent reagent)
{
return true;
}
@Override
public boolean canDrain(ForgeDirection from, Reagent reagent)
{
return true;
}
@Override
public ReagentContainerInfo[] getContainerInfo(ForgeDirection from)
{
ReagentContainerInfo[] info = new ReagentContainerInfo[this.getNumberOfTanks()];
for (int i = 0; i < this.getNumberOfTanks(); i++)
{
info[i] = tanks[i].getInfo();
}
return info;
}
@Override
public int getNumberOfTanks()
{
return tanks.length;
}
@Override
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))
{
this.attunedTankMap.remove(reagent);
return;
}
this.attunedTankMap.put(reagent, new Integer(total));
}
@Override
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)
{
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,134 @@
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
public class AltarRecipe
{
public int minTier;
public int liquidRequired;
public boolean canBeFilled; //Tells the system that the item is an orb
public int consumptionRate;
public int drainRate;
public ItemStack requiredItem;
public ItemStack result;
public boolean useTag;
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;
this.requiredItem = requiredItem;
this.minTier = minTier;
this.liquidRequired = liquidRequired;
this.consumptionRate = consumptionRate;
this.drainRate = drainRate;
this.canBeFilled = canBeFilled;
this.useTag = useTag;
}
public ItemStack getResult()
{
return this.result;
}
public ItemStack getRequiredItem()
{
return this.requiredItem;
}
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((NBTTagCompound) 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()
{
return this.liquidRequired;
}
public int getConsumptionRate()
{
return this.consumptionRate;
}
public int getDrainRate()
{
return this.drainRate;
}
public boolean getCanBeFilled()
{
return this.canBeFilled;
}
}

View File

@ -0,0 +1,65 @@
package WayofTime.alchemicalWizardry.api.altarRecipeRegistry;
import net.minecraft.item.ItemStack;
import java.util.LinkedList;
import java.util.List;
public class AltarRecipeRegistry
{
public static List<AltarRecipe> altarRecipes = new LinkedList();
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 registerAltarOrbRecipe(ItemStack orbStack, int minTier, int consumptionRate)
{
registerAltarRecipe(null, orbStack, minTier, 0, consumptionRate, 0, true);
}
public static boolean isRequiredItemValid(ItemStack testItem, int currentTierAltar)
{
for (AltarRecipe recipe : altarRecipes)
{
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
{
return true;
}
}
return false;
}
public static ItemStack getItemForItemAndTier(ItemStack testItem, int currentTierAltar)
{
for (AltarRecipe recipe : altarRecipes)
{
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
{
return ItemStack.copyItemStack(recipe.getResult());
}
}
return null;
}
public static AltarRecipe getAltarRecipeForItemAndTier(ItemStack testItem, int currentTierAltar)
{
for (AltarRecipe recipe : altarRecipes)
{
if (recipe.doesRequiredItemMatch(testItem, currentTierAltar))
{
return recipe;
}
}
return null;
}
}

View File

@ -0,0 +1,35 @@
package WayofTime.alchemicalWizardry.api.bindingRegistry;
import net.minecraft.item.ItemStack;
public class BindingRecipe
{
public ItemStack requiredItem;
public ItemStack outputItem;
public BindingRecipe(ItemStack outputItem, ItemStack requiredItem)
{
this.requiredItem = requiredItem;
this.outputItem = outputItem;
}
public boolean doesRequiredItemMatch(ItemStack testStack)
{
if (testStack == null || this.requiredItem == null)
{
return false;
}
return this.requiredItem.isItemEqual(testStack);
}
public ItemStack getResult(ItemStack inputItem)
{
return this.getResult();
}
public ItemStack getResult()
{
return this.outputItem;
}
}

View File

@ -0,0 +1,67 @@
package WayofTime.alchemicalWizardry.api.bindingRegistry;
import net.minecraft.item.ItemStack;
import java.util.LinkedList;
import java.util.List;
public class BindingRegistry
{
public static List<BindingRecipe> bindingRecipes = new LinkedList();
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))
{
return true;
}
}
return false;
}
public static ItemStack getItemForItemAndTier(ItemStack testItem)
{
for (BindingRecipe recipe : bindingRecipes)
{
if (recipe.doesRequiredItemMatch(testItem))
{
return recipe.getResult(testItem).copy();
}
}
return null;
}
public static int getIndexForItem(ItemStack testItem)
{
int i = 0;
for (BindingRecipe recipe : bindingRecipes)
{
if (recipe.doesRequiredItemMatch(testItem))
{
return i;
}
i++;
}
return -1;
}
public static ItemStack getOutputForIndex(int index)
{
if (bindingRecipes.size() <= index)
{
return null;
}
return bindingRecipes.get(index).getResult();
}
}

View File

@ -0,0 +1,14 @@
package WayofTime.alchemicalWizardry.api.compress;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public abstract class CompressionHandler
{
/**
* Called to look at the inventory and syphons the required stack. Returns resultant stack if successful, and null if not.
* @param inv The inventory iterated through
* @return The result of the compression
*/
public abstract ItemStack compressInventory(ItemStack[] inv, World world);
}

View File

@ -0,0 +1,67 @@
package WayofTime.alchemicalWizardry.api.compress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
/**
* A registry aimed to help compress items in an inventory into its compressible form.
*
*/
public class CompressionRegistry
{
public static List<CompressionHandler> compressionRegistry = new ArrayList();
public static Map<ItemStack, Integer> thresholdMap = new HashMap();
public static void registerHandler(CompressionHandler handler)
{
compressionRegistry.add(handler);
}
/**
* Registers an item so that it only compresses while above this threshold
* @param stack
* @param threshold
*/
public static void registerItemThreshold(ItemStack stack, int threshold)
{
thresholdMap.put(stack, new Integer(threshold));
}
public static ItemStack compressInventory(ItemStack[] inv, World world)
{
for(CompressionHandler handler : compressionRegistry)
{
ItemStack stack = handler.compressInventory(inv, world);
if(stack != null)
{
return stack;
}
}
return null;
}
public static int getItemThreshold(ItemStack stack)
{
for(Entry<ItemStack, Integer> entry : thresholdMap.entrySet())
{
if(areItemStacksEqual(entry.getKey(), stack))
{
return entry.getValue();
}
}
return 0;
}
public static boolean areItemStacksEqual(ItemStack stack, ItemStack compressedStack)
{
return stack.isItemEqual(compressedStack) && (stack.getTagCompound() == null ? compressedStack.getTagCompound() == null : stack.getTagCompound().equals(compressedStack.getTagCompound()));
}
}

View File

@ -0,0 +1,38 @@
package WayofTime.alchemicalWizardry.api.event;
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;
}
}

View File

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.Event;
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;
}
}

View File

@ -0,0 +1,15 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.eventhandler.Cancelable;
@Cancelable
public class ItemDrainInContainerEvent extends SoulNetworkEvent
{
public ItemStack stack;
public ItemDrainInContainerEvent(ItemStack stack, String ownerNetwork, int drainAmount)
{
super(ownerNetwork, drainAmount);
this.stack = stack;
}
}

View File

@ -0,0 +1,29 @@
package WayofTime.alchemicalWizardry.api.event;
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;
}
}

View File

@ -0,0 +1,18 @@
package WayofTime.alchemicalWizardry.api.event;
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;
}
}

View File

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.api.event;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.eventhandler.Cancelable;
@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;
}
}

View File

@ -0,0 +1,23 @@
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;
@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;
}
}

View File

@ -0,0 +1,18 @@
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;
}
}

View File

@ -0,0 +1,16 @@
package WayofTime.alchemicalWizardry.api.event;
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);
}
}

View File

@ -0,0 +1,15 @@
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;
}
}

View File

@ -0,0 +1,26 @@
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;
}
}

View File

@ -0,0 +1,33 @@
package WayofTime.alchemicalWizardry.api.harvest;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.List;
public class HarvestRegistry
{
public static List<IHarvestHandler> handlerList = new ArrayList();
public static void registerHarvestHandler(IHarvestHandler handler)
{
handlerList.add(handler);
}
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))
{
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,20 @@
package WayofTime.alchemicalWizardry.api.harvest;
import net.minecraft.block.Block;
import net.minecraft.world.World;
public interface IHarvestHandler
{
/**
* A handler that is used to harvest and replant the block at the specified location
*
* @param world
* @param xCoord
* @param yCoord
* @param zCoord
* @param block block at this given location
* @param meta meta at this given location
* @return true if successfully harvested, false if not
*/
public boolean harvestAndPlant(World world, int xCoord, int yCoord, int zCoord, Block block, int meta);
}

View File

@ -0,0 +1,6 @@
package WayofTime.alchemicalWizardry.api.items;
public interface IAltarManipulator
{
}

View File

@ -0,0 +1,806 @@
package WayofTime.alchemicalWizardry.api.items;
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;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
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
{
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()
{
super();
this.setMaxDamage(0);
this.setMaxStackSize(1);
this.setFull3D();
}
@Override
public void registerIcons(IIconRegister iconRegister)
{
this.itemIcon = iconRegister.registerIcon("AlchemicalWizardry:BoundTool");
}
@Override
public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLivingBase, EntityLivingBase par3EntityLivingBase)
{
float damage = this.getCustomItemAttack(par1ItemStack);
SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack);
if (parad != null)
{
parad.onLeftClickEntity(par1ItemStack, par2EntityLivingBase, par3EntityLivingBase);
}
damage += parad.getAddedDamageForEntity(par2EntityLivingBase);
if (rand.nextFloat() < this.getCritChance(par1ItemStack))
{
damage *= 1.75f;
}
if (par3EntityLivingBase instanceof EntityPlayer)
{
par2EntityLivingBase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) par3EntityLivingBase), damage);
} else
{
par2EntityLivingBase.attackEntityFrom(DamageSource.causeMobDamage(par3EntityLivingBase), damage);
}
return true;
}
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
SpellParadigmTool parad = this.loadParadigmFromStack(stack);
if (parad != null && entity instanceof EntityLivingBase)
{
parad.onLeftClickEntity(stack, (EntityLivingBase) entity, player);
}
return false;
}
@Override
public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player)
{
if (player.worldObj.isRemote)
{
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;
int hlvl = -1;
float blockHardness = block.getBlockHardness(world, x, y, z);
MovingObjectPosition mop = APISpellHelper.raytraceFromEntity(world, player, true, 5.0D);
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);
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)
{
boolean cancelHarvest = false;
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))
{
isEffective = true;
}
if (localBlock.getMaterial().isToolNotRequired())
{
isEffective = true;
}
if (!player.capabilities.isCreativeMode)
{
if (isEffective)
{
if (localBlock.removedByPlayer(world, player, x, y, z))
{
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);
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)
{
APISpellHelper.spawnItemListInWorld(newItems, world, x + 0.5f, y + 0.5f, z + 0.5f);
}
world.func_147479_m(x, y, z);
int cost = 0;
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));
if (cost > 0)
{
SoulNetworkHandler.syphonAndDamageFromNetwork(stack, player, cost);
}
} else
{
world.setBlockToAir(x, y, z);
world.func_147479_m(x, y, z);
}
} else
{
world.setBlockToAir(x, y, z);
world.func_147479_m(x, y, z);
}
}
}
}
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};
}
return new Material[0];
}
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)
{
return testString;
}
}
testString = "shovel";
matList = this.getMaterialsForToolclass(testString);
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)
{
return testString;
}
}
return null;
}
public Set<String> getToolClasses(ItemStack stack)
{
Set<String> set = new HashSet();
if (this.getHarvestLevel(stack, "pickaxe") > -1)
{
set.add("pickaxe");
}
if (this.getHarvestLevel(stack, "axe") > -1)
{
set.add("axe");
}
if (this.getHarvestLevel(stack, "shovel") > -1)
{
set.add("shovel");
}
return set;
}
@Override
public float getDigSpeed(ItemStack stack, Block block, int meta)
{
String toolClass = block.getHarvestTool(meta);
if (toolClass == null || toolClass.equals(""))
{
return 1.0f;
}
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
return tag.getFloat(digLevelSuffix + toolClass);
} else
{
stack.setTagCompound(new NBTTagCompound());
}
}
return 1.0f;
}
@Override
public int getHarvestLevel(ItemStack stack, String toolClass)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
if (tag.hasKey(harvestLevelSuffix + toolClass))
{
return tag.getInteger(harvestLevelSuffix + toolClass);
} else
{
return -1;
}
} else
{
stack.setTagCompound(new NBTTagCompound());
}
return -1;
}
@Override
public boolean canHarvestBlock(Block par1Block, ItemStack itemStack)
{
return true;
}
@Override
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)
{
return;
}
SpellParadigmTool parad = this.loadParadigmFromStack(toolStack);
int cost = parad.onUpdate(toolStack, world, par3Entity, par4, par5);
if (par3Entity instanceof EntityPlayer && cost > 0)
SoulNetworkHandler.syphonAndDamageFromNetwork(toolStack, (EntityPlayer) par3Entity, cost);
int duration = Math.max(this.getDuration(toolStack, world), 0);
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);
}
}
@Override
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if (par3EntityPlayer.isSneaking())
{
par3EntityPlayer.setCurrentItemOrArmor(0, this.getContainedCrystal(par1ItemStack));
return par1ItemStack;
}
SpellParadigmTool parad = this.loadParadigmFromStack(par1ItemStack);
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, false);
int cost = 0;
if (mop != null && mop.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK))
{
cost = parad.onRightClickBlock(par1ItemStack, par3EntityPlayer, par2World, mop);
} else
{
cost = parad.onRightClickAir(par1ItemStack, par2World, par3EntityPlayer);
}
if (cost > 0)
{
SoulNetworkHandler.syphonAndDamageFromNetwork(par1ItemStack, par3EntityPlayer, cost);
}
return par1ItemStack;
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)
{
par3List.add("A mace filled with ancient alchemy");
if (!(par1ItemStack.stackTagCompound == null))
{
if (!par1ItemStack.stackTagCompound.getString("ownerName").equals(""))
{
par3List.add("Current owner: " + par1ItemStack.stackTagCompound.getString("ownerName"));
}
for (String str : this.getToolListString(par1ItemStack))
{
par3List.add(str);
}
par3List.add("");
float damage = this.getCustomItemAttack(par1ItemStack);
par3List.add("\u00A79+" + ((int) (damage * 10)) / 10.0f + " " + "Attack Damage");
float critChance = ((int) (this.getCritChance(par1ItemStack) * 1000)) / 10.0f;
par3List.add("\u00A79+" + critChance + "% " + "Crit Chance");
}
}
//--------------Custom methods--------------//
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
{
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setInteger(harvestLevelSuffix + toolClass, Math.max(-1, harvestLevel));
stack.getTagCompound().setTag(tagName, tag);
}
}
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
{
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setFloat(digLevelSuffix + toolClass, digSpeed);
stack.getTagCompound().setTag(tagName, tag);
}
}
public float getDigSpeed(ItemStack stack, String toolClass)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
return tag.getFloat(digLevelSuffix + toolClass);
} else
{
stack.setTagCompound(new NBTTagCompound());
return 0.0f;
}
}
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.stackTagCompound.setTag(tagName, tag);
} else
{
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setFloat("itemAttack", Math.max(damage, 0.0f));
stack.stackTagCompound.setTag(tagName, tag);
}
}
public float getCustomItemAttack(ItemStack stack)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
return tag.getFloat("itemAttack");
} else
{
stack.setTagCompound(new NBTTagCompound());
return 0.0f;
}
}
public ItemStack getContainedCrystal(ItemStack container)
{
if (container.hasTagCompound())
{
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName).getCompoundTag("heldItem");
return ItemStack.loadItemStackFromNBT(tag);
} else
{
container.setTagCompound(new NBTTagCompound());
return null;
}
}
public void setContainedCrystal(ItemStack container, ItemStack crystal)
{
if (container.hasTagCompound())
{
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
NBTTagCompound tag = compTag.getCompoundTag("heldItem");
crystal.writeToNBT(tag);
compTag.setTag("heldItem", tag);
container.getTagCompound().setTag(tagName, compTag);
} else
{
container.setTagCompound(new NBTTagCompound());
NBTTagCompound compTag = container.getTagCompound().getCompoundTag(tagName);
NBTTagCompound tag = compTag.getCompoundTag("heldItem");
crystal.writeToNBT(tag);
compTag.setTag("heldItem", tag);
container.getTagCompound().setTag(tagName, compTag);
}
}
public void setDuration(ItemStack container, World world, int duration)
{
if (world.isRemote)
{
return;
} else
{
World overWorld = DimensionManager.getWorld(0);
long worldtime = overWorld.getTotalWorldTime();
if (container.hasTagCompound())
{
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
tag.setLong("duration", Math.max(duration + worldtime, worldtime));
container.getTagCompound().setTag(tagName, tag);
} else
{
container.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
tag.setLong("duration", Math.max(duration + worldtime, worldtime));
container.getTagCompound().setTag(tagName, tag);
}
}
}
public int getDuration(ItemStack container, World world)
{
if (world.isRemote)
{
return 0;
} else
{
World overWorld = DimensionManager.getWorld(0);
long worldtime = overWorld.getTotalWorldTime();
if (container.hasTagCompound())
{
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
return (int) (tag.getLong("duration") - worldtime);
} else
{
container.setTagCompound(new NBTTagCompound());
return 0;
}
}
}
public void loadParadigmIntoStack(ItemStack container, List<SpellEffect> list)
{
if (!container.hasTagCompound())
{
container.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
NBTTagList effectList = new NBTTagList();
for (SpellEffect eff : list)
{
effectList.appendTag(eff.getTag());
}
tagiest.setTag("Effects", effectList);
container.getTagCompound().setTag(tagName, tagiest);
}
public SpellParadigmTool loadParadigmFromStack(ItemStack container)
{
if (!container.hasTagCompound())
{
container.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
NBTTagList tagList = tagiest.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
List<SpellEffect> spellEffectList = new LinkedList();
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
if (eff != null)
{
spellEffectList.add(eff);
}
}
return SpellParadigmTool.getParadigmForEffectArray(spellEffectList);
}
public void setSilkTouch(ItemStack stack, boolean silkTouch)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setBoolean("silkTouch", silkTouch);
stack.stackTagCompound.setTag(tagName, tag);
} else
{
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setBoolean("silkTouch", silkTouch);
stack.stackTagCompound.setTag(tagName, tag);
}
}
public boolean getSilkTouch(ItemStack stack)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
return tag.getBoolean("silkTouch");
} else
{
stack.setTagCompound(new NBTTagCompound());
return false;
}
}
public void setFortuneLevel(ItemStack stack, int fortune)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
stack.stackTagCompound.setTag(tagName, tag);
} else
{
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
tag.setInteger("fortuneLevel", Math.max(fortune, 0));
stack.stackTagCompound.setTag(tagName, tag);
}
}
public int getFortuneLevel(ItemStack stack)
{
if (stack.hasTagCompound())
{
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(tagName);
return tag.getInteger("fortuneLevel");
} else
{
stack.setTagCompound(new NBTTagCompound());
return 0;
}
}
public List<String> getToolListString(ItemStack container)
{
if (!container.hasTagCompound())
{
container.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
NBTTagList tagList = tagiest.getTagList("ToolTips", Constants.NBT.TAG_COMPOUND);
List<String> toolTipList = new LinkedList();
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
String str = tag.getString("tip");
if (str != null)
{
toolTipList.add(str);
}
}
return toolTipList;
}
public void setToolListString(ItemStack container, List<String> toolTipString)
{
if (!container.hasTagCompound())
{
container.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tagiest = container.getTagCompound().getCompoundTag(tagName);
NBTTagList stringList = new NBTTagList();
for (String str : toolTipString)
{
NBTTagCompound tag = new NBTTagCompound();
tag.setString("tip", str);
stringList.appendTag(tag);
}
tagiest.setTag("ToolTips", stringList);
container.getTagCompound().setTag(tagName, tagiest);
}
public void setCritChance(ItemStack container, float chance)
{
if (container.hasTagCompound())
{
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
tag.setFloat("critChance", Math.max(chance, 0));
container.stackTagCompound.setTag(tagName, tag);
} else
{
container.setTagCompound(new NBTTagCompound());
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
tag.setFloat("critChance", Math.max(chance, 0));
container.stackTagCompound.setTag(tagName, tag);
}
}
public float getCritChance(ItemStack container)
{
if (container.hasTagCompound())
{
NBTTagCompound tag = container.getTagCompound().getCompoundTag(tagName);
return tag.getFloat("critChance");
} else
{
container.setTagCompound(new NBTTagCompound());
return 0;
}
}
}

View File

@ -0,0 +1,281 @@
package WayofTime.alchemicalWizardry.api.items;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
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
{
private static final int MAX_CRAFT_GRID_WIDTH = 3;
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
private ItemStack output = null;
private Object[] input = null;
public int width = 0;
public int height = 0;
private boolean mirrored = true;
public ShapedBloodOrbRecipe(Block result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapedBloodOrbRecipe(Item result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapedBloodOrbRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
String shape = "";
int idx = 0;
if (recipe[idx] instanceof Boolean)
{
mirrored = (Boolean) recipe[idx];
if (recipe[idx + 1] instanceof Object[])
{
recipe = (Object[]) recipe[idx + 1];
} else
{
idx = 1;
}
}
if (recipe[idx] instanceof String[])
{
String[] parts = ((String[]) recipe[idx++]);
for (String s : parts)
{
width = s.length();
shape += s;
}
height = parts.length;
} else
{
while (recipe[idx] instanceof String)
{
String s = (String) recipe[idx++];
shape += s;
width = s.length();
height++;
}
}
if (width * height != shape.length())
{
String ret = "Invalid shaped ore recipe: ";
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
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, (Integer) (((IBloodOrb) ((ItemStack) in).getItem()).getOrbLevel()));
else itemMap.put(chr, (Integer) (((IBloodOrb) in).getOrbLevel()));
} else if (in instanceof ItemStack)
{
itemMap.put(chr, ((ItemStack) in).copy());
} else if (in instanceof Item)
{
itemMap.put(chr, new ItemStack((Item) in));
} else if (in instanceof Block)
{
itemMap.put(chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE));
} else if (in instanceof String)
{
itemMap.put(chr, OreDictionary.getOres((String) in));
} else
{
String ret = "Invalid shaped ore recipe: ";
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
}
input = new Object[width * height];
int x = 0;
for (char chr : shape.toCharArray())
{
input[x++] = itemMap.get(chr);
}
}
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++)
{
ItemStack ingred = recipe.recipeItems[i];
if (ingred == null)
continue;
input[i] = recipe.recipeItems[i];
for (Entry<ItemStack, String> replace : replacements.entrySet())
{
if (OreDictionary.itemMatches(replace.getKey(), ingred, true))
{
input[i] = OreDictionary.getOres(replace.getValue());
break;
}
}
}
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1)
{
return output.copy();
}
@Override
public int getRecipeSize()
{
return input.length;
}
@Override
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))
{
return true;
}
if (mirrored && checkMatch(inv, x, y, true))
{
return true;
}
}
}
return false;
}
@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++)
{
int subX = x - startX;
int subY = y - startY;
Object target = null;
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
{
if (mirror)
{
target = input[width - subX - 1 + subY * width];
} 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)
{
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel() < (Integer) target)
{
return false;
}
} else return false;
} else if (target instanceof ItemStack)
{
if (!OreDictionary.itemMatches((ItemStack) target, slot, false))
{
return false;
}
} else if (target instanceof ArrayList)
{
boolean matched = false;
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) target).iterator();
while (itr.hasNext() && !matched)
{
matched = OreDictionary.itemMatches(itr.next(), slot, false);
}
if (!matched)
{
return false;
}
} else if (target == null && slot != null)
{
return false;
}
}
}
return true;
}
public ShapedBloodOrbRecipe setMirrored(boolean mirror)
{
mirrored = mirror;
return this;
}
public Object[] getInput()
{
return this.input;
}
}

View File

@ -0,0 +1,174 @@
package WayofTime.alchemicalWizardry.api.items;
import WayofTime.alchemicalWizardry.api.items.interfaces.IBloodOrb;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
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
{
private ItemStack output = null;
private ArrayList<Object> input = new ArrayList<Object>();
public ShapelessBloodOrbRecipe(Block result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapelessBloodOrbRecipe(Item result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public ShapelessBloodOrbRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
for (Object in : recipe)
{
if (in instanceof ItemStack)
{
input.add(((ItemStack) in).copy());
} else if (in instanceof IBloodOrb)
{ //If the item is an instanceof IBloodOrb then save the level of the orb
input.add((Integer) (((IBloodOrb) in).getOrbLevel()));
} else if (in instanceof Item)
{
input.add(new ItemStack((Item) in));
} else if (in instanceof Block)
{
input.add(new ItemStack((Block) in));
} else if (in instanceof String)
{
input.add(OreDictionary.getOres((String) in));
} else
{
String ret = "Invalid shapeless ore recipe: ";
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
}
}
@SuppressWarnings("unchecked")
ShapelessBloodOrbRecipe(ShapelessRecipes recipe, Map<ItemStack, String> replacements)
{
output = recipe.getRecipeOutput();
for (ItemStack ingred : ((List<ItemStack>) recipe.recipeItems))
{
Object finalObj = ingred;
for (Entry<ItemStack, String> replace : replacements.entrySet())
{
if (OreDictionary.itemMatches(replace.getKey(), ingred, false))
{
finalObj = OreDictionary.getOres(replace.getValue());
break;
}
}
input.add(finalObj);
}
}
@Override
public int getRecipeSize()
{
return input.size();
}
@Override
public ItemStack getRecipeOutput()
{
return output;
}
@Override
public ItemStack getCraftingResult(InventoryCrafting var1)
{
return output.copy();
}
@SuppressWarnings("unchecked")
@Override
public boolean matches(InventoryCrafting var1, World world)
{
ArrayList<Object> required = new ArrayList<Object>(input);
for (int x = 0; x < var1.getSizeInventory(); x++)
{
ItemStack slot = var1.getStackInSlot(x);
if (slot != null)
{
boolean inRecipe = false;
Iterator<Object> req = required.iterator();
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)
{
IBloodOrb orb = (IBloodOrb) slot.getItem();
if (orb.getOrbLevel() < (Integer) next)
{
return false;
}
} else return false;
} else if (next instanceof ItemStack)
{
match = OreDictionary.itemMatches((ItemStack) next, slot, false);
} else if (next instanceof ArrayList)
{
Iterator<ItemStack> itr = ((ArrayList<ItemStack>) next).iterator();
while (itr.hasNext() && !match)
{
match = OreDictionary.itemMatches(itr.next(), slot, false);
}
}
if (match)
{
inRecipe = true;
required.remove(next);
break;
}
}
if (!inRecipe)
{
return false;
}
}
}
return required.isEmpty();
}
public ArrayList<Object> getInput()
{
return this.input;
}
}

View File

@ -0,0 +1,15 @@
package WayofTime.alchemicalWizardry.api.items.interfaces;
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 void onArmourUpdate(World world, EntityPlayer player, ItemStack thisItemStack);
public boolean isUpgrade();
public int getEnergyForTenSeconds();
}

View File

@ -0,0 +1,5 @@
package WayofTime.alchemicalWizardry.api.items.interfaces;
public interface IBindable
{
}

View File

@ -0,0 +1,8 @@
package WayofTime.alchemicalWizardry.api.items.interfaces;
public interface IBloodOrb
{
public int getMaxEssence();
public int getOrbLevel();
}

View File

@ -0,0 +1,6 @@
package WayofTime.alchemicalWizardry.api.items.interfaces;
public interface IHolding
{
}

View File

@ -0,0 +1,9 @@
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
{
}

View File

@ -0,0 +1,21 @@
package WayofTime.alchemicalWizardry.api.renderer;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.ResourceLocation;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
public abstract class MRSRenderer
{
public abstract void renderAt(IMasterRitualStone tile, double x, double y, double z);
protected void bindTexture(ResourceLocation p_147499_1_)
{
TextureManager texturemanager = TileEntityRendererDispatcher.instance.field_147553_e;
if (texturemanager != null)
{
texturemanager.bindTexture(p_147499_1_);
}
}
}

View File

@ -0,0 +1,40 @@
package WayofTime.alchemicalWizardry.api.rituals;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ISegmentedReagentHandler;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public interface IMasterRitualStone extends ISegmentedReagentHandler
{
public void performRitual(World world, int x, int y, int z, String ritualID);
public String getOwner();
public void setCooldown(int newCooldown);
public int getCooldown();
public void setVar1(int newVar1);
public int getVar1();
public void setActive(boolean active);
public int getDirection();
public World getWorld();
public int getXCoord();
public int getYCoord();
public int getZCoord();
public NBTTagCompound getCustomRitualTag();
public void setCustomRitualTag(NBTTagCompound tag);
public boolean areTanksEmpty();
public int getRunningTime();
}

View File

@ -0,0 +1,18 @@
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
*/
public boolean isRuneType(World world, int x, int y, int z, int meta, int runeType);
}

View File

@ -0,0 +1,6 @@
package WayofTime.alchemicalWizardry.api.rituals;
public interface ITileRitualStone
{
public boolean isRuneType(int runeType);
}

View File

@ -0,0 +1,11 @@
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
}

View File

@ -0,0 +1,71 @@
package WayofTime.alchemicalWizardry.api.rituals;
public class RitualComponent
{
private int x;
private int y;
private int z;
private int stoneType;
public static final int BLANK = 0;
public static final int WATER = 1;
public static final int FIRE = 2;
public static final int EARTH = 3;
public static final int AIR = 4;
public static final int DUSK = 5;
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()
{
return this.x;
}
public int getY()
{
return this.y;
}
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 getStoneType()
{
return this.stoneType;
}
}

View File

@ -0,0 +1,56 @@
package WayofTime.alchemicalWizardry.api.rituals;
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;
public abstract class RitualEffect
{
public abstract void performEffect(IMasterRitualStone ritualStone);
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player)
{
return true;
}
public void onRitualBroken(IMasterRitualStone ritualStone, RitualBreakMethod method)
{
}
public abstract int getCostPerRefresh();
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)
{
return false;
}
ReagentStack reagentStack = new ReagentStack(reagent, amount);
ReagentStack stack = ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, false);
if (stack != null && stack.amount >= amount)
{
if (doDrain)
{
ritualStone.drain(ForgeDirection.UNKNOWN, reagentStack, true);
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,377 @@
package WayofTime.alchemicalWizardry.api.rituals;
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.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 final int actCost;
public final RitualEffect effect;
public final String name;
public final MRSRenderer customRenderer;
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)
{
this.crystalLevel = crystalLevel;
this.actCost = actCost;
this.effect = effect;
this.name = name;
keyList.add(name);
ritualMap.put(name, this);
this.customRenderer = renderer;
}
public Rituals(int crystalLevel, int actCost, RitualEffect effect, String name)
{
this(crystalLevel, actCost, effect, name, null);
}
/**
* Static method to register a ritual to the Ritual Registry
*
* @param key Unique identification key - must be different from all others to properly register
* @param crystalLevel Crystal level required to activate
* @param actCost LP amount required to activate
* @param effect The effect that will be ticked
* @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))
{
return false;
} else
{
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name, renderer);
ritual.removeRitualFromList();
ritualMap.put(key, ritual);
keyList.add(key);
return true;
}
}
public static boolean registerRitual(String key, int crystalLevel, int actCost, RitualEffect effect, String name)
{
if (ritualMap.containsKey(key))
{
return false;
} else
{
Rituals ritual = new Rituals(crystalLevel, actCost, effect, name);
ritual.removeRitualFromList();
ritualMap.put(key, ritual);
keyList.add(key);
return true;
}
}
public void removeRitualFromList()
{
if (ritualMap.containsValue(this))
{
ritualMap.remove(ritualMap.remove(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))
{
return key;
}
}
return "";
}
public static boolean canCrystalActivate(String ritualID, int crystalLevel)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null)
{
return ritual.getCrystalLevel() <= crystalLevel;
}
}
return false;
}
public static boolean checkRitualIsValid(World world, int x, int y, int z, String ritualID)
{
int direction = Rituals.getDirectionOfRitual(world, x, y, z, ritualID);
if (direction != -1)
{
return true;
}
return false;
}
/**
* 1 - NORTH
* 2 - EAST
* 3 - SOUTH
* 4 - WEST
*/
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)
{
return false;
}
Block test = null;
TileEntity te = null;
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())))
{
return false;
}
}
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))
{
return i;
}
}
return -1;
}
public static int getCostForActivation(String ritualID)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null)
{
return ritual.actCost;
}
}
return 0;
}
public static int getInitialCooldown(String ritualID)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null && ritual.effect != null)
{
return ritual.effect.getInitialCooldown();
}
}
return 0;
}
public static List<RitualComponent> getRitualList(String ritualID)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null)
{
return ritual.obtainComponents();
} else
{
return null;
}
} else
{
return null;
}
}
private List<RitualComponent> obtainComponents()
{
return this.effect.getRitualComponentList();
}
private int getCrystalLevel()
{
return this.crystalLevel;
}
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))
{
Rituals ritual = ritualMap.get(event.ritualKey);
if (ritual != null && ritual.effect != null)
{
ritual.effect.performEffect(ritualStone);
}
}
}
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)
{
return ritual.effect.startRitual(ritualStone, player);
}
}
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))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null && ritual.effect != null)
{
ritual.effect.onRitualBroken(ritualStone, method);
}
}
}
public static int getNumberOfRituals()
{
return ritualMap.size();
}
public String getRitualName()
{
return this.name;
}
public static String getNameOfRitual(String id)
{
if (ritualMap.containsKey(id))
{
Rituals ritual = ritualMap.get(id);
if (ritual != null)
{
return ritual.getRitualName();
}
}
return "";
}
public static String getNextRitualKey(String key)
{
boolean hasSpotted = false;
String firstKey = "";
for (String str : keyList)
{
if (firstKey.equals(""))
{
firstKey = str;
}
if (hasSpotted)
{
return str;
}
if (str.equals(key))
{
hasSpotted = true;
}
}
return firstKey;
}
public static String getPreviousRitualKey(String key)
{
boolean hasSpotted = false;
String lastKey = keyList.get(keyList.size() - 1);
for (String str : keyList)
{
if (str.equals(key))
{
hasSpotted = true;
}
if (hasSpotted)
{
return lastKey;
}
lastKey = str;
}
return lastKey;
}
public static MRSRenderer getRendererForKey(String ritualID)
{
if (ritualMap.containsKey(ritualID))
{
Rituals ritual = ritualMap.get(ritualID);
if (ritual != null)
{
return ritual.getRenderer();
}
}
return null;
}
}

View File

@ -0,0 +1,126 @@
package WayofTime.alchemicalWizardry.api.soulNetwork;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.GameProfile;
/**
* Temporary class to hash-out how to create a network not completely tied to the player.
*/
public class ComplexNetworkHandler
{
public static String fileName = "config/BloodMagic/soulnetworkKeys";
static HashMap<UUID, String> keyMap = new HashMap();
public static UUID getUUIDFromPlayer(EntityPlayer player)
{
return player.getPersistentID();
}
public static EntityPlayer getPlayerFromUUID(UUID uuid)
{
MinecraftServer server = MinecraftServer.getServer();
GameProfile gameProfile;
gameProfile = server.func_152358_ax().func_152652_a(uuid);
String str = uuid.toString();
//TODO ServerConfigurationManager d.createPlayerForUser
UUID.fromString(str);
return null;
}
public static String getKeyForPlayer(EntityPlayer player)
{
return "";
}
public static UUID getUUIDForKey(String key)
{
// if (MinecraftServer.getServer() == null)
// {
// return null;
// }
//
// World world = MinecraftServer.getServer().worldServers[0];
// UUIDKeyMap data = (UUIDKeyMap) world.loadItemData(UUIDKeyMap.class, key);
//
// if (data == null)
// {
// data = new UUIDKeyMap(key);
// world.setItemData(key, data);
// }
return null;
}
public static String assignKeyToPlayer(EntityPlayer player)
{
return "";
}
public static void save()
{
keyMap.put(new UUID(0, 0), "test");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(keyMap);
Writer writer;
try
{
writer = new FileWriter(fileName + ".json");
writer.write(json);
writer.close();
} catch (IOException e)
{
e.printStackTrace();
}
}
public static void load()
{
File save = new File(fileName + ".json");
if(save.canRead())
{
Gson gson = new GsonBuilder().setPrettyPrinting().create();
BufferedReader br;
try
{
br = new BufferedReader(new FileReader(save));
HashMap schema = gson.fromJson(br, keyMap.getClass());
keyMap = schema;
if(keyMap != null)
{
for(Entry<UUID, String> entry : keyMap.entrySet())
{
System.out.println("" + entry.getValue() + " gave: "+ entry.getKey());
}
}
} catch (FileNotFoundException e)
{
e.printStackTrace();
}
}
else
{
keyMap = null;
}
}
}

View File

@ -0,0 +1,30 @@
package WayofTime.alchemicalWizardry.api.soulNetwork;
import net.minecraft.nbt.NBTTagCompound;
public class LifeEssenceNetwork extends net.minecraft.world.WorldSavedData
{
public int currentEssence;
public int maxOrb;
public LifeEssenceNetwork(String par1Str)
{
super(par1Str);
currentEssence = 0;
maxOrb = 0;
}
@Override
public void readFromNBT(NBTTagCompound nbttagcompound)
{
currentEssence = nbttagcompound.getInteger("currentEssence");
maxOrb = nbttagcompound.getInteger("maxOrb");
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setInteger("currentEssence", currentEssence);
nbttagcompound.setInteger("maxOrb", maxOrb);
}
}

View File

@ -0,0 +1,458 @@
package WayofTime.alchemicalWizardry.api.soulNetwork;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
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 com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.Event.Result;
public class SoulNetworkHandler
{
public static UUID getUUIDFromPlayer(EntityPlayer player)
{
return player.getPersistentID();
}
public static EntityPlayer getPlayerFromUUID(UUID uuid)
{
MinecraftServer server = MinecraftServer.getServer();
GameProfile gameProfile;
gameProfile = server.func_152358_ax().func_152652_a(uuid);
return null;
}
public static boolean syphonFromNetworkWhileInContainer(ItemStack ist, int damageToBeDone)
{
String ownerName = "";
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
{
ownerName = ist.getTagCompound().getString("ownerName");
}
ItemDrainInContainerEvent event = new ItemDrainInContainerEvent(ist, ownerName, damageToBeDone);
if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Result.DENY)
{
return false;
}
return syphonFromNetwork(event.ownerNetwork, event.drainAmount) >= damageToBeDone;
}
public static int getCurrentMaxOrb(String ownerName)
{
if (MinecraftServer.getServer() == null)
{
return 0;
}
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
return data.maxOrb;
}
public static void setMaxOrbToMax(String ownerName, int maxOrb)
{
if (MinecraftServer.getServer() == null)
{
return;
}
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, ownerName);
if (data == null)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
data.maxOrb = Math.max(maxOrb, data.maxOrb);
data.markDirty();
}
public static int getMaximumForOrbTier(int maxOrb)
{
switch(maxOrb)
{
case 1:
return 5000;
case 2:
return 25000;
case 3:
return 150000;
case 4:
return 1000000;
case 5:
return 10000000;
case 6:
return 30000000;
default:
return 1;
}
}
public static int syphonFromNetwork(ItemStack ist, int damageToBeDone)
{
if (ist.getTagCompound() != null && !(ist.getTagCompound().getString("ownerName").equals("")))
{
String ownerName = ist.getTagCompound().getString("ownerName");
return syphonFromNetwork(ownerName, damageToBeDone);
}
return 0;
}
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)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
if (data.currentEssence >= damageToBeDone)
{
data.currentEssence -= damageToBeDone;
data.markDirty();
return damageToBeDone;
}
return 0;
}
/**
* Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP.
* Does not drain on the client side.
*
* @param ist Owned itemStack
* @param player Player using the item
* @param damageToBeDone
* @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)
{
return false;
}
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;
}
int drainAmount = syphonFromNetwork(event.ownerNetwork, event.drainAmount);
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.
}
int amount = SoulNetworkHandler.syphonFromNetwork(ist, drain);
hurtPlayer(player, drain - amount);
return true;
}
public static boolean syphonAndDamageFromNetwork(String ownerName, EntityPlayer player, int damageToBeDone)
{
if (player.worldObj.isRemote)
{
return false;
}
World world = player.worldObj;
if (world != null)
{
double posX = player.posX;
double posY = player.posY;
double posZ = player.posZ;
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);
return true;
}
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);
}
return false;
}
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)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
return data.currentEssence >= damageToBeDone;
}
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)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
return data.currentEssence;
}
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)
{
data = new LifeEssenceNetwork(ownerName);
world.setItemData(ownerName, data);
}
data.currentEssence = essence;
data.markDirty();
}
/**
* A method to add to an owner's network up to a maximum value.
*
* @param ownerName
* @param addedEssence
* @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)
{
return 0;
}
World world = MinecraftServer.getServer().worldServers[0];
LifeEssenceNetwork data = (LifeEssenceNetwork) world.loadItemData(LifeEssenceNetwork.class, event.ownerNetwork);
if (data == null)
{
data = new LifeEssenceNetwork(event.ownerNetwork);
world.setItemData(event.ownerNetwork, data);
}
int currEss = data.currentEssence;
if (currEss >= event.maximum)
{
return 0;
}
int newEss = Math.min(event.maximum, currEss + event.addedAmount);
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)
{
user.setHealth((user.getHealth() - 1));
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++)
{
user.setHealth((user.getHealth() - 1));
if (user.getHealth() <= 0.0005f)
{
user.onDeath(DamageSource.generic);
break;
}
}
}
}
}
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)
{
if (item.stackTagCompound == null)
{
item.setTagCompound(new NBTTagCompound());
}
if (item.stackTagCompound.getString("ownerName").equals(""))
{
ItemBindEvent event = new ItemBindEvent(player, SoulNetworkHandler.getUsername(player), item);
if(!MinecraftForge.EVENT_BUS.post(event))
{
item.stackTagCompound.setString("ownerName", event.key);
}
}
}
public static void checkAndSetItemOwner(ItemStack item, String ownerName)
{
if (item.stackTagCompound == null)
{
item.setTagCompound(new NBTTagCompound());
}
if (item.stackTagCompound.getString("ownerName").equals(""))
{
item.stackTagCompound.setString("ownerName", ownerName);
}
}
public static String getUsername(EntityPlayer player)
{
return player.getDisplayName();
}
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("")))
{
String ownerName = stack.getTagCompound().getString("ownerName");
SoulNetworkHandler.causeNauseaToPlayer(ownerName);
}
}
public static void causeNauseaToPlayer(String ownerName)
{
EntityPlayer entityOwner = SoulNetworkHandler.getPlayerForUsername(ownerName);
if (entityOwner == null)
{
return;
}
entityOwner.addPotionEffect(new PotionEffect(Potion.confusion.id, 80));
}
public static String getOwnerName(ItemStack item)
{
if (item.stackTagCompound == null)
{
item.setTagCompound(new NBTTagCompound());
}
return item.stackTagCompound.getString("ownerName");
}
}

View File

@ -0,0 +1,228 @@
package WayofTime.alchemicalWizardry.api.spell;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
public class APISpellHelper
{
public static int getPlayerLPTag(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:StoredLP"))
{
return data.getInteger("BM:StoredLP");
}
return 0;
}
public static void setPlayerLPTag(EntityPlayer player, int amount)
{
NBTTagCompound data = player.getEntityData();
data.setInteger("BM:StoredLP", amount);
}
public static int getPlayerMaxLPTag(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:MaxStoredLP"))
{
return data.getInteger("BM:MaxStoredLP");
}
return 0;
}
public static void setPlayerMaxLPTag(EntityPlayer player, int amount)
{
NBTTagCompound data = player.getEntityData();
data.setInteger("BM:MaxStoredLP", amount);
}
public static float getPlayerCurrentReagentAmount(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:StoredReagentAmount"))
{
return data.getFloat("BM:StoredReagentAmount");
}
return 0;
}
public static void setPlayerCurrentReagentAmount(EntityPlayer player, float amount)
{
NBTTagCompound data = player.getEntityData();
data.setFloat("BM:StoredReagentAmount", amount);
}
public static float getPlayerMaxReagentAmount(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:MaxReagentAmount"))
{
return data.getFloat("BM:MaxReagentAmount");
}
return 0;
}
public static void setPlayerMaxReagentAmount(EntityPlayer player, float amount)
{
NBTTagCompound data = player.getEntityData();
data.setFloat("BM:MaxReagentAmount", amount);
}
public static Reagent getPlayerReagentType(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:ReagentType"))
{
return ReagentRegistry.getReagentForKey(data.getString("BM:ReagentType"));
}
return null;
}
public static void setPlayerReagentType(EntityPlayer player, String str)
{
NBTTagCompound data = player.getEntityData();
data.setString("BM:ReagentType", str);
}
public static void setPlayerReagentType(EntityPlayer player, Reagent reagent)
{
setPlayerReagentType(player, ReagentRegistry.getKeyForReagent(reagent));
}
public static int getCurrentAdditionalHP(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:CurrentAddedHP"))
{
return data.getInteger("BM:CurrentAddedHP");
}
return 0;
}
public static void setCurrentAdditionalHP(EntityPlayer player, int amount)
{
NBTTagCompound data = player.getEntityData();
data.setInteger("BM:CurrentAddedHP", amount);
}
public static int getCurrentAdditionalMaxHP(EntityPlayer player)
{
NBTTagCompound data = player.getEntityData();
if(data.hasKey("BM:MaxAddedHP"))
{
return data.getInteger("BM:MaxAddedHP");
}
return 0;
}
public static void setCurrentAdditionalMaxHP(EntityPlayer player, int amount)
{
NBTTagCompound data = player.getEntityData();
data.setInteger("BM:MaxAddedHP", amount);
}
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;
double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) f;
Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
float f5 = -MathHelper.cos(-f1 * 0.017453292F);
float f6 = MathHelper.sin(-f1 * 0.017453292F);
float f7 = f4 * f5;
float f8 = f3 * f5;
double d3 = range;
if (player instanceof EntityPlayerMP)
{
// d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
}
Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
return world.func_147447_a(vec3, vec31, par3, !par3, par3);
}
public static 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)
{
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
ItemStack item = new ItemStack(block, 1, meta);
items.add(item);
return items;
} else
{
return block.getDrops(world, x, y, z, meta, fortune);
}
}
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)
{
case 1:
return "I";
case 2:
return "II";
case 3:
return "III";
case 4:
return "IV";
case 5:
return "V";
case 6:
return "VI";
case 7:
return "VII";
case 8:
return "VIII";
case 9:
return "IX";
case 10:
return "X";
default:
return "";
}
}
}

View File

@ -0,0 +1,92 @@
package WayofTime.alchemicalWizardry.api.spell;
public abstract class ComplexSpellEffect
{
public final ComplexSpellType type;
public final ComplexSpellModifier modifier;
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;
// }
}

View File

@ -0,0 +1,9 @@
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();
}

View File

@ -0,0 +1,9 @@
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();
}

View File

@ -0,0 +1,650 @@
package WayofTime.alchemicalWizardry.api.spell;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.*;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class EntitySpellProjectile extends Entity implements IProjectile
{
private int xTile = -1;
private int yTile = -1;
private int zTile = -1;
private int inTile = 0;
private int inData = 0;
private boolean inGround = false;
/**
* 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
private int maxRicochet = 0;
private float damage = 1;
public List<IProjectileImpactEffect> impactList = new ArrayList();
private boolean penetration = false;
public List<IProjectileUpdateEffect> updateEffectList = new ArrayList();
public List<SpellEffect> spellEffectList = new LinkedList();
private int blocksBroken = 0;
public EntitySpellProjectile(World par1World)
{
super(par1World);
this.setSize(0.5F, 0.5F);
}
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)
{
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);
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);
motionY = -MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI);
this.setThrowableHeading(motionX, motionY, motionZ, par3 * 1.5F, 1.0F);
}
@Override
protected void entityInit()
{
dataWatcher.addObject(16, Byte.valueOf((byte) 0));
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z
* direction.
*/
@Override
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;
var5 /= var9;
var1 += rand.nextGaussian() * 0.007499999832361937D * var8;
var3 += rand.nextGaussian() * 0.007499999832361937D * var8;
var5 += rand.nextGaussian() * 0.007499999832361937D * var8;
var1 *= var7;
var3 *= var7;
var5 *= var7;
motionX = var1;
motionY = var3;
motionZ = var5;
float var10 = MathHelper.sqrt_double(var1 * var1 + var5 * var5);
prevRotationYaw = rotationYaw = (float) (Math.atan2(var1, var5) * 180.0D / Math.PI);
prevRotationPitch = rotationPitch = (float) (Math.atan2(var3, var10) * 180.0D / Math.PI);
}
@Override
@SideOnly(Side.CLIENT)
/**
* 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)
{
this.setPosition(par1, par3, par5);
this.setRotation(par7, par8);
}
@Override
@SideOnly(Side.CLIENT)
/**
* Sets the velocity to the args. Args: x, y, z
*/
public void setVelocity(double par1, double par3, double par5)
{
motionX = par1;
motionY = par3;
motionZ = par5;
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);
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
this.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
}
}
/**
* Called to update the entity's position/logic.
*/
@Override
public void onUpdate()
{
super.onUpdate();
this.performUpdateEffects();
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));
Iterator i = players.iterator();
double closestDistance = Double.MAX_VALUE;
EntityPlayer closestPlayer = null;
while (i.hasNext())
{
EntityPlayer e = (EntityPlayer) i.next();
double distance = e.getDistanceToEntity(this);
if (distance < closestDistance)
{
closestPlayer = e;
}
}
if (closestPlayer != null)
{
shootingEntity = closestPlayer;
}
}
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)
{
var16.setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB var2 = var16.getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (var2 != null && var2.isVecInside(Vec3.createVectorHelper(posX, posY, posZ)))
{
inGround = true;
}
}
if (inGround)
{
Block var18 = worldObj.getBlock(xTile, yTile, zTile);
int var19 = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (var18.equals(Block.getBlockById(inTile)) && var19 == inData)
{
// this.groundImpact();
// this.setDead();
}
} 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++)
{
this.doFiringParticles();
}
}
Vec3 var17 = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition var4 = worldObj.func_147447_a(var17, var3, true, false, false);
var17 = Vec3.createVectorHelper(posX, posY, posZ);
var3 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (var4 != null)
{
var3 = Vec3.createVectorHelper(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));
double var7 = 0.0D;
Iterator var9 = var6.iterator();
float var11;
while (var9.hasNext())
{
Entity var10 = (Entity) var9.next();
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)
{
double var14 = var17.distanceTo(var13.hitVec);
if (var14 < var7 || var7 == 0.0D)
{
var5 = var10;
var7 = var14;
}
}
}
}
if (var5 != null)
{
var4 = new MovingObjectPosition(var5);
}
if (var4 != null)
{
this.onImpact(var4);
if (scheduledForDeath)
{
this.setDead();
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
this.setPosition(posX, posY, posZ);
//this.doBlockCollisions();
}
}
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);
worldObj.spawnParticle("flame", posX, posY, posZ, gaussian(motionX), gaussian(motionY), gaussian(motionZ));
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
@Override
public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
{
par1NBTTagCompound.setShort("xTile", (short) xTile);
par1NBTTagCompound.setShort("yTile", (short) yTile);
par1NBTTagCompound.setShort("zTile", (short) zTile);
par1NBTTagCompound.setByte("inTile", (byte) inTile);
par1NBTTagCompound.setByte("inData", (byte) inData);
par1NBTTagCompound.setByte("inGround", (byte) (inGround ? 1 : 0));
NBTTagList effectList = new NBTTagList();
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);
// }
// }
par1NBTTagCompound.setTag("Effects", effectList);
par1NBTTagCompound.setInteger("blocksBroken", blocksBroken);
par1NBTTagCompound.setBoolean("isSilkTouch", isSilkTouch);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
@Override
public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
{
xTile = par1NBTTagCompound.getShort("xTile");
yTile = par1NBTTagCompound.getShort("yTile");
zTile = par1NBTTagCompound.getShort("zTile");
inTile = par1NBTTagCompound.getByte("inTile") & 255;
inData = par1NBTTagCompound.getByte("inData") & 255;
inGround = par1NBTTagCompound.getByte("inGround") == 1;
blocksBroken = par1NBTTagCompound.getInteger("blocksBroken");
isSilkTouch = par1NBTTagCompound.getBoolean("isSilkTouch");
NBTTagList tagList = par1NBTTagCompound.getTagList("Effects", Constants.NBT.TAG_COMPOUND);
List<SpellEffect> spellEffectList = new LinkedList();
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
SpellEffect eff = SpellEffect.getEffectFromTag(tag);
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"));
// }
//SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForStringArray(effectList);
SpellParadigmProjectile parad = SpellParadigmProjectile.getParadigmForEffectArray(spellEffectList);
parad.applyAllSpellEffects();
parad.prepareProjectile(this);
}
/**
* returns if this entity triggers Block.onEntityWalking on the blocks they
* walk on. used for spiders and wolves to prevent them from trampling crops
*/
@Override
protected boolean canTriggerWalking()
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public float getShadowSize()
{
return 0.0F;
}
/**
* Sets the amount of knockback the arrow applies when it hits a mob.
*/
public void setKnockbackStrength(int par1)
{
}
/**
* If returns false, the item will not inflict any damage against entities.
*/
@Override
public boolean canAttackWithItem()
{
return false;
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
public void setIsCritical(boolean par1)
{
byte var2 = dataWatcher.getWatchableObjectByte(16);
if (par1)
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 | 1)));
} else
{
dataWatcher.updateObject(16, Byte.valueOf((byte) (var2 & -2)));
}
}
/**
* Whether the arrow has a stream of critical hit particles flying behind
* it.
*/
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)
{
if (mop.entityHit == shootingEntity) return;
this.onImpact(mop.entityHit);
this.performEntityImpactEffects(mop.entityHit);
} 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)
{
shootingEntity.attackEntityFrom(DamageSource.causePlayerDamage(shootingEntity), 1);
this.setDead();
} 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 doDamage(float f, Entity mop)
{
mop.attackEntityFrom(this.getDamageSource(), f);
}
private DamageSource getDamageSource()
{
return DamageSource.causePlayerDamage(shootingEntity);
}
private void groundImpact(int sideHit)
{
this.ricochet(sideHit);
}
private double smallGauss(double d)
{
return (worldObj.rand.nextFloat() - 0.5D) * d;
}
private double posGauss(double d)
{
return rand.nextFloat() * 0.5D * d;
}
private double gaussian(double d)
{
return d + d * ((rand.nextFloat() - 0.5D) / 4);
}
private void ricochet(int sideHit)
{
switch (sideHit)
{
case 0:
case 1:
// topHit, bottomHit, reflect Y
motionY = motionY * -1;
break;
case 2:
case 3:
// westHit, eastHit, reflect Z
motionZ = motionZ * -1;
break;
case 4:
case 5:
// southHit, northHit, reflect X
motionX = motionX * -1;
break;
}
ricochetCounter++;
if (ricochetCounter > this.getRicochetMax())
{
scheduledForDeath = true;
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));
break;
case 1:
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));
break;
case 3:
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));
break;
case 5:
worldObj.spawnParticle("smoke", posX, posY, posZ, gaussian(0.1D), gaussian(0.1D), gaussian(0.1D));
break;
}
}
}
}
//Custom stuff
public int getRicochetMax()
{
return this.maxRicochet;
}
public void setRicochetMax(int ricochet)
{
this.maxRicochet = ricochet;
}
public void setImpactList(List<IProjectileImpactEffect> list)
{
this.impactList = list;
}
public void setUpdateEffectList(List<IProjectileUpdateEffect> list)
{
this.updateEffectList = list;
}
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)
{
impactEffect.onTileImpact(worldObj, mop);
}
}
}
private void performUpdateEffects()
{
if (updateEffectList != null)
{
for (IProjectileUpdateEffect updateEffect : updateEffectList)
{
updateEffect.onUpdateEffect(this);
}
}
}
public void setPenetration(boolean penetration)
{
this.penetration = penetration;
}
public float getDamage()
{
return this.damage;
}
public void setDamage(float damage)
{
this.damage = damage;
}
public void setSpellEffectList(List<SpellEffect> list)
{
this.spellEffectList = list;
}
public int getBlocksBroken()
{
return this.blocksBroken;
}
public void setBlocksBroken(int blocksBroken)
{
this.blocksBroken = blocksBroken;
}
public boolean getIsSilkTouch()
{
return this.isSilkTouch;
}
public void setIsSilkTouch(boolean bool)
{
this.isSilkTouch = bool;
}
}

View File

@ -0,0 +1,72 @@
package WayofTime.alchemicalWizardry.api.spell;
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
{
protected float range;
protected float radius;
protected int powerUpgrades;
protected int potencyUpgrades;
protected int costUpgrades;
protected int maxHit;
public ExtrapolatedMeleeEntityEffect(int power, int potency, int cost)
{
this.powerUpgrades = power;
this.potencyUpgrades = potency;
this.costUpgrades = cost;
this.range = 0;
this.radius = 0;
this.maxHit = 1;
}
@Override
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));
int hit = 0;
if (entities != null)
{
for (Entity entity : entities)
{
if (hit < maxHit && !entity.equals(entityPlayer))
{
if (this.entityEffect(world, entity, entityPlayer))
{
hit++;
}
}
}
}
}
protected abstract boolean entityEffect(World world, Entity entity, EntityPlayer player);
public void setRange(float range)
{
this.range = range;
}
public void setRadius(float radius)
{
this.radius = radius;
}
public void setMaxNumberHit(int maxHit)
{
this.maxHit = maxHit;
}
}

View File

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.api.spell;
import WayofTime.alchemicalWizardry.api.items.ItemSpellMultiTool;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IDigAreaEffect
{
public abstract int digSurroundingArea(ItemStack container, World world, EntityPlayer player, MovingObjectPosition blockPos, String usedToolClass, float blockHardness, int harvestLvl, ItemSpellMultiTool itemTool);
}

View File

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.item.ItemStack;
import java.util.List;
public interface IItemManipulator
{
public List<ItemStack> handleItemsOnBlockBroken(ItemStack toolStack, List<ItemStack> itemList);
}

View File

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
public interface ILeftClickEffect
{
public abstract int onLeftClickEntity(ItemStack stack, EntityLivingBase attacked, EntityLivingBase weilder);
}

View File

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public interface IMeleeSpellEntityEffect
{
public void onEntityImpact(World world, EntityPlayer entityPlayer);
}

View File

@ -0,0 +1,9 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
public interface IMeleeSpellWorldEffect
{
public void onWorldEffect(World world, EntityPlayer entityPlayer);
}

View File

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IOnBanishTool
{
public abstract int onBanishTool(ItemStack toolStack, World world, Entity entity, int invSlot, boolean inHand);
}

View File

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public interface IOnBreakBlock
{
public abstract int onBlockBroken(ItemStack container, World world, EntityPlayer player, Block block, int meta, int x, int y, int z, ForgeDirection sideBroken);
}

View File

@ -0,0 +1,10 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public interface IOnSummonTool
{
public abstract int onSummonTool(ItemStack toolStack, World world, Entity entity);
}

View File

@ -0,0 +1,12 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public interface IProjectileImpactEffect
{
public void onEntityImpact(Entity mop, Entity projectile);
public void onTileImpact(World world, MovingObjectPosition mop);
}

View File

@ -0,0 +1,8 @@
package WayofTime.alchemicalWizardry.api.spell;
import net.minecraft.entity.Entity;
public interface IProjectileUpdateEffect
{
public void onUpdateEffect(Entity projectile);
}

Some files were not shown because too many files have changed in this diff Show More