Testing the creation of hell
This commit is contained in:
parent
796e75b1f9
commit
a2b006105e
2587 changed files with 0 additions and 129617 deletions
|
@ -0,0 +1,36 @@
|
|||
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);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
public interface IRitualStone
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
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 getStoneType()
|
||||
{
|
||||
return this.stoneType;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.Reagent;
|
||||
import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentStack;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class RitualEffect
|
||||
{
|
||||
public abstract void performEffect(IMasterRitualStone ritualStone);
|
||||
|
||||
public boolean startRitual(IMasterRitualStone ritualStone, EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onRitualBroken(IMasterRitualStone ritualStone)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,421 @@
|
|||
package WayofTime.alchemicalWizardry.api.rituals;
|
||||
|
||||
import WayofTime.alchemicalWizardry.common.renderer.MRSRenderer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Rituals
|
||||
{
|
||||
private int crystalLevel;
|
||||
private int actCost;
|
||||
private RitualEffect effect;
|
||||
private String name;
|
||||
|
||||
private 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;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case 1:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getX(), y + rc.getY(), z + rc.getZ());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x + rc.getX(), y + rc.getY(), z + rc.getZ()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getZ(), y + rc.getY(), z + rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x - rc.getZ(), y + rc.getY(), z + rc.getX()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 3:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x - rc.getX(), y + rc.getY(), z - rc.getZ());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x - rc.getX(), y + rc.getY(), z - rc.getZ()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 4:
|
||||
for (RitualComponent rc : ritual)
|
||||
{
|
||||
test = world.getBlock(x + rc.getZ(), y + rc.getY(), z - rc.getX());
|
||||
|
||||
if (!(test instanceof IRitualStone))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x + rc.getZ(), y + rc.getY(), z - rc.getX()) != rc.getStoneType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
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)
|
||||
{
|
||||
if (ritualMap.containsKey(ritualID))
|
||||
{
|
||||
Rituals ritual = ritualMap.get(ritualID);
|
||||
if (ritual != null && ritual.effect != null)
|
||||
{
|
||||
ritual.effect.onRitualBroken(ritualStone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue